diff --git a/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityAutoChisel.java b/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityAutoChisel.java index fa00f93f..18c147d3 100644 --- a/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityAutoChisel.java +++ b/src/main/java/com/cricketcraft/chisel/block/tileentity/TileEntityAutoChisel.java @@ -2,6 +2,8 @@ package com.cricketcraft.chisel.block.tileentity; import java.util.List; +import com.cricketcraft.chisel.api.carving.CarvingUtils; +import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; @@ -29,7 +31,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class TileEntityAutoChisel extends TileEntity implements ISidedInventory { public enum Upgrade { - SPEED, AUTOMATION, STACK; + SPEED, AUTOMATION, STACK, REVERSION; public String getUnlocalizedName() { return ChiselItems.upgrade.getUnlocalizedName() + "_" + this.name().toLowerCase(); @@ -47,7 +49,7 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory private static EntityItem ghostItem; boolean equal = false; - private ItemStack[] inventory = new ItemStack[7]; + private ItemStack[] inventory = new ItemStack[8]; private String name = "autoChisel"; // client animation fields @@ -114,7 +116,6 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory if (!worldObj.isRemote && hasChisel() && base != null && target != null) { if (canBeMadeFrom(base, target)) { - if (progress >= (hasUpgrade(Upgrade.SPEED) ? FAST_SPEED : SLOW_SPEED)) { // reset progress @@ -141,6 +142,65 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory // if we have the stack upgrade, boost the stack size to the max possible, otherwise just one chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1; + if (canChisel(chiseled)) { + // if our output is empty, just use the current result + if (output == null) { + setInventorySlotContents(OUTPUT, chiseled); + } else { + // otherwise just add our result to the existing stack + inventory[OUTPUT].stackSize += chiseled.stackSize; + slotChanged(OUTPUT); + } + + chiselItem(chiseled.stackSize); + + // remove what we made from the stack + base.stackSize -= chiseled.stackSize; + if (base.stackSize <= 0) { + setInventorySlotContents(BASE, null); // clear out 0 size itemstacks + } + } + } else if (worldObj.getTotalWorldTime() % 10 == 0) { + progress++; + } + } + } else if(!worldObj.isRemote && hasChisel() && base != null && hasUpgrade(Upgrade.REVERSION)){ + if(Carving.chisel.getItemsForChiseling(base) != null){ + if (progress >= (hasUpgrade(Upgrade.SPEED) ? FAST_SPEED : SLOW_SPEED)) { + + // reset progress + progress = 0; + + // the max possible for this craft + int canBeMade = base.getMaxStackSize(); + + // if there are items in the output, they count towards the max we can make + if (output != null) { + canBeMade -= output.stackSize; + } + + // can't make more than we have + canBeMade = Math.min(base.stackSize, canBeMade); + + // if we can't make any, forget it + if (canBeMade <= 0) { + return; + } + ItemStack chiseled; + if(Carving.chisel.getItemsForChiseling(inventory[TARGET]).get(0) != null){ + + // result will always be a copy of the target, of course + chiseled = inventory[TARGET].copy(); + // if we have the stack upgrade, boost the stack size to the max possible, otherwise just one + chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1; + } else { + // result will always be a copy of the target, of course + chiseled = base.copy(); + // if we have the stack upgrade, boost the stack size to the max possible, otherwise just one + chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1; + } + + if (canChisel(chiseled)) { // if our output is empty, just use the current result if (output == null) { @@ -197,7 +257,11 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory return !toMerge.getHasSubtypes() || toMerge.getItemDamage() == inventory[OUTPUT].getItemDamage(); } - return ((IChiselItem)inventory[CHISEL].getItem()).canChisel(worldObj, inventory[CHISEL], General.getVariation(inventory[TARGET])); + if(inventory[TARGET] == null){ + return ((IChiselItem)inventory[CHISEL].getItem()).canChisel(worldObj, inventory[CHISEL], General.getVariation(inventory[BASE])); + } else { + return ((IChiselItem)inventory[CHISEL].getItem()).canChisel(worldObj, inventory[CHISEL], General.getVariation(inventory[TARGET])); + } } private boolean hasChisel() { @@ -208,14 +272,27 @@ public class TileEntityAutoChisel extends TileEntity implements ISidedInventory private void chiselItem(int chiseled) { if (!worldObj.isRemote) { boolean breakChisel = false; - if (((IChiselItem) inventory[CHISEL].getItem()).onChisel(worldObj, inventory[CHISEL], General.getVariation(inventory[TARGET]))) { - inventory[CHISEL].setItemDamage(inventory[CHISEL].getItemDamage() + 1); - if (inventory[CHISEL].getItemDamage() >= inventory[CHISEL].getMaxDamage()) { - setInventorySlotContents(CHISEL, null); - breakChisel = true; + if(inventory[TARGET] == null){ + if (((IChiselItem) inventory[CHISEL].getItem()).onChisel(worldObj, inventory[CHISEL], CarvingUtils.getDefaultVariationFor(Block.getBlockFromItem(inventory[TARGET].getItem()), inventory[TARGET].getItemDamage(), General.getVariation(inventory[TARGET]).getOrder()))) { + inventory[CHISEL].setItemDamage(inventory[CHISEL].getItemDamage() + 1); + if (inventory[CHISEL].getItemDamage() >= inventory[CHISEL].getMaxDamage()) { + setInventorySlotContents(CHISEL, null); + breakChisel = true; + } } + PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true, breakChisel), worldObj.provider.dimensionId); + } else { + if (((IChiselItem) inventory[CHISEL].getItem()).onChisel(worldObj, inventory[CHISEL], General.getVariation(inventory[TARGET]))) { + inventory[CHISEL].setItemDamage(inventory[CHISEL].getItemDamage() + 1); + if (inventory[CHISEL].getItemDamage() >= inventory[CHISEL].getMaxDamage()) { + setInventorySlotContents(CHISEL, null); + breakChisel = true; + } + } + PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true, breakChisel), worldObj.provider.dimensionId); } - PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true, breakChisel), worldObj.provider.dimensionId); + + } else { if (breakChisel) { worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "random.break", 0.8F, 0.8F + worldObj.rand.nextFloat() * 0.4F, false); diff --git a/src/main/java/com/cricketcraft/chisel/inventory/ContainerAutoChisel.java b/src/main/java/com/cricketcraft/chisel/inventory/ContainerAutoChisel.java index 466b0942..72e04d9f 100644 --- a/src/main/java/com/cricketcraft/chisel/inventory/ContainerAutoChisel.java +++ b/src/main/java/com/cricketcraft/chisel/inventory/ContainerAutoChisel.java @@ -25,9 +25,10 @@ public class ContainerAutoChisel extends Container { addSlot(tileEntityAutoChisel, 1, 78, 52); addSlot(tileEntityAutoChisel, 2, 103, 15); addSlot(tileEntityAutoChisel, 3, 8, 62); - addSlot(tileEntityAutoChisel, 4, 151, 11); - addSlot(tileEntityAutoChisel, 5, 151, 31); - addSlot(tileEntityAutoChisel, 6, 151, 51); + addSlot(tileEntityAutoChisel, 4, 151, 5); + addSlot(tileEntityAutoChisel, 5, 151, 25); + addSlot(tileEntityAutoChisel, 6, 151, 45); + addSlot(tileEntityAutoChisel, 7, 151, 65); bindPlayerInventory(player); } diff --git a/src/main/java/com/cricketcraft/chisel/item/ItemUpgrade.java b/src/main/java/com/cricketcraft/chisel/item/ItemUpgrade.java index 25e9e1c9..5cbafc12 100644 --- a/src/main/java/com/cricketcraft/chisel/item/ItemUpgrade.java +++ b/src/main/java/com/cricketcraft/chisel/item/ItemUpgrade.java @@ -13,7 +13,7 @@ import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel.Upgrade; public class ItemUpgrade extends BaseItem { - public IIcon[] icons = new IIcon[3]; + public IIcon[] icons = new IIcon[4]; public ItemUpgrade(String unlocalizedName) { super(); @@ -40,7 +40,7 @@ public class ItemUpgrade extends BaseItem { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void getSubItems(Item item, CreativeTabs tab, List list) { - for (int i = 0; i < 3; i++) { + for (int i = 0; i < Upgrade.values().length; i++) { list.add(new ItemStack(item, 1, i)); } } diff --git a/src/main/resources/assets/chisel/lang/en_US.lang b/src/main/resources/assets/chisel/lang/en_US.lang index 0147efc5..9890a007 100644 --- a/src/main/resources/assets/chisel/lang/en_US.lang +++ b/src/main/resources/assets/chisel/lang/en_US.lang @@ -26,10 +26,12 @@ item.smashingRock.desc=Right-Click to throw. This will turn Cobblestone into Gra item.upgrade_speed.name=Speed Upgrade item.upgrade_automation.name=Automation Upgrade item.upgrade_stack.name=Stack Upgrade +item.upgrade_reversion.name=Reversion Upgrade item.upgrade_speed.desc=Increases the rate at which it works item.upgrade_automation.desc=Allows things to push in and out of the Auto Chisel item.upgrade_stack.desc=Allows it to manufacture stacks at a time +item.upgrade_reversion.desc=Reverts the base slot to its original form # Block localizations # Have fun! ~zombiepig333 @@ -112,6 +114,10 @@ tile.granite.6.desc=Granite Small Tiles tile.chisel.autoChisel.name=Auto Chisel autochisel.slot.chisel.tooltip=Chisel Slot autochisel.slot.target.tooltip=Target Slot +autochisel.slot.speed.tooltip=Speed Upgrade +autochisel.slot.automation.tooltip=Automation Upgrade +autochisel.slot.stack.tooltip=Stack Upgrade +autochisel.slot.reversion.tooltip=Reversion Upgrade #Leaves tile.chisel.leaves.name=Leaf diff --git a/src/main/resources/assets/chisel/textures/autochisel-gui.png b/src/main/resources/assets/chisel/textures/autochisel-gui.png index 9fad5cea..12ff701c 100644 Binary files a/src/main/resources/assets/chisel/textures/autochisel-gui.png and b/src/main/resources/assets/chisel/textures/autochisel-gui.png differ