diff --git a/src/minecraft/dan200/computer/api/ComputerCraftAPI.java b/src/minecraft/dan200/computer/api/ComputerCraftAPI.java index 159dfe4a3..56ae3a127 100644 --- a/src/minecraft/dan200/computer/api/ComputerCraftAPI.java +++ b/src/minecraft/dan200/computer/api/ComputerCraftAPI.java @@ -13,25 +13,7 @@ import java.lang.reflect.Method; * but may be called before it is fully loaded. */ public class ComputerCraftAPI -{ - /** - * Get the creative mode tab that ComputerCraft items can be found on. - * Use this to add your peripherals to ComputerCraft's tab. - */ - public static net.minecraft.creativetab.CreativeTabs getCreativeTab() - { - findCC(); - if (computerCraft_getCreativeTab != null) - { - try { - return (net.minecraft.creativetab.CreativeTabs)( computerCraft_getCreativeTab.invoke(null) ); - } catch (Exception e){ - // It failed - } - } - return null; - } - +{ /** * Registers a peripheral handler for a TileEntity that you do not have access to. Only * use this if you want to expose IPeripheral on a TileEntity from another mod. For your own @@ -61,7 +43,6 @@ public class ComputerCraftAPI if( !ccSearched ) { try { computerCraft = Class.forName( "dan200.ComputerCraft" ); - computerCraft_getCreativeTab = findCCMethod( "getCreativeTab", new Class[] { } ); computerCraft_registerExternalPeripheral = findCCMethod( "registerExternalPeripheral", new Class[] { Class.class, IPeripheralHandler.class } ); @@ -87,5 +68,4 @@ public class ComputerCraftAPI private static boolean ccSearched = false; private static Class computerCraft = null; private static Method computerCraft_registerExternalPeripheral = null; - private static Method computerCraft_getCreativeTab = null; } diff --git a/src/minecraft/ic2/api/crops/CropCard.java b/src/minecraft/ic2/api/crops/CropCard.java index 55db086fa..8214f02ea 100644 --- a/src/minecraft/ic2/api/crops/CropCard.java +++ b/src/minecraft/ic2/api/crops/CropCard.java @@ -1,7 +1,5 @@ package ic2.api.crops; -import java.util.HashMap; - import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; @@ -363,7 +361,7 @@ public abstract class CropCard { return Crops.instance.getIdFor(this); } - + @SideOnly(Side.CLIENT) protected Icon textures[]; } diff --git a/src/minecraft/ic2/api/crops/Crops.java b/src/minecraft/ic2/api/crops/Crops.java index 26d0c45bb..c3ee51541 100644 --- a/src/minecraft/ic2/api/crops/Crops.java +++ b/src/minecraft/ic2/api/crops/Crops.java @@ -1,23 +1,18 @@ package ic2.api.crops; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.oredict.OreDictionary; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * General management of the crop system. */ public abstract class Crops { public static Crops instance; - + /** * Adds a crop humidity and nutrient biome bonus. * @@ -28,30 +23,30 @@ public abstract class Crops { * @param nutrientsBonus Nutrient stat bonus */ public abstract void addBiomeBonus(BiomeGenBase biome, int humidityBonus, int nutrientsBonus); - + /** - * Gets the humidity bonus for a biome. + * Gets the humidity bonus for a biome. * * @param biome Biome to check * @return Humidity bonus or 0 if none */ public abstract int getHumidityBiomeBonus(BiomeGenBase biome); - + /** - * Gets the nutrient bonus for a biome. + * Gets the nutrient bonus for a biome. * * @param biome Biome to check * @return Nutrient bonus or 0 if none */ public abstract int getNutrientBiomeBonus(BiomeGenBase biome); - + /** * Returns the list of registered crops. - * + * * @return Registered crops by ID */ public abstract CropCard[] getCropList(); - + /** * Auto-assign an ID to a plant and register it. * Usage of this method is not recommended! Other plants could take your IDs and cause your plants to turn into other plants. @@ -60,7 +55,7 @@ public abstract class Crops { * @return The ID assigned to the plant */ public abstract short registerCrop(CropCard crop); - + /** * Attempt to register a plant to an ID. * If the ID is taken, the crop will not be registered and a console print will notify the user. @@ -70,7 +65,7 @@ public abstract class Crops { * @return Whether the crop was registered */ public abstract boolean registerCrop(CropCard crop, int i); - + /** * Registers a base seed, an item used to plant a crop. * @@ -83,14 +78,14 @@ public abstract class Crops { * @return True if successful */ public abstract boolean registerBaseSeed(ItemStack stack, int id, int size, int growth, int gain, int resistance); - + /** * Finds a base seed from the given item. * * @return Base seed or null if none found */ public abstract BaseSeed getBaseSeed(ItemStack stack); - + /** * Execute registerSprites for all registered crop cards. * @@ -98,7 +93,7 @@ public abstract class Crops { */ @SideOnly(Side.CLIENT) public abstract void startSpriteRegistration(IconRegister iconRegister); - + /** * Returns the ID for the given crop. * diff --git a/src/minecraft/ic2/api/info/IEnergyValueProvider.java b/src/minecraft/ic2/api/info/IEnergyValueProvider.java new file mode 100644 index 000000000..50e84e6e8 --- /dev/null +++ b/src/minecraft/ic2/api/info/IEnergyValueProvider.java @@ -0,0 +1,14 @@ +package ic2.api.info; + +import net.minecraft.item.ItemStack; + +public interface IEnergyValueProvider { + /** + * Determine the energy value for a single item in the supplied stack. + * The value is used by most machines in the discharge slot. + * + * @param itemStack ItemStack containing the item to evaluate. + * @return energy in EU + */ + int getEnergyValue(ItemStack itemStack); +} diff --git a/src/minecraft/ic2/api/info/IFuelValueProvider.java b/src/minecraft/ic2/api/info/IFuelValueProvider.java new file mode 100644 index 000000000..7c7fe0f4c --- /dev/null +++ b/src/minecraft/ic2/api/info/IFuelValueProvider.java @@ -0,0 +1,15 @@ +package ic2.api.info; + +import net.minecraft.item.ItemStack; + +public interface IFuelValueProvider { + /** + * Determine the fuel value for a single item in the supplied stack. + * The information currently applies to Generators and the Iron Furnace. + * + * @param itemStack ItemStack containing the item to evaluate. + * @param allowLava Determine if lava has a fuel value, currently only true for the Iron Furnace. + * @return fuel value + */ + int getFuelValue(ItemStack itemStack, boolean allowLava); +} diff --git a/src/minecraft/ic2/api/info/Info.java b/src/minecraft/ic2/api/info/Info.java new file mode 100644 index 000000000..48b85d7ee --- /dev/null +++ b/src/minecraft/ic2/api/info/Info.java @@ -0,0 +1,6 @@ +package ic2.api.info; + +public class Info { + public static IEnergyValueProvider itemEnergy; + public static IFuelValueProvider itemFuel; +} diff --git a/src/minecraft/ic2/api/item/ElectricItem.java b/src/minecraft/ic2/api/item/ElectricItem.java index 051a76b0a..511220fd8 100644 --- a/src/minecraft/ic2/api/item/ElectricItem.java +++ b/src/minecraft/ic2/api/item/ElectricItem.java @@ -1,7 +1,5 @@ package ic2.api.item; -import java.lang.reflect.Method; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -12,6 +10,20 @@ import net.minecraft.item.ItemStack; * ignoreTransferLimit and simulate set to true. */ public final class ElectricItem { + /** + * IElectricItemManager to use for interacting with IElectricItem ItemStacks. + * + * This manager will act as a gateway and delegate the tasks to the final implementation + * (rawManager or a custom one) as necessary. + */ + public static IElectricItemManager manager; + + /** + * Standard IElectricItemManager implementation, only call it directly from another + * IElectricItemManager. Use manager instead. + */ + public static IElectricItemManager rawManager; + /** * Charge an item with a specified amount of energy * @@ -21,15 +33,12 @@ public final class ElectricItem { * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() * @param simulate don't actually change the item, just determine the return value * @return Energy transferred into the electric item + * + * @deprecated use manager.charge() instead */ + @Deprecated public static int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) { - try { - if (ElectricItem_charge == null) ElectricItem_charge = Class.forName(getPackage() + ".core.item.ElectricItem").getMethod("charge", ItemStack.class, Integer.TYPE, Integer.TYPE, Boolean.TYPE, Boolean.TYPE); - - return (Integer) ElectricItem_charge.invoke(null, itemStack, amount, tier, ignoreTransferLimit, simulate); - } catch (Exception e) { - throw new RuntimeException(e); - } + return manager.charge(itemStack, amount, tier, ignoreTransferLimit, simulate); } /** @@ -41,15 +50,12 @@ public final class ElectricItem { * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() * @param simulate don't actually discharge the item, just determine the return value * @return Energy retrieved from the electric item + * + * @deprecated use manager.discharge() instead */ + @Deprecated public static int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) { - try { - if (ElectricItem_discharge == null) ElectricItem_discharge = Class.forName(getPackage() + ".core.item.ElectricItem").getMethod("discharge", ItemStack.class, Integer.TYPE, Integer.TYPE, Boolean.TYPE, Boolean.TYPE); - - return (Integer) ElectricItem_discharge.invoke(null, itemStack, amount, tier, ignoreTransferLimit, simulate); - } catch (Exception e) { - throw new RuntimeException(e); - } + return manager.discharge(itemStack, amount, tier, ignoreTransferLimit, simulate); } /** @@ -60,15 +66,12 @@ public final class ElectricItem { * @param itemStack electric item's stack * @param amount minimum amount of energy required * @return true if there's enough energy + * + * @deprecated use manager.canUse() instead */ + @Deprecated public static boolean canUse(ItemStack itemStack, int amount) { - try { - if (ElectricItem_canUse == null) ElectricItem_canUse = Class.forName(getPackage() + ".core.item.ElectricItem").getMethod("canUse", ItemStack.class, Integer.TYPE); - - return (Boolean) ElectricItem_canUse.invoke(null, itemStack, amount); - } catch (Exception e) { - throw new RuntimeException(e); - } + return manager.canUse(itemStack, amount); } /** @@ -79,15 +82,12 @@ public final class ElectricItem { * @param amount amount of energy to discharge in EU * @param player player holding the item * @return true if the operation succeeded + * + * @deprecated use manager.use() instead */ + @Deprecated public static boolean use(ItemStack itemStack, int amount, EntityPlayer player) { - try { - if (ElectricItem_use == null) ElectricItem_use = Class.forName(getPackage() + ".core.item.ElectricItem").getMethod("use", ItemStack.class, Integer.TYPE, EntityPlayer.class); - - return (Boolean) ElectricItem_use.invoke(null, itemStack, amount, player); - } catch (Exception e) { - throw new RuntimeException(e); - } + return manager.use(itemStack, amount, player); } /** @@ -97,38 +97,12 @@ public final class ElectricItem { * * @param itemStack electric item's stack * @param player player holding the item + * + * @deprecated use manager.chargeFromArmor() instead */ + @Deprecated public static void chargeFromArmor(ItemStack itemStack, EntityPlayer player) { - try { - if (ElectricItem_chargeFromArmor == null) ElectricItem_chargeFromArmor = Class.forName(getPackage() + ".core.item.ElectricItem").getMethod("chargeFromArmor", ItemStack.class, EntityPlayer.class); - - ElectricItem_chargeFromArmor.invoke(null, itemStack, player); - } catch (Exception e) { - throw new RuntimeException(e); - } + manager.chargeFromArmor(itemStack, player); } - - /** - * Get the base IC2 package name, used internally. - * - * @return IC2 package name, if unable to be determined defaults to ic2 - */ - private static String getPackage() { - Package pkg = ElectricItem.class.getPackage(); - - if (pkg != null) { - String packageName = pkg.getName(); - - return packageName.substring(0, packageName.length() - ".api.item".length()); - } - - return "ic2"; - } - - private static Method ElectricItem_charge; - private static Method ElectricItem_discharge; - private static Method ElectricItem_canUse; - private static Method ElectricItem_use; - private static Method ElectricItem_chargeFromArmor; } diff --git a/src/minecraft/ic2/api/item/ICustomElectricItem.java b/src/minecraft/ic2/api/item/ICustomElectricItem.java index 8c1baea40..9f4b1a684 100644 --- a/src/minecraft/ic2/api/item/ICustomElectricItem.java +++ b/src/minecraft/ic2/api/item/ICustomElectricItem.java @@ -10,12 +10,15 @@ import net.minecraft.item.ItemStack; * * The default implementation (when not using ICustomElectricItem) does the following: * - store and retrieve the charge - * - handle charging, taking amount, tier, transfer limit and simulate into account + * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) * - update and manage the damage value for the visual charge indicator * * @note ICustomElectricItem must not call the ElectricItem methods charge, discharge or canUse + * + * @deprecated Use ISpecialElectricItem instead. */ +@Deprecated public interface ICustomElectricItem extends IElectricItem { /** * Charge an item with a specified amount of energy diff --git a/src/minecraft/ic2/api/item/IElectricItemManager.java b/src/minecraft/ic2/api/item/IElectricItemManager.java new file mode 100644 index 000000000..6f08be3bd --- /dev/null +++ b/src/minecraft/ic2/api/item/IElectricItemManager.java @@ -0,0 +1,92 @@ +package ic2.api.item; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.ItemStack; + +/** + * This interface specifies a manager to handle the various tasks for electric items. + * + * The default implementation does the following: + * - store and retrieve the charge + * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account + * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) + * - update and manage the damage value for the visual charge indicator + * + * @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the + * default implementations through ElectricItem.rawManager. The default implementation is designed + * to minimize its dependency on its own constraints/structure and delegates most work back to the + * more atomic features in the gateway manager. + */ +public interface IElectricItemManager { + /** + * Charge an item with a specified amount of energy + * + * @param itemStack electric item's stack + * @param amount amount of energy to charge in EU + * @param tier tier of the charging device, has to be at least as high as the item to charge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param simulate don't actually change the item, just determine the return value + * @return Energy transferred into the electric item + */ + int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate); + + /** + * Discharge an item by a specified amount of energy + * + * @param itemStack electric item's stack + * @param amount amount of energy to charge in EU + * @param tier tier of the discharging device, has to be at least as high as the item to discharge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param simulate don't actually discharge the item, just determine the return value + * @return Energy retrieved from the electric item + */ + int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate); + + /** + * Determine the charge level for the specified item + * + * @param itemStack ItemStack containing the electric item + * @return charge level in EU + */ + int getCharge(ItemStack itemStack); + + /** + * Determine if the specified electric item has at least a specific amount of EU. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * BatPacks are not taken into account. + * + * @param itemStack electric item's stack + * @param amount minimum amount of energy required + * @return true if there's enough energy + */ + boolean canUse(ItemStack itemStack, int amount); + + /** + * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param entity entity holding the item + * @return true if the operation succeeded + */ + boolean use(ItemStack itemStack, int amount, EntityLiving entity); + + /** + * Charge an item from the BatPack a player is wearing. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * use() already contains this functionality. + * + * @param itemStack electric item's stack + * @param entity entity holding the item + */ + void chargeFromArmor(ItemStack itemStack, EntityLiving entity); + + /** + * Get the tool tip to display for electric items. + * + * @param itemStack ItemStack to determine the tooltip for + * @return tool tip string or null for none + */ + String getToolTip(ItemStack itemStack); +} diff --git a/src/minecraft/ic2/api/item/ISpecialElectricItem.java b/src/minecraft/ic2/api/item/ISpecialElectricItem.java new file mode 100644 index 000000000..a7302f530 --- /dev/null +++ b/src/minecraft/ic2/api/item/ISpecialElectricItem.java @@ -0,0 +1,13 @@ +package ic2.api.item; + +import net.minecraft.item.ItemStack; + +public interface ISpecialElectricItem extends IElectricItem { + /** + * Supply a custom IElectricItemManager. + * + * @param itemStack ItemStack to get the manager for + * @return IElectricItemManager instance + */ + IElectricItemManager getManager(ItemStack itemStack); +} diff --git a/src/minecraft/ic2/api/tile/IWrenchable.java b/src/minecraft/ic2/api/tile/IWrenchable.java index b82c6ffb6..f01441698 100644 --- a/src/minecraft/ic2/api/tile/IWrenchable.java +++ b/src/minecraft/ic2/api/tile/IWrenchable.java @@ -52,7 +52,7 @@ public interface IWrenchable { * Determine the item the block will drop when the wrenching is successful. * * @param entityPlayer player using the wrench, may be null - * @return Item to drop + * @return Item to drop, may be null */ ItemStack getWrenchDrop(EntityPlayer entityPlayer); } diff --git a/src/minecraft/mekanism/client/BasicRenderingHandler.java b/src/minecraft/mekanism/client/BasicRenderingHandler.java index 0f56bc028..bc7cae5ce 100644 --- a/src/minecraft/mekanism/client/BasicRenderingHandler.java +++ b/src/minecraft/mekanism/client/BasicRenderingHandler.java @@ -24,7 +24,7 @@ public class BasicRenderingHandler implements ISimpleBlockRenderingHandler if(block.blockID == Mekanism.basicBlockID) { - renderItem(renderer, metadata, block); + MekanismRenderer.renderItem(renderer, metadata, block); } GL11.glPopMatrix(); @@ -57,55 +57,4 @@ public class BasicRenderingHandler implements ISimpleBlockRenderingHandler { return ClientProxy.BASIC_RENDER_ID; } - - /** - * Cleaned-up snip of RenderBlocks.renderBlockAsItem() -- used for rendering an item as an entity, - * in a player's inventory, and in a player's hand. - * @param renderer - RenderBlocks renderer to render the item with - * @param metadata - block/item metadata - * @param block - block to render - */ - public void renderItem(RenderBlocks renderer, int metadata, Block block) - { - block.setBlockBoundsForItemRender(); - - renderer.setRenderBoundsFromBlock(block); - - if(renderer.useInventoryTint) - { - int renderColor = block.getRenderColor(metadata); - float red = (float)(renderColor >> 16 & 255) / 255.0F; - float green = (float)(renderColor >> 8 & 255) / 255.0F; - float blue = (float)(renderColor & 255) / 255.0F; - GL11.glColor4f(red, green, blue, 1.0F); - } - - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); - tessellator.draw(); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } } diff --git a/src/minecraft/mekanism/client/ClientPlayerTickHandler.java b/src/minecraft/mekanism/client/ClientPlayerTickHandler.java index cc276309f..b74c1541f 100644 --- a/src/minecraft/mekanism/client/ClientPlayerTickHandler.java +++ b/src/minecraft/mekanism/client/ClientPlayerTickHandler.java @@ -46,9 +46,9 @@ public class ClientPlayerTickHandler implements ITickHandler { if(!lastTickConfiguratorChange) { - item.setState(stack, (byte)(item.getState(stack) == 0 ? 1 : (item.getState(stack) == 1 ? 2 : 0))); + item.setState(stack, (byte)(item.getState(stack) < 3 ? item.getState(stack)+1 : 0)); PacketHandler.sendPacketDataInt(EnumPacketType.CONFIGURATOR_STATE, item.getState(stack)); - entityPlayer.sendChatToPlayer(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Configure State: " + (item.getState(stack) == 0 ? (EnumColor.BRIGHT_GREEN + "modify") : (item.getState(stack) == 1 ? (EnumColor.AQUA + "empty") : (EnumColor.YELLOW + "upgrade dump")))); + entityPlayer.sendChatToPlayer(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Configure State: " + item.getColor(item.getState(stack)) + item.getState(item.getState(stack))); lastTickConfiguratorChange = true; } } diff --git a/src/minecraft/mekanism/client/MachineRenderingHandler.java b/src/minecraft/mekanism/client/MachineRenderingHandler.java index 50cb88a80..0d29131f9 100644 --- a/src/minecraft/mekanism/client/MachineRenderingHandler.java +++ b/src/minecraft/mekanism/client/MachineRenderingHandler.java @@ -77,7 +77,7 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler chargepad.render(0.0625F); } else { - renderItem(renderer, metadata, block); + MekanismRenderer.renderItem(renderer, metadata, block); } } @@ -113,54 +113,4 @@ public class MachineRenderingHandler implements ISimpleBlockRenderingHandler { return ClientProxy.MACHINE_RENDER_ID; } - - /** - * Cleaned-up snip of RenderBlocks.renderBlockAsItem() -- used for rendering an item as an entity, - * in a player's inventory, and in a player's hand. - * @param renderer - RenderBlocks renderer to render the item with - * @param metadata - block/item metadata - * @param block - block to render - */ - public void renderItem(RenderBlocks renderer, int metadata, Block block) - { - //nope - renderer.setRenderBounds(0, 0, 0, 1, 1, 1); - - if (renderer.useInventoryTint) - { - int renderColor = block.getRenderColor(metadata); - float red = (float)(renderColor >> 16 & 255) / 255.0F; - float green = (float)(renderColor >> 8 & 255) / 255.0F; - float blue = (float)(renderColor & 255) / 255.0F; - GL11.glColor4f(red, green, blue, 1.0F); - } - - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); - tessellator.draw(); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } } diff --git a/src/minecraft/mekanism/client/MekanismRenderer.java b/src/minecraft/mekanism/client/MekanismRenderer.java index ed74bd3d7..d61a7f9fa 100644 --- a/src/minecraft/mekanism/client/MekanismRenderer.java +++ b/src/minecraft/mekanism/client/MekanismRenderer.java @@ -1,5 +1,6 @@ package mekanism.client; +import mekanism.common.ISpecialBounds; import net.minecraft.block.Block; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderBlocks; @@ -182,6 +183,71 @@ public class MekanismRenderer GL11.glPopAttrib(); } + /** + * Cleaned-up snip of RenderBlocks.renderBlockAsItem() -- used for rendering an item as an entity, + * in a player's inventory, and in a player's hand. + * @param renderer - RenderBlocks renderer to render the item with + * @param metadata - block/item metadata + * @param block - block to render + */ + public static void renderItem(RenderBlocks renderer, int metadata, Block block) + { + if(!(block instanceof ISpecialBounds) || ((ISpecialBounds)block).doDefaultBoundSetting(metadata)) + { + block.setBlockBoundsForItemRender(); + } + + if(block instanceof ISpecialBounds) + { + ((ISpecialBounds)block).setRenderBounds(block, metadata); + } + + if(!(block instanceof ISpecialBounds) || ((ISpecialBounds)block).doDefaultBoundSetting(metadata)) + { + renderer.setRenderBoundsFromBlock(block); + } + else { + renderer.setRenderBounds(0, 0, 0, 1, 1, 1); + } + + if(renderer.useInventoryTint) + { + int renderColor = block.getRenderColor(metadata); + float red = (float)(renderColor >> 16 & 255) / 255.0F; + float green = (float)(renderColor >> 8 & 255) / 255.0F; + float blue = (float)(renderColor & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); + } + + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + public static class DisplayInteger { public int display; diff --git a/src/minecraft/mekanism/client/RenderConfigurableMachine.java b/src/minecraft/mekanism/client/RenderConfigurableMachine.java index 64f111225..b4ae76eba 100644 --- a/src/minecraft/mekanism/client/RenderConfigurableMachine.java +++ b/src/minecraft/mekanism/client/RenderConfigurableMachine.java @@ -15,6 +15,7 @@ import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; @@ -72,9 +73,10 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer TileEntity tileEntity = (TileEntity)configurable; EntityPlayer player = mc.thePlayer; World world = mc.thePlayer.worldObj; + ItemStack itemStack = player.getCurrentEquippedItem(); MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F); - if(pos != null && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemConfigurator) + if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator && ((ItemConfigurator)itemStack.getItem()).getState(itemStack) == 0) { int xPos = MathHelper.floor_double(pos.blockX); int yPos = MathHelper.floor_double(pos.blockY); diff --git a/src/minecraft/mekanism/client/RenderTickHandler.java b/src/minecraft/mekanism/client/RenderTickHandler.java index 62e5f02a1..d4c788015 100644 --- a/src/minecraft/mekanism/client/RenderTickHandler.java +++ b/src/minecraft/mekanism/client/RenderTickHandler.java @@ -3,6 +3,7 @@ package mekanism.client; import java.util.EnumSet; import mekanism.api.Object3D; +import mekanism.common.Mekanism; import mekanism.common.MekanismUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -45,7 +46,7 @@ public class RenderTickHandler implements ITickHandler Object3D obj = new Object3D(x, y, z); - if(!MekanismUtils.isObfuscated() && mc.currentScreen == null && !mc.gameSettings.showDebugInfo) + if(Mekanism.debug && mc.currentScreen == null && !mc.gameSettings.showDebugInfo) { String tileDisplay = ""; diff --git a/src/minecraft/mekanism/common/BlockEnergyCube.java b/src/minecraft/mekanism/common/BlockEnergyCube.java index 4dcfafd9c..08161dbe3 100644 --- a/src/minecraft/mekanism/common/BlockEnergyCube.java +++ b/src/minecraft/mekanism/common/BlockEnergyCube.java @@ -238,7 +238,7 @@ public class BlockEnergyCube extends BlockContainer } } - if (tileEntity != null) + if(tileEntity != null) { if(!entityplayer.isSneaking()) { diff --git a/src/minecraft/mekanism/common/BlockMachine.java b/src/minecraft/mekanism/common/BlockMachine.java index 8aab98aa3..1517b2111 100644 --- a/src/minecraft/mekanism/common/BlockMachine.java +++ b/src/minecraft/mekanism/common/BlockMachine.java @@ -7,6 +7,7 @@ import mekanism.api.IEnergizedItem; import mekanism.api.IUpgradeManagement; import mekanism.client.ClientProxy; import mekanism.common.IFactory.RecipeType; +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; @@ -49,7 +50,7 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class BlockMachine extends BlockContainer +public class BlockMachine extends BlockContainer implements ISpecialBounds { public Icon[][] icons = new Icon[256][256]; public Random machineRand = new Random(); @@ -834,4 +835,13 @@ public class BlockMachine extends BlockContainer return Integer.toString(meta); } } + + @Override + public void setRenderBounds(Block block, int metadata) {} + + @Override + public boolean doDefaultBoundSetting(int metadata) + { + return false; + } } diff --git a/src/minecraft/mekanism/common/CommandMekanism.java b/src/minecraft/mekanism/common/CommandMekanism.java index 48a40b34b..8a82c0da3 100644 --- a/src/minecraft/mekanism/common/CommandMekanism.java +++ b/src/minecraft/mekanism/common/CommandMekanism.java @@ -3,6 +3,8 @@ package mekanism.common; import java.util.Arrays; import java.util.List; +import cpw.mods.fml.common.FMLCommonHandler; + import mekanism.api.EnumColor; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; @@ -51,9 +53,9 @@ public class CommandMekanism extends CommandBase sender.sendChatToPlayer(EnumColor.INDIGO + " /mk version" + EnumColor.GREY + " -- displays the version number."); sender.sendChatToPlayer(EnumColor.INDIGO + " /mk latest" + EnumColor.GREY + " -- displays the latest version number."); sender.sendChatToPlayer(EnumColor.INDIGO + " /mk news" + EnumColor.GREY + " -- displays most recent recent news."); + sender.sendChatToPlayer(EnumColor.INDIGO + " /mk debug" + EnumColor.GREY + " -- toggles Mekanism's debug mode."); sender.sendChatToPlayer(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------"); } - else if(params[0].equalsIgnoreCase("version")) { if(!MekanismUtils.checkForUpdates((EntityPlayer)sender)) @@ -67,17 +69,19 @@ public class CommandMekanism extends CommandBase } } } - else if(params[0].equalsIgnoreCase("news")) { sender.sendChatToPlayer(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Most recent news: " + EnumColor.INDIGO + Mekanism.recentNews); } - else if(params[0].equalsIgnoreCase("latest")) { sender.sendChatToPlayer(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " The latest version for this mod is " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber + EnumColor.GREY + "."); } - + else if(params[0].equalsIgnoreCase("debug")) + { + Mekanism.debug = !Mekanism.debug; + sender.sendChatToPlayer(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Debug mode set to " + EnumColor.DARK_GREY + Mekanism.debug); + } else { sender.sendChatToPlayer(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Unknown command. Type '" + EnumColor.INDIGO + "/mk help" + EnumColor.GREY + "' for help."); } diff --git a/src/minecraft/mekanism/common/FactoryRecipe.java b/src/minecraft/mekanism/common/FactoryRecipe.java index 10b5c4c18..6cc449ece 100644 --- a/src/minecraft/mekanism/common/FactoryRecipe.java +++ b/src/minecraft/mekanism/common/FactoryRecipe.java @@ -128,13 +128,14 @@ public class FactoryRecipe implements IRecipe input = new Object[width * height]; int x = 0; + for(char chr : shape.toCharArray()) { input[x++] = itemMap.get(chr); } } - FactoryRecipe(ShapedRecipes recipe, Map replacements) + public FactoryRecipe(ShapedRecipes recipe, Map replacements) { output = recipe.getRecipeOutput(); width = recipe.recipeWidth; diff --git a/src/minecraft/mekanism/common/ISpecialBounds.java b/src/minecraft/mekanism/common/ISpecialBounds.java new file mode 100644 index 000000000..6744078d0 --- /dev/null +++ b/src/minecraft/mekanism/common/ISpecialBounds.java @@ -0,0 +1,25 @@ +package mekanism.common; + +import net.minecraft.block.Block; + +/** + * Implement if you have metadata-sensitive block rendering bounds. + * @author aidancbrady + * + */ +public interface ISpecialBounds +{ + /** + * Sets the render bounds for this particular block's subtype. + * @param block - the Block instance the renderer pertains to. + * @param metadata - metadata of the block being rendered + */ + public void setRenderBounds(Block block, int metadata); + + /** + * Whether or not to call the default setBlockBoundsForItemRender() before rendering this block as an item. + * @param metadata - metadata of the block being rendered + * @return whether or not to call default bound setting on this block's metadata. + */ + public boolean doDefaultBoundSetting(int metadata); +} diff --git a/src/minecraft/mekanism/common/ItemConfigurator.java b/src/minecraft/mekanism/common/ItemConfigurator.java index 609aff5ee..0961a74f2 100644 --- a/src/minecraft/mekanism/common/ItemConfigurator.java +++ b/src/minecraft/mekanism/common/ItemConfigurator.java @@ -7,12 +7,13 @@ import java.util.Random; import mekanism.api.EnumColor; import mekanism.api.IConfigurable; import mekanism.api.IUpgradeManagement; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.electricity.ElectricityPack; public class ItemConfigurator extends ItemEnergized @@ -29,7 +30,7 @@ public class ItemConfigurator extends ItemEnergized public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { super.addInformation(itemstack, entityplayer, list, flag); - list.add(EnumColor.PINK + "State: " + EnumColor.GREY + (getState(itemstack) == 0 ? "modify" : (getState(itemstack) == 1 ? "empty" : "upgrade dump"))); + list.add(EnumColor.PINK + "State: " + EnumColor.GREY + getState(getState(itemstack))); } @Override @@ -172,10 +173,71 @@ public class ItemConfigurator extends ItemEnergized return true; } } + else if(getState(stack) == 3) + { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + if(tileEntity instanceof TileEntityBasicBlock) + { + TileEntityBasicBlock basicBlock = (TileEntityBasicBlock)tileEntity; + int newSide = basicBlock.facing; + + if(!player.isSneaking()) + { + newSide = side; + } + else { + newSide = ForgeDirection.OPPOSITES[side]; + } + + if(basicBlock.canSetFacing(newSide)) + { + basicBlock.setFacing((short)newSide); + world.playSoundEffect(x, y, z, "random.click", 1.0F, 1.0F); + } + + return true; + } + } } + return false; } + public String getState(int state) + { + switch(state) + { + case 0: + return "modify"; + case 1: + return "empty"; + case 2: + return "upgrade dump"; + case 3: + return "wrench"; + } + + return "unknown"; + } + + public EnumColor getColor(int state) + { + switch(state) + { + case 0: + return EnumColor.BRIGHT_GREEN; + case 1: + return EnumColor.AQUA; + case 2: + return EnumColor.YELLOW; + case 3: + return EnumColor.ORANGE; + } + + return EnumColor.GREY; + } + public void setState(ItemStack itemstack, byte state) { if(itemstack.stackTagCompound == null) diff --git a/src/minecraft/mekanism/common/Mekanism.java b/src/minecraft/mekanism/common/Mekanism.java index 14072ca17..69529ac7e 100644 --- a/src/minecraft/mekanism/common/Mekanism.java +++ b/src/minecraft/mekanism/common/Mekanism.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.Map; import java.util.logging.Logger; -import mekanism.api.EnumGas; import mekanism.api.GasTransferProtocol.GasTransferEvent; import mekanism.api.InfuseObject; import mekanism.api.InfusionInput; @@ -71,6 +70,9 @@ public class Mekanism @SidedProxy(clientSide = "mekanism.client.ClientProxy", serverSide = "mekanism.common.CommonProxy") public static CommonProxy proxy; + /** Mekanism debug mode */ + public static boolean debug = false; + /** Mekanism mod instance */ @Instance("Mekanism") public static Mekanism instance; diff --git a/src/minecraft/mekanism/common/MekanismUtils.java b/src/minecraft/mekanism/common/MekanismUtils.java index 6c7c230f9..23ac94cdc 100644 --- a/src/minecraft/mekanism/common/MekanismUtils.java +++ b/src/minecraft/mekanism/common/MekanismUtils.java @@ -371,6 +371,7 @@ public final class MekanismUtils return ((IActiveState)tileEntity).getActive(); } } + return false; } @@ -808,20 +809,6 @@ public final class MekanismUtils } } - /** - * Whether or not this mod is in an obfuscated environment. - * @return if the mod is in an obfuscated environment - */ - public static boolean isObfuscated() - { - try { - Class.forName("net.minecraft.world.World"); - return false; - } catch(Exception e) { - return true; - } - } - /** * Grabs a unique inventory ID for a dynamic tank. * @return unique inventory ID diff --git a/src/minecraft/mekanism/common/Tier.java b/src/minecraft/mekanism/common/Tier.java index 4f6b294a5..76dc25ec9 100644 --- a/src/minecraft/mekanism/common/Tier.java +++ b/src/minecraft/mekanism/common/Tier.java @@ -14,10 +14,10 @@ public final class Tier */ public static enum EnergyCubeTier { - BASIC("Basic", 2000000, 120, 320), - ADVANCED("Advanced", 8000000, 240, 540), - ELITE("Elite", 32000000, 240, 1280), - ULTIMATE("Ultimate", 128000000, 480, 2560); + BASIC("Basic", 2000000, 120, 200), + ADVANCED("Advanced", 8000000, 240, 800), + ELITE("Elite", 32000000, 240, 3200), + ULTIMATE("Ultimate", 128000000, 480, 12800); public double MAX_ELECTRICITY; public double VOLTAGE; diff --git a/src/minecraft/mekanism/generators/client/BlockRenderingHandler.java b/src/minecraft/mekanism/generators/client/BlockRenderingHandler.java index ea47620b2..9fc0313df 100644 --- a/src/minecraft/mekanism/generators/client/BlockRenderingHandler.java +++ b/src/minecraft/mekanism/generators/client/BlockRenderingHandler.java @@ -1,10 +1,10 @@ package mekanism.generators.client; +import mekanism.client.MekanismRenderer; import mekanism.generators.common.BlockGenerator.GeneratorType; import mekanism.generators.common.MekanismGenerators; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; @@ -80,7 +80,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler windTurbine.render(0.018F, 0); } else { - renderItem(renderer, metadata, block); + MekanismRenderer.renderItem(renderer, metadata, block); } } @@ -116,63 +116,4 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler { return GeneratorsClientProxy.GENERATOR_RENDER_ID; } - - /** - * Cleaned-up snip of RenderBlocks.renderBlockAsItem() -- used for rendering an item as an entity, - * in a player's inventory, and in a player's hand. - * @param renderer - RenderBlocks renderer to render the item with - * @param metadata - block/item metadata - * @param block - block to render - */ - public void renderItem(RenderBlocks renderer, int metadata, Block block) - { - block.setBlockBoundsForItemRender(); - - if(metadata == GeneratorType.SOLAR_GENERATOR.meta) - { - block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.4F, 1.0F); - } - else { - block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - renderer.setRenderBoundsFromBlock(block); - - if (renderer.useInventoryTint) - { - int renderColor = block.getRenderColor(metadata); - float red = (float)(renderColor >> 16 & 255) / 255.0F; - float green = (float)(renderColor >> 8 & 255) / 255.0F; - float blue = (float)(renderColor & 255) / 255.0F; - GL11.glColor4f(red, green, blue, 1.0F); - } - - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); - tessellator.draw(); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } } diff --git a/src/minecraft/mekanism/generators/common/BlockGenerator.java b/src/minecraft/mekanism/generators/common/BlockGenerator.java index 19ad49f86..a5004dab5 100644 --- a/src/minecraft/mekanism/generators/common/BlockGenerator.java +++ b/src/minecraft/mekanism/generators/common/BlockGenerator.java @@ -6,6 +6,7 @@ import java.util.Random; import mekanism.api.IEnergizedItem; import mekanism.common.IActiveState; import mekanism.common.IBoundingBlock; +import mekanism.common.ISpecialBounds; import mekanism.common.ISustainedInventory; import mekanism.common.ISustainedTank; import mekanism.common.Mekanism; @@ -13,6 +14,7 @@ import mekanism.common.MekanismUtils; import mekanism.common.TileEntityBasicBlock; import mekanism.common.TileEntityElectricBlock; import mekanism.generators.client.GeneratorsClientProxy; +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; @@ -45,7 +47,7 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class BlockGenerator extends BlockContainer +public class BlockGenerator extends BlockContainer implements ISpecialBounds { public Icon[] solarSprites = new Icon[256]; public Random machineRand = new Random(); @@ -613,4 +615,22 @@ public class BlockGenerator extends BlockContainer return Integer.toString(meta); } } + + @Override + public void setRenderBounds(Block block, int metadata) + { + if(metadata == GeneratorType.SOLAR_GENERATOR.meta) + { + block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.4F, 1.0F); + } + else { + block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + @Override + public boolean doDefaultBoundSetting(int metadata) + { + return true; + } } diff --git a/src/minecraft/mekanism/generators/common/TileEntityGenerator.java b/src/minecraft/mekanism/generators/common/TileEntityGenerator.java index db6cd5135..0ec9659bc 100644 --- a/src/minecraft/mekanism/generators/common/TileEntityGenerator.java +++ b/src/minecraft/mekanism/generators/common/TileEntityGenerator.java @@ -249,6 +249,12 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, MekanismGenerators.generatorID); } + @Override + public boolean canSetFacing(int side) + { + return side != 0 && side != 1; + } + @Override public boolean emitsEnergyTo(TileEntity receiver, Direction direction) { diff --git a/src/minecraft/thermalexpansion/api/ThermalExpansionInfo.java b/src/minecraft/thermalexpansion/api/ThermalExpansionInfo.java new file mode 100644 index 000000000..70bfe91fc --- /dev/null +++ b/src/minecraft/thermalexpansion/api/ThermalExpansionInfo.java @@ -0,0 +1,54 @@ + +package thermalexpansion.api; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.liquids.LiquidStack; +import cpw.mods.fml.common.registry.GameRegistry; + +/** + * This class contains some general hooks that can be useful if Thermal Expansion is installed. + */ +public class ThermalExpansionInfo { + + public static ItemStack coal = new ItemStack(Item.coal, 1, 0); + public static ItemStack charcoal = new ItemStack(Item.coal, 1, 1); + + public static int lavaFuelValue = 18000; + + public static int getFuelValue(ItemStack theFuel) { + + if (theFuel == null) { + return 0; + } + if (theFuel.isItemEqual(coal)) { + return 4800; + } + if (theFuel.isItemEqual(charcoal)) { + return 3200; + } + int itemId = theFuel.getItem().itemID; + if (theFuel.getItem() instanceof ItemBlock && Block.blocksList[itemId].blockMaterial == Material.wood) { + return 450; + } + if (itemId == Item.stick.itemID) { + return 150; + } + if (itemId == Block.sapling.blockID) { + return 150; + } + return GameRegistry.getFuelValue(theFuel) * 3 / 2; + } + + public static int getFuelValue(LiquidStack theFuel) { + + if (theFuel.itemID == Block.lavaStill.blockID) { + return lavaFuelValue; + } + return 0; + } + +} diff --git a/src/minecraft/thermalexpansion/api/crafting/CraftingHelpers.java b/src/minecraft/thermalexpansion/api/crafting/CraftingHelpers.java index 09df8404b..3f6410c35 100644 --- a/src/minecraft/thermalexpansion/api/crafting/CraftingHelpers.java +++ b/src/minecraft/thermalexpansion/api/crafting/CraftingHelpers.java @@ -16,20 +16,42 @@ public class CraftingHelpers { private static ItemStack sawdust = ItemRegistry.getItem("sawdust", 1); private static ItemStack slag = ItemRegistry.getItem("slag", 1); private static ItemStack slagRich = ItemRegistry.getItem("slagRich", 1); - private static ItemStack fluxSand = new ItemStack(Block.sand); + private static ItemStack blockSand = new ItemStack(Block.sand); /** * Ore x1 to Dust x2 conversion. 400 MJ. Will return false if recipe already exists. */ public static boolean addPulverizerOreToDustRecipe(ItemStack inputOre, ItemStack outputDust) { + if (inputOre == null || outputDust == null) { + return false; + } + ItemStack ore = inputOre.copy(); ore.stackSize = 1; ItemStack primaryDust = outputDust.copy(); primaryDust.stackSize = 2; - return CraftingManagers.pulverizerManager.addRecipe(400, ore, primaryDust, false); + return CraftingManagers.pulverizerManager.addRecipe(400, ore, primaryDust); + } + + /** + * Ingot x1 to Dust x1 conversion. 240 MJ. Will return false if recipe already exists. + */ + public static boolean addPulverizerIngotToDustRecipe(ItemStack inputIngot, ItemStack outputDust) { + + if (inputIngot == null || outputDust == null) { + return false; + } + + ItemStack ingot = inputIngot.copy(); + ingot.stackSize = 1; + + ItemStack primaryDust = outputDust.copy(); + primaryDust.stackSize = 1; + + return CraftingManagers.pulverizerManager.addRecipe(240, ingot, primaryDust); } /** @@ -38,6 +60,10 @@ public class CraftingHelpers { */ public static boolean addPulverizerOreToDustRecipe(ItemStack inputOre, ItemStack outputDust, ItemStack outputSecondary) { + if (inputOre == null || outputDust == null || outputSecondary == null) { + return false; + } + ItemStack ore = inputOre.copy(); ore.stackSize = 1; @@ -47,7 +73,7 @@ public class CraftingHelpers { ItemStack secondary = outputSecondary.copy(); secondary.stackSize = 1; - return CraftingManagers.pulverizerManager.addRecipe(400, ore, primaryDust, secondary, 10, false); + return CraftingManagers.pulverizerManager.addRecipe(400, ore, primaryDust, secondary, 10); } /** @@ -56,13 +82,17 @@ public class CraftingHelpers { */ public static boolean addSawmillLogToPlankRecipe(ItemStack inputLog, ItemStack outputPlanks) { + if (inputLog == null || outputPlanks == null) { + return false; + } + ItemStack log = inputLog.copy(); log.stackSize = 1; ItemStack planks = outputPlanks.copy(); planks.stackSize = 6; - return CraftingManagers.sawmillManager.addRecipe(80, log, planks, sawdust, false); + return CraftingManagers.sawmillManager.addRecipe(80, log, planks, sawdust); } /** @@ -71,13 +101,17 @@ public class CraftingHelpers { */ public static boolean addSmelterDustToIngotsRecipe(ItemStack inputDust, ItemStack outputIngots) { + if (inputDust == null || outputIngots == null) { + return false; + } + ItemStack dust = inputDust.copy(); dust.stackSize = 2; ItemStack ingots = outputIngots.copy(); ingots.stackSize = 2; - return CraftingManagers.smelterManager.addRecipe(80, dust, fluxSand, ingots, slag, 25, false); + return CraftingManagers.smelterManager.addRecipe(80, dust, blockSand, ingots, slag, 25); } /** @@ -86,6 +120,10 @@ public class CraftingHelpers { */ public static boolean addSmelterOreToIngotsRecipe(ItemStack inputOre, ItemStack outputIngots) { + if (inputOre == null || outputIngots == null) { + return false; + } + ItemStack ore = inputOre.copy(); ore.stackSize = 1; @@ -95,12 +133,13 @@ public class CraftingHelpers { ItemStack ingots3 = outputIngots.copy(); ingots3.stackSize = 3; - if (!CraftingManagers.smelterManager.addRecipe(320, ore, fluxSand, ingots2, slagRich, 5, false)) { + if (!CraftingManagers.smelterManager.addRecipe(320, ore, blockSand, ingots2, slagRich, 5)) { return false; } - if (!CraftingManagers.smelterManager.addRecipe(400, ore, slagRich, ingots3, slag, 75, false)) { + if (!CraftingManagers.smelterManager.addRecipe(400, ore, slagRich, ingots3, slag, 75)) { return false; } return true; } + } diff --git a/src/minecraft/thermalexpansion/api/item/IChargeableItem.java b/src/minecraft/thermalexpansion/api/item/IChargeableItem.java index c7fd4a032..042e81ef8 100644 --- a/src/minecraft/thermalexpansion/api/item/IChargeableItem.java +++ b/src/minecraft/thermalexpansion/api/item/IChargeableItem.java @@ -48,4 +48,5 @@ public interface IChargeableItem { * Get the max amount of energy that can be stored in the item. */ public float getMaxEnergyStored(ItemStack theItem); + } diff --git a/src/minecraft/thermalexpansion/api/item/ItemRegistry.java b/src/minecraft/thermalexpansion/api/item/ItemRegistry.java index 3f19b8597..f0e48d5cb 100644 --- a/src/minecraft/thermalexpansion/api/item/ItemRegistry.java +++ b/src/minecraft/thermalexpansion/api/item/ItemRegistry.java @@ -52,4 +52,73 @@ public final class ItemRegistry { } } + // String identifiers for obtaining Thermal Expansion Items: + + // dustIron - Dust obtained by pulverizing Iron Ore. + // dustGold - Dust obtained by pulverizing Gold Ore. + // dustObsidian - Dust obtained by pulverizing Obsidian. + // dustCopper - Dust obtained by pulverizing Copper Ore. + // dustTin - Dust obtained by pulverizing Tin Ore. + // dustSilver - Dust obtained by pulverizing Silver Ore. + // dustLead - Dust obtained by pulverizing Lead Ore. + // dustNickel - Dust obtained by pulverizing Ferrous Ore. + // dustPlatinum - Dust obtained as a secondary output from pulverizing Ferrous Ore. + // dustElectrum - Dust obtained by crafting Gold and Silver Dusts together. + // dustInvar - Dust obtained by crafting 2 Iron Dusts and Ferrous Dust. + // dustBronze - Uncraftable + // dustBrass - Uncraftable + + // ingotCopper - Ingot obtained by smelting Copper Dust. + // ingotTin - Ingot obtained by smelting Tin Dust. + // ingotSilver - Ingot obtained by smelting Silver Dust. + // ingotLead - Ingot obtained by smelting Lead Dust. + // ingotNickel - Ingot obtained by smelting Ferrous Dust. + // ingotPlatinum - Ingot obtained by smelting Shiny Dust. + // ingotElectrum - Ingot obtained by smelting Electrum Dust. + // ingotInvar - Ingot obtained by smelting Invar Dust. + + // nuggetCopper - Nugget obtained from Copper Ingots. + // nuggetTin - Nugget obtained from Tin Ingots. + // nuggetSilver - Nugget obtained from Silver Ingots. + // nuggetLead - Nugget obtained from Lead Ingots. + // nuggetNickel - Nugget obtained from Ferrous Ingots. + // nuggetPlatinum - Nugget obtained from Shiny Ingots. + // nuggetElectrum - Nugget obtained from Electrum Ingots. + // nuggetInvar - Nugget obtained from Invar Ingots. + + // crystalSulfur - Sulfur + // crystalNiter - Niter + + // woodchips - Woodchips obtained by putting logs in a Pulverizer. + // sawdust - Sawdust obtained + // through the Sawmill. + // sawdustCompressed - Sawdust compressed into one item. + // slag - Slag obtained in Smelter which can be used to create rockwool. + // slagRich - Rich Slag obtained in Smelter which can be used to boost ore output. + + // pneumaticServo - Used in Thermal Expansion recipes for machines that do not use power. + // powerCoilGold - Used in Thermal Expansion recipes for machines that receive power. + // powerCoilSilver - Used in Thermal Expansion recipes for machines that send power. + // powerCoilElectrum - Used in Thermal Expansion recipes for machines that both send/receive + // power. + + // gearCopper - Copper Gear. + // gearTin - Tin Gear. + // gearInvar - Invar Gear. + + // wrench - Cresent Hammer, rotates and dismantles things. + // multimeter - Multimeter, used to read Conduits, Liquiducts, and Tesseracts. + + // schematic - Schematic, used in the Assembler. + + // machineFrame - Used as a crafting recipe in many Thermal Expansion machines. + // energyCellFrameEmpty - Redstone Energy Cell before it has been filled with Liquid Redstone. + // energyCellFrameFull - Redstone Energy Cell after it has been filled with Liquid Redstone, but + // before it can be placed in the world. + // energyConduitEmpty - Redstone Energy Conduit before it is filled with Liquid Redstone. + // tesseractFrameEmpty - Tesseract before it has been filled with Liquid Ender. + // tesseractFrameFull - Tesseract after it has been filled with Liquid Ender, but before it can + // be placed in the world. + // lampFrame - Glowstone Illuminator before it has been filled with Liquid Glowstone. + }