diff --git a/bin/minecraft/mods/mekanism/gui/GuiRobitCrafting.png b/bin/minecraft/mods/mekanism/gui/GuiRobitCrafting.png index 431805587..4a0660a79 100644 Binary files a/bin/minecraft/mods/mekanism/gui/GuiRobitCrafting.png and b/bin/minecraft/mods/mekanism/gui/GuiRobitCrafting.png differ diff --git a/bin/minecraft/mods/mekanism/gui/GuiRobitInventory.png b/bin/minecraft/mods/mekanism/gui/GuiRobitInventory.png index b63f2c6de..5550d85ef 100644 Binary files a/bin/minecraft/mods/mekanism/gui/GuiRobitInventory.png and b/bin/minecraft/mods/mekanism/gui/GuiRobitInventory.png differ diff --git a/bin/minecraft/mods/mekanism/gui/GuiRobitMain.png b/bin/minecraft/mods/mekanism/gui/GuiRobitMain.png index 5e19e90fb..190873984 100644 Binary files a/bin/minecraft/mods/mekanism/gui/GuiRobitMain.png and b/bin/minecraft/mods/mekanism/gui/GuiRobitMain.png differ diff --git a/bin/minecraft/mods/mekanism/gui/GuiRobitSmelting.png b/bin/minecraft/mods/mekanism/gui/GuiRobitSmelting.png new file mode 100644 index 000000000..93510de81 Binary files /dev/null and b/bin/minecraft/mods/mekanism/gui/GuiRobitSmelting.png differ diff --git a/src/minecraft/mekanism/client/ClientProxy.java b/src/minecraft/mekanism/client/ClientProxy.java index bfe5391e0..f17e5d755 100644 --- a/src/minecraft/mekanism/client/ClientProxy.java +++ b/src/minecraft/mekanism/client/ClientProxy.java @@ -266,6 +266,12 @@ public class ClientProxy extends CommonProxy { return new GuiRobitInventory(player.inventory, robit1); } + case 24: + EntityRobit robit2 = (EntityRobit)world.getEntityByID(x); + if(robit2 != null) + { + return new GuiRobitSmelting(player.inventory, robit2); + } } return null; diff --git a/src/minecraft/mekanism/client/GuiRobitCrafting.java b/src/minecraft/mekanism/client/GuiRobitCrafting.java index 9a00f5a33..2e24919f3 100644 --- a/src/minecraft/mekanism/client/GuiRobitCrafting.java +++ b/src/minecraft/mekanism/client/GuiRobitCrafting.java @@ -64,6 +64,14 @@ public class GuiRobitCrafting extends GuiContainer else { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); } + + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) + { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); + } + else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); + } } @Override @@ -92,6 +100,12 @@ public class GuiRobitCrafting extends GuiContainer PacketHandler.sendRobitGui(2, entityId); mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, entityId, 0, 0); } + else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + PacketHandler.sendRobitGui(3, entityId); + mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, entityId, 0, 0); + } } } } diff --git a/src/minecraft/mekanism/client/GuiRobitInventory.java b/src/minecraft/mekanism/client/GuiRobitInventory.java index f25002405..64e094037 100644 --- a/src/minecraft/mekanism/client/GuiRobitInventory.java +++ b/src/minecraft/mekanism/client/GuiRobitInventory.java @@ -63,6 +63,14 @@ public class GuiRobitInventory extends GuiContainer else { drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); } + + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) + { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); + } + else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); + } } @Override @@ -91,6 +99,12 @@ public class GuiRobitInventory extends GuiContainer { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); } + else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + PacketHandler.sendRobitGui(3, robit.entityId); + mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.entityId, 0, 0); + } } } } diff --git a/src/minecraft/mekanism/client/GuiRobitMain.java b/src/minecraft/mekanism/client/GuiRobitMain.java index 7ccde0823..ed379151e 100644 --- a/src/minecraft/mekanism/client/GuiRobitMain.java +++ b/src/minecraft/mekanism/client/GuiRobitMain.java @@ -83,12 +83,20 @@ public class GuiRobitMain extends GuiContainer drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); } - if(xAxis >= 152 && xAxis <= 170 && yAxis >= 53 && yAxis <= 71) + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { - drawTexturedModalRect(guiWidth + 152, guiHeight + 53, 176 + 25, 108, 18, 18); + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); } else { - drawTexturedModalRect(guiWidth + 152, guiHeight + 53, 176 + 25, 126, 18, 18); + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); + } + + if(xAxis >= 152 && xAxis <= 170 && yAxis >= 53 && yAxis <= 71) + { + drawTexturedModalRect(guiWidth + 152, guiHeight + 53, 176 + 25, 144, 18, 18); + } + else { + drawTexturedModalRect(guiWidth + 152, guiHeight + 53, 176 + 25, 162, 18, 18); } int displayInt; @@ -128,6 +136,12 @@ public class GuiRobitMain extends GuiContainer PacketHandler.sendRobitGui(2, robit.entityId); mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.entityId, 0, 0); } + else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + PacketHandler.sendRobitGui(3, robit.entityId); + mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.entityId, 0, 0); + } else if(xAxis >= 152 && xAxis <= 170 && yAxis >= 53 && yAxis <= 71) { mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); diff --git a/src/minecraft/mekanism/client/GuiRobitSmelting.java b/src/minecraft/mekanism/client/GuiRobitSmelting.java new file mode 100644 index 000000000..e0cf73be8 --- /dev/null +++ b/src/minecraft/mekanism/client/GuiRobitSmelting.java @@ -0,0 +1,138 @@ +package mekanism.client; + +import mekanism.common.ContainerRobitSmelting; +import mekanism.common.EntityRobit; +import mekanism.common.Mekanism; +import mekanism.common.PacketHandler; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class GuiRobitSmelting extends GuiContainer +{ + public EntityRobit robit; + + public GuiRobitSmelting(InventoryPlayer inventory, EntityRobit entity) + { + super(new ContainerRobitSmelting(inventory, entity)); + xSize += 25; + robit = entity; + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + fontRenderer.drawString("Robit Smelting", 8, 6, 0x404040); + fontRenderer.drawString("Inventory", 8, ySize - 96 + 3, 0x404040); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture("/mods/mekanism/gui/GuiRobitSmelting.png"); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) + { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); + } + else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); + } + + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) + { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); + } + else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); + } + + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) + { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); + } + else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); + } + + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) + { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); + } + else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); + } + + int displayInt; + + if(robit.furnaceBurnTime > 0) + { + displayInt = getBurnTimeRemainingScaled(12); + drawTexturedModalRect(guiWidth + 56, guiHeight + 36 + 12 - displayInt, 176 + 25 + 18, 36 + 12 - displayInt, 14, displayInt + 2); + } + + displayInt = getCookProgressScaled(24); + drawTexturedModalRect(guiWidth + 79, guiHeight + 34, 176 + 25 + 18, 36 + 14, displayInt + 1, 16); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) + { + super.mouseClicked(mouseX, mouseY, button); + + if(button == 0) + { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + PacketHandler.sendRobitGui(0, robit.entityId); + mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.entityId, 0, 0); + } + else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + PacketHandler.sendRobitGui(1, robit.entityId); + mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.entityId, 0, 0); + } + else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + PacketHandler.sendRobitGui(2, robit.entityId); + mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.entityId, 0, 0); + } + else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) + { + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + } + } + + private int getCookProgressScaled(int i) + { + return robit.furnaceCookTime * i / 200; + } + + private int getBurnTimeRemainingScaled(int i) + { + if(robit.currentItemBurnTime == 0) + { + robit.currentItemBurnTime = 200; + } + + return robit.furnaceBurnTime * i / robit.currentItemBurnTime; + } +} diff --git a/src/minecraft/mekanism/common/CommonProxy.java b/src/minecraft/mekanism/common/CommonProxy.java index 796534cea..6ee08af80 100644 --- a/src/minecraft/mekanism/common/CommonProxy.java +++ b/src/minecraft/mekanism/common/CommonProxy.java @@ -208,6 +208,12 @@ public class CommonProxy { return new ContainerRobitInventory(player.inventory, robit1); } + case 24: + EntityRobit robit2 = (EntityRobit)world.getEntityByID(x); + if(robit2 != null) + { + return new ContainerRobitSmelting(player.inventory, robit2); + } } return null; diff --git a/src/minecraft/mekanism/common/ContainerRobitSmelting.java b/src/minecraft/mekanism/common/ContainerRobitSmelting.java new file mode 100644 index 000000000..73e9d8230 --- /dev/null +++ b/src/minecraft/mekanism/common/ContainerRobitSmelting.java @@ -0,0 +1,188 @@ +package mekanism.common; + +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.inventory.SlotFurnace; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.tileentity.TileEntityFurnace; + +public class ContainerRobitSmelting extends Container +{ + public EntityRobit robit; + + private int lastCookTime = 0; + private int lastBurnTime = 0; + private int lastItemBurnTime = 0; + + public ContainerRobitSmelting(InventoryPlayer inventory, EntityRobit entity) + { + robit = entity; + robit.openChest(); + + addSlotToContainer(new Slot(entity, 28, 56, 17)); + addSlotToContainer(new Slot(entity, 29, 56, 53)); + addSlotToContainer(new SlotFurnace(inventory.player, entity, 30, 116, 35)); + + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return true; + } + + @Override + public void addCraftingToCrafters(ICrafting icrafting) + { + super.addCraftingToCrafters(icrafting); + icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); + icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); + icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + + for(int i = 0; i < crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)crafters.get(i); + + if(lastCookTime != robit.furnaceCookTime) + { + icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); + } + + if(lastBurnTime != robit.furnaceBurnTime) + { + icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); + } + + if(lastItemBurnTime != robit.currentItemBurnTime) + { + icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); + } + } + + lastCookTime = robit.furnaceCookTime; + lastBurnTime = robit.furnaceBurnTime; + lastItemBurnTime = robit.currentItemBurnTime; + } + + @Override + public void updateProgressBar(int i, int j) + { + if(i == 0) + { + robit.furnaceCookTime = j; + } + + if(i == 1) + { + robit.furnaceBurnTime = j; + } + + if(i == 2) + { + robit.currentItemBurnTime = j; + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); + + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); + + if(slotID == 2) + { + if(!mergeItemStack(slotStack, 3, 39, true)) + { + return null; + } + } + else if(slotID != 1 && slotID != 0) + { + if(FurnaceRecipes.smelting().getSmeltingResult(slotStack) != null) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(TileEntityFurnace.isItemFuel(slotStack)) + { + if(!mergeItemStack(slotStack, 1, 2, false)) + { + return null; + } + } + else if(slotID >= 3 && slotID < 30) + { + if(!mergeItemStack(slotStack, 30, 39, false)) + { + return null; + } + } + else if(slotID >= 30 && slotID < 39 && !mergeItemStack(slotStack, 3, 30, false)) + { + return null; + } + } + else if(!mergeItemStack(slotStack, 3, 39, false)) + { + return null; + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + @Override + public void onCraftGuiClosed(EntityPlayer entityplayer) + { + super.onCraftGuiClosed(entityplayer); + robit.closeChest(); + } +} diff --git a/src/minecraft/mekanism/common/EntityRobit.java b/src/minecraft/mekanism/common/EntityRobit.java index 57a5bcfaf..c92af0a52 100644 --- a/src/minecraft/mekanism/common/EntityRobit.java +++ b/src/minecraft/mekanism/common/EntityRobit.java @@ -2,9 +2,10 @@ package mekanism.common; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; -import thermalexpansion.api.item.IChargeableItem; -import universalelectricity.core.item.ElectricItemHelper; -import universalelectricity.core.item.IItemElectric; + +import java.math.BigDecimal; +import java.math.RoundingMode; + import mekanism.api.EnergizedItemManager; import mekanism.api.IEnergizedItem; import mekanism.api.Object3D; @@ -17,11 +18,16 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; +import thermalexpansion.api.item.IChargeableItem; +import universalelectricity.core.item.ElectricItemHelper; +import universalelectricity.core.item.IItemElectric; import codechicken.core.alg.MathHelper; public class EntityRobit extends EntityCreature implements IInventory, ISustainedInventory @@ -30,14 +36,18 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public Object3D homeLocation; - public ItemStack[] inventory = new ItemStack[28]; + public ItemStack[] inventory = new ItemStack[31]; + + public int furnaceBurnTime = 0; + public int currentItemBurnTime = 0; + public int furnaceCookTime = 0; public EntityRobit(World world) { super(world); setSize(1, 1); - moveSpeed = 0.2F; + moveSpeed = 0.35F; texture = "/mods/mekanism/render/Robit.png"; getNavigator().setAvoidsWater(true); @@ -84,9 +94,22 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine dataWatcher.addObject(13, new Byte((byte)0)); /* Follow */ } + public double getRoundedTravelEnergy() + { + return new BigDecimal(getDistance(prevPosX, prevPosY, prevPosZ)*1.5).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + } + @Override public void onEntityUpdate() { + if(!worldObj.isRemote) + { + if(getFollowing() && getOwner() != null && getDistanceSqToEntity(getOwner()) > 4 && !getNavigator().noPath() && getEnergy() > 0) + { + setEnergy(getEnergy() - getRoundedTravelEnergy()); + } + } + super.onEntityUpdate(); if(!worldObj.isRemote) @@ -108,6 +131,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if(getEnergy() == 0 && !isOnChargepad()) { + setFollowing(false); setPositionAndUpdate(homeLocation.xCoord+0.5, homeLocation.yCoord+0.3, homeLocation.zCoord+0.5); motionX = 0; @@ -157,8 +181,88 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine } } } + + if(furnaceBurnTime > 0) + { + furnaceBurnTime--; + } + + if(!worldObj.isRemote) + { + if(furnaceBurnTime == 0 && canSmelt()) + { + currentItemBurnTime = furnaceBurnTime = TileEntityFurnace.getItemBurnTime(inventory[29]); + + if(furnaceBurnTime > 0) + { + if(inventory[29] != null) + { + inventory[29].stackSize--; + + if(inventory[29].stackSize == 0) + { + inventory[29] = inventory[29].getItem().getContainerItemStack(inventory[29]); + } + } + } + } + + if(furnaceBurnTime > 0 && canSmelt()) + { + furnaceCookTime++; + + if(furnaceCookTime == 200) + { + furnaceCookTime = 0; + smeltItem(); + } + } + else { + furnaceCookTime = 0; + } + } } } + + private boolean canSmelt() + { + if(inventory[28] == null) + { + return false; + } + else { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); + if(itemstack == null) return false; + if(inventory[30] == null) return true; + if(!inventory[30].isItemEqual(itemstack)) return false; + int result = inventory[30].stackSize + itemstack.stackSize; + return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); + } + } + + public void smeltItem() + { + if(canSmelt()) + { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); + + if(inventory[30] == null) + { + inventory[30] = itemstack.copy(); + } + else if(inventory[30].isItemEqual(itemstack)) + { + inventory[30].stackSize += itemstack.stackSize; + } + + inventory[28].stackSize--; + + if(inventory[28].stackSize <= 0) + { + inventory[28] = null; + } + } + } public boolean isOnChargepad() { @@ -498,4 +602,10 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine return tagList; } + + @Override + public float getShadowSize() + { + return 0.25F; + } } diff --git a/src/minecraft/mekanism/common/Mekanism.java b/src/minecraft/mekanism/common/Mekanism.java index b34c751a9..8194fd793 100644 --- a/src/minecraft/mekanism/common/Mekanism.java +++ b/src/minecraft/mekanism/common/Mekanism.java @@ -338,6 +338,9 @@ public class Mekanism CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 14), new Object[] { "PPP", "SES", Character.valueOf('P'), Block.pressurePlateStone, Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), EnergyTablet.getUnchargedItem() })); + CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(Robit.getUnchargedItem(), new Object[] { + " S ", "ECE", "OIO", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), EnergyTablet.getUnchargedItem(), Character.valueOf('C'), AtomicCore, Character.valueOf('O'), "ingotRefinedObsidian", Character.valueOf('I'), new ItemStack(MachineBlock, 1, 13) + })); //Factory Recipes CraftingManager.getInstance().getRecipeList().add(new FactoryRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, RecipeType.SMELTING), new Object[] { @@ -378,8 +381,6 @@ public class Mekanism //Enrichment Chamber Recipes RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreRedstone), new ItemStack(Item.redstone, 12)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.obsidian), new ItemStack(DirtyDust, 1, 6)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreIron), new ItemStack(Dust, 2, 0)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Dust, 2, 1)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Item.coal, 1, 0), new ItemStack(CompressedCarbon)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Item.coal, 1, 1), new ItemStack(CompressedCarbon)); RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreLapis), new ItemStack(Item.dyePowder, 12, 4)); @@ -409,10 +410,6 @@ public class Mekanism RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 0), new ItemStack(Block.stoneBrick, 1, 2)); RecipeHandler.addCrusherRecipe(new ItemStack(Block.stoneBrick, 1, 3), new ItemStack(Block.stoneBrick, 1, 0)); - //Purification Chamber Recipes - RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.oreIron), new ItemStack(Clump, 3, 0)); - RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Clump, 3, 1)); - //Metallurgic Infuser Recipes RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfusionType.COAL, 10, new ItemStack(EnrichedIron)), new ItemStack(Dust, 1, 5)); RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfusionType.BIO, 10, new ItemStack(Block.cobblestone)), new ItemStack(Block.cobblestoneMossy)); @@ -799,6 +796,18 @@ public class Mekanism RecipeHandler.addPurificationChamberRecipe(ore, new ItemStack(Clump, 3, 2)); } + for(ItemStack ore : OreDictionary.getOres("oreIron")) + { + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreIron), new ItemStack(Dust, 2, 0)); + RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.oreIron), new ItemStack(Clump, 3, 0)); + } + + for(ItemStack ore : OreDictionary.getOres("oreGold")) + { + RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Dust, 2, 1)); + RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Clump, 3, 1)); + } + try { for(ItemStack ore : OreDictionary.getOres("oreLead")) { diff --git a/src/minecraft/mekanism/common/PacketHandler.java b/src/minecraft/mekanism/common/PacketHandler.java index 48316a35b..a04f3db63 100644 --- a/src/minecraft/mekanism/common/PacketHandler.java +++ b/src/minecraft/mekanism/common/PacketHandler.java @@ -486,6 +486,10 @@ public class PacketHandler implements IPacketHandler { entityplayer.openGui(Mekanism.instance, 23, entityplayer.worldObj, id, 0, 0); } + else if(type == 3) + { + entityplayer.openGui(Mekanism.instance, 24, entityplayer.worldObj, id, 0, 0); + } } catch(Exception e) { System.err.println("[Mekanism] Error while handling robit GUI packet."); e.printStackTrace(); diff --git a/src/minecraft/mekanism/common/RobitAIFollow.java b/src/minecraft/mekanism/common/RobitAIFollow.java index 18e833c24..cbc6ad972 100644 --- a/src/minecraft/mekanism/common/RobitAIFollow.java +++ b/src/minecraft/mekanism/common/RobitAIFollow.java @@ -63,6 +63,10 @@ public class RobitAIFollow extends EntityAIBase { return false; } + else if(theRobit.getEnergy() == 0) + { + return false; + } else { theOwner = player; return true; @@ -72,7 +76,7 @@ public class RobitAIFollow extends EntityAIBase @Override public boolean continueExecuting() { - return !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) && theRobit.getFollowing(); + return !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) && theRobit.getFollowing() && theRobit.getEnergy() > 0; } @Override diff --git a/src/minecraft/mekanism/common/TileEntityChargepad.java b/src/minecraft/mekanism/common/TileEntityChargepad.java index c01b52fd8..df0d482cc 100644 --- a/src/minecraft/mekanism/common/TileEntityChargepad.java +++ b/src/minecraft/mekanism/common/TileEntityChargepad.java @@ -80,36 +80,21 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct for(ItemStack itemstack : player.inventory.mainInventory) { - if(itemstack != null) + chargeItemStack(itemstack); + + if(prevEnergy != getEnergy()) { - if(itemstack.getItem() instanceof IEnergizedItem) - { - setEnergy(getEnergy() - EnergizedItemManager.charge(itemstack, getEnergy())); - } - else if(itemstack.getItem() instanceof IItemElectric) - { - setEnergy(getEnergy() - ElectricItemHelper.chargeItem(itemstack, getEnergy(), getVoltage())); - } - else if(Mekanism.hooks.IC2Loaded && itemstack.getItem() instanceof IElectricItem) - { - double sent = ElectricItem.charge(itemstack, (int)(getEnergy()*Mekanism.TO_IC2), 3, false, false)*Mekanism.FROM_IC2; - setEnergy(getEnergy() - sent); - } - else if(itemstack.getItem() instanceof IChargeableItem) - { - IChargeableItem item = (IChargeableItem)itemstack.getItem(); - - float itemEnergy = (float)Math.min(Math.sqrt(item.getMaxEnergyStored(itemstack)), item.getMaxEnergyStored(itemstack) - item.getEnergyStored(itemstack)); - float toTransfer = (float)Math.min(itemEnergy, (getEnergy()*Mekanism.TO_BC)); - - item.receiveEnergy(itemstack, toTransfer, true); - setEnergy(getEnergy() - (toTransfer*Mekanism.FROM_BC)); - } - - if(prevEnergy != getEnergy()) - { - break; - } + break; + } + } + + for(ItemStack itemstack : player.inventory.armorInventory) + { + chargeItemStack(itemstack); + + if(prevEnergy != getEnergy()) + { + break; } } } @@ -132,6 +117,36 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct } } + public void chargeItemStack(ItemStack itemstack) + { + if(itemstack != null) + { + if(itemstack.getItem() instanceof IEnergizedItem) + { + setEnergy(getEnergy() - EnergizedItemManager.charge(itemstack, getEnergy())); + } + else if(itemstack.getItem() instanceof IItemElectric) + { + setEnergy(getEnergy() - ElectricItemHelper.chargeItem(itemstack, getEnergy(), getVoltage())); + } + else if(Mekanism.hooks.IC2Loaded && itemstack.getItem() instanceof IElectricItem) + { + double sent = ElectricItem.charge(itemstack, (int)(getEnergy()*Mekanism.TO_IC2), 3, false, false)*Mekanism.FROM_IC2; + setEnergy(getEnergy() - sent); + } + else if(itemstack.getItem() instanceof IChargeableItem) + { + IChargeableItem item = (IChargeableItem)itemstack.getItem(); + + float itemEnergy = (float)Math.min(Math.sqrt(item.getMaxEnergyStored(itemstack)), item.getMaxEnergyStored(itemstack) - item.getEnergyStored(itemstack)); + float toTransfer = (float)Math.min(itemEnergy, (getEnergy()*Mekanism.TO_BC)); + + item.receiveEnergy(itemstack, toTransfer, true); + setEnergy(getEnergy() - (toTransfer*Mekanism.FROM_BC)); + } + } + } + @Override public void invalidate() { diff --git a/src/minecraft/mekanism/generators/client/GuiWindTurbine.java b/src/minecraft/mekanism/generators/client/GuiWindTurbine.java index 757576aa1..5cc60570f 100644 --- a/src/minecraft/mekanism/generators/client/GuiWindTurbine.java +++ b/src/minecraft/mekanism/generators/client/GuiWindTurbine.java @@ -37,7 +37,7 @@ public class GuiWindTurbine extends GuiContainer fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00); - fontRenderer.drawString("Power: " + tileEntity.GENERATION_RATE*tileEntity.getVolumeMultiplier(), 51, 35, 0x00CD00); + fontRenderer.drawString("Power: " + tileEntity.GENERATION_RATE*tileEntity.getMultiplier(), 51, 35, 0x00CD00); fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00); int size = 44; diff --git a/src/minecraft/mekanism/generators/common/ItemBlockGenerator.java b/src/minecraft/mekanism/generators/common/ItemBlockGenerator.java index f1e1d00e7..ba40e8105 100644 --- a/src/minecraft/mekanism/generators/common/ItemBlockGenerator.java +++ b/src/minecraft/mekanism/generators/common/ItemBlockGenerator.java @@ -214,7 +214,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt { for(int zPos=-1;zPos<=1;zPos++) { - if(world.getBlockId(x+xPos, y+2, z+zPos) != 0) + if(world.getBlockId(x+xPos, y+2, z+zPos) != 0 || y+2 > 255) place = false; } } @@ -232,7 +232,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, IIt for(int yPos = y+1; yPos <= y+4; yPos++) { - if(world.getBlockId(x, yPos, z) != 0) + if(world.getBlockId(x, yPos, z) != 0 || yPos > 255) place = false; } } diff --git a/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java index 1607be173..7ef89db88 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java @@ -38,7 +38,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank public float crushMatrix = 0; /** The amount of electricity this machine can produce with a unit of fuel. */ - public final int GENERATION = 50; + public final int GENERATION = 120; /** The LiquidSlot biofuel instance for this generator. */ public LiquidSlot bioFuelSlot = new LiquidSlot(24000, Mekanism.hooks.ForestryBiofuelID); @@ -48,7 +48,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank public TileEntityBioGenerator() { - super("Bio-Generator", 160000, 100); + super("Bio-Generator", 160000, 240); inventory = new ItemStack[2]; if(Mekanism.hooks.ForestryLoaded) diff --git a/src/minecraft/mekanism/generators/common/TileEntityGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityGenerator.java index cc698498d..db6cd5135 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityGenerator.java @@ -97,9 +97,9 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem { if(electricityStored >= output) { - EnergyTileSourceEvent event = new EnergyTileSourceEvent(this, output); + EnergyTileSourceEvent event = new EnergyTileSourceEvent(this, (int)(output*Mekanism.TO_IC2)); MinecraftForge.EVENT_BUS.post(event); - setEnergy(electricityStored - (output - event.amount)); + setEnergy(electricityStored - (output - (event.amount*Mekanism.FROM_IC2))); } } else if(isPowerReceptor(tileEntity) && Mekanism.hooks.BuildCraftLoaded) diff --git a/src/minecraft/mekanism/generators/common/TileEntityHeatGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityHeatGenerator.java index a6113a3b2..4c39d6719 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityHeatGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityHeatGenerator.java @@ -29,11 +29,11 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan public LiquidTank lavaTank = new LiquidTank(24000); /** The amount of electricity this machine can produce with a unit of fuel. */ - public final int GENERATION = 80; + public final int GENERATION = 100; public TileEntityHeatGenerator() { - super("Heat Generator", 160000, 160); + super("Heat Generator", 160000, 200); inventory = new ItemStack[2]; }