Trying to work out an NEI handler...

This commit is contained in:
oitsjustjose 2015-10-23 14:03:45 -04:00
commit c50eaf8263
35 changed files with 2905 additions and 2266 deletions

View file

@ -23,6 +23,7 @@ import net.minecraft.world.World;
public class BlockCropomator extends BlockMachineBase public class BlockCropomator extends BlockMachineBase
{ {
private static String unlocName = "Cropomator"; private static String unlocName = "Cropomator";
public BlockCropomator() public BlockCropomator()
{ {
super(unlocName); super(unlocName);
@ -41,55 +42,58 @@ public class BlockCropomator extends BlockMachineBase
} }
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) public void breakBlock(World world, int x, int y, int z, Block block, int meta)
{ {
Random random = new Random(); Random random = new Random();
TileEntityCropomator tile = (TileEntityCropomator)world.getTileEntity(x, y, z); TileEntityCropomator tile = (TileEntityCropomator) world.getTileEntity(x, y, z);
if (tile != null) if (tile != null)
{ {
for (int i = 0; i < tile.getSizeInventory(); ++i) for (int i = 0; i < tile.getSizeInventory(); ++i)
{ {
ItemStack itemstack = tile.getStackInSlot(i); ItemStack itemstack = tile.getStackInSlot(i);
if (itemstack != null) if (itemstack != null)
{ {
float f = random.nextFloat() * 0.8F + 0.1F; float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F; float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F; float f2 = random.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0) while (itemstack.stackSize > 0)
{ {
int j = random.nextInt(21) + 10; int j = random.nextInt(21) + 10;
if (j > itemstack.stackSize) if (j > itemstack.stackSize)
{ {
j = itemstack.stackSize; j = itemstack.stackSize;
} }
itemstack.stackSize -= j; itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); EntityItem entityitem = new EntityItem(world, (double) ((float) x + f),
(double) ((float) y + f1), (double) ((float) z + f2),
new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) if (itemstack.hasTagCompound())
{ {
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); entityitem.getEntityItem()
} .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F; float f3 = 0.05F;
entityitem.motionX = (double)((float)random.nextGaussian() * f3); entityitem.motionX = (double) ((float) random.nextGaussian() * f3);
entityitem.motionY = (double)((float)random.nextGaussian() * f3 + 0.2F); entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)random.nextGaussian() * f3); entityitem.motionZ = (double) ((float) random.nextGaussian() * f3);
world.spawnEntityInWorld(entityitem); world.spawnEntityInWorld(entityitem);
} }
} }
} }
world.func_147453_f(x, y, z, block); world.func_147453_f(x, y, z, block);
} }
super.breakBlock(world, x, y, z, block, meta); super.breakBlock(world, x, y, z, block, meta);
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int meta) public TileEntity createNewTileEntity(World world, int meta)
@ -98,16 +102,16 @@ public class BlockCropomator extends BlockMachineBase
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
float hitY, float hitZ)
{ {
if(world.isRemote) if (world.isRemote)
{ {
return true; return true;
} } else
else
{ {
TileEntityCropomator tilecropomator = (TileEntityCropomator)world.getTileEntity(x, y, z); TileEntityCropomator tilecropomator = (TileEntityCropomator) world.getTileEntity(x, y, z);
if(tilecropomator != null) if (tilecropomator != null)
player.openGui(CrissCross.instance, GUIHandler.Cropomator, world, x, y, z); player.openGui(CrissCross.instance, GUIHandler.Cropomator, world, x, y, z);
return true; return true;
} }

View file

@ -23,6 +23,7 @@ import net.minecraft.world.World;
public class BlockElectroextractor extends BlockMachineBase public class BlockElectroextractor extends BlockMachineBase
{ {
private static String unlocName = "ElectroExtractor"; private static String unlocName = "ElectroExtractor";
public BlockElectroextractor() public BlockElectroextractor()
{ {
super(unlocName); super(unlocName);
@ -47,67 +48,70 @@ public class BlockElectroextractor extends BlockMachineBase
} }
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) public void breakBlock(World world, int x, int y, int z, Block block, int meta)
{ {
Random random = new Random(); Random random = new Random();
TileEntityElectroextractor tile = (TileEntityElectroextractor)world.getTileEntity(x, y, z); TileEntityElectroextractor tile = (TileEntityElectroextractor) world.getTileEntity(x, y, z);
if (tile != null) if (tile != null)
{ {
for (int i = 0; i < tile.getSizeInventory(); ++i) for (int i = 0; i < tile.getSizeInventory(); ++i)
{ {
ItemStack itemstack = tile.getStackInSlot(i); ItemStack itemstack = tile.getStackInSlot(i);
if (itemstack != null) if (itemstack != null)
{ {
float f = random.nextFloat() * 0.8F + 0.1F; float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F; float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F; float f2 = random.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0) while (itemstack.stackSize > 0)
{ {
int j = random.nextInt(21) + 10; int j = random.nextInt(21) + 10;
if (j > itemstack.stackSize) if (j > itemstack.stackSize)
{ {
j = itemstack.stackSize; j = itemstack.stackSize;
} }
itemstack.stackSize -= j; itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); EntityItem entityitem = new EntityItem(world, (double) ((float) x + f),
(double) ((float) y + f1), (double) ((float) z + f2),
new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) if (itemstack.hasTagCompound())
{ {
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); entityitem.getEntityItem()
} .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F; float f3 = 0.05F;
entityitem.motionX = (double)((float)random.nextGaussian() * f3); entityitem.motionX = (double) ((float) random.nextGaussian() * f3);
entityitem.motionY = (double)((float)random.nextGaussian() * f3 + 0.2F); entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)random.nextGaussian() * f3); entityitem.motionZ = (double) ((float) random.nextGaussian() * f3);
world.spawnEntityInWorld(entityitem); world.spawnEntityInWorld(entityitem);
} }
} }
} }
world.func_147453_f(x, y, z, block); world.func_147453_f(x, y, z, block);
} }
super.breakBlock(world, x, y, z, block, meta); super.breakBlock(world, x, y, z, block, meta);
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
float hitY, float hitZ)
{ {
if(world.isRemote) if (world.isRemote)
{ {
return true; return true;
} } else
else
{ {
TileEntityElectroextractor tileext = (TileEntityElectroextractor)world.getTileEntity(x, y, z); TileEntityElectroextractor tileext = (TileEntityElectroextractor) world.getTileEntity(x, y, z);
if(tileext != null) if (tileext != null)
player.openGui(CrissCross.instance, GUIHandler.Electroextractor, world, x, y, z); player.openGui(CrissCross.instance, GUIHandler.Electroextractor, world, x, y, z);
return true; return true;
} }

View file

@ -26,44 +26,44 @@ public class BlockMachineBase extends BlockContainer
public BlockMachineBase(String unlocName) public BlockMachineBase(String unlocName)
{ {
super(Material.rock); //0 - Top super(Material.rock); // 0 - Top
this.setHardness(2.0F); //1 - Bottom this.setHardness(2.0F); // 1 - Bottom
this.setResistance(2.0F); //3 - Front this.setResistance(2.0F); // 3 - Front
this.setStepSound(soundTypeMetal); //4 - Sides this.setStepSound(soundTypeMetal); // 4 - Sides
this.setBlockName(Reference.modid + "." + unlocName); this.setBlockName(Reference.modid + "." + unlocName);
this.setCreativeTab(CrissCross.CCTab); this.setCreativeTab(CrissCross.CCTab);
this.unlocalizedName = unlocName; this.unlocalizedName = unlocName;
} }
//Used for the ItemStack vs. In-world Rendering // Used for the ItemStack vs. In-world Rendering
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) public IIcon getIcon(int side, int meta)
{ {
if(side == 0) if (side == 0)
return blockTextures[0]; return blockTextures[0];
if(side == 1) if (side == 1)
return blockTextures[1]; return blockTextures[1];
if(side == 3) if (side == 3)
return blockTextures[2]; return blockTextures[2];
return blockTextures[3]; return blockTextures[3];
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side)
{ {
if(side == 0) if (side == 0)
return blockTextures[0]; return blockTextures[0];
if(side == 1) if (side == 1)
return blockTextures[1]; return blockTextures[1];
if(side == access.getBlockMetadata(x, y, z)) if (side == access.getBlockMetadata(x, y, z))
return blockTextures[2]; return blockTextures[2];
return blockTextures[3]; return blockTextures[3];
} }
@Override @Override
public void onBlockAdded(World world, int x, int y, int z) public void onBlockAdded(World world, int x, int y, int z)
@ -73,69 +73,69 @@ public class BlockMachineBase extends BlockContainer
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack) public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
{ {
int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int l = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (l == 0) if (l == 0)
{ {
world.setBlockMetadataWithNotify(x, y, z, 2, 2); world.setBlockMetadataWithNotify(x, y, z, 2, 2);
} }
if (l == 1) if (l == 1)
{ {
world.setBlockMetadataWithNotify(x, y, z, 5, 2); world.setBlockMetadataWithNotify(x, y, z, 5, 2);
} }
if (l == 2) if (l == 2)
{ {
world.setBlockMetadataWithNotify(x, y, z, 3, 2); world.setBlockMetadataWithNotify(x, y, z, 3, 2);
} }
if (l == 3) if (l == 3)
{ {
world.setBlockMetadataWithNotify(x, y, z, 4, 2); world.setBlockMetadataWithNotify(x, y, z, 4, 2);
} }
} }
private void setMetadataForFront(World world, int x, int y, int z) private void setMetadataForFront(World world, int x, int y, int z)
{ {
if (!world.isRemote) if (!world.isRemote)
{ {
Block block = world.getBlock(x, y, z - 1); Block block = world.getBlock(x, y, z - 1);
Block block1 = world.getBlock(x, y, z + 1); Block block1 = world.getBlock(x, y, z + 1);
Block block2 = world.getBlock(x - 1, y, z); Block block2 = world.getBlock(x - 1, y, z);
Block block3 = world.getBlock(x + 1, y, z); Block block3 = world.getBlock(x + 1, y, z);
byte b0 = 3; byte b0 = 3;
if (block.func_149730_j() && !block1.func_149730_j()) if (block.func_149730_j() && !block1.func_149730_j())
{ {
b0 = 3; b0 = 3;
} }
if (block1.func_149730_j() && !block.func_149730_j()) if (block1.func_149730_j() && !block.func_149730_j())
{ {
b0 = 2; b0 = 2;
} }
if (block2.func_149730_j() && !block3.func_149730_j()) if (block2.func_149730_j() && !block3.func_149730_j())
{ {
b0 = 5; b0 = 5;
} }
if (block3.func_149730_j() && !block2.func_149730_j()) if (block3.func_149730_j() && !block2.func_149730_j())
{ {
b0 = 4; b0 = 4;
} }
world.setBlockMetadataWithNotify(x, y, z, b0, 2); world.setBlockMetadataWithNotify(x, y, z, b0, 2);
} }
} }
public static void updateBlockState(boolean active, World world, int x, int y, int z) public static void updateBlockState(boolean active, World world, int x, int y, int z)
{ {
isActive = active; isActive = active;
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int meta) public TileEntity createNewTileEntity(World world, int meta)

View file

@ -22,6 +22,7 @@ import net.minecraft.world.World;
public class BlockWoodchipper extends BlockMachineBase public class BlockWoodchipper extends BlockMachineBase
{ {
private static String unlocName = "WoodChipper"; private static String unlocName = "WoodChipper";
public BlockWoodchipper() public BlockWoodchipper()
{ {
super(unlocName); super(unlocName);
@ -46,67 +47,70 @@ public class BlockWoodchipper extends BlockMachineBase
} }
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) public void breakBlock(World world, int x, int y, int z, Block block, int meta)
{ {
Random random = new Random(); Random random = new Random();
TileEntityWoodchipper tile = (TileEntityWoodchipper)world.getTileEntity(x, y, z); TileEntityWoodchipper tile = (TileEntityWoodchipper) world.getTileEntity(x, y, z);
if (tile != null) if (tile != null)
{ {
for (int i = 0; i < tile.getSizeInventory(); ++i) for (int i = 0; i < tile.getSizeInventory(); ++i)
{ {
ItemStack itemstack = tile.getStackInSlot(i); ItemStack itemstack = tile.getStackInSlot(i);
if (itemstack != null) if (itemstack != null)
{ {
float f = random.nextFloat() * 0.8F + 0.1F; float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F; float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F; float f2 = random.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0) while (itemstack.stackSize > 0)
{ {
int j = random.nextInt(21) + 10; int j = random.nextInt(21) + 10;
if (j > itemstack.stackSize) if (j > itemstack.stackSize)
{ {
j = itemstack.stackSize; j = itemstack.stackSize;
} }
itemstack.stackSize -= j; itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); EntityItem entityitem = new EntityItem(world, (double) ((float) x + f),
(double) ((float) y + f1), (double) ((float) z + f2),
new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) if (itemstack.hasTagCompound())
{ {
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); entityitem.getEntityItem()
} .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F; float f3 = 0.05F;
entityitem.motionX = (double)((float)random.nextGaussian() * f3); entityitem.motionX = (double) ((float) random.nextGaussian() * f3);
entityitem.motionY = (double)((float)random.nextGaussian() * f3 + 0.2F); entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)random.nextGaussian() * f3); entityitem.motionZ = (double) ((float) random.nextGaussian() * f3);
world.spawnEntityInWorld(entityitem); world.spawnEntityInWorld(entityitem);
} }
} }
} }
world.func_147453_f(x, y, z, block); world.func_147453_f(x, y, z, block);
} }
super.breakBlock(world, x, y, z, block, meta); super.breakBlock(world, x, y, z, block, meta);
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
float hitY, float hitZ)
{ {
if(world.isRemote) if (world.isRemote)
{ {
return true; return true;
} } else
else
{ {
TileEntityWoodchipper tileext = (TileEntityWoodchipper)world.getTileEntity(x, y, z); TileEntityWoodchipper tileext = (TileEntityWoodchipper) world.getTileEntity(x, y, z);
if(tileext != null) if (tileext != null)
player.openGui(CrissCross.instance, GUIHandler.Woodchipper, world, x, y, z); player.openGui(CrissCross.instance, GUIHandler.Woodchipper, world, x, y, z);
return true; return true;
} }

View file

@ -31,53 +31,53 @@ public class ContainerCropomator extends Container
lastProcessTime = 0; lastProcessTime = 0;
lastCatalystInUseTime = 0; lastCatalystInUseTime = 0;
this.addSlotToContainer(new Slot(cropomator, 0, 56, 17)); //input this.addSlotToContainer(new Slot(cropomator, 0, 56, 17)); // input
this.addSlotToContainer(new Slot(cropomator, 1, 56, 53)); //catalyst this.addSlotToContainer(new Slot(cropomator, 1, 56, 53)); // catalyst
this.addSlotToContainer(new MachineOutputSlot(player, cropomator, 2, 116, 35)); this.addSlotToContainer(new MachineOutputSlot(player, cropomator, 2, 116, 35));
this.addInventorySlots(); this.addInventorySlots();
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void updateProgressBar(int timeType1, int timeType2) public void updateProgressBar(int timeType1, int timeType2)
{ {
if (timeType1 == 0) if (timeType1 == 0)
{ {
this.cropomator.processTime = timeType2; this.cropomator.processTime = timeType2;
} }
if (timeType1 == 1) if (timeType1 == 1)
{ {
this.cropomator.catalystTime = timeType2; this.cropomator.catalystTime = timeType2;
} }
if (timeType1 == 2) if (timeType1 == 2)
{ {
this.cropomator.catalystInUseTime = timeType2; this.cropomator.catalystInUseTime = timeType2;
} }
} }
@Override @Override
public void addCraftingToCrafters(ICrafting crafting) public void addCraftingToCrafters(ICrafting crafting)
{ {
super.addCraftingToCrafters(crafting); super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, this.cropomator.processTime); crafting.sendProgressBarUpdate(this, 0, this.cropomator.processTime);
crafting.sendProgressBarUpdate(this, 1, this.cropomator.catalystTime); crafting.sendProgressBarUpdate(this, 1, this.cropomator.catalystTime);
crafting.sendProgressBarUpdate(this, 2, this.cropomator.catalystInUseTime); crafting.sendProgressBarUpdate(this, 2, this.cropomator.catalystInUseTime);
} }
@Override @Override
public void detectAndSendChanges() public void detectAndSendChanges()
{ {
super.detectAndSendChanges(); super.detectAndSendChanges();
for(int i = 0; i < this.crafters.size(); ++i) for (int i = 0; i < this.crafters.size(); ++i)
{ {
ICrafting crafting = (ICrafting)this.crafters.get(i); ICrafting crafting = (ICrafting) this.crafters.get(i);
if(this.lastUseTime != this.cropomator.processTime) if (this.lastUseTime != this.cropomator.processTime)
crafting.sendProgressBarUpdate(this, 0, this.cropomator.processTime); crafting.sendProgressBarUpdate(this, 0, this.cropomator.processTime);
if(this.lastProcessTime != this.cropomator.catalystTime) if (this.lastProcessTime != this.cropomator.catalystTime)
crafting.sendProgressBarUpdate(this, 1, this.cropomator.catalystTime); crafting.sendProgressBarUpdate(this, 1, this.cropomator.catalystTime);
if(this.lastCatalystInUseTime != this.cropomator.catalystInUseTime) if (this.lastCatalystInUseTime != this.cropomator.catalystInUseTime)
crafting.sendProgressBarUpdate(this, 2, this.cropomator.catalystInUseTime); crafting.sendProgressBarUpdate(this, 2, this.cropomator.catalystInUseTime);
} }
this.lastUseTime = this.cropomator.processTime; this.lastUseTime = this.cropomator.processTime;
@ -88,74 +88,68 @@ public class ContainerCropomator extends Container
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{ {
ItemStack itemstack = null; ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(slotID); Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack()) if (slot != null && slot.getHasStack())
{ {
ItemStack itemstack1 = slot.getStack(); ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy(); itemstack = itemstack1.copy();
if (slotID == 2) if (slotID == 2)
{ {
if (!this.mergeItemStack(itemstack1, 3, 39, true)) if (!this.mergeItemStack(itemstack1, 3, 39, true))
{ {
return null; return null;
} }
slot.onSlotChange(itemstack1, itemstack); slot.onSlotChange(itemstack1, itemstack);
} } else if (slotID != 1 && slotID != 0)
else if (slotID != 1 && slotID != 0) {
{ if (TileEntityCropomator.isValidForCropomator(itemstack1))
if (TileEntityCropomator.isValidForCropomator(itemstack1)) {
{ if (!this.mergeItemStack(itemstack1, 0, 1, false))
if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
{ return null;
return null; }
} } else if (TileEntityCropomator.isItemCatalyst(itemstack1))
} {
else if (TileEntityCropomator.isItemCatalyst(itemstack1)) if (!this.mergeItemStack(itemstack1, 1, 2, false))
{ {
if (!this.mergeItemStack(itemstack1, 1, 2, false)) return null;
{ }
return null; } else if (slotID >= 3 && slotID < 30)
} {
} if (!this.mergeItemStack(itemstack1, 30, 39, false))
else if (slotID >= 3 && slotID < 30) {
{ return null;
if (!this.mergeItemStack(itemstack1, 30, 39, false)) }
{ } else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
return null; {
} return null;
} }
else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) } else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{ {
return null; return null;
} }
}
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{
return null;
}
if (itemstack1.stackSize == 0) if (itemstack1.stackSize == 0)
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack) null);
} } else
else {
{ slot.onSlotChanged();
slot.onSlotChanged(); }
}
if (itemstack1.stackSize == itemstack.stackSize) if (itemstack1.stackSize == itemstack.stackSize)
{ {
return null; return null;
} }
slot.onPickupFromSlot(player, itemstack1); slot.onPickupFromSlot(player, itemstack1);
} }
return itemstack; return itemstack;
} }
@Override @Override

View file

@ -29,53 +29,53 @@ public class ContainerElectroextractor extends Container
lastCrushTime = 0; lastCrushTime = 0;
lastFuelTime = 0; lastFuelTime = 0;
this.addSlotToContainer(new Slot(electroextractor, 0, 56, 17)); //input this.addSlotToContainer(new Slot(electroextractor, 0, 56, 17)); // input
this.addSlotToContainer(new Slot(electroextractor, 1, 56, 53)); //fuelitem this.addSlotToContainer(new Slot(electroextractor, 1, 56, 53)); // fuelitem
this.addSlotToContainer(new MachineOutputSlot(player, electroextractor, 2, 116, 35)); this.addSlotToContainer(new MachineOutputSlot(player, electroextractor, 2, 116, 35));
this.addInventorySlots(); this.addInventorySlots();
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void updateProgressBar(int timeType1, int timeType2) public void updateProgressBar(int timeType1, int timeType2)
{ {
if (timeType1 == 0) if (timeType1 == 0)
{ {
this.electroextractor.crushTime = timeType2; this.electroextractor.crushTime = timeType2;
} }
if (timeType1 == 1) if (timeType1 == 1)
{ {
this.electroextractor.fuelTime = timeType2; this.electroextractor.fuelTime = timeType2;
} }
if (timeType1 == 2) if (timeType1 == 2)
{ {
this.electroextractor.fuelInUseTime = timeType2; this.electroextractor.fuelInUseTime = timeType2;
} }
} }
@Override @Override
public void addCraftingToCrafters(ICrafting crafting) public void addCraftingToCrafters(ICrafting crafting)
{ {
super.addCraftingToCrafters(crafting); super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, this.electroextractor.crushTime); crafting.sendProgressBarUpdate(this, 0, this.electroextractor.crushTime);
crafting.sendProgressBarUpdate(this, 1, this.electroextractor.fuelTime); crafting.sendProgressBarUpdate(this, 1, this.electroextractor.fuelTime);
crafting.sendProgressBarUpdate(this, 2, this.electroextractor.fuelInUseTime); crafting.sendProgressBarUpdate(this, 2, this.electroextractor.fuelInUseTime);
} }
@Override @Override
public void detectAndSendChanges() public void detectAndSendChanges()
{ {
super.detectAndSendChanges(); super.detectAndSendChanges();
for(int i = 0; i < this.crafters.size(); ++i) for (int i = 0; i < this.crafters.size(); ++i)
{ {
ICrafting crafting = (ICrafting)this.crafters.get(i); ICrafting crafting = (ICrafting) this.crafters.get(i);
if(this.lastUseTime != this.electroextractor.crushTime) if (this.lastUseTime != this.electroextractor.crushTime)
crafting.sendProgressBarUpdate(this, 0, this.electroextractor.crushTime); crafting.sendProgressBarUpdate(this, 0, this.electroextractor.crushTime);
if(this.lastCrushTime != this.electroextractor.fuelTime) if (this.lastCrushTime != this.electroextractor.fuelTime)
crafting.sendProgressBarUpdate(this, 1, this.electroextractor.fuelTime); crafting.sendProgressBarUpdate(this, 1, this.electroextractor.fuelTime);
if(this.lastFuelTime != this.electroextractor.fuelInUseTime) if (this.lastFuelTime != this.electroextractor.fuelInUseTime)
crafting.sendProgressBarUpdate(this, 2, this.electroextractor.fuelInUseTime); crafting.sendProgressBarUpdate(this, 2, this.electroextractor.fuelInUseTime);
} }
this.lastUseTime = this.electroextractor.crushTime; this.lastUseTime = this.electroextractor.crushTime;
@ -86,74 +86,68 @@ public class ContainerElectroextractor extends Container
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{ {
ItemStack itemstack = null; ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(slotID); Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack()) if (slot != null && slot.getHasStack())
{ {
ItemStack itemstack1 = slot.getStack(); ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy(); itemstack = itemstack1.copy();
if (slotID == 2) if (slotID == 2)
{ {
if (!this.mergeItemStack(itemstack1, 3, 39, true)) if (!this.mergeItemStack(itemstack1, 3, 39, true))
{ {
return null; return null;
} }
slot.onSlotChange(itemstack1, itemstack); slot.onSlotChange(itemstack1, itemstack);
} } else if (slotID != 1 && slotID != 0)
else if (slotID != 1 && slotID != 0) {
{ if (TileEntityElectroextractor.isValidForElectroextractor(itemstack1))
if (TileEntityElectroextractor.isValidForElectroextractor(itemstack1)) {
{ if (!this.mergeItemStack(itemstack1, 0, 1, false))
if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
{ return null;
return null; }
} } else if (TileEntityElectroextractor.isItemEnergetic(itemstack1))
} {
else if (TileEntityElectroextractor.isItemEnergetic(itemstack1)) if (!this.mergeItemStack(itemstack1, 1, 2, false))
{ {
if (!this.mergeItemStack(itemstack1, 1, 2, false)) return null;
{ }
return null; } else if (slotID >= 3 && slotID < 30)
} {
} if (!this.mergeItemStack(itemstack1, 30, 39, false))
else if (slotID >= 3 && slotID < 30) {
{ return null;
if (!this.mergeItemStack(itemstack1, 30, 39, false)) }
{ } else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
return null; {
} return null;
} }
else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) } else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{ {
return null; return null;
} }
}
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{
return null;
}
if (itemstack1.stackSize == 0) if (itemstack1.stackSize == 0)
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack) null);
} } else
else {
{ slot.onSlotChanged();
slot.onSlotChanged(); }
}
if (itemstack1.stackSize == itemstack.stackSize) if (itemstack1.stackSize == itemstack.stackSize)
{ {
return null; return null;
} }
slot.onPickupFromSlot(player, itemstack1); slot.onPickupFromSlot(player, itemstack1);
} }
return itemstack; return itemstack;
} }
@Override @Override

View file

@ -29,48 +29,51 @@ public class ContainerWoodchipper extends Container
lastChopTime = 0; lastChopTime = 0;
lastFuelTime = 0; lastFuelTime = 0;
this.addSlotToContainer(new Slot(woodchipper, 0, 56, 17)); //input this.addSlotToContainer(new Slot(woodchipper, 0, 56, 17)); // input
this.addSlotToContainer(new Slot(woodchipper, 1, 56, 53)); //catalyst this.addSlotToContainer(new Slot(woodchipper, 1, 56, 53)); // catalyst
this.addSlotToContainer(new MachineOutputSlot(player, woodchipper, 2, 116, 35)); this.addSlotToContainer(new MachineOutputSlot(player, woodchipper, 2, 116, 35));
this.addInventorySlots(); this.addInventorySlots();
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void updateProgressBar(int timeType1, int timeType2) public void updateProgressBar(int timeType1, int timeType2)
{ {
switch(timeType1) switch (timeType1)
{ {
case 0:this.woodchipper.processTime = timeType2; case 0:
break; this.woodchipper.processTime = timeType2;
case 1:this.woodchipper.fuelTime = timeType2; break;
break; case 1:
case 2:this.woodchipper.fuelUsetime = timeType2; this.woodchipper.fuelTime = timeType2;
break; break;
} case 2:
} this.woodchipper.fuelUsetime = timeType2;
break;
}
}
@Override @Override
public void addCraftingToCrafters(ICrafting crafting) public void addCraftingToCrafters(ICrafting crafting)
{ {
super.addCraftingToCrafters(crafting); super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, this.woodchipper.processTime); crafting.sendProgressBarUpdate(this, 0, this.woodchipper.processTime);
crafting.sendProgressBarUpdate(this, 1, this.woodchipper.fuelTime); crafting.sendProgressBarUpdate(this, 1, this.woodchipper.fuelTime);
crafting.sendProgressBarUpdate(this, 2, this.woodchipper.fuelUsetime); crafting.sendProgressBarUpdate(this, 2, this.woodchipper.fuelUsetime);
} }
@Override @Override
public void detectAndSendChanges() public void detectAndSendChanges()
{ {
super.detectAndSendChanges(); super.detectAndSendChanges();
for(int i = 0; i < this.crafters.size(); ++i) for (int i = 0; i < this.crafters.size(); ++i)
{ {
ICrafting crafting = (ICrafting)this.crafters.get(i); ICrafting crafting = (ICrafting) this.crafters.get(i);
if(this.lastUseTime != this.woodchipper.processTime) if (this.lastUseTime != this.woodchipper.processTime)
crafting.sendProgressBarUpdate(this, 0, this.woodchipper.processTime); crafting.sendProgressBarUpdate(this, 0, this.woodchipper.processTime);
if(this.lastChopTime != this.woodchipper.fuelTime) if (this.lastChopTime != this.woodchipper.fuelTime)
crafting.sendProgressBarUpdate(this, 1, this.woodchipper.fuelTime); crafting.sendProgressBarUpdate(this, 1, this.woodchipper.fuelTime);
if(this.lastFuelTime != this.woodchipper.fuelUsetime) if (this.lastFuelTime != this.woodchipper.fuelUsetime)
crafting.sendProgressBarUpdate(this, 2, this.woodchipper.fuelUsetime); crafting.sendProgressBarUpdate(this, 2, this.woodchipper.fuelUsetime);
} }
this.lastUseTime = this.woodchipper.processTime; this.lastUseTime = this.woodchipper.processTime;
@ -81,74 +84,68 @@ public class ContainerWoodchipper extends Container
@Override @Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{ {
ItemStack itemstack = null; ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(slotID); Slot slot = (Slot) this.inventorySlots.get(slotID);
if (slot != null && slot.getHasStack()) if (slot != null && slot.getHasStack())
{ {
ItemStack itemstack1 = slot.getStack(); ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy(); itemstack = itemstack1.copy();
if (slotID == 2) if (slotID == 2)
{ {
if (!this.mergeItemStack(itemstack1, 3, 39, true)) if (!this.mergeItemStack(itemstack1, 3, 39, true))
{ {
return null; return null;
} }
slot.onSlotChange(itemstack1, itemstack); slot.onSlotChange(itemstack1, itemstack);
} } else if (slotID != 1 && slotID != 0)
else if (slotID != 1 && slotID != 0) {
{ if (TileEntityWoodchipper.isValidForWoodchipper(itemstack1))
if (TileEntityWoodchipper.isValidForWoodchipper(itemstack1)) {
{ if (!this.mergeItemStack(itemstack1, 0, 1, false))
if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
{ return null;
return null; }
} } else if (TileEntityWoodchipper.isItemFuel(itemstack1))
} {
else if (TileEntityWoodchipper.isItemFuel(itemstack1)) if (!this.mergeItemStack(itemstack1, 1, 2, false))
{ {
if (!this.mergeItemStack(itemstack1, 1, 2, false)) return null;
{ }
return null; } else if (slotID >= 3 && slotID < 30)
} {
} if (!this.mergeItemStack(itemstack1, 30, 39, false))
else if (slotID >= 3 && slotID < 30) {
{ return null;
if (!this.mergeItemStack(itemstack1, 30, 39, false)) }
{ } else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
return null; {
} return null;
} }
else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) } else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{ {
return null; return null;
} }
}
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{
return null;
}
if (itemstack1.stackSize == 0) if (itemstack1.stackSize == 0)
{ {
slot.putStack((ItemStack)null); slot.putStack((ItemStack) null);
} } else
else {
{ slot.onSlotChanged();
slot.onSlotChanged(); }
}
if (itemstack1.stackSize == itemstack.stackSize) if (itemstack1.stackSize == itemstack.stackSize)
{ {
return null; return null;
} }
slot.onPickupFromSlot(player, itemstack1); slot.onPickupFromSlot(player, itemstack1);
} }
return itemstack; return itemstack;
} }
@Override @Override

View file

@ -13,51 +13,51 @@ import net.minecraft.util.MathHelper;
public class MachineOutputSlot extends Slot public class MachineOutputSlot extends Slot
{ {
/** The player that is using the GUI where this slot resides. */ /** The player that is using the GUI where this slot resides. */
private EntityPlayer thePlayer; private EntityPlayer thePlayer;
private int temp; private int temp;
public MachineOutputSlot(EntityPlayer player, IInventory inventory, int x, int y, int z) public MachineOutputSlot(EntityPlayer player, IInventory inventory, int x, int y, int z)
{ {
super(inventory, x, y, z); super(inventory, x, y, z);
this.thePlayer = player; this.thePlayer = player;
} }
@Override @Override
public boolean isItemValid(ItemStack stack) public boolean isItemValid(ItemStack stack)
{ {
return false; return false;
} }
@Override @Override
public ItemStack decrStackSize(int slot) public ItemStack decrStackSize(int slot)
{ {
if (this.getHasStack()) if (this.getHasStack())
{ {
this.temp += Math.min(slot, this.getStack().stackSize); this.temp += Math.min(slot, this.getStack().stackSize);
} }
return super.decrStackSize(slot); return super.decrStackSize(slot);
} }
@Override @Override
public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack) public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack)
{ {
this.onCrafting(itemstack); this.onCrafting(itemstack);
super.onPickupFromSlot(player, itemstack); super.onPickupFromSlot(player, itemstack);
} }
@Override @Override
protected void onCrafting(ItemStack itemstack, int slot) protected void onCrafting(ItemStack itemstack, int slot)
{ {
this.temp += slot; this.temp += slot;
this.onCrafting(itemstack); this.onCrafting(itemstack);
} }
@Override @Override
protected void onCrafting(ItemStack stack) protected void onCrafting(ItemStack stack)
{ {
stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.temp); stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.temp);
this.temp = 0; this.temp = 0;
} }
} }

View file

@ -2,7 +2,7 @@ package com.oitsjustjose.criss_cross;
import com.oitsjustjose.criss_cross.Blocks.CCBlocks; import com.oitsjustjose.criss_cross.Blocks.CCBlocks;
import com.oitsjustjose.criss_cross.Items.CCItems; import com.oitsjustjose.criss_cross.Items.CCItems;
import com.oitsjustjose.criss_cross.Recipes.CRecipes; import com.oitsjustjose.criss_cross.Recipes.CCRecipes;
import com.oitsjustjose.criss_cross.Util.CommonProxy; import com.oitsjustjose.criss_cross.Util.CommonProxy;
import com.oitsjustjose.criss_cross.Util.ConfigHandler; import com.oitsjustjose.criss_cross.Util.ConfigHandler;
import com.oitsjustjose.criss_cross.Util.OreDictionaryAdder; import com.oitsjustjose.criss_cross.Util.OreDictionaryAdder;
@ -23,17 +23,17 @@ public class CrissCross
{ {
public static CreativeTabs CCTab; public static CreativeTabs CCTab;
@Instance(Reference.modid) @Instance(Reference.modid)
public static CrissCross instance; public static CrissCross instance;
@SidedProxy(clientSide = "com.oitsjustjose.criss_cross.Util.ClientProxy", serverSide = "com.oitsjustjose.criss_cross.Util.CommonProxy") @SidedProxy(clientSide = "com.oitsjustjose.criss_cross.Util.ClientProxy", serverSide = "com.oitsjustjose.criss_cross.Util.CommonProxy")
public static CommonProxy proxy; public static CommonProxy proxy;
@EventHandler @EventHandler
public static void preInit(FMLPreInitializationEvent event) public static void preInit(FMLPreInitializationEvent event)
{ {
ConfigHandler.init(event.getSuggestedConfigurationFile()); ConfigHandler.init(event.getSuggestedConfigurationFile());
FMLCommonHandler.instance().bus().register(new ConfigHandler()); FMLCommonHandler.instance().bus().register(new ConfigHandler());
CCTab = new CCTab(); CCTab = new CCTab();
proxy.preInit(); proxy.preInit();
} }
@ -43,7 +43,7 @@ public class CrissCross
{ {
CCBlocks.init(); CCBlocks.init();
CCItems.init(); CCItems.init();
CRecipes.init(); CCRecipes.init();
OreDictionaryAdder.init(); OreDictionaryAdder.init();
proxy.init(); proxy.init();
} }

View file

@ -24,26 +24,27 @@ public class GUICropomator extends GuiContainer
this.cropomator = cropomator; this.cropomator = cropomator;
} }
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{ {
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.cropomator"), 55, 7, 4210752); this.fontRendererObj.drawString(StatCollector.translateToLocal("container.cropomator"), 55, 7, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92, 4210752); this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92,
} 4210752);
}
protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY) protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY)
{ {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texture); this.mc.renderEngine.bindTexture(texture);
int k = (this.width - this.xSize) / 2; int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
if (this.cropomator.isUsingFuel()) if (this.cropomator.isUsingFuel())
{ {
int i1 = this.cropomator.getBurnTimeRemainingScaled(13); int i1 = this.cropomator.getBurnTimeRemainingScaled(13);
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1);
i1 = this.cropomator.getProgressScaled(24); i1 = this.cropomator.getProgressScaled(24);
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
} }
} }
} }

View file

@ -12,7 +12,8 @@ import net.minecraft.util.StatCollector;
public class GUIElectroextractor extends GuiContainer public class GUIElectroextractor extends GuiContainer
{ {
public static final ResourceLocation texture = new ResourceLocation("crisscross", "textures/gui/electroextractor.png"); public static final ResourceLocation texture = new ResourceLocation("crisscross",
"textures/gui/electroextractor.png");
private TileEntityElectroextractor electroextractor; private TileEntityElectroextractor electroextractor;
@ -22,26 +23,27 @@ public class GUIElectroextractor extends GuiContainer
this.electroextractor = electroextractor; this.electroextractor = electroextractor;
} }
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{ {
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.electroextractor"), 50, 7, 4210752); this.fontRendererObj.drawString(StatCollector.translateToLocal("container.electroextractor"), 50, 7, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92, 4210752); this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92,
} 4210752);
}
protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY) protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY)
{ {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texture); this.mc.renderEngine.bindTexture(texture);
int k = (this.width - this.xSize) / 2; int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
if (this.electroextractor.isUsingFuel()) if (this.electroextractor.isUsingFuel())
{ {
int i1 = this.electroextractor.getBurnTimeRemainingScaled(13); int i1 = this.electroextractor.getBurnTimeRemainingScaled(13);
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1);
i1 = this.electroextractor.getProgressScaled(24); i1 = this.electroextractor.getProgressScaled(24);
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
} }
} }
} }

View file

@ -8,27 +8,27 @@ import net.minecraft.client.gui.GuiScreen;
public class GUIFactory implements IModGuiFactory public class GUIFactory implements IModGuiFactory
{ {
@Override @Override
public void initialize(Minecraft minecraftInstance) public void initialize(Minecraft minecraftInstance)
{ {
} }
@Override @Override
public Class<? extends GuiScreen> mainConfigGuiClass() public Class<? extends GuiScreen> mainConfigGuiClass()
{ {
return ModGUIConfig.class; return ModGUIConfig.class;
} }
@Override @Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
{ {
return null; return null;
} }
@Override @Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element)
{ {
return null; return null;
} }
} }

View file

@ -23,21 +23,21 @@ public class GUIHandler implements IGuiHandler
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityCropomator) if (tile instanceof TileEntityCropomator)
{ {
TileEntityCropomator TE = (TileEntityCropomator)tile; TileEntityCropomator TE = (TileEntityCropomator) tile;
return new ContainerCropomator(player, TE); return new ContainerCropomator(player, TE);
} }
if(tile instanceof TileEntityElectroextractor) if (tile instanceof TileEntityElectroextractor)
{ {
TileEntityElectroextractor TE = (TileEntityElectroextractor)tile; TileEntityElectroextractor TE = (TileEntityElectroextractor) tile;
return new ContainerElectroextractor(player, TE); return new ContainerElectroextractor(player, TE);
} }
if(tile instanceof TileEntityWoodchipper) if (tile instanceof TileEntityWoodchipper)
{ {
TileEntityWoodchipper TE = (TileEntityWoodchipper)tile; TileEntityWoodchipper TE = (TileEntityWoodchipper) tile;
return new ContainerWoodchipper(player, TE); return new ContainerWoodchipper(player, TE);
} }
@ -49,22 +49,22 @@ public class GUIHandler implements IGuiHandler
{ {
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityCropomator) if (tile instanceof TileEntityCropomator)
{ {
TileEntityCropomator TE = (TileEntityCropomator)tile; TileEntityCropomator TE = (TileEntityCropomator) tile;
return new GUICropomator(player, TE); return new GUICropomator(player, TE);
} }
if(tile instanceof TileEntityElectroextractor) if (tile instanceof TileEntityElectroextractor)
{ {
TileEntityElectroextractor TE = (TileEntityElectroextractor)tile; TileEntityElectroextractor TE = (TileEntityElectroextractor) tile;
return new GUIElectroextractor(player, TE); return new GUIElectroextractor(player, TE);
} }
if(tile instanceof TileEntityWoodchipper) if (tile instanceof TileEntityWoodchipper)
{ {
TileEntityWoodchipper TE = (TileEntityWoodchipper)tile; TileEntityWoodchipper TE = (TileEntityWoodchipper) tile;
return new GUIWoodchipper(player, TE); return new GUIWoodchipper(player, TE);
} }

View file

@ -22,26 +22,27 @@ public class GUIWoodchipper extends GuiContainer
this.woodchipper = woodchipper; this.woodchipper = woodchipper;
} }
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{ {
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.woodchipper"), 55, 7, 4210752); this.fontRendererObj.drawString(StatCollector.translateToLocal("container.woodchipper"), 55, 7, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92, 4210752); this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92,
} 4210752);
}
protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY) protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY)
{ {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texture); this.mc.renderEngine.bindTexture(texture);
int k = (this.width - this.xSize) / 2; int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2; int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
if (this.woodchipper.isUsingFuel()) if (this.woodchipper.isUsingFuel())
{ {
int i1 = this.woodchipper.getBurnTimeRemainingScaled(13); int i1 = this.woodchipper.getBurnTimeRemainingScaled(13);
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1);
i1 = this.woodchipper.getProgressScaled(24); i1 = this.woodchipper.getProgressScaled(24);
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
} }
} }
} }

View file

@ -10,13 +10,10 @@ import net.minecraftforge.common.config.Configuration;
public class ModGUIConfig extends GuiConfig public class ModGUIConfig extends GuiConfig
{ {
public ModGUIConfig(GuiScreen guiScreen) public ModGUIConfig(GuiScreen guiScreen)
{ {
super(guiScreen, super(guiScreen,
new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
Reference.modid, Reference.modid, false, true, GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString()));
false, }
true,
GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString()));
}
} }

View file

@ -5,6 +5,7 @@ import net.minecraft.item.Item;
public class CCItems public class CCItems
{ {
public static Item dusts; public static Item dusts;
public static void init() public static void init()
{ {
dusts = new ItemDust(); dusts = new ItemDust();

View file

@ -63,7 +63,7 @@ public class ItemDust extends Item
@Override @Override
public String getUnlocalizedName(ItemStack itemStack) public String getUnlocalizedName(ItemStack itemStack)
{ {
if(itemStack.getItemDamage() >= colors.size() || itemStack.getItemDamage() >= dustNames.size()) if (itemStack.getItemDamage() >= colors.size() || itemStack.getItemDamage() >= dustNames.size())
{ {
itemStack.setStackDisplayName("This is a bad item, please trash it."); itemStack.setStackDisplayName("This is a bad item, please trash it.");
return ("item." + Reference.modid + ".trash"); return ("item." + Reference.modid + ".trash");
@ -83,13 +83,12 @@ public class ItemDust extends Item
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int pass) public int getColorFromItemStack(ItemStack stack, int pass)
{ {
if(pass == 1) if (pass == 1)
{ {
if(stack.getItemDamage() >= colors.size()) if (stack.getItemDamage() >= colors.size())
return 0; return 0;
return colors.get(stack.getItemDamage()); return colors.get(stack.getItemDamage());
} } else
else
return 16777215; return 16777215;
} }
@ -97,7 +96,7 @@ public class ItemDust extends Item
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) public void getSubItems(Item item, CreativeTabs tab, List list)
{ {
for(int i = 0; i < dustNames.size(); i++) for (int i = 0; i < dustNames.size(); i++)
list.add(new ItemStack(item, 1, i)); list.add(new ItemStack(item, 1, i));
} }
} }

View file

@ -0,0 +1,34 @@
package com.oitsjustjose.criss_cross.NEI;
import com.oitsjustjose.criss_cross.Util.Reference;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import codechicken.nei.recipe.TemplateRecipeHandler;
public class CCNEIIntegration implements IConfigureNEI
{
@Override
public void loadConfig()
{
registerHandler(new RecipeHandlerWoodchipper());
}
@Override
public String getName()
{
return Reference.modid + " built-in NEI plugin.";
}
@Override
public String getVersion()
{
return Reference.version;
}
public void registerHandler(RecipeHandlerBase handler)
{
API.registerRecipeHandler(handler);
API.registerUsageHandler(handler);
}
}

View file

@ -0,0 +1,358 @@
package com.oitsjustjose.criss_cross.NEI;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.IFluidContainerItem;
public abstract class RecipeHandlerBase extends TemplateRecipeHandler
{
public abstract class CachedBaseRecipe extends CachedRecipe
{
public List<FluidTankElement> getFluidTanks()
{
return null;
}
}
public abstract String getRecipeID();
public void loadCraftingRecipes(FluidStack result)
{
}
public void loadUsageRecipes(FluidStack ingredient)
{
}
@Override
public void drawForeground(int recipe)
{
super.drawForeground(recipe);
this.drawFluidTanks(recipe);
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
try
{
if (outputId.equals("liquid") && results.length == 1 && results[0] instanceof FluidStack)
{
this.loadCraftingRecipes((FluidStack) results[0]);
} else
{
super.loadCraftingRecipes(outputId, results);
}
} catch (Throwable ex)
{
ex.printStackTrace();
}
}
@Override
public void loadCraftingRecipes(ItemStack result)
{
FluidStack fluid = getFluidStack(result);
if (fluid != null)
{
this.loadCraftingRecipes(fluid);
}
}
@Override
public void loadUsageRecipes(String inputId, Object... ingredients)
{
try
{
if (inputId.equals("liquid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack)
{
this.loadUsageRecipes((FluidStack) ingredients[0]);
} else
{
super.loadUsageRecipes(inputId, ingredients);
}
} catch (Throwable ex)
{
ex.printStackTrace();
}
}
@Override
public void loadUsageRecipes(ItemStack ingred)
{
FluidStack fluid = getFluidStack(ingred);
if (fluid != null)
{
this.loadUsageRecipes(fluid);
}
}
@Override
public List<String> handleTooltip(GuiRecipe guiRecipe, List<String> currenttip, int recipe)
{
super.handleTooltip(guiRecipe, currenttip, recipe);
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
if (GuiContainerManager.shouldShowTooltip(guiRecipe))
{
Point mouse = GuiDraw.getMousePosition();
Point offset = guiRecipe.getRecipePosition(recipe);
Point relMouse = new Point(mouse.x - ((guiRecipe.width - 176) / 2) - offset.x,
mouse.y - ((guiRecipe.height - 166) / 2) - offset.y);
if (crecipe.getFluidTanks() != null)
{
for (FluidTankElement tank : crecipe.getFluidTanks())
{
if (tank.position.contains(relMouse))
{
tank.handleTooltip(currenttip);
}
}
}
}
return currenttip;
}
@Override
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe)
{
if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
{
if (this.transferFluidTank(gui, recipe, false))
{
return true;
}
} else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
{
if (this.transferFluidTank(gui, recipe, true))
{
return true;
}
}
return super.keyTyped(gui, keyChar, keyCode, recipe);
}
@Override
public boolean mouseClicked(GuiRecipe gui, int button, int recipe)
{
if (button == 0)
{
if (this.transferFluidTank(gui, recipe, false))
{
return true;
}
} else if (button == 1)
{
if (this.transferFluidTank(gui, recipe, true))
{
return true;
}
}
return super.mouseClicked(gui, button, recipe);
}
protected boolean transferFluidTank(GuiRecipe guiRecipe, int recipe, boolean usage)
{
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
Point mousepos = GuiDraw.getMousePosition();
Point offset = guiRecipe.getRecipePosition(recipe);
Point relMouse = new Point(mousepos.x - ((guiRecipe.width - 176) / 2) - offset.x,
mousepos.y - ((guiRecipe.height - 166) / 2) - offset.y);
if (crecipe.getFluidTanks() != null)
{
for (FluidTankElement tank : crecipe.getFluidTanks())
{
if (tank.position.contains(relMouse))
{
if ((tank.fluid != null) && tank.fluid.amount > 0)
{
if (usage)
{
if (!GuiUsageRecipe.openRecipeGui("liquid", new Object[]
{ tank.fluid }))
{
return false;
}
} else
{
if (!GuiCraftingRecipe.openRecipeGui("liquid", new Object[]
{ tank.fluid }))
{
return false;
}
}
return true;
}
}
}
}
return false;
}
public void drawFluidTanks(int recipe)
{
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
if (crecipe.getFluidTanks() != null)
{
for (FluidTankElement fluidTank : crecipe.getFluidTanks())
{
fluidTank.draw();
}
}
}
public static List getSingleList(Object o)
{
List list = new ArrayList();
list.add(o);
return list;
}
public static FluidStack getFluidStack(ItemStack stack)
{
if (stack == null)
{
return null;
}
Item item = stack.getItem();
FluidStack fluidStack = null;
if ((item instanceof IFluidContainerItem))
{
fluidStack = ((IFluidContainerItem) item).getFluid(stack);
}
if (fluidStack == null)
{
fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
}
if ((fluidStack == null) && (Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock))
{
Fluid fluid = ((IFluidBlock) Block.getBlockFromItem(stack.getItem())).getFluid();
if (fluid != null)
{
return new FluidStack(fluid, 1000);
}
}
return fluidStack;
}
public static boolean areFluidsEqual(FluidStack fluidStack1, FluidStack fluidStack2)
{
if (fluidStack1 == null || fluidStack2 == null)
{
return false;
}
return fluidStack1.isFluidEqual(fluidStack2);
}
public static class FluidTankElement
{
public Rectangle position;
public FluidStack fluid;
public int capacity;
public boolean flowingTexture = false;
public FluidTankElement(Rectangle position, int capacity, FluidStack fluid)
{
this.position = position;
this.capacity = capacity;
this.fluid = fluid;
}
public List<String> handleTooltip(List<String> currenttip)
{
if (this.fluid == null || this.fluid.getFluid() == null || this.fluid.amount <= 0)
{
return currenttip;
}
currenttip.add(this.fluid.getLocalizedName());
currenttip.add(EnumChatFormatting.GRAY.toString() + this.fluid.amount + " mB");
return currenttip;
}
public void draw()
{
if (this.fluid == null || this.fluid.getFluid() == null || this.fluid.amount <= 0)
{
return;
}
IIcon fluidIcon = null;
if (this.flowingTexture && this.fluid.getFluid().getFlowingIcon() != null)
{
fluidIcon = this.fluid.getFluid().getFlowingIcon();
} else if (this.fluid.getFluid().getStillIcon() != null)
{
fluidIcon = this.fluid.getFluid().getStillIcon();
} else
{
return;
}
GuiDraw.changeTexture(TextureMap.locationBlocksTexture);
int color = this.fluid.getFluid().getColor(this.fluid);
GL11.glColor3ub((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF));
GL11.glDisable(GL11.GL_BLEND);
int amount = Math
.max(Math.min(this.position.height, this.fluid.amount * this.position.height / this.capacity), 1);
int posY = this.position.y + this.position.height - amount;
for (int i = 0; i < this.position.width; i += 16)
{
for (int j = 0; j < amount; j += 16)
{
int drawWidth = Math.min(this.position.width - i, 16);
int drawHeight = Math.min(amount - j, 16);
int drawX = this.position.x + i;
int drawY = posY + j;
double minU = fluidIcon.getMinU();
double maxU = fluidIcon.getMaxU();
double minV = fluidIcon.getMinV();
double maxV = fluidIcon.getMaxV();
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(drawX, drawY + drawHeight, 0, minU,
minV + (maxV - minV) * drawHeight / 16F);
tessellator.addVertexWithUV(drawX + drawWidth, drawY + drawHeight, 0,
minU + (maxU - minU) * drawWidth / 16F, minV + (maxV - minV) * drawHeight / 16F);
tessellator.addVertexWithUV(drawX + drawWidth, drawY, 0, minU + (maxU - minU) * drawWidth / 16F,
minV);
tessellator.addVertexWithUV(drawX, drawY, 0, minU, minV);
tessellator.draw();
}
}
GL11.glEnable(GL11.GL_BLEND);
}
}
}

View file

@ -0,0 +1,6 @@
package com.oitsjustjose.criss_cross.NEI;
public class RecipeHandlerElectroextractor
{
}

View file

@ -0,0 +1,130 @@
package com.oitsjustjose.criss_cross.NEI;
import java.awt.Rectangle;
import java.util.ArrayList;
import org.lwjgl.opengl.GL11;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityWoodchipper;
import com.oitsjustjose.criss_cross.TileEntity.TileEntityWoodchipper.WoodchipperRecipe;
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class RecipeHandlerWoodchipper extends RecipeHandlerBase
{
public class CachedWoodchipperRecipe extends CachedBaseRecipe
{
public PositionedStack input;
public PositionedStack output;
public int time = ConfigHandler.woodchipperProcessTime;
public CachedWoodchipperRecipe(WoodchipperRecipe chipper)
{
this.input = new PositionedStack(chipper.input, 44, 18);
this.output = new PositionedStack(chipper.result, 98, 18);
}
@Override
public PositionedStack getIngredient()
{
return this.input;
}
@Override
public PositionedStack getResult()
{
return this.output;
}
}
@Override
public String getRecipeName()
{
return StatCollector.translateToLocal("crisscross.nei.woodchipper");
}
@Override
public String getRecipeID()
{
return "crisscross.woodchipper";
}
@Override
public void loadTransferRects()
{
this.transferRects
.add(new RecipeTransferRect(new Rectangle(68, 20, 22, 15), this.getRecipeID(), new Object[0]));
}
@Override
public String getGuiTexture()
{
return "crisscross:textures/gui/woodchipper.png";
}
@Override
public void drawBackground(int recipe)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(this.getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 160, 65);
}
@Override
public void drawExtras(int recipe)
{
int time = ((CachedWoodchipperRecipe) this.arecipes.get(recipe)).time;
int seconds = time / 20;
GuiDraw.drawStringC(time + " ticks (" + seconds + " secs)", 81, 40, 0x808080, false);
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if (outputId.equals(this.getRecipeID()))
{
ArrayList<ItemStack> inputs = TileEntityWoodchipper.getInputs();
ArrayList<ItemStack> outputs = TileEntityWoodchipper.getOutputs();
for (int i = 0; i < inputs.size(); i++)
{
WoodchipperRecipe recipe = new WoodchipperRecipe(inputs.get(i), outputs.get(i));
this.arecipes.add(new CachedWoodchipperRecipe(recipe));
}
} else
{
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result)
{
WoodchipperRecipe recipe = new WoodchipperRecipe(TileEntityWoodchipper.getItemFromResult(result), result);
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.result, result))
{
this.arecipes.add(new CachedWoodchipperRecipe(recipe));
}
}
@Override
public void loadUsageRecipes(ItemStack ingred)
{
WoodchipperRecipe recipe = new WoodchipperRecipe(ingred, TileEntityWoodchipper.getResult(ingred));
if (NEIServerUtils.areStacksSameTypeCrafting(recipe.input, ingred))
{
this.arecipes.add(new CachedWoodchipperRecipe(recipe));
}
}
}

View file

@ -13,7 +13,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.FurnaceRecipes;
public class CRecipes public class CCRecipes
{ {
public static void init() public static void init()
{ {
@ -27,27 +27,22 @@ public class CRecipes
String[] unlocItem = ConfigHandler.woodchipperRecipeItem.split(":"); String[] unlocItem = ConfigHandler.woodchipperRecipeItem.split(":");
ItemStack centerItem = new ItemStack(Blocks.diamond_block); ItemStack centerItem = new ItemStack(Blocks.diamond_block);
if(GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1) != null) if (GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1) != null)
{ {
ItemStack newStack = GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1); ItemStack newStack = GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1);
if(unlocItem.length == 2) if (unlocItem.length == 2)
centerItem = newStack; centerItem = newStack;
if(unlocItem.length == 3) if (unlocItem.length == 3)
centerItem = new ItemStack(newStack.getItem(), 1, Integer.parseInt(unlocItem[2])); centerItem = new ItemStack(newStack.getItem(), 1, Integer.parseInt(unlocItem[2]));
} } else
else
{ {
CCLog.warn("Item " + ConfigHandler.woodchipperRecipeItem + "could not be added as part of the recipe of the Woodchipper."); CCLog.warn("Item " + ConfigHandler.woodchipperRecipeItem
+ "could not be added as part of the recipe of the Woodchipper.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
GameRegistry.addRecipe(new ItemStack(CCBlocks.woodchipper), new Object[] GameRegistry.addRecipe(new ItemStack(CCBlocks.woodchipper), new Object[]
{ { "I#I", "SCS", "I#I", '#', Items.diamond_axe, 'I', Blocks.iron_bars, 'S', Items.golden_axe, 'C', centerItem });
"I#I",
"SCS",
"I#I",
'#', Items.diamond_axe, 'I', Blocks.iron_bars, 'S', Items.golden_axe, 'C', centerItem
});
} }
static void electroextractorRecipe() static void electroextractorRecipe()
@ -55,28 +50,23 @@ public class CRecipes
String[] unlocItem = ConfigHandler.electroextractorRecipeItem.split(":"); String[] unlocItem = ConfigHandler.electroextractorRecipeItem.split(":");
ItemStack centerItem = new ItemStack(Blocks.diamond_block); ItemStack centerItem = new ItemStack(Blocks.diamond_block);
if(GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1) != null) if (GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1) != null)
{ {
ItemStack newStack = GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1); ItemStack newStack = GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1);
if(unlocItem.length == 2) if (unlocItem.length == 2)
centerItem = newStack; centerItem = newStack;
if(unlocItem.length == 3) if (unlocItem.length == 3)
centerItem = new ItemStack(newStack.getItem(), 1, Integer.parseInt(unlocItem[2])); centerItem = new ItemStack(newStack.getItem(), 1, Integer.parseInt(unlocItem[2]));
} } else
else
{ {
CCLog.warn("Item " + ConfigHandler.electroextractorRecipeItem + " could not be added as part of the recipe of the electroextractor."); CCLog.warn("Item " + ConfigHandler.electroextractorRecipeItem
+ " could not be added as part of the recipe of the electroextractor.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
GameRegistry.addRecipe(new ItemStack(CCBlocks.electroextractor), new Object[] GameRegistry.addRecipe(new ItemStack(CCBlocks.electroextractor), new Object[]
{ { "I#I", "SCS", "I#I", '#', Blocks.piston, 'I', Blocks.iron_bars, 'S', Items.golden_pickaxe, 'C', centerItem });
"I#I",
"SCS",
"I#I",
'#', Blocks.piston, 'I', Blocks.iron_bars, 'S', Items.golden_pickaxe, 'C', centerItem
});
} }
static void cropomatorRecipe() static void cropomatorRecipe()
@ -84,26 +74,21 @@ public class CRecipes
String[] unlocItem = ConfigHandler.cropomatorRecipeItem.split(":"); String[] unlocItem = ConfigHandler.cropomatorRecipeItem.split(":");
ItemStack centerItem = new ItemStack(Blocks.diamond_block); ItemStack centerItem = new ItemStack(Blocks.diamond_block);
if(GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1) != null) if (GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1) != null)
{ {
ItemStack newStack = GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1); ItemStack newStack = GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1);
if(unlocItem.length == 2) if (unlocItem.length == 2)
centerItem = newStack; centerItem = newStack;
if(unlocItem.length == 3) if (unlocItem.length == 3)
centerItem = new ItemStack(newStack.getItem(), 1, Integer.parseInt(unlocItem[2])); centerItem = new ItemStack(newStack.getItem(), 1, Integer.parseInt(unlocItem[2]));
} } else
else
{ {
CCLog.warn("Item " + ConfigHandler.cropomatorRecipeItem + " could not be added as part of the recipe of the cropomator."); CCLog.warn("Item " + ConfigHandler.cropomatorRecipeItem
+ " could not be added as part of the recipe of the cropomator.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
GameRegistry.addRecipe(new ItemStack(CCBlocks.cropomator), new Object[] GameRegistry.addRecipe(new ItemStack(CCBlocks.cropomator), new Object[]
{ { "I#I", "SCS", "I#I", '#', Blocks.hay_block, 'I', Items.iron_ingot, 'S', Items.golden_hoe, 'C', centerItem });
"I#I",
"SCS",
"I#I",
'#', Blocks.hay_block, 'I', Items.iron_ingot, 'S', Items.golden_hoe, 'C', centerItem
});
} }
} }

View file

@ -12,38 +12,41 @@ public class CropomatorRecipes
{ {
public static void initRecipes() public static void initRecipes()
{ {
for(int i = 0; i < ConfigHandler.cropomatorInputs.length; i++) for (int i = 0; i < ConfigHandler.cropomatorInputs.length; i++)
{ {
try try
{ {
String[] unlocStack = ConfigHandler.cropomatorInputs[i].split(":"); String[] unlocStack = ConfigHandler.cropomatorInputs[i].split(":");
if(unlocStack.length == 2) if (unlocStack.length == 2)
{ {
if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null)
TileEntityCropomator.addItemStackToOutputs(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1)); TileEntityCropomator
.addItemStackToOutputs(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1));
else else
{ {
CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's recipe list."); CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i]
+ " could not be added to the Cropomator's recipe list.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
} }
if(unlocStack.length == 3) if (unlocStack.length == 3)
{ {
if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null)
{ {
ItemStack newStack = new ItemStack(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1, Integer.parseInt(unlocStack[2])); ItemStack newStack = new ItemStack(
GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1,
Integer.parseInt(unlocStack[2]));
TileEntityCropomator.addItemStackToOutputs(newStack); TileEntityCropomator.addItemStackToOutputs(newStack);
} } else
else
{ {
CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's recipe list."); CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i]
+ " could not be added to the Cropomator's recipe list.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
} }
} } catch (Exception e)
catch(Exception e)
{ {
CCLog.warn("[CrissCross]: Error reading itemstack for inputs from input file at item: " + (i + 1)); CCLog.warn("[CrissCross]: Error reading itemstack for inputs from input file at item: " + (i + 1));
} }
@ -53,37 +56,40 @@ public class CropomatorRecipes
public static void initCatalysts() public static void initCatalysts()
{ {
for(int i = 0; i < ConfigHandler.cropomatorCatalysts.length; i++) for (int i = 0; i < ConfigHandler.cropomatorCatalysts.length; i++)
{ {
try try
{ {
String[] unlocStack = ConfigHandler.cropomatorCatalysts[i].split(":"); String[] unlocStack = ConfigHandler.cropomatorCatalysts[i].split(":");
if(unlocStack.length == 2) if (unlocStack.length == 2)
{ {
if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null)
TileEntityCropomator.addItemStackToCatalysts(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1)); TileEntityCropomator
.addItemStackToCatalysts(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1));
else else
{ {
CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's catalyst list."); CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i]
+ " could not be added to the Cropomator's catalyst list.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
} }
if(unlocStack.length == 3) if (unlocStack.length == 3)
{ {
if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null)
{ {
ItemStack newStack = new ItemStack(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1, Integer.parseInt(unlocStack[2])); ItemStack newStack = new ItemStack(
GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1,
Integer.parseInt(unlocStack[2]));
TileEntityCropomator.addItemStackToCatalysts(newStack); TileEntityCropomator.addItemStackToCatalysts(newStack);
} } else
else
{ {
CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's catalyst list."); CCLog.warn("Item " + ConfigHandler.cropomatorInputs[i]
+ " could not be added to the Cropomator's catalyst list.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
} }
} } catch (Exception e)
catch(Exception e)
{ {
CCLog.warn("Error reading itemstack for catalysts from input file at item: " + (i + 1)); CCLog.warn("Error reading itemstack for catalysts from input file at item: " + (i + 1));
} }

View file

@ -28,69 +28,73 @@ public class ElectroextractorRecipes
public static void oreDictionaryInit() public static void oreDictionaryInit()
{ {
ArrayList<String> dustNames = ItemDust.getDusts(); ArrayList<String> dustNames = ItemDust.getDusts();
for(int i = 0; i < ConfigHandler.electroextractorOreDictInputs.length; i++) for (int i = 0; i < ConfigHandler.electroextractorOreDictInputs.length; i++)
{ {
String[] entry = ConfigHandler.electroextractorOreDictInputs[i].split(":"); String[] entry = ConfigHandler.electroextractorOreDictInputs[i].split(":");
if(OreDictionary.doesOreNameExist("ore" + entry[0]) && OreDictionary.doesOreNameExist("ingot" + entry[0])) if (OreDictionary.doesOreNameExist("ore" + entry[0]) && OreDictionary.doesOreNameExist("ingot" + entry[0]))
{ {
ArrayList<ItemStack> ores = OreDictionary.getOres("ore" + entry[0]); ArrayList<ItemStack> ores = OreDictionary.getOres("ore" + entry[0]);
ItemDust.addDustType(entry[0], Integer.parseInt(entry[1])); ItemDust.addDustType(entry[0], Integer.parseInt(entry[1]));
for(int j = 0; j < ores.size(); j++) for (int j = 0; j < ores.size(); j++)
TileEntityElectroextractor.addRecipe(ores.get(j), new ItemStack(CCItems.dusts, 1, dustNames.size() - 1)); TileEntityElectroextractor.addRecipe(ores.get(j),
} new ItemStack(CCItems.dusts, 1, dustNames.size() - 1));
else } else
{ {
CCLog.warn("Your oreDictionary Entry " + ConfigHandler.electroextractorOreDictInputs[i] + " could not be registered."); CCLog.warn("Your oreDictionary Entry " + ConfigHandler.electroextractorOreDictInputs[i]
if(!OreDictionary.doesOreNameExist("ore" + entry[0])) + " could not be registered.");
CCLog.warn("This is because your oreDictionary Entry was not valid or registered as " + entry[0] + "."); if (!OreDictionary.doesOreNameExist("ore" + entry[0]))
else if(!OreDictionary.doesOreNameExist("ingot" + entry[0])) CCLog.warn("This is because your oreDictionary Entry was not valid or registered as " + entry[0]
+ ".");
else if (!OreDictionary.doesOreNameExist("ingot" + entry[0]))
CCLog.warn("This is because your oreDictionary Entry does not have an ingot for " + entry[0] + "."); CCLog.warn("This is because your oreDictionary Entry does not have an ingot for " + entry[0] + ".");
} }
} }
for(int i = 0; i < dustNames.size(); i++) for (int i = 0; i < dustNames.size(); i++)
{ {
ItemStack ingot = null; ItemStack ingot = null;
if(OreDictionary.doesOreNameExist("ingot" + dustNames.get(i))) if (OreDictionary.doesOreNameExist("ingot" + dustNames.get(i)))
ingot = OreDictionary.getOres("ingot" + dustNames.get(i)).get(0); ingot = OreDictionary.getOres("ingot" + dustNames.get(i)).get(0);
if(ingot != null) if (ingot != null)
GameRegistry.addSmelting(new ItemStack(CCItems.dusts, 1, i), ingot, 0.0F); GameRegistry.addSmelting(new ItemStack(CCItems.dusts, 1, i), ingot, 0.0F);
} }
} }
public static void initFuels() public static void initFuels()
{ {
for(int i = 0; i < ConfigHandler.electroextractorEnergySources.length; i++) for (int i = 0; i < ConfigHandler.electroextractorEnergySources.length; i++)
{ {
try try
{ {
String[] unlocStack = ConfigHandler.electroextractorEnergySources[i].split(":"); String[] unlocStack = ConfigHandler.electroextractorEnergySources[i].split(":");
if(unlocStack.length == 2) if (unlocStack.length == 2)
{ {
if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null)
TileEntityElectroextractor.addFuel(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 0)); TileEntityElectroextractor.addFuel(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 0));
else else
{ {
CCLog.warn("Item " + ConfigHandler.electroextractorEnergySources[i] + " could not be added to the Electroextractor's fuel list."); CCLog.warn("Item " + ConfigHandler.electroextractorEnergySources[i]
+ " could not be added to the Electroextractor's fuel list.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
} }
if(unlocStack.length == 3) if (unlocStack.length == 3)
{ {
if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null)
{ {
ItemStack newStack = new ItemStack(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1, Integer.parseInt(unlocStack[2])); ItemStack newStack = new ItemStack(
GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1,
Integer.parseInt(unlocStack[2]));
TileEntityElectroextractor.addFuel(newStack); TileEntityElectroextractor.addFuel(newStack);
} } else
else
{ {
CCLog.warn("Item " + ConfigHandler.electroextractorEnergySources[i] + " could not be added to the Electroextractor's fuel list."); CCLog.warn("Item " + ConfigHandler.electroextractorEnergySources[i]
+ " could not be added to the Electroextractor's fuel list.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
} }
} } catch (Exception e)
catch(Exception e)
{ {
CCLog.warn("Error reading itemstack for electroextractor's energy sources at item: " + (i + 1)); CCLog.warn("Error reading itemstack for electroextractor's energy sources at item: " + (i + 1));
} }

View file

@ -22,25 +22,25 @@ public class WoodchipperRecipes
String logName; String logName;
String plankName; String plankName;
for(int i = 0; i < logs.size(); i++) for (int i = 0; i < logs.size(); i++)
{ {
for(int logMeta = 0; logMeta < 16; logMeta++) for (int logMeta = 0; logMeta < 16; logMeta++)
{ {
ItemStack log = new ItemStack(logs.get(i).getItem(), 1, logMeta); ItemStack log = new ItemStack(logs.get(i).getItem(), 1, logMeta);
logName = log.getDisplayName(); logName = log.getDisplayName();
logName = logName.replace("Wood", ""); logName = logName.replace("Wood", "");
logName = logName.trim(); logName = logName.trim();
for(int j = 0; j < planks.size(); j++) for (int j = 0; j < planks.size(); j++)
{ {
for(int plankMeta = 0; plankMeta < 16; plankMeta++) for (int plankMeta = 0; plankMeta < 16; plankMeta++)
{ {
ItemStack plank = new ItemStack(planks.get(j).getItem(), 1, plankMeta); ItemStack plank = new ItemStack(planks.get(j).getItem(), 1, plankMeta);
plankName = plank.getDisplayName(); plankName = plank.getDisplayName();
plankName = plankName.replace("Wood", ""); plankName = plankName.replace("Wood", "");
plankName = plankName.replace("Planks", ""); plankName = plankName.replace("Planks", "");
plankName = plankName.trim(); plankName = plankName.trim();
if(plankName.contains(logName)) if (plankName.contains(logName))
{ {
TileEntityWoodchipper.addRecipe(log, plank); TileEntityWoodchipper.addRecipe(log, plank);
break; break;
@ -53,37 +53,39 @@ public class WoodchipperRecipes
public static void initFuels() public static void initFuels()
{ {
for(int i = 0; i < ConfigHandler.woodchipperFuels.length; i++) for (int i = 0; i < ConfigHandler.woodchipperFuels.length; i++)
{ {
try try
{ {
String[] unlocStack = ConfigHandler.woodchipperFuels[i].split(":"); String[] unlocStack = ConfigHandler.woodchipperFuels[i].split(":");
if(unlocStack.length == 2) if (unlocStack.length == 2)
{ {
if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null)
TileEntityWoodchipper.addFuel(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 0)); TileEntityWoodchipper.addFuel(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 0));
else else
{ {
CCLog.warn("Item " + ConfigHandler.woodchipperFuels[i] + " could not be added to the Woodchipper's fuel list."); CCLog.warn("Item " + ConfigHandler.woodchipperFuels[i]
+ " could not be added to the Woodchipper's fuel list.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
} }
if(unlocStack.length == 3) if (unlocStack.length == 3)
{ {
if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null)
{ {
ItemStack newStack = new ItemStack(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1, Integer.parseInt(unlocStack[2])); ItemStack newStack = new ItemStack(
GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1,
Integer.parseInt(unlocStack[2]));
TileEntityWoodchipper.addFuel(newStack); TileEntityWoodchipper.addFuel(newStack);
} } else
else
{ {
CCLog.warn("Item " + ConfigHandler.woodchipperFuels[i] + " could not be added to the Woodchipper's fuel list."); CCLog.warn("Item " + ConfigHandler.woodchipperFuels[i]
+ " could not be added to the Woodchipper's fuel list.");
CCLog.warn("Please confirm you have the name and formatting correct."); CCLog.warn("Please confirm you have the name and formatting correct.");
} }
} }
} } catch (Exception e)
catch(Exception e)
{ {
CCLog.warn("Error reading itemstack for Woodchipper's energy sources at item: " + (i + 1)); CCLog.warn("Error reading itemstack for Woodchipper's energy sources at item: " + (i + 1));
} }

View file

@ -18,389 +18,406 @@ import net.minecraft.tileentity.TileEntity;
public class TileEntityCropomator extends TileEntity implements ISidedInventory public class TileEntityCropomator extends TileEntity implements ISidedInventory
{ {
private static int proTicks = ConfigHandler.cropomatorProcessTime; private static int proTicks = ConfigHandler.cropomatorProcessTime;
private static int qty = ConfigHandler.cropomatorOutput; private static int qty = ConfigHandler.cropomatorOutput;
private static final int[] slotsTop = new int[] {0}; private static final int[] slotsTop = new int[]
private static final int[] slotsBottom = new int[] {2, 1}; { 0 };
private static final int[] slotsSides = new int[] {1}; private static final int[] slotsBottom = new int[]
private static ArrayList<ItemStack> recipeItems = new ArrayList<ItemStack>(); { 2, 1 };
private static ArrayList<ItemStack> catalystItems = new ArrayList<ItemStack>(); private static final int[] slotsSides = new int[]
{ 1 };
private static ArrayList<ItemStack> recipeItems = new ArrayList<ItemStack>();
private static ArrayList<ItemStack> catalystItems = new ArrayList<ItemStack>();
private ItemStack[] ItemStacks = new ItemStack[3]; private ItemStack[] ItemStacks = new ItemStack[3];
public int catalystTime; public int catalystTime;
public int processTime; public int processTime;
public int catalystInUseTime; public int catalystInUseTime;
public static ItemStack getResult(ItemStack input)
{
for (int i = 0; i < recipeItems.size(); i++)
{
ItemStack temp = recipeItems.get(i);
if (ItemStack.areItemStacksEqual(temp, input))
return new ItemStack(temp.getItem(), qty, temp.getItemDamage());
}
return null;
}
@Override @Override
public int getSizeInventory() public int getSizeInventory()
{ {
return this.ItemStacks.length; return this.ItemStacks.length;
} }
@Override
public ItemStack getStackInSlot(int slot)
{
return this.ItemStacks[slot];
}
@Override
public ItemStack decrStackSize(int slot, int qtyToDecr)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack;
if (this.ItemStacks[slot].stackSize <= qtyToDecr)
{
itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
}
else
{
itemstack = this.ItemStacks[slot].splitStack(qtyToDecr);
if (this.ItemStacks[slot].stackSize == 0)
{
this.ItemStacks[slot] = null;
}
return itemstack;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
this.ItemStacks[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
{
itemstack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "container.cropomator";
}
@Override
public boolean hasCustomInventoryName()
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
this.ItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
byte b0 = nbttagcompound1.getByte("Slot");
if (b0 >= 0 && b0 < this.ItemStacks.length)
{
this.ItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.catalystTime = tag.getShort("BonemealTime");
this.processTime = tag.getShort("ProcessTime");
this.catalystInUseTime = getItemBurnTime(this.ItemStacks[1]);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tag.setShort("BonemealTime", (short)this.catalystTime);
tag.setShort("ProcessTime", (short)this.processTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.ItemStacks.length; ++i)
{
if (this.ItemStacks[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
this.ItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tag.setTag("Items", nbttaglist);
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@SideOnly(Side.CLIENT)
public int getProgressScaled(int par1)
{
return this.processTime * par1 / proTicks;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1)
{
if (this.catalystInUseTime == 0)
{
this.catalystInUseTime = proTicks;
}
return this.catalystTime * par1 / this.catalystInUseTime;
}
public boolean isUsingFuel()
{
return this.catalystTime > 0;
}
public void updateEntity()
{
boolean flag = this.catalystTime > 0;
boolean flag1 = false;
if (this.catalystTime > 0)
{
--this.catalystTime;
}
if (!this.worldObj.isRemote)
{
if (this.catalystTime != 0 || this.ItemStacks[1] != null && this.ItemStacks[0] != null)
{
if (this.catalystTime == 0 && this.canProcess())
{
this.catalystInUseTime = this.catalystTime = getItemBurnTime(this.ItemStacks[1]);
if (this.catalystTime > 0)
{
flag1 = true;
if (this.ItemStacks[1] != null)
{
--this.ItemStacks[1].stackSize;
if (this.ItemStacks[1].stackSize == 0)
{
this.ItemStacks[1] = ItemStacks[1].getItem().getContainerItem(ItemStacks[1]);
}
}
}
}
if (this.isUsingFuel() && this.canProcess())
{
++this.processTime;
if (this.processTime == proTicks)
{
this.processTime = 0;
this.fertilizeItem();
flag1 = true;
}
}
else
{
this.processTime = 0;
}
}
if (flag != this.catalystTime > 0)
{
flag1 = true;
BlockCropomator.updateBlockState(this.catalystTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
}
if (flag1)
{
this.markDirty();
}
}
private boolean canProcess()
{
if (this.ItemStacks[0] == null)
{
return false;
}
else
{
ItemStack itemstack = new ItemStack(this.ItemStacks[0].getItem(), qty, this.ItemStacks[0].getItemDamage());
if(this.ItemStacks[2] == null)
return true;
if(!this.ItemStacks[2].isItemEqual(itemstack))
return false;
int result = ItemStacks[2].stackSize + itemstack.stackSize;
return result <= getInventoryStackLimit() && result <= this.ItemStacks[2].getMaxStackSize();
}
}
public static boolean removeItemStackFromOutputs(ItemStack itemstack)
{
for(int i = 0; i < recipeItems.size(); i++)
{
if(recipeItems.get(i) == itemstack)
{
recipeItems.remove(i);
return true;
}
}
return false;
}
public static void addItemStackToOutputs(ItemStack itemstack)
{
recipeItems.add(itemstack);
}
public static void addItemToOutputs(Item item)
{
recipeItems.add(new ItemStack(item));
}
public static void addBlockToOutputs(Block block)
{
recipeItems.add(new ItemStack(block));
}
public static void addItemStackToCatalysts(ItemStack itemstack)
{
catalystItems.add(itemstack);
}
public static boolean removeItemStackFromCatalysts(ItemStack itemstack)
{
for(int i = 0; i < catalystItems.size(); i++)
{
if(catalystItems.get(i) == itemstack)
{
catalystItems.remove(i);
return true;
}
}
return false;
}
public static boolean isValidForCropomator(ItemStack itemstack)
{
for(int i = 0; i < recipeItems.size(); i++)
{
ItemStack temp = recipeItems.get(i);
if(temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public void fertilizeItem()
{
if (this.canProcess())
{
ItemStack output = new ItemStack(this.ItemStacks[0].getItem(), qty, this.ItemStacks[0].getItemDamage());
if (this.ItemStacks[2] == null)
{
this.ItemStacks[2] = output.copy();
}
else if (this.ItemStacks[2].getItem() == output.getItem())
{
this.ItemStacks[2].stackSize += output.stackSize;
}
--this.ItemStacks[0].stackSize;
if (this.ItemStacks[0].stackSize <= 0)
{
this.ItemStacks[0] = null;
}
}
}
public static int getItemBurnTime(ItemStack itemstack)
{
return isItemCatalyst(itemstack) ? proTicks : 0;
}
public static boolean isItemCatalyst(ItemStack itemstack)
{
for(int i = 0; i < catalystItems.size(); i++)
{
ItemStack temp = catalystItems.get(i);
if(temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public boolean isUseableByPlayer(EntityPlayer player)
{
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}
public void openInventory(){}
public void closeInventory(){}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
return slot == 2 ? false : (slot == 1 ? isItemCatalyst(itemstack) : true);
}
@Override
public int[] getAccessibleSlotsFromSide(int slot)
{
return slot == 0 ? slotsBottom : (slot == 1 ? slotsTop : slotsSides);
}
@Override
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
{
return this.isItemValidForSlot(slot, itemstack);
}
@Override
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
{
return side != 0 || slot != 1;
}
@Override @Override
public void markDirty(){} public ItemStack getStackInSlot(int slot)
{
return this.ItemStacks[slot];
}
@Override
public ItemStack decrStackSize(int slot, int qtyToDecr)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack;
if (this.ItemStacks[slot].stackSize <= qtyToDecr)
{
itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
} else
{
itemstack = this.ItemStacks[slot].splitStack(qtyToDecr);
if (this.ItemStacks[slot].stackSize == 0)
{
this.ItemStacks[slot] = null;
}
return itemstack;
}
} else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
} else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
this.ItemStacks[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
{
itemstack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "container.cropomator";
}
@Override
public boolean hasCustomInventoryName()
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
this.ItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
byte b0 = nbttagcompound1.getByte("Slot");
if (b0 >= 0 && b0 < this.ItemStacks.length)
{
this.ItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.catalystTime = tag.getShort("BonemealTime");
this.processTime = tag.getShort("ProcessTime");
this.catalystInUseTime = getItemBurnTime(this.ItemStacks[1]);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tag.setShort("BonemealTime", (short) this.catalystTime);
tag.setShort("ProcessTime", (short) this.processTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.ItemStacks.length; ++i)
{
if (this.ItemStacks[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
this.ItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tag.setTag("Items", nbttaglist);
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@SideOnly(Side.CLIENT)
public int getProgressScaled(int par1)
{
return this.processTime * par1 / proTicks;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1)
{
if (this.catalystInUseTime == 0)
{
this.catalystInUseTime = proTicks;
}
return this.catalystTime * par1 / this.catalystInUseTime;
}
public boolean isUsingFuel()
{
return this.catalystTime > 0;
}
public void updateEntity()
{
boolean flag = this.catalystTime > 0;
boolean flag1 = false;
if (this.catalystTime > 0)
{
--this.catalystTime;
}
if (!this.worldObj.isRemote)
{
if (this.catalystTime != 0 || this.ItemStacks[1] != null && this.ItemStacks[0] != null)
{
if (this.catalystTime == 0 && this.canProcess())
{
this.catalystInUseTime = this.catalystTime = getItemBurnTime(this.ItemStacks[1]);
if (this.catalystTime > 0)
{
flag1 = true;
if (this.ItemStacks[1] != null)
{
--this.ItemStacks[1].stackSize;
if (this.ItemStacks[1].stackSize == 0)
{
this.ItemStacks[1] = ItemStacks[1].getItem().getContainerItem(ItemStacks[1]);
}
}
}
}
if (this.isUsingFuel() && this.canProcess())
{
++this.processTime;
if (this.processTime == proTicks)
{
this.processTime = 0;
this.fertilizeItem();
flag1 = true;
}
} else
{
this.processTime = 0;
}
}
if (flag != this.catalystTime > 0)
{
flag1 = true;
BlockCropomator.updateBlockState(this.catalystTime > 0, this.worldObj, this.xCoord, this.yCoord,
this.zCoord);
}
}
if (flag1)
{
this.markDirty();
}
}
private boolean canProcess()
{
if (this.ItemStacks[0] == null)
{
return false;
} else
{
ItemStack itemstack = new ItemStack(this.ItemStacks[0].getItem(), qty, this.ItemStacks[0].getItemDamage());
if (this.ItemStacks[2] == null)
return true;
if (!this.ItemStacks[2].isItemEqual(itemstack))
return false;
int result = ItemStacks[2].stackSize + itemstack.stackSize;
return result <= getInventoryStackLimit() && result <= this.ItemStacks[2].getMaxStackSize();
}
}
public static boolean removeItemStackFromOutputs(ItemStack itemstack)
{
for (int i = 0; i < recipeItems.size(); i++)
{
if (recipeItems.get(i) == itemstack)
{
recipeItems.remove(i);
return true;
}
}
return false;
}
public static void addItemStackToOutputs(ItemStack itemstack)
{
recipeItems.add(itemstack);
}
public static void addItemToOutputs(Item item)
{
recipeItems.add(new ItemStack(item));
}
public static void addBlockToOutputs(Block block)
{
recipeItems.add(new ItemStack(block));
}
public static void addItemStackToCatalysts(ItemStack itemstack)
{
catalystItems.add(itemstack);
}
public static boolean removeItemStackFromCatalysts(ItemStack itemstack)
{
for (int i = 0; i < catalystItems.size(); i++)
{
if (catalystItems.get(i) == itemstack)
{
catalystItems.remove(i);
return true;
}
}
return false;
}
public static boolean isValidForCropomator(ItemStack itemstack)
{
for (int i = 0; i < recipeItems.size(); i++)
{
ItemStack temp = recipeItems.get(i);
if (temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public void fertilizeItem()
{
if (this.canProcess())
{
ItemStack output = new ItemStack(this.ItemStacks[0].getItem(), qty, this.ItemStacks[0].getItemDamage());
if (this.ItemStacks[2] == null)
{
this.ItemStacks[2] = output.copy();
} else if (this.ItemStacks[2].getItem() == output.getItem())
{
this.ItemStacks[2].stackSize += output.stackSize;
}
--this.ItemStacks[0].stackSize;
if (this.ItemStacks[0].stackSize <= 0)
{
this.ItemStacks[0] = null;
}
}
}
public static int getItemBurnTime(ItemStack itemstack)
{
return isItemCatalyst(itemstack) ? proTicks : 0;
}
public static boolean isItemCatalyst(ItemStack itemstack)
{
for (int i = 0; i < catalystItems.size(); i++)
{
ItemStack temp = catalystItems.get(i);
if (temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public boolean isUseableByPlayer(EntityPlayer player)
{
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false
: player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D,
(double) this.zCoord + 0.5D) <= 64.0D;
}
public void openInventory()
{
}
public void closeInventory()
{
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
return slot == 2 ? false : (slot == 1 ? isItemCatalyst(itemstack) : true);
}
@Override
public int[] getAccessibleSlotsFromSide(int slot)
{
return slot == 0 ? slotsBottom : (slot == 1 ? slotsTop : slotsSides);
}
@Override
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
{
return this.isItemValidForSlot(slot, itemstack);
}
@Override
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
{
return side != 0 || slot != 1;
}
@Override
public void markDirty()
{
}
} }

View file

@ -19,418 +19,437 @@ import net.minecraft.tileentity.TileEntity;
public class TileEntityElectroextractor extends TileEntity implements ISidedInventory public class TileEntityElectroextractor extends TileEntity implements ISidedInventory
{ {
private static int proTicks = ConfigHandler.electroextractorProcessTime; private static int proTicks = ConfigHandler.electroextractorProcessTime;
private static int qty = ConfigHandler.electroextractorOutput; private static int qty = ConfigHandler.electroextractorOutput;
private static final int[] slotsTop = new int[] {0}; private static final int[] slotsTop = new int[]
private static final int[] slotsBottom = new int[] {2, 1}; { 0 };
private static final int[] slotsSides = new int[] {1}; private static final int[] slotsBottom = new int[]
private static ArrayList<ItemStack> inputItems = new ArrayList<ItemStack>(); { 2, 1 };
private static ArrayList<ItemStack> outputItems = new ArrayList<ItemStack>(); private static final int[] slotsSides = new int[]
private static ArrayList<ItemStack> fuelItems = new ArrayList<ItemStack>(); { 1 };
private static ArrayList<ItemStack> inputItems = new ArrayList<ItemStack>();
private static ArrayList<ItemStack> outputItems = new ArrayList<ItemStack>();
private static ArrayList<ItemStack> fuelItems = new ArrayList<ItemStack>();
private ItemStack[] ItemStacks = new ItemStack[3]; private ItemStack[] ItemStacks = new ItemStack[3];
public int fuelTime; public int fuelTime;
public int crushTime; public int crushTime;
public int fuelInUseTime; public int fuelInUseTime;
public static ItemStack getResult(ItemStack input)
{
for (int i = 0; i < inputItems.size(); i++)
{
ItemStack temp = inputItems.get(i);
if (ItemStack.areItemStacksEqual(temp, input))
return new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
}
return null;
}
@Override @Override
public int getSizeInventory() public int getSizeInventory()
{ {
return this.ItemStacks.length; return this.ItemStacks.length;
} }
@Override
public ItemStack getStackInSlot(int slot)
{
return this.ItemStacks[slot];
}
@Override
public ItemStack decrStackSize(int slot, int qtyToDecr)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack;
if (this.ItemStacks[slot].stackSize <= qtyToDecr)
{
itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
}
else
{
itemstack = this.ItemStacks[slot].splitStack(qtyToDecr);
if (this.ItemStacks[slot].stackSize == 0)
{
this.ItemStacks[slot] = null;
}
return itemstack;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
this.ItemStacks[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
{
itemstack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "container.electroextractor";
}
@Override
public boolean hasCustomInventoryName()
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
this.ItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
byte b0 = nbttagcompound1.getByte("Slot");
if (b0 >= 0 && b0 < this.ItemStacks.length)
{
this.ItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.fuelTime = tag.getShort("Energy");
this.crushTime = tag.getShort("CrushTime");
this.fuelInUseTime = getItemBurnTime(this.ItemStacks[1]);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tag.setShort("Energy", (short)this.fuelTime);
tag.setShort("CrushTime", (short)this.crushTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.ItemStacks.length; ++i)
{
if (this.ItemStacks[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
this.ItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tag.setTag("Items", nbttaglist);
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@SideOnly(Side.CLIENT)
public int getProgressScaled(int par1)
{
return this.crushTime * par1 / proTicks;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1)
{
if (this.fuelInUseTime == 0)
{
this.fuelInUseTime = proTicks;
}
return this.fuelTime * par1 / this.fuelInUseTime;
}
public boolean isUsingFuel()
{
return this.fuelTime > 0;
}
public void updateEntity()
{
boolean flag = this.fuelTime > 0;
boolean flag1 = false;
if (this.fuelTime > 0)
{
--this.fuelTime;
}
if (!this.worldObj.isRemote)
{
if (this.fuelTime != 0 || this.ItemStacks[1] != null && this.ItemStacks[0] != null)
{
if (this.fuelTime == 0 && this.canProcess())
{
this.fuelInUseTime = this.fuelTime = getItemBurnTime(this.ItemStacks[1]);
if (this.fuelTime > 0)
{
flag1 = true;
if (this.ItemStacks[1] != null)
{
--this.ItemStacks[1].stackSize;
if (this.ItemStacks[1].stackSize == 0)
{
this.ItemStacks[1] = ItemStacks[1].getItem().getContainerItem(ItemStacks[1]);
}
}
}
}
if (this.isUsingFuel() && this.canProcess())
{
++this.crushTime;
if (this.crushTime == proTicks)
{
this.crushTime = 0;
this.crushItem();
flag1 = true;
}
}
else
{
this.crushTime = 0;
}
}
if (flag != this.fuelTime > 0)
{
flag1 = true;
BlockElectroextractor.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
}
if (flag1)
{
this.markDirty();
}
}
private boolean canProcess()
{
if (this.ItemStacks[0] == null)
{
return false;
}
else
{
ItemStack output = null;
for(int i = 0; i < inputItems.size(); i++)
{
if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
{
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
}
}
if(output == null)
return false;
if(this.ItemStacks[2] == null)
return true;
if(!this.ItemStacks[2].isItemEqual(output))
return false;
int result = ItemStacks[2].stackSize + output.stackSize;
return result <= getInventoryStackLimit() && result <= this.ItemStacks[2].getMaxStackSize();
}
}
public static boolean removeRecipe(ItemStack itemstack)
{
for(int i = 0; i < inputItems.size(); i++)
{
if(inputItems.get(i) == itemstack)
{
inputItems.remove(i);
outputItems.remove(i);
return true;
}
}
return false;
}
public static void addRecipe(ItemStack input, ItemStack output)
{
inputItems.add(input);
outputItems.add(output);
}
public static void addRecipe(Item item, ItemStack output)
{
inputItems.add(new ItemStack(item));
outputItems.add(output);
}
public static void addRecipe(Block block, ItemStack output)
{
inputItems.add(new ItemStack(block));
outputItems.add(output);
}
public static void addFuel(ItemStack itemstack)
{
fuelItems.add(itemstack);
}
public static boolean removeFuel(ItemStack itemstack)
{
for(int i = 0; i < fuelItems.size(); i++)
{
if(fuelItems.get(i) == itemstack)
{
fuelItems.remove(i);
return true;
}
}
return false;
}
public static boolean isValidForElectroextractor(ItemStack itemstack)
{
for(int i = 0; i < inputItems.size(); i++)
{
ItemStack temp = inputItems.get(i);
if(temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public void crushItem()
{
if (this.canProcess())
{
ItemStack output = null;
for(int i = 0; i < inputItems.size(); i++)
{
if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
{
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
if(output.getItem() instanceof ItemDust)
output.setStackDisplayName("Electrolytic " + ItemDust.getName(outputItems.get(i).getItemDamage()) + " Dust");
}
}
if(output == null)
return;
if (this.ItemStacks[2] == null)
{
this.ItemStacks[2] = output.copy();
}
else if (this.ItemStacks[2].getItem() == output.getItem())
{
this.ItemStacks[2].stackSize += output.stackSize;
}
--this.ItemStacks[0].stackSize;
if (this.ItemStacks[0].stackSize <= 0)
{
this.ItemStacks[0] = null;
}
}
}
public static int getItemBurnTime(ItemStack itemstack)
{
return isItemEnergetic(itemstack) ? proTicks : 0;
}
public static boolean isItemEnergetic(ItemStack itemstack)
{
for(int i = 0; i < fuelItems.size(); i++)
{
ItemStack temp = fuelItems.get(i);
if(temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public boolean isUseableByPlayer(EntityPlayer player)
{
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}
public void openInventory(){}
public void closeInventory(){}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
return slot == 2 ? false : (slot == 1 ? isItemEnergetic(itemstack) : true);
}
@Override
public int[] getAccessibleSlotsFromSide(int slot)
{
return slot == 0 ? slotsBottom : (slot == 1 ? slotsTop : slotsSides);
}
@Override
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
{
return this.isItemValidForSlot(slot, itemstack);
}
@Override
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
{
return side != 0 || slot != 1;
}
@Override @Override
public void markDirty(){} public ItemStack getStackInSlot(int slot)
{
return this.ItemStacks[slot];
}
@Override
public ItemStack decrStackSize(int slot, int qtyToDecr)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack;
if (this.ItemStacks[slot].stackSize <= qtyToDecr)
{
itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
} else
{
itemstack = this.ItemStacks[slot].splitStack(qtyToDecr);
if (this.ItemStacks[slot].stackSize == 0)
{
this.ItemStacks[slot] = null;
}
return itemstack;
}
} else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
} else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
this.ItemStacks[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
{
itemstack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "container.electroextractor";
}
@Override
public boolean hasCustomInventoryName()
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
this.ItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
byte b0 = nbttagcompound1.getByte("Slot");
if (b0 >= 0 && b0 < this.ItemStacks.length)
{
this.ItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.fuelTime = tag.getShort("Energy");
this.crushTime = tag.getShort("CrushTime");
this.fuelInUseTime = getItemBurnTime(this.ItemStacks[1]);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tag.setShort("Energy", (short) this.fuelTime);
tag.setShort("CrushTime", (short) this.crushTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.ItemStacks.length; ++i)
{
if (this.ItemStacks[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
this.ItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tag.setTag("Items", nbttaglist);
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@SideOnly(Side.CLIENT)
public int getProgressScaled(int par1)
{
return this.crushTime * par1 / proTicks;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1)
{
if (this.fuelInUseTime == 0)
{
this.fuelInUseTime = proTicks;
}
return this.fuelTime * par1 / this.fuelInUseTime;
}
public boolean isUsingFuel()
{
return this.fuelTime > 0;
}
public void updateEntity()
{
boolean flag = this.fuelTime > 0;
boolean flag1 = false;
if (this.fuelTime > 0)
{
--this.fuelTime;
}
if (!this.worldObj.isRemote)
{
if (this.fuelTime != 0 || this.ItemStacks[1] != null && this.ItemStacks[0] != null)
{
if (this.fuelTime == 0 && this.canProcess())
{
this.fuelInUseTime = this.fuelTime = getItemBurnTime(this.ItemStacks[1]);
if (this.fuelTime > 0)
{
flag1 = true;
if (this.ItemStacks[1] != null)
{
--this.ItemStacks[1].stackSize;
if (this.ItemStacks[1].stackSize == 0)
{
this.ItemStacks[1] = ItemStacks[1].getItem().getContainerItem(ItemStacks[1]);
}
}
}
}
if (this.isUsingFuel() && this.canProcess())
{
++this.crushTime;
if (this.crushTime == proTicks)
{
this.crushTime = 0;
this.crushItem();
flag1 = true;
}
} else
{
this.crushTime = 0;
}
}
if (flag != this.fuelTime > 0)
{
flag1 = true;
BlockElectroextractor.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord,
this.zCoord);
}
}
if (flag1)
{
this.markDirty();
}
}
private boolean canProcess()
{
if (this.ItemStacks[0] == null)
{
return false;
} else
{
ItemStack output = null;
for (int i = 0; i < inputItems.size(); i++)
{
if (inputItems.get(i).getItem() == ItemStacks[0].getItem()
&& inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
{
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
}
}
if (output == null)
return false;
if (this.ItemStacks[2] == null)
return true;
if (!this.ItemStacks[2].isItemEqual(output))
return false;
int result = ItemStacks[2].stackSize + output.stackSize;
return result <= getInventoryStackLimit() && result <= this.ItemStacks[2].getMaxStackSize();
}
}
public static boolean removeRecipe(ItemStack itemstack)
{
for (int i = 0; i < inputItems.size(); i++)
{
if (inputItems.get(i) == itemstack)
{
inputItems.remove(i);
outputItems.remove(i);
return true;
}
}
return false;
}
public static void addRecipe(ItemStack input, ItemStack output)
{
inputItems.add(input);
outputItems.add(output);
}
public static void addRecipe(Item item, ItemStack output)
{
inputItems.add(new ItemStack(item));
outputItems.add(output);
}
public static void addRecipe(Block block, ItemStack output)
{
inputItems.add(new ItemStack(block));
outputItems.add(output);
}
public static void addFuel(ItemStack itemstack)
{
fuelItems.add(itemstack);
}
public static boolean removeFuel(ItemStack itemstack)
{
for (int i = 0; i < fuelItems.size(); i++)
{
if (fuelItems.get(i) == itemstack)
{
fuelItems.remove(i);
return true;
}
}
return false;
}
public static boolean isValidForElectroextractor(ItemStack itemstack)
{
for (int i = 0; i < inputItems.size(); i++)
{
ItemStack temp = inputItems.get(i);
if (temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public void crushItem()
{
if (this.canProcess())
{
ItemStack output = null;
for (int i = 0; i < inputItems.size(); i++)
{
if (inputItems.get(i).getItem() == ItemStacks[0].getItem()
&& inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
{
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
if (output.getItem() instanceof ItemDust)
output.setStackDisplayName(
"Electrolytic " + ItemDust.getName(outputItems.get(i).getItemDamage()) + " Dust");
}
}
if (output == null)
return;
if (this.ItemStacks[2] == null)
{
this.ItemStacks[2] = output.copy();
} else if (this.ItemStacks[2].getItem() == output.getItem())
{
this.ItemStacks[2].stackSize += output.stackSize;
}
--this.ItemStacks[0].stackSize;
if (this.ItemStacks[0].stackSize <= 0)
{
this.ItemStacks[0] = null;
}
}
}
public static int getItemBurnTime(ItemStack itemstack)
{
return isItemEnergetic(itemstack) ? proTicks : 0;
}
public static boolean isItemEnergetic(ItemStack itemstack)
{
for (int i = 0; i < fuelItems.size(); i++)
{
ItemStack temp = fuelItems.get(i);
if (temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public boolean isUseableByPlayer(EntityPlayer player)
{
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false
: player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D,
(double) this.zCoord + 0.5D) <= 64.0D;
}
public void openInventory()
{
}
public void closeInventory()
{
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
return slot == 2 ? false : (slot == 1 ? isItemEnergetic(itemstack) : true);
}
@Override
public int[] getAccessibleSlotsFromSide(int slot)
{
return slot == 0 ? slotsBottom : (slot == 1 ? slotsTop : slotsSides);
}
@Override
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
{
return this.isItemValidForSlot(slot, itemstack);
}
@Override
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
{
return side != 0 || slot != 1;
}
@Override
public void markDirty()
{
}
} }

View file

@ -18,415 +18,484 @@ import net.minecraft.tileentity.TileEntity;
public class TileEntityWoodchipper extends TileEntity implements ISidedInventory public class TileEntityWoodchipper extends TileEntity implements ISidedInventory
{ {
private static int proTicks = ConfigHandler.woodchipperProcessTime; private static int proTicks = ConfigHandler.woodchipperProcessTime;
private static int qty = ConfigHandler.woodchipperOutput; private static int qty = ConfigHandler.woodchipperOutput;
private static final int[] slotsTop = new int[] {0}; private static final int[] slotsTop = new int[]
private static final int[] slotsBottom = new int[] {2, 1}; { 0 };
private static final int[] slotsSides = new int[] {1}; private static final int[] slotsBottom = new int[]
private static ArrayList<ItemStack> inputItems = new ArrayList<ItemStack>(); { 2, 1 };
private static ArrayList<ItemStack> outputItems = new ArrayList<ItemStack>(); private static final int[] slotsSides = new int[]
private static ArrayList<ItemStack> fuelItems = new ArrayList<ItemStack>(); { 1 };
private static ArrayList<ItemStack> inputItems = new ArrayList<ItemStack>();
private static ArrayList<ItemStack> outputItems = new ArrayList<ItemStack>();
private static ArrayList<ItemStack> fuelItems = new ArrayList<ItemStack>();
private ItemStack[] ItemStacks = new ItemStack[3]; private ItemStack[] ItemStacks = new ItemStack[3];
public int fuelTime; public int fuelTime;
public int processTime; public int processTime;
public int fuelUsetime; public int fuelUsetime;
public static ItemStack getItemFromResult(ItemStack output)
{
for (int i = 0; i < outputItems.size(); i++)
{
ItemStack temp = outputItems.get(i);
if (ItemStack.areItemStacksEqual(temp, output))
return new ItemStack(inputItems.get(i).getItem(), qty, inputItems.get(i).getItemDamage());
}
return null;
}
public static ItemStack getResult(ItemStack input)
{
for (int i = 0; i < inputItems.size(); i++)
{
ItemStack temp = inputItems.get(i);
if (ItemStack.areItemStacksEqual(temp, input))
return new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
}
return null;
}
public static ArrayList<ItemStack> getInputs()
{
return inputItems;
}
public static ArrayList<ItemStack> getOutputs()
{
return outputItems;
}
public static ArrayList<ItemStack> getFuels()
{
return fuelItems;
}
@Override @Override
public int getSizeInventory() public int getSizeInventory()
{ {
return this.ItemStacks.length; return this.ItemStacks.length;
} }
@Override
public ItemStack getStackInSlot(int slot)
{
return this.ItemStacks[slot];
}
@Override
public ItemStack decrStackSize(int slot, int qtyToDecr)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack;
if (this.ItemStacks[slot].stackSize <= qtyToDecr)
{
itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
}
else
{
itemstack = this.ItemStacks[slot].splitStack(qtyToDecr);
if (this.ItemStacks[slot].stackSize == 0)
{
this.ItemStacks[slot] = null;
}
return itemstack;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
this.ItemStacks[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
{
itemstack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "container.woodchipper";
}
@Override
public boolean hasCustomInventoryName()
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
this.ItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
byte b0 = nbttagcompound1.getByte("Slot");
if (b0 >= 0 && b0 < this.ItemStacks.length)
{
this.ItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.fuelTime = tag.getShort("FuelTime");
this.processTime = tag.getShort("WorkTime");
this.fuelUsetime = getItemBurnTime(this.ItemStacks[1]);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tag.setShort("FuelTime", (short)this.fuelTime);
tag.setShort("WorkTime", (short)this.processTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.ItemStacks.length; ++i)
{
if (this.ItemStacks[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
this.ItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tag.setTag("Items", nbttaglist);
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@SideOnly(Side.CLIENT)
public int getProgressScaled(int par1)
{
return this.processTime * par1 / proTicks;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1)
{
if (this.fuelUsetime == 0)
{
this.fuelUsetime = proTicks;
}
return this.fuelTime * par1 / this.fuelUsetime;
}
public boolean isUsingFuel()
{
return this.fuelTime > 0;
}
public void updateEntity()
{
boolean flag = this.fuelTime > 0;
boolean flag1 = false;
if (this.fuelTime > 0)
{
--this.fuelTime;
}
if (!this.worldObj.isRemote)
{
if (this.fuelTime != 0 || this.ItemStacks[1] != null && this.ItemStacks[0] != null)
{
if (this.fuelTime == 0 && this.canProcess())
{
this.fuelUsetime = this.fuelTime = getItemBurnTime(this.ItemStacks[1]);
if (this.fuelTime > 0)
{
flag1 = true;
if (this.ItemStacks[1] != null)
{
--this.ItemStacks[1].stackSize;
if (this.ItemStacks[1].stackSize == 0)
{
this.ItemStacks[1] = ItemStacks[1].getItem().getContainerItem(ItemStacks[1]);
}
}
}
}
if (this.isUsingFuel() && this.canProcess())
{
++this.processTime;
if (this.processTime == proTicks)
{
this.processTime = 0;
this.processItem();
flag1 = true;
}
}
else
{
this.processTime = 0;
}
}
if (flag != this.fuelTime > 0)
{
flag1 = true;
BlockWoodchipper.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
}
if (flag1)
{
this.markDirty();
}
}
private boolean canProcess()
{
if (this.ItemStacks[0] == null)
{
return false;
}
else
{
ItemStack output = null;
for(int i = 0; i < inputItems.size(); i++)
{
if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
{
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
}
}
if(output == null)
return false;
if(this.ItemStacks[2] == null)
return true;
if(!this.ItemStacks[2].isItemEqual(output))
return false;
int result = ItemStacks[2].stackSize + output.stackSize;
return result <= getInventoryStackLimit() && result <= this.ItemStacks[2].getMaxStackSize();
}
}
public static boolean removeRecipe(ItemStack itemstack)
{
for(int i = 0; i < inputItems.size(); i++)
{
if(inputItems.get(i) == itemstack)
{
inputItems.remove(i);
outputItems.remove(i);
return true;
}
}
return false;
}
public static void addRecipe(ItemStack input, ItemStack output)
{
inputItems.add(input);
outputItems.add(output);
}
public static void addRecipe(Item item, ItemStack output)
{
inputItems.add(new ItemStack(item));
outputItems.add(output);
}
public static void addRecipe(Block block, ItemStack output)
{
inputItems.add(new ItemStack(block));
outputItems.add(output);
}
public static void addFuel(ItemStack itemstack)
{
fuelItems.add(itemstack);
}
public static boolean removeFuel(ItemStack itemstack)
{
for(int i = 0; i < fuelItems.size(); i++)
{
if(fuelItems.get(i) == itemstack)
{
fuelItems.remove(i);
return true;
}
}
return false;
}
public static boolean isValidForWoodchipper(ItemStack itemstack)
{
for(int i = 0; i < inputItems.size(); i++)
{
ItemStack temp = inputItems.get(i);
if(temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public void processItem()
{
if (this.canProcess())
{
ItemStack output = null;
for(int i = 0; i < inputItems.size(); i++)
{
if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
{
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
}
}
if(output == null)
return;
if (this.ItemStacks[2] == null)
{
this.ItemStacks[2] = output.copy();
}
else if (this.ItemStacks[2].getItem() == output.getItem())
{
this.ItemStacks[2].stackSize += output.stackSize;
}
--this.ItemStacks[0].stackSize;
if (this.ItemStacks[0].stackSize <= 0)
{
this.ItemStacks[0] = null;
}
}
}
public static int getItemBurnTime(ItemStack itemstack)
{
return isItemFuel(itemstack) ? proTicks : 0;
}
public static boolean isItemFuel(ItemStack itemstack)
{
for(int i = 0; i < fuelItems.size(); i++)
{
ItemStack temp = fuelItems.get(i);
if(temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public boolean isUseableByPlayer(EntityPlayer player)
{
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}
public void openInventory(){}
public void closeInventory(){}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
return slot == 2 ? false : (slot == 1 ? isItemFuel(itemstack) : true);
}
@Override
public int[] getAccessibleSlotsFromSide(int slot)
{
return slot == 0 ? slotsBottom : (slot == 1 ? slotsTop : slotsSides);
}
@Override
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
{
return this.isItemValidForSlot(slot, itemstack);
}
@Override
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
{
return side != 0 || slot != 1;
}
@Override @Override
public void markDirty(){} public ItemStack getStackInSlot(int slot)
{
return this.ItemStacks[slot];
}
@Override
public ItemStack decrStackSize(int slot, int qtyToDecr)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack;
if (this.ItemStacks[slot].stackSize <= qtyToDecr)
{
itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
} else
{
itemstack = this.ItemStacks[slot].splitStack(qtyToDecr);
if (this.ItemStacks[slot].stackSize == 0)
{
this.ItemStacks[slot] = null;
}
return itemstack;
}
} else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot)
{
if (this.ItemStacks[slot] != null)
{
ItemStack itemstack = this.ItemStacks[slot];
this.ItemStacks[slot] = null;
return itemstack;
} else
{
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack)
{
this.ItemStacks[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
{
itemstack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInventoryName()
{
return "container.woodchipper";
}
@Override
public boolean hasCustomInventoryName()
{
return true;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
this.ItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
byte b0 = nbttagcompound1.getByte("Slot");
if (b0 >= 0 && b0 < this.ItemStacks.length)
{
this.ItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.fuelTime = tag.getShort("FuelTime");
this.processTime = tag.getShort("WorkTime");
this.fuelUsetime = getItemBurnTime(this.ItemStacks[1]);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tag.setShort("FuelTime", (short) this.fuelTime);
tag.setShort("WorkTime", (short) this.processTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.ItemStacks.length; ++i)
{
if (this.ItemStacks[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
this.ItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tag.setTag("Items", nbttaglist);
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@SideOnly(Side.CLIENT)
public int getProgressScaled(int par1)
{
return this.processTime * par1 / proTicks;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1)
{
if (this.fuelUsetime == 0)
{
this.fuelUsetime = proTicks;
}
return this.fuelTime * par1 / this.fuelUsetime;
}
public boolean isUsingFuel()
{
return this.fuelTime > 0;
}
public void updateEntity()
{
boolean flag = this.fuelTime > 0;
boolean flag1 = false;
if (this.fuelTime > 0)
{
--this.fuelTime;
}
if (!this.worldObj.isRemote)
{
if (this.fuelTime != 0 || this.ItemStacks[1] != null && this.ItemStacks[0] != null)
{
if (this.fuelTime == 0 && this.canProcess())
{
this.fuelUsetime = this.fuelTime = getItemBurnTime(this.ItemStacks[1]);
if (this.fuelTime > 0)
{
flag1 = true;
if (this.ItemStacks[1] != null)
{
--this.ItemStacks[1].stackSize;
if (this.ItemStacks[1].stackSize == 0)
{
this.ItemStacks[1] = ItemStacks[1].getItem().getContainerItem(ItemStacks[1]);
}
}
}
}
if (this.isUsingFuel() && this.canProcess())
{
++this.processTime;
if (this.processTime == proTicks)
{
this.processTime = 0;
this.processItem();
flag1 = true;
}
} else
{
this.processTime = 0;
}
}
if (flag != this.fuelTime > 0)
{
flag1 = true;
BlockWoodchipper.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord,
this.zCoord);
}
}
if (flag1)
{
this.markDirty();
}
}
private boolean canProcess()
{
if (this.ItemStacks[0] == null)
{
return false;
} else
{
ItemStack output = null;
for (int i = 0; i < inputItems.size(); i++)
{
if (inputItems.get(i).getItem() == ItemStacks[0].getItem()
&& inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
{
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
}
}
if (output == null)
return false;
if (this.ItemStacks[2] == null)
return true;
if (!this.ItemStacks[2].isItemEqual(output))
return false;
int result = ItemStacks[2].stackSize + output.stackSize;
return result <= getInventoryStackLimit() && result <= this.ItemStacks[2].getMaxStackSize();
}
}
public static boolean removeRecipe(ItemStack itemstack)
{
for (int i = 0; i < inputItems.size(); i++)
{
if (inputItems.get(i) == itemstack)
{
inputItems.remove(i);
outputItems.remove(i);
return true;
}
}
return false;
}
public static void addRecipe(ItemStack input, ItemStack output)
{
inputItems.add(input);
outputItems.add(output);
}
public static void addRecipe(Item item, ItemStack output)
{
inputItems.add(new ItemStack(item));
outputItems.add(output);
}
public static void addRecipe(Block block, ItemStack output)
{
inputItems.add(new ItemStack(block));
outputItems.add(output);
}
public static void addFuel(ItemStack itemstack)
{
fuelItems.add(itemstack);
}
public static boolean removeFuel(ItemStack itemstack)
{
for (int i = 0; i < fuelItems.size(); i++)
{
if (fuelItems.get(i) == itemstack)
{
fuelItems.remove(i);
return true;
}
}
return false;
}
public static boolean isValidForWoodchipper(ItemStack itemstack)
{
for (int i = 0; i < inputItems.size(); i++)
{
ItemStack temp = inputItems.get(i);
if (temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public void processItem()
{
if (this.canProcess())
{
ItemStack output = null;
for (int i = 0; i < inputItems.size(); i++)
{
if (inputItems.get(i).getItem() == ItemStacks[0].getItem()
&& inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage())
{
output = new ItemStack(outputItems.get(i).getItem(), qty, outputItems.get(i).getItemDamage());
}
}
if (output == null)
return;
if (this.ItemStacks[2] == null)
{
this.ItemStacks[2] = output.copy();
} else if (this.ItemStacks[2].getItem() == output.getItem())
{
this.ItemStacks[2].stackSize += output.stackSize;
}
--this.ItemStacks[0].stackSize;
if (this.ItemStacks[0].stackSize <= 0)
{
this.ItemStacks[0] = null;
}
}
}
public static int getItemBurnTime(ItemStack itemstack)
{
return isItemFuel(itemstack) ? proTicks : 0;
}
public static boolean isItemFuel(ItemStack itemstack)
{
for (int i = 0; i < fuelItems.size(); i++)
{
ItemStack temp = fuelItems.get(i);
if (temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
return true;
}
return false;
}
public boolean isUseableByPlayer(EntityPlayer player)
{
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false
: player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D,
(double) this.zCoord + 0.5D) <= 64.0D;
}
public void openInventory()
{
}
public void closeInventory()
{
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
{
return slot == 2 ? false : (slot == 1 ? isItemFuel(itemstack) : true);
}
@Override
public int[] getAccessibleSlotsFromSide(int slot)
{
return slot == 0 ? slotsBottom : (slot == 1 ? slotsTop : slotsSides);
}
@Override
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
{
return this.isItemValidForSlot(slot, itemstack);
}
@Override
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
{
return side != 0 || slot != 1;
}
@Override
public void markDirty()
{
}
public static class WoodchipperRecipe
{
public final int time;
public final ItemStack input;
public final ItemStack result;
public WoodchipperRecipe(ItemStack input, ItemStack result)
{
this.time = ConfigHandler.woodchipperProcessTime;
this.input = input;
this.result = result;
}
public boolean matches(ItemStack input)
{
return ItemStack.areItemStacksEqual(this.input, input);
}
public ItemStack getResult()
{
return result.copy();
}
}
} }

View file

@ -2,6 +2,11 @@ package com.oitsjustjose.criss_cross.Util;
public class CommonProxy public class CommonProxy
{ {
public void preInit(){}; public void preInit()
public void init(){}; {
};
public void init()
{
};
} }

View file

@ -9,119 +9,125 @@ import net.minecraftforge.common.config.Configuration;
public class ConfigHandler public class ConfigHandler
{ {
public static Configuration config; public static Configuration config;
public static int cropomatorProcessTime; public static int cropomatorProcessTime;
public static int cropomatorOutput; public static int cropomatorOutput;
public static String cropomatorRecipeItem; public static String cropomatorRecipeItem;
public static String[] cropomatorInputs; public static String[] cropomatorInputs;
public static String[] cropomatorCatalysts; public static String[] cropomatorCatalysts;
public static String[] defaultCropomatorInputs = new String[] public static String[] defaultCropomatorInputs = new String[]
{ { "minecraft:apple", "minecraft:reeds", "minecraft:nether_wart", "minecraft:carrot", "minecraft:cactus",
"minecraft:apple", "minecraft:reeds", "minecraft:nether_wart", "minecraft:potato", "minecraft:sapling:0", "minecraft:sapling:1", "minecraft:sapling:2",
"minecraft:carrot", "minecraft:cactus", "minecraft:potato", "minecraft:sapling:3", "minecraft:sapling:4", "minecraft:sapling:5", "minecraft:melon",
"minecraft:sapling:0", "minecraft:sapling:1", "minecraft:sapling:2", "minecraft:brown_mushroom", "minecraft:red_mushroom", "minecraft:cocoa", "minecraft:pumpkin",
"minecraft:sapling:3", "minecraft:sapling:4", "minecraft:sapling:5", "minecraft:wheat", "minecraft:wheat_seeds" };
"minecraft:melon", "minecraft:brown_mushroom", "minecraft:red_mushroom", public static String[] defaultCropomatorCatalystItems = new String[]
"minecraft:cocoa", "minecraft:pumpkin", "minecraft:wheat", { "minecraft:dye:15" };
"minecraft:wheat_seeds"
};
public static String[] defaultCropomatorCatalystItems = new String[]
{
"minecraft:dye:15"
};
public static int electroextractorProcessTime; public static int electroextractorProcessTime;
public static int electroextractorOutput; public static int electroextractorOutput;
public static String electroextractorRecipeItem; public static String electroextractorRecipeItem;
public static String[] electroextractorEnergySources; public static String[] electroextractorEnergySources;
public static String[] electroextractorOreDictInputs; public static String[] electroextractorOreDictInputs;
public static String[] defaultElectroextractorOreDictInputs = new String[] public static String[] defaultElectroextractorOreDictInputs = new String[]
{ { "Iron:12428902", "Gold:15400704", "Aluminum:15987699", "Cobalt:17663", "Ardite:13938485", "Copper:16751872",
"Iron:12428902", "Gold:15400704", "Aluminum:15987699", "Tin:15132390", "Silver:13297640", "Lead:5722979", "Platinum:11067903", "Mithril:4433113",
"Cobalt:17663", "Ardite:13938485", "Copper:16751872", "Nickel:16580553" };
"Tin:15132390", "Silver:13297640", "Lead:5722979", public static String[] defaultElectroextractorEnergySources = new String[]
"Platinum:11067903", "Mithril:4433113", "Nickel:16580553" { "minecraft:redstone_block" };
};
public static String[] defaultElectroextractorEnergySources = new String[]
{
"minecraft:redstone_block"
};
public static int woodchipperProcessTime; public static int woodchipperProcessTime;
public static int woodchipperOutput; public static int woodchipperOutput;
public static String woodchipperRecipeItem; public static String woodchipperRecipeItem;
public static String[] woodchipperFuels; public static String[] woodchipperFuels;
public static String[] defaultWoodchipperFuels = new String[] public static String[] defaultWoodchipperFuels = new String[]
{ { "minecraft:water_bucket", "minecraft:potion:0" };
"minecraft:water_bucket", "minecraft:potion:0"
};
public static void init(File configFile) public static void init(File configFile)
{ {
// Create the configuration object from the given configuration file // Create the configuration object from the given configuration file
if (config == null) if (config == null)
{ {
config = new Configuration(configFile); config = new Configuration(configFile);
loadConfiguration(); loadConfiguration();
} }
} }
private static void loadConfiguration() private static void loadConfiguration()
{ {
//Cropomator Configs // Cropomator Configs
cropomatorInputs = config.get(config.CATEGORY_GENERAL, "Cropomator's Recipe Items.", defaultCropomatorInputs, cropomatorInputs = config
"A list of items to be added to the Cropomator's recipe list. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.").getStringList(); .get(config.CATEGORY_GENERAL, "Cropomator's Recipe Items.", defaultCropomatorInputs,
"A list of items to be added to the Cropomator's recipe list. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.")
.getStringList();
cropomatorCatalysts = config.get(config.CATEGORY_GENERAL, "Cropomator's Catalyst Items.", defaultCropomatorCatalystItems, cropomatorCatalysts = config
"A list of items to be added to the Cropomator's catalyst list. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.").getStringList(); .get(config.CATEGORY_GENERAL, "Cropomator's Catalyst Items.", defaultCropomatorCatalystItems,
"A list of items to be added to the Cropomator's catalyst list. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.")
.getStringList();
cropomatorProcessTime = config.getInt("Cropomator Processing Time", config.CATEGORY_GENERAL, 150, 1, Short.MAX_VALUE, cropomatorProcessTime = config.getInt("Cropomator Processing Time", config.CATEGORY_GENERAL, 150, 1,
"Control how many ticks it takes the Cropomator to process an item. Default is 150; furnaces are 200."); Short.MAX_VALUE,
"Control how many ticks it takes the Cropomator to process an item. Default is 150; furnaces are 200.");
cropomatorOutput = config.getInt("Cropomator Output Quantity", config.CATEGORY_GENERAL, 3, 0, 64, cropomatorOutput = config.getInt("Cropomator Output Quantity", config.CATEGORY_GENERAL, 3, 0, 64,
"Control how many of the input item you get as the output item. Default is 3."); "Control how many of the input item you get as the output item. Default is 3.");
cropomatorRecipeItem = config.getString("Cropomator Crafting Item.", config.CATEGORY_GENERAL, "minecraft:diamond_block", cropomatorRecipeItem = config.getString("Cropomator Crafting Item.", config.CATEGORY_GENERAL,
"This is the item located in the center of the crafting recipe for the Cropomator. Formatted as: <modid>:<item>:<meta> or <modid>:<item>."); "minecraft:diamond_block",
"This is the item located in the center of the crafting recipe for the Cropomator. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.");
//Electroextractor's Configs // Electroextractor's Configs
electroextractorEnergySources = config.get(config.CATEGORY_GENERAL, "Electroextractor's Fuel Items.", defaultElectroextractorEnergySources, electroextractorEnergySources = config
"A list of items to be added as the Electroextractor's energy sources. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.").getStringList(); .get(config.CATEGORY_GENERAL, "Electroextractor's Fuel Items.", defaultElectroextractorEnergySources,
"A list of items to be added as the Electroextractor's energy sources. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.")
.getStringList();
electroextractorProcessTime = config.getInt("Electroextractor Processing Time", config.CATEGORY_GENERAL, 250, 0, Short.MAX_VALUE, electroextractorProcessTime = config.getInt("Electroextractor Processing Time", config.CATEGORY_GENERAL, 250, 0,
"Control how many ticks it takes the Electroextractor to process an item. Default is 250; furnaces are 200."); Short.MAX_VALUE,
"Control how many ticks it takes the Electroextractor to process an item. Default is 250; furnaces are 200.");
electroextractorOutput = config.getInt("Electroextractor Output Quantity", config.CATEGORY_GENERAL, 2, 0, 64, electroextractorOutput = config.getInt("Electroextractor Output Quantity", config.CATEGORY_GENERAL, 2, 0, 64,
"Control how many dusts you get as the output. Default is 2."); "Control how many dusts you get as the output. Default is 2.");
electroextractorRecipeItem = config.getString("Electroextractor Crafting Item.", config.CATEGORY_GENERAL, "minecraft:diamond_block", electroextractorRecipeItem = config.getString("Electroextractor Crafting Item.", config.CATEGORY_GENERAL,
"This is the item located in the center of the crafting recipe for the Electroextractor. Formatted as: <modid>:<item>:<meta> or <modid>:<item>."); "minecraft:diamond_block",
"This is the item located in the center of the crafting recipe for the Electroextractor. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.");
electroextractorOreDictInputs = config.get(config.CATEGORY_GENERAL, "Electroextractor OreDictionary Entries.", defaultElectroextractorOreDictInputs, electroextractorOreDictInputs = config
"Formatted as <OreDictName>:<DecimalColorYouWant>." + "\n" + " Remove the 'ore' part of the oredict name (i.e. 'oreIron' should be entered as 'Iron')" + "\n" .get(config.CATEGORY_GENERAL, "Electroextractor OreDictionary Entries.",
+ "Use http://www.colorpicker.com/ to find a color and http://bit.ly/1RhPhcX to convert it from Hex to Decimal.").getStringList(); defaultElectroextractorOreDictInputs,
"Formatted as <OreDictName>:<DecimalColorYouWant>." + "\n"
+ " Remove the 'ore' part of the oredict name (i.e. 'oreIron' should be entered as 'Iron')"
+ "\n"
+ "Use http://www.colorpicker.com/ to find a color and http://bit.ly/1RhPhcX to convert it from Hex to Decimal.")
.getStringList();
//Woodchipper's Configs // Woodchipper's Configs
woodchipperFuels = config.get(config.CATEGORY_GENERAL, "Woodchipper Fuel Items", defaultWoodchipperFuels, woodchipperFuels = config
"A list of items to be added as the Woodchipper's 'fuels'. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.").getStringList(); .get(config.CATEGORY_GENERAL, "Woodchipper Fuel Items", defaultWoodchipperFuels,
"A list of items to be added as the Woodchipper's 'fuels'. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.")
.getStringList();
woodchipperProcessTime = config.getInt("Woodchipper Process Time", config.CATEGORY_GENERAL, 400, 0, Short.MAX_VALUE, woodchipperProcessTime = config.getInt("Woodchipper Process Time", config.CATEGORY_GENERAL, 400, 0,
"Control how many ticks it takes the Woodchipper to process an item. Default is 400; furnaces are 200."); Short.MAX_VALUE,
"Control how many ticks it takes the Woodchipper to process an item. Default is 400; furnaces are 200.");
woodchipperOutput = config.getInt("Woodchipper Output Quantity", config.CATEGORY_GENERAL, 6, 0, 64, woodchipperOutput = config.getInt("Woodchipper Output Quantity", config.CATEGORY_GENERAL, 6, 0, 64,
"Control how many planks are yielded from processing a log. Default is 6."); "Control how many planks are yielded from processing a log. Default is 6.");
woodchipperRecipeItem = config.getString("Woodchipper Crafting Item", config.CATEGORY_GENERAL, "minecraft:diamond_block", woodchipperRecipeItem = config.getString("Woodchipper Crafting Item", config.CATEGORY_GENERAL,
"This is the item located in the center of the crafting recipe for the Woodchipper. Formatted as: <modid>:<item>:<meta> or <modid>:<item>."); "minecraft:diamond_block",
"This is the item located in the center of the crafting recipe for the Woodchipper. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.");
if (config.hasChanged()) if (config.hasChanged())
config.save(); config.save();
} }
@SubscribeEvent @SubscribeEvent
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event)
{ {
if (event.modID.equalsIgnoreCase(Reference.modid)) if (event.modID.equalsIgnoreCase(Reference.modid))
loadConfiguration(); loadConfiguration();
} }
} }

View file

@ -14,7 +14,7 @@ public class OreDictionaryAdder
{ {
ArrayList<String> dustNames = ItemDust.getDusts(); ArrayList<String> dustNames = ItemDust.getDusts();
for(int i = 0; i < dustNames.size(); i++) for (int i = 0; i < dustNames.size(); i++)
OreDictionary.registerOre("dust" + dustNames.get(i), new ItemStack(CCItems.dusts, 1, i)); OreDictionary.registerOre("dust" + dustNames.get(i), new ItemStack(CCItems.dusts, 1, i));
} }
} }