diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCropomator.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCropomator.java new file mode 100644 index 0000000..64f6922 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCropomator.java @@ -0,0 +1,116 @@ +package com.oitsjustjose.criss_cross.Blocks; + +import java.util.Random; + +import com.oitsjustjose.criss_cross.CrissCross; +import com.oitsjustjose.criss_cross.GUI.GUIHandler; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator; +import com.oitsjustjose.criss_cross.Util.Reference; + +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class BlockCropomator extends BlockMachineBase +{ + private static String unlocName = "Cropomator"; + public BlockCropomator() + { + super(unlocName); + + GameRegistry.registerBlock(this, unlocName); + GameRegistry.registerTileEntity(TileEntityCropomator.class, unlocName); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) + { + blockTextures[0] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Bottom"); + blockTextures[1] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Top"); + 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) + { + Random random = new Random(); + 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 (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 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) + { + if(world.isRemote) + { + return true; + } + else + { + TileEntityCropomator tilecropomator = (TileEntityCropomator)world.getTileEntity(x, y, z); + if(tilecropomator != null) + player.openGui(CrissCross.instance, GUIHandler.Cropomator, world, x, y, z); + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockElectroextractor.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockElectroextractor.java new file mode 100644 index 0000000..94fff70 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockElectroextractor.java @@ -0,0 +1,116 @@ +package com.oitsjustjose.criss_cross.Blocks; + +import java.util.Random; + +import com.oitsjustjose.criss_cross.CrissCross; +import com.oitsjustjose.criss_cross.GUI.GUIHandler; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor; +import com.oitsjustjose.criss_cross.Util.Reference; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +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.registerBlock(this, unlocName); + GameRegistry.registerTileEntity(TileEntityElectroextractor.class, unlocName); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) + { + blockTextures[0] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Bottom"); + blockTextures[1] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Top"); + 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) + { + if(world.isRemote) + { + return true; + } + else + { + TileEntityElectroextractor tileext = (TileEntityElectroextractor)world.getTileEntity(x, y, z); + if(tileext != null) + player.openGui(CrissCross.instance, GUIHandler.Electroextractor, world, x, y, z); + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockMachineBase.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockMachineBase.java new file mode 100644 index 0000000..fe50ea3 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockMachineBase.java @@ -0,0 +1,144 @@ +package com.oitsjustjose.criss_cross.Blocks; + +import com.oitsjustjose.criss_cross.Util.Reference; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +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 + this.setBlockName(Reference.modid + "." + unlocName); + this.setCreativeTab(CreativeTabs.tabBlock); + + this.unlocalizedName = unlocName; + } + + //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]; + + 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 + 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; + + if (l == 0) + { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + } + + if (l == 1) + { + world.setBlockMetadataWithNotify(x, y, z, 5, 2); + } + + if (l == 2) + { + world.setBlockMetadataWithNotify(x, y, z, 3, 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 (block.func_149730_j() && !block1.func_149730_j()) + { + b0 = 3; + } + + if (block1.func_149730_j() && !block.func_149730_j()) + { + b0 = 2; + } + + if (block2.func_149730_j() && !block3.func_149730_j()) + { + b0 = 5; + } + + 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; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) + { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockManager.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockManager.java new file mode 100644 index 0000000..46ffafe --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockManager.java @@ -0,0 +1,28 @@ +package com.oitsjustjose.criss_cross.Blocks; + +import com.oitsjustjose.criss_cross.CrissCross; +import com.oitsjustjose.criss_cross.GUI.GUIHandler; +import com.oitsjustjose.criss_cross.Util.CropomatorRecipes; +import com.oitsjustjose.criss_cross.Util.ElectroextractorRecipes; + +import cpw.mods.fml.common.network.NetworkRegistry; +import net.minecraft.block.Block; + +public class BlockManager +{ + public static Block cropomator; + public static Block electroextractor; + + public static void init() + { + cropomator = new BlockCropomator(); + CropomatorRecipes.initRecipes(); + CropomatorRecipes.initCatalysts(); + + electroextractor = new BlockElectroextractor(); + ElectroextractorRecipes.initRecipes(); + ElectroextractorRecipes.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 new file mode 100644 index 0000000..b3ed075 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerCropomator.java @@ -0,0 +1,183 @@ +package com.oitsjustjose.criss_cross.Container; + +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.tileentity.TileEntityFurnace; + +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 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; + } + + 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); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for(int i = 0; i < this.crafters.size(); ++i) + { + 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) + crafting.sendProgressBarUpdate(this, 1, this.cropomator.catalystTime); + 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); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + 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; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(player, itemstack1); + } + + 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 new file mode 100644 index 0000000..2d5f45c --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerElectroextractor.java @@ -0,0 +1,181 @@ +package com.oitsjustjose.criss_cross.Container; + +import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerElectroextractor extends Container +{ + TileEntityElectroextractor electroextractor; + EntityPlayer player; + + private int lastUseTime; + private int lastCrushTime; + private int lastCatalystInUseTime; + + public ContainerElectroextractor(EntityPlayer player, TileEntityElectroextractor electroextractor) + { + this.player = player; + this.electroextractor = electroextractor; + + lastUseTime = 0; + lastCrushTime = 0; + lastCatalystInUseTime = 0; + + 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; + } + + 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); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for(int i = 0; i < this.crafters.size(); ++i) + { + 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) + crafting.sendProgressBarUpdate(this, 1, this.electroextractor.fuelTime); + if(this.lastCatalystInUseTime != this.electroextractor.fuelInUseTime) + crafting.sendProgressBarUpdate(this, 2, this.electroextractor.fuelInUseTime); + } + this.lastUseTime = this.electroextractor.crushTime; + this.lastCrushTime = this.electroextractor.fuelTime; + this.lastCatalystInUseTime = this.electroextractor.fuelInUseTime; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(slotID); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + 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; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(player, itemstack1); + } + + 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/MachineOutputSlot.java b/src/main/java/com/oitsjustjose/criss_cross/Container/MachineOutputSlot.java new file mode 100644 index 0000000..1f5b4dc --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Container/MachineOutputSlot.java @@ -0,0 +1,63 @@ +package com.oitsjustjose.criss_cross.Container; + +import cpw.mods.fml.common.FMLCommonHandler; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.stats.AchievementList; +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; + + 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); + } + + return super.decrStackSize(slot); + } + + @Override + public void onPickupFromSlot(EntityPlayer player, ItemStack itemstack) + { + this.onCrafting(itemstack); + super.onPickupFromSlot(player, itemstack); + } + + @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 new file mode 100644 index 0000000..62ed478 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/CrissCross.java @@ -0,0 +1,43 @@ +package com.oitsjustjose.criss_cross; + +import com.oitsjustjose.criss_cross.Blocks.BlockManager; +import com.oitsjustjose.criss_cross.Items.ItemManager; +import com.oitsjustjose.criss_cross.Util.CommonProxy; +import com.oitsjustjose.criss_cross.Util.ConfigHandler; +import com.oitsjustjose.criss_cross.Util.RecipeHandler; +import com.oitsjustjose.criss_cross.Util.Reference; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +@Mod(modid = Reference.modid, version = Reference.version, guiFactory = Reference.guifactory) +public class CrissCross +{ + @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()); + ItemManager.init(); + BlockManager.init(); + proxy.preInit(); + } + + @EventHandler + public static void init(FMLInitializationEvent event) + { + RecipeHandler.init(); + proxy.init(); + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUICropomator.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUICropomator.java new file mode 100644 index 0000000..8c48eaa --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUICropomator.java @@ -0,0 +1,49 @@ +package com.oitsjustjose.criss_cross.GUI; + +import org.lwjgl.opengl.GL11; + +import com.oitsjustjose.criss_cross.Container.ContainerCropomator; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator; +import com.oitsjustjose.criss_cross.Util.Reference; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +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) + { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.cropomator"), 55, 7, 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); + + 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 new file mode 100644 index 0000000..40ae843 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIElectroextractor.java @@ -0,0 +1,47 @@ +package com.oitsjustjose.criss_cross.GUI; + +import org.lwjgl.opengl.GL11; + +import com.oitsjustjose.criss_cross.Container.ContainerElectroextractor; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class GUIElectroextractor extends GuiContainer +{ + 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) + { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.electroextractor"), 50, 7, 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); + + 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 new file mode 100644 index 0000000..c5d8253 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIFactory.java @@ -0,0 +1,34 @@ +package com.oitsjustjose.criss_cross.GUI; + +import java.util.Set; + +import cpw.mods.fml.client.IModGuiFactory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; + +public class GUIFactory implements IModGuiFactory +{ + @Override + public void initialize(Minecraft minecraftInstance) + { + + } + + @Override + public Class mainConfigGuiClass() + { + return ModGUIConfig.class; + } + + @Override + public Set runtimeGuiCategories() + { + 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 new file mode 100644 index 0000000..71841e2 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIHandler.java @@ -0,0 +1,58 @@ +package com.oitsjustjose.criss_cross.GUI; + +import com.oitsjustjose.criss_cross.Container.ContainerCropomator; +import com.oitsjustjose.criss_cross.Container.ContainerElectroextractor; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor; + +import cpw.mods.fml.common.network.IGuiHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class GUIHandler implements IGuiHandler +{ + public static final int Cropomator = 1; + public static final int Electroextractor = 2; + + @Override + 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) + { + TileEntityCropomator tileCropomator = (TileEntityCropomator)tile; + + return new ContainerCropomator(player, tileCropomator); + } + if(tile instanceof TileEntityElectroextractor) + { + TileEntityElectroextractor tileExt = (TileEntityElectroextractor)tile; + + return new ContainerElectroextractor(player, tileExt); + } + return null; + } + + @Override + 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) + { + TileEntityCropomator tileCropomator = (TileEntityCropomator)tile; + + return new GUICropomator(player, tileCropomator); + } + + if(tile instanceof TileEntityElectroextractor) + { + TileEntityElectroextractor tileExt = (TileEntityElectroextractor)tile; + + return new GUIElectroextractor(player, tileExt); + } + return null; + } +} \ 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 new file mode 100644 index 0000000..cc2df5e --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/ModGUIConfig.java @@ -0,0 +1,22 @@ +package com.oitsjustjose.criss_cross.GUI; + +import com.oitsjustjose.criss_cross.Util.ConfigHandler; +import com.oitsjustjose.criss_cross.Util.Reference; + +import cpw.mods.fml.client.config.GuiConfig; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.config.ConfigElement; +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())); + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Items/ItemDust.java b/src/main/java/com/oitsjustjose/criss_cross/Items/ItemDust.java new file mode 100644 index 0000000..f74b07e --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Items/ItemDust.java @@ -0,0 +1,80 @@ +package com.oitsjustjose.criss_cross.Items; + +import java.util.ArrayList; +import java.util.List; + +import com.oitsjustjose.criss_cross.Util.Reference; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class ItemDust extends Item +{ + private static ArrayList dustNames = new ArrayList(); + private static ArrayList colors = new ArrayList(); + public static IIcon overlay; + public static IIcon base; + + public ItemDust() + { + this.setHasSubtypes(true); + this.setCreativeTab(CreativeTabs.tabMaterials); + GameRegistry.registerItem(this, this.getUnlocalizedName()); + } + + public static void addDustType(String name, int color) + { + dustNames.add(name); + colors.add(color); + } + + @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) + { + return "item." + Reference.modid + "." + dustNames.get(itemStack.getItemDamage()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) + { + 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) + return colors.get(stack.getItemDamage()); + else + return 16777215; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tab, List list) + { + 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/Items/ItemManager.java b/src/main/java/com/oitsjustjose/criss_cross/Items/ItemManager.java new file mode 100644 index 0000000..c083996 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Items/ItemManager.java @@ -0,0 +1,14 @@ +package com.oitsjustjose.criss_cross.Items; + +import net.minecraft.item.Item; + +public class ItemManager +{ + public static Item dusts; + public static void init() + { + dusts = new ItemDust(); + ItemDust.addDustType("Iron", 10053171); + ItemDust.addDustType("Gold", 13467442); + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCropomator.java b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCropomator.java new file mode 100644 index 0000000..1057b66 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCropomator.java @@ -0,0 +1,407 @@ +package com.oitsjustjose.criss_cross.TileEntity; + +import java.util.ArrayList; + +import com.oitsjustjose.criss_cross.Blocks.BlockCropomator; +import com.oitsjustjose.criss_cross.Util.ConfigHandler; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +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 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]; + } + + @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 new file mode 100644 index 0000000..8afef8d --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityElectroextractor.java @@ -0,0 +1,430 @@ +package com.oitsjustjose.criss_cross.TileEntity; + +import java.util.ArrayList; + +import com.oitsjustjose.criss_cross.Blocks.BlockCropomator; +import com.oitsjustjose.criss_cross.Util.ConfigHandler; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +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 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]; + } + + @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; + BlockCropomator.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 + { + int posInArList = 0; + for(int i = 0; i < inputItems.size(); i++) + { + if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage()) + { + posInArList = i; + } + } + + ItemStack itemstack = new ItemStack(outputItems.get(posInArList).getItem(), qty, outputItems.get(posInArList).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 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 addItemRecipe(Item item, ItemStack output) + { + inputItems.add(new ItemStack(item)); + outputItems.add(output); + } + + public static void addBlockRecipe(Block block, ItemStack output) + { + inputItems.add(new ItemStack(block)); + outputItems.add(output); + } + + public static void addItemStackToFuels(ItemStack itemstack) + { + fuelItems.add(itemstack); + } + + public static boolean removeItemStackFromFuels(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()) + { + int posInArList = 0; + for(int i = 0; i < inputItems.size(); i++) + { + if(inputItems.get(i).getItem() == ItemStacks[0].getItem() && inputItems.get(i).getItemDamage() == ItemStacks[0].getItemDamage()) + { + posInArList = i; + } + } + + ItemStack output = new ItemStack(outputItems.get(posInArList).getItem(), qty, outputItems.get(posInArList).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 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/Util/ClientProxy.java b/src/main/java/com/oitsjustjose/criss_cross/Util/ClientProxy.java new file mode 100644 index 0000000..c084a02 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/ClientProxy.java @@ -0,0 +1,16 @@ +package com.oitsjustjose.criss_cross.Util; + +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 new file mode 100644 index 0000000..10a20d0 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/CommonProxy.java @@ -0,0 +1,7 @@ +package com.oitsjustjose.criss_cross.Util; + +public class CommonProxy +{ + 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 new file mode 100644 index 0000000..7541ffa --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/ConfigHandler.java @@ -0,0 +1,98 @@ +package com.oitsjustjose.criss_cross.Util; + +import java.io.File; +import java.util.regex.Pattern; + +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +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[] electroextractorInputs; + public static String[] electroextractorEnergySources; + + public static String[] defaultElectroextractorEnergySources = new String[] + { + "minecraft:redstone_block" + }; + + + + 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, "Items to be added to the Cropomator's recipes.", defaultCropomatorInputs, + "A list of items to be added to the Cropomator's recipe list. Formatted as: :: or :.").getStringList(); + + cropomatorCatalysts = config.get(config.CATEGORY_GENERAL, "Items to be added to the Cropomator's Catalyst list.", 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("Key crafting item of the Cropomator.", 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, "Items to be added to the Electroextractor's energy sources.", 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 of the input item you get as the output item. Default is 2."); + + electroextractorRecipeItem = config.getString("Key crafting item of the Electroextractor.", config.CATEGORY_GENERAL, "minecraft:diamond_block", + "This is the item located in the center of the crafting recipe for the Electroextractor. 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/CropomatorRecipes.java b/src/main/java/com/oitsjustjose/criss_cross/Util/CropomatorRecipes.java new file mode 100644 index 0000000..d88ece6 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/CropomatorRecipes.java @@ -0,0 +1,100 @@ +package com.oitsjustjose.criss_cross.Util; + +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.item.ItemStack; + +public class CropomatorRecipes +{ + public static void initRecipes() + { + //Iterates through the inputItems String array + for(int i = 0; i < ConfigHandler.cropomatorInputs.length; i++) + { + //Done in a try loop just in case there's an issue with reading a value in. + try + { + //Splits the modid:item / modid:item:metadata string at the ':' and makes a + //new Array of strings, each element containing the newly separated parts. + String[] unlocStack = ConfigHandler.cropomatorInputs[i].split(":"); + //Checks the read in string as modid:item + if(unlocStack.length == 2) + { + //Attempts to find the Itemstack with given info modid and unlocalizedname + if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) + TileEntityCropomator.addItemStackToOutputs(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1)); + //If it fails, it prints out an error message letting the user know exactly where they made a mistake + else + System.out.println("[CrissCross] Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's recipe list. Please confirm you have the name and formatting correct."); + } + //Checks the read in string as modid:item:metadata + if(unlocStack.length == 3) + { + //Attempts to find the Itemstack with given info modid and unlocalizedname + if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) + { + //It then creates a new itemstack with the itemstack's getItem, qty 1, with a parsed int value of the 3rd argument + ItemStack newStack = new ItemStack(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1, Integer.parseInt(unlocStack[2])); + TileEntityCropomator.addItemStackToOutputs(newStack); + } + //If it fails, it prints out an error message letting the user know exactly where they made a mistake + else + System.out.println("[CrissCross] Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's recipe list. Please confirm you have the name and formatting correct."); + } + + } + //Gotta catch em all + catch(Exception e) + { + System.out.println("[CrissCross]: Error reading itemstack for inputs from input file at item: " + (i + 1)); + } + + } + } + + //Iterates through the catalystItems String array + public static void initCatalysts() + { + //Done in a try loop just in case there's an issue with reading a value in. + for(int i = 0; i < ConfigHandler.cropomatorCatalysts.length; i++) + { + try + { + //Splits the modid:item / modid:item:metadata string at the ':' and makes a + //new Array of strings, each element containing the newly separated parts. + String[] unlocStack = ConfigHandler.cropomatorCatalysts[i].split(":"); + //Checks the read in string as modid:item + if(unlocStack.length == 2) + { + //Attempts to find the Itemstack with given info modid and unlocalizedname + if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) + TileEntityCropomator.addItemStackToCatalysts(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1)); + //If it fails, it prints out an error message letting the user know exactly where they made a mistake + else + System.out.println("[CrissCross] Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's catalyst list. Please confirm you have the name and formatting correct."); + } + + //Checks the read in string as modid:item:metadata + if(unlocStack.length == 3) + { + //Attempts to find the Itemstack with given info modid and unlocalizedname + if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) + { + //It then creates a new itemstack with the itemstack's getItem, qty 1, with a parsed int value of the 3rd argument + ItemStack newStack = new ItemStack(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1).getItem(), 1, Integer.parseInt(unlocStack[2])); + TileEntityCropomator.addItemStackToCatalysts(newStack); + } + //If it fails, it prints out an error message letting the user know exactly where they made a mistake + else + System.out.println("[CrissCross] Item " + ConfigHandler.cropomatorInputs[i] + " could not be added to the Cropomator's catalyst list. Please confirm you have the name and formatting correct."); + } + } + //Gotta catch em all + catch(Exception e) + { + System.out.println("[CrissCross]: Error reading itemstack for catalysts from input file at item: " + (i + 1)); + } + } + } +} diff --git a/src/main/java/com/oitsjustjose/criss_cross/Util/ElectroextractorRecipes.java b/src/main/java/com/oitsjustjose/criss_cross/Util/ElectroextractorRecipes.java new file mode 100644 index 0000000..4df4c43 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/ElectroextractorRecipes.java @@ -0,0 +1,56 @@ +package com.oitsjustjose.criss_cross.Util; + +import com.oitsjustjose.criss_cross.Items.ItemManager; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class ElectroextractorRecipes +{ + public static void initRecipes() + { + TileEntityElectroextractor.addBlockRecipe(Blocks.diamond_ore, new ItemStack(Items.diamond)); + TileEntityElectroextractor.addBlockRecipe(Blocks.emerald_ore, new ItemStack(Items.emerald)); + TileEntityElectroextractor.addBlockRecipe(Blocks.iron_ore, new ItemStack(ItemManager.dusts, 1, 0)); + TileEntityElectroextractor.addBlockRecipe(Blocks.gold_ore, new ItemStack(ItemManager.dusts, 1, 1)); + TileEntityElectroextractor.addBlockRecipe(Blocks.coal_ore, new ItemStack(Items.coal)); + + } + + public static void initFuels() + { + for(int i = 0; i < ConfigHandler.electroextractorEnergySources.length; i++) + { + try + { + String[] unlocStack = ConfigHandler.electroextractorEnergySources[i].split(":"); + if(unlocStack.length == 2) + { + if(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 1) != null) + TileEntityElectroextractor.addItemStackToFuels(GameRegistry.findItemStack(unlocStack[0], unlocStack[1], 0)); + else + System.out.println("[CrissCross] Item " + ConfigHandler.electroextractorEnergySources[i] + " could not be added to the Electroextractor's fuel list. Please confirm you have the name and formatting correct."); + } + + if(unlocStack.length == 3) + { + 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])); + TileEntityElectroextractor.addItemStackToFuels(newStack); + } + else + System.out.println("[CrissCross] Item " + ConfigHandler.electroextractorEnergySources[i] + " could not be added to the Electroextractor's fuel list. Please confirm you have the name and formatting correct."); + } + } + catch(Exception e) + { + System.out.println("[CrissCross]: Error reading itemstack for electroextractor's energy sources at item: " + (i + 1)); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Util/RecipeHandler.java b/src/main/java/com/oitsjustjose/criss_cross/Util/RecipeHandler.java new file mode 100644 index 0000000..1eb90da --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/RecipeHandler.java @@ -0,0 +1,76 @@ +package com.oitsjustjose.criss_cross.Util; + +import com.oitsjustjose.criss_cross.Blocks.BlockManager; +import com.oitsjustjose.criss_cross.Items.ItemManager; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; + +public class RecipeHandler +{ + public static void init() + { + cropomatorRecipe(); + electroextractorRecipe(); + GameRegistry.addSmelting(new ItemStack(ItemManager.dusts, 1, 0), new ItemStack(Items.iron_ingot), 1.0F); + GameRegistry.addSmelting(new ItemStack(ItemManager.dusts, 1, 1), new ItemStack(Items.gold_ingot), 1.0F); + + } + + static void electroextractorRecipe() + { + String[] unlocItem = ConfigHandler.electroextractorRecipeItem.split(":"); + ItemStack centerItem = new ItemStack(Blocks.diamond_block); + + if(GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1) != null) + { + ItemStack newStack = GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1); + if(unlocItem.length == 2) + centerItem = newStack; + if(unlocItem.length == 3) + centerItem = new ItemStack(newStack.getItem(), 1, Integer.parseInt(unlocItem[2])); + } + else + { + System.out.println("[CrissCross] Item " + ConfigHandler.electroextractorRecipeItem + " could not be added as part of the recipe of the cropomator. Please confirm you have the name and formatting correct."); + } + + GameRegistry.addRecipe(new ItemStack(BlockManager.electroextractor), new Object[] + { + "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) + { + ItemStack newStack = GameRegistry.findItemStack(unlocItem[0], unlocItem[1], 1); + if(unlocItem.length == 2) + centerItem = newStack; + if(unlocItem.length == 3) + centerItem = new ItemStack(newStack.getItem(), 1, Integer.parseInt(unlocItem[2])); + } + else + { + System.out.println("[CrissCross] Item " + ConfigHandler.cropomatorRecipeItem + " could not be added as part of the recipe of the cropomator. Please confirm you have the name and formatting correct."); + } + + GameRegistry.addRecipe(new ItemStack(BlockManager.cropomator), new Object[] + { + "I#I", + "SCS", + "I#I", + '#', Blocks.hay_block, 'I', Items.iron_ingot, 'S', Items.iron_hoe, 'C', centerItem + }); + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Util/Reference.java b/src/main/java/com/oitsjustjose/criss_cross/Util/Reference.java new file mode 100644 index 0000000..f8247d6 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/Reference.java @@ -0,0 +1,8 @@ +package com.oitsjustjose.criss_cross.Util; + +public class Reference +{ + public static final String modid = "CrissCross"; + public static final String version = "1.0_a"; + public static final String guifactory = "com.oitsjustjose.criss_cross.GUI.GUIFactory"; +} \ No newline at end of file diff --git a/src/main/resources/assets/crisscross/lang/en_US.lang b/src/main/resources/assets/crisscross/lang/en_US.lang new file mode 100644 index 0000000..99824ec --- /dev/null +++ b/src/main/resources/assets/crisscross/lang/en_US.lang @@ -0,0 +1,11 @@ +#Tiles +tile.CrissCross.Cropomator.name=Cropomator +tile.CrissCross.ElectroExtractor.name=ElectroExtractor + +#Items +item.CrissCross.Iron.name=Electrolytic Iron Dust +item.CrissCross.Gold.name=Electrolytic Gold Dust + +#Containers +container.cropomator=Cropomator +container.electroextractor=ElectroExtractor \ No newline at end of file diff --git a/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator Bottom.psd b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator Bottom.psd new file mode 100644 index 0000000..aa3da81 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator Bottom.psd differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator Front Active.psd b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator Front Active.psd new file mode 100644 index 0000000..cc78881 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator Front Active.psd differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator Front.psd b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator Front.psd new file mode 100644 index 0000000..f62aa65 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator Front.psd differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator top.psd b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator top.psd new file mode 100644 index 0000000..efd6d0d Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator top.psd differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Bottom.png b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Bottom.png new file mode 100644 index 0000000..0f7e873 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Bottom.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Front.png b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Front.png new file mode 100644 index 0000000..a2cfbba Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Front.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Sides.png b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Sides.png new file mode 100644 index 0000000..a9c1584 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Sides.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Top.png b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Top.png new file mode 100644 index 0000000..9526250 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/Cropomator_Top.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/Cropomator/cropomator side.psd b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/cropomator side.psd new file mode 100644 index 0000000..a0dfcb3 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/Cropomator/cropomator side.psd differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator Bottom.psd b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator Bottom.psd new file mode 100644 index 0000000..aa3da81 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator Bottom.psd differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator Front Active.psd b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator Front Active.psd new file mode 100644 index 0000000..cc78881 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator Front Active.psd differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator Front.psd b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator Front.psd new file mode 100644 index 0000000..f62aa65 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator Front.psd differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator top.psd b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator top.psd new file mode 100644 index 0000000..efd6d0d Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/Cropomator top.psd differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Bottom.png b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Bottom.png new file mode 100644 index 0000000..0f7e873 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Bottom.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Front.png b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Front.png new file mode 100644 index 0000000..bc0efd7 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Front.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Front.png.mcmeta b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Front.png.mcmeta new file mode 100644 index 0000000..7644671 --- /dev/null +++ b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Front.png.mcmeta @@ -0,0 +1,38 @@ +{ + "animation": { + "frames": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ] + } +} diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Sides.png b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Sides.png new file mode 100644 index 0000000..a9c1584 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Sides.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Top.png b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Top.png new file mode 100644 index 0000000..27a8aff Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/ElectroExtractor_Top.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/cropomator side.psd b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/cropomator side.psd new file mode 100644 index 0000000..a0dfcb3 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/ElectroExtractor/cropomator side.psd differ diff --git a/src/main/resources/assets/crisscross/textures/gui/cropomator.png b/src/main/resources/assets/crisscross/textures/gui/cropomator.png new file mode 100644 index 0000000..1586ab7 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/gui/cropomator.png differ diff --git a/src/main/resources/assets/crisscross/textures/gui/electroextractor.png b/src/main/resources/assets/crisscross/textures/gui/electroextractor.png new file mode 100644 index 0000000..0440995 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/gui/electroextractor.png differ diff --git a/src/main/resources/assets/crisscross/textures/items/dust_base.png b/src/main/resources/assets/crisscross/textures/items/dust_base.png new file mode 100644 index 0000000..f7222f4 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/items/dust_base.png differ diff --git a/src/main/resources/assets/crisscross/textures/items/dust_overlay.png b/src/main/resources/assets/crisscross/textures/items/dust_overlay.png new file mode 100644 index 0000000..b6a8099 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/items/dust_overlay.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info new file mode 100644 index 0000000..b893d41 --- /dev/null +++ b/src/main/resources/mcmod.info @@ -0,0 +1,16 @@ +[ +{ + "modid": "CrissCross", + "name": "CrissCross", + "description": "A highly confused mod!.", + "version": "1.0A", + "mcversion": "1.7.10", + "url": "", + "updateUrl": "", + "authorList": ["oitsjustjose"], + "credits": "", + "logoFile": "", + "screenshots": [], + "dependencies": [] +} +]