diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCobblegen.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCobblegen.java new file mode 100644 index 0000000..3d8b8f3 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockCobblegen.java @@ -0,0 +1,119 @@ +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.TileEntityCobblegen; +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 BlockCobblegen extends BlockMachineBase +{ + private static String unlocName = "CobblestoneGenerator"; + + public BlockCobblegen() + { + super(unlocName); + GameRegistry.registerTileEntity(TileEntityCobblegen.class, unlocName); + GameRegistry.registerBlock(this, 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 TileEntityCobblegen(); + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) + { + Random random = new Random(); + TileEntityCobblegen tile = (TileEntityCobblegen) 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 + { + TileEntityCobblegen tileext = (TileEntityCobblegen) world.getTileEntity(x, y, z); + if(tileext != null) + player.openGui(CrissCross.instance, GUIHandler.Cobblegen, world, x, y, z); + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockStonegen.java b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockStonegen.java new file mode 100644 index 0000000..0fab395 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/BlockStonegen.java @@ -0,0 +1,119 @@ +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.TileEntityStonegen; +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 BlockStonegen extends BlockMachineBase +{ + private static String unlocName = "StoneGenerator"; + + public BlockStonegen() + { + super(unlocName); + GameRegistry.registerTileEntity(TileEntityStonegen.class, unlocName); + GameRegistry.registerBlock(this, 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 TileEntityStonegen(); + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) + { + Random random = new Random(); + TileEntityStonegen tile = (TileEntityStonegen) 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 + { + TileEntityStonegen tileext = (TileEntityStonegen) world.getTileEntity(x, y, z); + if(tileext != null) + player.openGui(CrissCross.instance, GUIHandler.Stonegen, world, x, y, z); + return true; + } + } +} \ No newline at end of file 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 8a5a93f..1889918 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Blocks/CCBlocks.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Blocks/CCBlocks.java @@ -11,12 +11,16 @@ public class CCBlocks public static Block cropomator; public static Block electroextractor; public static Block woodchipper; + public static Block cobblegen; + public static Block stonegen; public static void init() { cropomator = new BlockCropomator(); electroextractor = new BlockElectroextractor(); woodchipper = new BlockWoodchipper(); + cobblegen = new BlockCobblegen(); + stonegen = new BlockStonegen(); NetworkRegistry.INSTANCE.registerGuiHandler(CrissCross.instance, new GUIHandler()); } diff --git a/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerCobblegen.java b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerCobblegen.java new file mode 100644 index 0000000..0f5000a --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerCobblegen.java @@ -0,0 +1,178 @@ +package com.oitsjustjose.criss_cross.Container; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCobblegen; +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 ContainerCobblegen extends Container +{ + TileEntityCobblegen cobblegen; + EntityPlayer player; + + private int lastUseTime; + private int lastChopTime; + private int lastFuelTime; + + public ContainerCobblegen(EntityPlayer player, TileEntityCobblegen cobblegen) + { + this.player = player; + this.cobblegen = cobblegen; + + lastUseTime = 0; + lastChopTime = 0; + lastFuelTime = 0; + + this.addSlotToContainer(new Slot(cobblegen, 0, 56, 17)); // input + this.addSlotToContainer(new Slot(cobblegen, 1, 56, 53)); // catalyst + this.addSlotToContainer(new MachineOutputSlot(player, cobblegen, 2, 116, 35)); + this.addInventorySlots(); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int timeType1, int timeType2) + { + switch(timeType1) + { + case 0: + this.cobblegen.processTime = timeType2; + break; + case 1: + this.cobblegen.fuelTime = timeType2; + break; + case 2: + this.cobblegen.fuelUsetime = timeType2; + break; + } + } + + @Override + public void addCraftingToCrafters(ICrafting crafting) + { + super.addCraftingToCrafters(crafting); + crafting.sendProgressBarUpdate(this, 0, this.cobblegen.processTime); + crafting.sendProgressBarUpdate(this, 1, this.cobblegen.fuelTime); + crafting.sendProgressBarUpdate(this, 2, this.cobblegen.fuelUsetime); + } + + @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.cobblegen.processTime) + crafting.sendProgressBarUpdate(this, 0, this.cobblegen.processTime); + if(this.lastChopTime != this.cobblegen.fuelTime) + crafting.sendProgressBarUpdate(this, 1, this.cobblegen.fuelTime); + if(this.lastFuelTime != this.cobblegen.fuelUsetime) + crafting.sendProgressBarUpdate(this, 2, this.cobblegen.fuelUsetime); + } + this.lastUseTime = this.cobblegen.processTime; + this.lastChopTime = this.cobblegen.fuelTime; + this.lastFuelTime = this.cobblegen.fuelUsetime; + } + + @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(TileEntityCobblegen.isValid(itemstack1)) + { + if(!this.mergeItemStack(itemstack1, 0, 1, false)) + { + return null; + } + } + else if(TileEntityCobblegen.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 == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(player, itemstack1); + } + + return itemstack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) + { + return this.cobblegen.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/ContainerStonegen.java b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerStonegen.java new file mode 100644 index 0000000..3947526 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Container/ContainerStonegen.java @@ -0,0 +1,178 @@ +package com.oitsjustjose.criss_cross.Container; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityStonegen; +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 ContainerStonegen extends Container +{ + TileEntityStonegen Stonegen; + EntityPlayer player; + + private int lastUseTime; + private int lastChopTime; + private int lastFuelTime; + + public ContainerStonegen(EntityPlayer player, TileEntityStonegen Stonegen) + { + this.player = player; + this.Stonegen = Stonegen; + + lastUseTime = 0; + lastChopTime = 0; + lastFuelTime = 0; + + this.addSlotToContainer(new Slot(Stonegen, 0, 56, 17)); // input + this.addSlotToContainer(new Slot(Stonegen, 1, 56, 53)); // catalyst + this.addSlotToContainer(new MachineOutputSlot(player, Stonegen, 2, 116, 35)); + this.addInventorySlots(); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int timeType1, int timeType2) + { + switch(timeType1) + { + case 0: + this.Stonegen.processTime = timeType2; + break; + case 1: + this.Stonegen.fuelTime = timeType2; + break; + case 2: + this.Stonegen.fuelUsetime = timeType2; + break; + } + } + + @Override + public void addCraftingToCrafters(ICrafting crafting) + { + super.addCraftingToCrafters(crafting); + crafting.sendProgressBarUpdate(this, 0, this.Stonegen.processTime); + crafting.sendProgressBarUpdate(this, 1, this.Stonegen.fuelTime); + crafting.sendProgressBarUpdate(this, 2, this.Stonegen.fuelUsetime); + } + + @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.Stonegen.processTime) + crafting.sendProgressBarUpdate(this, 0, this.Stonegen.processTime); + if(this.lastChopTime != this.Stonegen.fuelTime) + crafting.sendProgressBarUpdate(this, 1, this.Stonegen.fuelTime); + if(this.lastFuelTime != this.Stonegen.fuelUsetime) + crafting.sendProgressBarUpdate(this, 2, this.Stonegen.fuelUsetime); + } + this.lastUseTime = this.Stonegen.processTime; + this.lastChopTime = this.Stonegen.fuelTime; + this.lastFuelTime = this.Stonegen.fuelUsetime; + } + + @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(TileEntityStonegen.isValid(itemstack1)) + { + if(!this.mergeItemStack(itemstack1, 0, 1, false)) + { + return null; + } + } + else if(TileEntityStonegen.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 == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(player, itemstack1); + } + + return itemstack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) + { + return this.Stonegen.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/GUI/GUICobblegen.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUICobblegen.java new file mode 100644 index 0000000..af8f28b --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUICobblegen.java @@ -0,0 +1,48 @@ +package com.oitsjustjose.criss_cross.GUI; + +import org.lwjgl.opengl.GL11; + +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCobblegen; + +import com.oitsjustjose.criss_cross.Container.ContainerCobblegen; +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 GUICobblegen extends GuiContainer +{ + public static final ResourceLocation texture = new ResourceLocation("crisscross", "textures/gui/cobblegen.png"); + + private TileEntityCobblegen cobblegen; + + public GUICobblegen(EntityPlayer player, TileEntityCobblegen cobblegen) + { + super(new ContainerCobblegen(player, cobblegen)); + this.cobblegen = cobblegen; + } + + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.cobblegen"), 30, 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.cobblegen.isUsingFuel()) + { + int i1 = this.cobblegen.getBurnTimeRemainingScaled(13); + this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); + i1 = this.cobblegen.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/GUIHandler.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIHandler.java index e080491..6ddee15 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIHandler.java +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIHandler.java @@ -2,12 +2,16 @@ 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.Container.ContainerStonegen; import com.oitsjustjose.criss_cross.Container.ContainerWoodchipper; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCobblegen; import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator; import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityStonegen; import com.oitsjustjose.criss_cross.TileEntity.TileEntityWoodchipper; import cpw.mods.fml.common.network.IGuiHandler; +import com.oitsjustjose.criss_cross.Container.ContainerCobblegen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -17,6 +21,8 @@ public class GUIHandler implements IGuiHandler public static final int Cropomator = 1; public static final int Electroextractor = 2; public static final int Woodchipper = 3; + public static final int Cobblegen = 4; + public static final int Stonegen = 5; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) @@ -41,6 +47,18 @@ public class GUIHandler implements IGuiHandler return new ContainerWoodchipper(player, TE); } + if(tile instanceof TileEntityCobblegen) + { + TileEntityCobblegen TE = (TileEntityCobblegen) tile; + + return new ContainerCobblegen(player, TE); + } + if(tile instanceof TileEntityStonegen) + { + TileEntityStonegen TE = (TileEntityStonegen) tile; + + return new ContainerStonegen(player, TE); + } return null; } @@ -69,7 +87,19 @@ public class GUIHandler implements IGuiHandler return new GUIWoodchipper(player, TE); } - + if(tile instanceof TileEntityCobblegen) + { + TileEntityCobblegen TE = (TileEntityCobblegen) tile; + + return new GUICobblegen(player, TE); + } + if(tile instanceof TileEntityStonegen) + { + TileEntityStonegen TE = (TileEntityStonegen) tile; + + return new GUIStonegen(player, TE); + } + return null; } } \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIStonegen.java b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIStonegen.java new file mode 100644 index 0000000..2bf74e8 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/GUI/GUIStonegen.java @@ -0,0 +1,48 @@ +package com.oitsjustjose.criss_cross.GUI; + +import org.lwjgl.opengl.GL11; + +import com.oitsjustjose.criss_cross.TileEntity.TileEntityStonegen; + +import com.oitsjustjose.criss_cross.Container.ContainerStonegen; +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 GUIStonegen extends GuiContainer +{ + public static final ResourceLocation texture = new ResourceLocation("crisscross", "textures/gui/stonegen.png"); + + private TileEntityStonegen stonegen; + + public GUIStonegen(EntityPlayer player, TileEntityStonegen stonegen) + { + super(new ContainerStonegen(player, stonegen)); + this.stonegen = stonegen; + } + + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + this.fontRendererObj.drawString(StatCollector.translateToLocal("container.stonegen"), 30, 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.stonegen.isUsingFuel()) + { + int i1 = this.stonegen.getBurnTimeRemainingScaled(13); + this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1); + i1 = this.stonegen.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/Items/CCItems.java b/src/main/java/com/oitsjustjose/criss_cross/Items/CCItems.java index 528339a..38be940 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Items/CCItems.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Items/CCItems.java @@ -1,6 +1,7 @@ package com.oitsjustjose.criss_cross.Items; import net.minecraft.item.Item; +import net.minecraftforge.fluids.FluidRegistry; public class CCItems { diff --git a/src/main/java/com/oitsjustjose/criss_cross/Recipes/CCCraftingRecipes.java b/src/main/java/com/oitsjustjose/criss_cross/Recipes/CCCraftingRecipes.java index a48ba4f..5f98ef8 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Recipes/CCCraftingRecipes.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Recipes/CCCraftingRecipes.java @@ -19,6 +19,24 @@ public class CCCraftingRecipes electroextractorRecipe(); woodChipperRecipe(); initBucketRecipes(); + initBlockGeneratorRecipes(); + } + + static void initBlockGeneratorRecipes() + { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(CCBlocks.cobblegen), + "CPC", + "#$#", + "CPC", + '$', "blockIron", 'C', "cobblestone", 'P', Blocks.piston, '#', Items.stone_pickaxe + )); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(CCBlocks.stonegen), + "CPC", + "#$#", + "CPC", + '$', "blockIron", 'C', "stone", 'P', Blocks.piston, '#', Items.stone_pickaxe + )); } static void initBucketRecipes() diff --git a/src/main/java/com/oitsjustjose/criss_cross/Recipes/CobblegenRecipes.java b/src/main/java/com/oitsjustjose/criss_cross/Recipes/CobblegenRecipes.java new file mode 100644 index 0000000..611fa3b --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Recipes/CobblegenRecipes.java @@ -0,0 +1,68 @@ +package com.oitsjustjose.criss_cross.Recipes; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import com.google.common.collect.Maps; +import com.oitsjustjose.criss_cross.Items.CCItems; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityCobblegen; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class CobblegenRecipes +{ + private static final CobblegenRecipes recipeBase = new CobblegenRecipes(); + private Map recipes = Maps.newHashMap(); + + public CobblegenRecipes() + { + this.addRecipe(new ItemStack(Items.lava_bucket), new ItemStack(Blocks.cobblestone)); + TileEntityCobblegen.addFuel(new ItemStack(Items.water_bucket)); + TileEntityCobblegen.addFuel(new ItemStack(CCItems.magicBucket)); + } + + public static CobblegenRecipes getInstance() + { + return recipeBase; + } + + public void addRecipe(ItemStack input, ItemStack stack) + { + this.recipes.put(input, stack); + } + + public ItemStack getResult(ItemStack stack) + { + Iterator iterator = this.recipes.entrySet().iterator(); + Entry entry; + + do + { + if(!iterator.hasNext()) + return null; + + entry = (Entry) iterator.next(); + } + while(!this.compareItemStacks(stack, (ItemStack) entry.getKey())); + + return (ItemStack) entry.getValue(); + } + + private boolean compareItemStacks(ItemStack stack1, ItemStack stack2) + { + return stack2.getItem() == stack1.getItem() + && (stack2.getItemDamage() == 32767 || stack2.getItemDamage() == stack1.getItemDamage()); + } + + public Map getRecipeList() + { + return this.recipes; + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/Recipes/StonegenRecipes.java b/src/main/java/com/oitsjustjose/criss_cross/Recipes/StonegenRecipes.java new file mode 100644 index 0000000..7c16ff4 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/Recipes/StonegenRecipes.java @@ -0,0 +1,64 @@ +package com.oitsjustjose.criss_cross.Recipes; + +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import com.google.common.collect.Maps; +import com.oitsjustjose.criss_cross.Items.CCItems; +import com.oitsjustjose.criss_cross.TileEntity.TileEntityStonegen; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class StonegenRecipes +{ + private static final StonegenRecipes recipeBase = new StonegenRecipes(); + private Map recipes = Maps.newHashMap(); + + public StonegenRecipes() + { + this.addRecipe(new ItemStack(Items.lava_bucket), new ItemStack(Blocks.stone)); + TileEntityStonegen.addFuel(new ItemStack(Items.water_bucket)); + TileEntityStonegen.addFuel(new ItemStack(CCItems.magicBucket)); + } + + public static StonegenRecipes getInstance() + { + return recipeBase; + } + + public void addRecipe(ItemStack input, ItemStack stack) + { + this.recipes.put(input, stack); + } + + public ItemStack getResult(ItemStack stack) + { + Iterator iterator = this.recipes.entrySet().iterator(); + Entry entry; + + do + { + if(!iterator.hasNext()) + return null; + + entry = (Entry) iterator.next(); + } + while(!this.compareItemStacks(stack, (ItemStack) entry.getKey())); + + return (ItemStack) entry.getValue(); + } + + private boolean compareItemStacks(ItemStack stack1, ItemStack stack2) + { + return stack2.getItem() == stack1.getItem() + && (stack2.getItemDamage() == 32767 || stack2.getItemDamage() == stack1.getItemDamage()); + } + + public Map getRecipeList() + { + return this.recipes; + } +} \ No newline at end of file diff --git a/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCobblegen.java b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCobblegen.java new file mode 100644 index 0000000..83e83e9 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityCobblegen.java @@ -0,0 +1,392 @@ +package com.oitsjustjose.criss_cross.TileEntity; + +import java.util.ArrayList; + +import com.oitsjustjose.criss_cross.Util.ConfigHandler; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import com.oitsjustjose.criss_cross.Blocks.BlockCobblegen; +import com.oitsjustjose.criss_cross.Recipes.CobblegenRecipes; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityCobblegen extends TileEntity implements ISidedInventory +{ + private static int proTicks = ConfigHandler.blockGeneratorProcessTimes; + 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 fuelItems = new ArrayList(); + + private ItemStack[] ItemStacks = new ItemStack[3]; + + public int fuelTime; + public int processTime; + public int fuelUsetime; + + public static ArrayList getFuels() + { + return fuelItems; + } + + @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.cobblegen"; + } + + @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) + { + 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; + BlockCobblegen.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord, + this.zCoord); + } + } + + if(flag1) + { + this.markDirty(); + } + } + + private boolean canProcess() + { + ItemStack input = this.ItemStacks[0]; + if(input != null) + { + ItemStack output = CobblegenRecipes.getInstance().getResult(input); + if(output == null) + return false; + ItemStack outputSlot = this.ItemStacks[2]; + if(outputSlot == null) + return true; + if(!outputSlot.isItemEqual(output)) + return false; + int result = outputSlot.stackSize + output.stackSize; + return result <= output.getMaxStackSize(); + } + return false; + } + + 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 isValid(ItemStack itemstack) + { + if(CobblegenRecipes.getInstance().getResult(itemstack) != null) + return true; + return false; + } + + public void processItem() + { + if(this.canProcess()) + { + + ItemStack input = ItemStacks[0]; + ItemStack output = CobblegenRecipes.getInstance().getResult(input); + ItemStack outputSlot = ItemStacks[2]; + if(outputSlot == null) + { + ItemStacks[2] = output.copy(); + } + else if(outputSlot.isItemEqual(output)) + { + outputSlot.stackSize += output.stackSize; + } + + if(input.stackSize <= 0) + { + 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() + { + } +} diff --git a/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityStonegen.java b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityStonegen.java new file mode 100644 index 0000000..d7f34b9 --- /dev/null +++ b/src/main/java/com/oitsjustjose/criss_cross/TileEntity/TileEntityStonegen.java @@ -0,0 +1,393 @@ +package com.oitsjustjose.criss_cross.TileEntity; + +import java.util.ArrayList; + +import com.oitsjustjose.criss_cross.Blocks.BlockStonegen; +import com.oitsjustjose.criss_cross.Recipes.StonegenRecipes; +import com.oitsjustjose.criss_cross.Util.ConfigHandler; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityStonegen extends TileEntity implements ISidedInventory +{ + private static int proTicks = ConfigHandler.blockGeneratorProcessTimes; + 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 fuelItems = new ArrayList(); + + private ItemStack[] ItemStacks = new ItemStack[3]; + + public int fuelTime; + public int processTime; + public int fuelUsetime; + + public static ArrayList getFuels() + { + return fuelItems; + } + + @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.stonegen"; + } + + @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; + BlockStonegen.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord, + this.zCoord); + } + } + + if(flag1) + { + this.markDirty(); + } + } + + private boolean canProcess() + { + ItemStack input = this.ItemStacks[0]; + if(input != null) + { + ItemStack output = StonegenRecipes.getInstance().getResult(input); + if(output == null) + return false; + ItemStack outputSlot = this.ItemStacks[2]; + if(outputSlot == null) + return true; + if(!outputSlot.isItemEqual(output)) + return false; + int result = outputSlot.stackSize + output.stackSize; + return result <= output.getMaxStackSize(); + } + return false; + } + + 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 isValid(ItemStack itemstack) + { + if(StonegenRecipes.getInstance().getResult(itemstack) != null) + return true; + return false; + } + + public void processItem() + { + if(this.canProcess()) + { + + ItemStack input = ItemStacks[0]; + ItemStack output = StonegenRecipes.getInstance().getResult(input); + ItemStack outputSlot = ItemStacks[2]; + if(outputSlot == null) + { + ItemStacks[2] = output.copy(); + } + else if(outputSlot.isItemEqual(output)) + { + outputSlot.stackSize += output.stackSize; + } + + if(input.stackSize <= 0) + { + 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() + { + } +} 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 02cd153..e384057 100644 --- a/src/main/java/com/oitsjustjose/criss_cross/Util/ConfigHandler.java +++ b/src/main/java/com/oitsjustjose/criss_cross/Util/ConfigHandler.java @@ -52,8 +52,7 @@ public class ConfigHandler "minecraft:water_bucket", "minecraft:potion:0", "CrissCross:magicBucket:0" }; - public static int autosmithProcessTime; - public static String autosmithRecipeItem; + public static int blockGeneratorProcessTimes; public static void init(File configFile) { @@ -134,12 +133,8 @@ public class ConfigHandler //Autosmith's Configs - autosmithProcessTime = config.getInt("Autosmith Process Time", config.CATEGORY_GENERAL, 200, 0, Short.MAX_VALUE, - "Control how many ticks it takes the Autosmith to process an item. Default is 200; furnaces are also 200."); - - autosmithRecipeItem = config.getString("Autosmith Crafting Item", config.CATEGORY_GENERAL, - "minecraft:diamond_block", - "This is the item located in the center of the crafting recipe for the Autosmith. Formatted as: :: or :."); + blockGeneratorProcessTimes = config.getInt("Stone Generators' Process Times", config.CATEGORY_GENERAL, 20, 0, Short.MAX_VALUE, + "Control how many ticks it takes a stone generator to process an item. Default is 20; furnaces are 200."); if(config.hasChanged()) config.save(); diff --git a/src/main/resources/assets/crisscross/lang/en_US.lang b/src/main/resources/assets/crisscross/lang/en_US.lang index 3e85894..b568e19 100644 --- a/src/main/resources/assets/crisscross/lang/en_US.lang +++ b/src/main/resources/assets/crisscross/lang/en_US.lang @@ -2,6 +2,9 @@ tile.CrissCross.Cropomator.name=Cropomator tile.CrissCross.ElectroExtractor.name=ElectroExtractor tile.CrissCross.WoodChipper.name=Wood Chipper +tile.CrissCross.CobblestoneGenerator.name=Cobblestone Generator +tile.CrissCross.StoneGenerator.name=Smooth Stone Generator + #Items #Dust Name Components @@ -16,6 +19,8 @@ item.CrissCross.voidBucket.name=Insatiable Bucket container.cropomator=Cropomator container.electroextractor=ElectroExtractor container.woodchipper=Wood Chipper +container.stonegen=Smooth Stone Generator +container.cobblegen=Cobblestone Generator #NEI Integration recipe.cropomatorfuel=Cropomator Fuels @@ -24,6 +29,8 @@ recipe.electroextractor=ElectroExtractor recipe.electroextractorfuel=ElectorExtractor Fuels recipe.woodchipper=Wood Chipper recipe.woodchipperfuel=Wood Chipper Fuels +recipe.stonegen=Smooth Stone Generator +recipe.cobblegen=Cobblestone Generator #Tab itemGroup.tabCrissCross=Criss Cross \ No newline at end of file diff --git a/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Bottom.png b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Bottom.png new file mode 100644 index 0000000..0f7e873 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Bottom.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Front.png b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Front.png new file mode 100644 index 0000000..cb55327 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Front.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Front.png.mcmeta b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Front.png.mcmeta new file mode 100644 index 0000000..269b2dc --- /dev/null +++ b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Front.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { +"frametime": 1 + } +} diff --git a/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Sides.png b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Sides.png new file mode 100644 index 0000000..a9c1584 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Sides.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Top.png b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Top.png new file mode 100644 index 0000000..3959b7c Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/CobblestoneGenerator/CobblestoneGenerator_Top.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Bottom.png b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Bottom.png new file mode 100644 index 0000000..0f7e873 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Bottom.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Front.png b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Front.png new file mode 100644 index 0000000..367da4b Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Front.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Front.png.mcmeta b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Front.png.mcmeta new file mode 100644 index 0000000..269b2dc --- /dev/null +++ b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Front.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { +"frametime": 1 + } +} diff --git a/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Sides.png b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Sides.png new file mode 100644 index 0000000..a9c1584 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Sides.png differ diff --git a/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Top.png b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Top.png new file mode 100644 index 0000000..3959b7c Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/blocks/StoneGenerator/StoneGenerator_Top.png differ diff --git a/src/main/resources/assets/crisscross/textures/gui/cobblegen.png b/src/main/resources/assets/crisscross/textures/gui/cobblegen.png new file mode 100644 index 0000000..a446d62 Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/gui/cobblegen.png differ diff --git a/src/main/resources/assets/crisscross/textures/gui/stonegen.png b/src/main/resources/assets/crisscross/textures/gui/stonegen.png new file mode 100644 index 0000000..651b68c Binary files /dev/null and b/src/main/resources/assets/crisscross/textures/gui/stonegen.png differ