265 lines
11 KiB
Java
265 lines
11 KiB
Java
package net.paladrill.paladrillmod.procedure;
|
|
|
|
import net.paladrill.paladrillmod.item.ItemTitaneIngot;
|
|
import net.paladrill.paladrillmod.item.ItemPaladiumIngot;
|
|
import net.paladrill.paladrillmod.item.ItemOrangeBlueFruit;
|
|
import net.paladrill.paladrillmod.item.ItemOkamiFruit;
|
|
import net.paladrill.paladrillmod.item.ItemKiwano;
|
|
import net.paladrill.paladrillmod.item.ItemEndiumNugget;
|
|
import net.paladrill.paladrillmod.item.ItemEggPlantFruit;
|
|
import net.paladrill.paladrillmod.item.ItemAmethystIngot;
|
|
import net.paladrill.paladrillmod.ElementsPaladrillmodMod;
|
|
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.tileentity.TileEntityLockableLoot;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import java.util.Map;
|
|
|
|
@ElementsPaladrillmodMod.ModElement.Tag
|
|
public class ProcedurePaladiumCrusherGenerateButton extends ElementsPaladrillmodMod.ModElement {
|
|
public ProcedurePaladiumCrusherGenerateButton(ElementsPaladrillmodMod instance) {
|
|
super(instance, 204);
|
|
}
|
|
|
|
public static void executeProcedure(Map<String, Object> dependencies) {
|
|
if (dependencies.get("x") == null) {
|
|
System.err.println("Failed to load dependency x for procedure PaladiumCrusherGenerateButton!");
|
|
return;
|
|
}
|
|
if (dependencies.get("y") == null) {
|
|
System.err.println("Failed to load dependency y for procedure PaladiumCrusherGenerateButton!");
|
|
return;
|
|
}
|
|
if (dependencies.get("z") == null) {
|
|
System.err.println("Failed to load dependency z for procedure PaladiumCrusherGenerateButton!");
|
|
return;
|
|
}
|
|
if (dependencies.get("world") == null) {
|
|
System.err.println("Failed to load dependency world for procedure PaladiumCrusherGenerateButton!");
|
|
return;
|
|
}
|
|
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 (((new Object() {
|
|
public ItemStack getItemStack(BlockPos pos, int sltid) {
|
|
TileEntity inv = world.getTileEntity(pos);
|
|
if (inv instanceof TileEntityLockableLoot)
|
|
return ((TileEntityLockableLoot) inv).getStackInSlot(sltid);
|
|
return ItemStack.EMPTY;
|
|
}
|
|
}.getItemStack(new BlockPos((int) x, (int) y, (int) z), (int) (0))).getItem() == new ItemStack(ItemOrangeBlueFruit.block, (int) (1))
|
|
.getItem())) {
|
|
if ((Math.random() < (new Object() {
|
|
public double getValue(BlockPos pos, String tag) {
|
|
TileEntity tileEntity = world.getTileEntity(pos);
|
|
if (tileEntity != null)
|
|
return tileEntity.getTileData().getDouble(tag);
|
|
return -1;
|
|
}
|
|
}.getValue(new BlockPos((int) x, (int) y, (int) z), "luck")))) {
|
|
{
|
|
TileEntity inv = world.getTileEntity(new BlockPos((int) x, (int) y, (int) z));
|
|
if (inv != null && (inv instanceof TileEntityLockableLoot)) {
|
|
ItemStack _setstack = new ItemStack(ItemEndiumNugget.block, (int) (1));
|
|
_setstack.setCount(((new Object() {
|
|
public int getAmount(BlockPos pos, int sltid) {
|
|
TileEntity inv = world.getTileEntity(pos);
|
|
if (inv instanceof TileEntityLockableLoot) {
|
|
ItemStack stack = ((TileEntityLockableLoot) inv).getStackInSlot(sltid);
|
|
if (stack != null)
|
|
return stack.getCount();
|
|
}
|
|
return 0;
|
|
}
|
|
}.getAmount(new BlockPos((int) x, (int) y, (int) z), (int) (2))) + 1));
|
|
((TileEntityLockableLoot) inv).setInventorySlotContents((int) (2), _setstack);
|
|
}
|
|
}
|
|
if (!world.isRemote) {
|
|
BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
|
|
TileEntity _tileEntity = world.getTileEntity(_bp);
|
|
IBlockState _bs = world.getBlockState(_bp);
|
|
if (_tileEntity != null)
|
|
_tileEntity.getTileData().setDouble("luck", 0);
|
|
world.notifyBlockUpdate(_bp, _bs, _bs, 3);
|
|
}
|
|
} else {
|
|
if (!world.isRemote) {
|
|
BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
|
|
TileEntity _tileEntity = world.getTileEntity(_bp);
|
|
IBlockState _bs = world.getBlockState(_bp);
|
|
if (_tileEntity != null)
|
|
_tileEntity.getTileData().setDouble("luck", 0);
|
|
world.notifyBlockUpdate(_bp, _bs, _bs, 3);
|
|
}
|
|
}
|
|
}
|
|
if (((new Object() {
|
|
public ItemStack getItemStack(BlockPos pos, int sltid) {
|
|
TileEntity inv = world.getTileEntity(pos);
|
|
if (inv instanceof TileEntityLockableLoot)
|
|
return ((TileEntityLockableLoot) inv).getStackInSlot(sltid);
|
|
return ItemStack.EMPTY;
|
|
}
|
|
}.getItemStack(new BlockPos((int) x, (int) y, (int) z), (int) (0))).getItem() == new ItemStack(ItemKiwano.block, (int) (1)).getItem())) {
|
|
if ((Math.random() < (new Object() {
|
|
public double getValue(BlockPos pos, String tag) {
|
|
TileEntity tileEntity = world.getTileEntity(pos);
|
|
if (tileEntity != null)
|
|
return tileEntity.getTileData().getDouble(tag);
|
|
return -1;
|
|
}
|
|
}.getValue(new BlockPos((int) x, (int) y, (int) z), "luck")))) {
|
|
{
|
|
TileEntity inv = world.getTileEntity(new BlockPos((int) x, (int) y, (int) z));
|
|
if (inv != null && (inv instanceof TileEntityLockableLoot)) {
|
|
ItemStack _setstack = new ItemStack(ItemPaladiumIngot.block, (int) (1));
|
|
_setstack.setCount(((new Object() {
|
|
public int getAmount(BlockPos pos, int sltid) {
|
|
TileEntity inv = world.getTileEntity(pos);
|
|
if (inv instanceof TileEntityLockableLoot) {
|
|
ItemStack stack = ((TileEntityLockableLoot) inv).getStackInSlot(sltid);
|
|
if (stack != null)
|
|
return stack.getCount();
|
|
}
|
|
return 0;
|
|
}
|
|
}.getAmount(new BlockPos((int) x, (int) y, (int) z), (int) (2))) + 1));
|
|
((TileEntityLockableLoot) inv).setInventorySlotContents((int) (2), _setstack);
|
|
}
|
|
}
|
|
if (!world.isRemote) {
|
|
BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
|
|
TileEntity _tileEntity = world.getTileEntity(_bp);
|
|
IBlockState _bs = world.getBlockState(_bp);
|
|
if (_tileEntity != null)
|
|
_tileEntity.getTileData().setDouble("luck", 0);
|
|
world.notifyBlockUpdate(_bp, _bs, _bs, 3);
|
|
}
|
|
} else {
|
|
if (!world.isRemote) {
|
|
BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
|
|
TileEntity _tileEntity = world.getTileEntity(_bp);
|
|
IBlockState _bs = world.getBlockState(_bp);
|
|
if (_tileEntity != null)
|
|
_tileEntity.getTileData().setDouble("luck", 0);
|
|
world.notifyBlockUpdate(_bp, _bs, _bs, 3);
|
|
}
|
|
}
|
|
}
|
|
if (((new Object() {
|
|
public ItemStack getItemStack(BlockPos pos, int sltid) {
|
|
TileEntity inv = world.getTileEntity(pos);
|
|
if (inv instanceof TileEntityLockableLoot)
|
|
return ((TileEntityLockableLoot) inv).getStackInSlot(sltid);
|
|
return ItemStack.EMPTY;
|
|
}
|
|
}.getItemStack(new BlockPos((int) x, (int) y, (int) z), (int) (0))).getItem() == new ItemStack(ItemEggPlantFruit.block, (int) (1))
|
|
.getItem())) {
|
|
if ((Math.random() < (new Object() {
|
|
public double getValue(BlockPos pos, String tag) {
|
|
TileEntity tileEntity = world.getTileEntity(pos);
|
|
if (tileEntity != null)
|
|
return tileEntity.getTileData().getDouble(tag);
|
|
return -1;
|
|
}
|
|
}.getValue(new BlockPos((int) x, (int) y, (int) z), "luck")))) {
|
|
{
|
|
TileEntity inv = world.getTileEntity(new BlockPos((int) x, (int) y, (int) z));
|
|
if (inv != null && (inv instanceof TileEntityLockableLoot)) {
|
|
ItemStack _setstack = new ItemStack(ItemAmethystIngot.block, (int) (1));
|
|
_setstack.setCount(((new Object() {
|
|
public int getAmount(BlockPos pos, int sltid) {
|
|
TileEntity inv = world.getTileEntity(pos);
|
|
if (inv instanceof TileEntityLockableLoot) {
|
|
ItemStack stack = ((TileEntityLockableLoot) inv).getStackInSlot(sltid);
|
|
if (stack != null)
|
|
return stack.getCount();
|
|
}
|
|
return 0;
|
|
}
|
|
}.getAmount(new BlockPos((int) x, (int) y, (int) z), (int) (2))) + 1));
|
|
((TileEntityLockableLoot) inv).setInventorySlotContents((int) (2), _setstack);
|
|
}
|
|
}
|
|
if (!world.isRemote) {
|
|
BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
|
|
TileEntity _tileEntity = world.getTileEntity(_bp);
|
|
IBlockState _bs = world.getBlockState(_bp);
|
|
if (_tileEntity != null)
|
|
_tileEntity.getTileData().setDouble("luck", 0);
|
|
world.notifyBlockUpdate(_bp, _bs, _bs, 3);
|
|
}
|
|
} else {
|
|
if (!world.isRemote) {
|
|
BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
|
|
TileEntity _tileEntity = world.getTileEntity(_bp);
|
|
IBlockState _bs = world.getBlockState(_bp);
|
|
if (_tileEntity != null)
|
|
_tileEntity.getTileData().setDouble("luck", 0);
|
|
world.notifyBlockUpdate(_bp, _bs, _bs, 3);
|
|
}
|
|
}
|
|
}
|
|
if (((new Object() {
|
|
public ItemStack getItemStack(BlockPos pos, int sltid) {
|
|
TileEntity inv = world.getTileEntity(pos);
|
|
if (inv instanceof TileEntityLockableLoot)
|
|
return ((TileEntityLockableLoot) inv).getStackInSlot(sltid);
|
|
return ItemStack.EMPTY;
|
|
}
|
|
}.getItemStack(new BlockPos((int) x, (int) y, (int) z), (int) (0))).getItem() == new ItemStack(ItemOkamiFruit.block, (int) (1)).getItem())) {
|
|
if ((Math.random() < (new Object() {
|
|
public double getValue(BlockPos pos, String tag) {
|
|
TileEntity tileEntity = world.getTileEntity(pos);
|
|
if (tileEntity != null)
|
|
return tileEntity.getTileData().getDouble(tag);
|
|
return -1;
|
|
}
|
|
}.getValue(new BlockPos((int) x, (int) y, (int) z), "luck")))) {
|
|
{
|
|
TileEntity inv = world.getTileEntity(new BlockPos((int) x, (int) y, (int) z));
|
|
if (inv != null && (inv instanceof TileEntityLockableLoot)) {
|
|
ItemStack _setstack = new ItemStack(ItemTitaneIngot.block, (int) (1));
|
|
_setstack.setCount(((new Object() {
|
|
public int getAmount(BlockPos pos, int sltid) {
|
|
TileEntity inv = world.getTileEntity(pos);
|
|
if (inv instanceof TileEntityLockableLoot) {
|
|
ItemStack stack = ((TileEntityLockableLoot) inv).getStackInSlot(sltid);
|
|
if (stack != null)
|
|
return stack.getCount();
|
|
}
|
|
return 0;
|
|
}
|
|
}.getAmount(new BlockPos((int) x, (int) y, (int) z), (int) (2))) + 1));
|
|
((TileEntityLockableLoot) inv).setInventorySlotContents((int) (2), _setstack);
|
|
}
|
|
}
|
|
if (!world.isRemote) {
|
|
BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
|
|
TileEntity _tileEntity = world.getTileEntity(_bp);
|
|
IBlockState _bs = world.getBlockState(_bp);
|
|
if (_tileEntity != null)
|
|
_tileEntity.getTileData().setDouble("luck", 0);
|
|
world.notifyBlockUpdate(_bp, _bs, _bs, 3);
|
|
}
|
|
} else {
|
|
if (!world.isRemote) {
|
|
BlockPos _bp = new BlockPos((int) x, (int) y, (int) z);
|
|
TileEntity _tileEntity = world.getTileEntity(_bp);
|
|
IBlockState _bs = world.getBlockState(_bp);
|
|
if (_tileEntity != null)
|
|
_tileEntity.getTileData().setDouble("luck", 0);
|
|
world.notifyBlockUpdate(_bp, _bs, _bs, 3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|