From f745e84d31753c7161db8b2e4bbea12bd7c03e8d Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Mon, 11 Mar 2013 13:49:01 -0400 Subject: [PATCH] v5.4.1 Release Final build for 1.4.7. *Cleaned up imports. *Added javadocs and cleaned up code. *API improvements and fixes. *Changed around packages and finalized API. *Fixed auto-download feature. *Removed UE implementation of multiblock, added my own. *Better Obsidian TNT code. *Better Atomic Assembler efficiency modes. *Made gas storage tanks more CPU efficient. *Better version control. *Added RecipeHelper for reflective implementations of recipes. *Reduced Osmium generation. *Fixed upgrade bug. *Pressurized Tube doesn't function when receiving a redstone signal. *Better Advanced Solar Generator code. *HP information for hoes. *Lowered chance of mobs spawning with armor. *InfuseRegistry for adding new infuse objects. *GasTransmission for external gas transmission. --- .../mekanism/{common => api}/EnumColor.java | 2 +- .../{common => api}/GasTransferProtocol.java | 9 +- .../mekanism/api/GasTransmission.java | 104 +++++++++++++++ src/minecraft/mekanism/api/ITileNetwork.java | 4 - .../mekanism/api/InfuseRegistry.java | 32 +++++ src/minecraft/mekanism/api/ItemRetriever.java | 5 + src/minecraft/mekanism/api/RecipeHelper.java | 104 +++++++++++++++ src/minecraft/mekanism/api/SideData.java | 1 - src/minecraft/mekanism/api/TabProxy.java | 5 +- .../mekanism/client/GuiControlPanel.java | 2 +- src/minecraft/mekanism/client/GuiCredits.java | 13 +- .../client/GuiTheoreticalElementizer.java | 2 +- .../mekanism/client/ItemRenderingHandler.java | 4 +- .../client/RenderPressurizedTube.java | 5 +- .../mekanism/client/SoundHandler.java | 10 +- .../mekanism/client/ThreadClientUpdate.java | 32 +++-- .../mekanism/common/BlockBounding.java | 90 +++++++++++++ .../mekanism/common/BlockMachine.java | 5 + .../mekanism/common/BlockPressurizedTube.java | 3 +- .../mekanism/common/CommandMekanism.java | 1 + .../mekanism/common/CommonProxy.java | 2 +- .../mekanism/common/EntityObsidianTNT.java | 36 +++--- .../mekanism/common/IBoundingBlock.java | 14 ++ .../common/ItemAtomicDisassembler.java | 29 +++-- .../mekanism/common/ItemConfigurator.java | 1 + .../mekanism/common/ItemElectricBow.java | 1 + .../common/ItemPortableTeleporter.java | 1 + .../mekanism/common/ItemStorageTank.java | 4 +- src/minecraft/mekanism/common/Mekanism.java | 23 ++-- .../mekanism/common/MekanismUtils.java | 121 ++++-------------- src/minecraft/mekanism/common/OreHandler.java | 4 +- .../mekanism/common/PacketHandler.java | 3 +- .../mekanism/common/RecipeHandler.java | 6 +- .../TileEntityAdvancedElectricMachine.java | 3 +- .../TileEntityAdvancedSmeltingFactory.java | 1 + .../common/TileEntityBoundingBlock.java | 88 +++++++++++++ .../common/TileEntityElectricMachine.java | 3 +- .../TileEntityEliteSmeltingFactory.java | 1 + .../mekanism/common/TileEntityGasTank.java | 3 +- .../common/TileEntityMetallurgicInfuser.java | 3 +- .../common/TileEntityPressurizedTube.java | 2 +- .../common/TileEntitySmeltingFactory.java | 3 +- .../mekanism/common/TileEntityTeleporter.java | 1 + .../generators/common/BlockGenerator.java | 30 +---- .../generators/common/MekanismGenerators.java | 2 +- .../TileEntityAdvancedSolarGenerator.java | 26 +--- .../TileEntityElectrolyticSeparator.java | 15 +-- .../mekanism/nei/NEIMekanismConfig.java | 2 +- .../tools/common/ItemMekanismHoe.java | 20 ++- .../mekanism/tools/common/MekanismTools.java | 4 +- 50 files changed, 619 insertions(+), 266 deletions(-) rename src/minecraft/mekanism/{common => api}/EnumColor.java (97%) rename src/minecraft/mekanism/{common => api}/GasTransferProtocol.java (90%) create mode 100644 src/minecraft/mekanism/api/GasTransmission.java create mode 100644 src/minecraft/mekanism/api/InfuseRegistry.java create mode 100644 src/minecraft/mekanism/api/RecipeHelper.java create mode 100644 src/minecraft/mekanism/common/BlockBounding.java create mode 100644 src/minecraft/mekanism/common/IBoundingBlock.java create mode 100644 src/minecraft/mekanism/common/TileEntityBoundingBlock.java diff --git a/src/minecraft/mekanism/common/EnumColor.java b/src/minecraft/mekanism/api/EnumColor.java similarity index 97% rename from src/minecraft/mekanism/common/EnumColor.java rename to src/minecraft/mekanism/api/EnumColor.java index 01110427e..7e75e8ee8 100644 --- a/src/minecraft/mekanism/common/EnumColor.java +++ b/src/minecraft/mekanism/api/EnumColor.java @@ -1,4 +1,4 @@ -package mekanism.common; +package mekanism.api; /** * Simple color enum for adding colors to in-game GUI strings of text. diff --git a/src/minecraft/mekanism/common/GasTransferProtocol.java b/src/minecraft/mekanism/api/GasTransferProtocol.java similarity index 90% rename from src/minecraft/mekanism/common/GasTransferProtocol.java rename to src/minecraft/mekanism/api/GasTransferProtocol.java index b598a0853..550b2298a 100644 --- a/src/minecraft/mekanism/common/GasTransferProtocol.java +++ b/src/minecraft/mekanism/api/GasTransferProtocol.java @@ -1,11 +1,9 @@ -package mekanism.common; +package mekanism.api; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import mekanism.api.EnumGas; -import mekanism.api.IGasAcceptor; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; @@ -45,7 +43,7 @@ public class GasTransferProtocol */ public void loopThrough(TileEntity tile) { - IGasAcceptor[] acceptors = MekanismUtils.getConnectedAcceptors(tile); + IGasAcceptor[] acceptors = GasTransmission.getConnectedAcceptors(tile); for(IGasAcceptor acceptor : acceptors) { @@ -60,7 +58,7 @@ public class GasTransferProtocol iteratedTubes.add(tile); - TileEntity[] tubes = MekanismUtils.getConnectedTubes(tile); + TileEntity[] tubes = GasTransmission.getConnectedTubes(tile); for(TileEntity tube : tubes) { @@ -84,7 +82,6 @@ public class GasTransferProtocol if(!availableAcceptors.isEmpty()) { - boolean sentRemaining = false; int divider = availableAcceptors.size(); int remaining = gasToSend % divider; int sending = (gasToSend-remaining)/divider; diff --git a/src/minecraft/mekanism/api/GasTransmission.java b/src/minecraft/mekanism/api/GasTransmission.java new file mode 100644 index 000000000..a55b4f64b --- /dev/null +++ b/src/minecraft/mekanism/api/GasTransmission.java @@ -0,0 +1,104 @@ +package mekanism.api; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; +import universalelectricity.core.vector.Vector3; + +public class GasTransmission +{ + /** + * Gets all the tubes around a tile entity. + * @param tileEntity - center tile entity + * @return array of TileEntities + */ + public static TileEntity[] getConnectedTubes(TileEntity tileEntity) + { + TileEntity[] tubes = new TileEntity[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.values()) + { + if(orientation != ForgeDirection.UNKNOWN) + { + TileEntity tube = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation); + + if(tube instanceof IPressurizedTube && ((IPressurizedTube)tube).canTransferGas()) + { + tubes[orientation.ordinal()] = tube; + } + } + } + + return tubes; + } + + /** + * Gets all the acceptors around a tile entity. + * @param tileEntity - center tile entity + * @return array of IGasAcceptors + */ + public static IGasAcceptor[] getConnectedAcceptors(TileEntity tileEntity) + { + IGasAcceptor[] acceptors = new IGasAcceptor[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.values()) + { + if(orientation != ForgeDirection.UNKNOWN) + { + TileEntity acceptor = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation); + + if(acceptor instanceof IGasAcceptor) + { + acceptors[orientation.ordinal()] = (IGasAcceptor)acceptor; + } + } + } + + return acceptors; + } + + /** + * Gets all the tube connections around a tile entity. + * @param tileEntity - center tile entity + * @return array of ITubeConnections + */ + public static ITubeConnection[] getConnections(TileEntity tileEntity) + { + ITubeConnection[] connections = new ITubeConnection[] {null, null, null, null, null, null}; + + for(ForgeDirection orientation : ForgeDirection.values()) + { + if(orientation != ForgeDirection.UNKNOWN) + { + TileEntity connection = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation); + + if(connection instanceof ITubeConnection) + { + connections[orientation.ordinal()] = (ITubeConnection)connection; + } + } + } + + return connections; + } + + /** + * Emits a defined gas to the network. + * @param type - gas type to send + * @param amount - amount of gas to send + * @param sender - the sender of the gas + * @param facing - side the sender is outputting from + * @return rejected gas + */ + public static int emitGasToNetwork(EnumGas type, int amount, TileEntity sender, ForgeDirection facing) + { + TileEntity pointer = Vector3.getTileEntityFromSide(sender.worldObj, new Vector3(sender.xCoord, sender.yCoord, sender.zCoord), facing); + + if(pointer != null) + { + GasTransferProtocol calculation = new GasTransferProtocol(pointer, type, amount); + return calculation.calculate(); + } + + return amount; + } +} diff --git a/src/minecraft/mekanism/api/ITileNetwork.java b/src/minecraft/mekanism/api/ITileNetwork.java index 1c76487aa..6eea8dd78 100644 --- a/src/minecraft/mekanism/api/ITileNetwork.java +++ b/src/minecraft/mekanism/api/ITileNetwork.java @@ -2,10 +2,6 @@ package mekanism.api; import java.util.ArrayList; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet250CustomPayload; - import com.google.common.io.ByteArrayDataInput; /** diff --git a/src/minecraft/mekanism/api/InfuseRegistry.java b/src/minecraft/mekanism/api/InfuseRegistry.java new file mode 100644 index 000000000..c64197f5d --- /dev/null +++ b/src/minecraft/mekanism/api/InfuseRegistry.java @@ -0,0 +1,32 @@ +package mekanism.api; + +import java.lang.reflect.Field; +import java.util.HashMap; + +import net.minecraft.item.ItemStack; + +public class InfuseRegistry +{ + /** + * Registers a block or item that serves as an infuse object. An infuse object will store a certain type and amount of infuse, + * and will deliver this amount to the Metallurgic Infuser's buffer of infuse. The item's stack size will be decremented when + * it is placed in the Metallurgic Infuser's infuse slot, and the machine can accept the type and amount of infuse stored in the + * object. + * @param itemStack - stack the infuse object is linked to -- stack size is ignored + * @param infuseObject - the infuse object with the type and amount data + * @return whether or not the registration was successful + */ + public boolean registerInfuseObject(ItemStack itemStack, InfuseObject infuseObject) + { + try { + Class c = Class.forName("mekanism.common.Mekanism"); + Field field = c.getField("infusions"); + HashMap map = (HashMap)field.get(null); + map.put(itemStack, infuseObject); + return true; + } catch(Exception e) { + System.err.println("[Mekanism] Error while adding infuse object: " + e.getMessage()); + return false; + } + } +} diff --git a/src/minecraft/mekanism/api/ItemRetriever.java b/src/minecraft/mekanism/api/ItemRetriever.java index 0b94fba0e..2fac51e0a 100644 --- a/src/minecraft/mekanism/api/ItemRetriever.java +++ b/src/minecraft/mekanism/api/ItemRetriever.java @@ -1,5 +1,6 @@ package mekanism.api; +import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -55,6 +56,10 @@ public final class ItemRetriever { return new ItemStack((Item)ret, 1); } + else if(ret instanceof Block) + { + return new ItemStack((Block)ret, 1); + } else { return null; } diff --git a/src/minecraft/mekanism/api/RecipeHelper.java b/src/minecraft/mekanism/api/RecipeHelper.java new file mode 100644 index 000000000..428b27a5d --- /dev/null +++ b/src/minecraft/mekanism/api/RecipeHelper.java @@ -0,0 +1,104 @@ +package mekanism.api; + +import java.lang.reflect.Method; + +import net.minecraft.item.ItemStack; + +public class RecipeHelper +{ + /** + * Add an Enrichment Chamber recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addEnrichmentChamberRecipe(ItemStack input, ItemStack output) + { + try { + Class recipeClass = Class.forName("mekanism.common.RecipeHandler"); + Method m = recipeClass.getMethod("addEnrichmentChamberRecipe", ItemStack.class, ItemStack.class); + m.invoke(null, input, output); + } catch(Exception e) { + System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); + } + } + + /** + * Add an Osmium Compressor recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addOsmiumCompressorRecipe(ItemStack input, ItemStack output) + { + try { + Class recipeClass = Class.forName("mekanism.common.RecipeHandler"); + Method m = recipeClass.getMethod("addOsmiumCompressorRecipe", ItemStack.class, ItemStack.class); + m.invoke(null, input, output); + } catch(Exception e) { + System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); + } + } + + /** + * Add a Combiner recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addCombinerRecipe(ItemStack input, ItemStack output) + { + try { + Class recipeClass = Class.forName("mekanism.common.RecipeHandler"); + Method m = recipeClass.getMethod("addCombinerRecipe", ItemStack.class, ItemStack.class); + m.invoke(null, input, output); + } catch(Exception e) { + System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); + } + } + + /** + * Add a Crusher recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addCrusherRecipe(ItemStack input, ItemStack output) + { + try { + Class recipeClass = Class.forName("mekanism.common.RecipeHandler"); + Method m = recipeClass.getMethod("addCrusherRecipe", ItemStack.class, ItemStack.class); + m.invoke(null, input, output); + } catch(Exception e) { + System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); + } + } + + /** + * Add a Purification Chamber recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addPurificationChamberRecipe(ItemStack input, ItemStack output) + { + try { + Class recipeClass = Class.forName("mekanism.common.RecipeHandler"); + Method m = recipeClass.getMethod("addPurificationChamberRecipe", ItemStack.class, ItemStack.class); + m.invoke(null, input, output); + } catch(Exception e) { + System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); + } + } + + /** + * Add a Metallurgic Infuser recipe. + * @param input - input Infusion + * @param output - output ItemStack + */ + public static void addMetallurgicInfuserRecipe(InfusionInput input, ItemStack output) + { + try { + Class recipeClass = Class.forName("mekanism.common.RecipeHandler"); + Method m = recipeClass.getMethod("addMetallurgicInfuserRecipe", InfusionInput.class, ItemStack.class); + m.invoke(null, input, output); + } catch(Exception e) { + System.err.println("[Mekanism] Error while adding recipe: " + e.getMessage()); + } + } +} diff --git a/src/minecraft/mekanism/api/SideData.java b/src/minecraft/mekanism/api/SideData.java index 81c4b4590..25e22a1c5 100644 --- a/src/minecraft/mekanism/api/SideData.java +++ b/src/minecraft/mekanism/api/SideData.java @@ -1,6 +1,5 @@ package mekanism.api; -import mekanism.common.EnumColor; public class SideData { diff --git a/src/minecraft/mekanism/api/TabProxy.java b/src/minecraft/mekanism/api/TabProxy.java index c5ab5dcf5..9fb828dbd 100644 --- a/src/minecraft/mekanism/api/TabProxy.java +++ b/src/minecraft/mekanism/api/TabProxy.java @@ -32,9 +32,8 @@ public final class TabProxy { return (CreativeTabs)ret; } - else { - return preferred; - } + + return preferred; } catch(Exception e) { System.err.println("[Mekanism] Error retrieving Mekanism creative tab."); return preferred; diff --git a/src/minecraft/mekanism/client/GuiControlPanel.java b/src/minecraft/mekanism/client/GuiControlPanel.java index b4f6e43a9..231ac2035 100644 --- a/src/minecraft/mekanism/client/GuiControlPanel.java +++ b/src/minecraft/mekanism/client/GuiControlPanel.java @@ -1,7 +1,7 @@ package mekanism.client; +import mekanism.api.EnumColor; import mekanism.api.IAccessibleGui; -import mekanism.common.EnumColor; import mekanism.common.PacketHandler; import mekanism.common.TileEntityControlPanel; import net.minecraft.client.gui.GuiButton; diff --git a/src/minecraft/mekanism/client/GuiCredits.java b/src/minecraft/mekanism/client/GuiCredits.java index 106b6bf56..59b13ead0 100644 --- a/src/minecraft/mekanism/client/GuiCredits.java +++ b/src/minecraft/mekanism/client/GuiCredits.java @@ -1,6 +1,6 @@ package mekanism.client; -import mekanism.common.EnumColor; +import mekanism.api.EnumColor; import mekanism.common.Mekanism; import mekanism.common.MekanismUtils; import net.minecraft.client.gui.GuiButton; @@ -16,6 +16,7 @@ public class GuiCredits extends GuiScreen { controlList.clear(); 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")); + ((GuiButton)controlList.get(0)).enabled = !MekanismUtils.isNotOutdated(); } @Override @@ -43,11 +44,13 @@ public class GuiCredits extends GuiScreen { } if(guibutton.id == 0) { - if(!MekanismUtils.isLatestVersion()) + if(!MekanismUtils.isNotOutdated()) { updateProgress = "Downloading latest version..."; guibutton.enabled = false; - new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/Mekanism.jar"); + new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/Mekanism-v" + Mekanism.latestVersionNumber + ".jar", 0); + new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/MekanismGenerators-v" + Mekanism.latestVersionNumber + ".jar", 1); + new ThreadClientUpdate("http://dl.dropbox.com/u/90411166/MekanismTools-v" + Mekanism.latestVersionNumber + ".jar", 2); } else { updateProgress = "You already have the latest version."; @@ -75,11 +78,11 @@ public class GuiCredits extends GuiScreen { { drawDefaultBackground(); drawCenteredString(fontRenderer, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff); - writeText(EnumColor.GREY + "Your version: " + (MekanismUtils.isLatestVersion() ? Mekanism.versionNumber.toString() : EnumColor.DARK_RED + Mekanism.versionNumber.toString()) + EnumColor.GREY + " -- OUTDATED", 36); + writeText(EnumColor.GREY + "Your version: " + (MekanismUtils.isNotOutdated() ? Mekanism.versionNumber : EnumColor.DARK_RED + Mekanism.versionNumber.toString() + EnumColor.GREY + " -- OUTDATED"), 36); writeText(EnumColor.GREY + "Newest version: " + Mekanism.latestVersionNumber, 45); writeText(EnumColor.GREY + "*Developed on Mac OS X 10.8 Mountain Lion", 63); writeText(EnumColor.GREY + "*Code, textures, and ideas by aidancbrady", 72); - writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + Mekanism.recentNews, 81); + writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + (!Mekanism.recentNews.contains("null") ? Mekanism.recentNews : "couldn't access."), 81); writeText(EnumColor.GREY + updateProgress, 99); super.drawScreen(i, j, f); } diff --git a/src/minecraft/mekanism/client/GuiTheoreticalElementizer.java b/src/minecraft/mekanism/client/GuiTheoreticalElementizer.java index 8bbf5c6ab..5568c03e2 100644 --- a/src/minecraft/mekanism/client/GuiTheoreticalElementizer.java +++ b/src/minecraft/mekanism/client/GuiTheoreticalElementizer.java @@ -1,6 +1,6 @@ package mekanism.client; -import mekanism.common.EnumColor; +import mekanism.api.EnumColor; import mekanism.common.MekanismUtils; import mekanism.common.TileEntityTheoreticalElementizer; import net.minecraft.entity.player.InventoryPlayer; diff --git a/src/minecraft/mekanism/client/ItemRenderingHandler.java b/src/minecraft/mekanism/client/ItemRenderingHandler.java index d3bee6947..47e2deb9f 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.ELITE ? 2 : 0))); + renderItem((RenderBlocks)data[0], tier == EnergyCubeTier.BASIC ? 0 : (tier == EnergyCubeTier.ADVANCED ? 1 : (tier == EnergyCubeTier.ELITE ? 2 : 3))); } } @@ -57,7 +57,7 @@ public class ItemRenderingHandler implements IItemRenderer renderer.setRenderBoundsFromBlock(block); block.setBlockBoundsForItemRender(); - if (renderer.useInventoryTint) + if(renderer.useInventoryTint) { int renderColor = block.getRenderColor(metadata); float red = (float)(renderColor >> 16 & 255) / 255.0F; diff --git a/src/minecraft/mekanism/client/RenderPressurizedTube.java b/src/minecraft/mekanism/client/RenderPressurizedTube.java index 9f55f1977..135777de1 100644 --- a/src/minecraft/mekanism/client/RenderPressurizedTube.java +++ b/src/minecraft/mekanism/client/RenderPressurizedTube.java @@ -6,6 +6,7 @@ import org.lwjgl.opengl.GL11; import net.minecraftforge.common.ForgeDirection; +import mekanism.api.GasTransmission; import mekanism.api.IGasAcceptor; import mekanism.api.ITubeConnection; import mekanism.common.MekanismUtils; @@ -29,11 +30,11 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); GL11.glScalef(1.0F, -1F, -1F); - ITubeConnection[] connections = MekanismUtils.getConnections(tileEntity); + ITubeConnection[] connections = GasTransmission.getConnections(tileEntity); for(ITubeConnection connection : connections) { - if(connection != null) + if(connection != null) { int side = Arrays.asList(connections).indexOf(connection); diff --git a/src/minecraft/mekanism/client/SoundHandler.java b/src/minecraft/mekanism/client/SoundHandler.java index d32203bdd..bf4cb70ee 100644 --- a/src/minecraft/mekanism/client/SoundHandler.java +++ b/src/minecraft/mekanism/client/SoundHandler.java @@ -73,14 +73,14 @@ public class SoundHandler } } - /** Create and return an instance of a Sound. - * + /** + * Create and return an instance of a Sound. * @param name - unique identifier for this sound * @param path - bundled path to the sound effect * @param world - world to play sound in - * @param x - x coord - * @param y - y coord - * @param z - z coord + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate * @return Sound instance */ public Sound getSound(String path, World world, int x, int y, int z) diff --git a/src/minecraft/mekanism/client/ThreadClientUpdate.java b/src/minecraft/mekanism/client/ThreadClientUpdate.java index dfabbedb6..d77d83087 100644 --- a/src/minecraft/mekanism/client/ThreadClientUpdate.java +++ b/src/minecraft/mekanism/client/ThreadClientUpdate.java @@ -16,13 +16,15 @@ import net.minecraft.client.Minecraft; */ public class ThreadClientUpdate extends Thread { + private int downloadType; private int bytesDownloaded; private int lastBytesDownloaded; private byte[] buffer = new byte[10240]; private URL url; - public ThreadClientUpdate(String location) + public ThreadClientUpdate(String location, int type) { + downloadType = type; try { url = new URL(location); setDaemon(true); @@ -35,7 +37,8 @@ public class ThreadClientUpdate extends Thread @Override public void run() { - File download = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods/Mekanism.jar").toString()); + String downloadName = downloadType == 0 ? "" : (downloadType == 1 ? "Generators" : "Tools"); + File download = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods/Mekanism" + downloadName + "-v" + Mekanism.latestVersionNumber + ".jar").toString()); try { prepareForDownload(); download.createNewFile(); @@ -51,10 +54,14 @@ public class ThreadClientUpdate extends Thread outputStream.close(); stream.close(); - GuiCredits.onFinishedDownloading(); - System.out.println("[Mekanism] Successfully updated to latest version (" + Mekanism.latestVersionNumber + ")."); - finalize(); + if(downloadType == 2) + { + GuiCredits.onFinishedDownloading(); + System.out.println("[Mekanism] Successfully updated to latest version (" + Mekanism.latestVersionNumber + ")."); + } + + finalize(); } catch(Throwable e) { GuiCredits.onErrorDownloading(); @@ -72,17 +79,16 @@ public class ThreadClientUpdate extends Thread */ public void prepareForDownload() { - File download = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods/Mekanism.jar").toString()); - File config = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/config/Mekanism.cfg").toString()); + File[] modsList = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/mods").toString()).listFiles(); - if(download.exists()) + for(File file : modsList) { - download.delete(); - } - if(config.exists()) - { - config.delete(); + if(file.getName().startsWith("Mekanism") && file.getName().endsWith(".jar") && !file.getName().contains(Mekanism.latestVersionNumber)) + { + file.delete(); + } } + System.out.println("[Mekanism] Preparing to update..."); } } diff --git a/src/minecraft/mekanism/common/BlockBounding.java b/src/minecraft/mekanism/common/BlockBounding.java new file mode 100644 index 000000000..98309efbe --- /dev/null +++ b/src/minecraft/mekanism/common/BlockBounding.java @@ -0,0 +1,90 @@ +package mekanism.common; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +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.IBlockAccess; +import net.minecraft.world.World; + +public class BlockBounding extends Block +{ + public BlockBounding(int id) + { + super(id, Material.iron); + setHardness(0.8F); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) + { + TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z); + return Block.blocksList[world.getBlockId(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ)].onBlockActivated(world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ, entityplayer, facing, playerX, playerY, playerZ); + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) + { + TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z); + return Block.blocksList[world.getBlockId(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ)].getPickBlock(target, world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ); + } + + @Override + public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) + { + TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z); + + if(Block.blocksList[world.getBlockId(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ)] != null) + { + return Block.blocksList[world.getBlockId(tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ)].removeBlockByPlayer(world, player, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ); + } + + return false; + } + + @Override + public int quantityDropped(Random random) + { + return 0; + } + + @Override + public int idDropped(int i, Random random, int j) + { + return 0; + } + + @Override + public int getRenderType() + { + return -1; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) + { + return new TileEntityBoundingBlock(); + } +} diff --git a/src/minecraft/mekanism/common/BlockMachine.java b/src/minecraft/mekanism/common/BlockMachine.java index 9144173da..2756345e1 100644 --- a/src/minecraft/mekanism/common/BlockMachine.java +++ b/src/minecraft/mekanism/common/BlockMachine.java @@ -75,6 +75,11 @@ public class BlockMachine extends BlockContainer implements IDismantleable } tileEntity.setFacing((short)change); + + if(tileEntity instanceof IBoundingBlock) + { + ((IBoundingBlock)tileEntity).onPlace(); + } } @Override diff --git a/src/minecraft/mekanism/common/BlockPressurizedTube.java b/src/minecraft/mekanism/common/BlockPressurizedTube.java index b3d0f0801..1353bfa2e 100644 --- a/src/minecraft/mekanism/common/BlockPressurizedTube.java +++ b/src/minecraft/mekanism/common/BlockPressurizedTube.java @@ -6,6 +6,7 @@ import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.api.GasTransmission; import mekanism.api.IGasAcceptor; import mekanism.api.ITubeConnection; import mekanism.client.ClientProxy; @@ -46,7 +47,7 @@ public class BlockPressurizedTube extends Block if(tileEntity != null) { boolean[] connectable = new boolean[] {false, false, false, false, false, false}; - ITubeConnection[] connections = MekanismUtils.getConnections(tileEntity); + ITubeConnection[] connections = GasTransmission.getConnections(tileEntity); for(ITubeConnection connection : connections) { diff --git a/src/minecraft/mekanism/common/CommandMekanism.java b/src/minecraft/mekanism/common/CommandMekanism.java index 9553720b2..07393decf 100644 --- a/src/minecraft/mekanism/common/CommandMekanism.java +++ b/src/minecraft/mekanism/common/CommandMekanism.java @@ -3,6 +3,7 @@ package mekanism.common; import java.util.Arrays; import java.util.List; +import mekanism.api.EnumColor; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; diff --git a/src/minecraft/mekanism/common/CommonProxy.java b/src/minecraft/mekanism/common/CommonProxy.java index f436c3810..9d41b5d92 100644 --- a/src/minecraft/mekanism/common/CommonProxy.java +++ b/src/minecraft/mekanism/common/CommonProxy.java @@ -63,7 +63,7 @@ public class CommonProxy Mekanism.oreBlockID = Mekanism.configuration.getBlock("OreBlock", 3002).getInt(); Mekanism.obsidianTNTID = Mekanism.configuration.getBlock("ObsidianTNT", 3003).getInt(); Mekanism.energyCubeID = Mekanism.configuration.getBlock("EnergyCube", 3004).getInt(); - Mekanism.nullRenderID = Mekanism.configuration.getBlock("NullRender", 3005).getInt(); + Mekanism.boundingBlockID = Mekanism.configuration.getBlock("BoundingBlock", 3005).getInt(); Mekanism.gasTankID = Mekanism.configuration.getBlock("GasTank", 3006).getInt(); Mekanism.pressurizedTubeID = Mekanism.configuration.getBlock("PressurizedTube", 3007).getInt(); Mekanism.extrasEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ExtrasEnabled", true).getBoolean(true); diff --git a/src/minecraft/mekanism/common/EntityObsidianTNT.java b/src/minecraft/mekanism/common/EntityObsidianTNT.java index 54b15bc93..d97dda6b4 100644 --- a/src/minecraft/mekanism/common/EntityObsidianTNT.java +++ b/src/minecraft/mekanism/common/EntityObsidianTNT.java @@ -8,29 +8,31 @@ public class EntityObsidianTNT extends Entity { /** How long the fuse is */ public int fuse; + + /** Whether or not the TNT has exploded */ private boolean hasExploded = false; - public EntityObsidianTNT(World par1World) + public EntityObsidianTNT(World world) { - super(par1World); + super(world); fuse = 0; preventEntitySpawning = true; setSize(0.98F, 0.98F); yOffset = height / 2.0F; } - public EntityObsidianTNT(World par1World, double par2, double par4, double par6) + public EntityObsidianTNT(World world, double x, double y, double z) { - this(par1World); - setPosition(par2, par4, par6); - float var8 = (float)(Math.random() * Math.PI * 2); - motionX = (double)(-((float)Math.sin((double)var8)) * 0.02F); + this(world); + setPosition(x, y, z); + float randPi = (float)(Math.random()*Math.PI*2); + motionX = -(Math.sin(randPi))*0.02F; motionY = 0.2; - motionZ = (double)(-((float)Math.cos((double)var8)) * 0.02F); + motionZ = -(Math.cos(randPi))*0.02F; fuse = Mekanism.ObsidianTNTDelay; - prevPosX = par2; - prevPosY = par4; - prevPosZ = par6; + prevPosX = x; + prevPosY = y; + prevPosZ = z; } @Override @@ -60,22 +62,21 @@ public class EntityObsidianTNT extends Entity motionY *= 0.98; motionZ *= 0.98; - if (onGround) + if(onGround) { motionX *= 0.7; motionZ *= 0.7; motionY *= -0.5; } - if (fuse-- <= 0) + if(fuse-- <= 0) { - if (!worldObj.isRemote) + if(!worldObj.isRemote) { setDead(); explode(); } - else - { + else { if(hasExploded) { setDead(); @@ -85,8 +86,7 @@ public class EntityObsidianTNT extends Entity } } } - else - { + else { worldObj.spawnParticle("lava", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D); } } diff --git a/src/minecraft/mekanism/common/IBoundingBlock.java b/src/minecraft/mekanism/common/IBoundingBlock.java new file mode 100644 index 000000000..96ef9a2da --- /dev/null +++ b/src/minecraft/mekanism/common/IBoundingBlock.java @@ -0,0 +1,14 @@ +package mekanism.common; + +public interface IBoundingBlock +{ + /** + * Called when the main block is placed. + */ + public void onPlace(); + + /** + * Called when any part of the structure is broken. + */ + public void onBreak(); +} diff --git a/src/minecraft/mekanism/common/ItemAtomicDisassembler.java b/src/minecraft/mekanism/common/ItemAtomicDisassembler.java index 4df5a0864..568cbb1fa 100644 --- a/src/minecraft/mekanism/common/ItemAtomicDisassembler.java +++ b/src/minecraft/mekanism/common/ItemAtomicDisassembler.java @@ -2,6 +2,7 @@ package mekanism.common; import java.util.List; +import mekanism.api.EnumColor; import net.minecraft.block.Block; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; @@ -43,6 +44,7 @@ public class ItemAtomicDisassembler extends ItemEnergized else { hitEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)player), 4); } + return false; } @@ -54,7 +56,7 @@ public class ItemAtomicDisassembler extends ItemEnergized @Override public boolean onBlockDestroyed(ItemStack itemstack, World world, int id, int x, int y, int z, EntityLiving entityliving) { - if ((double)Block.blocksList[id].getBlockHardness(world, x, y, z) != 0.0D) + if(Block.blocksList[id].getBlockHardness(world, x, y, z) != 0.0D) { onUse(getEfficiency(itemstack), itemstack); } @@ -93,10 +95,10 @@ public class ItemAtomicDisassembler extends ItemEnergized { if(itemStack.stackTagCompound == null) { - return 5; + return 2; } - int efficiency = 5; + int efficiency = 2; if(itemStack.stackTagCompound.getTag("efficiency") != null) { @@ -119,26 +121,31 @@ public class ItemAtomicDisassembler extends ItemEnergized public int getIncremented(int previous) { - if(previous == 5) + if(previous == 0) { - return 10; + return 2; } - else if(previous == 10) + else if(previous == 2) { - return 25; + return 8; } - else if(previous == 25) + else if(previous == 8) { - return 50; + return 24; } - else if(previous == 50) + else if(previous == 24) + { + return 64; + } + else if(previous == 64) { return 100; } else if(previous == 100) { - return 5; + return 0; } + return 0; } } diff --git a/src/minecraft/mekanism/common/ItemConfigurator.java b/src/minecraft/mekanism/common/ItemConfigurator.java index 47252a70f..44c232af2 100644 --- a/src/minecraft/mekanism/common/ItemConfigurator.java +++ b/src/minecraft/mekanism/common/ItemConfigurator.java @@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import mekanism.api.EnumColor; import mekanism.api.IConfigurable; public class ItemConfigurator extends ItemEnergized diff --git a/src/minecraft/mekanism/common/ItemElectricBow.java b/src/minecraft/mekanism/common/ItemElectricBow.java index cf9f10823..0709c087d 100644 --- a/src/minecraft/mekanism/common/ItemElectricBow.java +++ b/src/minecraft/mekanism/common/ItemElectricBow.java @@ -2,6 +2,7 @@ package mekanism.common; import java.util.List; +import mekanism.api.EnumColor; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/minecraft/mekanism/common/ItemPortableTeleporter.java b/src/minecraft/mekanism/common/ItemPortableTeleporter.java index 0407c4d5f..fd4df805c 100644 --- a/src/minecraft/mekanism/common/ItemPortableTeleporter.java +++ b/src/minecraft/mekanism/common/ItemPortableTeleporter.java @@ -1,5 +1,6 @@ package mekanism.common; +import mekanism.api.EnumColor; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/minecraft/mekanism/common/ItemStorageTank.java b/src/minecraft/mekanism/common/ItemStorageTank.java index 330e637fe..c1c8c0010 100644 --- a/src/minecraft/mekanism/common/ItemStorageTank.java +++ b/src/minecraft/mekanism/common/ItemStorageTank.java @@ -54,10 +54,8 @@ public class ItemStorageTank extends ItemMekanism implements IStorageTank public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { ItemStorageTank item = ((ItemStorageTank)itemstack.getItem()); - item.setGas(itemstack, item.getGasType(itemstack), item.getGas(itemstack)); - item.setGasType(itemstack, item.getGasType(itemstack)); - if(item.getGas(itemstack) == 0) + if(item.getGas(itemstack) == 0 && item.getGasType(itemstack) != EnumGas.NONE) { item.setGasType(itemstack, EnumGas.NONE); } diff --git a/src/minecraft/mekanism/common/Mekanism.java b/src/minecraft/mekanism/common/Mekanism.java index 59116249d..0e8e0f939 100644 --- a/src/minecraft/mekanism/common/Mekanism.java +++ b/src/minecraft/mekanism/common/Mekanism.java @@ -11,6 +11,7 @@ import mekanism.api.InfuseObject; import mekanism.api.InfusionInput; import mekanism.api.InfusionOutput; import mekanism.api.InfusionType; +import mekanism.api.RecipeHelper; import mekanism.api.Tier.EnergyCubeTier; import mekanism.client.SoundHandler; import net.minecraft.block.Block; @@ -23,8 +24,6 @@ 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; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; @@ -52,7 +51,7 @@ import cpw.mods.fml.server.FMLServerHandler; * @author AidanBrady * */ -@Mod(modid = "Mekanism", name = "Mekanism", version = "5.4.0") +@Mod(modid = "Mekanism", name = "Mekanism", version = "5.4.1") @NetworkMod(channels = {"Mekanism"}, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) public class Mekanism { @@ -74,7 +73,7 @@ public class Mekanism public static Configuration configuration; /** Mekanism version number */ - public static Version versionNumber = new Version(5, 4, 0); + public static Version versionNumber = new Version(5, 4, 1); /** Map of Teleporters */ public static Map> teleporters = new HashMap>(); @@ -110,7 +109,7 @@ public class Mekanism public static int oreBlockID = 3002; public static int obsidianTNTID = 3003; public static int energyCubeID = 3004; - public static int nullRenderID = 3005; + public static int boundingBlockID = 3005; public static int gasTankID = 3006; public static int pressurizedTubeID = 3007; @@ -132,17 +131,17 @@ public class Mekanism public static Item TeleportationCore; public static Item Configurator; - //Extra Blocks + //Blocks public static Block BasicBlock; public static Block MachineBlock; public static Block OreBlock; public static Block ObsidianTNT; public static Block EnergyCube; - public static BlockMulti NullRender; + public static Block BoundingBlock; public static Block GasTank; public static Block PressurizedTube; - //MultiID Items + //Multi-ID Items public static Item Dust; public static Item Ingot; public static Item Clump; @@ -399,7 +398,7 @@ public class Mekanism LanguageRegistry.addName(AtomicCore, "Atomic Core"); LanguageRegistry.addName(ElectricBow, "Electric Bow"); LanguageRegistry.addName(StorageTank, "Hydrogen Tank"); - LanguageRegistry.addName(NullRender, "Null Render"); + LanguageRegistry.addName(BoundingBlock, "Bounding Block"); LanguageRegistry.addName(GasTank, "Gas Tank"); LanguageRegistry.addName(StorageTank, "Storage Tank"); LanguageRegistry.addName(ControlCircuit, "Control Circuit"); @@ -552,13 +551,13 @@ public class Mekanism OreBlock = new BlockOre(oreBlockID).setBlockName("OreBlock"); EnergyCube = new BlockEnergyCube(energyCubeID).setBlockName("EnergyCube"); ObsidianTNT = new BlockObsidianTNT(obsidianTNTID).setBlockName("ObsidianTNT").setCreativeTab(tabMekanism); - NullRender = (BlockMulti) new BlockMulti(nullRenderID).setBlockName("NullRender"); + BoundingBlock = (BlockBounding) new BlockBounding(boundingBlockID).setBlockName("BoundingBlock"); GasTank = new BlockGasTank(gasTankID).setBlockName("GasTank"); PressurizedTube = new BlockPressurizedTube(pressurizedTubeID).setBlockName("PressurizedTube"); //Registrations GameRegistry.registerBlock(ObsidianTNT, "ObsidianTNT"); - GameRegistry.registerBlock(NullRender, "NullRender"); + GameRegistry.registerBlock(BoundingBlock, "BoundingBlock"); GameRegistry.registerBlock(GasTank, "GasTank"); GameRegistry.registerBlock(PressurizedTube, "PressurizedTube"); @@ -879,7 +878,7 @@ public class Mekanism GameRegistry.registerTileEntity(TileEntityCombiner.class, "Combiner"); GameRegistry.registerTileEntity(TileEntityCrusher.class, "Crusher"); GameRegistry.registerTileEntity(TileEntityEnergyCube.class, "EnergyCube"); - GameRegistry.registerTileEntity(TileEntityMulti.class, "MekanismMulti"); + GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock"); GameRegistry.registerTileEntity(TileEntityControlPanel.class, "ControlPanel"); GameRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank"); GameRegistry.registerTileEntity(TileEntitySmeltingFactory.class, "SmeltingFactory"); diff --git a/src/minecraft/mekanism/common/MekanismUtils.java b/src/minecraft/mekanism/common/MekanismUtils.java index 615499726..a74a3bc5a 100644 --- a/src/minecraft/mekanism/common/MekanismUtils.java +++ b/src/minecraft/mekanism/common/MekanismUtils.java @@ -10,7 +10,9 @@ import java.util.Arrays; import java.util.Map; import universalelectricity.core.vector.Vector3; +import universalelectricity.prefab.multiblock.TileEntityMulti; +import mekanism.api.EnumColor; import mekanism.api.EnumGas; import mekanism.api.IActiveState; import mekanism.api.IConfigurable; @@ -49,7 +51,7 @@ public final class MekanismUtils { if(Mekanism.updateNotifications) { - if(!Mekanism.latestVersionNumber.equals("Error retrieving data.")) + if(!Mekanism.latestVersionNumber.equals("null")) { if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1) { @@ -79,8 +81,8 @@ public final class MekanismUtils public static String getLatestVersion() { String[] text = getHTML("http://dl.dropbox.com/u/90411166/Mod%20Versions/Mekanism.txt").split(":"); - if(!text[0].contains("UTF-8") && !text[0].contains("HTML")) return text[0]; - return "Error retrieving data."; + if(!text[0].contains("UTF-8") && !text[0].contains("HTML") && !text[0].contains("http")) return text[0]; + return "null"; } /** @@ -90,8 +92,8 @@ public final class MekanismUtils public static String getRecentNews() { String[] text = getHTML("http://dl.dropbox.com/u/90411166/Mod%20Versions/Mekanism.txt").split(":"); - if(text.length > 1 && !text[1].contains("UTF-8") && !text[1].contains("HTML")) return text[1]; - return "There is no news to show."; + if(text.length > 1 && !text[1].contains("UTF-8") && !text[1].contains("HTML") && !text[1].contains("http")) return text[1]; + return "null"; } /** @@ -119,7 +121,7 @@ public final class MekanismUtils } rd.close(); } catch (Exception e) { - result = "Error retrieving data."; + result = "null"; System.err.println("[Mekanism] An error occured while connecting to URL '" + urlToRead + ".'"); } return result; @@ -140,6 +142,10 @@ public final class MekanismUtils } } + /** + * Sends the defined message to all players. + * @param msg - message to send + */ public static void sendChatMessageToAllPlayers(String msg) { PacketDispatcher.sendPacketToAllPlayers(new Packet3Chat(msg)); @@ -149,9 +155,9 @@ public final class MekanismUtils * Checks if the mod is running on the latest version. * @return if mod is latest version */ - public static boolean isLatestVersion() + public static boolean isNotOutdated() { - return Mekanism.versionNumber.toString().equals(Mekanism.latestVersionNumber); + return Mekanism.latestVersionNumber.contains("null") || Mekanism.versionNumber.comparedState(Version.get(Mekanism.latestVersionNumber)) != -1; } /** @@ -412,98 +418,15 @@ public final class MekanismUtils } /** - * Gets all the tubes around a tile entity. - * @param tileEntity - center tile entity - * @return array of TileEntities + * Places a fake bounding block at the defined location. + * @param world - world to place block in + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate */ - public static TileEntity[] getConnectedTubes(TileEntity tileEntity) + public static void makeBoundingBlock(World world, int x, int y, int z, int origX, int origY, int origZ) { - TileEntity[] tubes = new TileEntity[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.values()) - { - if(orientation != ForgeDirection.UNKNOWN) - { - TileEntity tube = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation); - - if(tube instanceof IPressurizedTube && ((IPressurizedTube)tube).canTransferGas()) - { - tubes[orientation.ordinal()] = tube; - } - } - } - - return tubes; - } - - /** - * Gets all the acceptors around a tile entity. - * @param tileEntity - center tile entity - * @return array of IGasAcceptors - */ - public static IGasAcceptor[] getConnectedAcceptors(TileEntity tileEntity) - { - IGasAcceptor[] acceptors = new IGasAcceptor[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.values()) - { - if(orientation != ForgeDirection.UNKNOWN) - { - TileEntity acceptor = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation); - - if(acceptor instanceof IGasAcceptor) - { - acceptors[orientation.ordinal()] = (IGasAcceptor)acceptor; - } - } - } - - return acceptors; - } - - /** - * Gets all the tube connections around a tile entity. - * @param tileEntity - center tile entity - * @return array of ITubeConnections - */ - public static ITubeConnection[] getConnections(TileEntity tileEntity) - { - ITubeConnection[] connections = new ITubeConnection[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.values()) - { - if(orientation != ForgeDirection.UNKNOWN) - { - TileEntity connection = Vector3.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation); - - if(connection instanceof ITubeConnection) - { - connections[orientation.ordinal()] = (ITubeConnection)connection; - } - } - } - - return connections; - } - - /** - * Emits a defined gas to the network. - * @param type - gas type to send - * @param amount - amount of gas to send - * @param sender - the sender of the gas - * @param facing - side the sender is outputting from - * @return rejected gas - */ - public static int emitGasToNetwork(EnumGas type, int amount, TileEntity sender, ForgeDirection facing) - { - TileEntity pointer = Vector3.getTileEntityFromSide(sender.worldObj, new Vector3(sender.xCoord, sender.yCoord, sender.zCoord), facing); - - if(pointer != null) - { - GasTransferProtocol calculation = new GasTransferProtocol(pointer, type, amount); - return calculation.calculate(); - } - - return amount; + world.setBlockWithNotify(x, y, z, Mekanism.BoundingBlock.blockID); + ((TileEntityBoundingBlock)world.getBlockTileEntity(x, y, z)).setMainLocation(origX, origY, origZ); } } diff --git a/src/minecraft/mekanism/common/OreHandler.java b/src/minecraft/mekanism/common/OreHandler.java index 698d22091..60e7dfe37 100644 --- a/src/minecraft/mekanism/common/OreHandler.java +++ b/src/minecraft/mekanism/common/OreHandler.java @@ -17,12 +17,12 @@ public class OreHandler implements IWorldGenerator { if(!(chunkGenerator instanceof ChunkProviderHell) && !(chunkGenerator instanceof ChunkProviderEnd)) { - for(int i=0;i<12;i++) + for(int i=0;i<8;i++) { int randPosX = (chunkX*16) + random.nextInt(16); int randPosY = random.nextInt(60); int randPosZ = (chunkZ*16) + random.nextInt(16); - (new WorldGenMinable(new ItemStack(Mekanism.OreBlock, 1, 0).itemID, 12)).generate(world, random, randPosX, randPosY, randPosZ); + (new WorldGenMinable(new ItemStack(Mekanism.OreBlock, 1, 0).itemID, 8)).generate(world, random, randPosX, randPosY, randPosZ); } } } diff --git a/src/minecraft/mekanism/common/PacketHandler.java b/src/minecraft/mekanism/common/PacketHandler.java index 93b9a0a8c..059d6a85d 100644 --- a/src/minecraft/mekanism/common/PacketHandler.java +++ b/src/minecraft/mekanism/common/PacketHandler.java @@ -53,6 +53,7 @@ public class PacketHandler implements IPacketHandler System.out.println("[Mekanism] Received weather update packet from " + entityplayer.username + "."); entityplayer.getCurrentEquippedItem().damageItem(4999, entityplayer); int weatherType = dataStream.readInt(); + if(weatherType == EnumWeatherType.CLEAR.id) { entityplayer.worldObj.getWorldInfo().setRaining(false); @@ -447,7 +448,7 @@ public class PacketHandler implements IPacketHandler 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."); + System.out.println("[Mekanism] Sent portal FX packet to clients."); } /** diff --git a/src/minecraft/mekanism/common/RecipeHandler.java b/src/minecraft/mekanism/common/RecipeHandler.java index a0a13a9a0..c17d391bd 100644 --- a/src/minecraft/mekanism/common/RecipeHandler.java +++ b/src/minecraft/mekanism/common/RecipeHandler.java @@ -70,7 +70,7 @@ public final class RecipeHandler } /** - * Adds a Metallurgic Infuser recipe. + * Add a Metallurgic Infuser recipe. * @param input - input Infusion * @param output - output ItemStack */ @@ -147,7 +147,7 @@ public final class RecipeHandler PURIFICATION_CHAMBER(new HashMap()), METALLURGIC_INFUSER(new HashMap()); - private Map recipes; + private HashMap recipes; private Recipe(HashMap map) { @@ -159,7 +159,7 @@ public final class RecipeHandler recipes.put(input, output); } - public Map get() + public HashMap get() { return recipes; } diff --git a/src/minecraft/mekanism/common/TileEntityAdvancedElectricMachine.java b/src/minecraft/mekanism/common/TileEntityAdvancedElectricMachine.java index 861dae285..4175d2858 100644 --- a/src/minecraft/mekanism/common/TileEntityAdvancedElectricMachine.java +++ b/src/minecraft/mekanism/common/TileEntityAdvancedElectricMachine.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import ic2.api.ElectricItem; import ic2.api.IElectricItem; +import mekanism.api.EnumColor; import mekanism.api.SideData; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -114,7 +115,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM if(inventory[4] != null) { - if(inventory[4].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8) + if(inventory[4].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8) { if(upgradeTicks < UPGRADE_TICKS_REQUIRED) { diff --git a/src/minecraft/mekanism/common/TileEntityAdvancedSmeltingFactory.java b/src/minecraft/mekanism/common/TileEntityAdvancedSmeltingFactory.java index 23fa815e7..932052086 100644 --- a/src/minecraft/mekanism/common/TileEntityAdvancedSmeltingFactory.java +++ b/src/minecraft/mekanism/common/TileEntityAdvancedSmeltingFactory.java @@ -1,5 +1,6 @@ package mekanism.common; +import mekanism.api.EnumColor; import mekanism.api.SideData; import mekanism.api.Tier.SmeltingFactoryTier; diff --git a/src/minecraft/mekanism/common/TileEntityBoundingBlock.java b/src/minecraft/mekanism/common/TileEntityBoundingBlock.java new file mode 100644 index 000000000..dc07d061c --- /dev/null +++ b/src/minecraft/mekanism/common/TileEntityBoundingBlock.java @@ -0,0 +1,88 @@ +package mekanism.common; + +import java.util.ArrayList; + +import com.google.common.io.ByteArrayDataInput; + +import mekanism.api.EnumGas; +import mekanism.api.ITileNetwork; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetworkManager; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork +{ + public int mainX; + public int mainY; + public int mainZ; + + public void setMainLocation(int x, int y, int z) + { + mainX = x; + mainY = y; + mainZ = z; + + if(!worldObj.isRemote) + { + PacketHandler.sendTileEntityPacketToClients(this, 0, getNetworkedData(new ArrayList())); + } + } + + @Override + public boolean canUpdate() + { + return false; + } + + @Override + public void validate() + { + super.validate(); + + if(worldObj.isRemote) + { + PacketHandler.sendDataRequest(this); + } + } + + @Override + public void handlePacketData(ByteArrayDataInput dataStream) + { + mainX = dataStream.readInt(); + mainY = dataStream.readInt(); + mainZ = dataStream.readInt(); + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) + { + super.readFromNBT(nbtTags); + + mainX = nbtTags.getInteger("mainX"); + mainY = nbtTags.getInteger("mainX"); + mainZ = nbtTags.getInteger("mainX"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) + { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("mainX", mainX); + nbtTags.setInteger("mainY", mainY); + nbtTags.setInteger("mainZ", mainZ); + } + + @Override + public ArrayList getNetworkedData(ArrayList data) + { + data.add(mainX); + data.add(mainY); + data.add(mainZ); + return data; + } +} diff --git a/src/minecraft/mekanism/common/TileEntityElectricMachine.java b/src/minecraft/mekanism/common/TileEntityElectricMachine.java index 18c1507e4..da5f23cda 100644 --- a/src/minecraft/mekanism/common/TileEntityElectricMachine.java +++ b/src/minecraft/mekanism/common/TileEntityElectricMachine.java @@ -2,6 +2,7 @@ package mekanism.common; import ic2.api.ElectricItem; import ic2.api.IElectricItem; +import mekanism.api.EnumColor; import mekanism.api.SideData; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -87,7 +88,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine if(inventory[3] != null) { - if(inventory[3].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8) + if(inventory[3].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8) { if(upgradeTicks < UPGRADE_TICKS_REQUIRED) { diff --git a/src/minecraft/mekanism/common/TileEntityEliteSmeltingFactory.java b/src/minecraft/mekanism/common/TileEntityEliteSmeltingFactory.java index f7ed14465..95cf87c8d 100644 --- a/src/minecraft/mekanism/common/TileEntityEliteSmeltingFactory.java +++ b/src/minecraft/mekanism/common/TileEntityEliteSmeltingFactory.java @@ -1,5 +1,6 @@ package mekanism.common; +import mekanism.api.EnumColor; import mekanism.api.SideData; import mekanism.api.Tier.SmeltingFactoryTier; diff --git a/src/minecraft/mekanism/common/TileEntityGasTank.java b/src/minecraft/mekanism/common/TileEntityGasTank.java index eead597b4..ff1cfce72 100644 --- a/src/minecraft/mekanism/common/TileEntityGasTank.java +++ b/src/minecraft/mekanism/common/TileEntityGasTank.java @@ -3,6 +3,7 @@ package mekanism.common; import java.util.ArrayList; import mekanism.api.EnumGas; +import mekanism.api.GasTransmission; import mekanism.api.IGasAcceptor; import mekanism.api.IGasStorage; import mekanism.api.IStorageTank; @@ -110,7 +111,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS if(gasStored > 0 && !worldObj.isRemote) { - setGas(gasType, gasStored - (Math.min(gasStored, output) - MekanismUtils.emitGasToNetwork(gasType, Math.min(gasStored, output), this, ForgeDirection.getOrientation(facing)))); + setGas(gasType, gasStored - (Math.min(gasStored, output) - GasTransmission.emitGasToNetwork(gasType, Math.min(gasStored, output), this, ForgeDirection.getOrientation(facing)))); TileEntity tileEntity = Vector3.getTileEntityFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(facing)); diff --git a/src/minecraft/mekanism/common/TileEntityMetallurgicInfuser.java b/src/minecraft/mekanism/common/TileEntityMetallurgicInfuser.java index a6c1538c4..4bfdd980b 100644 --- a/src/minecraft/mekanism/common/TileEntityMetallurgicInfuser.java +++ b/src/minecraft/mekanism/common/TileEntityMetallurgicInfuser.java @@ -10,6 +10,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.Map; +import mekanism.api.EnumColor; import mekanism.api.IActiveState; import mekanism.api.IConfigurable; import mekanism.api.IUpgradeManagement; @@ -200,7 +201,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem if(inventory[0] != null) { - if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8) + if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8) { if(upgradeTicks < UPGRADE_TICKS_REQUIRED) { diff --git a/src/minecraft/mekanism/common/TileEntityPressurizedTube.java b/src/minecraft/mekanism/common/TileEntityPressurizedTube.java index 3be838d90..321543e23 100644 --- a/src/minecraft/mekanism/common/TileEntityPressurizedTube.java +++ b/src/minecraft/mekanism/common/TileEntityPressurizedTube.java @@ -13,7 +13,7 @@ public class TileEntityPressurizedTube extends TileEntity implements IPressurize @Override public boolean canTransferGas() { - return true; + return !worldObj.isBlockGettingPowered(xCoord, yCoord, zCoord); } @Override diff --git a/src/minecraft/mekanism/common/TileEntitySmeltingFactory.java b/src/minecraft/mekanism/common/TileEntitySmeltingFactory.java index 7865a7aae..8f728f7bf 100644 --- a/src/minecraft/mekanism/common/TileEntitySmeltingFactory.java +++ b/src/minecraft/mekanism/common/TileEntitySmeltingFactory.java @@ -7,6 +7,7 @@ import ic2.api.Direction; import ic2.api.ElectricItem; import ic2.api.IElectricItem; import ic2.api.energy.tile.IEnergySink; +import mekanism.api.EnumColor; import mekanism.api.IActiveState; import mekanism.api.IConfigurable; import mekanism.api.IUpgradeManagement; @@ -201,7 +202,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement if(inventory[0] != null) { - if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && speedMultiplier < 8) + if(inventory[0].isItemEqual(new ItemStack(Mekanism.EnergyUpgrade)) && energyMultiplier < 8) { if(upgradeTicks < UPGRADE_TICKS_REQUIRED) { diff --git a/src/minecraft/mekanism/common/TileEntityTeleporter.java b/src/minecraft/mekanism/common/TileEntityTeleporter.java index ce86b8114..2826888b6 100644 --- a/src/minecraft/mekanism/common/TileEntityTeleporter.java +++ b/src/minecraft/mekanism/common/TileEntityTeleporter.java @@ -25,6 +25,7 @@ import cpw.mods.fml.server.FMLServerHandler; import dan200.computer.api.IComputerAccess; import dan200.computer.api.IPeripheral; +import mekanism.api.EnumColor; import mekanism.common.Teleporter.Coords; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; diff --git a/src/minecraft/mekanism/generators/common/BlockGenerator.java b/src/minecraft/mekanism/generators/common/BlockGenerator.java index 94de99a8c..a473b5393 100644 --- a/src/minecraft/mekanism/generators/common/BlockGenerator.java +++ b/src/minecraft/mekanism/generators/common/BlockGenerator.java @@ -8,6 +8,7 @@ import buildcraft.api.tools.IToolWrench; import mekanism.api.IActiveState; import mekanism.api.IEnergyCube; +import mekanism.common.IBoundingBlock; import mekanism.common.Mekanism; import mekanism.common.MekanismUtils; import mekanism.common.TileEntityBasicBlock; @@ -30,9 +31,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import thermalexpansion.api.core.IDismantleable; import universalelectricity.core.implement.IItemElectric; -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; @@ -97,7 +96,7 @@ public class BlockGenerator extends BlockContainer implements IDismantleable int height = Math.round(entityliving.rotationPitch); int change = 3; - if(!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel && world.getBlockMetadata(x, y, z) != 1) + if(!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel && tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) { if(height >= 65) { @@ -120,9 +119,9 @@ public class BlockGenerator extends BlockContainer implements IDismantleable tileEntity.setFacing((short)change); - if(tileEntity instanceof IMultiBlock) + if(tileEntity instanceof IBoundingBlock) { - ((IMultiBlock)tileEntity).onCreate(new Vector3(x, y, z)); + ((IBoundingBlock)tileEntity).onPlace(); } } @@ -429,24 +428,9 @@ public class BlockGenerator extends BlockContainer implements IDismantleable } } - if(world.getBlockMetadata(x, y, z) == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) + if(tileEntity instanceof IBoundingBlock) { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, new ItemStack(MekanismGenerators.Generator, 1, 5)); - - IItemElectric electricItem = (IItemElectric)entityItem.getEntityItem().getItem(); - electricItem.setJoules(tileEntity.electricityStored, entityItem.getEntityItem()); - - world.spawnEntityInWorld(entityItem); - } - - if(tileEntity instanceof IMultiBlock) - { - ((IMultiBlock)tileEntity).onDestroy(tileEntity); + ((IBoundingBlock)tileEntity).onBreak(); } } @@ -612,7 +596,7 @@ public class BlockGenerator extends BlockContainer implements IDismantleable @Override public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) { - if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)) && world.getBlockMetadata(x, y, z) != GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) + if(!player.capabilities.isCreativeMode && !world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z))) { TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getBlockTileEntity(x, y, z); diff --git a/src/minecraft/mekanism/generators/common/MekanismGenerators.java b/src/minecraft/mekanism/generators/common/MekanismGenerators.java index 1faba5951..7d9b30c50 100644 --- a/src/minecraft/mekanism/generators/common/MekanismGenerators.java +++ b/src/minecraft/mekanism/generators/common/MekanismGenerators.java @@ -22,7 +22,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.4.0", dependencies = "required-after:Mekanism") +@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "5.4.1", dependencies = "required-after:Mekanism") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class MekanismGenerators { diff --git a/src/minecraft/mekanism/generators/common/TileEntityAdvancedSolarGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityAdvancedSolarGenerator.java index 470a6a2b4..d7f589507 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityAdvancedSolarGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityAdvancedSolarGenerator.java @@ -1,12 +1,12 @@ package mekanism.generators.common; +import mekanism.common.IBoundingBlock; import mekanism.common.Mekanism; +import mekanism.common.MekanismUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; -import universalelectricity.core.vector.Vector3; -import universalelectricity.prefab.multiblock.IMultiBlock; -public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator implements IMultiBlock +public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator implements IBoundingBlock { public TileEntityAdvancedSolarGenerator() { @@ -14,21 +14,21 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i } @Override - public void onCreate(Vector3 position) + public void onPlace() { - Mekanism.NullRender.makeFakeBlock(worldObj, new Vector3(xCoord, yCoord+1, zCoord), new Vector3(xCoord, yCoord, zCoord)); + MekanismUtils.makeBoundingBlock(worldObj, xCoord, yCoord+1, zCoord, xCoord, yCoord, zCoord); for(int x=-1;x<=1;x++) { for(int z=-1;z<=1;z++) { - Mekanism.NullRender.makeFakeBlock(worldObj, new Vector3(xCoord+x, yCoord+2, zCoord+z), position); + MekanismUtils.makeBoundingBlock(worldObj, xCoord+x, yCoord+2, zCoord+z, xCoord, yCoord, zCoord); } } } @Override - public void onDestroy(TileEntity tileEntity) + public void onBreak() { worldObj.setBlock(xCoord, yCoord+1, zCoord, 0); @@ -41,17 +41,5 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i } worldObj.setBlock(xCoord, yCoord, zCoord, 0); - invalidate(); - } - - @Override - public boolean onActivated(EntityPlayer entityplayer) - { - if(!entityplayer.isSneaking()) - { - entityplayer.openGui(MekanismGenerators.instance, 1, worldObj, xCoord, yCoord, zCoord); - return true; - } - return false; } } diff --git a/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java b/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java index 78f46283e..e576d7263 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityElectrolyticSeparator.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.EnumSet; import mekanism.api.EnumGas; +import mekanism.api.GasTransmission; import mekanism.api.IGasAcceptor; import mekanism.api.IGasStorage; import mekanism.api.IStorageTank; @@ -72,7 +73,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp public TileEntityElectrolyticSeparator() { - super("Electrolytic Seperator", 9600); + super("Electrolytic Separator", 9600); ElectricityConnections.registerConnector(this, EnumSet.allOf(ForgeDirection.class)); inventory = new ItemStack[4]; outputType = EnumGas.HYDROGEN; @@ -90,16 +91,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp setJoules(electricityStored + received); } - if(hydrogenStored > MAX_GAS) - { - hydrogenStored = MAX_GAS; - } - - if(oxygenStored > MAX_GAS) - { - oxygenStored = MAX_GAS; - } - if(!worldObj.isRemote) { for(ForgeDirection direction : ForgeDirection.values()) @@ -246,7 +237,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp if(outputType != EnumGas.NONE && getGas(outputType) > 0 && !worldObj.isRemote) { - setGas(outputType, getGas(outputType) - (Math.min(getGas(outputType), output) - MekanismUtils.emitGasToNetwork(outputType, Math.min(getGas(outputType), output), this, ForgeDirection.getOrientation(facing)))); + setGas(outputType, getGas(outputType) - (Math.min(getGas(outputType), output) - GasTransmission.emitGasToNetwork(outputType, Math.min(getGas(outputType), output), this, ForgeDirection.getOrientation(facing)))); TileEntity tileEntity = Vector3.getTileEntityFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(facing)); diff --git a/src/minecraft/mekanism/nei/NEIMekanismConfig.java b/src/minecraft/mekanism/nei/NEIMekanismConfig.java index 609324860..8cb8d4309 100644 --- a/src/minecraft/mekanism/nei/NEIMekanismConfig.java +++ b/src/minecraft/mekanism/nei/NEIMekanismConfig.java @@ -22,7 +22,7 @@ public class NEIMekanismConfig implements IConfigureNEI API.registerRecipeHandler(new PurificationChamberRecipeHandler()); API.registerUsageHandler(new PurificationChamberRecipeHandler()); - API.hideItem(Mekanism.nullRenderID); + API.hideItem(Mekanism.boundingBlockID); } @Override diff --git a/src/minecraft/mekanism/tools/common/ItemMekanismHoe.java b/src/minecraft/mekanism/tools/common/ItemMekanismHoe.java index 3d50ca1d0..d32396f0d 100644 --- a/src/minecraft/mekanism/tools/common/ItemMekanismHoe.java +++ b/src/minecraft/mekanism/tools/common/ItemMekanismHoe.java @@ -1,5 +1,7 @@ package mekanism.tools.common; +import java.util.List; + import mekanism.common.ItemMekanism; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; @@ -36,12 +38,12 @@ public class ItemMekanismHoe extends ItemMekanism else { UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z); - if (MinecraftForge.EVENT_BUS.post(event)) + if(MinecraftForge.EVENT_BUS.post(event)) { return false; } - if (event.getResult() == Result.ALLOW) + if(event.getResult() == Result.ALLOW) { itemstack.damageItem(1, entityplayer); return true; @@ -50,12 +52,11 @@ public class ItemMekanismHoe extends ItemMekanism int blockID = world.getBlockId(x, y, z); int aboveBlockID = world.getBlockId(x, y + 1, z); - if ((side == 0 || aboveBlockID != 0 || blockID != Block.grass.blockID) && blockID != Block.dirt.blockID) + if((side == 0 || aboveBlockID != 0 || blockID != Block.grass.blockID) && blockID != Block.dirt.blockID) { return false; } - else - { + else { Block block = Block.tilledField; world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); @@ -63,8 +64,7 @@ public class ItemMekanismHoe extends ItemMekanism { return true; } - else - { + else { world.setBlockWithNotify(x, y, z, block.blockID); itemstack.damageItem(1, entityplayer); return true; @@ -72,6 +72,12 @@ public class ItemMekanismHoe extends ItemMekanism } } } + + @Override + public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) + { + list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); + } @Override @SideOnly(Side.CLIENT) diff --git a/src/minecraft/mekanism/tools/common/MekanismTools.java b/src/minecraft/mekanism/tools/common/MekanismTools.java index 8fce6aac5..5d4924569 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.4.0", dependencies = "required-after:Mekanism") +@Mod(modid = "MekanismTools", name = "MekanismTools", version = "5.4.1", dependencies = "required-after:Mekanism") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class MekanismTools { @@ -619,7 +619,7 @@ public class MekanismTools int chance = random.nextInt(100); int secondChance = random.nextInt(3); - if(chance < 4) + if(chance < 3) { if(event.entityLiving instanceof EntityZombie || event.entityLiving instanceof EntitySkeleton) {