package studio.halbear.hem.procedures;

import studio.halbear.hem.HemMod;

import net.minecraft.item.ItemStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.Entity;

import java.util.Map;

public class GasCanister612litreItemInInventoryTickProcedure {

	public static void executeProcedure(Map<String, Object> dependencies) {
		if (dependencies.get("entity") == null) {
			if (!dependencies.containsKey("entity"))
				HemMod.LOGGER.warn("Failed to load dependency entity for procedure GasCanister612litreItemInInventoryTick!");
			return;
		}
		if (dependencies.get("itemstack") == null) {
			if (!dependencies.containsKey("itemstack"))
				HemMod.LOGGER.warn("Failed to load dependency itemstack for procedure GasCanister612litreItemInInventoryTick!");
			return;
		}
		Entity entity = (Entity) dependencies.get("entity");
		ItemStack itemstack = (ItemStack) dependencies.get("itemstack");
		double Force = 0;
		double Weight = 0;
		if (!itemstack.getOrCreateTag().getBoolean("Setup")) {
			itemstack.getOrCreateTag().putBoolean("Setup", (true));
			itemstack.getOrCreateTag().putDouble("GasFilled", 612);
			itemstack.getOrCreateTag().putString("Contents", "Helium");
		}
		if ((itemstack.getOrCreateTag().getString("Contents")).equals("Helium")) {
			Weight = (10000 * (110 + ((entity instanceof LivingEntity) ? ((LivingEntity) entity).getTotalArmorValue() : 0)));
			Force = ((itemstack.getOrCreateTag().getDouble("GasFilled") * (itemstack).getCount()) / Weight);
			entity.setMotion(entity.getMotion().getX(), entity.getMotion().getY() + Force, entity.getMotion().getZ());
		}
	}
}
