Files
mc/mods/pala/legacy-src-backup/net/paladrill/paladrillmod/procedure/ProcedureOkamiRightClickedOnBlock.java
T

66 lines
2.9 KiB
Java

package net.paladrill.paladrillmod.procedure;
import net.paladrill.paladrillmod.item.ItemOkamiSeeds;
import net.paladrill.paladrillmod.block.BlockOkamiStage0;
import net.paladrill.paladrillmod.ElementsPaladrillmodMod;
import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.minecraft.item.ItemStack;
import net.minecraft.init.Blocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;
import java.util.Map;
@ElementsPaladrillmodMod.ModElement.Tag
public class ProcedureOkamiRightClickedOnBlock extends ElementsPaladrillmodMod.ModElement {
public ProcedureOkamiRightClickedOnBlock(ElementsPaladrillmodMod instance) {
super(instance, 278);
}
public static void executeProcedure(Map<String, Object> dependencies) {
if (dependencies.get("entity") == null) {
System.err.println("Failed to load dependency entity for procedure OkamiRightClickedOnBlock!");
return;
}
if (dependencies.get("x") == null) {
System.err.println("Failed to load dependency x for procedure OkamiRightClickedOnBlock!");
return;
}
if (dependencies.get("y") == null) {
System.err.println("Failed to load dependency y for procedure OkamiRightClickedOnBlock!");
return;
}
if (dependencies.get("z") == null) {
System.err.println("Failed to load dependency z for procedure OkamiRightClickedOnBlock!");
return;
}
if (dependencies.get("world") == null) {
System.err.println("Failed to load dependency world for procedure OkamiRightClickedOnBlock!");
return;
}
Entity entity = (Entity) dependencies.get("entity");
int x = (int) dependencies.get("x");
int y = (int) dependencies.get("y");
int z = (int) dependencies.get("z");
World world = (World) dependencies.get("world");
if (((((entity instanceof EntityLivingBase) ? ((EntityLivingBase) entity).getHeldItemMainhand() : ItemStack.EMPTY)
.getItem() == new ItemStack(ItemOkamiSeeds.block, (int) (1)).getItem())
&& (((world.getBlockState(new BlockPos((int) x, (int) y, (int) z))).getBlock() == Blocks.FARMLAND.getDefaultState().getBlock())
&& (((world.getBlockState(new BlockPos((int) x, (int) (y + 1), (int) z))).getBlock() == Blocks.AIR.getDefaultState()
.getBlock())
|| (((world.getBlockState(new BlockPos((int) x, (int) (y + 1), (int) z))).getBlock() == Blocks.AIR.getDefaultState()
.getBlock())
|| ((world.getBlockState(new BlockPos((int) x, (int) (y + 1), (int) z))).getBlock() == Blocks.AIR
.getDefaultState().getBlock())))))) {
world.setBlockState(new BlockPos((int) x, (int) (y + 1), (int) z), BlockOkamiStage0.block.getDefaultState(), 3);
if ((!((entity instanceof EntityPlayer) ? ((EntityPlayer) entity).capabilities.isCreativeMode : false))) {
if (entity instanceof EntityPlayer)
((EntityPlayer) entity).inventory.clearMatchingItems(new ItemStack(ItemOkamiSeeds.block, (int) (1)).getItem(), -1, (int) 1, null);
}
}
}
}