diff --git a/README.md b/README.md index 22a2a4cae..b72ced214 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Mekanism for Minecraft 1.4.6 # +# Mekanism for Minecraft 1.4.7 # Source code. More information can be found on the mod's forum post. diff --git a/bin/minecraft/resources/mekanism/animate/InfuserFront.png b/bin/minecraft/resources/mekanism/animate/InfuserFront.png index b6ff8fb7b..890aa060d 100644 Binary files a/bin/minecraft/resources/mekanism/animate/InfuserFront.png and b/bin/minecraft/resources/mekanism/animate/InfuserFront.png differ diff --git a/bin/minecraft/resources/mekanism/gui/GuiPortableTeleporter.png b/bin/minecraft/resources/mekanism/gui/GuiPortableTeleporter.png new file mode 100755 index 000000000..7ca045fd2 Binary files /dev/null and b/bin/minecraft/resources/mekanism/gui/GuiPortableTeleporter.png differ diff --git a/bin/minecraft/resources/mekanism/gui/GuiTeleporter.png b/bin/minecraft/resources/mekanism/gui/GuiTeleporter.png new file mode 100755 index 000000000..7535b5e73 Binary files /dev/null and b/bin/minecraft/resources/mekanism/gui/GuiTeleporter.png differ diff --git a/bin/minecraft/resources/mekanism/textures/items.png b/bin/minecraft/resources/mekanism/textures/items.png index f61e17fa2..7f53eb50e 100644 Binary files a/bin/minecraft/resources/mekanism/textures/items.png and b/bin/minecraft/resources/mekanism/textures/items.png differ diff --git a/bin/minecraft/resources/mekanism/textures/terrain.png b/bin/minecraft/resources/mekanism/textures/terrain.png index bb38862cd..ed4f1da0d 100755 Binary files a/bin/minecraft/resources/mekanism/textures/terrain.png and b/bin/minecraft/resources/mekanism/textures/terrain.png differ diff --git a/src/minecraft/mekanism/api/Tier.java b/src/minecraft/mekanism/api/Tier.java index ba1a0bb1e..f92c37328 100644 --- a/src/minecraft/mekanism/api/Tier.java +++ b/src/minecraft/mekanism/api/Tier.java @@ -16,7 +16,7 @@ public final class Tier { BASIC("Basic", 1000000, 10000), ADVANCED("Advanced", 2500000, 25000), - ULTIMATE("Ultimate", 5000000, 50000); + ELITE("Elite", 5000000, 50000); public double MAX_ELECTRICITY; public double VOLTAGE; @@ -54,7 +54,7 @@ public final class Tier { BASIC("Basic", 3, "GuiBasicSmeltingFactory.png"), ADVANCED("Advanced", 5, "GuiAdvancedSmeltingFactory.png"), - ULTIMATE("Ultimate", 7, "GuiUltimateSmeltingFactory.png"); + ELITE("Elite", 7, "GuiUltimateSmeltingFactory.png"); public int processes; public String guiTexturePath; diff --git a/src/minecraft/mekanism/client/BlockRenderingHandler.java b/src/minecraft/mekanism/client/BlockRenderingHandler.java index b777da526..5a149048e 100644 --- a/src/minecraft/mekanism/client/BlockRenderingHandler.java +++ b/src/minecraft/mekanism/client/BlockRenderingHandler.java @@ -52,7 +52,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler if(!MachineType.getFromMetadata(metadata).hasModel) { renderer.renderStandardBlock(block, x, y, z); - renderer.updateCustomBlockBounds(block); + renderer.setRenderBoundsFromBlock(block); return true; } } @@ -83,7 +83,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler { block.setBlockBoundsForItemRender(); - renderer.updateCustomBlockBounds(block); + renderer.setRenderBoundsFromBlock(block); if (renderer.useInventoryTint) { diff --git a/src/minecraft/mekanism/client/ClientProxy.java b/src/minecraft/mekanism/client/ClientProxy.java index b6e8eeb93..3882e9e72 100644 --- a/src/minecraft/mekanism/client/ClientProxy.java +++ b/src/minecraft/mekanism/client/ClientProxy.java @@ -4,6 +4,7 @@ import java.io.IOException; import mekanism.common.CommonProxy; import mekanism.common.EntityObsidianTNT; +import mekanism.common.ItemPortableTeleporter; import mekanism.common.Mekanism; import mekanism.common.TileEntityAdvancedElectricMachine; import mekanism.common.TileEntityControlPanel; @@ -12,6 +13,7 @@ import mekanism.common.TileEntityEnergyCube; import mekanism.common.TileEntityGasTank; import mekanism.common.TileEntityMetallurgicInfuser; import mekanism.common.TileEntitySmeltingFactory; +import mekanism.common.TileEntityTeleporter; import mekanism.common.TileEntityTheoreticalElementizer; import mekanism.generators.client.ModelAdvancedSolarGenerator; import mekanism.generators.client.RenderAdvancedSolarGenerator; @@ -26,6 +28,7 @@ import mekanism.generators.common.TileEntityHeatGenerator; import mekanism.generators.common.TileEntityHydrogenGenerator; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; @@ -151,6 +154,14 @@ public class ClientProxy extends CommonProxy return new GuiSmeltingFactory(player.inventory, (TileEntitySmeltingFactory)tileEntity); case 12: return new GuiMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser)tileEntity); + case 13: + return new GuiTeleporter(player.inventory, (TileEntityTeleporter)tileEntity); + case 14: + ItemStack itemStack = player.getCurrentEquippedItem(); + if(itemStack != null && itemStack.getItem() instanceof ItemPortableTeleporter) + { + return new GuiPortableTeleporter(player, itemStack); + } } return null; } @@ -158,6 +169,8 @@ public class ClientProxy extends CommonProxy @Override public void loadTickHandler() { + super.loadTickHandler(); + TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT); } diff --git a/src/minecraft/mekanism/client/ClientTickHandler.java b/src/minecraft/mekanism/client/ClientTickHandler.java index bd44f748b..ecdd16da0 100644 --- a/src/minecraft/mekanism/client/ClientTickHandler.java +++ b/src/minecraft/mekanism/client/ClientTickHandler.java @@ -47,6 +47,6 @@ public class ClientTickHandler implements ITickHandler @Override public String getLabel() { - return "Mekanism"; + return "MekanismClient"; } } diff --git a/src/minecraft/mekanism/client/GuiCredits.java b/src/minecraft/mekanism/client/GuiCredits.java index fa93856cf..106b6bf56 100644 --- a/src/minecraft/mekanism/client/GuiCredits.java +++ b/src/minecraft/mekanism/client/GuiCredits.java @@ -14,7 +14,7 @@ public class GuiCredits extends GuiScreen { public void initGui() { controlList.clear(); - controlList.add(new GuiButton(2, width / 2 - 100, height / 4 + 72 + 12, "Update")); + controlList.add(new GuiButton(0, width / 2 - 100, height / 4 + 72 + 12, "Update")); controlList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96 + 12, "Cancel")); } @@ -41,7 +41,7 @@ public class GuiCredits extends GuiScreen { { return; } - if(guibutton.id == 2) + if(guibutton.id == 0) { if(!MekanismUtils.isLatestVersion()) { diff --git a/src/minecraft/mekanism/client/GuiPortableTeleporter.java b/src/minecraft/mekanism/client/GuiPortableTeleporter.java new file mode 100644 index 000000000..9b676548d --- /dev/null +++ b/src/minecraft/mekanism/client/GuiPortableTeleporter.java @@ -0,0 +1,134 @@ +package mekanism.client; + +import mekanism.common.ContainerTeleporter; +import mekanism.common.EnumPacketType; +import mekanism.common.ItemPortableTeleporter; +import mekanism.common.PacketHandler; +import mekanism.common.TileEntityTeleporter; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +import org.lwjgl.opengl.GL11; + +public class GuiPortableTeleporter extends GuiScreen +{ + public EntityPlayer entityPlayer; + public ItemStack itemStack; + + public int xSize = 176; + public int ySize = 166; + + public GuiPortableTeleporter(EntityPlayer player, ItemStack itemstack) + { + entityPlayer = player; + itemStack = itemstack; + } + + @Override + public void initGui() + { + controlList.clear(); + controlList.add(new GuiButton(0, 173, 105, 80, 20, "Teleport")); + } + + @Override + public void drawScreen(int i, int j, float f) + { + if(mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter) + { + itemStack = mc.thePlayer.getCurrentEquippedItem(); + } + + int texture = mc.renderEngine.getTexture("/resources/mekanism/gui/GuiPortableTeleporter.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(texture); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int displayInt; + + displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0)); + drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1)); + drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2)); + drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3)); + drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13); + + ItemPortableTeleporter item = (ItemPortableTeleporter)itemStack.getItem(); + + fontRenderer.drawString("Portable Teleporter", 160, 43, 0x404040); + fontRenderer.drawString(item.getStatusAsString(item.getStatus(itemStack)), 178, 56, 0x00CD00); + super.drawScreen(i, j, f); + } + + @Override + protected void actionPerformed(GuiButton guibutton) + { + if(guibutton.id == 0) + { + PacketHandler.sendPacketDataInt(EnumPacketType.PORTABLE_TELEPORT, 0); + } + } + + @Override + protected void mouseClicked(int x, int y, int button) + { + super.mouseClicked(x, y, button); + + int xAxis = (x - (width - xSize) / 2); + int yAxis = (y - (height - ySize) / 2); + + if(xAxis > 23 && xAxis < 37 && yAxis > 44 && yAxis < 58) + { + PacketHandler.sendDigitUpdate(0, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0))); + ((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 0, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 0))); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + else if(xAxis > 62 && xAxis < 76 && yAxis > 44 && yAxis < 58) + { + PacketHandler.sendDigitUpdate(1, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1))); + ((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 1, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 1))); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + else if(xAxis > 101 && xAxis < 115 && yAxis > 44 && yAxis < 58) + { + PacketHandler.sendDigitUpdate(2, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2))); + ((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 2, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 2))); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + else if(xAxis > 140 && xAxis < 154 && yAxis > 44 && yAxis < 58) + { + PacketHandler.sendDigitUpdate(3, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3))); + ((ItemPortableTeleporter)itemStack.getItem()).setDigit(itemStack, 3, getIncrementedNumber(((ItemPortableTeleporter)itemStack.getItem()).getDigit(itemStack, 3))); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + } + + public int getIncrementedNumber(int i) + { + if(i < 9) i++; + else if(i == 9) i=0; + + return i; + } + + public int getYAxisForNumber(int i) + { + return i*13; + } + + @Override + public boolean doesGuiPauseGame() + { + return false; + } +} diff --git a/src/minecraft/mekanism/client/GuiSmeltingFactory.java b/src/minecraft/mekanism/client/GuiSmeltingFactory.java index 2601b9841..6a712e035 100644 --- a/src/minecraft/mekanism/client/GuiSmeltingFactory.java +++ b/src/minecraft/mekanism/client/GuiSmeltingFactory.java @@ -62,7 +62,7 @@ public class GuiSmeltingFactory extends GuiContainer } } - if(tileEntity.tier == SmeltingFactoryTier.ULTIMATE) + if(tileEntity.tier == SmeltingFactoryTier.ELITE) { for(int i = 0; i < tileEntity.tier.processes; i++) { diff --git a/src/minecraft/mekanism/client/GuiTeleporter.java b/src/minecraft/mekanism/client/GuiTeleporter.java new file mode 100644 index 000000000..deec7c777 --- /dev/null +++ b/src/minecraft/mekanism/client/GuiTeleporter.java @@ -0,0 +1,102 @@ +package mekanism.client; + +import mekanism.common.ContainerTeleporter; +import mekanism.common.PacketHandler; +import mekanism.common.TileEntityTeleporter; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; + +import org.lwjgl.opengl.GL11; + +public class GuiTeleporter extends GuiContainer +{ + public TileEntityTeleporter tileEntity; + + public GuiTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) + { + super(new ContainerTeleporter(inventory, tentity)); + tileEntity = tentity; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040); + fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + fontRenderer.drawString(tileEntity.status, 66, 19, 0x00CD00); + } + + @Override + protected void mouseClicked(int x, int y, int button) + { + super.mouseClicked(x, y, button); + + int xAxis = (x - (width - xSize) / 2); + int yAxis = (y - (height - ySize) / 2); + + if(xAxis > 23 && xAxis < 37 && yAxis > 44 && yAxis < 58) + { + PacketHandler.sendTileEntityPacketToServer(tileEntity, 0, getIncrementedNumber(tileEntity.code.digitOne)); + tileEntity.code.digitOne = getIncrementedNumber(tileEntity.code.digitOne); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + else if(xAxis > 62 && xAxis < 76 && yAxis > 44 && yAxis < 58) + { + PacketHandler.sendTileEntityPacketToServer(tileEntity, 1, getIncrementedNumber(tileEntity.code.digitTwo)); + tileEntity.code.digitTwo = getIncrementedNumber(tileEntity.code.digitTwo); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + else if(xAxis > 101 && xAxis < 115 && yAxis > 44 && yAxis < 58) + { + PacketHandler.sendTileEntityPacketToServer(tileEntity, 2, getIncrementedNumber(tileEntity.code.digitThree)); + tileEntity.code.digitThree = getIncrementedNumber(tileEntity.code.digitThree); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + else if(xAxis > 140 && xAxis < 154 && yAxis > 44 && yAxis < 58) + { + PacketHandler.sendTileEntityPacketToServer(tileEntity, 3, getIncrementedNumber(tileEntity.code.digitFour)); + tileEntity.code.digitFour = getIncrementedNumber(tileEntity.code.digitFour); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + int texture = mc.renderEngine.getTexture("/resources/mekanism/gui/GuiTeleporter.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(texture); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176 + 13, 52 - displayInt, 4, displayInt); + + displayInt = getYAxisForNumber(tileEntity.code.digitOne); + drawTexturedModalRect(guiWidth + 23, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(tileEntity.code.digitTwo); + drawTexturedModalRect(guiWidth + 62, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(tileEntity.code.digitThree); + drawTexturedModalRect(guiWidth + 101, guiHeight + 44, 176, displayInt, 13, 13); + + displayInt = getYAxisForNumber(tileEntity.code.digitFour); + drawTexturedModalRect(guiWidth + 140, guiHeight + 44, 176, displayInt, 13, 13); + } + + public int getIncrementedNumber(int i) + { + if(i < 9) i++; + else if(i == 9) i=0; + + return i; + } + + public int getYAxisForNumber(int i) + { + return i*13; + } +} diff --git a/src/minecraft/mekanism/client/ItemRenderingHandler.java b/src/minecraft/mekanism/client/ItemRenderingHandler.java index 761116c53..d3bee6947 100644 --- a/src/minecraft/mekanism/client/ItemRenderingHandler.java +++ b/src/minecraft/mekanism/client/ItemRenderingHandler.java @@ -40,7 +40,7 @@ public class ItemRenderingHandler implements IItemRenderer GL11.glTranslatef(0.5F, 0.5F, 0.5F); } - renderItem((RenderBlocks)data[0], tier == EnergyCubeTier.BASIC ? 0 : (tier == EnergyCubeTier.ADVANCED ? 1 : (tier == EnergyCubeTier.ULTIMATE ? 2 : 0))); + renderItem((RenderBlocks)data[0], tier == EnergyCubeTier.BASIC ? 0 : (tier == EnergyCubeTier.ADVANCED ? 1 : (tier == EnergyCubeTier.ELITE ? 2 : 0))); } } @@ -54,7 +54,7 @@ public class ItemRenderingHandler implements IItemRenderer public void renderItem(RenderBlocks renderer, int metadata) { Block block = Block.blocksList[Mekanism.energyCubeID]; - renderer.updateCustomBlockBounds(block); + renderer.setRenderBoundsFromBlock(block); block.setBlockBoundsForItemRender(); if (renderer.useInventoryTint) diff --git a/src/minecraft/mekanism/client/Sound.java b/src/minecraft/mekanism/client/Sound.java index 18a2550fb..a46201cee 100644 --- a/src/minecraft/mekanism/client/Sound.java +++ b/src/minecraft/mekanism/client/Sound.java @@ -62,8 +62,12 @@ public class Sound } Mekanism.audioHandler.sounds.add(this); - Mekanism.audioHandler.soundSystem.newSource(false, id, url, sound, true, x, y, z, 0, 16F); - Mekanism.audioHandler.soundSystem.activate(id); + + if(Mekanism.audioHandler.soundSystem != null) + { + Mekanism.audioHandler.soundSystem.newSource(false, id, url, sound, true, x, y, z, 0, 16F); + Mekanism.audioHandler.soundSystem.activate(id); + } } } @@ -79,7 +83,10 @@ public class Sound return; } - Mekanism.audioHandler.soundSystem.play(identifier); + if(Mekanism.audioHandler.soundSystem != null) + { + Mekanism.audioHandler.soundSystem.play(identifier); + } isPlaying = true; } } @@ -96,7 +103,10 @@ public class Sound return; } - Mekanism.audioHandler.soundSystem.stop(identifier); + if(Mekanism.audioHandler.soundSystem != null) + { + Mekanism.audioHandler.soundSystem.stop(identifier); + } isPlaying = false; } } @@ -114,7 +124,11 @@ public class Sound } Mekanism.audioHandler.sounds.remove(this); - Mekanism.audioHandler.soundSystem.removeSource(identifier); + + if(Mekanism.audioHandler.soundSystem != null) + { + Mekanism.audioHandler.soundSystem.removeSource(identifier); + } } } @@ -136,7 +150,10 @@ public class Sound double distanceVolume = entityplayer.getDistanceSq(xCoord, yCoord, zCoord)*0.01; volume = (float)Math.max(Mekanism.audioHandler.masterVolume-distanceVolume, 0); - Mekanism.audioHandler.soundSystem.setVolume(identifier, volume); + if(Mekanism.audioHandler.soundSystem != null) + { + Mekanism.audioHandler.soundSystem.setVolume(identifier, volume); + } } } } diff --git a/src/minecraft/mekanism/common/BlockBasic.java b/src/minecraft/mekanism/common/BlockBasic.java index e8f217970..a7885babe 100644 --- a/src/minecraft/mekanism/common/BlockBasic.java +++ b/src/minecraft/mekanism/common/BlockBasic.java @@ -29,6 +29,7 @@ import net.minecraftforge.common.ForgeChunkManager; * 4: Refined Glowstone * 5: Steel Block * 6: Control Panel + * 7: Teleporter * @author AidanBrady * */ @@ -62,6 +63,8 @@ public class BlockBasic extends Block return 29; case 6: return 0; + case 7: + return 25; } return 0; } @@ -83,6 +86,7 @@ public class BlockBasic extends Block list.add(new ItemStack(i, 1, 4)); list.add(new ItemStack(i, 1, 5)); //list.add(new ItemStack(i, 1, 6)); + list.add(new ItemStack(i, 1, 7)); } @Override @@ -102,10 +106,27 @@ public class BlockBasic extends Block { if(!entityplayer.isSneaking()) { - entityplayer.openGui(Mekanism.instance, 14, world, x, y, z); + entityplayer.openGui(Mekanism.instance, 9, world, x, y, z); return true; } } + else if(metadata == 7) + { + if(entityplayer.isSneaking()) + { + entityplayer.openGui(Mekanism.instance, 13, world, x, y, z); + return true; + } + if(!world.isRemote) + { + TileEntityTeleporter tileEntity = (TileEntityTeleporter)world.getBlockTileEntity(x, y, z); + + if(tileEntity.canTeleport() == 1) + { + tileEntity.teleport(); + } + } + } return false; } @@ -126,7 +147,7 @@ public class BlockBasic extends Block @Override public boolean hasTileEntity(int metadata) { - return metadata == 6; + return metadata == 6 || metadata == 7; } @Override @@ -136,6 +157,8 @@ public class BlockBasic extends Block { case 6: return new TileEntityControlPanel(); + case 7: + return new TileEntityTeleporter(); } return null; } diff --git a/src/minecraft/mekanism/common/BlockEnergyCube.java b/src/minecraft/mekanism/common/BlockEnergyCube.java index 370bfdb6c..fe65fa200 100644 --- a/src/minecraft/mekanism/common/BlockEnergyCube.java +++ b/src/minecraft/mekanism/common/BlockEnergyCube.java @@ -8,6 +8,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import universalelectricity.core.implement.IItemElectric; +import universalelectricity.prefab.implement.IToolConfigurator; import mekanism.api.IEnergyCube; import mekanism.api.Tier.EnergyCubeTier; @@ -30,9 +31,9 @@ import net.minecraftforge.common.ForgeDirection; /** * Block class for handling multiple energy cube block IDs. - * 0: Power Unit - * 1: Advanced Power Unit - * 2: Ultimate Power Unit + * 0: Basic Energy Cube + * 1: Advanced Energy Cube + * 2: Elite Energy Cube * @author AidanBrady * */ @@ -147,7 +148,7 @@ public class BlockEnergyCube extends BlockContainer return 22; } } - else if(tileEntity.tier == EnergyCubeTier.ULTIMATE) + else if(tileEntity.tier == EnergyCubeTier.ELITE) { if(side == tileEntity.facing) { @@ -191,7 +192,7 @@ public class BlockEnergyCube extends BlockContainer if (slotStack.hasTagCompound()) { - entityItem.func_92014_d().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); + entityItem.getEntityItem().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); } float motion = 0.05F; @@ -210,11 +211,11 @@ public class BlockEnergyCube extends BlockContainer entityItem.motionY = powerRand.nextGaussian() * motion + 0.2F; entityItem.motionZ = powerRand.nextGaussian() * motion; - IEnergyCube energyCube = (IEnergyCube)entityItem.func_92014_d().getItem(); - energyCube.setTier(entityItem.func_92014_d(), tileEntity.tier); + IEnergyCube energyCube = (IEnergyCube)entityItem.getEntityItem().getItem(); + energyCube.setTier(entityItem.getEntityItem(), tileEntity.tier); - IItemElectric electricItem = (IItemElectric)entityItem.func_92014_d().getItem(); - electricItem.setJoules(tileEntity.electricityStored, entityItem.func_92014_d()); + IItemElectric electricItem = (IItemElectric)entityItem.getEntityItem().getItem(); + electricItem.setJoules(tileEntity.electricityStored, entityItem.getEntityItem()); world.spawnEntityInWorld(entityItem); } @@ -278,6 +279,39 @@ public class BlockEnergyCube extends BlockContainer TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getBlockTileEntity(x, y, z); int metadata = world.getBlockMetadata(x, y, z); + if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() instanceof IToolConfigurator) + { + world.notifyBlocksOfNeighborChange(x, y, z, blockID); + ((IToolConfigurator)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, x, y, z); + + int change = 0; + + switch(tileEntity.facing) + { + case 3: + change = 4; + break; + case 4: + change = 5; + break; + case 5: + change = 2; + break; + case 2: + change = 1; + break; + case 1: + change = 0; + break; + case 0: + change = 3; + break; + } + + tileEntity.setFacing((short)change); + return true; + } + if (tileEntity != null) { if(!entityplayer.isSneaking()) diff --git a/src/minecraft/mekanism/common/BlockGasTank.java b/src/minecraft/mekanism/common/BlockGasTank.java index 760f7ae0c..2c91e1d97 100644 --- a/src/minecraft/mekanism/common/BlockGasTank.java +++ b/src/minecraft/mekanism/common/BlockGasTank.java @@ -24,6 +24,8 @@ public class BlockGasTank extends BlockContainer { super(id, Material.iron); setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 1.0F, 0.8F); + setHardness(3.5F); + setResistance(8F); setCreativeTab(Mekanism.tabMekanism); } @@ -112,7 +114,7 @@ public class BlockGasTank extends BlockContainer if (slotStack.hasTagCompound()) { - item.func_92014_d().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); + item.getEntityItem().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); } float k = 0.05F; diff --git a/src/minecraft/mekanism/common/BlockMachine.java b/src/minecraft/mekanism/common/BlockMachine.java index 84a0e8313..4ee829bb2 100644 --- a/src/minecraft/mekanism/common/BlockMachine.java +++ b/src/minecraft/mekanism/common/BlockMachine.java @@ -3,6 +3,8 @@ package mekanism.common; import java.util.List; import java.util.Random; +import universalelectricity.prefab.implement.IToolConfigurator; + import mekanism.api.IActiveState; import mekanism.client.ClientProxy; import net.minecraft.block.BlockContainer; @@ -30,7 +32,7 @@ import cpw.mods.fml.relauncher.SideOnly; * 4: Theoretical Elementizer * 5: Basic Smelting Factory * 6: Advanced Smelting Factory - * 7: Ultimate Smelting Factory + * 7: Elite Smelting Factory * 8: Metallurgic Infuser * @author AidanBrady * @@ -389,7 +391,7 @@ public class BlockMachine extends BlockContainer if (slotStack.hasTagCompound()) { - item.func_92014_d().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); + item.getEntityItem().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); } float k = 0.05F; @@ -416,6 +418,33 @@ public class BlockMachine extends BlockContainer TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); int metadata = world.getBlockMetadata(x, y, z); + if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() instanceof IToolConfigurator) + { + world.notifyBlocksOfNeighborChange(x, y, z, blockID); + ((IToolConfigurator)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, x, y, z); + + int change = 0; + + switch(tileEntity.facing) + { + case 3: + change = 4; + break; + case 4: + change = 5; + break; + case 5: + change = 2; + break; + case 2: + change = 3; + break; + } + + tileEntity.setFacing((short)change); + return true; + } + if (tileEntity != null) { if(!entityplayer.isSneaking()) @@ -474,7 +503,7 @@ public class BlockMachine extends BlockContainer THEORETICAL_ELEMENTIZER(4, 7, TileEntityTheoreticalElementizer.class, true), BASIC_SMELTING_FACTORY(5, 11, TileEntitySmeltingFactory.class, false), ADVANCED_SMELTING_FACTORY(6, 11, TileEntityAdvancedSmeltingFactory.class, false), - ULTIMATE_SMELTING_FACTORY(7, 11, TileEntityUltimateSmeltingFactory.class, false), + ELITE_SMELTING_FACTORY(7, 11, TileEntityEliteSmeltingFactory.class, false), METALLURGIC_INFUSER(8, 12, TileEntityMetallurgicInfuser.class, false); public int meta; diff --git a/src/minecraft/mekanism/common/BlockObsidianTNT.java b/src/minecraft/mekanism/common/BlockObsidianTNT.java index 909ef7e7f..4d5883172 100644 --- a/src/minecraft/mekanism/common/BlockObsidianTNT.java +++ b/src/minecraft/mekanism/common/BlockObsidianTNT.java @@ -101,7 +101,7 @@ public class BlockObsidianTNT extends Block @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) { - if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.shiftedIndex) + if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.itemID) { onBlockDestroyedByPlayer(world, x, y, z, 1); world.setBlockWithNotify(x, y, z, 0); diff --git a/src/minecraft/mekanism/common/CommonProxy.java b/src/minecraft/mekanism/common/CommonProxy.java index 65ce30a4b..dc6c00657 100644 --- a/src/minecraft/mekanism/common/CommonProxy.java +++ b/src/minecraft/mekanism/common/CommonProxy.java @@ -1,5 +1,10 @@ package mekanism.common; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.TickRegistry; +import cpw.mods.fml.relauncher.Side; +import mekanism.client.GuiTeleporter; +import mekanism.generators.common.TileEntityAdvancedSolarGenerator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; @@ -17,7 +22,10 @@ public class CommonProxy /** * Register tile entities that have special models. Overwritten in client to register TESRs. */ - public void registerSpecialTileEntities() {} + public void registerSpecialTileEntities() + { + GameRegistry.registerTileEntity(TileEntityTheoreticalElementizer.class, "TheoreticalElementizer"); + } /** * Register and load client-only render information. @@ -57,7 +65,9 @@ public class CommonProxy Mekanism.nullRenderID = Mekanism.configuration.getBlock("NullRender", 3005).getInt(); Mekanism.gasTankID = Mekanism.configuration.getBlock("GasTank", 3006).getInt(); Mekanism.extrasEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ExtrasEnabled", true).getBoolean(true); - Mekanism.oreGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OreGenerationEnabled", true).getBoolean(true); + Mekanism.platinumGenerationEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "PlatinumGenerationEnabled", true).getBoolean(true); + Mekanism.disableBCSteelCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCSteelCrafting", true).getBoolean(true); + Mekanism.disableBCBronzeCrafting = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisableBCBronzeCrafting", true).getBoolean(true); Mekanism.configuration.save(); } @@ -67,9 +77,12 @@ public class CommonProxy public void loadUtilities() {} /** - * Set up and load the client-only tick handler. + * Set up and load the tick handlers. */ - public void loadTickHandler() {} + public void loadTickHandler() + { + TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER); + } /** * Set up and load the sound handler. @@ -130,6 +143,8 @@ public class CommonProxy return new ContainerSmeltingFactory(player.inventory, (TileEntitySmeltingFactory)tileEntity); case 12: return new ContainerMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser)tileEntity); + case 13: + return new ContainerTeleporter(player.inventory, (TileEntityTeleporter)tileEntity); } return null; } diff --git a/src/minecraft/mekanism/common/CommonTickHandler.java b/src/minecraft/mekanism/common/CommonTickHandler.java new file mode 100644 index 000000000..4c4fdd269 --- /dev/null +++ b/src/minecraft/mekanism/common/CommonTickHandler.java @@ -0,0 +1,96 @@ +package mekanism.common; + +import java.util.EnumSet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.ITickHandler; +import cpw.mods.fml.common.TickType; + +public class CommonTickHandler implements ITickHandler +{ + @Override + public void tickStart(EnumSet type, Object... tickData) + { + + } + + @Override + public void tickEnd(EnumSet type, Object... tickData) + { + if(tickData[0] instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer)tickData[0]; + if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemPortableTeleporter) + { + ItemPortableTeleporter item = (ItemPortableTeleporter)player.getCurrentEquippedItem().getItem(); + ItemStack itemstack = player.getCurrentEquippedItem(); + + Teleporter.Code teleCode = new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3)); + + if(Mekanism.teleporters.containsKey(teleCode)) + { + if(Mekanism.teleporters.get(teleCode).size() == 1) + { + int energyNeeded = item.calculateEnergyCost(player, Mekanism.teleporters.get(teleCode).get(0)); + + if(item.getJoules(itemstack) < energyNeeded) + { + if(item.getStatus(itemstack) != 2) + { + item.setStatus(itemstack, 2); + PacketHandler.sendStatusUpdate(player, 2); + } + } + else { + if(item.getStatus(itemstack) != 1) + { + item.setStatus(itemstack, 1); + PacketHandler.sendStatusUpdate(player, 1); + } + } + return; + } + else if(Mekanism.teleporters.get(teleCode).size() > 1) + { + if(item.getStatus(itemstack) != 3) + { + item.setStatus(itemstack, 3); + PacketHandler.sendStatusUpdate(player, 3); + } + return; + } + else { + if(item.getStatus(itemstack) != 4) + { + item.setStatus(itemstack, 4); + PacketHandler.sendStatusUpdate(player, 4); + } + return; + } + } + else { + if(item.getStatus(itemstack) != 4) + { + item.setStatus(itemstack, 4); + PacketHandler.sendStatusUpdate(player, 4); + } + return; + } + } + } + } + + @Override + public EnumSet ticks() + { + return EnumSet.of(TickType.PLAYER); + } + + @Override + public String getLabel() + { + return "MekanismCommon"; + } +} diff --git a/src/minecraft/mekanism/common/ContainerAdvancedElectricMachine.java b/src/minecraft/mekanism/common/ContainerAdvancedElectricMachine.java index b642386ad..d71a7431b 100644 --- a/src/minecraft/mekanism/common/ContainerAdvancedElectricMachine.java +++ b/src/minecraft/mekanism/common/ContainerAdvancedElectricMachine.java @@ -71,6 +71,22 @@ public class ContainerAdvancedElectricMachine extends Container return null; } } + else if(tileEntity.getInvName().equals("Theoretical Elementizer") && slotStack.isItemEqual(new ItemStack(Mekanism.EnrichedAlloy))) + { + if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) + { + if (!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } + } else if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem) { if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) @@ -87,7 +103,7 @@ public class ContainerAdvancedElectricMachine extends Container } } } - else if(slotStack.itemID == Item.redstone.shiftedIndex) + else if(slotStack.itemID == Item.redstone.itemID) { if(slotID != 3 && slotID != 0) { @@ -177,6 +193,12 @@ public class ContainerAdvancedElectricMachine extends Container return null; } } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } } if (slotStack.stackSize == 0) diff --git a/src/minecraft/mekanism/common/ContainerElectricMachine.java b/src/minecraft/mekanism/common/ContainerElectricMachine.java index 08786e386..a5b7cd95e 100644 --- a/src/minecraft/mekanism/common/ContainerElectricMachine.java +++ b/src/minecraft/mekanism/common/ContainerElectricMachine.java @@ -70,7 +70,7 @@ public class ContainerElectricMachine extends Container return null; } } - else if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.shiftedIndex) + else if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.itemID) { if(slotID != 1) { @@ -134,6 +134,12 @@ public class ContainerElectricMachine extends Container return null; } } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } } if (slotStack.stackSize == 0) diff --git a/src/minecraft/mekanism/common/ContainerEnergyCube.java b/src/minecraft/mekanism/common/ContainerEnergyCube.java index 9474f6643..ed36e2cc9 100644 --- a/src/minecraft/mekanism/common/ContainerEnergyCube.java +++ b/src/minecraft/mekanism/common/ContainerEnergyCube.java @@ -61,7 +61,7 @@ public class ContainerEnergyCube extends Container ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.shiftedIndex) + if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.itemID) { if(slotID != 0 && slotID != 1) { @@ -106,6 +106,12 @@ public class ContainerEnergyCube extends Container return null; } } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } } if (slotStack.stackSize == 0) diff --git a/src/minecraft/mekanism/common/ContainerGasTank.java b/src/minecraft/mekanism/common/ContainerGasTank.java index ff61db4e8..f6e681605 100644 --- a/src/minecraft/mekanism/common/ContainerGasTank.java +++ b/src/minecraft/mekanism/common/ContainerGasTank.java @@ -105,6 +105,12 @@ public class ContainerGasTank extends Container return null; } } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } } if (slotStack.stackSize == 0) diff --git a/src/minecraft/mekanism/common/ContainerMetallurgicInfuser.java b/src/minecraft/mekanism/common/ContainerMetallurgicInfuser.java index 411d99f15..124dfa044 100644 --- a/src/minecraft/mekanism/common/ContainerMetallurgicInfuser.java +++ b/src/minecraft/mekanism/common/ContainerMetallurgicInfuser.java @@ -119,6 +119,12 @@ public class ContainerMetallurgicInfuser extends Container return null; } } + else { + if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) + { + return null; + } + } } } else { diff --git a/src/minecraft/mekanism/common/ContainerSmeltingFactory.java b/src/minecraft/mekanism/common/ContainerSmeltingFactory.java index 95e55e1ae..6d3013dab 100644 --- a/src/minecraft/mekanism/common/ContainerSmeltingFactory.java +++ b/src/minecraft/mekanism/common/ContainerSmeltingFactory.java @@ -46,7 +46,7 @@ public class ContainerSmeltingFactory extends Container } } - else if(tileEntity.tier == SmeltingFactoryTier.ULTIMATE) + else if(tileEntity.tier == SmeltingFactoryTier.ELITE) { for(int i = 0; i < tileEntity.tier.processes; i++) { @@ -106,7 +106,7 @@ public class ContainerSmeltingFactory extends Container return null; } } - else if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.shiftedIndex) + else if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.itemID) { if(slotID != 1) { @@ -196,6 +196,12 @@ public class ContainerSmeltingFactory extends Container return null; } } + else { + if(!mergeItemStack(slotStack, slotEnd, inventorySlots.size(), true)) + { + return null; + } + } } if (slotStack.stackSize == 0) @@ -224,7 +230,7 @@ public class ContainerSmeltingFactory extends Container return slot == 2 || slot == 4 || slot == 6; if(tileEntity.tier == Tier.SmeltingFactoryTier.ADVANCED) return slot == 2 || slot == 4 || slot == 6 || slot == 8 || slot == 10; - if(tileEntity.tier == Tier.SmeltingFactoryTier.ULTIMATE) + if(tileEntity.tier == Tier.SmeltingFactoryTier.ELITE) return slot == 2 || slot == 4 || slot == 6 || slot == 8 || slot == 12 || slot == 14; return false; @@ -236,7 +242,7 @@ public class ContainerSmeltingFactory extends Container return slot == 3 || slot == 5 || slot == 7; if(tileEntity.tier == Tier.SmeltingFactoryTier.ADVANCED) return slot == 3 || slot == 5 || slot == 7 || slot == 9 || slot == 11; - if(tileEntity.tier == Tier.SmeltingFactoryTier.ULTIMATE) + if(tileEntity.tier == Tier.SmeltingFactoryTier.ELITE) return slot == 3 || slot == 5 || slot == 7 || slot == 9 || slot == 11 || slot == 13 || slot == 15; return false; diff --git a/src/minecraft/mekanism/common/ContainerTeleporter.java b/src/minecraft/mekanism/common/ContainerTeleporter.java new file mode 100644 index 000000000..f43f5afcc --- /dev/null +++ b/src/minecraft/mekanism/common/ContainerTeleporter.java @@ -0,0 +1,122 @@ +package mekanism.common; + +import ic2.api.IElectricItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.inventory.SlotFurnace; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import universalelectricity.core.implement.IItemElectric; + +public class ContainerTeleporter extends Container +{ + private TileEntityTeleporter tileEntity; + + public ContainerTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) + { + tileEntity = tentity; + addSlotToContainer(new SlotEnergy(tentity, 0, 27, 14)); + 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)); + } + + tileEntity.openChest(); + } + + @Override + public void onCraftGuiClosed(EntityPlayer entityplayer) + { + super.onCraftGuiClosed(entityplayer); + tileEntity.closeChest(); + } + + @Override + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return tileEntity.isUseableByPlayer(par1EntityPlayer); + } + + @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(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.itemID) + { + if(slotID != 0) + { + if(!mergeItemStack(slotStack, 0, 1, false)) + { + return null; + } + } + else if(slotID == 0) + { + if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) + { + return null; + } + } + } + else { + if(slotID >= 1 && slotID <= 27) + { + if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 27) + { + if(!mergeItemStack(slotStack, 1, 27, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) + { + 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; + } +} diff --git a/src/minecraft/mekanism/common/EnumPacketType.java b/src/minecraft/mekanism/common/EnumPacketType.java index 89513c425..abdcd4c7b 100644 --- a/src/minecraft/mekanism/common/EnumPacketType.java +++ b/src/minecraft/mekanism/common/EnumPacketType.java @@ -17,8 +17,16 @@ public enum EnumPacketType TILE_ENTITY(2), /** Used for sending a control panel GUI request to the server. */ CONTROL_PANEL(3), + /** Used to send a portal FX packet to all clients. */ + PORTAL_FX(4), + /** Used to send a teleport packet from an ItemStack to the server. */ + PORTABLE_TELEPORT(5), + /** Used to send a digit update packet from a portable teleporter to the server. */ + DIGIT_UPDATE(6), + /** Used to send a status update packet from a portable teleporter to the client. */ + STATUS_UPDATE(7), /** A custom packet type. Handled in PacketHandler. */ - CUSTOM(4); + CUSTOM(8); /** The ID of the packet type */ public final int id; diff --git a/src/minecraft/mekanism/common/ItemBlockBasic.java b/src/minecraft/mekanism/common/ItemBlockBasic.java index 4dff935cc..aeee118f4 100644 --- a/src/minecraft/mekanism/common/ItemBlockBasic.java +++ b/src/minecraft/mekanism/common/ItemBlockBasic.java @@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack; * 4: Refined Glowstone * 5: Steel Block * 6: Control Panel + * 7: Teleporter * @author AidanBrady * */ @@ -66,6 +67,9 @@ public class ItemBlockBasic extends ItemBlock case 6: name = "ControlPanel"; break; + case 7: + name = "Teleporter"; + break; default: name = "Unknown"; break; diff --git a/src/minecraft/mekanism/common/ItemBlockMachine.java b/src/minecraft/mekanism/common/ItemBlockMachine.java index 2b1358a6a..02bc1bfc9 100644 --- a/src/minecraft/mekanism/common/ItemBlockMachine.java +++ b/src/minecraft/mekanism/common/ItemBlockMachine.java @@ -13,7 +13,7 @@ import net.minecraft.item.ItemStack; * 4: Theoretical Elementizer * 5: Basic Smelting Factory * 6: Advanced Smelting Factory - * 7: Ultimate Smelting Factory + * 7: Elite Smelting Factory * 8: Metallurgic Infuser * @author AidanBrady * @@ -69,7 +69,7 @@ public class ItemBlockMachine extends ItemBlock name = "AdvancedSmeltingFactory"; break; case 7: - name = "UltimateSmeltingFactory"; + name = "EliteSmeltingFactory"; break; case 8: name = "MetallurgicInfuser"; diff --git a/src/minecraft/mekanism/common/ItemElectricBow.java b/src/minecraft/mekanism/common/ItemElectricBow.java index 79de47d21..19648cb6e 100644 --- a/src/minecraft/mekanism/common/ItemElectricBow.java +++ b/src/minecraft/mekanism/common/ItemElectricBow.java @@ -33,7 +33,7 @@ public class ItemElectricBow extends ItemEnergized { boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, itemstack) > 0; - if (flag || player.inventory.hasItem(Item.arrow.shiftedIndex)) + if (flag || player.inventory.hasItem(Item.arrow.itemID)) { int maxItemUse = getMaxItemUseDuration(itemstack) - itemUseCount; float f = (float)maxItemUse / 20F; @@ -69,7 +69,7 @@ public class ItemElectricBow extends ItemEnergized } else { - player.inventory.consumeInventoryItem(Item.arrow.shiftedIndex); + player.inventory.consumeInventoryItem(Item.arrow.itemID); } if (!world.isRemote) @@ -104,7 +104,7 @@ public class ItemElectricBow extends ItemEnergized { if(!entityplayer.isSneaking()) { - if (entityplayer.capabilities.isCreativeMode || entityplayer.inventory.hasItem(Item.arrow.shiftedIndex)) + if (entityplayer.capabilities.isCreativeMode || entityplayer.inventory.hasItem(Item.arrow.itemID)) { entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); } diff --git a/src/minecraft/mekanism/common/ItemMachineUpgrade.java b/src/minecraft/mekanism/common/ItemMachineUpgrade.java index 6f15039b4..456b09141 100644 --- a/src/minecraft/mekanism/common/ItemMachineUpgrade.java +++ b/src/minecraft/mekanism/common/ItemMachineUpgrade.java @@ -53,14 +53,14 @@ public class ItemMachineUpgrade extends Item implements IMachineUpgrade, IModifi @Override public String getName(ItemStack itemstack) { - return shiftedIndex == Mekanism.SpeedUpgrade.shiftedIndex ? "Speed" : - (shiftedIndex == Mekanism.EnergyUpgrade.shiftedIndex ? "Capacity" : "All"); + return itemID == Mekanism.SpeedUpgrade.itemID ? "Speed" : + (itemID == Mekanism.EnergyUpgrade.itemID ? "Capacity" : "All"); } @Override public int getEffectiveness(ItemStack itemstack) { - return shiftedIndex == Mekanism.SpeedUpgrade.shiftedIndex ? 150 : - (shiftedIndex == Mekanism.EnergyUpgrade.shiftedIndex ? 1000 : 2500); + return itemID == Mekanism.SpeedUpgrade.itemID ? 150 : + (itemID == Mekanism.EnergyUpgrade.itemID ? 1000 : 2500); } } diff --git a/src/minecraft/mekanism/common/ItemPortableTeleporter.java b/src/minecraft/mekanism/common/ItemPortableTeleporter.java new file mode 100644 index 000000000..e5f5fc9ab --- /dev/null +++ b/src/minecraft/mekanism/common/ItemPortableTeleporter.java @@ -0,0 +1,106 @@ +package mekanism.common; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.world.World; + +public class ItemPortableTeleporter extends ItemEnergized +{ + public ItemPortableTeleporter(int id) + { + super(id, 500000, 120, 5000); + } + + @Override + public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) + { + super.onUpdate(itemstack, world, entity, i, flag); + + setStatus(itemstack, getStatus(itemstack)); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) + { + entityplayer.openGui(Mekanism.instance, 14, world, 0, 0, 0); + return itemstack; + } + + public int calculateEnergyCost(Entity entity, Teleporter.Coords coords) + { + int neededEnergy = 1000; + + if(entity.worldObj.provider.dimensionId != coords.dimensionId) + { + neededEnergy+=10000; + } + + int distance = (int)entity.getDistanceSq(coords.xCoord, coords.yCoord, coords.zCoord); + + neededEnergy+=(distance*10); + + return neededEnergy; + } + + public String getStatusAsString(int i) + { + switch(i) + { + case 0: + return EnumColor.DARK_RED + "Not ready."; + case 1: + return EnumColor.DARK_GREEN + "Ready."; + case 2: + return EnumColor.DARK_RED + "Needs energy."; + case 3: + return EnumColor.DARK_RED + "Links > 1."; + case 4: + return EnumColor.DARK_RED + "No link found."; + default: + return EnumColor.DARK_RED + "Not ready."; + } + } + + public int getStatus(ItemStack itemstack) + { + if (itemstack.stackTagCompound == null) + { + return 0; + } + + return itemstack.stackTagCompound.getInteger("status"); + } + + public void setStatus(ItemStack itemstack, int status) + { + if (itemstack.stackTagCompound == null) + { + itemstack.setTagCompound(new NBTTagCompound()); + } + + itemstack.stackTagCompound.setInteger("status", status); + } + + public int getDigit(ItemStack itemstack, int index) + { + if (itemstack.stackTagCompound == null) + { + return 0; + } + + return itemstack.stackTagCompound.getInteger("digit"+index); + } + + public void setDigit(ItemStack itemstack, int index, int digit) + { + if (itemstack.stackTagCompound == null) + { + itemstack.setTagCompound(new NBTTagCompound()); + } + + itemstack.stackTagCompound.setInteger("digit"+index, digit); + } +} diff --git a/src/minecraft/mekanism/common/Mekanism.java b/src/minecraft/mekanism/common/Mekanism.java index 781ddb190..a0866ec06 100644 --- a/src/minecraft/mekanism/common/Mekanism.java +++ b/src/minecraft/mekanism/common/Mekanism.java @@ -2,6 +2,9 @@ package mekanism.common; import ic2.api.Ic2Recipes; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import java.util.logging.Logger; import mekanism.api.InfusionInput; @@ -18,6 +21,7 @@ import net.minecraftforge.common.Configuration; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; +import universalelectricity.core.UniversalElectricity; import universalelectricity.prefab.multiblock.BlockMulti; import universalelectricity.prefab.multiblock.TileEntityMulti; import cpw.mods.fml.common.Mod; @@ -38,13 +42,14 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import cpw.mods.fml.server.FMLServerHandler; /** * Mekanism mod -- adds in Tools, Armor, Weapons, Machines, and Magic. Universal source. * @author AidanBrady * */ -@Mod(modid = "Mekanism", name = "Mekanism", version = "5.0.10") +@Mod(modid = "Mekanism", name = "Mekanism", version = "5.1.1") @NetworkMod(channels = {"Mekanism"}, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) public class Mekanism { @@ -66,7 +71,10 @@ public class Mekanism public static Configuration configuration; /** Mekanism version number */ - public static Version versionNumber = new Version(5, 0, 10); + public static Version versionNumber = new Version(5, 1, 1); + + /** Map of Teleporter info. */ + public static Map> teleporters = new HashMap>(); /** Mekanism creative tab */ public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism(); @@ -115,6 +123,8 @@ public class Mekanism public static Item ControlCircuit; public static Item EnrichedIron; public static Item CompressedCarbon; + public static Item PortableTeleporter; + public static Item TeleportationCore; //Extra Blocks public static Block BasicBlock; @@ -131,7 +141,9 @@ public class Mekanism //Boolean Values public static boolean extrasEnabled = true; - public static boolean oreGenerationEnabled = true; + public static boolean platinumGenerationEnabled = true; + public static boolean disableBCBronzeCrafting = true; + public static boolean disableBCSteelCrafting = true; //Extra data public static float ObsidianTNTBlastRadius = 12.0F; @@ -201,13 +213,13 @@ public class Mekanism "ARA", "CIC", "ARA", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('R'), Item.redstone, Character.valueOf('I'), "blockSteel", Character.valueOf('C'), ControlCircuit })); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 1), new Object[] { - "RCR", "GIG", "RCR", Character.valueOf('R'), Item.redstone, Character.valueOf('C'), ControlCircuit, Character.valueOf('G'), Block.glass, Character.valueOf('I'), "blockSteel" + "RCR", "GIG", "RCR", Character.valueOf('R'), Item.redstone, Character.valueOf('C'), "basicCircuit", Character.valueOf('G'), Block.glass, Character.valueOf('I'), "blockSteel" })); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 2), new Object[] { - "SCS", "RIR", "SCS", Character.valueOf('S'), Block.cobblestone, Character.valueOf('C'), ControlCircuit, Character.valueOf('R'), Item.redstone, Character.valueOf('I'), "blockSteel" + "SCS", "RIR", "SCS", Character.valueOf('S'), Block.cobblestone, Character.valueOf('C'), "basicCircuit", Character.valueOf('R'), Item.redstone, Character.valueOf('I'), "blockSteel" })); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 3), new Object[] { - "RLR", "CIC", "RLR", Character.valueOf('R'), Item.redstone, Character.valueOf('L'), Item.bucketLava, Character.valueOf('C'), ControlCircuit, Character.valueOf('I'), "blockSteel" + "RLR", "CIC", "RLR", Character.valueOf('R'), Item.redstone, Character.valueOf('L'), Item.bucketLava, Character.valueOf('C'), "basicCircuit", Character.valueOf('I'), "blockSteel" })); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(SpeedUpgrade), new Object[] { "PAP", "AEA", "PAP", Character.valueOf('P'), "dustPlatinum", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('E'), Item.emerald @@ -239,7 +251,7 @@ public class Mekanism CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.ADVANCED), new Object[] { "EGE", "TBT", "EGE", Character.valueOf('E'), EnrichedAlloy, Character.valueOf('G'), Item.ingotGold, Character.valueOf('T'), EnergyTablet.getUnchargedItem(), Character.valueOf('B'), MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.BASIC) })); - CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.ULTIMATE), new Object[] { + CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.ELITE), new Object[] { "EDE", "TAT", "EDE", Character.valueOf('E'), EnrichedAlloy, Character.valueOf('D'), Item.diamond, Character.valueOf('T'), EnergyTablet.getUnchargedItem(), Character.valueOf('A'), MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.ADVANCED) })); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(ControlCircuit), new Object[] { @@ -255,16 +267,28 @@ public class Mekanism "T", "I", "T", Character.valueOf('T'), "dustTin", Character.valueOf('I'), Item.ingotIron })); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 5), new Object[] { - "CAC", "GIG", "CAC", Character.valueOf('C'), ControlCircuit, Character.valueOf('A'), EnrichedAlloy, Character.valueOf('G'), "dustGold", Character.valueOf('I'), "blockSteel" + "CAC", "GIG", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('G'), "dustGold", Character.valueOf('I'), "blockSteel" })); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 6), new Object[] { - "CAC", "DFD", "CAC", Character.valueOf('C'), ControlCircuit, Character.valueOf('A'), EnrichedAlloy, Character.valueOf('D'), "dustDiamond", Character.valueOf('F'), new ItemStack(MachineBlock, 1, 5) + "CAC", "DFD", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('D'), "dustDiamond", Character.valueOf('F'), new ItemStack(MachineBlock, 1, 5) })); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 7), new Object[] { - "CAC", "cFc", "CAC", Character.valueOf('C'), ControlCircuit, Character.valueOf('A'), EnrichedAlloy, Character.valueOf('c'), AtomicCore, Character.valueOf('F'), new ItemStack(MachineBlock, 1, 6) + "CAC", "cFc", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('c'), AtomicCore, Character.valueOf('F'), new ItemStack(MachineBlock, 1, 6) + })); + CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 7), new Object[] { + "CAC", "cFc", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('c'), AtomicCore, Character.valueOf('F'), "electricFurnace" })); CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 8), new Object[] { - "IFI", "CEC", "IFI", Character.valueOf('I'), Item.ingotIron, Character.valueOf('F'), Block.stoneOvenIdle, Character.valueOf('C'), ControlCircuit, Character.valueOf('E'), EnrichedAlloy + "IFI", "CEC", "IFI", Character.valueOf('I'), Item.ingotIron, Character.valueOf('F'), Block.stoneOvenIdle, Character.valueOf('C'), "basicCircuit", Character.valueOf('E'), EnrichedAlloy + })); + CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(TeleportationCore), new Object[] { + "LAL", "GDG", "LAL", Character.valueOf('L'), new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('A'), AtomicCore, Character.valueOf('G'), Item.ingotGold, Character.valueOf('D'), Item.diamond + })); + CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(PortableTeleporter), new Object[] { + " E ", "CTC", " E ", Character.valueOf('E'), EnergyTablet.getUnchargedItem(), Character.valueOf('C'), "basicCircuit", Character.valueOf('T'), TeleportationCore + })); + CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(BasicBlock, 1, 7), new Object[] { + "COC", "OTO", "COC", Character.valueOf('C'), "basicCircuit", Character.valueOf('O'), new ItemStack(BasicBlock, 1, 2), Character.valueOf('T'), TeleportationCore })); if(extrasEnabled) @@ -276,11 +300,11 @@ public class Mekanism //Furnace Recipes FurnaceRecipes.smelting().addSmelting(oreBlockID, 0, new ItemStack(Ingot, 1, 1), 1.0F); - FurnaceRecipes.smelting().addSmelting(Dust.shiftedIndex, 2, new ItemStack(Ingot, 1, 1), 1.0F); - FurnaceRecipes.smelting().addSmelting(Dust.shiftedIndex, 0, new ItemStack(Item.ingotIron), 1.0F); - FurnaceRecipes.smelting().addSmelting(Dust.shiftedIndex, 1, new ItemStack(Item.ingotGold), 1.0F); - FurnaceRecipes.smelting().addSmelting(Dust.shiftedIndex, 5, new ItemStack(Ingot, 1, 4), 1.0F); - GameRegistry.addSmelting(Item.coal.shiftedIndex, new ItemStack(CompressedCarbon), 1.0F); + FurnaceRecipes.smelting().addSmelting(Dust.itemID, 2, new ItemStack(Ingot, 1, 1), 1.0F); + FurnaceRecipes.smelting().addSmelting(Dust.itemID, 0, new ItemStack(Item.ingotIron), 1.0F); + FurnaceRecipes.smelting().addSmelting(Dust.itemID, 1, new ItemStack(Item.ingotGold), 1.0F); + FurnaceRecipes.smelting().addSmelting(Dust.itemID, 5, new ItemStack(Ingot, 1, 4), 1.0F); + GameRegistry.addSmelting(Item.coal.itemID, new ItemStack(CompressedCarbon), 1.0F); //Enrichment Chamber Recipes RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Dust, 1, 4), new ItemStack(Item.diamond)); @@ -302,12 +326,6 @@ public class Mekanism RecipeHandler.addCrusherRecipe(new ItemStack(Item.ingotIron), new ItemStack(Dust, 1, 0)); RecipeHandler.addCrusherRecipe(new ItemStack(Item.ingotGold), new ItemStack(Dust, 1, 1)); - if(extrasEnabled) - { - //Theoretical Elementizer Recipes - RecipeHandler.addTheoreticalElementizerRecipe(new ItemStack(EnrichedAlloy), new ItemStack(TileEntityTheoreticalElementizer.getRandomMagicItem())); - } - //Metallurgic Infuser Recipes RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfusionType.COAL, 10, new ItemStack(EnrichedIron)), new ItemStack(Dust, 1, 5)); } @@ -342,6 +360,8 @@ public class Mekanism LanguageRegistry.addName(ControlCircuit, "Control Circuit"); LanguageRegistry.addName(EnrichedIron, "Enriched Iron"); LanguageRegistry.addName(CompressedCarbon, "Compressed Carbon"); + LanguageRegistry.addName(PortableTeleporter, "Portable Teleporter"); + LanguageRegistry.addName(TeleportationCore, "Teleportation Core"); //Localization for MultiBlock LanguageRegistry.instance().addStringLocalization("tile.BasicBlock.PlatinumBlock.name", "Platinum Block"); @@ -351,6 +371,7 @@ public class Mekanism LanguageRegistry.instance().addStringLocalization("tile.BasicBlock.RefinedGlowstone.name", "Refined Glowstone"); LanguageRegistry.instance().addStringLocalization("tile.BasicBlock.SteelBlock.name", "Steel Block"); LanguageRegistry.instance().addStringLocalization("tile.BasicBlock.ControlPanel.name", "Control Panel"); + LanguageRegistry.instance().addStringLocalization("tile.BasicBlock.Teleporter.name", "Teleporter"); //Localization for MachineBlock LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.EnrichmentChamber.name", "Enrichment Chamber"); @@ -360,7 +381,7 @@ public class Mekanism LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.TheoreticalElementizer.name", "Theoretical Elementizer"); LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.BasicSmeltingFactory.name", "Basic Smelting Factory"); LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.AdvancedSmeltingFactory.name", "Advanced Smelting Factory"); - LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.UltimateSmeltingFactory.name", "Ultimate Smelting Factory"); + LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.EliteSmeltingFactory.name", "Elite Smelting Factory"); LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.MetallurgicInfuser.name", "Metallurgic Infuser"); //Localization for OreBlock @@ -369,7 +390,7 @@ public class Mekanism //Localization for EnergyCube LanguageRegistry.instance().addStringLocalization("tile.EnergyCube.Basic.name", "Basic Energy Cube"); LanguageRegistry.instance().addStringLocalization("tile.EnergyCube.Advanced.name", "Advanced Energy Cube"); - LanguageRegistry.instance().addStringLocalization("tile.EnergyCube.Ultimate.name", "Ultimate Energy Cube"); + LanguageRegistry.instance().addStringLocalization("tile.EnergyCube.Elite.name", "Elite Energy Cube"); //Localization for Dust LanguageRegistry.instance().addStringLocalization("item.ironDust.name", "Iron Dust"); @@ -415,6 +436,8 @@ public class Mekanism ControlCircuit.setIconIndex(223); EnrichedIron.setIconIndex(222); CompressedCarbon.setIconIndex(221); + PortableTeleporter.setIconIndex(206); + TeleportationCore.setIconIndex(207); } /** @@ -442,6 +465,8 @@ public class Mekanism ControlCircuit = new ItemMekanism(configuration.getItem("ControlCircuit", 11214).getInt()).setItemName("ControlCircuit"); EnrichedIron = new ItemMekanism(configuration.getItem("EnrichedIron", 11215).getInt()).setItemName("EnrichedIron"); CompressedCarbon = new ItemMekanism(configuration.getItem("CompressedCarbon", 11216).getInt()).setItemName("CompressedCarbon"); + PortableTeleporter = new ItemPortableTeleporter(configuration.getItem("PortableTeleporter", 11217).getInt()).setItemName("PortableTeleporter"); + TeleportationCore = new ItemMekanism(configuration.getItem("TeleportationCore", 11218).getInt()).setItemName("TeleportationCore"); configuration.save(); } @@ -501,6 +526,8 @@ public class Mekanism OreDictionary.registerOre("orePlatinum", new ItemStack(OreBlock, 1, 0)); + OreDictionary.registerOre("basicCircuit", new ItemStack(ControlCircuit)); + if(hooks.IC2Loaded) { if(!hooks.RailcraftLoaded) @@ -570,17 +597,25 @@ public class Mekanism RecipeHandler.addCrusherRecipe(ore, new ItemStack(Item.lightStoneDust)); } + try { + FurnaceRecipes.smelting().addSmelting(Dust.itemID, 6, OreDictionary.getOres("ingotCopper").get(0), 1.0F); + } catch(Exception e) {} + + try { + FurnaceRecipes.smelting().addSmelting(Dust.itemID, 7, OreDictionary.getOres("ingotTin").get(0), 1.0F); + } catch(Exception e) {} + try { for(ItemStack ore : OreDictionary.getOres("ingotCopper")) { - RecipeHandler.addCrusherRecipe(ore, OreDictionary.getOres("dustCopper").get(0)); + RecipeHandler.addCrusherRecipe(ore, new ItemStack(Dust, 1, 6)); } } catch(Exception e) {} try { for(ItemStack ore : OreDictionary.getOres("ingotTin")) { - RecipeHandler.addCrusherRecipe(ore, OreDictionary.getOres("dustTin").get(0)); + RecipeHandler.addCrusherRecipe(ore, new ItemStack(Dust, 1, 7)); } } catch(Exception e) {} @@ -615,7 +650,7 @@ public class Mekanism try { for(ItemStack ore : OreDictionary.getOres("ingotCopper")) { - RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfusionType.TIN, 10, ore), new ItemStack(Ingot, 1, 2)); + RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfusionType.TIN, 10, MekanismUtils.getStackWithSize(ore, 1)), new ItemStack(Ingot, 1, 2)); } } catch(Exception e) {} @@ -658,13 +693,14 @@ public class Mekanism GameRegistry.registerTileEntity(TileEntityCombiner.class, "Combiner"); GameRegistry.registerTileEntity(TileEntityCrusher.class, "Crusher"); GameRegistry.registerTileEntity(TileEntityEnergyCube.class, "EnergyCube"); - GameRegistry.registerTileEntity(TileEntityMulti.class, "Multi"); + GameRegistry.registerTileEntity(TileEntityMulti.class, "MekanismMulti"); GameRegistry.registerTileEntity(TileEntityControlPanel.class, "ControlPanel"); GameRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank"); GameRegistry.registerTileEntity(TileEntitySmeltingFactory.class, "SmeltingFactory"); GameRegistry.registerTileEntity(TileEntityAdvancedSmeltingFactory.class, "AdvancedSmeltingFactory"); - GameRegistry.registerTileEntity(TileEntityUltimateSmeltingFactory.class, "UltimateSmeltingFactory"); + GameRegistry.registerTileEntity(TileEntityEliteSmeltingFactory.class, "UltimateSmeltingFactory"); GameRegistry.registerTileEntity(TileEntityMetallurgicInfuser.class, "MetallurgicInfuser"); + GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter"); //Load tile entities that have special renderers. proxy.registerSpecialTileEntities(); @@ -683,6 +719,7 @@ public class Mekanism public void serverStopping(FMLServerStoppingEvent event) { proxy.unloadSoundHandler(); + teleporters.clear(); } @PreInit @@ -716,8 +753,10 @@ public class Mekanism //Register the MachineryManager manager = new MachineryManager(); + //Initialization notification System.out.println("[Mekanism] Version " + versionNumber + " initializing..."); + //Get data from server. new ThreadGetData(); //Load proxy @@ -726,6 +765,7 @@ public class Mekanism proxy.loadUtilities(); proxy.loadTickHandler(); + //Register to recieve subscribed events MinecraftForge.EVENT_BUS.register(this); //Attempt to load server commands @@ -741,6 +781,7 @@ public class Mekanism addRecipes(); addEntities(); + //Completion notification System.out.println("[Mekanism] Loading complete."); //Success message diff --git a/src/minecraft/mekanism/common/MekanismHooks.java b/src/minecraft/mekanism/common/MekanismHooks.java index af1932522..a65e05849 100644 --- a/src/minecraft/mekanism/common/MekanismHooks.java +++ b/src/minecraft/mekanism/common/MekanismHooks.java @@ -80,10 +80,18 @@ public final class MekanismHooks } if(BasicComponentsLoaded) { - RecipeHelper.removeRecipes(getBasicComponentsItem("itemSteelDust")); - RecipeHelper.removeRecipes(getBasicComponentsItem("itemSteelIngot")); - RecipeHelper.removeRecipes(getBasicComponentsItem("itemBronzeDust")); - RecipeHelper.removeRecipes(getBasicComponentsItem("itemBronzeIngot")); + if(Mekanism.disableBCSteelCrafting) + { + RecipeHelper.removeRecipes(getBasicComponentsItem("itemSteelDust")); + RecipeHelper.removeRecipes(getBasicComponentsItem("itemSteelIngot")); + } + + if(Mekanism.disableBCBronzeCrafting) + { + RecipeHelper.removeRecipes(getBasicComponentsItem("itemBronzeDust")); + RecipeHelper.removeRecipes(getBasicComponentsItem("itemBronzeIngot")); + } + System.out.println("[Mekanism] Hooked into BasicComponents successfully."); } if(BuildCraftLoaded) diff --git a/src/minecraft/mekanism/common/MekanismUtils.java b/src/minecraft/mekanism/common/MekanismUtils.java index 8b6251351..09060d75f 100644 --- a/src/minecraft/mekanism/common/MekanismUtils.java +++ b/src/minecraft/mekanism/common/MekanismUtils.java @@ -10,6 +10,7 @@ import mekanism.api.IActiveState; import mekanism.api.Tier.EnergyCubeTier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.network.packet.Packet3Chat; @@ -20,6 +21,7 @@ import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; +import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.server.FMLServerHandler; /** @@ -120,6 +122,11 @@ public final class MekanismUtils } } + public static void sendChatMessageToAllPlayers(String msg) + { + PacketDispatcher.sendPacketToAllPlayers(new Packet3Chat(msg)); + } + /** * Checks if the mod is running on the latest version. * @return if mod is latest version @@ -188,8 +195,9 @@ public final class MekanismUtils */ public static ItemStack getStackWithSize(ItemStack itemstack, int size) { - itemstack.stackSize = size; - return itemstack; + ItemStack newStack = itemstack.copy(); + newStack.stackSize = size; + return newStack; } /** @@ -234,6 +242,11 @@ public final class MekanismUtils return false; } + /** + * Gets the left side of a certain orientation. + * @param orientation + * @return left side + */ public static ForgeDirection getLeft(int orientation) { switch(orientation) @@ -249,18 +262,28 @@ public final class MekanismUtils } } + /** + * Gets the right side of a certain orientation. + * @param orientation + * @return right side + */ public static ForgeDirection getRight(int orientation) { return getLeft(orientation).getOpposite(); } + /** + * Checks to see if a specified ItemStack is stored in the Ore Dictionary with the specified name. + * @param check - ItemStack to check + * @param oreDict - name to check with + * @return if the ItemStack has the Ore Dictionary key + */ public static boolean oreDictCheck(ItemStack check, String oreDict) { boolean hasResource = false; for(ItemStack ore : OreDictionary.getOres(oreDict)) { - if(ore.isItemEqual(check)) { hasResource = true; diff --git a/src/minecraft/mekanism/common/OreHandler.java b/src/minecraft/mekanism/common/OreHandler.java index 06038f9f9..0390588d9 100644 --- a/src/minecraft/mekanism/common/OreHandler.java +++ b/src/minecraft/mekanism/common/OreHandler.java @@ -29,7 +29,7 @@ public class OreHandler implements IWorldGenerator */ public void generateSurface(World world, Random random, int chunkX, int chunkZ) { - if(Mekanism.oreGenerationEnabled == true) + if(Mekanism.platinumGenerationEnabled == true) { for(int i=0;i<6;i++) { diff --git a/src/minecraft/mekanism/common/PacketHandler.java b/src/minecraft/mekanism/common/PacketHandler.java index 89cf2fa22..13bedf088 100644 --- a/src/minecraft/mekanism/common/PacketHandler.java +++ b/src/minecraft/mekanism/common/PacketHandler.java @@ -3,9 +3,12 @@ package mekanism.common; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.util.Random; import mekanism.api.ITileNetwork; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; @@ -71,7 +74,7 @@ public class PacketHandler implements IPacketHandler int y = dataStream.readInt(); int z = dataStream.readInt(); - World world = ((EntityPlayer)player).worldObj; + World world = entityplayer.worldObj; TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if(tileEntity instanceof ITileNetwork) { @@ -114,17 +117,103 @@ public class PacketHandler implements IPacketHandler } entityplayer.openGui(instance, guiId, entityplayer.worldObj, x, y, z); - } catch (Exception e) { System.err.println("[Mekanism] Error while handling control panel packet."); e.printStackTrace(); } } + if(packetType == EnumPacketType.PORTAL_FX.id) + { + try { + Random random = new Random(); + int x = dataStream.readInt(); + int y = dataStream.readInt(); + int z = dataStream.readInt(); + + for(int i = 0; i < 50; i++) + { + entityplayer.worldObj.spawnParticle("portal", x + random.nextFloat(), y + random.nextFloat(), z + random.nextFloat(), 0.0F, 0.0F, 0.0F); + entityplayer.worldObj.spawnParticle("portal", x + random.nextFloat(), y + 1 + random.nextFloat(), z + random.nextFloat(), 0.0F, 0.0F, 0.0F); + } + } catch (Exception e) + { + System.err.println("[Mekanism] Error while handling portal FX packet."); + e.printStackTrace(); + } + } + if(packetType == EnumPacketType.DIGIT_UPDATE.id) + { + try { + int index = dataStream.readInt(); + int digit = dataStream.readInt(); + + ItemStack currentStack = entityplayer.getCurrentEquippedItem(); + + if(currentStack != null && currentStack.getItem() instanceof ItemPortableTeleporter) + { + ItemPortableTeleporter item = (ItemPortableTeleporter)currentStack.getItem(); + item.setDigit(currentStack, index, digit); + } + } catch (Exception e) + { + System.err.println("[Mekanism] Error while handling digit update packet."); + e.printStackTrace(); + } + } + if(packetType == EnumPacketType.STATUS_UPDATE.id) + { + try { + ItemStack currentStack = entityplayer.getCurrentEquippedItem(); + + if(currentStack != null && currentStack.getItem() instanceof ItemPortableTeleporter) + { + ItemPortableTeleporter item = (ItemPortableTeleporter)currentStack.getItem(); + item.setStatus(currentStack, dataStream.readInt()); + } + } catch (Exception e) + { + System.err.println("[Mekanism] Error while handling status update packet."); + e.printStackTrace(); + } + } + if(packetType == EnumPacketType.PORTABLE_TELEPORT.id) + { + try { + if(entityplayer instanceof EntityPlayerMP) + { + EntityPlayerMP entityPlayerMP = (EntityPlayerMP)entityplayer; + ItemStack itemstack = entityPlayerMP.getCurrentEquippedItem(); + + if(itemstack != null && itemstack.getItem() instanceof ItemPortableTeleporter) + { + ItemPortableTeleporter item = (ItemPortableTeleporter)itemstack.getItem(); + + if(item.getStatus(itemstack) == 1) + { + Teleporter.Coords coords = Mekanism.teleporters.get(new Teleporter.Code(item.getDigit(itemstack, 0), item.getDigit(itemstack, 1), item.getDigit(itemstack, 2), item.getDigit(itemstack, 3))).get(0); + + if(entityPlayerMP.worldObj.provider.dimensionId != coords.dimensionId) + { + entityPlayerMP.travelToDimension(coords.dimensionId); + } + + entityPlayerMP.playerNetServerHandler.setPlayerLocation(coords.xCoord, coords.yCoord, coords.zCoord, entityPlayerMP.rotationYaw, entityPlayerMP.rotationPitch); + + item.onUse(item.calculateEnergyCost(entityPlayerMP, coords), itemstack); + } + } + } + } catch (Exception e) + { + System.err.println("[Mekanism] Error while handling portable teleport packet."); + e.printStackTrace(); + } + } } catch (Exception e) { - System.err.println("[Mekanism] Error while handling data int packet."); + System.err.println("[Mekanism] Error while handling packet."); e.printStackTrace(); } } @@ -303,6 +392,70 @@ public class PacketHandler implements IPacketHandler System.out.println("[Mekanism] Sent control panel packet to server."); } + public static void sendPortalFX(int x, int y, int z, int id) + { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + DataOutputStream data = new DataOutputStream(bytes); + + try { + data.writeInt(EnumPacketType.PORTAL_FX.id); + data.writeInt(x); + data.writeInt(y); + data.writeInt(z); + } catch (IOException e) { + System.out.println("[Mekanism] An error occured while writing packet data."); + e.printStackTrace(); + } + + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "Mekanism"; + packet.data = bytes.toByteArray(); + packet.length = packet.data.length; + PacketDispatcher.sendPacketToAllAround(x, y, z, 40, id, packet); + System.out.println("[Mekanism] Sent portal FX packet to server."); + } + + public static void sendDigitUpdate(int index, int digit) + { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + DataOutputStream data = new DataOutputStream(bytes); + + try { + data.writeInt(EnumPacketType.DIGIT_UPDATE.id); + data.writeInt(index); + data.writeInt(digit); + } catch (IOException e) { + System.out.println("[Mekanism] An error occured while writing packet data."); + e.printStackTrace(); + } + + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "Mekanism"; + packet.data = bytes.toByteArray(); + packet.length = packet.data.length; + PacketDispatcher.sendPacketToServer(packet); + } + + public static void sendStatusUpdate(EntityPlayer entityplayer, int status) + { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + DataOutputStream data = new DataOutputStream(bytes); + + try { + data.writeInt(EnumPacketType.STATUS_UPDATE.id); + data.writeInt(status); + } catch (IOException e) { + System.out.println("[Mekanism] An error occured while writing packet data."); + e.printStackTrace(); + } + + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "Mekanism"; + packet.data = bytes.toByteArray(); + packet.length = packet.data.length; + PacketDispatcher.sendPacketToPlayer(packet, (Player)entityplayer); + } + /** * Sends the server the defined packet data int. * @param type - packet type diff --git a/src/minecraft/mekanism/common/RecipeHandler.java b/src/minecraft/mekanism/common/RecipeHandler.java index b3d6f8eb1..fd130df27 100644 --- a/src/minecraft/mekanism/common/RecipeHandler.java +++ b/src/minecraft/mekanism/common/RecipeHandler.java @@ -53,16 +53,6 @@ public final class RecipeHandler TileEntityCrusher.recipes.put(input, output); } - /** - * Add a Theoretical Elementizer recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addTheoreticalElementizerRecipe(ItemStack input, ItemStack output) - { - TileEntityTheoreticalElementizer.recipes.put(input, output); - } - /** * Adds a Metallurgic Infuser recipe. * @param input - input Infusion diff --git a/src/minecraft/mekanism/common/SlotEnergy.java b/src/minecraft/mekanism/common/SlotEnergy.java index 951d559ad..8d98e3cb3 100644 --- a/src/minecraft/mekanism/common/SlotEnergy.java +++ b/src/minecraft/mekanism/common/SlotEnergy.java @@ -17,6 +17,6 @@ public class SlotEnergy extends Slot @Override public boolean isItemValid(ItemStack itemstack) { - return itemstack.getItem() instanceof IElectricItem || itemstack.getItem() instanceof IItemElectric || itemstack.itemID == Item.redstone.shiftedIndex; + return itemstack.getItem() instanceof IElectricItem || itemstack.getItem() instanceof IItemElectric || itemstack.itemID == Item.redstone.itemID; } } diff --git a/src/minecraft/mekanism/common/Teleporter.java b/src/minecraft/mekanism/common/Teleporter.java new file mode 100644 index 000000000..6a950a14a --- /dev/null +++ b/src/minecraft/mekanism/common/Teleporter.java @@ -0,0 +1,59 @@ +package mekanism.common; + +public class Teleporter +{ + public static final class Coords + { + public int xCoord; + public int yCoord; + public int zCoord; + public int dimensionId; + + public Coords(int x, int y, int z, int id) + { + xCoord = x; + yCoord = y; + zCoord = z; + dimensionId = id; + } + + public static Coords get(TileEntityTeleporter tileEntity) + { + return new Coords(tileEntity.xCoord, tileEntity.yCoord+1, tileEntity.zCoord, tileEntity.worldObj.provider.dimensionId); + } + + @Override + public boolean equals(Object coords) + { + return coords instanceof Coords && ((Coords)coords).xCoord == xCoord && ((Coords)coords).yCoord == yCoord && ((Coords)coords).zCoord == zCoord && ((Coords)coords).dimensionId == dimensionId; + } + } + + public static final class Code + { + public int digitOne; + public int digitTwo; + public int digitThree; + public int digitFour; + + public Code(int one, int two, int three, int four) + { + digitOne = one; + digitTwo = two; + digitThree = three; + digitFour = four; + } + + @Override + public int hashCode() + { + return Integer.parseInt(1 + "" + digitOne + "" + digitTwo + "" + digitThree + "" + digitFour); + } + + @Override + public boolean equals(Object code) + { + return code instanceof Code && ((Code)code).digitOne == digitOne && ((Code)code).digitTwo == digitTwo && ((Code)code).digitThree == digitThree && ((Code)code).digitFour == digitFour; + } + } +} diff --git a/src/minecraft/mekanism/common/TileEntityAdvancedElectricMachine.java b/src/minecraft/mekanism/common/TileEntityAdvancedElectricMachine.java index 333581f93..6a828b548 100644 --- a/src/minecraft/mekanism/common/TileEntityAdvancedElectricMachine.java +++ b/src/minecraft/mekanism/common/TileEntityAdvancedElectricMachine.java @@ -98,7 +98,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM } } } - if(inventory[3].itemID == Item.redstone.shiftedIndex && electricityStored <= (MAX_ELECTRICITY-1000)) + if(inventory[3].itemID == Item.redstone.itemID && electricityStored <= (MAX_ELECTRICITY-1000)) { setJoules(electricityStored + 1000); --inventory[3].stackSize; diff --git a/src/minecraft/mekanism/common/TileEntityBasicBlock.java b/src/minecraft/mekanism/common/TileEntityBasicBlock.java index 4583e905b..3d8f43d92 100644 --- a/src/minecraft/mekanism/common/TileEntityBasicBlock.java +++ b/src/minecraft/mekanism/common/TileEntityBasicBlock.java @@ -115,6 +115,6 @@ public abstract class TileEntityBasicBlock extends TileEntityDisableable impleme @Override public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { - return new ItemStack(blockType.blockID, 1, blockMetadata); + return new ItemStack(worldObj.getBlockId(xCoord, yCoord, zCoord), 1, worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); } } diff --git a/src/minecraft/mekanism/common/TileEntityBasicMachine.java b/src/minecraft/mekanism/common/TileEntityBasicMachine.java index a43a398e9..4c7d42a3d 100644 --- a/src/minecraft/mekanism/common/TileEntityBasicMachine.java +++ b/src/minecraft/mekanism/common/TileEntityBasicMachine.java @@ -318,7 +318,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp } @Override - public void attach(IComputerAccess computer, String computerSide) {} + public void attach(IComputerAccess computer) {} @Override public void detach(IComputerAccess computer) {} diff --git a/src/minecraft/mekanism/common/TileEntityElectricMachine.java b/src/minecraft/mekanism/common/TileEntityElectricMachine.java index 1559f5142..83d454dde 100644 --- a/src/minecraft/mekanism/common/TileEntityElectricMachine.java +++ b/src/minecraft/mekanism/common/TileEntityElectricMachine.java @@ -77,7 +77,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine } } } - if(inventory[1].itemID == Item.redstone.shiftedIndex && electricityStored <= (currentMaxElectricity-1000)) + if(inventory[1].itemID == Item.redstone.itemID && electricityStored <= (currentMaxElectricity-1000)) { setJoules(electricityStored + 1000); --inventory[1].stackSize; diff --git a/src/minecraft/mekanism/common/TileEntityEliteSmeltingFactory.java b/src/minecraft/mekanism/common/TileEntityEliteSmeltingFactory.java new file mode 100644 index 000000000..a4fa75979 --- /dev/null +++ b/src/minecraft/mekanism/common/TileEntityEliteSmeltingFactory.java @@ -0,0 +1,11 @@ +package mekanism.common; + +import mekanism.api.Tier.SmeltingFactoryTier; + +public class TileEntityEliteSmeltingFactory extends TileEntitySmeltingFactory +{ + public TileEntityEliteSmeltingFactory() + { + super(SmeltingFactoryTier.ELITE); + } +} diff --git a/src/minecraft/mekanism/common/TileEntityEnergyCube.java b/src/minecraft/mekanism/common/TileEntityEnergyCube.java index 3101ec57d..e74e8ddc9 100644 --- a/src/minecraft/mekanism/common/TileEntityEnergyCube.java +++ b/src/minecraft/mekanism/common/TileEntityEnergyCube.java @@ -63,6 +63,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn public TileEntityEnergyCube(String name, int maxEnergy, int i) { super(name, maxEnergy); + powerProvider.configure(5, 2, 10, 1, maxEnergy/10); ElectricityConnections.registerConnector(this, EnumSet.allOf(ForgeDirection.class)); inventory = new ItemStack[2]; output = i; @@ -111,32 +112,9 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn if(inventory[0].getItem() instanceof IItemElectric) { IItemElectric electricItem = (IItemElectric)inventory[0].getItem(); - double sendingElectricity = 0; - double actualSendingElectricity = 0; - double rejectedElectricity = 0; - double itemElectricityNeeded = electricItem.getMaxJoules(inventory[0]) - electricItem.getJoules(inventory[0]); - - if(electricItem.getVoltage(inventory[0]) <= electricityStored) - { - sendingElectricity = electricItem.getVoltage(inventory[0]); - } - else if(electricItem.getVoltage(inventory[0]) > electricityStored) - { - sendingElectricity = electricityStored; - } - - if(sendingElectricity <= itemElectricityNeeded) - { - actualSendingElectricity = sendingElectricity; - } - else if(sendingElectricity > itemElectricityNeeded) - { - rejectedElectricity = sendingElectricity-itemElectricityNeeded; - actualSendingElectricity = itemElectricityNeeded; - } - - electricItem.setJoules((electricItem.getJoules(inventory[0]) + actualSendingElectricity), inventory[0]); - setJoules(electricityStored - Math.max(actualSendingElectricity - rejectedElectricity, 0)); + double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[0])*0.005, electricityStored), getVoltage()), electricityStored); + double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[0]); + setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects)); } else if(inventory[0].getItem() instanceof IElectricItem) { @@ -158,9 +136,9 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn if(electricItem.getVoltage(inventory[1]) <= joulesNeeded) { - joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[0]), inventory[1]); + joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[1]), inventory[1]); } - else if(electricItem.getVoltage(inventory[0]) > joulesNeeded) + else if(electricItem.getVoltage(inventory[1]) > joulesNeeded) { joulesReceived = electricItem.onUse(joulesNeeded, inventory[1]); } @@ -177,7 +155,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn setJoules(electricityStored + gain); } } - else if(inventory[1].itemID == Item.redstone.shiftedIndex) + else if(inventory[1].itemID == Item.redstone.itemID) { setJoules(electricityStored + 1000); --inventory[1].stackSize; @@ -396,7 +374,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn } @Override - public void attach(IComputerAccess computer, String computerSide) {} + public void attach(IComputerAccess computer) {} @Override public void detach(IComputerAccess computer) {} diff --git a/src/minecraft/mekanism/common/TileEntityMetallurgicInfuser.java b/src/minecraft/mekanism/common/TileEntityMetallurgicInfuser.java index e7b0e6d99..0fe88f341 100644 --- a/src/minecraft/mekanism/common/TileEntityMetallurgicInfuser.java +++ b/src/minecraft/mekanism/common/TileEntityMetallurgicInfuser.java @@ -172,7 +172,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem } } } - if(inventory[4].itemID == Item.redstone.shiftedIndex && electricityStored <= (currentMaxElectricity-1000)) + if(inventory[4].itemID == Item.redstone.itemID && electricityStored <= (currentMaxElectricity-1000)) { setJoules(electricityStored + 1000); --inventory[4].stackSize; @@ -545,7 +545,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem } @Override - public void attach(IComputerAccess computer, String computerSide) {} + public void attach(IComputerAccess computer) {} @Override public void detach(IComputerAccess computer) {} diff --git a/src/minecraft/mekanism/common/TileEntitySmeltingFactory.java b/src/minecraft/mekanism/common/TileEntitySmeltingFactory.java index 4dd341165..cf9848414 100644 --- a/src/minecraft/mekanism/common/TileEntitySmeltingFactory.java +++ b/src/minecraft/mekanism/common/TileEntitySmeltingFactory.java @@ -7,6 +7,7 @@ import ic2.api.ElectricItem; import ic2.api.IElectricItem; import ic2.api.energy.tile.IEnergySink; import mekanism.api.IActiveState; +import mekanism.api.IMachineUpgrade; import mekanism.api.Tier.SmeltingFactoryTier; import mekanism.client.Sound; import net.minecraft.entity.player.EntityPlayer; @@ -172,7 +173,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement } } } - if(inventory[1].itemID == Item.redstone.shiftedIndex && electricityStored <= (currentMaxElectricity-1000)) + if(inventory[1].itemID == Item.redstone.itemID && electricityStored <= (currentMaxElectricity-1000)) { setJoules(electricityStored + 1000); --inventory[1].stackSize; @@ -184,35 +185,19 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement } } - if(inventory[0] != null) + if(inventory[0] != null && inventory[0].getItem() instanceof IMachineUpgrade) { int energyToAdd = 0; int ticksToRemove = 0; - if(inventory[0].isItemEqual(new ItemStack(Mekanism.SpeedUpgrade))) + if(currentMaxElectricity == MAX_ELECTRICITY) { - if(currentTicksRequired == TICKS_REQUIRED) - { - ticksToRemove = 150; - } + energyToAdd = ((IMachineUpgrade)inventory[0].getItem()).getEnergyBoost(inventory[0]); } - else if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade))) + + if(currentTicksRequired == TICKS_REQUIRED) { - if(currentMaxElectricity == MAX_ELECTRICITY) - { - energyToAdd = 600; - } - } - else if(inventory[0].isItemEqual(new ItemStack(Mekanism.UltimateUpgrade))) - { - if(currentTicksRequired == TICKS_REQUIRED) - { - ticksToRemove = 150; - } - if(currentMaxElectricity == MAX_ELECTRICITY) - { - energyToAdd = 600; - } + ticksToRemove = ((IMachineUpgrade)inventory[0].getItem()).getTickReduction(inventory[0]); } currentMaxElectricity += energyToAdd; @@ -560,7 +545,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement } @Override - public void attach(IComputerAccess computer, String computerSide) {} + public void attach(IComputerAccess computer) {} @Override public void detach(IComputerAccess computer) {} diff --git a/src/minecraft/mekanism/common/TileEntityTeleporter.java b/src/minecraft/mekanism/common/TileEntityTeleporter.java new file mode 100644 index 000000000..7bad18775 --- /dev/null +++ b/src/minecraft/mekanism/common/TileEntityTeleporter.java @@ -0,0 +1,570 @@ +package mekanism.common; + +import ic2.api.Direction; +import ic2.api.ElectricItem; +import ic2.api.IElectricItem; +import ic2.api.energy.tile.IEnergySink; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; +import java.util.Random; + +import universalelectricity.core.electricity.ElectricityConnections; +import universalelectricity.core.implement.IConductor; +import universalelectricity.core.implement.IItemElectric; +import universalelectricity.core.implement.IJouleStorage; +import universalelectricity.core.implement.IVoltage; +import universalelectricity.core.vector.Vector3; + +import com.google.common.io.ByteArrayDataInput; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import cpw.mods.fml.server.FMLServerHandler; +import dan200.computer.api.IComputerAccess; +import dan200.computer.api.IPeripheral; + +import mekanism.common.Teleporter.Coords; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.ForgeDirection; + +public class TileEntityTeleporter extends TileEntityElectricBlock implements IEnergySink, IJouleStorage, IVoltage, IPeripheral +{ + public Teleporter.Code code; + public String status = (EnumColor.DARK_RED + "Not ready."); + + public TileEntityTeleporter() + { + super("Teleporter", 3000000); + inventory = new ItemStack[1]; + code = new Teleporter.Code(0, 0, 0, 0); + + ElectricityConnections.registerConnector(this, EnumSet.allOf(ForgeDirection.class)); + } + + @Override + public void onUpdate() + { + super.onUpdate(); + + if(!worldObj.isRemote) + { + if(Mekanism.teleporters.containsKey(code)) + { + if(!Mekanism.teleporters.get(code).contains(Teleporter.Coords.get(this)) && hasFrame()) + { + Mekanism.teleporters.get(code).add(Teleporter.Coords.get(this)); + } + else if(Mekanism.teleporters.get(code).contains(Teleporter.Coords.get(this)) && !hasFrame()) + { + Mekanism.teleporters.get(code).remove(Teleporter.Coords.get(this)); + } + } + else if(hasFrame()) + { + ArrayList newCoords = new ArrayList(); + newCoords.add(Teleporter.Coords.get(this)); + Mekanism.teleporters.put(code, newCoords); + } + + switch(canTeleport()) + { + case 1: + status = EnumColor.DARK_GREEN + "Ready."; + break; + case 2: + status = EnumColor.DARK_RED + "No frame."; + break; + case 3: + status = EnumColor.DARK_RED + "No link found."; + break; + case 4: + status = EnumColor.DARK_RED + "Links > 2."; + break; + case 5: + status = EnumColor.DARK_RED + "Needs energy."; + break; + case 6: + status = EnumColor.DARK_GREEN + "Idle."; + break; + } + } + + if(powerProvider != null) + { + int received = (int)(powerProvider.useEnergy(0, (float)((MAX_ELECTRICITY-electricityStored)*Mekanism.TO_BC), true)*10); + setJoules(electricityStored + received); + } + + if(!worldObj.isRemote) + { + for(ForgeDirection direction : ForgeDirection.values()) + { + TileEntity tileEntity = Vector3.getTileEntityFromSide(worldObj, new Vector3(this), direction); + if(tileEntity != null) + { + if(tileEntity instanceof IConductor) + { + if(electricityStored < MAX_ELECTRICITY) + { + double electricityNeeded = MAX_ELECTRICITY - electricityStored; + ((IConductor)tileEntity).getNetwork().startRequesting(this, electricityNeeded, electricityNeeded >= getVoltage() ? getVoltage() : electricityNeeded); + setJoules(electricityStored + ((IConductor)tileEntity).getNetwork().consumeElectricity(this).getWatts()); + } + else if(electricityStored >= MAX_ELECTRICITY) + { + ((IConductor)tileEntity).getNetwork().stopRequesting(this); + } + } + } + } + } + + if(inventory[0] != null) + { + if(electricityStored < MAX_ELECTRICITY) + { + if(inventory[0].getItem() instanceof IItemElectric) + { + IItemElectric electricItem = (IItemElectric)inventory[0].getItem(); + + if (electricItem.canProduceElectricity()) + { + double joulesNeeded = MAX_ELECTRICITY-electricityStored; + double joulesReceived = 0; + + if(electricItem.getVoltage(inventory[0]) <= joulesNeeded) + { + joulesReceived = electricItem.onUse(electricItem.getVoltage(inventory[0]), inventory[0]); + } + else if(electricItem.getVoltage(inventory[0]) > joulesNeeded) + { + joulesReceived = electricItem.onUse(joulesNeeded, inventory[0]); + } + + setJoules(electricityStored + joulesReceived); + } + } + else if(inventory[0].getItem() instanceof IElectricItem) + { + IElectricItem item = (IElectricItem)inventory[0].getItem(); + if(item.canProvideEnergy()) + { + double gain = ElectricItem.discharge(inventory[0], (int)((MAX_ELECTRICITY - electricityStored)*Mekanism.TO_IC2), 3, false, false)*Mekanism.FROM_IC2; + setJoules(electricityStored + gain); + } + } + } + if(inventory[0].itemID == Item.redstone.itemID && electricityStored <= (MAX_ELECTRICITY-1000)) + { + setJoules(electricityStored + 1000); + --inventory[0].stackSize; + + if (inventory[0].stackSize <= 0) + { + inventory[0] = null; + } + } + } + } + + /** + * 1: yes + * 2: no frame + * 3: no link found + * 4: too many links + * 5: not enough electricity + * 6: nothing to teleport + * @return + */ + public byte canTeleport() + { + if(!hasFrame()) + { + return 2; + } + + if(!Mekanism.teleporters.containsKey(code) || Mekanism.teleporters.get(code).isEmpty()) + { + return 3; + } + + if(Mekanism.teleporters.get(code).size() > 2) + { + return 4; + } + + if(Mekanism.teleporters.get(code).size() == 2) + { + List entitiesInPortal = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord-1, yCoord, zCoord-1, xCoord+1, yCoord+3, zCoord+1)); + + Teleporter.Coords closestCoords = null; + + for(Teleporter.Coords coords : Mekanism.teleporters.get(code)) + { + if(!coords.equals(Teleporter.Coords.get(this))) + { + closestCoords = coords; + break; + } + } + + int electricityNeeded = 0; + + for(EntityPlayer entity : entitiesInPortal) + { + electricityNeeded += calculateEnergyCost(entity, closestCoords); + } + + if(entitiesInPortal.size() == 0) + { + return 6; + } + + if(electricityStored < electricityNeeded) + { + return 5; + } + + return 1; + } + + return 3; + } + + public void teleport() + { + if(worldObj.isRemote) return; + + List entitiesInPortal = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(xCoord-1, yCoord, zCoord-1, xCoord+1, yCoord+3, zCoord+1)); + + Teleporter.Coords closestCoords = null; + + for(Teleporter.Coords coords : Mekanism.teleporters.get(code)) + { + if(!coords.equals(Teleporter.Coords.get(this))) + { + closestCoords = coords; + break; + } + } + + for(EntityPlayer entity : entitiesInPortal) + { + setJoules(electricityStored - calculateEnergyCost(entity, closestCoords)); + + entity.worldObj.playSoundAtEntity((EntityPlayerMP)entity, "mob.enderman.portal", 1.0F, 1.0F); + + if(entity.worldObj.provider.dimensionId != closestCoords.dimensionId) + { + entity.travelToDimension(closestCoords.dimensionId); + } + + ((EntityPlayerMP)entity).setLocationAndAngles(closestCoords.xCoord, closestCoords.yCoord, closestCoords.zCoord, entity.rotationYaw, entity.rotationPitch); + ((EntityPlayerMP)entity).playerNetServerHandler.setPlayerLocation(closestCoords.xCoord, closestCoords.yCoord, closestCoords.zCoord, entity.rotationYaw, entity.rotationPitch); + + for(Teleporter.Coords coords : Mekanism.teleporters.get(code)) + { + PacketHandler.sendPortalFX(coords.xCoord, coords.yCoord, coords.zCoord, coords.dimensionId); + } + } + } + + @Override + public void invalidate() + { + super.invalidate(); + + if(!worldObj.isRemote) + { + if(Mekanism.teleporters.containsKey(code)) + { + if(Mekanism.teleporters.get(code).contains(Teleporter.Coords.get(this))) + { + Mekanism.teleporters.get(code).remove(Teleporter.Coords.get(this)); + } + + if(Mekanism.teleporters.get(code).isEmpty()) Mekanism.teleporters.remove(code); + } + } + } + + public int calculateEnergyCost(Entity entity, Teleporter.Coords coords) + { + int energyCost = 1000; + + if(entity.worldObj.provider.dimensionId != coords.dimensionId) + { + energyCost+=10000; + } + + int distance = (int)entity.getDistanceSq(coords.xCoord, coords.yCoord, coords.zCoord); + + energyCost+=(distance*10); + + return energyCost; + } + + public boolean hasFrame() + { + if(isFrame(xCoord-1, yCoord, zCoord) && isFrame(xCoord+1, yCoord, zCoord) + && isFrame(xCoord-1, yCoord+1, zCoord) && isFrame(xCoord+1, yCoord+1, zCoord) + && isFrame(xCoord-1, yCoord+2, zCoord) && isFrame(xCoord+1, yCoord+2, zCoord) + && isFrame(xCoord-1, yCoord+3, zCoord) && isFrame(xCoord+1, yCoord+3, zCoord) + && isFrame(xCoord, yCoord+3, zCoord)) {return true;} + if(isFrame(xCoord, yCoord, zCoord-1) && isFrame(xCoord, yCoord, zCoord+1) + && isFrame(xCoord, yCoord+1, zCoord-1) && isFrame(xCoord, yCoord+1, zCoord+1) + && isFrame(xCoord, yCoord+2, zCoord-1) && isFrame(xCoord, yCoord+2, zCoord+1) + && isFrame(xCoord, yCoord+3, zCoord-1) && isFrame(xCoord, yCoord+3, zCoord+1) + && isFrame(xCoord, yCoord+3, zCoord)) {return true;} + return false; + } + + public boolean isFrame(int x, int y, int z) + { + return worldObj.getBlockId(x, y, z) == Mekanism.basicBlockID && worldObj.getBlockMetadata(x, y, z) == 2; + } + + public int getScaledEnergyLevel(int i) + { + return (int)(electricityStored*i / MAX_ELECTRICITY); + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + code.digitOne = nbtTags.getInteger("digitOne"); + code.digitTwo = nbtTags.getInteger("digitTwo"); + code.digitThree = nbtTags.getInteger("digitThree"); + code.digitFour = nbtTags.getInteger("digitFour"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("digitOne", code.digitOne); + nbtTags.setInteger("digitTwo", code.digitTwo); + nbtTags.setInteger("digitThree", code.digitThree); + nbtTags.setInteger("digitFour", code.digitFour); + } + + @Override + public void handlePacketData(INetworkManager network, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) + { + if(!worldObj.isRemote) + { + try { + if(Mekanism.teleporters.containsKey(code)) + { + if(Mekanism.teleporters.get(code).contains(Teleporter.Coords.get(this))) + { + Mekanism.teleporters.get(code).remove(Teleporter.Coords.get(this)); + } + + if(Mekanism.teleporters.get(code).isEmpty()) Mekanism.teleporters.remove(code); + } + + int type = dataStream.readInt(); + + if(type == 0) + { + code.digitOne = dataStream.readInt(); + } + else if(type == 1) + { + code.digitTwo = dataStream.readInt(); + } + else if(type == 2) + { + code.digitThree = dataStream.readInt(); + } + else if(type == 3) + { + code.digitFour = dataStream.readInt(); + } + } catch (Exception e) + { + System.out.println("[Mekanism] Error while handling tile entity packet."); + e.printStackTrace(); + } + return; + } + + try { + facing = dataStream.readInt(); + electricityStored = dataStream.readDouble(); + status = dataStream.readUTF().trim(); + code.digitOne = dataStream.readInt(); + code.digitTwo = dataStream.readInt(); + code.digitThree = dataStream.readInt(); + code.digitFour = dataStream.readInt(); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + worldObj.updateAllLightTypes(xCoord, yCoord, zCoord); + } catch (Exception e) + { + System.out.println("[Mekanism] Error while handling tile entity packet."); + e.printStackTrace(); + } + } + + @Override + public void sendPacket() + { + PacketHandler.sendTileEntityPacketToClients(this, 0, facing, electricityStored, status, code.digitOne, code.digitTwo, code.digitThree, code.digitFour); + } + + @Override + public void sendPacketWithRange() + { + PacketHandler.sendTileEntityPacketToClients(this, 50, facing, electricityStored, status, code.digitOne, code.digitTwo, code.digitThree, code.digitFour); + } + + @Override + public boolean acceptsEnergyFrom(TileEntity emitter, Direction direction) + { + return true; + } + + @Override + public String getType() + { + return getInvName(); + } + + @Override + public String[] getMethodNames() + { + return new String[] {"getStored", "canTeleport", "getMaxEnergy", "getEnergyNeeded", "teleport", "set"}; + } + + @Override + public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception + { + switch(method) + { + case 0: + return new Object[] {electricityStored}; + case 1: + return new Object[] {canTeleport()}; + case 2: + return new Object[] {MAX_ELECTRICITY}; + case 3: + return new Object[] {(MAX_ELECTRICITY-electricityStored)}; + case 4: + teleport(); + return new Object[] {"Attempted to teleport."}; + case 5: + if(!(arguments[0] instanceof Integer) || !(arguments[1] instanceof Integer)) + { + return new Object[] {"Invalid parameters."}; + } + + int digit = (Integer)arguments[0]; + int newDigit = (Integer)arguments[1]; + + switch(digit) + { + case 0: + code.digitOne = newDigit; + break; + case 1: + code.digitTwo = newDigit; + break; + case 2: + code.digitThree = newDigit; + break; + case 3: + code.digitFour = newDigit; + break; + default: + return new Object[] {"No digit found."}; + } + default: + System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID()); + return new Object[] {"Unknown command."}; + } + } + + @Override + public boolean canAttachToSide(int side) + { + return true; + } + + @Override + public void attach(IComputerAccess computer) {} + + @Override + public void detach(IComputerAccess computer) {} + + @Override + public double getVoltage(Object... data) + { + return 120; + } + + @Override + public double getJoules(Object... data) + { + return electricityStored; + } + + @Override + public void setJoules(double joules, Object... data) + { + electricityStored = Math.max(Math.min(joules, getMaxJoules()), 0); + } + + @Override + public double getMaxJoules(Object... data) + { + return MAX_ELECTRICITY; + } + + @Override + public int demandsEnergy() + { + return (int)((MAX_ELECTRICITY - electricityStored)*Mekanism.TO_IC2); + } + + @Override + public int injectEnergy(Direction directionFrom, int amount) + { + double givenEnergy = amount*Mekanism.FROM_IC2; + double rejects = 0; + double neededEnergy = MAX_ELECTRICITY-electricityStored; + + if(givenEnergy < neededEnergy) + { + electricityStored += givenEnergy; + } + else if(givenEnergy > neededEnergy) + { + electricityStored += neededEnergy; + rejects = givenEnergy-neededEnergy; + } + + return (int)(rejects*Mekanism.TO_IC2); + } + + @Override + public int getMaxSafeInput() + { + return 2048; + } +} diff --git a/src/minecraft/mekanism/common/TileEntityTheoreticalElementizer.java b/src/minecraft/mekanism/common/TileEntityTheoreticalElementizer.java index 3de3c3c03..d49bc431b 100644 --- a/src/minecraft/mekanism/common/TileEntityTheoreticalElementizer.java +++ b/src/minecraft/mekanism/common/TileEntityTheoreticalElementizer.java @@ -1,5 +1,6 @@ package mekanism.common; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Random; @@ -9,8 +10,6 @@ import net.minecraft.item.ItemStack; public class TileEntityTheoreticalElementizer extends TileEntityAdvancedElectricMachine { - public static Map recipes = new HashMap(); - public TileEntityTheoreticalElementizer() { super("Elementizer.ogg", "Theoretical Elementizer", "/resources/mekanism/gui/GuiElementizer.png", 50, 1, 1000, 10000, 1000); @@ -19,13 +18,59 @@ public class TileEntityTheoreticalElementizer extends TileEntityAdvancedElectric @Override public Map getRecipes() { - return recipes; + return Collections.synchronizedMap(new HashMap()); } + + @Override + public void operate() + { + if (!canOperate()) + { + return; + } + + ItemStack itemstack = new ItemStack(getRandomMagicItem()); + + inventory[0].stackSize--; + + if (inventory[0].stackSize <= 0) + { + inventory[0] = null; + } + + inventory[2] = itemstack; + } + + @Override + public boolean canOperate() + { + if (inventory[0] == null) + { + return false; + } + + if(electricityStored < ENERGY_PER_TICK) + { + return false; + } + + if(secondaryEnergyStored < SECONDARY_ENERGY_PER_TICK) + { + return false; + } + + if (inventory[2] != null) + { + return false; + } + + return true; + } @Override public int getFuelTicks(ItemStack itemstack) { - if (itemstack.itemID == Item.diamond.shiftedIndex) return 1000; + if (itemstack.itemID == Item.diamond.itemID) return 1000; return 0; } @@ -37,4 +82,4 @@ public class TileEntityTheoreticalElementizer extends TileEntityAdvancedElectric if(random == 1) return Mekanism.WeatherOrb; return Mekanism.EnrichedAlloy; } -} +} \ No newline at end of file diff --git a/src/minecraft/mekanism/common/TileEntityUltimateSmeltingFactory.java b/src/minecraft/mekanism/common/TileEntityUltimateSmeltingFactory.java deleted file mode 100644 index d61778090..000000000 --- a/src/minecraft/mekanism/common/TileEntityUltimateSmeltingFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -package mekanism.common; - -import mekanism.api.Tier.SmeltingFactoryTier; - -public class TileEntityUltimateSmeltingFactory extends TileEntitySmeltingFactory -{ - public TileEntityUltimateSmeltingFactory() - { - super(SmeltingFactoryTier.ULTIMATE); - } -} diff --git a/src/minecraft/mekanism/generators/client/BlockRenderingHandler.java b/src/minecraft/mekanism/generators/client/BlockRenderingHandler.java index 169c2e7fb..361743e70 100644 --- a/src/minecraft/mekanism/generators/client/BlockRenderingHandler.java +++ b/src/minecraft/mekanism/generators/client/BlockRenderingHandler.java @@ -87,7 +87,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler if(!GeneratorType.getFromMetadata(metadata).hasModel) { renderer.renderStandardBlock(block, x, y, z); - renderer.updateCustomBlockBounds(block); + renderer.setRenderBoundsFromBlock(block); return true; } } @@ -126,7 +126,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } - renderer.updateCustomBlockBounds(block); + renderer.setRenderBoundsFromBlock(block); if (renderer.useInventoryTint) { diff --git a/src/minecraft/mekanism/generators/common/BlockGenerator.java b/src/minecraft/mekanism/generators/common/BlockGenerator.java index 6b7575c90..9894283f2 100644 --- a/src/minecraft/mekanism/generators/common/BlockGenerator.java +++ b/src/minecraft/mekanism/generators/common/BlockGenerator.java @@ -23,6 +23,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.vector.Vector3; +import universalelectricity.prefab.implement.IToolConfigurator; import universalelectricity.prefab.multiblock.IMultiBlock; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -89,13 +90,16 @@ public class BlockGenerator extends BlockContainer int height = Math.round(entityliving.rotationPitch); int change = 3; - if(height >= 65) + if(!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel && world.getBlockMetadata(x, y, z) != 1) { - change = 1; - } - else if(height <= -65) - { - change = 0; + if(height >= 65) + { + change = 1; + } + else if(height <= -65) + { + change = 0; + } } else { switch(side) @@ -329,7 +333,7 @@ public class BlockGenerator extends BlockContainer if (slotStack.hasTagCompound()) { - item.func_92014_d().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); + item.getEntityItem().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); } float k = 0.05F; @@ -364,6 +368,7 @@ public class BlockGenerator extends BlockContainer @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) { + TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); int metadata = world.getBlockMetadata(x, y, z); if(world.isRemote) @@ -371,6 +376,33 @@ public class BlockGenerator extends BlockContainer return true; } + if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() instanceof IToolConfigurator) + { + world.notifyBlocksOfNeighborChange(x, y, z, blockID); + ((IToolConfigurator)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, x, y, z); + + int change = 0; + + switch(tileEntity.facing) + { + case 3: + change = 4; + break; + case 4: + change = 5; + break; + case 5: + change = 2; + break; + case 2: + change = 3; + break; + } + + tileEntity.setFacing((short)change); + return true; + } + if(metadata == 3 && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().isItemEqual(new ItemStack(MekanismGenerators.Generator, 1, 2))) { if(((TileEntityBasicBlock)world.getBlockTileEntity(x, y, z)).facing != facing) @@ -378,8 +410,6 @@ public class BlockGenerator extends BlockContainer return false; } } - - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); if (tileEntity != null) { diff --git a/src/minecraft/mekanism/generators/common/ContainerBioGenerator.java b/src/minecraft/mekanism/generators/common/ContainerBioGenerator.java index cf63751ba..80ed9751d 100644 --- a/src/minecraft/mekanism/generators/common/ContainerBioGenerator.java +++ b/src/minecraft/mekanism/generators/common/ContainerBioGenerator.java @@ -62,7 +62,7 @@ public class ContainerBioGenerator extends Container ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.shiftedIndex) + if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.itemID) { if(slotID != 1) { @@ -95,7 +95,7 @@ public class ContainerBioGenerator extends Container } } } - else if(slotStack.itemID == Item.bucketEmpty.shiftedIndex) + else if(slotStack.itemID == Item.bucketEmpty.itemID) { if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { @@ -117,6 +117,12 @@ public class ContainerBioGenerator extends Container return null; } } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } } if (slotStack.stackSize == 0) diff --git a/src/minecraft/mekanism/generators/common/ContainerElectrolyticSeparator.java b/src/minecraft/mekanism/generators/common/ContainerElectrolyticSeparator.java index 0c1221321..a5e95d466 100644 --- a/src/minecraft/mekanism/generators/common/ContainerElectrolyticSeparator.java +++ b/src/minecraft/mekanism/generators/common/ContainerElectrolyticSeparator.java @@ -68,7 +68,7 @@ public class ContainerElectrolyticSeparator extends Container if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) { - if(slotStack.itemID == Item.bucketWater.shiftedIndex) + if(slotStack.itemID == Item.bucketWater.itemID) { if(!mergeItemStack(slotStack, 0, 1, false)) { @@ -124,6 +124,12 @@ public class ContainerElectrolyticSeparator extends Container return null; } } + else { + if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) + { + return null; + } + } } } else { diff --git a/src/minecraft/mekanism/generators/common/ContainerHeatGenerator.java b/src/minecraft/mekanism/generators/common/ContainerHeatGenerator.java index 6b2ceab1d..7547c96fd 100644 --- a/src/minecraft/mekanism/generators/common/ContainerHeatGenerator.java +++ b/src/minecraft/mekanism/generators/common/ContainerHeatGenerator.java @@ -62,7 +62,7 @@ public class ContainerHeatGenerator extends Container ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.shiftedIndex) + if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.itemID) { if(slotID != 1) { @@ -95,7 +95,7 @@ public class ContainerHeatGenerator extends Container } } } - else if(slotStack.itemID == Item.bucketEmpty.shiftedIndex) + else if(slotStack.itemID == Item.bucketEmpty.itemID) { if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { @@ -117,6 +117,12 @@ public class ContainerHeatGenerator extends Container return null; } } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } } if (slotStack.stackSize == 0) diff --git a/src/minecraft/mekanism/generators/common/ContainerHydrogenGenerator.java b/src/minecraft/mekanism/generators/common/ContainerHydrogenGenerator.java index 1420b2a52..7ebc1964e 100644 --- a/src/minecraft/mekanism/generators/common/ContainerHydrogenGenerator.java +++ b/src/minecraft/mekanism/generators/common/ContainerHydrogenGenerator.java @@ -99,13 +99,28 @@ public class ContainerHydrogenGenerator extends Container } } } - else if(slotStack.itemID == Item.bucketEmpty.shiftedIndex) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } + else { + if(slotID >= 2 && slotID <= 28) + { + if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 28) + { + if(!mergeItemStack(slotStack, 2, 28, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) + { + return null; + } + } + } if (slotStack.stackSize == 0) { diff --git a/src/minecraft/mekanism/generators/common/ContainerSolarGenerator.java b/src/minecraft/mekanism/generators/common/ContainerSolarGenerator.java index 84a9de44b..2f8452496 100644 --- a/src/minecraft/mekanism/generators/common/ContainerSolarGenerator.java +++ b/src/minecraft/mekanism/generators/common/ContainerSolarGenerator.java @@ -60,7 +60,7 @@ public class ContainerSolarGenerator extends Container ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); - if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.shiftedIndex) + if(slotStack.getItem() instanceof IItemElectric || slotStack.getItem() instanceof IElectricItem || slotStack.itemID == Item.redstone.itemID) { if(slotID != 0) { @@ -92,6 +92,12 @@ public class ContainerSolarGenerator extends Container return null; } } + else { + if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) + { + return null; + } + } } if (slotStack.stackSize == 0) diff --git a/src/minecraft/mekanism/generators/common/MekanismGenerators.java b/src/minecraft/mekanism/generators/common/MekanismGenerators.java index 652ca818c..68420614e 100644 --- a/src/minecraft/mekanism/generators/common/MekanismGenerators.java +++ b/src/minecraft/mekanism/generators/common/MekanismGenerators.java @@ -19,7 +19,7 @@ import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; -@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "5.0.10", dependencies = "required-after:Mekanism") +@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "5.1.1", dependencies = "required-after:Mekanism") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class MekanismGenerators { diff --git a/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java index 44a508804..38ae594df 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityBioGenerator.java @@ -18,6 +18,7 @@ import net.minecraftforge.liquids.ILiquidTank; import net.minecraftforge.liquids.ITankContainer; import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidTank; +import universalelectricity.core.electricity.ElectricInfo; import universalelectricity.core.implement.IItemElectric; import com.google.common.io.ByteArrayDataInput; @@ -52,32 +53,9 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank if(inventory[1].getItem() instanceof IItemElectric) { IItemElectric electricItem = (IItemElectric)inventory[1].getItem(); - double sendingElectricity = 0; - double actualSendingElectricity = 0; - double rejectedElectricity = 0; - double itemElectricityNeeded = electricItem.getMaxJoules(inventory[1]) - electricItem.getJoules(inventory[1]); - - if(electricItem.getVoltage() <= electricityStored) - { - sendingElectricity = electricItem.getVoltage(); - } - else if(electricItem.getVoltage() > electricityStored) - { - sendingElectricity = electricityStored; - } - - if(sendingElectricity <= itemElectricityNeeded) - { - actualSendingElectricity = sendingElectricity; - } - else if(sendingElectricity > itemElectricityNeeded) - { - rejectedElectricity = sendingElectricity-itemElectricityNeeded; - actualSendingElectricity = itemElectricityNeeded; - } - - electricItem.setJoules((electricItem.getJoules(inventory[1]) + actualSendingElectricity), inventory[1]); - setJoules(electricityStored - Math.max(actualSendingElectricity - rejectedElectricity, 0)); + double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[1])*0.005, electricityStored), getVoltage()), electricityStored); + double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[1]); + setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects)); } else if(inventory[1].getItem() instanceof IElectricItem) { @@ -165,7 +143,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank public int getFuel(ItemStack itemstack) { - return itemstack.itemID == MekanismGenerators.BioFuel.shiftedIndex ? 100 : 0; + return itemstack.itemID == MekanismGenerators.BioFuel.itemID ? 100 : 0; } /** @@ -211,6 +189,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank bioFuelSlot.liquidStored = dataStream.readInt(); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); worldObj.updateAllLightTypes(xCoord, yCoord, zCoord); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, MekanismGenerators.generatorID); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); diff --git a/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java b/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java index 8d2a9ee26..463354eec 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java @@ -157,7 +157,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp if(inventory[0] != null && waterSlot.liquidStored < waterSlot.MAX_LIQUID) { - if(inventory[0].itemID == Item.bucketWater.shiftedIndex) + if(inventory[0].itemID == Item.bucketWater.itemID) { inventory[0] = new ItemStack(Item.bucketEmpty, 1); waterSlot.setLiquid(waterSlot.liquidStored + 1000); @@ -608,7 +608,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } @Override - public void attach(IComputerAccess computer, String computerSide) {} + public void attach(IComputerAccess computer) {} @Override public void detach(IComputerAccess computer) {} diff --git a/src/minecraft/mekanism/generators/common/TileEntityGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityGenerator.java index 64dbfffc5..9087a8e79 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityGenerator.java @@ -77,6 +77,17 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem } catch(NoSuchMethodError e) {} } + if(packetTick == 20) + { + if(ElectricityConnections.isConnector(this)) + { + ElectricityConnections.unregisterConnector(this); + } + + ElectricityConnections.registerConnector(this, EnumSet.of(ForgeDirection.getOrientation(facing))); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, MekanismGenerators.generatorID); + } + if(electricityStored > 0) { TileEntity tileEntity = Vector3.getTileEntityFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(facing)); @@ -117,7 +128,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem if(getJoules() > 0 && outputWatts > 0) { - outputNetwork.startProducing(this, outputWatts / getVoltage(), getVoltage()); + outputNetwork.startProducing(this, (outputWatts / getVoltage()) / 20, getVoltage()); setJoules(electricityStored - outputWatts); } else { @@ -247,7 +258,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem } @Override - public void attach(IComputerAccess computer, String computerSide) {} + public void attach(IComputerAccess computer) {} @Override public void detach(IComputerAccess computer) {} diff --git a/src/minecraft/mekanism/generators/common/TileEntityHeatGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityHeatGenerator.java index 4fa9827df..503f4b6db 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityHeatGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityHeatGenerator.java @@ -19,6 +19,7 @@ import net.minecraftforge.liquids.ILiquidTank; import net.minecraftforge.liquids.ITankContainer; import net.minecraftforge.liquids.LiquidStack; import net.minecraftforge.liquids.LiquidTank; +import universalelectricity.core.electricity.ElectricInfo; import universalelectricity.core.implement.IItemElectric; import com.google.common.io.ByteArrayDataInput; @@ -50,32 +51,9 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan if(inventory[1].getItem() instanceof IItemElectric) { IItemElectric electricItem = (IItemElectric)inventory[1].getItem(); - double sendingElectricity = 0; - double actualSendingElectricity = 0; - double rejectedElectricity = 0; - double itemElectricityNeeded = electricItem.getMaxJoules(inventory[1]) - electricItem.getJoules(inventory[1]); - - if(electricItem.getVoltage(inventory[1]) <= electricityStored) - { - sendingElectricity = electricItem.getVoltage(inventory[1]); - } - else if(electricItem.getVoltage(inventory[1]) > electricityStored) - { - sendingElectricity = electricityStored; - } - - if(sendingElectricity <= itemElectricityNeeded) - { - actualSendingElectricity = sendingElectricity; - } - else if(sendingElectricity > itemElectricityNeeded) - { - rejectedElectricity = sendingElectricity-itemElectricityNeeded; - actualSendingElectricity = itemElectricityNeeded; - } - - electricItem.setJoules((electricItem.getJoules(inventory[1]) + actualSendingElectricity), inventory[1]); - setJoules(electricityStored - Math.max(actualSendingElectricity - rejectedElectricity, 0)); + double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[1])*0.005, electricityStored), getVoltage()), electricityStored); + double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[1]); + setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects)); } else if(inventory[1].getItem() instanceof IElectricItem) { @@ -163,17 +141,17 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan int boost = 0; if(worldObj.getBlockId(xCoord+1, yCoord, zCoord) == 10 || worldObj.getBlockId(xCoord+1, yCoord, zCoord) == 11) - boost+=80; + boost+=10; if(worldObj.getBlockId(xCoord-1, yCoord, zCoord) == 10 || worldObj.getBlockId(xCoord-1, yCoord, zCoord) == 11) - boost+=80; + boost+=10; if(worldObj.getBlockId(xCoord, yCoord+1, zCoord) == 10 || worldObj.getBlockId(xCoord, yCoord+1, zCoord) == 11) - boost+=80; + boost+=10; if(worldObj.getBlockId(xCoord, yCoord-1, zCoord) == 10 || worldObj.getBlockId(xCoord, yCoord-1, zCoord) == 11) - boost+=80; + boost+=10; if(worldObj.getBlockId(xCoord, yCoord, zCoord+1) == 10 || worldObj.getBlockId(xCoord, yCoord, zCoord+1) == 11) - boost+=80; + boost+=10; if(worldObj.getBlockId(xCoord, yCoord, zCoord-1) == 10 || worldObj.getBlockId(xCoord, yCoord, zCoord-1) == 11) - boost+=80; + boost+=10; return boost; } diff --git a/src/minecraft/mekanism/generators/common/TileEntityHydrogenGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityHydrogenGenerator.java index 207721f3f..d2afcad06 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityHydrogenGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityHydrogenGenerator.java @@ -15,6 +15,7 @@ import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.UniversalElectricity; +import universalelectricity.core.electricity.ElectricInfo; import universalelectricity.core.implement.IItemElectric; import com.google.common.io.ByteArrayDataInput; @@ -44,32 +45,9 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements if(inventory[1].getItem() instanceof IItemElectric) { IItemElectric electricItem = (IItemElectric)inventory[1].getItem(); - double sendingElectricity = 0; - double actualSendingElectricity = 0; - double rejectedElectricity = 0; - double itemElectricityNeeded = electricItem.getMaxJoules(inventory[1]) - electricItem.getJoules(inventory[1]); - - if(electricItem.getVoltage() <= electricityStored) - { - sendingElectricity = electricItem.getVoltage(); - } - else if(electricItem.getVoltage() > electricityStored) - { - sendingElectricity = electricityStored; - } - - if(sendingElectricity <= itemElectricityNeeded) - { - actualSendingElectricity = sendingElectricity; - } - else if(sendingElectricity > itemElectricityNeeded) - { - rejectedElectricity = sendingElectricity-itemElectricityNeeded; - actualSendingElectricity = itemElectricityNeeded; - } - - electricItem.setJoules((electricItem.getJoules(inventory[1]) + actualSendingElectricity), inventory[1]); - setJoules(electricityStored - Math.max(actualSendingElectricity - rejectedElectricity, 0)); + double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[1])*0.005, electricityStored), getVoltage()), electricityStored); + double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[1]); + setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects)); } else if(inventory[1].getItem() instanceof IElectricItem) { @@ -217,6 +195,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements isActive = dataStream.readBoolean(); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); worldObj.updateAllLightTypes(xCoord, yCoord, zCoord); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, MekanismGenerators.generatorID); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); diff --git a/src/minecraft/mekanism/generators/common/TileEntitySolarGenerator.java b/src/minecraft/mekanism/generators/common/TileEntitySolarGenerator.java index 973c89718..cad20e9c6 100644 --- a/src/minecraft/mekanism/generators/common/TileEntitySolarGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntitySolarGenerator.java @@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraftforge.common.ForgeDirection; +import universalelectricity.core.electricity.ElectricInfo; import universalelectricity.core.implement.IItemElectric; import com.google.common.io.ByteArrayDataInput; @@ -66,32 +67,9 @@ public class TileEntitySolarGenerator extends TileEntityGenerator if(inventory[0].getItem() instanceof IItemElectric) { IItemElectric electricItem = (IItemElectric)inventory[0].getItem(); - double sendingElectricity = 0; - double actualSendingElectricity = 0; - double rejectedElectricity = 0; - double itemElectricityNeeded = electricItem.getMaxJoules(inventory[0]) - electricItem.getJoules(inventory[0]); - - if(electricItem.getVoltage() <= electricityStored) - { - sendingElectricity = electricItem.getVoltage(); - } - else if(electricItem.getVoltage() > electricityStored) - { - sendingElectricity = electricityStored; - } - - if(sendingElectricity <= itemElectricityNeeded) - { - actualSendingElectricity = sendingElectricity; - } - else if(sendingElectricity > itemElectricityNeeded) - { - rejectedElectricity = sendingElectricity-itemElectricityNeeded; - actualSendingElectricity = itemElectricityNeeded; - } - - electricItem.setJoules((electricItem.getJoules(inventory[0]) + actualSendingElectricity), inventory[0]); - setJoules(electricityStored - Math.max(actualSendingElectricity - rejectedElectricity, 0)); + double ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(inventory[0])*0.005, electricityStored), getVoltage()), electricityStored); + double rejects = electricItem.onReceive(ampsToGive, getVoltage(), inventory[0]); + setJoules(electricityStored - (ElectricInfo.getJoules(ampsToGive, getVoltage(), 1) - rejects)); } else if(inventory[0].getItem() instanceof IElectricItem) { @@ -170,6 +148,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator isActive = dataStream.readBoolean(); seesSun = dataStream.readBoolean(); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, MekanismGenerators.generatorID); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); diff --git a/src/minecraft/mekanism/nei/AdvancedMachineRecipeHandler.java b/src/minecraft/mekanism/nei/AdvancedMachineRecipeHandler.java deleted file mode 100644 index aba4076b1..000000000 --- a/src/minecraft/mekanism/nei/AdvancedMachineRecipeHandler.java +++ /dev/null @@ -1,139 +0,0 @@ -package mekanism.nei; - -import java.awt.Rectangle; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import net.minecraft.item.ItemStack; - -import org.lwjgl.opengl.GL11; - -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.forge.GuiContainerManager; -import codechicken.nei.recipe.TemplateRecipeHandler; - -public abstract class AdvancedMachineRecipeHandler extends TemplateRecipeHandler -{ - int ticksPassed; - - public abstract String getRecipeId(); - - public abstract ItemStack getFuelStack(); - - public abstract Set> getRecipes(); - - @Override - public void drawBackground(GuiContainerManager guimanager, int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - guimanager.bindTextureByName(getGuiTexture()); - guimanager.drawTexturedModalRect(12, 0, 28, 5, 144, 68); - } - - @Override - public void drawExtras(GuiContainerManager guimanager, int i) - { - float f = ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F; - drawProgressBar(guimanager, 63, 34, 176, 0, 24, 7, f, 0); - - f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F; - if(ticksPassed < 20) f = 0.0F; - drawProgressBar(guimanager, 45, 32, 176, 7, 5, 12, f, 3); - - f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; - drawProgressBar(guimanager, 149, 12, 176, 19, 4, 52, f, 3); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - ticksPassed++; - } - - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0])); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(Map.Entry irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe, getFuelStack())); - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } - - @Override - public void loadCraftingRecipes(ItemStack result) - { - for(Map.Entry irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result)) - { - arecipes.add(new CachedIORecipe(irecipe, getFuelStack())); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(Map.Entry irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe, getFuelStack())); - } - } - } - - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public PositionedStack inputStack; - public PositionedStack outputStack; - public PositionedStack fuelStack; - - @Override - public PositionedStack getIngredient() - { - return inputStack; - } - - @Override - public PositionedStack getResult() - { - return outputStack; - } - - @Override - public PositionedStack getOtherStack() - { - return fuelStack; - } - - public CachedIORecipe(ItemStack input, ItemStack output, ItemStack fuel) - { - super(); - inputStack = new PositionedStack(input, 40, 12); - outputStack = new PositionedStack(output, 100, 30); - fuelStack = new PositionedStack(fuel, 40, 48); - } - - public CachedIORecipe(Map.Entry recipe, ItemStack fuel) - { - this((ItemStack)recipe.getKey(), (ItemStack)recipe.getValue(), fuel); - } - } -} diff --git a/src/minecraft/mekanism/nei/CombinerRecipeHandler.java b/src/minecraft/mekanism/nei/CombinerRecipeHandler.java deleted file mode 100644 index 35ba7ab65..000000000 --- a/src/minecraft/mekanism/nei/CombinerRecipeHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -package mekanism.nei; - -import java.util.List; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - -import mekanism.client.GuiAdvancedElectricMachine; -import mekanism.common.TileEntityCombiner; - -public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return "Combiner"; - } - - @Override - public String getRecipeId() - { - return "mekanism.combiner"; - } - - @Override - public String getOverlayIdentifier() - { - return "combiner"; - } - - @Override - public Set getRecipes() - { - return TileEntityCombiner.recipes.entrySet(); - } - - @Override - public String getGuiTexture() - { - return "/resources/mekanism/gui/GuiCombiner.png"; - } - - @Override - public ItemStack getFuelStack() - { - return new ItemStack(Block.cobblestone); - } - - @Override - public Class getGuiClass() - { - return GuiAdvancedElectricMachine.class; - } -} diff --git a/src/minecraft/mekanism/nei/CrusherRecipeHandler.java b/src/minecraft/mekanism/nei/CrusherRecipeHandler.java deleted file mode 100644 index 1ca9083e6..000000000 --- a/src/minecraft/mekanism/nei/CrusherRecipeHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -package mekanism.nei; - -import java.util.Set; - -import mekanism.client.GuiElectricMachine; -import mekanism.common.TileEntityCrusher; - -public class CrusherRecipeHandler extends MachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return "Crusher"; - } - - @Override - public String getRecipeId() - { - return "mekanism.crusher"; - } - - @Override - public String getOverlayIdentifier() - { - return "crusher"; - } - - @Override - public Set getRecipes() - { - return TileEntityCrusher.recipes.entrySet(); - } - - @Override - public String getGuiTexture() - { - return "/resources/mekanism/gui/GuiCrusher.png"; - } - - @Override - public Class getGuiClass() - { - return GuiElectricMachine.class; - } -} diff --git a/src/minecraft/mekanism/nei/EnrichmentChamberRecipeHandler.java b/src/minecraft/mekanism/nei/EnrichmentChamberRecipeHandler.java deleted file mode 100644 index 2d4f69a23..000000000 --- a/src/minecraft/mekanism/nei/EnrichmentChamberRecipeHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -package mekanism.nei; - -import java.util.Set; - -import mekanism.client.GuiElectricMachine; -import mekanism.common.TileEntityEnrichmentChamber; - -public class EnrichmentChamberRecipeHandler extends MachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return "Enrichment Chamber"; - } - - @Override - public String getRecipeId() - { - return "mekanism.chamber"; - } - - @Override - public String getOverlayIdentifier() - { - return "chamber"; - } - - @Override - public Set getRecipes() - { - return TileEntityEnrichmentChamber.recipes.entrySet(); - } - - @Override - public String getGuiTexture() - { - return "/resources/mekanism/gui/GuiChamber.png"; - } - - @Override - public Class getGuiClass() - { - return GuiElectricMachine.class; - } -} diff --git a/src/minecraft/mekanism/nei/MachineRecipeHandler.java b/src/minecraft/mekanism/nei/MachineRecipeHandler.java deleted file mode 100644 index 3632d39e3..000000000 --- a/src/minecraft/mekanism/nei/MachineRecipeHandler.java +++ /dev/null @@ -1,124 +0,0 @@ -package mekanism.nei; - -import java.awt.Rectangle; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import net.minecraft.item.ItemStack; - -import org.lwjgl.opengl.GL11; - -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.forge.GuiContainerManager; -import codechicken.nei.recipe.TemplateRecipeHandler; - -public abstract class MachineRecipeHandler extends TemplateRecipeHandler -{ - int ticksPassed; - - public abstract String getRecipeId(); - - public abstract Set> getRecipes(); - - @Override - public void drawBackground(GuiContainerManager guimanager, int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - guimanager.bindTextureByName(getGuiTexture()); - guimanager.drawTexturedModalRect(12, 0, 28, 5, 144, 68); - } - - @Override - public void drawExtras(GuiContainerManager guimanager, int i) - { - float f = ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; - drawProgressBar(guimanager, 63, 34, 176, 0, 24, 7, f, 0); - f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; - drawProgressBar(guimanager, 149, 12, 176, 7, 4, 52, f, 3); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - ticksPassed++; - } - - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0])); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(Map.Entry irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } - - @Override - public void loadCraftingRecipes(ItemStack result) - { - for(Map.Entry irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getValue(), result)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(Map.Entry irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getKey(), ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public PositionedStack input; - public PositionedStack output; - - @Override - public PositionedStack getIngredient() - { - return input; - } - - @Override - public PositionedStack getResult() - { - return output; - } - - public CachedIORecipe(ItemStack itemstack, ItemStack itemstack1) - { - super(); - input = new PositionedStack(itemstack, 40, 12); - output = new PositionedStack(itemstack1, 100, 30); - } - - public CachedIORecipe(Map.Entry recipe) - { - this((ItemStack)recipe.getKey(), (ItemStack)recipe.getValue()); - } - } -} diff --git a/src/minecraft/mekanism/nei/MetallurgicInfuserRecipeHandler.java b/src/minecraft/mekanism/nei/MetallurgicInfuserRecipeHandler.java deleted file mode 100644 index cfb98c723..000000000 --- a/src/minecraft/mekanism/nei/MetallurgicInfuserRecipeHandler.java +++ /dev/null @@ -1,181 +0,0 @@ -package mekanism.nei; - -import java.awt.Rectangle; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import mekanism.api.InfusionInput; -import mekanism.api.InfusionOutput; -import mekanism.api.InfusionType; -import mekanism.client.GuiMetallurgicInfuser; -import mekanism.common.Mekanism; -import mekanism.common.TileEntityMetallurgicInfuser; -import net.minecraft.item.ItemStack; - -import org.lwjgl.opengl.GL11; - -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.forge.GuiContainerManager; -import codechicken.nei.recipe.TemplateRecipeHandler; - -public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler -{ - int ticksPassed; - - @Override - public String getRecipeName() - { - return "Metallurgic Infuser"; - } - - @Override - public String getOverlayIdentifier() - { - return "infuser"; - } - - @Override - public String getGuiTexture() - { - return "/resources/mekanism/gui/GuiMetallurgicInfuser.png"; - } - - @Override - public Class getGuiClass() - { - return GuiMetallurgicInfuser.class; - } - - public String getRecipeId() - { - return "mekanism.infuser"; - } - - public ItemStack getInfuseStack(InfusionType type) - { - return type == InfusionType.COAL ? new ItemStack(Mekanism.CompressedCarbon) : new ItemStack(Mekanism.Dust, 1, 7); - } - - public Set> getRecipes() - { - return TileEntityMetallurgicInfuser.recipes.entrySet(); - } - - @Override - public void drawBackground(GuiContainerManager guimanager, int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - guimanager.bindTextureByName(getGuiTexture()); - guimanager.drawTexturedModalRect(0, 0, 5, 5, 166, 78); - } - - @Override - public void drawExtras(GuiContainerManager guimanager, int i) - { - float f = ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F; - drawProgressBar(guimanager, 67, 42, 176, 104, 32, 8, f, 0); - - f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F; - if(ticksPassed < 20) f = 0.0F; - int infuseX = 176 + (getOtherStacks(i).get(0).item.isItemEqual(new ItemStack(Mekanism.CompressedCarbon)) ? 4 : 0); - int infuseY = getOtherStacks(i).get(0).item.isItemEqual(new ItemStack(Mekanism.CompressedCarbon)) ? 0 : 52; - - drawProgressBar(guimanager, 2, 22, infuseX, infuseY, 4, 52, f, 3); - - f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; - drawProgressBar(guimanager, 160, 12, 176, 0, 4, 52, f, 3); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - ticksPassed++; - } - - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(67, 42, 32, 8), getRecipeId(), new Object[0])); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(Map.Entry irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe, getInfuseStack(((InfusionInput)irecipe.getKey()).infusionType))); - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } - - @Override - public void loadCraftingRecipes(ItemStack result) - { - for(Map.Entry irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(((InfusionOutput)irecipe.getValue()).resource, result)) - { - arecipes.add(new CachedIORecipe(irecipe, getInfuseStack(((InfusionInput)irecipe.getKey()).infusionType))); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(Map.Entry irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(((InfusionInput)irecipe.getKey()).inputSlot, ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe, getInfuseStack(((InfusionInput)irecipe.getKey()).infusionType))); - } - } - } - - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public PositionedStack inputStack; - public PositionedStack outputStack; - public PositionedStack infuseStack; - - @Override - public PositionedStack getIngredient() - { - return inputStack; - } - - @Override - public PositionedStack getResult() - { - return outputStack; - } - - @Override - public PositionedStack getOtherStack() - { - return infuseStack; - } - - public CachedIORecipe(ItemStack input, ItemStack output, ItemStack infuse) - { - super(); - inputStack = new PositionedStack(input, 46, 38); - outputStack = new PositionedStack(output, 104, 38); - infuseStack = new PositionedStack(infuse, 12, 30); - } - - public CachedIORecipe(Map.Entry recipe, ItemStack infuse) - { - this(((InfusionInput)recipe.getKey()).inputSlot, ((InfusionOutput)recipe.getValue()).resource, infuse); - } - } -} diff --git a/src/minecraft/mekanism/nei/NEIMekanismConfig.java b/src/minecraft/mekanism/nei/NEIMekanismConfig.java deleted file mode 100644 index 15de8c160..000000000 --- a/src/minecraft/mekanism/nei/NEIMekanismConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -package mekanism.nei; - -import codechicken.nei.api.API; -import codechicken.nei.api.IConfigureNEI; - -public class NEIMekanismConfig implements IConfigureNEI -{ - @Override - public void loadConfig() - { - API.registerRecipeHandler(new EnrichmentChamberRecipeHandler()); - API.registerUsageHandler(new EnrichmentChamberRecipeHandler()); - API.registerRecipeHandler(new PlatinumCompressorRecipeHandler()); - API.registerUsageHandler(new PlatinumCompressorRecipeHandler()); - API.registerRecipeHandler(new CrusherRecipeHandler()); - API.registerUsageHandler(new CrusherRecipeHandler()); - API.registerRecipeHandler(new CombinerRecipeHandler()); - API.registerUsageHandler(new CombinerRecipeHandler()); - API.registerRecipeHandler(new MetallurgicInfuserRecipeHandler()); - API.registerUsageHandler(new MetallurgicInfuserRecipeHandler()); - } - - @Override - public String getName() - { - return "Mekanism NEI Plugin"; - } - - @Override - public String getVersion() - { - return "1.0.0"; - } -} diff --git a/src/minecraft/mekanism/nei/PlatinumCompressorRecipeHandler.java b/src/minecraft/mekanism/nei/PlatinumCompressorRecipeHandler.java deleted file mode 100644 index 6bcf1dbf2..000000000 --- a/src/minecraft/mekanism/nei/PlatinumCompressorRecipeHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -package mekanism.nei; - -import java.util.Set; - -import net.minecraft.item.ItemStack; - -import mekanism.client.GuiAdvancedElectricMachine; -import mekanism.common.Mekanism; -import mekanism.common.TileEntityPlatinumCompressor; - -public class PlatinumCompressorRecipeHandler extends AdvancedMachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return "Platinum Compressor"; - } - - @Override - public String getRecipeId() - { - return "mekanism.compressor"; - } - - @Override - public String getOverlayIdentifier() - { - return "compressor"; - } - - @Override - public Set getRecipes() - { - return TileEntityPlatinumCompressor.recipes.entrySet(); - } - - @Override - public String getGuiTexture() - { - return "/resources/mekanism/gui/GuiCompressor.png"; - } - - @Override - public ItemStack getFuelStack() - { - return new ItemStack(Mekanism.Ingot, 1, 1); - } - - @Override - public Class getGuiClass() - { - return GuiAdvancedElectricMachine.class; - } -} diff --git a/src/minecraft/mekanism/tools/common/MekanismTools.java b/src/minecraft/mekanism/tools/common/MekanismTools.java index 167511b08..9f1f2c138 100644 --- a/src/minecraft/mekanism/tools/common/MekanismTools.java +++ b/src/minecraft/mekanism/tools/common/MekanismTools.java @@ -26,7 +26,7 @@ import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; -@Mod(modid = "MekanismTools", name = "MekanismTools", version = "5.0.10", dependencies = "required-after:Mekanism") +@Mod(modid = "MekanismTools", name = "MekanismTools", version = "5.1.1", dependencies = "required-after:Mekanism") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class MekanismTools {