From c50eaf826316cdae167600f8bf3bd2cc5dd41ddb Mon Sep 17 00:00:00 2001 From: oitsjustjose Date: Fri, 23 Oct 2015 14:03:45 -0400 Subject: [PATCH] Trying to work out an NEI handler... --- .../criss_cross/Blocks/BlockCropomator.java | 102 +- .../Blocks/BlockElectroextractor.java | 126 +-- .../criss_cross/Blocks/BlockMachineBase.java | 176 ++-- .../criss_cross/Blocks/BlockWoodchipper.java | 126 +-- .../criss_cross/Blocks/CCBlocks.java | 8 +- .../Container/ContainerCropomator.java | 202 ++-- .../Container/ContainerElectroextractor.java | 202 ++-- .../Container/ContainerWoodchipper.java | 199 ++-- .../Container/MachineOutputSlot.java | 82 +- .../oitsjustjose/criss_cross/CrissCross.java | 22 +- .../criss_cross/GUI/GUICropomator.java | 45 +- .../criss_cross/GUI/GUIElectroextractor.java | 48 +- .../criss_cross/GUI/GUIFactory.java | 38 +- .../criss_cross/GUI/GUIHandler.java | 42 +- .../criss_cross/GUI/GUIWoodchipper.java | 45 +- .../criss_cross/GUI/ModGUIConfig.java | 15 +- .../criss_cross/Items/CCItems.java | 1 + .../criss_cross/Items/ItemDust.java | 31 +- .../criss_cross/NEI/CCNEIIntegration.java | 34 + .../criss_cross/NEI/RecipeHandlerBase.java | 358 +++++++ .../NEI/RecipeHandlerCropomator.java | 0 .../NEI/RecipeHandlerElectroextractor.java | 6 + .../NEI/RecipeHandlerWoodchipper.java | 130 +++ .../Recipes/{CRecipes.java => CCRecipes.java} | 77 +- .../Recipes/CropomatorRecipes.java | 66 +- .../Recipes/ElectroextractorRecipes.java | 64 +- .../Recipes/WoodchipperRecipes.java | 46 +- .../TileEntity/TileEntityCropomator.java | 777 ++++++++-------- .../TileEntityElectroextractor.java | 837 +++++++++-------- .../TileEntity/TileEntityWoodchipper.java | 875 ++++++++++-------- .../oitsjustjose/criss_cross/Util/CCLog.java | 12 +- .../criss_cross/Util/ClientProxy.java | 4 +- .../criss_cross/Util/CommonProxy.java | 9 +- .../criss_cross/Util/ConfigHandler.java | 232 ++--- .../criss_cross/Util/OreDictionaryAdder.java | 4 +- 35 files changed, 2840 insertions(+), 2201 deletions(-) create mode 100644 src/main/java/com/oitsjustjose/criss_cross/NEI/CCNEIIntegration.java create mode 100644 src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerBase.java create mode 100644 src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerCropomator.java create mode 100644 src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerElectroextractor.java create mode 100644 src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerWoodchipper.java rename src/main/java/com/oitsjustjose/criss_cross/Recipes/{CRecipes.java => CCRecipes.java} (66%) diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCropomator.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCropomator.java index a4d1da0..ae59551 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCropomator.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCropomator.java @@ -21,8 +21,9 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlockCropomator extends BlockMachineBase -{ +{ private static String unlocName = "Cropomator"; + public BlockCropomator() { super(unlocName); @@ -39,75 +40,78 @@ public class BlockCropomator extends BlockMachineBase blockTextures[2] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Front"); blockTextures[3] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Sides"); } - + @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(); - TileEntityCropomator tile = (TileEntityCropomator)world.getTileEntity(x, y, z); + TileEntityCropomator tile = (TileEntityCropomator) world.getTileEntity(x, y, z); - if (tile != null) - { - for (int i = 0; i < tile.getSizeInventory(); ++i) - { - ItemStack itemstack = tile.getStackInSlot(i); + if (tile != null) + { + for (int i = 0; i < tile.getSizeInventory(); ++i) + { + ItemStack itemstack = tile.getStackInSlot(i); - if (itemstack != null) - { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - float f2 = random.nextFloat() * 0.8F + 0.1F; + if (itemstack != null) + { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + float f2 = random.nextFloat() * 0.8F + 0.1F; - while (itemstack.stackSize > 0) - { - int j = random.nextInt(21) + 10; + while (itemstack.stackSize > 0) + { + int j = random.nextInt(21) + 10; - if (j > itemstack.stackSize) - { - j = itemstack.stackSize; - } + if (j > itemstack.stackSize) + { + j = itemstack.stackSize; + } - 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())); + 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())); - if (itemstack.hasTagCompound()) - { - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem() + .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); + } - float f3 = 0.05F; - entityitem.motionX = (double)((float)random.nextGaussian() * f3); - entityitem.motionY = (double)((float)random.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = (double)((float)random.nextGaussian() * f3); - world.spawnEntityInWorld(entityitem); - } - } - } + float f3 = 0.05F; + entityitem.motionX = (double) ((float) random.nextGaussian() * f3); + entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double) ((float) random.nextGaussian() * f3); + 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 public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityCropomator(); } - + @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; - } - else + } else { - TileEntityCropomator tilecropomator = (TileEntityCropomator)world.getTileEntity(x, y, z); - if(tilecropomator != null) + TileEntityCropomator tilecropomator = (TileEntityCropomator) world.getTileEntity(x, y, z); + if (tilecropomator != null) player.openGui(CrissCross.instance, GUIHandler.Cropomator, world, x, y, z); return true; } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockElectroextractor.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockElectroextractor.java index b327bc6..3a97e0a 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockElectroextractor.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockElectroextractor.java @@ -21,15 +21,16 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlockElectroextractor extends BlockMachineBase -{ +{ private static String unlocName = "ElectroExtractor"; + public BlockElectroextractor() { super(unlocName); GameRegistry.registerTileEntity(TileEntityElectroextractor.class, unlocName); GameRegistry.registerBlock(this, unlocName); } - + @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister register) @@ -39,75 +40,78 @@ public class BlockElectroextractor extends BlockMachineBase blockTextures[2] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Front"); blockTextures[3] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Sides"); } - + @Override public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityElectroextractor(); } - + @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - Random random = new Random(); - TileEntityElectroextractor tile = (TileEntityElectroextractor)world.getTileEntity(x, y, z); - - if (tile != null) - { - for (int i = 0; i < tile.getSizeInventory(); ++i) - { - ItemStack itemstack = tile.getStackInSlot(i); - - if (itemstack != null) - { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - float f2 = random.nextFloat() * 0.8F + 0.1F; - - while (itemstack.stackSize > 0) - { - int j = random.nextInt(21) + 10; - - if (j > itemstack.stackSize) - { - j = itemstack.stackSize; - } - - 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())); - - if (itemstack.hasTagCompound()) - { - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - - float f3 = 0.05F; - entityitem.motionX = (double)((float)random.nextGaussian() * f3); - entityitem.motionY = (double)((float)random.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = (double)((float)random.nextGaussian() * f3); - world.spawnEntityInWorld(entityitem); - } - } - } - - world.func_147453_f(x, y, z, block); - - } - - super.breakBlock(world, x, y, z, block, meta); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - if(world.isRemote) + Random random = new Random(); + TileEntityElectroextractor tile = (TileEntityElectroextractor) world.getTileEntity(x, y, z); + + if (tile != null) + { + for (int i = 0; i < tile.getSizeInventory(); ++i) + { + ItemStack itemstack = tile.getStackInSlot(i); + + if (itemstack != null) + { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + float f2 = random.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j = random.nextInt(21) + 10; + + if (j > itemstack.stackSize) + { + j = itemstack.stackSize; + } + + 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())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem() + .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double) ((float) random.nextGaussian() * f3); + entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double) ((float) random.nextGaussian() * f3); + world.spawnEntityInWorld(entityitem); + } + } + } + + world.func_147453_f(x, y, z, block); + + } + + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, + float hitY, float hitZ) + { + if (world.isRemote) { return true; - } - else + } else { - TileEntityElectroextractor tileext = (TileEntityElectroextractor)world.getTileEntity(x, y, z); - if(tileext != null) + TileEntityElectroextractor tileext = (TileEntityElectroextractor) world.getTileEntity(x, y, z); + if (tileext != null) player.openGui(CrissCross.instance, GUIHandler.Electroextractor, world, x, y, z); return true; } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockMachineBase.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockMachineBase.java index e0e3fe0..f12641a 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockMachineBase.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockMachineBase.java @@ -19,123 +19,123 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockMachineBase extends BlockContainer -{ +{ IIcon[] blockTextures = new IIcon[4]; private static String unlocalizedName; private static boolean isActive = false; - + public BlockMachineBase(String unlocName) { - super(Material.rock); //0 - Top - this.setHardness(2.0F); //1 - Bottom - this.setResistance(2.0F); //3 - Front - this.setStepSound(soundTypeMetal); //4 - Sides + super(Material.rock); // 0 - Top + this.setHardness(2.0F); // 1 - Bottom + this.setResistance(2.0F); // 3 - Front + this.setStepSound(soundTypeMetal); // 4 - Sides this.setBlockName(Reference.modid + "." + unlocName); this.setCreativeTab(CrissCross.CCTab); - + this.unlocalizedName = unlocName; } - - //Used for the ItemStack vs. In-world Rendering + + // Used for the ItemStack vs. In-world Rendering @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - if(side == 0) - return blockTextures[0]; - if(side == 1) - return blockTextures[1]; - if(side == 3) - return blockTextures[2]; + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + if (side == 0) + return blockTextures[0]; + if (side == 1) + return blockTextures[1]; + if (side == 3) + return blockTextures[2]; - return blockTextures[3]; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) - { - if(side == 0) - return blockTextures[0]; - if(side == 1) - return blockTextures[1]; - if(side == access.getBlockMetadata(x, y, z)) - return blockTextures[2]; + return blockTextures[3]; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess access, int x, int y, int z, int side) + { + if (side == 0) + return blockTextures[0]; + if (side == 1) + return blockTextures[1]; + if (side == access.getBlockMetadata(x, y, z)) + return blockTextures[2]; + + return blockTextures[3]; + } - return blockTextures[3]; - } - @Override public void onBlockAdded(World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); setMetadataForFront(world, x, y, z); } - + @Override - 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; + 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; - if (l == 0) - { - world.setBlockMetadataWithNotify(x, y, z, 2, 2); - } + if (l == 0) + { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + } - if (l == 1) - { - world.setBlockMetadataWithNotify(x, y, z, 5, 2); - } + if (l == 1) + { + world.setBlockMetadataWithNotify(x, y, z, 5, 2); + } - if (l == 2) - { - world.setBlockMetadataWithNotify(x, y, z, 3, 2); - } + if (l == 2) + { + world.setBlockMetadataWithNotify(x, y, z, 3, 2); + } + + if (l == 3) + { + world.setBlockMetadataWithNotify(x, y, z, 4, 2); + } + } - if (l == 3) - { - world.setBlockMetadataWithNotify(x, y, z, 4, 2); - } - } - private void setMetadataForFront(World world, int x, int y, int z) - { - if (!world.isRemote) - { - Block block = world.getBlock(x, y, z - 1); - Block block1 = world.getBlock(x, y, z + 1); - Block block2 = world.getBlock(x - 1, y, z); - Block block3 = world.getBlock(x + 1, y, z); - byte b0 = 3; + { + if (!world.isRemote) + { + Block block = world.getBlock(x, y, z - 1); + Block block1 = world.getBlock(x, y, z + 1); + Block block2 = world.getBlock(x - 1, y, z); + Block block3 = world.getBlock(x + 1, y, z); + byte b0 = 3; - if (block.func_149730_j() && !block1.func_149730_j()) - { - b0 = 3; - } + if (block.func_149730_j() && !block1.func_149730_j()) + { + b0 = 3; + } - if (block1.func_149730_j() && !block.func_149730_j()) - { - b0 = 2; - } + if (block1.func_149730_j() && !block.func_149730_j()) + { + b0 = 2; + } - if (block2.func_149730_j() && !block3.func_149730_j()) - { - b0 = 5; - } + if (block2.func_149730_j() && !block3.func_149730_j()) + { + b0 = 5; + } - if (block3.func_149730_j() && !block2.func_149730_j()) - { - b0 = 4; - } + if (block3.func_149730_j() && !block2.func_149730_j()) + { + b0 = 4; + } - world.setBlockMetadataWithNotify(x, y, z, b0, 2); - } - } - - public static void updateBlockState(boolean active, World world, int x, int y, int z) - { - isActive = active; - } + world.setBlockMetadataWithNotify(x, y, z, b0, 2); + } + } + + public static void updateBlockState(boolean active, World world, int x, int y, int z) + { + isActive = active; + } @Override public TileEntity createNewTileEntity(World world, int meta) diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockWoodchipper.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockWoodchipper.java index aaa2db7..da06b3a 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockWoodchipper.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockWoodchipper.java @@ -20,15 +20,16 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlockWoodchipper extends BlockMachineBase -{ +{ private static String unlocName = "WoodChipper"; + public BlockWoodchipper() { super(unlocName); GameRegistry.registerTileEntity(TileEntityWoodchipper.class, unlocName); GameRegistry.registerBlock(this, unlocName); } - + @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister register) @@ -38,75 +39,78 @@ public class BlockWoodchipper extends BlockMachineBase blockTextures[2] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Front"); blockTextures[3] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Sides"); } - + @Override public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityWoodchipper(); } - + @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - Random random = new Random(); - TileEntityWoodchipper tile = (TileEntityWoodchipper)world.getTileEntity(x, y, z); - - if (tile != null) - { - for (int i = 0; i < tile.getSizeInventory(); ++i) - { - ItemStack itemstack = tile.getStackInSlot(i); - - if (itemstack != null) - { - float f = random.nextFloat() * 0.8F + 0.1F; - float f1 = random.nextFloat() * 0.8F + 0.1F; - float f2 = random.nextFloat() * 0.8F + 0.1F; - - while (itemstack.stackSize > 0) - { - int j = random.nextInt(21) + 10; - - if (j > itemstack.stackSize) - { - j = itemstack.stackSize; - } - - 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())); - - if (itemstack.hasTagCompound()) - { - entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); - } - - float f3 = 0.05F; - entityitem.motionX = (double)((float)random.nextGaussian() * f3); - entityitem.motionY = (double)((float)random.nextGaussian() * f3 + 0.2F); - entityitem.motionZ = (double)((float)random.nextGaussian() * f3); - world.spawnEntityInWorld(entityitem); - } - } - } - - world.func_147453_f(x, y, z, block); - - } - - super.breakBlock(world, x, y, z, block, meta); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { - if(world.isRemote) + Random random = new Random(); + TileEntityWoodchipper tile = (TileEntityWoodchipper) world.getTileEntity(x, y, z); + + if (tile != null) + { + for (int i = 0; i < tile.getSizeInventory(); ++i) + { + ItemStack itemstack = tile.getStackInSlot(i); + + if (itemstack != null) + { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + float f2 = random.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j = random.nextInt(21) + 10; + + if (j > itemstack.stackSize) + { + j = itemstack.stackSize; + } + + 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())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem() + .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double) ((float) random.nextGaussian() * f3); + entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double) ((float) random.nextGaussian() * f3); + world.spawnEntityInWorld(entityitem); + } + } + } + + world.func_147453_f(x, y, z, block); + + } + + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, + float hitY, float hitZ) + { + if (world.isRemote) { return true; - } - else + } else { - TileEntityWoodchipper tileext = (TileEntityWoodchipper)world.getTileEntity(x, y, z); - if(tileext != null) + TileEntityWoodchipper tileext = (TileEntityWoodchipper) world.getTileEntity(x, y, z); + if (tileext != null) player.openGui(CrissCross.instance, GUIHandler.Woodchipper, world, x, y, z); return true; } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/CCBlocks.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/CCBlocks.java index 69a6920..7a31fd9 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Blocks/CCBlocks.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/CCBlocks.java @@ -14,21 +14,21 @@ public class CCBlocks public static Block cropomator; public static Block electroextractor; public static Block woodchipper; - + public static void init() { cropomator = new BlockCropomator(); CropomatorRecipes.initRecipes(); CropomatorRecipes.initCatalysts(); - + electroextractor = new BlockElectroextractor(); ElectroextractorRecipes.initRecipes(); ElectroextractorRecipes.initFuels(); - + woodchipper = new BlockWoodchipper(); WoodchipperRecipes.initRecipes(); WoodchipperRecipes.initFuels(); - + NetworkRegistry.INSTANCE.registerGuiHandler(CrissCross.instance, new GUIHandler()); } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerCropomator.java b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerCropomator.java index b3ed075..4fac611 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerCropomator.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerCropomator.java @@ -17,166 +17,160 @@ public class ContainerCropomator extends Container { TileEntityCropomator cropomator; EntityPlayer player; - + private int lastUseTime; private int lastProcessTime; private int lastCatalystInUseTime; - + public ContainerCropomator(EntityPlayer player, TileEntityCropomator cropomator) { this.player = player; this.cropomator = cropomator; - + lastUseTime = 0; lastProcessTime = 0; lastCatalystInUseTime = 0; - - this.addSlotToContainer(new Slot(cropomator, 0, 56, 17)); //input - this.addSlotToContainer(new Slot(cropomator, 1, 56, 53)); //catalyst + + this.addSlotToContainer(new Slot(cropomator, 0, 56, 17)); // input + this.addSlotToContainer(new Slot(cropomator, 1, 56, 53)); // catalyst this.addSlotToContainer(new MachineOutputSlot(player, cropomator, 2, 116, 35)); this.addInventorySlots(); } - - @SideOnly(Side.CLIENT) - public void updateProgressBar(int timeType1, int timeType2) - { - if (timeType1 == 0) - { - this.cropomator.processTime = timeType2; - } - if (timeType1 == 1) - { - this.cropomator.catalystTime = timeType2; - } + @SideOnly(Side.CLIENT) + public void updateProgressBar(int timeType1, int timeType2) + { + if (timeType1 == 0) + { + this.cropomator.processTime = timeType2; + } + + if (timeType1 == 1) + { + this.cropomator.catalystTime = timeType2; + } + + if (timeType1 == 2) + { + this.cropomator.catalystInUseTime = timeType2; + } + } - if (timeType1 == 2) - { - this.cropomator.catalystInUseTime = timeType2; - } - } - @Override public void addCraftingToCrafters(ICrafting crafting) - { - super.addCraftingToCrafters(crafting); - crafting.sendProgressBarUpdate(this, 0, this.cropomator.processTime); - crafting.sendProgressBarUpdate(this, 1, this.cropomator.catalystTime); - crafting.sendProgressBarUpdate(this, 2, this.cropomator.catalystInUseTime); - } - + { + super.addCraftingToCrafters(crafting); + crafting.sendProgressBarUpdate(this, 0, this.cropomator.processTime); + crafting.sendProgressBarUpdate(this, 1, this.cropomator.catalystTime); + crafting.sendProgressBarUpdate(this, 2, this.cropomator.catalystInUseTime); + } + @Override public void 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); - - if(this.lastUseTime != this.cropomator.processTime) + ICrafting crafting = (ICrafting) this.crafters.get(i); + + if (this.lastUseTime != 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); - if(this.lastCatalystInUseTime != this.cropomator.catalystInUseTime) + if (this.lastCatalystInUseTime != this.cropomator.catalystInUseTime) crafting.sendProgressBarUpdate(this, 2, this.cropomator.catalystInUseTime); } this.lastUseTime = this.cropomator.processTime; this.lastProcessTime = this.cropomator.catalystTime; this.lastCatalystInUseTime = this.cropomator.catalystInUseTime; } - + @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { - ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(slotID); + ItemStack itemstack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); - if (slot != null && slot.getHasStack()) - { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); - if (slotID == 2) - { - if (!this.mergeItemStack(itemstack1, 3, 39, true)) - { - return null; - } + if (slotID == 2) + { + if (!this.mergeItemStack(itemstack1, 3, 39, true)) + { + return null; + } - slot.onSlotChange(itemstack1, itemstack); - } - else if (slotID != 1 && slotID != 0) - { - if (TileEntityCropomator.isValidForCropomator(itemstack1)) - { - if (!this.mergeItemStack(itemstack1, 0, 1, false)) - { - return null; - } - } - else if (TileEntityCropomator.isItemCatalyst(itemstack1)) - { - if (!this.mergeItemStack(itemstack1, 1, 2, false)) - { - return null; - } - } - else if (slotID >= 3 && slotID < 30) - { - if (!this.mergeItemStack(itemstack1, 30, 39, false)) - { - return null; - } - } - else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) - { - return null; - } - } - else if (!this.mergeItemStack(itemstack1, 3, 39, false)) - { - return null; - } + slot.onSlotChange(itemstack1, itemstack); + } else if (slotID != 1 && slotID != 0) + { + if (TileEntityCropomator.isValidForCropomator(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 0, 1, false)) + { + return null; + } + } else if (TileEntityCropomator.isItemCatalyst(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 1, 2, false)) + { + return null; + } + } else if (slotID >= 3 && slotID < 30) + { + if (!this.mergeItemStack(itemstack1, 30, 39, false)) + { + return null; + } + } else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) + { + return null; + } + } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) + { + return null; + } - if (itemstack1.stackSize == 0) - { - slot.putStack((ItemStack)null); - } - else - { - slot.onSlotChanged(); - } + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack) null); + } else + { + slot.onSlotChanged(); + } - if (itemstack1.stackSize == itemstack.stackSize) - { - return null; - } + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } - slot.onPickupFromSlot(player, itemstack1); - } + slot.onPickupFromSlot(player, itemstack1); + } - return itemstack; + return itemstack; } - + @Override public boolean canInteractWith(EntityPlayer player) { return this.cropomator.isUseableByPlayer(this.player); } - + public final void addInventorySlots() { this.addInventorySlots(8, 84, 142); } - + public final void addInventorySlots(int xOffset, int yOffset, int yHotbar) { InventoryPlayer inventory = this.player.inventory; - + for (int i = 0; i < 3; ++i) for (int j = 0; j < 9; ++j) this.addSlotToContainer(new Slot(inventory, 9 + j + i * 9, xOffset + j * 18, yOffset + i * 18)); - + for (int i = 0; i < 9; ++i) this.addSlotToContainer(new Slot(inventory, i, xOffset + i * 18, yHotbar)); } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerElectroextractor.java b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerElectroextractor.java index 0564c7e..835257e 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerElectroextractor.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerElectroextractor.java @@ -15,166 +15,160 @@ public class ContainerElectroextractor extends Container { TileEntityElectroextractor electroextractor; EntityPlayer player; - + private int lastUseTime; private int lastCrushTime; private int lastFuelTime; - + public ContainerElectroextractor(EntityPlayer player, TileEntityElectroextractor electroextractor) { this.player = player; this.electroextractor = electroextractor; - + lastUseTime = 0; lastCrushTime = 0; lastFuelTime = 0; - - this.addSlotToContainer(new Slot(electroextractor, 0, 56, 17)); //input - this.addSlotToContainer(new Slot(electroextractor, 1, 56, 53)); //fuelitem + + this.addSlotToContainer(new Slot(electroextractor, 0, 56, 17)); // input + this.addSlotToContainer(new Slot(electroextractor, 1, 56, 53)); // fuelitem this.addSlotToContainer(new MachineOutputSlot(player, electroextractor, 2, 116, 35)); this.addInventorySlots(); } - - @SideOnly(Side.CLIENT) - public void updateProgressBar(int timeType1, int timeType2) - { - if (timeType1 == 0) - { - this.electroextractor.crushTime = timeType2; - } - if (timeType1 == 1) - { - this.electroextractor.fuelTime = timeType2; - } + @SideOnly(Side.CLIENT) + public void updateProgressBar(int timeType1, int timeType2) + { + if (timeType1 == 0) + { + this.electroextractor.crushTime = timeType2; + } + + if (timeType1 == 1) + { + this.electroextractor.fuelTime = timeType2; + } + + if (timeType1 == 2) + { + this.electroextractor.fuelInUseTime = timeType2; + } + } - if (timeType1 == 2) - { - this.electroextractor.fuelInUseTime = timeType2; - } - } - @Override public void addCraftingToCrafters(ICrafting crafting) - { - super.addCraftingToCrafters(crafting); - crafting.sendProgressBarUpdate(this, 0, this.electroextractor.crushTime); - crafting.sendProgressBarUpdate(this, 1, this.electroextractor.fuelTime); - crafting.sendProgressBarUpdate(this, 2, this.electroextractor.fuelInUseTime); - } - + { + super.addCraftingToCrafters(crafting); + crafting.sendProgressBarUpdate(this, 0, this.electroextractor.crushTime); + crafting.sendProgressBarUpdate(this, 1, this.electroextractor.fuelTime); + crafting.sendProgressBarUpdate(this, 2, this.electroextractor.fuelInUseTime); + } + @Override public void 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); - - if(this.lastUseTime != this.electroextractor.crushTime) + ICrafting crafting = (ICrafting) this.crafters.get(i); + + if (this.lastUseTime != 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); - if(this.lastFuelTime != this.electroextractor.fuelInUseTime) + if (this.lastFuelTime != this.electroextractor.fuelInUseTime) crafting.sendProgressBarUpdate(this, 2, this.electroextractor.fuelInUseTime); } this.lastUseTime = this.electroextractor.crushTime; this.lastCrushTime = this.electroextractor.fuelTime; this.lastFuelTime = this.electroextractor.fuelInUseTime; } - + @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { - ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(slotID); + ItemStack itemstack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); - if (slot != null && slot.getHasStack()) - { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); - if (slotID == 2) - { - if (!this.mergeItemStack(itemstack1, 3, 39, true)) - { - return null; - } + if (slotID == 2) + { + if (!this.mergeItemStack(itemstack1, 3, 39, true)) + { + return null; + } - slot.onSlotChange(itemstack1, itemstack); - } - else if (slotID != 1 && slotID != 0) - { - if (TileEntityElectroextractor.isValidForElectroextractor(itemstack1)) - { - if (!this.mergeItemStack(itemstack1, 0, 1, false)) - { - return null; - } - } - else if (TileEntityElectroextractor.isItemEnergetic(itemstack1)) - { - if (!this.mergeItemStack(itemstack1, 1, 2, false)) - { - return null; - } - } - else if (slotID >= 3 && slotID < 30) - { - if (!this.mergeItemStack(itemstack1, 30, 39, false)) - { - return null; - } - } - else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) - { - return null; - } - } - else if (!this.mergeItemStack(itemstack1, 3, 39, false)) - { - return null; - } + slot.onSlotChange(itemstack1, itemstack); + } else if (slotID != 1 && slotID != 0) + { + if (TileEntityElectroextractor.isValidForElectroextractor(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 0, 1, false)) + { + return null; + } + } else if (TileEntityElectroextractor.isItemEnergetic(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 1, 2, false)) + { + return null; + } + } else if (slotID >= 3 && slotID < 30) + { + if (!this.mergeItemStack(itemstack1, 30, 39, false)) + { + return null; + } + } else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) + { + return null; + } + } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) + { + return null; + } - if (itemstack1.stackSize == 0) - { - slot.putStack((ItemStack)null); - } - else - { - slot.onSlotChanged(); - } + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack) null); + } else + { + slot.onSlotChanged(); + } - if (itemstack1.stackSize == itemstack.stackSize) - { - return null; - } + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } - slot.onPickupFromSlot(player, itemstack1); - } + slot.onPickupFromSlot(player, itemstack1); + } - return itemstack; + return itemstack; } - + @Override public boolean canInteractWith(EntityPlayer player) { return this.electroextractor.isUseableByPlayer(this.player); } - + public final void addInventorySlots() { this.addInventorySlots(8, 84, 142); } - + public final void addInventorySlots(int xOffset, int yOffset, int yHotbar) { InventoryPlayer inventory = this.player.inventory; - + for (int i = 0; i < 3; ++i) for (int j = 0; j < 9; ++j) this.addSlotToContainer(new Slot(inventory, 9 + j + i * 9, xOffset + j * 18, yOffset + i * 18)); - + for (int i = 0; i < 9; ++i) this.addSlotToContainer(new Slot(inventory, i, xOffset + i * 18, yHotbar)); } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerWoodchipper.java b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerWoodchipper.java index 14c0554..b59438f 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerWoodchipper.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerWoodchipper.java @@ -15,161 +15,158 @@ public class ContainerWoodchipper extends Container { TileEntityWoodchipper woodchipper; EntityPlayer player; - + private int lastUseTime; private int lastChopTime; private int lastFuelTime; - + public ContainerWoodchipper(EntityPlayer player, TileEntityWoodchipper woodchipper) { this.player = player; this.woodchipper = woodchipper; - + lastUseTime = 0; lastChopTime = 0; lastFuelTime = 0; - - this.addSlotToContainer(new Slot(woodchipper, 0, 56, 17)); //input - this.addSlotToContainer(new Slot(woodchipper, 1, 56, 53)); //catalyst + + this.addSlotToContainer(new Slot(woodchipper, 0, 56, 17)); // input + this.addSlotToContainer(new Slot(woodchipper, 1, 56, 53)); // catalyst this.addSlotToContainer(new MachineOutputSlot(player, woodchipper, 2, 116, 35)); this.addInventorySlots(); } - - @SideOnly(Side.CLIENT) - public void updateProgressBar(int timeType1, int timeType2) - { - switch(timeType1) - { - case 0:this.woodchipper.processTime = timeType2; - break; - case 1:this.woodchipper.fuelTime = timeType2; - break; - case 2:this.woodchipper.fuelUsetime = timeType2; - break; - } - } - + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int timeType1, int timeType2) + { + switch (timeType1) + { + case 0: + this.woodchipper.processTime = timeType2; + break; + case 1: + this.woodchipper.fuelTime = timeType2; + break; + case 2: + this.woodchipper.fuelUsetime = timeType2; + break; + } + } + @Override public void addCraftingToCrafters(ICrafting crafting) - { - super.addCraftingToCrafters(crafting); - crafting.sendProgressBarUpdate(this, 0, this.woodchipper.processTime); - crafting.sendProgressBarUpdate(this, 1, this.woodchipper.fuelTime); - crafting.sendProgressBarUpdate(this, 2, this.woodchipper.fuelUsetime); - } - + { + super.addCraftingToCrafters(crafting); + crafting.sendProgressBarUpdate(this, 0, this.woodchipper.processTime); + crafting.sendProgressBarUpdate(this, 1, this.woodchipper.fuelTime); + crafting.sendProgressBarUpdate(this, 2, this.woodchipper.fuelUsetime); + } + @Override public void 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); - - if(this.lastUseTime != this.woodchipper.processTime) + ICrafting crafting = (ICrafting) this.crafters.get(i); + + if (this.lastUseTime != 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); - if(this.lastFuelTime != this.woodchipper.fuelUsetime) + if (this.lastFuelTime != this.woodchipper.fuelUsetime) crafting.sendProgressBarUpdate(this, 2, this.woodchipper.fuelUsetime); } this.lastUseTime = this.woodchipper.processTime; this.lastChopTime = this.woodchipper.fuelTime; this.lastFuelTime = this.woodchipper.fuelUsetime; } - + @Override public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { - ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(slotID); + ItemStack itemstack = null; + Slot slot = (Slot) this.inventorySlots.get(slotID); - if (slot != null && slot.getHasStack()) - { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); - if (slotID == 2) - { - if (!this.mergeItemStack(itemstack1, 3, 39, true)) - { - return null; - } + if (slotID == 2) + { + if (!this.mergeItemStack(itemstack1, 3, 39, true)) + { + return null; + } - slot.onSlotChange(itemstack1, itemstack); - } - else if (slotID != 1 && slotID != 0) - { - if (TileEntityWoodchipper.isValidForWoodchipper(itemstack1)) - { - if (!this.mergeItemStack(itemstack1, 0, 1, false)) - { - return null; - } - } - else if (TileEntityWoodchipper.isItemFuel(itemstack1)) - { - if (!this.mergeItemStack(itemstack1, 1, 2, false)) - { - return null; - } - } - else if (slotID >= 3 && slotID < 30) - { - if (!this.mergeItemStack(itemstack1, 30, 39, false)) - { - return null; - } - } - else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) - { - return null; - } - } - else if (!this.mergeItemStack(itemstack1, 3, 39, false)) - { - return null; - } + slot.onSlotChange(itemstack1, itemstack); + } else if (slotID != 1 && slotID != 0) + { + if (TileEntityWoodchipper.isValidForWoodchipper(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 0, 1, false)) + { + return null; + } + } else if (TileEntityWoodchipper.isItemFuel(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 1, 2, false)) + { + return null; + } + } else if (slotID >= 3 && slotID < 30) + { + if (!this.mergeItemStack(itemstack1, 30, 39, false)) + { + return null; + } + } else if (slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) + { + return null; + } + } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) + { + return null; + } - if (itemstack1.stackSize == 0) - { - slot.putStack((ItemStack)null); - } - else - { - slot.onSlotChanged(); - } + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack) null); + } else + { + slot.onSlotChanged(); + } - if (itemstack1.stackSize == itemstack.stackSize) - { - return null; - } + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } - slot.onPickupFromSlot(player, itemstack1); - } + slot.onPickupFromSlot(player, itemstack1); + } - return itemstack; + return itemstack; } - + @Override public boolean canInteractWith(EntityPlayer player) { return this.woodchipper.isUseableByPlayer(this.player); } - + public final void addInventorySlots() { this.addInventorySlots(8, 84, 142); } - + public final void addInventorySlots(int xOffset, int yOffset, int yHotbar) { InventoryPlayer inventory = this.player.inventory; - + for (int i = 0; i < 3; ++i) for (int j = 0; j < 9; ++j) this.addSlotToContainer(new Slot(inventory, 9 + j + i * 9, xOffset + j * 18, yOffset + i * 18)); - + for (int i = 0; i < 9; ++i) this.addSlotToContainer(new Slot(inventory, i, xOffset + i * 18, yHotbar)); } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Container/MachineOutputSlot.java b/src/main/java/com/oitsjustjose/criss_cross/Container/MachineOutputSlot.java index 1f5b4dc..9198e4d 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Container/MachineOutputSlot.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Container/MachineOutputSlot.java @@ -13,51 +13,51 @@ import net.minecraft.util.MathHelper; public class MachineOutputSlot extends Slot { - /** The player that is using the GUI where this slot resides. */ - private EntityPlayer thePlayer; - private int temp; + /** The player that is using the GUI where this slot resides. */ + private EntityPlayer thePlayer; + private int temp; - public MachineOutputSlot(EntityPlayer player, IInventory inventory, int x, int y, int z) - { - super(inventory, x, y, z); - this.thePlayer = player; - } + public MachineOutputSlot(EntityPlayer player, IInventory inventory, int x, int y, int z) + { + super(inventory, x, y, z); + this.thePlayer = player; + } - @Override - public boolean isItemValid(ItemStack stack) - { - return false; - } - - @Override - public ItemStack decrStackSize(int slot) - { - if (this.getHasStack()) - { - this.temp += Math.min(slot, this.getStack().stackSize); - } + @Override + public boolean isItemValid(ItemStack stack) + { + return false; + } - return super.decrStackSize(slot); - } + @Override + public ItemStack decrStackSize(int slot) + { + if (this.getHasStack()) + { + this.temp += Math.min(slot, this.getStack().stackSize); + } - @Override - public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack) - { - this.onCrafting(itemstack); - super.onPickupFromSlot(player, itemstack); - } + return super.decrStackSize(slot); + } - @Override - protected void onCrafting(ItemStack itemstack, int slot) - { - this.temp += slot; - this.onCrafting(itemstack); - } + @Override + public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack) + { + this.onCrafting(itemstack); + super.onPickupFromSlot(player, itemstack); + } - @Override - protected void onCrafting(ItemStack stack) - { - stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.temp); - this.temp = 0; - } + @Override + protected void onCrafting(ItemStack itemstack, int slot) + { + this.temp += slot; + this.onCrafting(itemstack); + } + + @Override + protected void onCrafting(ItemStack stack) + { + stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.temp); + this.temp = 0; + } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/CrissCross.java b/src/main/java/com/oitsjustjose/criss_cross/CrissCross.java index ec44ee8..98e8a45 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/CrissCross.java +++ b/src/main/java/com/oitsjustjose/criss_cross/CrissCross.java @@ -2,7 +2,7 @@ package com.oitsjustjose.criss_cross; import com.oitsjustjose.criss_cross.Blocks.CCBlocks; 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.ConfigHandler; import com.oitsjustjose.criss_cross.Util.OreDictionaryAdder; @@ -22,28 +22,28 @@ import net.minecraft.creativetab.CreativeTabs; public class CrissCross { public static CreativeTabs CCTab; - - @Instance(Reference.modid) - public static CrissCross instance; - - @SidedProxy(clientSide = "com.oitsjustjose.criss_cross.Util.ClientProxy", serverSide = "com.oitsjustjose.criss_cross.Util.CommonProxy") - public static CommonProxy proxy; - + + @Instance(Reference.modid) + public static CrissCross instance; + + @SidedProxy(clientSide = "com.oitsjustjose.criss_cross.Util.ClientProxy", serverSide = "com.oitsjustjose.criss_cross.Util.CommonProxy") + public static CommonProxy proxy; + @EventHandler public static void preInit(FMLPreInitializationEvent event) { ConfigHandler.init(event.getSuggestedConfigurationFile()); - FMLCommonHandler.instance().bus().register(new ConfigHandler()); + FMLCommonHandler.instance().bus().register(new ConfigHandler()); CCTab = new CCTab(); proxy.preInit(); } - + @EventHandler public static void init(FMLInitializationEvent event) { CCBlocks.init(); CCItems.init(); - CRecipes.init(); + CCRecipes.init(); OreDictionaryAdder.init(); proxy.init(); } diff --git a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUICropomator.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUICropomator.java index 8c48eaa..42a326c 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUICropomator.java +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUICropomator.java @@ -15,35 +15,36 @@ import net.minecraft.util.StatCollector; public class GUICropomator extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("crisscross", "textures/gui/cropomator.png"); - + private TileEntityCropomator cropomator; - + public GUICropomator(EntityPlayer player, TileEntityCropomator cropomator) { super(new ContainerCropomator(player, 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.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) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(texture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - if (this.cropomator.isUsingFuel()) - { - int i1 = this.cropomator.getBurnTimeRemainingScaled(13); - this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); - i1 = this.cropomator.getProgressScaled(24); - this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); - } - } + if (this.cropomator.isUsingFuel()) + { + int i1 = this.cropomator.getBurnTimeRemainingScaled(13); + this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); + i1 = this.cropomator.getProgressScaled(24); + this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); + } + } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIElectroextractor.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIElectroextractor.java index 40ae843..2751cd1 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIElectroextractor.java +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIElectroextractor.java @@ -12,36 +12,38 @@ import net.minecraft.util.StatCollector; 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; - + public GUIElectroextractor(EntityPlayer player, TileEntityElectroextractor electroextractor) { super(new ContainerElectroextractor(player, 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.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) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(texture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - if (this.electroextractor.isUsingFuel()) - { - int i1 = this.electroextractor.getBurnTimeRemainingScaled(13); - this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); - i1 = this.electroextractor.getProgressScaled(24); - this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); - } - } + if (this.electroextractor.isUsingFuel()) + { + int i1 = this.electroextractor.getBurnTimeRemainingScaled(13); + this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); + i1 = this.electroextractor.getProgressScaled(24); + this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); + } + } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIFactory.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIFactory.java index c5d8253..7cfa0d8 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIFactory.java +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIFactory.java @@ -8,27 +8,27 @@ import net.minecraft.client.gui.GuiScreen; public class GUIFactory implements IModGuiFactory { - @Override - public void initialize(Minecraft minecraftInstance) - { + @Override + public void initialize(Minecraft minecraftInstance) + { - } + } - @Override - public Class mainConfigGuiClass() - { - return ModGUIConfig.class; - } + @Override + public Class mainConfigGuiClass() + { + return ModGUIConfig.class; + } - @Override - public Set runtimeGuiCategories() - { - return null; - } + @Override + public Set runtimeGuiCategories() + { + return null; + } - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) - { - return null; - } + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) + { + return null; + } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIHandler.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIHandler.java index 5c71195..2847ad2 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIHandler.java +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIHandler.java @@ -22,23 +22,23 @@ public class GUIHandler implements IGuiHandler public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int 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); } - if(tile instanceof TileEntityElectroextractor) + if (tile instanceof TileEntityElectroextractor) { - TileEntityElectroextractor TE = (TileEntityElectroextractor)tile; - + TileEntityElectroextractor TE = (TileEntityElectroextractor) tile; + 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 null; @@ -48,24 +48,24 @@ public class GUIHandler implements IGuiHandler public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int 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); } - - if(tile instanceof TileEntityElectroextractor) + + if (tile instanceof TileEntityElectroextractor) { - TileEntityElectroextractor TE = (TileEntityElectroextractor)tile; - + TileEntityElectroextractor TE = (TileEntityElectroextractor) tile; + 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 null; diff --git a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIWoodchipper.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIWoodchipper.java index da6e53b..5bae2c7 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIWoodchipper.java +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIWoodchipper.java @@ -13,35 +13,36 @@ import net.minecraft.util.StatCollector; public class GUIWoodchipper extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("crisscross", "textures/gui/woodchipper.png"); - + private TileEntityWoodchipper woodchipper; - + public GUIWoodchipper(EntityPlayer player, TileEntityWoodchipper woodchipper) { super(new ContainerWoodchipper(player, 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.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) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(texture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - if (this.woodchipper.isUsingFuel()) - { - int i1 = this.woodchipper.getBurnTimeRemainingScaled(13); - this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); - i1 = this.woodchipper.getProgressScaled(24); - this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); - } - } + if (this.woodchipper.isUsingFuel()) + { + int i1 = this.woodchipper.getBurnTimeRemainingScaled(13); + this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); + i1 = this.woodchipper.getProgressScaled(24); + this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); + } + } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/GUI/ModGUIConfig.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/ModGUIConfig.java index cc2df5e..baebe6e 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/GUI/ModGUIConfig.java +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/ModGUIConfig.java @@ -10,13 +10,10 @@ import net.minecraftforge.common.config.Configuration; public class ModGUIConfig extends GuiConfig { - public ModGUIConfig(GuiScreen guiScreen) - { - super(guiScreen, - new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), - Reference.modid, - false, - true, - GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString())); - } + public ModGUIConfig(GuiScreen guiScreen) + { + super(guiScreen, + new ConfigElement(ConfigHandler.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), + Reference.modid, false, true, GuiConfig.getAbridgedConfigPath(ConfigHandler.config.toString())); + } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Items/CCItems.java b/src/main/java/com/oitsjustjose/criss_cross/Items/CCItems.java index 6b41912..b038c40 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Items/CCItems.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Items/CCItems.java @@ -5,6 +5,7 @@ import net.minecraft.item.Item; public class CCItems { public static Item dusts; + public static void init() { dusts = new ItemDust(); diff --git a/src/main/java/com/oitsjustjose/criss_cross/Items/ItemDust.java b/src/main/java/com/oitsjustjose/criss_cross/Items/ItemDust.java index b0b084b..d9d257a 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Items/ItemDust.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Items/ItemDust.java @@ -24,53 +24,53 @@ public class ItemDust extends Item private static ArrayList colors = new ArrayList(); public static IIcon overlay; public static IIcon base; - + public ItemDust() { this.setHasSubtypes(true); this.setCreativeTab(CrissCross.CCTab); GameRegistry.registerItem(this, this.getUnlocalizedName()); } - + public static ArrayList getDusts() { return dustNames; } - + public static void addDustType(String name, int color) { dustNames.add(name); colors.add(color); } - + public static String getName(int meta) { return dustNames.get(meta); } - + @Override public boolean requiresMultipleRenderPasses() { return true; } - + @Override public IIcon getIconFromDamageForRenderPass(int meta, int pass) { return pass == 0 ? base : overlay; } - + @Override 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."); return ("item." + Reference.modid + ".trash"); } return "item." + Reference.modid + "." + dustNames.get(itemStack.getItemDamage()); } - + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister register) @@ -78,26 +78,25 @@ public class ItemDust extends Item overlay = register.registerIcon(Reference.modid + ":dust_overlay"); base = register.registerIcon(Reference.modid + ":dust_base"); } - + @Override @SideOnly(Side.CLIENT) 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 colors.get(stack.getItemDamage()); - } - else + } else return 16777215; } - + @Override @SideOnly(Side.CLIENT) 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)); } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/NEI/CCNEIIntegration.java b/src/main/java/com/oitsjustjose/criss_cross/NEI/CCNEIIntegration.java new file mode 100644 index 0000000..7e0f1b2 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/NEI/CCNEIIntegration.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerBase.java b/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerBase.java new file mode 100644 index 0000000..2be8661 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerBase.java @@ -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 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 handleTooltip(GuiRecipe guiRecipe, List 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 handleTooltip(List 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); + } + + } + +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerCropomator.java b/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerCropomator.java new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerElectroextractor.java b/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerElectroextractor.java new file mode 100644 index 0000000..b0d58cb --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerElectroextractor.java @@ -0,0 +1,6 @@ +package com.oitsjustjose.criss_cross.NEI; + +public class RecipeHandlerElectroextractor +{ + +} diff --git a/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerWoodchipper.java b/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerWoodchipper.java new file mode 100644 index 0000000..8c641e5 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/NEI/RecipeHandlerWoodchipper.java @@ -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 inputs = TileEntityWoodchipper.getInputs(); + ArrayList 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)); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Recipes/CRecipes.java b/src/main/java/com/oitsjustjose/criss_cross/Recipes/CCRecipes.java similarity index 66% rename from src/main/java/com/oitsjustjose/criss_cross/Recipes/CRecipes.java rename to src/main/java/com/oitsjustjose/criss_cross/Recipes/CCRecipes.java index 64f7e2e..e84cb16 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Recipes/CRecipes.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Recipes/CCRecipes.java @@ -13,7 +13,7 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; -public class CRecipes +public class CCRecipes { public static void init() { @@ -21,89 +21,74 @@ public class CRecipes electroextractorRecipe(); woodChipperRecipe(); } - + static void woodChipperRecipe() { String[] unlocItem = ConfigHandler.woodchipperRecipeItem.split(":"); 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); - if(unlocItem.length == 2) + if (unlocItem.length == 2) centerItem = newStack; - if(unlocItem.length == 3) + if (unlocItem.length == 3) 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."); } - + 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() { String[] unlocItem = ConfigHandler.electroextractorRecipeItem.split(":"); 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); - if(unlocItem.length == 2) + if (unlocItem.length == 2) centerItem = newStack; - if(unlocItem.length == 3) + if (unlocItem.length == 3) 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."); } - + 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() { String[] unlocItem = ConfigHandler.cropomatorRecipeItem.split(":"); 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); - if(unlocItem.length == 2) + if (unlocItem.length == 2) centerItem = newStack; - if(unlocItem.length == 3) + if (unlocItem.length == 3) 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."); } - + 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 }); } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Recipes/CropomatorRecipes.java b/src/main/java/com/oitsjustjose/criss_cross/Recipes/CropomatorRecipes.java index 6fd3a41..58f6fc6 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Recipes/CropomatorRecipes.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Recipes/CropomatorRecipes.java @@ -12,80 +12,86 @@ public class CropomatorRecipes { public static void initRecipes() { - for(int i = 0; i < ConfigHandler.cropomatorInputs.length; i++) + for (int i = 0; i < ConfigHandler.cropomatorInputs.length; i++) { try { String[] unlocStack = ConfigHandler.cropomatorInputs[i].split(":"); - if(unlocStack.length == 2) + if (unlocStack.length == 2) { - if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) - TileEntityCropomator.addItemStackToOutputs(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1)); + if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) + TileEntityCropomator + .addItemStackToOutputs(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1)); 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."); } } - 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); - } - 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."); } } - } - catch(Exception e) + } catch (Exception e) { CCLog.warn("[CrissCross]: Error reading itemstack for inputs from input file at item: " + (i + 1)); } - + } } - + public static void initCatalysts() { - for(int i = 0; i < ConfigHandler.cropomatorCatalysts.length; i++) + for (int i = 0; i < ConfigHandler.cropomatorCatalysts.length; i++) { try { String[] unlocStack = ConfigHandler.cropomatorCatalysts[i].split(":"); - if(unlocStack.length == 2) + if (unlocStack.length == 2) { - if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) - TileEntityCropomator.addItemStackToCatalysts(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1)); + if (GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) + TileEntityCropomator + .addItemStackToCatalysts(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1)); 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."); } } - - 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); - } - 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."); } } - } - 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)); } } } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Recipes/ElectroextractorRecipes.java b/src/main/java/com/oitsjustjose/criss_cross/Recipes/ElectroextractorRecipes.java index 6a6e81a..798cda0 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Recipes/ElectroextractorRecipes.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Recipes/ElectroextractorRecipes.java @@ -24,73 +24,77 @@ public class ElectroextractorRecipes TileEntityElectroextractor.addRecipe(Blocks.emerald_ore, new ItemStack(Items.emerald)); TileEntityElectroextractor.addRecipe(Blocks.coal_ore, new ItemStack(Items.coal)); } - + public static void oreDictionaryInit() - { + { ArrayList 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(":"); - if(OreDictionary.doesOreNameExist("ore" + entry[0]) && OreDictionary.doesOreNameExist("ingot" + entry[0])) + if (OreDictionary.doesOreNameExist("ore" + entry[0]) && OreDictionary.doesOreNameExist("ingot" + entry[0])) { ArrayList ores = OreDictionary.getOres("ore" + entry[0]); ItemDust.addDustType(entry[0], Integer.parseInt(entry[1])); - for(int j = 0; j < ores.size(); j++) - TileEntityElectroextractor.addRecipe(ores.get(j), new ItemStack(CCItems.dusts, 1, dustNames.size() - 1)); - } - else + for (int j = 0; j < ores.size(); j++) + TileEntityElectroextractor.addRecipe(ores.get(j), + new ItemStack(CCItems.dusts, 1, dustNames.size() - 1)); + } else { - CCLog.warn("Your oreDictionary Entry " + ConfigHandler.electroextractorOreDictInputs[i] + " could not be registered."); - if(!OreDictionary.doesOreNameExist("ore" + 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("Your oreDictionary Entry " + ConfigHandler.electroextractorOreDictInputs[i] + + " could not be registered."); + if (!OreDictionary.doesOreNameExist("ore" + 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] + "."); } } - - for(int i = 0; i < dustNames.size(); i++) + + for (int i = 0; i < dustNames.size(); i++) { 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); - if(ingot != null) + if (ingot != null) GameRegistry.addSmelting(new ItemStack(CCItems.dusts, 1, i), ingot, 0.0F); } } - + public static void initFuels() { - for(int i = 0; i < ConfigHandler.electroextractorEnergySources.length; i++) + for (int i = 0; i < ConfigHandler.electroextractorEnergySources.length; i++) { try { 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)); 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."); } } - - 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); - } - 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."); } } - } - catch(Exception e) + } catch (Exception e) { CCLog.warn("Error reading itemstack for electroextractor's energy sources at item: " + (i + 1)); } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Recipes/WoodchipperRecipes.java b/src/main/java/com/oitsjustjose/criss_cross/Recipes/WoodchipperRecipes.java index 3a478f9..dd55077 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Recipes/WoodchipperRecipes.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Recipes/WoodchipperRecipes.java @@ -18,29 +18,29 @@ public class WoodchipperRecipes { ArrayList logs = OreDictionary.getOres("logWood"); ArrayList planks = OreDictionary.getOres("plankWood"); - + String logName; 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); logName = log.getDisplayName(); logName = logName.replace("Wood", ""); 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); plankName = plank.getDisplayName(); plankName = plankName.replace("Wood", ""); plankName = plankName.replace("Planks", ""); plankName = plankName.trim(); - if(plankName.contains(logName)) + if (plankName.contains(logName)) { TileEntityWoodchipper.addRecipe(log, plank); break; @@ -50,40 +50,42 @@ public class WoodchipperRecipes } } } - + public static void initFuels() { - for(int i = 0; i < ConfigHandler.woodchipperFuels.length; i++) + for (int i = 0; i < ConfigHandler.woodchipperFuels.length; i++) { try { 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)); 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."); } } - - 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); - } - 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."); } } - } - catch(Exception e) + } catch (Exception e) { CCLog.warn("Error reading itemstack for Woodchipper's energy sources at item: " + (i + 1)); } diff --git a/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCropomator.java b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCropomator.java index 890bc46..98410f8 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCropomator.java +++ b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCropomator.java @@ -18,389 +18,406 @@ import net.minecraft.tileentity.TileEntity; public class TileEntityCropomator extends TileEntity implements ISidedInventory { - private static int proTicks = ConfigHandler.cropomatorProcessTime; - private static int qty = ConfigHandler.cropomatorOutput; - private static final int[] slotsTop = new int[] {0}; - private static final int[] slotsBottom = new int[] {2, 1}; - private static final int[] slotsSides = new int[] {1}; - private static ArrayList recipeItems = new ArrayList(); - private static ArrayList catalystItems = new ArrayList(); + private static int proTicks = ConfigHandler.cropomatorProcessTime; + private static int qty = ConfigHandler.cropomatorOutput; + private static final int[] slotsTop = new int[] + { 0 }; + private static final int[] slotsBottom = new int[] + { 2, 1 }; + private static final int[] slotsSides = new int[] + { 1 }; + private static ArrayList recipeItems = new ArrayList(); + private static ArrayList catalystItems = new ArrayList(); - private ItemStack[] ItemStacks = new ItemStack[3]; - - public int catalystTime; - public int processTime; - public int catalystInUseTime; - - @Override - public int getSizeInventory() - { - return this.ItemStacks.length; - } - - @Override - public ItemStack getStackInSlot(int slot) - { - return this.ItemStacks[slot]; - } + private ItemStack[] ItemStacks = new ItemStack[3]; - @Override - public ItemStack decrStackSize(int slot, int qtyToDecr) - { - if (this.ItemStacks[slot] != null) - { - ItemStack itemstack; + public int catalystTime; + public int processTime; + public int catalystInUseTime; - 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; - } + 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 - public void markDirty(){} + public int getSizeInventory() + { + 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 + public void markDirty() + { + } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityElectroextractor.java b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityElectroextractor.java index 1228cdd..9891b41 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityElectroextractor.java +++ b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityElectroextractor.java @@ -19,418 +19,437 @@ import net.minecraft.tileentity.TileEntity; public class TileEntityElectroextractor extends TileEntity implements ISidedInventory { - private static int proTicks = ConfigHandler.electroextractorProcessTime; - private static int qty = ConfigHandler.electroextractorOutput; - private static final int[] slotsTop = new int[] {0}; - private static final int[] slotsBottom = new int[] {2, 1}; - private static final int[] slotsSides = new int[] {1}; - private static ArrayList inputItems = new ArrayList(); - private static ArrayList outputItems = new ArrayList(); - private static ArrayList fuelItems = new ArrayList(); + private static int proTicks = ConfigHandler.electroextractorProcessTime; + private static int qty = ConfigHandler.electroextractorOutput; + private static final int[] slotsTop = new int[] + { 0 }; + private static final int[] slotsBottom = new int[] + { 2, 1 }; + private static final int[] slotsSides = new int[] + { 1 }; + private static ArrayList inputItems = new ArrayList(); + private static ArrayList outputItems = new ArrayList(); + private static ArrayList fuelItems = new ArrayList(); - private ItemStack[] ItemStacks = new ItemStack[3]; - - public int fuelTime; - public int crushTime; - public int fuelInUseTime; - - - @Override - public int getSizeInventory() - { - return this.ItemStacks.length; - } - - @Override - public ItemStack getStackInSlot(int slot) - { - return this.ItemStacks[slot]; - } + private ItemStack[] ItemStacks = new ItemStack[3]; - @Override - public ItemStack decrStackSize(int slot, int qtyToDecr) - { - if (this.ItemStacks[slot] != null) - { - ItemStack itemstack; + public int fuelTime; + public int crushTime; + public int fuelInUseTime; - 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; - } + 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 - public void markDirty(){} + public int getSizeInventory() + { + 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 + public void markDirty() + { + } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityWoodchipper.java b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityWoodchipper.java index e9e4f7c..2852f4e 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityWoodchipper.java +++ b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityWoodchipper.java @@ -18,415 +18,484 @@ import net.minecraft.tileentity.TileEntity; public class TileEntityWoodchipper extends TileEntity implements ISidedInventory { - private static int proTicks = ConfigHandler.woodchipperProcessTime; - private static int qty = ConfigHandler.woodchipperOutput; - private static final int[] slotsTop = new int[] {0}; - private static final int[] slotsBottom = new int[] {2, 1}; - private static final int[] slotsSides = new int[] {1}; - private static ArrayList inputItems = new ArrayList(); - private static ArrayList outputItems = new ArrayList(); - private static ArrayList fuelItems = new ArrayList(); + private static int proTicks = ConfigHandler.woodchipperProcessTime; + private static int qty = ConfigHandler.woodchipperOutput; + private static final int[] slotsTop = new int[] + { 0 }; + private static final int[] slotsBottom = new int[] + { 2, 1 }; + private static final int[] slotsSides = new int[] + { 1 }; + private static ArrayList inputItems = new ArrayList(); + private static ArrayList outputItems = new ArrayList(); + private static ArrayList fuelItems = new ArrayList(); - private ItemStack[] ItemStacks = new ItemStack[3]; - - public int fuelTime; - public int processTime; - public int fuelUsetime; - - @Override - public int getSizeInventory() - { - return this.ItemStacks.length; - } - - @Override - public ItemStack getStackInSlot(int slot) - { - return this.ItemStacks[slot]; - } + private ItemStack[] ItemStacks = new ItemStack[3]; - @Override - public ItemStack decrStackSize(int slot, int qtyToDecr) - { - if (this.ItemStacks[slot] != null) - { - ItemStack itemstack; + public int fuelTime; + public int processTime; + public int fuelUsetime; - if (this.ItemStacks[slot].stackSize <= qtyToDecr) - { - itemstack = this.ItemStacks[slot]; - this.ItemStacks[slot] = null; - return itemstack; - } - else - { - itemstack = this.ItemStacks[slot].splitStack(qtyToDecr); + 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; + } - if (this.ItemStacks[slot].stackSize == 0) - { - this.ItemStacks[slot] = 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; + } - return itemstack; - } - } - else - { - return null; - } - } + public static ArrayList getInputs() + { + return inputItems; + } - @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; + public static ArrayList getOutputs() + { + return outputItems; + } - 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; - } + public static ArrayList getFuels() + { + return fuelItems; + } @Override - public void markDirty(){} -} \ No newline at end of file + public int getSizeInventory() + { + 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 + 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(); + } + } +} diff --git a/src/main/java/com/oitsjustjose/criss_cross/Util/CCLog.java b/src/main/java/com/oitsjustjose/criss_cross/Util/CCLog.java index ebb0419..8721ff6 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Util/CCLog.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/CCLog.java @@ -6,27 +6,27 @@ import org.apache.logging.log4j.Logger; public class CCLog { private static Logger LOGGER = LogManager.getLogger(Reference.modid); - + public CCLog() { - + } - + public static void warn(String msg) { LOGGER.warn(msg); } - + public static void error(String msg) { LOGGER.error(msg); } - + public static void info(String msg) { LOGGER.info(msg); } - + public static void debug(String msg) { LOGGER.debug(msg); diff --git a/src/main/java/com/oitsjustjose/criss_cross/Util/ClientProxy.java b/src/main/java/com/oitsjustjose/criss_cross/Util/ClientProxy.java index c084a02..90b18c0 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Util/ClientProxy.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/ClientProxy.java @@ -5,12 +5,12 @@ public class ClientProxy extends CommonProxy @Override public void preInit() { - + } @Override public void init() { - + } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Util/CommonProxy.java b/src/main/java/com/oitsjustjose/criss_cross/Util/CommonProxy.java index 10a20d0..831ad34 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Util/CommonProxy.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/CommonProxy.java @@ -2,6 +2,11 @@ package com.oitsjustjose.criss_cross.Util; public class CommonProxy { - public void preInit(){}; - public void init(){}; + public void preInit() + { + }; + + public void init() + { + }; } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Util/ConfigHandler.java b/src/main/java/com/oitsjustjose/criss_cross/Util/ConfigHandler.java index 5150d6f..c5e786e 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Util/ConfigHandler.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/ConfigHandler.java @@ -9,119 +9,125 @@ import net.minecraftforge.common.config.Configuration; public class ConfigHandler { - public static Configuration config; - public static int cropomatorProcessTime; - public static int cropomatorOutput; - public static String cropomatorRecipeItem; - public static String[] cropomatorInputs; - public static String[] cropomatorCatalysts; - public static String[] defaultCropomatorInputs = new String[] - { - "minecraft:apple", "minecraft:reeds", "minecraft:nether_wart", - "minecraft:carrot", "minecraft:cactus", "minecraft:potato", - "minecraft:sapling:0", "minecraft:sapling:1", "minecraft:sapling:2", - "minecraft:sapling:3", "minecraft:sapling:4", "minecraft:sapling:5", - "minecraft:melon", "minecraft:brown_mushroom", "minecraft:red_mushroom", - "minecraft:cocoa", "minecraft:pumpkin", "minecraft:wheat", - "minecraft:wheat_seeds" - }; - public static String[] defaultCropomatorCatalystItems = new String[] - { - "minecraft:dye:15" - }; - - public static int electroextractorProcessTime; - public static int electroextractorOutput; - public static String electroextractorRecipeItem; - public static String[] electroextractorEnergySources; - public static String[] electroextractorOreDictInputs; - public static String[] defaultElectroextractorOreDictInputs = new String[] - { - "Iron:12428902", "Gold:15400704", "Aluminum:15987699", - "Cobalt:17663", "Ardite:13938485", "Copper:16751872", - "Tin:15132390", "Silver:13297640", "Lead:5722979", - "Platinum:11067903", "Mithril:4433113", "Nickel:16580553" - }; - public static String[] defaultElectroextractorEnergySources = new String[] - { - "minecraft:redstone_block" - }; - - public static int woodchipperProcessTime; - public static int woodchipperOutput; - public static String woodchipperRecipeItem; - public static String[] woodchipperFuels; - public static String[] defaultWoodchipperFuels = new String[] - { - "minecraft:water_bucket", "minecraft:potion:0" - }; - - public static void init(File configFile) - { - // Create the configuration object from the given configuration file - if (config == null) - { - config = new Configuration(configFile); - loadConfiguration(); - } - } + public static Configuration config; + public static int cropomatorProcessTime; + public static int cropomatorOutput; + public static String cropomatorRecipeItem; + public static String[] cropomatorInputs; + public static String[] cropomatorCatalysts; + public static String[] defaultCropomatorInputs = new String[] + { "minecraft:apple", "minecraft:reeds", "minecraft:nether_wart", "minecraft:carrot", "minecraft:cactus", + "minecraft:potato", "minecraft:sapling:0", "minecraft:sapling:1", "minecraft:sapling:2", + "minecraft:sapling:3", "minecraft:sapling:4", "minecraft:sapling:5", "minecraft:melon", + "minecraft:brown_mushroom", "minecraft:red_mushroom", "minecraft:cocoa", "minecraft:pumpkin", + "minecraft:wheat", "minecraft:wheat_seeds" }; + public static String[] defaultCropomatorCatalystItems = new String[] + { "minecraft:dye:15" }; - private static void loadConfiguration() - { - //Cropomator Configs - cropomatorInputs = config.get(config.CATEGORY_GENERAL, "Cropomator's Recipe Items.", defaultCropomatorInputs, - "A list of items to be added to the Cropomator's recipe list. Formatted as: :: or :.").getStringList(); - - cropomatorCatalysts = config.get(config.CATEGORY_GENERAL, "Cropomator's Catalyst Items.", defaultCropomatorCatalystItems, - "A list of items to be added to the Cropomator's catalyst list. Formatted as: :: or :.").getStringList(); - - cropomatorProcessTime = config.getInt("Cropomator Processing Time", config.CATEGORY_GENERAL, 150, 1, 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, - "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", - "This is the item located in the center of the crafting recipe for the Cropomator. Formatted as: :: or :."); - - //Electroextractor's Configs - electroextractorEnergySources = config.get(config.CATEGORY_GENERAL, "Electroextractor's Fuel Items.", defaultElectroextractorEnergySources, - "A list of items to be added as the Electroextractor's energy sources. Formatted as: :: or :.").getStringList(); - - electroextractorProcessTime = config.getInt("Electroextractor Processing Time", config.CATEGORY_GENERAL, 250, 0, 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, - "Control how many dusts you get as the output. Default is 2."); - - electroextractorRecipeItem = config.getString("Electroextractor Crafting Item.", config.CATEGORY_GENERAL, "minecraft:diamond_block", - "This is the item located in the center of the crafting recipe for the Electroextractor. Formatted as: :: or :."); - - electroextractorOreDictInputs = config.get(config.CATEGORY_GENERAL, "Electroextractor OreDictionary Entries.", defaultElectroextractorOreDictInputs, - "Formatted as :." + "\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 - woodchipperFuels = config.get(config.CATEGORY_GENERAL, "Woodchipper Fuel Items", defaultWoodchipperFuels, - "A list of items to be added as the Woodchipper's 'fuels'. Formatted as: :: or :.").getStringList(); - - woodchipperProcessTime = config.getInt("Woodchipper Process Time", config.CATEGORY_GENERAL, 400, 0, 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, - "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", - "This is the item located in the center of the crafting recipe for the Woodchipper. Formatted as: :: or :."); - - if (config.hasChanged()) - config.save(); - } + public static int electroextractorProcessTime; + public static int electroextractorOutput; + public static String electroextractorRecipeItem; + public static String[] electroextractorEnergySources; + public static String[] electroextractorOreDictInputs; + public static String[] defaultElectroextractorOreDictInputs = new String[] + { "Iron:12428902", "Gold:15400704", "Aluminum:15987699", "Cobalt:17663", "Ardite:13938485", "Copper:16751872", + "Tin:15132390", "Silver:13297640", "Lead:5722979", "Platinum:11067903", "Mithril:4433113", + "Nickel:16580553" }; + public static String[] defaultElectroextractorEnergySources = new String[] + { "minecraft:redstone_block" }; - @SubscribeEvent - public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) - { - if (event.modID.equalsIgnoreCase(Reference.modid)) - loadConfiguration(); - } + public static int woodchipperProcessTime; + public static int woodchipperOutput; + public static String woodchipperRecipeItem; + public static String[] woodchipperFuels; + public static String[] defaultWoodchipperFuels = new String[] + { "minecraft:water_bucket", "minecraft:potion:0" }; + + public static void init(File configFile) + { + // Create the configuration object from the given configuration file + if (config == null) + { + config = new Configuration(configFile); + loadConfiguration(); + } + } + + private static void loadConfiguration() + { + // Cropomator Configs + cropomatorInputs = config + .get(config.CATEGORY_GENERAL, "Cropomator's Recipe Items.", defaultCropomatorInputs, + "A list of items to be added to the Cropomator's recipe list. Formatted as: :: or :.") + .getStringList(); + + cropomatorCatalysts = config + .get(config.CATEGORY_GENERAL, "Cropomator's Catalyst Items.", defaultCropomatorCatalystItems, + "A list of items to be added to the Cropomator's catalyst list. Formatted as: :: or :.") + .getStringList(); + + cropomatorProcessTime = config.getInt("Cropomator Processing Time", config.CATEGORY_GENERAL, 150, 1, + 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, + "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", + "This is the item located in the center of the crafting recipe for the Cropomator. Formatted as: :: or :."); + + // Electroextractor's Configs + electroextractorEnergySources = config + .get(config.CATEGORY_GENERAL, "Electroextractor's Fuel Items.", defaultElectroextractorEnergySources, + "A list of items to be added as the Electroextractor's energy sources. Formatted as: :: or :.") + .getStringList(); + + electroextractorProcessTime = config.getInt("Electroextractor Processing Time", config.CATEGORY_GENERAL, 250, 0, + 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, + "Control how many dusts you get as the output. Default is 2."); + + electroextractorRecipeItem = config.getString("Electroextractor Crafting Item.", config.CATEGORY_GENERAL, + "minecraft:diamond_block", + "This is the item located in the center of the crafting recipe for the Electroextractor. Formatted as: :: or :."); + + electroextractorOreDictInputs = config + .get(config.CATEGORY_GENERAL, "Electroextractor OreDictionary Entries.", + defaultElectroextractorOreDictInputs, + "Formatted as :." + "\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 + woodchipperFuels = config + .get(config.CATEGORY_GENERAL, "Woodchipper Fuel Items", defaultWoodchipperFuels, + "A list of items to be added as the Woodchipper's 'fuels'. Formatted as: :: or :.") + .getStringList(); + + woodchipperProcessTime = config.getInt("Woodchipper Process Time", config.CATEGORY_GENERAL, 400, 0, + 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, + "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", + "This is the item located in the center of the crafting recipe for the Woodchipper. Formatted as: :: or :."); + + if (config.hasChanged()) + config.save(); + } + + @SubscribeEvent + public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) + { + if (event.modID.equalsIgnoreCase(Reference.modid)) + loadConfiguration(); + } } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Util/OreDictionaryAdder.java b/src/main/java/com/oitsjustjose/criss_cross/Util/OreDictionaryAdder.java index dc358a9..b4a1f59 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Util/OreDictionaryAdder.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/OreDictionaryAdder.java @@ -13,8 +13,8 @@ public class OreDictionaryAdder public static void init() { ArrayList 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)); } } \ No newline at end of file