From 4d3b6e48e489908b15a6e8c53bd95baadaf699ab Mon Sep 17 00:00:00 2001 From: Calclavia Date: Wed, 8 Jan 2014 22:09:27 +0800 Subject: [PATCH] Gave each RI module a loader --- .../java/resonantinduction/Reference.java | 19 +- .../resonantinduction/core/ClientProxy.java | 74 +++ .../resonantinduction/core/CommonProxy.java | 55 +++ .../core/ResonantInduction.java | 30 +- .../java/resonantinduction/core/Settings.java | 1 + .../resonantinduction/core/SoundHandler.java | 3 +- .../core/base/BlockBase.java | 5 +- .../core/base/BlockIOBase.java | 5 +- .../core/base/BlockRotatableBase.java | 5 +- .../resonantinduction/core/base/ItemBase.java | 5 +- .../core/base/ItemMultipartBase.java | 5 +- .../core/multimeter/RenderMultimeter.java | 4 +- .../core/resource/ResourceGenerator.java | 142 ++++++ .../resonantinduction/energy/ClientProxy.java | 33 +- .../resonantinduction/energy/CommonProxy.java | 13 +- .../energy/ResonantInductionEnergy.java | 205 +------- .../energy/battery/BlockBattery.java | 4 +- .../energy/battery/RenderBattery.java | 6 +- .../energy/fx/FXElectricBolt.java | 4 +- .../energy/gui/GuiMultimeter.java | 4 +- .../energy/tesla/BlockTesla.java | 4 +- .../energy/tesla/RenderTesla.java | 8 +- .../energy/tesla/TileTesla.java | 5 +- .../energy/transformer/RenderTransformer.java | 4 +- .../energy/wire/ItemWire.java | 11 +- .../energy/wire/framed/RenderPartWire.java | 7 +- .../mechanics/ClientProxy.java | 101 ++++ .../mechanics/CommonProxy.java | 60 +++ .../mechanics/ResonantInductionMechanics.java | 225 +++++++++ .../mechanics/grinder/TileGrinderWheel.java | 4 +- .../mechanics/grinder/TilePurifier.java | 4 +- .../mechanics/item/ItemDust.java | 136 +----- .../transport/ResonantInductionTransport.java | 458 +++++++++--------- .../transport/levitator/BlockLevitator.java | 4 +- .../transport/levitator/RenderLevitator.java | 5 +- 35 files changed, 1003 insertions(+), 655 deletions(-) create mode 100644 src/main/java/resonantinduction/core/ClientProxy.java create mode 100644 src/main/java/resonantinduction/core/CommonProxy.java create mode 100644 src/main/java/resonantinduction/core/resource/ResourceGenerator.java create mode 100644 src/main/java/resonantinduction/mechanics/ClientProxy.java create mode 100644 src/main/java/resonantinduction/mechanics/CommonProxy.java create mode 100644 src/main/java/resonantinduction/mechanics/ResonantInductionMechanics.java diff --git a/src/main/java/resonantinduction/Reference.java b/src/main/java/resonantinduction/Reference.java index fbb79a2a3..45803afce 100644 --- a/src/main/java/resonantinduction/Reference.java +++ b/src/main/java/resonantinduction/Reference.java @@ -7,11 +7,28 @@ package resonantinduction; */ public class Reference { + /** The official name of the mod */ + public static final String NAME = "Resonant Induction"; + public static final String MAJOR_VERSION = "@MAJOR@"; public static final String MINOR_VERSION = "@MINOR@"; public static final String REVISION_VERSION = "@REVIS@"; public static final String BUILD_VERSION = "@BUILD@"; public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION; public static final String CHANNEL = "resonindc"; - public static final String NAME = "Resonant Induction"; + /** + * Directory Information + */ + public static final String DOMAIN = "resonantinduction"; + public static final String PREFIX = DOMAIN + ":"; + public static final String DIRECTORY = "/assets/" + DOMAIN + "/"; + public static final String TEXTURE_DIRECTORY = "textures/"; + public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/"; + public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/"; + public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/"; + public static final String MODEL_PATH = "models/"; + public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + MODEL_PATH; + public static final String MODEL_DIRECTORY = DIRECTORY + MODEL_PATH; + public static final String LANGUAGE_DIRECTORY = DIRECTORY + "languages/"; + public static final String[] LANGUAGES = new String[] { "en_US", "de_DE" }; } diff --git a/src/main/java/resonantinduction/core/ClientProxy.java b/src/main/java/resonantinduction/core/ClientProxy.java new file mode 100644 index 000000000..cce71205d --- /dev/null +++ b/src/main/java/resonantinduction/core/ClientProxy.java @@ -0,0 +1,74 @@ +package resonantinduction.core; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.common.MinecraftForge; +import resonantinduction.core.ResonantInduction; +import resonantinduction.core.SoundHandler; +import resonantinduction.core.multimeter.PartMultimeter; +import resonantinduction.core.render.BlockRenderingHandler; +import resonantinduction.core.render.RenderRIItem; +import resonantinduction.energy.battery.RenderBattery; +import resonantinduction.energy.battery.TileBattery; +import resonantinduction.energy.fx.FXElectricBolt; +import resonantinduction.energy.gui.GuiMultimeter; +import resonantinduction.energy.tesla.RenderTesla; +import resonantinduction.energy.tesla.TileTesla; +import resonantinduction.mechanics.item.ItemDust; +import resonantinduction.transport.levitator.RenderLevitator; +import resonantinduction.transport.levitator.TileEMLevitator; +import universalelectricity.api.vector.Vector3; +import codechicken.multipart.TMultiPart; +import codechicken.multipart.TileMultipart; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * @author Calclavia + * + */ +@SideOnly(Side.CLIENT) +public class ClientProxy extends CommonProxy +{ + @Override + public void preInit() + { + MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE); + } + + @Override + public void postInit() + { + } + + @Override + public boolean isPaused() + { + if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) + { + GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen; + + if (screen != null) + { + if (screen.doesGuiPauseGame()) + { + return true; + } + } + } + + return false; + } + + @Override + public boolean isFancy() + { + return FMLClientHandler.instance().getClient().gameSettings.fancyGraphics; + } +} diff --git a/src/main/java/resonantinduction/core/CommonProxy.java b/src/main/java/resonantinduction/core/CommonProxy.java new file mode 100644 index 000000000..d85ceddd5 --- /dev/null +++ b/src/main/java/resonantinduction/core/CommonProxy.java @@ -0,0 +1,55 @@ +/** + * + */ +package resonantinduction.core; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import resonantinduction.core.multimeter.ContainerMultimeter; +import resonantinduction.core.multimeter.PartMultimeter; +import universalelectricity.api.vector.Vector3; +import codechicken.lib.colour.ColourRGBA; +import codechicken.multipart.TMultiPart; +import codechicken.multipart.TileMultipart; +import cpw.mods.fml.common.network.IGuiHandler; + +/** + * @author Calclavia + * + */ +public class CommonProxy implements IGuiHandler +{ + public void preInit() + { + + } + + public void postInit() + { + + } + + @Override + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) + { + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + return null; + } + + public boolean isPaused() + { + return false; + } + + public boolean isFancy() + { + return false; + } + +} diff --git a/src/main/java/resonantinduction/core/ResonantInduction.java b/src/main/java/resonantinduction/core/ResonantInduction.java index fed678fb0..23a4d1c4c 100644 --- a/src/main/java/resonantinduction/core/ResonantInduction.java +++ b/src/main/java/resonantinduction/core/ResonantInduction.java @@ -30,6 +30,7 @@ import resonantinduction.Reference; import resonantinduction.core.multimeter.ItemMultimeter; import resonantinduction.energy.CommonProxy; import resonantinduction.energy.LinkEvent; +import resonantinduction.energy.ResonantInductionEnergy; import resonantinduction.energy.battery.BlockBattery; import resonantinduction.energy.battery.ItemBlockBattery; import resonantinduction.energy.battery.TileBattery; @@ -101,26 +102,6 @@ public class ResonantInduction public static final Logger LOGGER = Logger.getLogger(Reference.NAME); - /** - * Directory Information - */ - public static final String DOMAIN = "resonantinduction"; - public static final String PREFIX = DOMAIN + ":"; - public static final String DIRECTORY = "/assets/" + DOMAIN + "/"; - public static final String TEXTURE_DIRECTORY = "textures/"; - public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/"; - public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/"; - public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/"; - - public static final String MODEL_PATH = "models/"; - - public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + MODEL_PATH; - public static final String MODEL_DIRECTORY = DIRECTORY + MODEL_PATH; - - public static final String LANGUAGE_DIRECTORY = DIRECTORY + "languages/"; - public static final String[] LANGUAGES = new String[] { "en_US", "de_DE" }; - - /** * Packets */ @@ -131,22 +112,23 @@ public class ResonantInduction @EventHandler public void preInit(FMLPreInitializationEvent evt) { - LOGGER.setParent(FMLLog.getLogger()); + ResonantInduction.LOGGER.setParent(FMLLog.getLogger()); NetworkRegistry.instance().registerGuiHandler(this, ResonantInduction.proxy); Modstats.instance().getReporter().registerMod(this); /** * Set reference itemstacks */ - ResonantInductionTabs.ITEMSTACK = new ItemStack(null); + //ResonantInductionTabs.ITEMSTACK = new ItemStack(null); MinecraftForge.EVENT_BUS.register(new LinkEvent()); + Settings.init(); } @EventHandler public void init(FMLInitializationEvent evt) { - LOGGER.fine("Languages Loaded:" + LanguageUtility.loadLanguages(LANGUAGE_DIRECTORY, LANGUAGES)); - // TODO localize this + ResonantInduction.LOGGER.fine("Languages Loaded:" + LanguageUtility.loadLanguages(Reference.LANGUAGE_DIRECTORY, Reference.LANGUAGES)); + metadata.modId = ID; metadata.name = Reference.NAME; metadata.description = LanguageUtility.getLocal("meta.resonantinduction.description"); diff --git a/src/main/java/resonantinduction/core/Settings.java b/src/main/java/resonantinduction/core/Settings.java index 33465d76e..58e2422f9 100644 --- a/src/main/java/resonantinduction/core/Settings.java +++ b/src/main/java/resonantinduction/core/Settings.java @@ -61,5 +61,6 @@ public class Settings TileEMLevitator.MAX_REACH = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Reach", TileEMLevitator.MAX_REACH).getInt(TileEMLevitator.MAX_REACH); TileEMLevitator.MAX_SPEED = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Speed", TileEMLevitator.MAX_SPEED).getDouble(TileEMLevitator.MAX_SPEED); TileEMLevitator.PUSH_DELAY = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Push Delay", TileEMLevitator.PUSH_DELAY).getInt(TileEMLevitator.PUSH_DELAY); + CONFIGURATION.save(); } } diff --git a/src/main/java/resonantinduction/core/SoundHandler.java b/src/main/java/resonantinduction/core/SoundHandler.java index ac040f0fe..086ce8f78 100644 --- a/src/main/java/resonantinduction/core/SoundHandler.java +++ b/src/main/java/resonantinduction/core/SoundHandler.java @@ -3,6 +3,7 @@ */ package resonantinduction.core; +import resonantinduction.Reference; import net.minecraftforge.client.event.sound.SoundLoadEvent; import net.minecraftforge.event.ForgeSubscribe; import cpw.mods.fml.relauncher.Side; @@ -24,7 +25,7 @@ public class SoundHandler { for (int i = 0; i < SOUND_FILES.length; i++) { - event.manager.addSound(ResonantInduction.PREFIX + SOUND_FILES[i]); + event.manager.addSound(Reference.PREFIX + SOUND_FILES[i]); } ResonantInduction.LOGGER.fine("Loaded sound fxs"); diff --git a/src/main/java/resonantinduction/core/base/BlockBase.java b/src/main/java/resonantinduction/core/base/BlockBase.java index cf76bdb0f..d06260c45 100644 --- a/src/main/java/resonantinduction/core/base/BlockBase.java +++ b/src/main/java/resonantinduction/core/base/BlockBase.java @@ -5,6 +5,7 @@ package resonantinduction.core.base; import net.minecraft.block.material.Material; import net.minecraftforge.common.Configuration; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInductionTabs; import universalelectricity.api.UniversalElectricity; @@ -20,8 +21,8 @@ public class BlockBase extends BlockAdvanced { super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), UniversalElectricity.machine); this.setCreativeTab(ResonantInductionTabs.CORE); - this.setUnlocalizedName(ResonantInduction.PREFIX + name); - this.setTextureName(ResonantInduction.PREFIX + name); + this.setUnlocalizedName(Reference.PREFIX + name); + this.setTextureName(Reference.PREFIX + name); this.setHardness(1f); } } diff --git a/src/main/java/resonantinduction/core/base/BlockIOBase.java b/src/main/java/resonantinduction/core/base/BlockIOBase.java index 722af51a8..591fabfdb 100644 --- a/src/main/java/resonantinduction/core/base/BlockIOBase.java +++ b/src/main/java/resonantinduction/core/base/BlockIOBase.java @@ -5,6 +5,7 @@ package resonantinduction.core.base; import net.minecraft.block.material.Material; import net.minecraftforge.common.Configuration; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInductionTabs; import calclavia.lib.prefab.block.BlockSidedIO; @@ -19,8 +20,8 @@ public class BlockIOBase extends BlockSidedIO { super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), Material.piston); this.setCreativeTab(ResonantInductionTabs.CORE); - this.setUnlocalizedName(ResonantInduction.PREFIX + name); - this.setTextureName(ResonantInduction.PREFIX + name); + this.setUnlocalizedName(Reference.PREFIX + name); + this.setTextureName(Reference.PREFIX + name); this.setHardness(1f); } } diff --git a/src/main/java/resonantinduction/core/base/BlockRotatableBase.java b/src/main/java/resonantinduction/core/base/BlockRotatableBase.java index 310d8e579..1ddb92217 100644 --- a/src/main/java/resonantinduction/core/base/BlockRotatableBase.java +++ b/src/main/java/resonantinduction/core/base/BlockRotatableBase.java @@ -6,6 +6,7 @@ package resonantinduction.core.base; import calclavia.lib.prefab.block.BlockRotatable; import net.minecraft.block.material.Material; import net.minecraftforge.common.Configuration; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInductionTabs; import universalelectricity.api.UniversalElectricity; @@ -20,8 +21,8 @@ public class BlockRotatableBase extends BlockRotatable { super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_BLOCK, name, id).getInt(id), UniversalElectricity.machine); this.setCreativeTab(ResonantInductionTabs.CORE); - this.setUnlocalizedName(ResonantInduction.PREFIX + name); - this.setTextureName(ResonantInduction.PREFIX + name); + this.setUnlocalizedName(Reference.PREFIX + name); + this.setTextureName(Reference.PREFIX + name); this.setHardness(1f); } } diff --git a/src/main/java/resonantinduction/core/base/ItemBase.java b/src/main/java/resonantinduction/core/base/ItemBase.java index 428b3d68d..151a13b85 100644 --- a/src/main/java/resonantinduction/core/base/ItemBase.java +++ b/src/main/java/resonantinduction/core/base/ItemBase.java @@ -2,6 +2,7 @@ package resonantinduction.core.base; import net.minecraft.item.Item; import net.minecraftforge.common.Configuration; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInductionTabs; @@ -16,7 +17,7 @@ public class ItemBase extends Item { super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, name, id).getInt(id)); this.setCreativeTab(ResonantInductionTabs.CORE); - this.setUnlocalizedName(ResonantInduction.PREFIX + name); - this.setTextureName(ResonantInduction.PREFIX + name); + this.setUnlocalizedName(Reference.PREFIX + name); + this.setTextureName(Reference.PREFIX + name); } } diff --git a/src/main/java/resonantinduction/core/base/ItemMultipartBase.java b/src/main/java/resonantinduction/core/base/ItemMultipartBase.java index 81de964d5..ec8a62b21 100644 --- a/src/main/java/resonantinduction/core/base/ItemMultipartBase.java +++ b/src/main/java/resonantinduction/core/base/ItemMultipartBase.java @@ -1,6 +1,7 @@ package resonantinduction.core.base; import net.minecraftforge.common.Configuration; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInductionTabs; import codechicken.multipart.JItemMultiPart; @@ -15,8 +16,8 @@ public abstract class ItemMultipartBase extends JItemMultiPart { super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, name, id).getInt(id)); this.setCreativeTab(ResonantInductionTabs.CORE); - this.setUnlocalizedName(ResonantInduction.PREFIX + name); - this.setTextureName(ResonantInduction.PREFIX + name); + this.setUnlocalizedName(Reference.PREFIX + name); + this.setTextureName(Reference.PREFIX + name); } } diff --git a/src/main/java/resonantinduction/core/multimeter/RenderMultimeter.java b/src/main/java/resonantinduction/core/multimeter/RenderMultimeter.java index 39f5e4d82..ca2e3dceb 100644 --- a/src/main/java/resonantinduction/core/multimeter/RenderMultimeter.java +++ b/src/main/java/resonantinduction/core/multimeter/RenderMultimeter.java @@ -7,7 +7,7 @@ import net.minecraftforge.common.ForgeDirection; import org.lwjgl.opengl.GL11; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import resonantinduction.energy.model.ModelMultimeter; import universalelectricity.api.energy.UnitDisplay; import universalelectricity.api.energy.UnitDisplay.Unit; @@ -25,7 +25,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderMultimeter { public static final ModelMultimeter MODEL = new ModelMultimeter(); - public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "multimeter.png"); + public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_TEXTURE_DIRECTORY + "multimeter.png"); @SuppressWarnings("incomplete-switch") public static void render(PartMultimeter tileEntity, double x, double y, double z) diff --git a/src/main/java/resonantinduction/core/resource/ResourceGenerator.java b/src/main/java/resonantinduction/core/resource/ResourceGenerator.java new file mode 100644 index 000000000..8148a32e4 --- /dev/null +++ b/src/main/java/resonantinduction/core/resource/ResourceGenerator.java @@ -0,0 +1,142 @@ +package resonantinduction.core.resource; + +import java.awt.Color; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Set; + +import javax.imageio.ImageIO; + +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.oredict.OreDictionary; +import resonantinduction.Reference; +import resonantinduction.core.api.MachineRecipes; +import resonantinduction.core.api.MachineRecipes.RecipeType; +import resonantinduction.mechanics.item.ItemDust; + +/** + * @author Calclavia + * + */ +public class ResourceGenerator +{ + public static final Set materialNames = new HashSet(); + public static final HashMap materialColors = new HashMap(); + + public static void generateDusts() + { + for (String materialName : ResourceGenerator.materialNames) + { + String name = materialName.substring(0, 1).toUpperCase() + materialName.substring(1); + + if (OreDictionary.getOres("ore" + name).size() > 0) + { + if (OreDictionary.getOres("dust" + name).size() == 0) + { + ItemDust.dusts.add(ItemDust.getStackFromDust(materialName)); + OreDictionary.registerOre("dust" + name, ItemDust.getStackFromDust(materialName)); + + } + + // Add to machine recipes + + ItemStack dust = OreDictionary.getOres("dust" + name).get(0).copy(); + dust.stackSize = 2; + MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "ore" + name, dust); + } + } + } + + @SideOnly(Side.CLIENT) + public static void computeColors() + { + for (String ingotName : materialNames) + { + LinkedList colorCodes = new LinkedList(); + + // Compute color + int totalR = 0; + int totalG = 0; + int totalB = 0; + + for (ItemStack ingotStack : OreDictionary.getOres("ingot" + ingotName.substring(0, 1).toUpperCase() + ingotName.substring(1))) + { + + Item theIngot = ingotStack.getItem(); + + Method o = ReflectionHelper.findMethod(Item.class, theIngot, new String[] { "getIconString", "func_" + "111208_A" }); + String iconString; + + try + { + iconString = (String) o.invoke(theIngot); + } + catch (ReflectiveOperationException e1) + { + // e1.printStackTrace(); + break; + } + + ResourceLocation textureLocation = new ResourceLocation(iconString.replace(":", ":" + Reference.ITEM_TEXTURE_DIRECTORY) + ".png"); + InputStream inputstream; + try + { + inputstream = Minecraft.getMinecraft().getResourceManager().getResource(textureLocation).getInputStream(); + + BufferedImage bufferedimage = ImageIO.read(inputstream); + + int width = bufferedimage.getWidth(); + int height = bufferedimage.getWidth(); + + for (int x = 0; x < width; x++) + { + for (int y = 0; y < height; y++) + { + colorCodes.add(bufferedimage.getRGB(x, y)); + } + } + } + catch (IOException e) + { + // e.printStackTrace(); + } + } + if (colorCodes.size() > 0) + { + for (int colorCode : colorCodes) + { + Color color = new Color(colorCode); + + if (color.getAlpha() != 0) + { + totalR += color.getRed(); + totalG += color.getGreen(); + totalB += color.getBlue(); + } + } + + totalR /= colorCodes.size(); + totalG /= colorCodes.size(); + totalB /= colorCodes.size(); + + int resultantColor = new Color(totalR, totalG, totalB).brighter().brighter().getRGB(); + materialColors.put(ingotName, resultantColor); + } + if (!materialColors.containsKey(ingotName)) + { + materialColors.put(ingotName, 0xFFFFFF); + } + } + } +} diff --git a/src/main/java/resonantinduction/energy/ClientProxy.java b/src/main/java/resonantinduction/energy/ClientProxy.java index ff225a277..117d1cb53 100644 --- a/src/main/java/resonantinduction/energy/ClientProxy.java +++ b/src/main/java/resonantinduction/energy/ClientProxy.java @@ -37,13 +37,11 @@ import cpw.mods.fml.relauncher.SideOnly; public class ClientProxy extends CommonProxy { @Override - public void registerRenderers() + public void preInit() { - MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE); - RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE); - MinecraftForgeClient.registerItemRenderer(ResonantInduction.itemMultimeter.itemID, RenderRIItem.INSTANCE); - MinecraftForgeClient.registerItemRenderer(ResonantInduction.itemTransformer.itemID, RenderRIItem.INSTANCE); + MinecraftForgeClient.registerItemRenderer(ResonantInductionEnergy.itemMultimeter.itemID, RenderRIItem.INSTANCE); + MinecraftForgeClient.registerItemRenderer(ResonantInductionEnergy.itemTransformer.itemID, RenderRIItem.INSTANCE); ClientRegistry.bindTileEntitySpecialRenderer(TileTesla.class, new RenderTesla()); ClientRegistry.bindTileEntitySpecialRenderer(TileEMLevitator.class, new RenderLevitator()); ClientRegistry.bindTileEntitySpecialRenderer(TileBattery.class, new RenderBattery()); @@ -72,31 +70,6 @@ public class ClientProxy extends CommonProxy return null; } - @Override - public boolean isPaused() - { - if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) - { - GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen; - - if (screen != null) - { - if (screen.doesGuiPauseGame()) - { - return true; - } - } - } - - return false; - } - - @Override - public boolean isFancy() - { - return FMLClientHandler.instance().getClient().gameSettings.fancyGraphics; - } - @Override public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b, boolean split) { diff --git a/src/main/java/resonantinduction/energy/CommonProxy.java b/src/main/java/resonantinduction/energy/CommonProxy.java index 7136365be..b527c9737 100644 --- a/src/main/java/resonantinduction/energy/CommonProxy.java +++ b/src/main/java/resonantinduction/energy/CommonProxy.java @@ -20,7 +20,7 @@ import cpw.mods.fml.common.network.IGuiHandler; */ public class CommonProxy implements IGuiHandler { - public void registerRenderers() + public void preInit() { } @@ -53,11 +53,6 @@ public class CommonProxy implements IGuiHandler return null; } - public boolean isPaused() - { - return false; - } - public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b, boolean split) { @@ -88,10 +83,4 @@ public class CommonProxy implements IGuiHandler this.renderElectricShock(world, start, target, 0.55f, 0.7f, 1f, b); } - - public boolean isFancy() - { - return false; - } - } diff --git a/src/main/java/resonantinduction/energy/ResonantInductionEnergy.java b/src/main/java/resonantinduction/energy/ResonantInductionEnergy.java index e534a0b69..5ddfa8b77 100644 --- a/src/main/java/resonantinduction/energy/ResonantInductionEnergy.java +++ b/src/main/java/resonantinduction/energy/ResonantInductionEnergy.java @@ -2,11 +2,9 @@ package resonantinduction.energy; import ic2.api.item.Items; -import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.logging.Logger; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -15,7 +13,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.Icon; import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.Configuration; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.fluids.Fluid; @@ -23,13 +20,15 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; -import org.modstats.ModstatInfo; import org.modstats.Modstats; import resonantinduction.Reference; +import resonantinduction.core.MultipartRI; import resonantinduction.core.PacketMultiPart; +import resonantinduction.core.ResonantInduction; +import resonantinduction.core.ResonantInductionTabs; +import resonantinduction.core.Settings; import resonantinduction.core.multimeter.ItemMultimeter; -import resonantinduction.energy.LinkEvent; import resonantinduction.energy.battery.BlockBattery; import resonantinduction.energy.battery.ItemBlockBattery; import resonantinduction.energy.battery.TileBattery; @@ -79,7 +78,7 @@ import cpw.mods.fml.relauncher.SideOnly; * @author Calclavia * */ -@Mod(modid = ResonantInductionEnergy.ID, name = ResonantInductionEnergy.NAME, version = Reference.VERSION, dependencies = "required-after:ResonantInduction|Core") +@Mod(modid = ResonantInductionEnergy.ID, name = Reference.NAME, version = Reference.VERSION, dependencies = "required-after:ResonantInduction|Core") @NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) public class ResonantInductionEnergy { @@ -87,7 +86,7 @@ public class ResonantInductionEnergy * Mod Information */ public static final String ID = "ResonantInduction|Energy"; - public static final String NAME = "Resonant Induction"; + @Instance(ID) public static ResonantInductionEnergy INSTANCE; @@ -97,74 +96,13 @@ public class ResonantInductionEnergy @Mod.Metadata(ID) public static ModMetadata metadata; - public static final Logger LOGGER = Logger.getLogger(NAME); - - /** - * Directory Information - */ - public static final String DOMAIN = "resonantinduction"; - public static final String PREFIX = DOMAIN + ":"; - public static final String DIRECTORY = "/assets/" + DOMAIN + "/"; - public static final String TEXTURE_DIRECTORY = "textures/"; - public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/"; - public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/"; - public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/"; - - public static final String MODEL_PATH = "models/"; - - public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + MODEL_PATH; - public static final String MODEL_DIRECTORY = DIRECTORY + MODEL_PATH; - - public static final String LANGUAGE_DIRECTORY = DIRECTORY + "languages/"; - public static final String[] LANGUAGES = new String[] { "en_US", "de_DE" }; - - /** - * Settings - */ - public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), NAME + ".cfg")); - public static int FURNACE_WATTAGE = 50000; - public static boolean SOUND_FXS = true; - public static boolean LO_FI_INSULATION = false; - public static boolean SHINY_SILVER = true; - public static boolean REPLACE_FURNACE = true; - - /** Block ID by Jyzarc */ - private static final int BLOCK_ID_PREFIX = 3200; - /** Item ID by Horfius */ - private static final int ITEM_ID_PREFIX = 20150; - public static int MAX_CONTRACTOR_DISTANCE = 200; - - private static int NEXT_BLOCK_ID = BLOCK_ID_PREFIX; - private static int NEXT_ITEM_ID = ITEM_ID_PREFIX; - - public static int getNextBlockID() - { - return NEXT_BLOCK_ID++; - } - - public static int getNextItemID() - { - return NEXT_ITEM_ID++; - } - // Items - /** - * Transport - */ private static Item itemPartWire; public static Item itemMultimeter; public static Item itemTransformer; - /** - * Machines - */ - public static Item itemDust; - // Blocks - public static Block blockTesla, blockEMContractor, blockBattery, blockAdvancedFurnace, - blockMachinePart, blockGrinderWheel, blockPurifier, blockFluidMixture; - - public static Fluid MIXTURE; + public static Block blockTesla, blockBattery; /** * Packets @@ -176,72 +114,32 @@ public class ResonantInductionEnergy @EventHandler public void preInit(FMLPreInitializationEvent evt) { - LOGGER.setParent(FMLLog.getLogger()); + ResonantInduction.LOGGER.setParent(FMLLog.getLogger()); NetworkRegistry.instance().registerGuiHandler(this, ResonantInductionEnergy.proxy); Modstats.instance().getReporter().registerMod(this); - CONFIGURATION.load(); - - // Config - FURNACE_WATTAGE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Furnace Wattage Per Tick", FURNACE_WATTAGE).getInt(FURNACE_WATTAGE); - SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS); - LO_FI_INSULATION = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Use lo-fi insulation texture", LO_FI_INSULATION).getBoolean(LO_FI_INSULATION); - SHINY_SILVER = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Shiny silver wires", SHINY_SILVER).getBoolean(SHINY_SILVER); - MAX_CONTRACTOR_DISTANCE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_CONTRACTOR_DISTANCE).getInt(MAX_CONTRACTOR_DISTANCE); - REPLACE_FURNACE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Replace vanilla furnace", REPLACE_FURNACE).getBoolean(REPLACE_FURNACE); - - TileEMLevitator.ACCELERATION = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Acceleration", TileEMLevitator.ACCELERATION).getDouble(TileEMLevitator.ACCELERATION); - TileEMLevitator.MAX_REACH = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Reach", TileEMLevitator.MAX_REACH).getInt(TileEMLevitator.MAX_REACH); - TileEMLevitator.MAX_SPEED = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Speed", TileEMLevitator.MAX_SPEED).getDouble(TileEMLevitator.MAX_SPEED); - TileEMLevitator.PUSH_DELAY = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Push Delay", TileEMLevitator.PUSH_DELAY).getInt(TileEMLevitator.PUSH_DELAY); + Settings.CONFIGURATION.load(); // Items - itemPartWire = new ItemWire(getNextItemID()); - itemMultimeter = new ItemMultimeter(getNextItemID()); - itemTransformer = new ItemTransformer(getNextItemID()); - itemDust = new ItemDust(getNextItemID()); + itemPartWire = new ItemWire(Settings.getNextItemID()); + itemMultimeter = new ItemMultimeter(Settings.getNextItemID()); + itemTransformer = new ItemTransformer(Settings.getNextItemID()); // Blocks - blockTesla = new BlockTesla(getNextBlockID()); - blockEMContractor = new BlockLevitator(getNextBlockID()); - blockBattery = new BlockBattery(getNextBlockID()); - blockMachinePart = new BlockMachinePart(getNextBlockID()); - blockGrinderWheel = new BlockGrinderWheel(getNextBlockID()); - blockPurifier = new BlockPurifier(getNextBlockID()); + blockTesla = new BlockTesla(Settings.getNextBlockID()); + blockBattery = new BlockBattery(Settings.getNextBlockID()); - MIXTURE = new Fluid("mixture"); - FluidRegistry.registerFluid(MIXTURE); - blockFluidMixture = new BlockFluidMixture(getNextBlockID(), MIXTURE); - - if (REPLACE_FURNACE) - { - blockAdvancedFurnace = BlockAdvancedFurnace.createNew(false); - GameRegistry.registerBlock(blockAdvancedFurnace, "ri_" + blockAdvancedFurnace.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileAdvancedFurnace.class, "ri_" + blockAdvancedFurnace.getUnlocalizedName()); - } - - CONFIGURATION.save(); + Settings.CONFIGURATION.save(); GameRegistry.registerItem(itemMultimeter, itemMultimeter.getUnlocalizedName()); GameRegistry.registerItem(itemTransformer, itemTransformer.getUnlocalizedName()); - GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName()); - - GameRegistry.registerBlock(blockGrinderWheel, blockGrinderWheel.getUnlocalizedName()); - GameRegistry.registerBlock(blockPurifier, blockPurifier.getUnlocalizedName()); - GameRegistry.registerBlock(blockFluidMixture, blockFluidMixture.getUnlocalizedName()); - GameRegistry.registerBlock(blockMachinePart, blockMachinePart.getUnlocalizedName()); GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName()); - GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName()); GameRegistry.registerBlock(blockBattery, ItemBlockBattery.class, blockBattery.getUnlocalizedName()); // Tiles - GameRegistry.registerTileEntity(TilePurifier.class, blockPurifier.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileGrinderWheel.class, blockGrinderWheel.getUnlocalizedName()); GameRegistry.registerTileEntity(TileTesla.class, blockTesla.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileEMLevitator.class, blockEMContractor.getUnlocalizedName()); GameRegistry.registerTileEntity(TileBattery.class, blockBattery.getUnlocalizedName()); - GameRegistry.registerTileEntity(TileFluidMixture.class, blockFluidMixture.getUnlocalizedName()); - ResonantInductionEnergy.proxy.registerRenderers(); + ResonantInductionEnergy.proxy.preInit(); /** * Set reference itemstacks @@ -252,23 +150,18 @@ public class ResonantInductionEnergy { material.setWire(itemPartWire); } - - MinecraftForge.EVENT_BUS.register(itemDust); - MinecraftForge.EVENT_BUS.register(new LinkEvent()); } @EventHandler public void init(FMLInitializationEvent evt) { - LOGGER.fine("Languages Loaded:" + LanguageUtility.loadLanguages(LANGUAGE_DIRECTORY, LANGUAGES)); - // TODO localize this metadata.modId = ID; - metadata.name = NAME; + metadata.name = Reference.NAME; metadata.description = LanguageUtility.getLocal("meta.resonantinduction.description"); metadata.url = "http://calclavia.com/resonant-induction"; metadata.logoFile = "ri_logo.png"; metadata.version = Reference.VERSION + "." + Reference.BUILD_VERSION; - metadata.authorList = Arrays.asList(new String[] { "Calclavia", "Alex_hawks" }); + metadata.authorList = Arrays.asList(new String[] { "Calclavia", "DarkCow" }); metadata.credits = LanguageUtility.getLocal("meta.resonantinduction.credits"); metadata.autogenerated = false; @@ -292,9 +185,6 @@ public class ResonantInductionEnergy /** Battery */ GameRegistry.addRecipe(new ShapedOreRecipe(blockBattery, "III", "IRI", "III", 'R', Block.blockRedstone, 'I', UniversalRecipe.PRIMARY_METAL.get())); - /** EM Contractor */ - GameRegistry.addRecipe(new ShapedOreRecipe(blockEMContractor, " I ", "GCG", "WWW", 'W', UniversalRecipe.PRIMARY_METAL.get(), 'C', UniversalRecipe.BATTERY.get(), 'G', UniversalRecipe.SECONDARY_METAL.get(), 'I', UniversalRecipe.PRIMARY_METAL.get())); - /** Wires **/ GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.COPPER.getWire(3), "MMM", 'M', "ingotCopper")); GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.TIN.getWire(3), "MMM", 'M', "ingotTin")); @@ -317,65 +207,6 @@ public class ResonantInductionEnergy { GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.COPPER.getWire(), "universalCable")); } - - /** Auto-gen dusts */ - ItemDust.generateDusts(); ResonantInductionEnergy.proxy.postInit(); - - /** Inject new furnace tile class */ - replaceTileEntity(TileEntityFurnace.class, TileAdvancedFurnace.class); } - - public static void replaceTileEntity(Class findTile, Class replaceTile) - { - try - { - Map nameToClassMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_a", "nameToClassMap", "a"); - Map classToNameMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_b", "classToNameMap", "b"); - - String findTileID = classToNameMap.get(findTile); - - if (findTileID != null) - { - nameToClassMap.put(findTileID, replaceTile); - classToNameMap.put(replaceTile, findTileID); - classToNameMap.remove(findTile); - LOGGER.fine("Replaced TileEntity: " + findTile); - } - else - { - LOGGER.severe("Failed to replace TileEntity: " + findTile); - } - } - catch (Exception e) - { - LOGGER.severe("Failed to replace TileEntity: " + findTile); - e.printStackTrace(); - } - } - - public static final HashMap fluidIconMap = new HashMap(); - - public void registerIcon(String name, TextureStitchEvent.Pre event) - { - fluidIconMap.put(name, event.map.registerIcon(name)); - } - - @ForgeSubscribe - @SideOnly(Side.CLIENT) - public void preTextureHook(TextureStitchEvent.Pre event) - { - if (event.map.textureType == 0) - { - registerIcon(PREFIX + "mixture", event); - } - } - - @ForgeSubscribe - @SideOnly(Side.CLIENT) - public void textureHook(TextureStitchEvent.Post event) - { - MIXTURE.setIcons(fluidIconMap.get(PREFIX + "mixture")); - } - } diff --git a/src/main/java/resonantinduction/energy/battery/BlockBattery.java b/src/main/java/resonantinduction/energy/battery/BlockBattery.java index 67a7dee9c..76a5cf6e3 100644 --- a/src/main/java/resonantinduction/energy/battery/BlockBattery.java +++ b/src/main/java/resonantinduction/energy/battery/BlockBattery.java @@ -11,7 +11,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import resonantinduction.core.base.BlockIOBase; import resonantinduction.core.render.BlockRenderingHandler; import universalelectricity.api.CompatibilityModule; @@ -29,7 +29,7 @@ public class BlockBattery extends BlockIOBase implements ITileEntityProvider public BlockBattery(int id) { super("battery", id); - this.setTextureName(ResonantInduction.PREFIX + "machine"); + this.setTextureName(Reference.PREFIX + "machine"); } @Override diff --git a/src/main/java/resonantinduction/energy/battery/RenderBattery.java b/src/main/java/resonantinduction/energy/battery/RenderBattery.java index ed24a59ff..838efaaaf 100644 --- a/src/main/java/resonantinduction/energy/battery/RenderBattery.java +++ b/src/main/java/resonantinduction/energy/battery/RenderBattery.java @@ -13,7 +13,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.IModelCustom; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -25,8 +25,8 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderBattery extends TileEntitySpecialRenderer { - public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_PATH + "battery.png"); - public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(ResonantInduction.MODEL_DIRECTORY + "battery.obj"); + public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "battery.png"); + public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "battery.obj"); @Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) diff --git a/src/main/java/resonantinduction/energy/fx/FXElectricBolt.java b/src/main/java/resonantinduction/energy/fx/FXElectricBolt.java index ba4dd0c1a..98a4a2151 100644 --- a/src/main/java/resonantinduction/energy/fx/FXElectricBolt.java +++ b/src/main/java/resonantinduction/energy/fx/FXElectricBolt.java @@ -26,7 +26,7 @@ import net.minecraft.world.World; import org.lwjgl.opengl.GL11; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import universalelectricity.api.vector.Vector3; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; @@ -41,7 +41,7 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class FXElectricBolt extends EntityFX { - public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "fadedSphere.png"); + public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_TEXTURE_DIRECTORY + "fadedSphere.png"); public static final ResourceLocation PARTICLE_RESOURCE = new ResourceLocation("textures/particle/particles.png"); /** The width of the electrical bolt. */ diff --git a/src/main/java/resonantinduction/energy/gui/GuiMultimeter.java b/src/main/java/resonantinduction/energy/gui/GuiMultimeter.java index 1b3bdc5f6..3d1782f15 100644 --- a/src/main/java/resonantinduction/energy/gui/GuiMultimeter.java +++ b/src/main/java/resonantinduction/energy/gui/GuiMultimeter.java @@ -7,7 +7,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import resonantinduction.core.multimeter.ContainerMultimeter; import resonantinduction.core.multimeter.PartMultimeter; import universalelectricity.api.energy.UnitDisplay.Unit; @@ -37,7 +37,7 @@ public class GuiMultimeter extends GuiContainerBase super(new ContainerMultimeter(inventoryPlayer, tileEntity)); this.multimeter = tileEntity; this.ySize = 217; - this.baseTexture = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.GUI_DIRECTORY + "gui_multimeter.png"); + this.baseTexture = new ResourceLocation(Reference.DOMAIN, Reference.GUI_DIRECTORY + "gui_multimeter.png"); } @Override diff --git a/src/main/java/resonantinduction/energy/tesla/BlockTesla.java b/src/main/java/resonantinduction/energy/tesla/BlockTesla.java index b2ed4f09d..7484879de 100644 --- a/src/main/java/resonantinduction/energy/tesla/BlockTesla.java +++ b/src/main/java/resonantinduction/energy/tesla/BlockTesla.java @@ -8,7 +8,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import resonantinduction.core.Utility; import resonantinduction.core.base.BlockIOBase; import resonantinduction.core.render.BlockRenderingHandler; @@ -29,7 +29,7 @@ public class BlockTesla extends BlockIOBase implements ITileEntityProvider public BlockTesla(int id) { super("tesla", id); - this.setTextureName(ResonantInduction.PREFIX + "machine"); + this.setTextureName(Reference.PREFIX + "machine"); } @Override diff --git a/src/main/java/resonantinduction/energy/tesla/RenderTesla.java b/src/main/java/resonantinduction/energy/tesla/RenderTesla.java index 60b7150b3..5f9ab82e9 100644 --- a/src/main/java/resonantinduction/energy/tesla/RenderTesla.java +++ b/src/main/java/resonantinduction/energy/tesla/RenderTesla.java @@ -9,7 +9,7 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import resonantinduction.energy.model.ModelTeslaBottom; import resonantinduction.energy.model.ModelTeslaMiddle; import resonantinduction.energy.model.ModelTeslaTop; @@ -23,9 +23,9 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderTesla extends TileEntitySpecialRenderer { - public static final ResourceLocation TEXTURE_BOTTOM = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "tesla_bottom.png"); - public static final ResourceLocation TEXTURE_MIDDLE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "tesla_middle.png"); - public static final ResourceLocation TEXTURE_TOP = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "tesla_top.png"); + public static final ResourceLocation TEXTURE_BOTTOM = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_TEXTURE_DIRECTORY + "tesla_bottom.png"); + public static final ResourceLocation TEXTURE_MIDDLE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_TEXTURE_DIRECTORY + "tesla_middle.png"); + public static final ResourceLocation TEXTURE_TOP = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_TEXTURE_DIRECTORY + "tesla_top.png"); public static final ModelTeslaBottom MODEL_BOTTOM = new ModelTeslaBottom(); public static final ModelTeslaMiddle MODEL_MIDDLE = new ModelTeslaMiddle(); public static final ModelTeslaTop MODEL_TOP = new ModelTeslaTop(); diff --git a/src/main/java/resonantinduction/energy/tesla/TileTesla.java b/src/main/java/resonantinduction/energy/tesla/TileTesla.java index e2e230d2e..7707b5b78 100644 --- a/src/main/java/resonantinduction/energy/tesla/TileTesla.java +++ b/src/main/java/resonantinduction/energy/tesla/TileTesla.java @@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.api.ITesla; import resonantinduction.energy.ILinkable; @@ -129,7 +130,7 @@ public class TileTesla extends TileElectrical implements ITesla, IPacketSender, if (this.zapCounter % 5 == 0 && ResonantInduction.SOUND_FXS) { - this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", (float) this.energy.getEnergy() / (float) TRANSFER_CAP, 1.3f - 0.5f * (this.dyeID / 16f)); + this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.PREFIX + "electricshock", (float) this.energy.getEnergy() / (float) TRANSFER_CAP, 1.3f - 0.5f * (this.dyeID / 16f)); } } } @@ -205,7 +206,7 @@ public class TileTesla extends TileElectrical implements ITesla, IPacketSender, { if (this.zapCounter % 5 == 0 && ResonantInduction.SOUND_FXS) { - this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", (float) this.energy.getEnergy() / (float) TRANSFER_CAP, 1.3f - 0.5f * (this.dyeID / 16f)); + this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.PREFIX + "electricshock", (float) this.energy.getEnergy() / (float) TRANSFER_CAP, 1.3f - 0.5f * (this.dyeID / 16f)); } Vector3 targetVector = new Vector3((TileEntity) tesla); diff --git a/src/main/java/resonantinduction/energy/transformer/RenderTransformer.java b/src/main/java/resonantinduction/energy/transformer/RenderTransformer.java index 0f1e8252f..036ebb309 100644 --- a/src/main/java/resonantinduction/energy/transformer/RenderTransformer.java +++ b/src/main/java/resonantinduction/energy/transformer/RenderTransformer.java @@ -7,7 +7,7 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import universalelectricity.api.vector.Vector3; import calclavia.lib.render.CalclaviaRenderHelper; import calclavia.lib.utility.LanguageUtility; @@ -19,7 +19,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class RenderTransformer { public static final ModelTransformer MODEL = new ModelTransformer(); - public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "transformer.png"); + public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_TEXTURE_DIRECTORY + "transformer.png"); public static void render(PartTransformer part, double x, double y, double z) { diff --git a/src/main/java/resonantinduction/energy/wire/ItemWire.java b/src/main/java/resonantinduction/energy/wire/ItemWire.java index fa55fbbda..f7ef28fd4 100644 --- a/src/main/java/resonantinduction/energy/wire/ItemWire.java +++ b/src/main/java/resonantinduction/energy/wire/ItemWire.java @@ -13,6 +13,7 @@ import net.minecraftforge.common.ForgeDirection; import org.lwjgl.input.Keyboard; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInductionTabs; import resonantinduction.core.Utility; @@ -40,7 +41,7 @@ public class ItemWire extends JItemMultiPart public ItemWire(int id) { super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "wire", id).getInt(id)); - this.setUnlocalizedName(ResonantInduction.PREFIX + "wire"); + this.setUnlocalizedName(Reference.PREFIX + "wire"); this.setCreativeTab(ResonantInductionTabs.CORE); this.setHasSubtypes(true); this.setMaxDamage(0); @@ -122,12 +123,12 @@ public class ItemWire extends JItemMultiPart { for (EnumWireMaterial material : EnumWireMaterial.values()) { - icons[material.ordinal()] = register.registerIcon(ResonantInduction.PREFIX + "wire." + EnumWireMaterial.values()[material.ordinal()].getName().toLowerCase()); + icons[material.ordinal()] = register.registerIcon(Reference.PREFIX + "wire." + EnumWireMaterial.values()[material.ordinal()].getName().toLowerCase()); } - RenderFlatWire.flatWireTexture = register.registerIcon(ResonantInduction.PREFIX + "models/flatWire"); - RenderPartWire.wireIcon = register.registerIcon(ResonantInduction.PREFIX + "models/wire"); - RenderPartWire.insulationIcon = register.registerIcon(ResonantInduction.PREFIX + "models/insulation" + (ResonantInduction.LO_FI_INSULATION ? "tiny" : "")); + RenderFlatWire.flatWireTexture = register.registerIcon(Reference.PREFIX + "models/flatWire"); + RenderPartWire.wireIcon = register.registerIcon(Reference.PREFIX + "models/wire"); + RenderPartWire.insulationIcon = register.registerIcon(Reference.PREFIX + "models/insulation" + (ResonantInduction.LO_FI_INSULATION ? "tiny" : "")); } @Override diff --git a/src/main/java/resonantinduction/energy/wire/framed/RenderPartWire.java b/src/main/java/resonantinduction/energy/wire/framed/RenderPartWire.java index 7bc1c357e..7982a2f20 100644 --- a/src/main/java/resonantinduction/energy/wire/framed/RenderPartWire.java +++ b/src/main/java/resonantinduction/energy/wire/framed/RenderPartWire.java @@ -11,6 +11,7 @@ import net.minecraftforge.common.ForgeDirection; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.render.InvertX; import codechicken.lib.colour.Colour; @@ -33,7 +34,7 @@ import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderPartWire { - private static final ResourceLocation WIRE_SHINE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "white.png"); + private static final ResourceLocation WIRE_SHINE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_TEXTURE_DIRECTORY + "white.png"); public static final Map models; public static final Map shinyModels; public static Icon wireIcon; @@ -133,8 +134,8 @@ public class RenderPartWire public static void registerIcons(IconRegister iconReg) { - lainWireIcon = iconReg.registerIcon(ResonantInduction.PREFIX + "models/lainWire"); - breakIcon = iconReg.registerIcon(ResonantInduction.PREFIX + "wire"); + lainWireIcon = iconReg.registerIcon(Reference.PREFIX + "models/lainWire"); + breakIcon = iconReg.registerIcon(Reference.PREFIX + "wire"); } public void renderStatic(PartFramedWire wire) diff --git a/src/main/java/resonantinduction/mechanics/ClientProxy.java b/src/main/java/resonantinduction/mechanics/ClientProxy.java new file mode 100644 index 000000000..a2a8d7d5a --- /dev/null +++ b/src/main/java/resonantinduction/mechanics/ClientProxy.java @@ -0,0 +1,101 @@ +package resonantinduction.mechanics; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.common.MinecraftForge; +import resonantinduction.core.ResonantInduction; +import resonantinduction.core.SoundHandler; +import resonantinduction.core.multimeter.PartMultimeter; +import resonantinduction.core.render.BlockRenderingHandler; +import resonantinduction.core.render.RenderRIItem; +import resonantinduction.energy.battery.RenderBattery; +import resonantinduction.energy.battery.TileBattery; +import resonantinduction.energy.fx.FXElectricBolt; +import resonantinduction.energy.gui.GuiMultimeter; +import resonantinduction.energy.tesla.RenderTesla; +import resonantinduction.energy.tesla.TileTesla; +import resonantinduction.mechanics.item.ItemDust; +import resonantinduction.transport.levitator.RenderLevitator; +import resonantinduction.transport.levitator.TileEMLevitator; +import universalelectricity.api.vector.Vector3; +import codechicken.multipart.TMultiPart; +import codechicken.multipart.TileMultipart; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * @author Calclavia + * + */ +@SideOnly(Side.CLIENT) +public class ClientProxy extends CommonProxy +{ + @Override + public void preInit() + { + RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE); + } + + @Override + public void postInit() + { + } + + @Override + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) + { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + if (tileEntity instanceof TileMultipart) + { + TMultiPart part = ((TileMultipart) tileEntity).partMap(id); + + if (part instanceof PartMultimeter) + { + return new GuiMultimeter(player.inventory, (PartMultimeter) part); + } + } + + return null; + } + + @Override + public boolean isPaused() + { + if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) + { + GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen; + + if (screen != null) + { + if (screen.doesGuiPauseGame()) + { + return true; + } + } + } + + return false; + } + + @Override + public boolean isFancy() + { + return FMLClientHandler.instance().getClient().gameSettings.fancyGraphics; + } + + @Override + public void renderElectricShock(World world, Vector3 start, Vector3 target, float r, float g, float b, boolean split) + { + if (world.isRemote) + { + FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FXElectricBolt(world, start, target, split).setColor(r, g, b)); + } + } +} diff --git a/src/main/java/resonantinduction/mechanics/CommonProxy.java b/src/main/java/resonantinduction/mechanics/CommonProxy.java new file mode 100644 index 000000000..75efd9ae8 --- /dev/null +++ b/src/main/java/resonantinduction/mechanics/CommonProxy.java @@ -0,0 +1,60 @@ +/** + * + */ +package resonantinduction.mechanics; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import resonantinduction.core.multimeter.ContainerMultimeter; +import resonantinduction.core.multimeter.PartMultimeter; +import universalelectricity.api.vector.Vector3; +import codechicken.lib.colour.ColourRGBA; +import codechicken.multipart.TMultiPart; +import codechicken.multipart.TileMultipart; +import cpw.mods.fml.common.network.IGuiHandler; + +/** + * @author Calclavia + * + */ +public class CommonProxy implements IGuiHandler +{ + public void preInit() + { + + } + + public void init() + { + + } + + public void postInit() + { + + } + + @Override + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) + { + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); + + if (tileEntity instanceof TileMultipart) + { + TMultiPart part = ((TileMultipart) tileEntity).partMap(id); + if (part instanceof PartMultimeter) + { + return new ContainerMultimeter(player.inventory, ((PartMultimeter) part)); + } + } + + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) + { + return null; + } +} diff --git a/src/main/java/resonantinduction/mechanics/ResonantInductionMechanics.java b/src/main/java/resonantinduction/mechanics/ResonantInductionMechanics.java new file mode 100644 index 000000000..5985fc598 --- /dev/null +++ b/src/main/java/resonantinduction/mechanics/ResonantInductionMechanics.java @@ -0,0 +1,225 @@ +package resonantinduction.mechanics; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.Icon; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import org.modstats.Modstats; + +import resonantinduction.Reference; +import resonantinduction.core.MultipartRI; +import resonantinduction.core.PacketMultiPart; +import resonantinduction.core.ResonantInduction; +import resonantinduction.core.Settings; +import resonantinduction.core.resource.ResourceGenerator; +import resonantinduction.mechanics.furnace.BlockAdvancedFurnace; +import resonantinduction.mechanics.furnace.TileAdvancedFurnace; +import resonantinduction.mechanics.grinder.BlockGrinderWheel; +import resonantinduction.mechanics.grinder.TileGrinderWheel; +import resonantinduction.mechanics.grinder.TilePurifier; +import resonantinduction.mechanics.item.ItemDust; +import resonantinduction.mechanics.liquid.BlockFluidMixture; +import resonantinduction.mechanics.liquid.TileFluidMixture; +import resonantinduction.mechanics.purifier.BlockPurifier; +import calclavia.lib.network.PacketHandler; +import calclavia.lib.network.PacketTile; +import calclavia.lib.utility.LanguageUtility; +import codechicken.lib.colour.ColourRGBA; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.ModMetadata; +import cpw.mods.fml.common.ObfuscationReflectionHelper; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * The core module of Resonant Induction + * + * @author Calclavia + * + */ +@Mod(modid = ResonantInductionMechanics.ID, name = Reference.NAME, version = Reference.VERSION, dependencies = "required-after:ResonantInduction|Core") +@NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) +public class ResonantInductionMechanics +{ + /** + * Mod Information + */ + public static final String ID = "ResonantInduction|Mechanics"; + + @Instance(ID) + public static ResonantInductionMechanics INSTANCE; + + @SidedProxy(clientSide = "resonantinduction.mechanics.ClientProxy", serverSide = "resonantinduction.mechanics.CommonProxy") + public static CommonProxy proxy; + + @Mod.Metadata(ID) + public static ModMetadata metadata; + + // Items + + /** + * Machines + */ + public static Item itemDust; + + // Blocks + public static Block blockAdvancedFurnace, blockMachinePart, blockGrinderWheel, blockPurifier, + blockFluidMixture; + + public static Fluid MIXTURE; + + /** + * Packets + */ + public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL); + public static final PacketMultiPart PACKET_MULTIPART = new PacketMultiPart(Reference.CHANNEL); + public static final ColourRGBA[] DYE_COLORS = new ColourRGBA[] { new ColourRGBA(255, 255, 255, 255), new ColourRGBA(1, 0, 0, 1d), new ColourRGBA(0, 0.608, 0.232, 1d), new ColourRGBA(0.588, 0.294, 0, 1d), new ColourRGBA(0, 0, 1, 1d), new ColourRGBA(0.5, 0, 05, 1d), new ColourRGBA(0, 1, 1, 1d), new ColourRGBA(0.8, 0.8, 0.8, 1d), new ColourRGBA(0.3, 0.3, 0.3, 1d), new ColourRGBA(1, 0.412, 0.706, 1d), new ColourRGBA(0.616, 1, 0, 1d), new ColourRGBA(1, 1, 0, 1d), new ColourRGBA(0.46f, 0.932, 1, 1d), new ColourRGBA(0.5, 0.2, 0.5, 1d), new ColourRGBA(0.7, 0.5, 0.1, 1d), new ColourRGBA(1, 1, 1, 1d) }; + + @EventHandler + public void preInit(FMLPreInitializationEvent evt) + { + ResonantInduction.LOGGER.setParent(FMLLog.getLogger()); + NetworkRegistry.instance().registerGuiHandler(this, ResonantInductionMechanics.proxy); + Modstats.instance().getReporter().registerMod(this); + Settings.CONFIGURATION.load(); + + // Items + itemDust = new ItemDust(Settings.getNextItemID()); + + // Blocks + blockMachinePart = new BlockMachinePart(Settings.getNextBlockID()); + blockGrinderWheel = new BlockGrinderWheel(Settings.getNextBlockID()); + blockPurifier = new BlockPurifier(Settings.getNextBlockID()); + + MIXTURE = new Fluid("mixture"); + FluidRegistry.registerFluid(MIXTURE); + blockFluidMixture = new BlockFluidMixture(Settings.getNextBlockID(), MIXTURE); + + if (Settings.REPLACE_FURNACE) + { + blockAdvancedFurnace = BlockAdvancedFurnace.createNew(false); + GameRegistry.registerBlock(blockAdvancedFurnace, "ri_" + blockAdvancedFurnace.getUnlocalizedName()); + GameRegistry.registerTileEntity(TileAdvancedFurnace.class, "ri_" + blockAdvancedFurnace.getUnlocalizedName()); + } + + Settings.CONFIGURATION.save(); + GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName()); + + GameRegistry.registerBlock(blockGrinderWheel, blockGrinderWheel.getUnlocalizedName()); + GameRegistry.registerBlock(blockPurifier, blockPurifier.getUnlocalizedName()); + GameRegistry.registerBlock(blockFluidMixture, blockFluidMixture.getUnlocalizedName()); + GameRegistry.registerBlock(blockMachinePart, blockMachinePart.getUnlocalizedName()); + + // Tiles + GameRegistry.registerTileEntity(TilePurifier.class, blockPurifier.getUnlocalizedName()); + GameRegistry.registerTileEntity(TileGrinderWheel.class, blockGrinderWheel.getUnlocalizedName()); + GameRegistry.registerTileEntity(TileFluidMixture.class, blockFluidMixture.getUnlocalizedName()); + + ResonantInductionMechanics.proxy.preInit(); + MinecraftForge.EVENT_BUS.register(itemDust); + } + + @EventHandler + public void init(FMLInitializationEvent evt) + { + metadata.modId = ID; + metadata.name = Reference.NAME; + metadata.description = LanguageUtility.getLocal("meta.resonantinduction.description"); + metadata.url = "http://calclavia.com/resonant-induction"; + metadata.logoFile = "ri_logo.png"; + metadata.version = Reference.VERSION + "." + Reference.BUILD_VERSION; + metadata.authorList = Arrays.asList(new String[] { "Calclavia", "DarkCow" }); + metadata.credits = LanguageUtility.getLocal("meta.resonantinduction.credits"); + metadata.autogenerated = false; + + MultipartRI.INSTANCE = new MultipartRI(); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent evt) + { + /** + * Recipes + */ + /** Auto-gen dusts */ + ResourceGenerator.generateDusts(); + ResonantInductionMechanics.proxy.postInit(); + + /** Inject new furnace tile class */ + replaceTileEntity(TileEntityFurnace.class, TileAdvancedFurnace.class); + } + + public static void replaceTileEntity(Class findTile, Class replaceTile) + { + try + { + Map nameToClassMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_a", "nameToClassMap", "a"); + Map classToNameMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_b", "classToNameMap", "b"); + + String findTileID = classToNameMap.get(findTile); + + if (findTileID != null) + { + nameToClassMap.put(findTileID, replaceTile); + classToNameMap.put(replaceTile, findTileID); + classToNameMap.remove(findTile); + ResonantInduction.LOGGER.fine("Replaced TileEntity: " + findTile); + } + else + { + ResonantInduction.LOGGER.severe("Failed to replace TileEntity: " + findTile); + } + } + catch (Exception e) + { + ResonantInduction.LOGGER.severe("Failed to replace TileEntity: " + findTile); + e.printStackTrace(); + } + } + + public static final HashMap fluidIconMap = new HashMap(); + + public void registerIcon(String name, TextureStitchEvent.Pre event) + { + fluidIconMap.put(name, event.map.registerIcon(name)); + } + + @ForgeSubscribe + @SideOnly(Side.CLIENT) + public void preTextureHook(TextureStitchEvent.Pre event) + { + if (event.map.textureType == 0) + { + registerIcon(Reference.PREFIX + "mixture", event); + } + } + + @ForgeSubscribe + @SideOnly(Side.CLIENT) + public void textureHook(TextureStitchEvent.Post event) + { + MIXTURE.setIcons(fluidIconMap.get(Reference.PREFIX + "mixture")); + } + +} diff --git a/src/main/java/resonantinduction/mechanics/grinder/TileGrinderWheel.java b/src/main/java/resonantinduction/mechanics/grinder/TileGrinderWheel.java index 630bf62cd..48b1f53e5 100644 --- a/src/main/java/resonantinduction/mechanics/grinder/TileGrinderWheel.java +++ b/src/main/java/resonantinduction/mechanics/grinder/TileGrinderWheel.java @@ -4,7 +4,7 @@ import java.util.HashMap; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import resonantinduction.core.api.MachineRecipes; import resonantinduction.core.api.MachineRecipes.RecipeType; import resonantinduction.core.api.RecipeUtils.ItemStackResource; @@ -100,7 +100,7 @@ public class TileGrinderWheel extends TileElectrical { if (this.ticks % 20 == 0) { - this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "grinder", 0.5f, 1); + this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.PREFIX + "grinder", 0.5f, 1); } this.energy.extractEnergy(POWER / 20, true); diff --git a/src/main/java/resonantinduction/mechanics/grinder/TilePurifier.java b/src/main/java/resonantinduction/mechanics/grinder/TilePurifier.java index ef102042a..3b4f5596c 100644 --- a/src/main/java/resonantinduction/mechanics/grinder/TilePurifier.java +++ b/src/main/java/resonantinduction/mechanics/grinder/TilePurifier.java @@ -7,7 +7,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import resonantinduction.core.api.MachineRecipes; import resonantinduction.core.api.MachineRecipes.RecipeType; import resonantinduction.core.api.RecipeUtils.ItemStackResource; @@ -133,7 +133,7 @@ public class TilePurifier extends TileElectrical { if (this.ticks % 20 == 0) { - this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "grinder", 0.5f, 1); + this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.PREFIX + "grinder", 0.5f, 1); } this.energy.extractEnergy(POWER / 20, true); diff --git a/src/main/java/resonantinduction/mechanics/item/ItemDust.java b/src/main/java/resonantinduction/mechanics/item/ItemDust.java index 0cfd73f54..232b234cd 100644 --- a/src/main/java/resonantinduction/mechanics/item/ItemDust.java +++ b/src/main/java/resonantinduction/mechanics/item/ItemDust.java @@ -1,36 +1,23 @@ package resonantinduction.mechanics.item; -import java.awt.Color; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Method; -import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Set; -import javax.imageio.ImageIO; - -import net.minecraft.client.Minecraft; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; -import resonantinduction.core.api.MachineRecipes; import resonantinduction.core.api.OreDetectionBlackList; -import resonantinduction.core.api.MachineRecipes.RecipeType; import resonantinduction.core.base.ItemBase; +import resonantinduction.core.resource.ResourceGenerator; import calclavia.lib.utility.LanguageUtility; import calclavia.lib.utility.NBTUtility; -import cpw.mods.fml.relauncher.ReflectionHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -42,14 +29,11 @@ import cpw.mods.fml.relauncher.SideOnly; */ public class ItemDust extends ItemBase { - public static final Set materialNames = new HashSet(); public static final Set dusts = new HashSet(); - public static final HashMap ingotColors = new HashMap(); - public ItemDust(int id) { super("dust", id); - this.setTextureName(ResonantInduction.PREFIX + "dust"); + this.setTextureName(Reference.PREFIX + "dust"); } @Override @@ -72,7 +56,7 @@ public class ItemDust extends ItemBase if (OreDetectionBlackList.isIngotBlackListed("ingot" + ingotName) || OreDetectionBlackList.isOreBlackListed("ore" + ingotName)) return; - materialNames.add(ingotName.toLowerCase()); + ResourceGenerator.materialNames.add(ingotName.toLowerCase()); } } @@ -80,113 +64,7 @@ public class ItemDust extends ItemBase @SideOnly(Side.CLIENT) public void reloadTextures(TextureStitchEvent.Post e) { - computeColors(); - } - - public static void generateDusts() - { - for (String materialName : materialNames) - { - String name = materialName.substring(0, 1).toUpperCase() + materialName.substring(1); - - if (OreDictionary.getOres("ore" + name).size() > 0) - { - if (OreDictionary.getOres("dust" + name).size() == 0) - { - dusts.add(getStackFromDust(materialName)); - OreDictionary.registerOre("dust" + name, getStackFromDust(materialName)); - - } - - // Add to machine recipes - - ItemStack dust = OreDictionary.getOres("dust" + name).get(0).copy(); - dust.stackSize = 2; - MachineRecipes.INSTANCE.addRecipe(RecipeType.GRINDER, "ore" + name, dust); - } - } - } - - @SideOnly(Side.CLIENT) - public static void computeColors() - { - for (String ingotName : materialNames) - { - LinkedList colorCodes = new LinkedList(); - - // Compute color - int totalR = 0; - int totalG = 0; - int totalB = 0; - - for (ItemStack ingotStack : OreDictionary.getOres("ingot" + ingotName.substring(0, 1).toUpperCase() + ingotName.substring(1))) - { - - Item theIngot = ingotStack.getItem(); - - Method o = ReflectionHelper.findMethod(Item.class, theIngot, new String[] { "getIconString", "func_" + "111208_A" }); - String iconString; - - try - { - iconString = (String) o.invoke(theIngot); - } - catch (ReflectiveOperationException e1) - { - // e1.printStackTrace(); - break; - } - - ResourceLocation textureLocation = new ResourceLocation(iconString.replace(":", ":" + ResonantInduction.ITEM_TEXTURE_DIRECTORY) + ".png"); - InputStream inputstream; - try - { - inputstream = Minecraft.getMinecraft().getResourceManager().getResource(textureLocation).getInputStream(); - - BufferedImage bufferedimage = ImageIO.read(inputstream); - - int width = bufferedimage.getWidth(); - int height = bufferedimage.getWidth(); - - for (int x = 0; x < width; x++) - { - for (int y = 0; y < height; y++) - { - colorCodes.add(bufferedimage.getRGB(x, y)); - } - } - } - catch (IOException e) - { - // e.printStackTrace(); - } - } - if (colorCodes.size() > 0) - { - for (int colorCode : colorCodes) - { - Color color = new Color(colorCode); - - if (color.getAlpha() != 0) - { - totalR += color.getRed(); - totalG += color.getGreen(); - totalB += color.getBlue(); - } - } - - totalR /= colorCodes.size(); - totalG /= colorCodes.size(); - totalB /= colorCodes.size(); - - int resultantColor = new Color(totalR, totalG, totalB).brighter().brighter().getRGB(); - ingotColors.put(ingotName, resultantColor); - } - if (!ingotColors.containsKey(ingotName)) - { - ingotColors.put(ingotName, 0xFFFFFF); - } - } + ResourceGenerator.computeColors(); } public static ItemStack getStackFromDust(String name) @@ -225,9 +103,9 @@ public class ItemDust extends ItemBase */ String name = this.getDustFromStack(itemStack); - if (ingotColors.containsKey(name)) + if (ResourceGenerator.materialColors.containsKey(name)) { - return ingotColors.get(name); + return ResourceGenerator.materialColors.get(name); } return 16777215; diff --git a/src/main/java/resonantinduction/transport/ResonantInductionTransport.java b/src/main/java/resonantinduction/transport/ResonantInductionTransport.java index 56b8703ba..3c32f73de 100644 --- a/src/main/java/resonantinduction/transport/ResonantInductionTransport.java +++ b/src/main/java/resonantinduction/transport/ResonantInductionTransport.java @@ -45,6 +45,7 @@ import resonantinduction.blocks.BlockOre; import resonantinduction.blocks.GasOreGenerator; import resonantinduction.blocks.ItemBlockColored; import resonantinduction.blocks.BlockOre.OreData; +import resonantinduction.core.Settings; import resonantinduction.core.debug.BlockDebug; import resonantinduction.core.multimeter.ItemReadoutTools; import resonantinduction.core.network.PacketIDTile; @@ -89,6 +90,9 @@ import resonantinduction.transport.fluid.ItemFluidCan; import resonantinduction.transport.hopper.BlockAdvancedHopper; import resonantinduction.transport.imprinter.BlockImprinter; import resonantinduction.transport.imprinter.ItemImprinter; +import resonantinduction.transport.levitator.BlockLevitator; +import resonantinduction.transport.levitator.ItemBlockContractor; +import resonantinduction.transport.levitator.TileEMLevitator; import resonantinduction.transport.logistic.BlockDetector; import resonantinduction.transport.logistic.BlockManipulator; import resonantinduction.transport.logistic.BlockRejector; @@ -132,268 +136,274 @@ import cpw.mods.fml.relauncher.Side; @NetworkMod(channels = { ResonantInductionTransport.CHANNEL }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) public class ResonantInductionTransport { - public static final String TEXTURE_DIRECTORY = "textures/"; - public static final String BLOCK_DIRECTORY = TEXTURE_DIRECTORY + "blocks/"; - public static final String ITEM_DIRECTORY = TEXTURE_DIRECTORY + "items/"; - public static final String MODEL_DIRECTORY = TEXTURE_DIRECTORY + "models/"; - public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/"; - public static final String CHANNEL = "ALChannel"; + public static final String TEXTURE_DIRECTORY = "textures/"; + public static final String BLOCK_DIRECTORY = TEXTURE_DIRECTORY + "blocks/"; + public static final String ITEM_DIRECTORY = TEXTURE_DIRECTORY + "items/"; + public static final String MODEL_DIRECTORY = TEXTURE_DIRECTORY + "models/"; + public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/"; + public static final String CHANNEL = "ALChannel"; - // @Mod - public static final String MOD_ID = "AssemblyLine"; - public static final String MOD_NAME = "Assembly Line"; + // @Mod + public static final String MOD_ID = "AssemblyLine"; + public static final String MOD_NAME = "Assembly Line"; - public static final String DOMAIN = "al"; - public static final String PREFIX = DOMAIN + ":"; + public static final String DOMAIN = "al"; + public static final String PREFIX = DOMAIN + ":"; - public static String DIRECTORY_NO_SLASH = "assets/" + DOMAIN + "/"; - public static String DIRECTORY = "/" + DIRECTORY_NO_SLASH; - public static String LANGUAGE_PATH = DIRECTORY + "languages/"; - public static String SOUND_PATH = DIRECTORY + "audio/"; + public static String DIRECTORY_NO_SLASH = "assets/" + DOMAIN + "/"; + public static String DIRECTORY = "/" + DIRECTORY_NO_SLASH; + public static String LANGUAGE_PATH = DIRECTORY + "languages/"; + public static String SOUND_PATH = DIRECTORY + "audio/"; - @SidedProxy(clientSide = "com.builtbroken.assemblyline.client.ClientProxy", serverSide = "com.builtbroken.assemblyline.CommonProxy") - public static CommonProxy proxy; + @SidedProxy(clientSide = "com.builtbroken.assemblyline.client.ClientProxy", serverSide = "com.builtbroken.assemblyline.CommonProxy") + public static CommonProxy proxy; - @Instance(ResonantInductionTransport.MOD_ID) - public static ResonantInductionTransport instance; + @Instance(ResonantInductionTransport.MOD_ID) + public static ResonantInductionTransport instance; - @Metadata(ResonantInductionTransport.MOD_ID) - public static ModMetadata meta; + @Metadata(ResonantInductionTransport.MOD_ID) + public static ModMetadata meta; - private static final String[] LANGUAGES_SUPPORTED = new String[] { "en_US", "de_DE" }; + private static final String[] LANGUAGES_SUPPORTED = new String[] { "en_US", "de_DE" }; - public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "AssemblyLine.cfg")); + public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "AssemblyLine.cfg")); - public static Logger FMLog = Logger.getLogger(ResonantInductionTransport.MOD_NAME); + public static Logger FMLog = Logger.getLogger(ResonantInductionTransport.MOD_NAME); - public static boolean VINALLA_RECIPES = false; + public static boolean VINALLA_RECIPES = false; - public static int entitiesIds = 60; + public static int entitiesIds = 60; - private static PacketIDTile tilePacket; + private static PacketIDTile tilePacket; - public static PacketIDTile getTilePacket() - { - if (tilePacket == null) - { - tilePacket = new PacketIDTile(ResonantInductionTransport.CHANNEL); - } - return tilePacket; - } + public static Block blockEMContractor; - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { - CONFIGURATION.load(); - FMLog.setParent(FMLLog.getLogger()); + public static PacketIDTile getTilePacket() + { + if (tilePacket == null) + { + tilePacket = new PacketIDTile(ResonantInductionTransport.CHANNEL); + } + return tilePacket; + } - DarkCore.instance().preLoad(); - Modstats.instance().getReporter().registerMod(this); - MinecraftForge.EVENT_BUS.register(this); - MinecraftForge.EVENT_BUS.register(new FluidHelper()); - MinecraftForge.EVENT_BUS.register(SaveManager.instance()); - TickRegistry.registerTickHandler(NetworkUpdateHandler.instance(), Side.SERVER); - TickRegistry.registerScheduledTickHandler(new PlayerKeyHandler(ResonantInductionTransport.CHANNEL), Side.CLIENT); - MinecraftForge.EVENT_BUS.register(new LaserEntityDamageSource(null)); - NetworkRegistry.instance().registerGuiHandler(this, proxy); + @EventHandler + public void preInit(FMLPreInitializationEvent event) + { + CONFIGURATION.load(); + + blockEMContractor = new BlockLevitator(Settings.getNextBlockID()); + GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName()); + GameRegistry.registerTileEntity(TileEMLevitator.class, blockEMContractor.getUnlocalizedName()); - TaskRegistry.registerCommand(new TaskDrop()); - TaskRegistry.registerCommand(new TaskGive()); - TaskRegistry.registerCommand(new TaskTake()); - TaskRegistry.registerCommand(new TaskGrabItem()); - TaskRegistry.registerCommand(new TaskGrabEntity()); - TaskRegistry.registerCommand(new TaskRotateBy()); - TaskRegistry.registerCommand(new TaskRotateTo()); - TaskRegistry.registerCommand(new TaskUse()); - TaskRegistry.registerCommand(new TaskIF()); - TaskRegistry.registerCommand(new TaskGOTO()); - TaskRegistry.registerCommand(new TaskReturn()); - TaskRegistry.registerCommand(new TaskEnd()); - TaskRegistry.registerCommand(new TaskFire()); - TaskRegistry.registerCommand(new TaskHarvest()); - TaskRegistry.registerCommand(new TaskPlace()); - TaskRegistry.registerCommand(new TaskBreak()); - TaskRegistry.registerCommand(new TaskStart()); - TaskRegistry.registerCommand(new TaskIdle()); + DarkCore.instance().preLoad(); + Modstats.instance().getReporter().registerMod(this); + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.register(new FluidHelper()); + MinecraftForge.EVENT_BUS.register(SaveManager.instance()); + TickRegistry.registerTickHandler(NetworkUpdateHandler.instance(), Side.SERVER); + TickRegistry.registerScheduledTickHandler(new PlayerKeyHandler(ResonantInductionTransport.CHANNEL), Side.CLIENT); + MinecraftForge.EVENT_BUS.register(new LaserEntityDamageSource(null)); + NetworkRegistry.instance().registerGuiHandler(this, proxy); - this.registerObjects(); - proxy.preInit(); - } + TaskRegistry.registerCommand(new TaskDrop()); + TaskRegistry.registerCommand(new TaskGive()); + TaskRegistry.registerCommand(new TaskTake()); + TaskRegistry.registerCommand(new TaskGrabItem()); + TaskRegistry.registerCommand(new TaskGrabEntity()); + TaskRegistry.registerCommand(new TaskRotateBy()); + TaskRegistry.registerCommand(new TaskRotateTo()); + TaskRegistry.registerCommand(new TaskUse()); + TaskRegistry.registerCommand(new TaskIF()); + TaskRegistry.registerCommand(new TaskGOTO()); + TaskRegistry.registerCommand(new TaskReturn()); + TaskRegistry.registerCommand(new TaskEnd()); + TaskRegistry.registerCommand(new TaskFire()); + TaskRegistry.registerCommand(new TaskHarvest()); + TaskRegistry.registerCommand(new TaskPlace()); + TaskRegistry.registerCommand(new TaskBreak()); + TaskRegistry.registerCommand(new TaskStart()); + TaskRegistry.registerCommand(new TaskIdle()); - @EventHandler - public void init(FMLInitializationEvent event) - { - DarkCore.instance().Load(); + this.registerObjects(); + proxy.preInit(); + } - FMLog.info("Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " languages."); + @EventHandler + public void init(FMLInitializationEvent event) + { + DarkCore.instance().Load(); - for (EnumGas gas : EnumGas.values()) - { - FluidRegistry.registerFluid(gas.getGas()); - } - if (RecipeLoader.blockGas != null) - { - EnumGas.NATURAL_GAS.getGas().setBlockID(RecipeLoader.blockGas); - } - if (RecipeLoader.blockGas != null) - { - GameRegistry.registerWorldGenerator(new GasOreGenerator()); - } - if (RecipeLoader.blockOre != null) - { - for (OreData data : OreData.values()) - { - if (data.doWorldGen) - { - OreGenReplaceStone gen = data.getGeneratorSettings(); - if (gen != null) - { - OreGenerator.addOre(gen); - } - } - } - } - if (RecipeLoader.itemParts != null) - { - for (Parts part : Parts.values()) - { - OreDictionary.registerOre(part.name, new ItemStack(RecipeLoader.itemParts, 1, part.ordinal())); - } - } - proxy.init(); - } + FMLog.info("Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " languages."); - @EventHandler - public void postInit(FMLPostInitializationEvent event) - { - DarkCore.instance().postLoad(); - proxy.postInit(); - RecipeLoader.instance().loadRecipes(); - CONFIGURATION.save(); - } + for (EnumGas gas : EnumGas.values()) + { + FluidRegistry.registerFluid(gas.getGas()); + } + if (RecipeLoader.blockGas != null) + { + EnumGas.NATURAL_GAS.getGas().setBlockID(RecipeLoader.blockGas); + } + if (RecipeLoader.blockGas != null) + { + GameRegistry.registerWorldGenerator(new GasOreGenerator()); + } + if (RecipeLoader.blockOre != null) + { + for (OreData data : OreData.values()) + { + if (data.doWorldGen) + { + OreGenReplaceStone gen = data.getGeneratorSettings(); + if (gen != null) + { + OreGenerator.addOre(gen); + } + } + } + } + if (RecipeLoader.itemParts != null) + { + for (Parts part : Parts.values()) + { + OreDictionary.registerOre(part.name, new ItemStack(RecipeLoader.itemParts, 1, part.ordinal())); + } + } + proxy.init(); + } - /** Separated method for registering & creating objects */ - public void registerObjects() - { + @EventHandler + public void postInit(FMLPostInitializationEvent event) + { + DarkCore.instance().postLoad(); + proxy.postInit(); + RecipeLoader.instance().loadRecipes(); + CONFIGURATION.save(); + } - /* BLOCKS */ - RecipeLoader.blockConveyorBelt = CoreRegistry.createNewBlock("ALBlockConveyor", ResonantInductionTransport.MOD_ID, BlockConveyorBelt.class); - RecipeLoader.blockManipulator = CoreRegistry.createNewBlock("Manipulator", ResonantInductionTransport.MOD_ID, BlockManipulator.class); - RecipeLoader.blockCrate = (BlockCrate) CoreRegistry.createNewBlock("Crate", ResonantInductionTransport.MOD_ID, BlockCrate.class, ItemBlockCrate.class); - RecipeLoader.blockImprinter = CoreRegistry.createNewBlock("Imprinter", ResonantInductionTransport.MOD_ID, BlockImprinter.class); - RecipeLoader.blockDetector = CoreRegistry.createNewBlock("Detector", ResonantInductionTransport.MOD_ID, BlockDetector.class); + /** Separated method for registering & creating objects */ + public void registerObjects() + { - RecipeLoader.blockRejector = CoreRegistry.createNewBlock("Rejector", ResonantInductionTransport.MOD_ID, BlockRejector.class); - RecipeLoader.blockEncoder = CoreRegistry.createNewBlock("Encoder", ResonantInductionTransport.MOD_ID, BlockEncoder.class); - RecipeLoader.blockArmbot = CoreRegistry.createNewBlock("Armbot", ResonantInductionTransport.MOD_ID, BlockArmbot.class); - RecipeLoader.blockTurntable = CoreRegistry.createNewBlock("Turntable", ResonantInductionTransport.MOD_ID, BlockTurntable.class); - RecipeLoader.processorMachine = CoreRegistry.createNewBlock("ALBlockProcessor", ResonantInductionTransport.MOD_ID, BlockProcessor.class, ItemBlockHolder.class); + /* BLOCKS */ + RecipeLoader.blockConveyorBelt = CoreRegistry.createNewBlock("ALBlockConveyor", ResonantInductionTransport.MOD_ID, BlockConveyorBelt.class); + RecipeLoader.blockManipulator = CoreRegistry.createNewBlock("Manipulator", ResonantInductionTransport.MOD_ID, BlockManipulator.class); + RecipeLoader.blockCrate = (BlockCrate) CoreRegistry.createNewBlock("Crate", ResonantInductionTransport.MOD_ID, BlockCrate.class, ItemBlockCrate.class); + RecipeLoader.blockImprinter = CoreRegistry.createNewBlock("Imprinter", ResonantInductionTransport.MOD_ID, BlockImprinter.class); + RecipeLoader.blockDetector = CoreRegistry.createNewBlock("Detector", ResonantInductionTransport.MOD_ID, BlockDetector.class); - RecipeLoader.blockAdvancedHopper = CoreRegistry.createNewBlock("ALBlockHopper", ResonantInductionTransport.MOD_ID, BlockAdvancedHopper.class, ItemBlockHolder.class); - RecipeLoader.blockPipe = CoreRegistry.createNewBlock("FMBlockPipe", ResonantInductionTransport.MOD_ID, BlockPipe.class, ItemBlockPipe.class); - RecipeLoader.blockPumpMachine = CoreRegistry.createNewBlock("FMBlockPump", ResonantInductionTransport.MOD_ID, BlockPumpMachine.class, ItemBlockHolder.class); - RecipeLoader.blockReleaseValve = CoreRegistry.createNewBlock("FMBlockReleaseValve", ResonantInductionTransport.MOD_ID, BlockReleaseValve.class, ItemBlockHolder.class); - RecipeLoader.blockTank = CoreRegistry.createNewBlock("FMBlockTank", ResonantInductionTransport.MOD_ID, BlockTank.class, ItemBlockPipe.class); + RecipeLoader.blockRejector = CoreRegistry.createNewBlock("Rejector", ResonantInductionTransport.MOD_ID, BlockRejector.class); + RecipeLoader.blockEncoder = CoreRegistry.createNewBlock("Encoder", ResonantInductionTransport.MOD_ID, BlockEncoder.class); + RecipeLoader.blockArmbot = CoreRegistry.createNewBlock("Armbot", ResonantInductionTransport.MOD_ID, BlockArmbot.class); + RecipeLoader.blockTurntable = CoreRegistry.createNewBlock("Turntable", ResonantInductionTransport.MOD_ID, BlockTurntable.class); + RecipeLoader.processorMachine = CoreRegistry.createNewBlock("ALBlockProcessor", ResonantInductionTransport.MOD_ID, BlockProcessor.class, ItemBlockHolder.class); - RecipeLoader.blockSink = CoreRegistry.createNewBlock("FMBlockSink", ResonantInductionTransport.MOD_ID, BlockKitchenSink.class, ItemBlockHolder.class); - RecipeLoader.blockDrain = CoreRegistry.createNewBlock("FMBlockDrain", ResonantInductionTransport.MOD_ID, BlockDrain.class, ItemBlockHolder.class); - RecipeLoader.blockConPump = CoreRegistry.createNewBlock("FMBlockConstructionPump", ResonantInductionTransport.MOD_ID, BlockConstructionPump.class, ItemBlockHolder.class); - RecipeLoader.blockSteamGen = CoreRegistry.createNewBlock("DMBlockSteamMachine", ResonantInductionTransport.MOD_ID, BlockSmallSteamGen.class, ItemBlockHolder.class); - RecipeLoader.blockOre = CoreRegistry.createNewBlock("DMBlockOre", ResonantInductionTransport.MOD_ID, BlockOre.class, ItemBlockOre.class); + RecipeLoader.blockAdvancedHopper = CoreRegistry.createNewBlock("ALBlockHopper", ResonantInductionTransport.MOD_ID, BlockAdvancedHopper.class, ItemBlockHolder.class); + RecipeLoader.blockPipe = CoreRegistry.createNewBlock("FMBlockPipe", ResonantInductionTransport.MOD_ID, BlockPipe.class, ItemBlockPipe.class); + RecipeLoader.blockPumpMachine = CoreRegistry.createNewBlock("FMBlockPump", ResonantInductionTransport.MOD_ID, BlockPumpMachine.class, ItemBlockHolder.class); + RecipeLoader.blockReleaseValve = CoreRegistry.createNewBlock("FMBlockReleaseValve", ResonantInductionTransport.MOD_ID, BlockReleaseValve.class, ItemBlockHolder.class); + RecipeLoader.blockTank = CoreRegistry.createNewBlock("FMBlockTank", ResonantInductionTransport.MOD_ID, BlockTank.class, ItemBlockPipe.class); - RecipeLoader.blockWire = CoreRegistry.createNewBlock("DMBlockWire", ResonantInductionTransport.MOD_ID, BlockWire.class, ItemBlockWire.class); - RecipeLoader.blockDebug = CoreRegistry.createNewBlock("DMBlockDebug", ResonantInductionTransport.MOD_ID, BlockDebug.class, ItemBlockHolder.class); - RecipeLoader.blockStainGlass = CoreRegistry.createNewBlock("DMBlockStainedGlass", ResonantInductionTransport.MOD_ID, BlockColorGlass.class, ItemBlockColored.class); - RecipeLoader.blockColorSand = CoreRegistry.createNewBlock("DMBlockColorSand", ResonantInductionTransport.MOD_ID, BlockColorSand.class, ItemBlockColored.class); - RecipeLoader.blockBasalt = CoreRegistry.createNewBlock("DMBlockBasalt", ResonantInductionTransport.MOD_ID, BlockBasalt.class, ItemBlockColored.class); + RecipeLoader.blockSink = CoreRegistry.createNewBlock("FMBlockSink", ResonantInductionTransport.MOD_ID, BlockKitchenSink.class, ItemBlockHolder.class); + RecipeLoader.blockDrain = CoreRegistry.createNewBlock("FMBlockDrain", ResonantInductionTransport.MOD_ID, BlockDrain.class, ItemBlockHolder.class); + RecipeLoader.blockConPump = CoreRegistry.createNewBlock("FMBlockConstructionPump", ResonantInductionTransport.MOD_ID, BlockConstructionPump.class, ItemBlockHolder.class); + RecipeLoader.blockSteamGen = CoreRegistry.createNewBlock("DMBlockSteamMachine", ResonantInductionTransport.MOD_ID, BlockSmallSteamGen.class, ItemBlockHolder.class); + RecipeLoader.blockOre = CoreRegistry.createNewBlock("DMBlockOre", ResonantInductionTransport.MOD_ID, BlockOre.class, ItemBlockOre.class); - RecipeLoader.blockGlowGlass = CoreRegistry.createNewBlock("DMBlockGlowGlass", ResonantInductionTransport.MOD_ID, BlockColorGlowGlass.class, ItemBlockColored.class); - RecipeLoader.blockSolar = CoreRegistry.createNewBlock("DMBlockSolar", ResonantInductionTransport.MOD_ID, BlockSolarPanel.class, ItemBlockHolder.class); - RecipeLoader.blockGas = CoreRegistry.createNewBlock("DMBlockGas", ResonantInductionTransport.MOD_ID, BlockGasOre.class, ItemBlockHolder.class); - RecipeLoader.blockBatBox = CoreRegistry.createNewBlock("DMBlockBatBox", ResonantInductionTransport.MOD_ID, BlockEnergyStorage.class, ItemBlockEnergyStorage.class); + RecipeLoader.blockWire = CoreRegistry.createNewBlock("DMBlockWire", ResonantInductionTransport.MOD_ID, BlockWire.class, ItemBlockWire.class); + RecipeLoader.blockDebug = CoreRegistry.createNewBlock("DMBlockDebug", ResonantInductionTransport.MOD_ID, BlockDebug.class, ItemBlockHolder.class); + RecipeLoader.blockStainGlass = CoreRegistry.createNewBlock("DMBlockStainedGlass", ResonantInductionTransport.MOD_ID, BlockColorGlass.class, ItemBlockColored.class); + RecipeLoader.blockColorSand = CoreRegistry.createNewBlock("DMBlockColorSand", ResonantInductionTransport.MOD_ID, BlockColorSand.class, ItemBlockColored.class); + RecipeLoader.blockBasalt = CoreRegistry.createNewBlock("DMBlockBasalt", ResonantInductionTransport.MOD_ID, BlockBasalt.class, ItemBlockColored.class); - /* ITEMS */ - RecipeLoader.itemTool = CoreRegistry.createNewItem("DMReadoutTools", ResonantInductionTransport.MOD_ID, ItemReadoutTools.class, true); - RecipeLoader.battery = CoreRegistry.createNewItem("DMItemBattery", ResonantInductionTransport.MOD_ID, ItemBattery.class, true); - RecipeLoader.wrench = CoreRegistry.createNewItem("DMWrench", ResonantInductionTransport.MOD_ID, ItemWrench.class, true); - RecipeLoader.itemGlowingSand = CoreRegistry.createNewItem("DMItemGlowingSand", ResonantInductionTransport.MOD_ID, ItemColoredDust.class, true); - RecipeLoader.itemDiggingTool = CoreRegistry.createNewItem("ItemDiggingTools", ResonantInductionTransport.MOD_ID, ItemCommonTool.class, true); + RecipeLoader.blockGlowGlass = CoreRegistry.createNewBlock("DMBlockGlowGlass", ResonantInductionTransport.MOD_ID, BlockColorGlowGlass.class, ItemBlockColored.class); + RecipeLoader.blockSolar = CoreRegistry.createNewBlock("DMBlockSolar", ResonantInductionTransport.MOD_ID, BlockSolarPanel.class, ItemBlockHolder.class); + RecipeLoader.blockGas = CoreRegistry.createNewBlock("DMBlockGas", ResonantInductionTransport.MOD_ID, BlockGasOre.class, ItemBlockHolder.class); + RecipeLoader.blockBatBox = CoreRegistry.createNewBlock("DMBlockBatBox", ResonantInductionTransport.MOD_ID, BlockEnergyStorage.class, ItemBlockEnergyStorage.class); - RecipeLoader.itemVehicleTest = CoreRegistry.createNewItem("ItemVehicleTest", ResonantInductionTransport.MOD_ID, ItemVehicleSpawn.class, true); - RecipeLoader.itemImprint = new ItemImprinter(CONFIGURATION.getItem("Imprint", DarkCore.getNextItemId()).getInt()); - RecipeLoader.itemDisk = new ItemDisk(CONFIGURATION.getItem("Disk", DarkCore.getNextItemId()).getInt()); - RecipeLoader.itemFluidCan = CoreRegistry.createNewItem("ItemFluidCan", ResonantInductionTransport.MOD_ID, ItemFluidCan.class, true); - RecipeLoader.itemParts = CoreRegistry.createNewItem("DMCraftingParts", ResonantInductionTransport.MOD_ID, ItemParts.class, true); + /* ITEMS */ + RecipeLoader.itemTool = CoreRegistry.createNewItem("DMReadoutTools", ResonantInductionTransport.MOD_ID, ItemReadoutTools.class, true); + RecipeLoader.battery = CoreRegistry.createNewItem("DMItemBattery", ResonantInductionTransport.MOD_ID, ItemBattery.class, true); + RecipeLoader.wrench = CoreRegistry.createNewItem("DMWrench", ResonantInductionTransport.MOD_ID, ItemWrench.class, true); + RecipeLoader.itemGlowingSand = CoreRegistry.createNewItem("DMItemGlowingSand", ResonantInductionTransport.MOD_ID, ItemColoredDust.class, true); + RecipeLoader.itemDiggingTool = CoreRegistry.createNewItem("ItemDiggingTools", ResonantInductionTransport.MOD_ID, ItemCommonTool.class, true); - RecipeLoader.itemMetals = CoreRegistry.createNewItem("DMOreDirvParts", ResonantInductionTransport.MOD_ID, ItemOreDirv.class, true); - //ALRecipeLoader.itemMPWire = CoreRegistry.createNewItem("DMMPWire", AssemblyLine.MOD_ID, ItemWire.class, true); + RecipeLoader.itemVehicleTest = CoreRegistry.createNewItem("ItemVehicleTest", ResonantInductionTransport.MOD_ID, ItemVehicleSpawn.class, true); + RecipeLoader.itemImprint = new ItemImprinter(CONFIGURATION.getItem("Imprint", DarkCore.getNextItemId()).getInt()); + RecipeLoader.itemDisk = new ItemDisk(CONFIGURATION.getItem("Disk", DarkCore.getNextItemId()).getInt()); + RecipeLoader.itemFluidCan = CoreRegistry.createNewItem("ItemFluidCan", ResonantInductionTransport.MOD_ID, ItemFluidCan.class, true); + RecipeLoader.itemParts = CoreRegistry.createNewItem("DMCraftingParts", ResonantInductionTransport.MOD_ID, ItemParts.class, true); - TileEntityAssembly.refresh_diff = CONFIGURATION.get("TileSettings", "RefreshRandomRange", 9, "n = value of config, 1 + n, random number range from 1 to n that will be added to the lowest refresh value").getInt(); - TileEntityAssembly.refresh_min_rate = CONFIGURATION.get("TileSettings", "RefreshLowestValue", 20, "Lowest value the refresh rate of the tile network will be").getInt(); + RecipeLoader.itemMetals = CoreRegistry.createNewItem("DMOreDirvParts", ResonantInductionTransport.MOD_ID, ItemOreDirv.class, true); + // ALRecipeLoader.itemMPWire = CoreRegistry.createNewItem("DMMPWire", AssemblyLine.MOD_ID, + // ItemWire.class, true); - //Entities - if (ResonantInductionTransport.CONFIGURATION.get("Override", "Eggs", true).getBoolean(true)) - { - Item.itemsList[Item.egg.itemID] = null; - Item.egg = null; - Item.egg = new ItemFarmEgg(88); - GameRegistry.registerItem(Item.egg, "FTEgg", MOD_ID); - EntityRegistry.registerGlobalEntityID(EntityFarmEgg.class, "FarmEgg", EntityRegistry.findGlobalUniqueEntityId()); - EntityRegistry.registerModEntity(EntityFarmEgg.class, "FarmEgg", entitiesIds++, this, 64, 1, true); - BlockDispenser.dispenseBehaviorRegistry.putObject(Item.egg, new BehaviorDispenseEgg()); - } + TileEntityAssembly.refresh_diff = CONFIGURATION.get("TileSettings", "RefreshRandomRange", 9, "n = value of config, 1 + n, random number range from 1 to n that will be added to the lowest refresh value").getInt(); + TileEntityAssembly.refresh_min_rate = CONFIGURATION.get("TileSettings", "RefreshLowestValue", 20, "Lowest value the refresh rate of the tile network will be").getInt(); - EntityRegistry.registerGlobalEntityID(EntityTestCar.class, "TestCar", EntityRegistry.findGlobalUniqueEntityId()); - EntityRegistry.registerModEntity(EntityTestCar.class, "TestCar", 60, this, 64, 1, true); + // Entities + if (ResonantInductionTransport.CONFIGURATION.get("Override", "Eggs", true).getBoolean(true)) + { + Item.itemsList[Item.egg.itemID] = null; + Item.egg = null; + Item.egg = new ItemFarmEgg(88); + GameRegistry.registerItem(Item.egg, "FTEgg", MOD_ID); + EntityRegistry.registerGlobalEntityID(EntityFarmEgg.class, "FarmEgg", EntityRegistry.findGlobalUniqueEntityId()); + EntityRegistry.registerModEntity(EntityFarmEgg.class, "FarmEgg", entitiesIds++, this, 64, 1, true); + BlockDispenser.dispenseBehaviorRegistry.putObject(Item.egg, new BehaviorDispenseEgg()); + } - for (EnumBird bird : EnumBird.values()) - { - if (bird != EnumBird.VANILLA_CHICKEN && CONFIGURATION.get("Entities", "Enable_" + bird.name(), true).getBoolean(true)) - { - bird.register(); - } - } - //Post object creation, normally creative tab icon setup - if (RecipeLoader.blockPipe != null) - { - ResonantInductionTabs.tabHydraulic().setIconItemStack(FluidPartsMaterial.IRON.getStack()); - } - else - { - ResonantInductionTabs.tabHydraulic().setIconItemStack(new ItemStack(Item.bucketWater)); - } - if (RecipeLoader.itemMetals != null) - { - ResonantInductionTabs.tabIndustrial().itemStack = EnumMaterial.getStack(RecipeLoader.itemMetals, EnumMaterial.IRON, EnumOrePart.GEARS, 1); - RecipeLoader.parseOreNames(CONFIGURATION); - } - else - { + EntityRegistry.registerGlobalEntityID(EntityTestCar.class, "TestCar", EntityRegistry.findGlobalUniqueEntityId()); + EntityRegistry.registerModEntity(EntityTestCar.class, "TestCar", 60, this, 64, 1, true); - } - if (RecipeLoader.blockConveyorBelt != null) - { - ResonantInductionTabs.tabAutomation().setIconItemStack(new ItemStack(RecipeLoader.blockConveyorBelt)); - } - else - { - ResonantInductionTabs.tabAutomation().setIconItemStack(new ItemStack(Block.pistonStickyBase)); - } + for (EnumBird bird : EnumBird.values()) + { + if (bird != EnumBird.VANILLA_CHICKEN && CONFIGURATION.get("Entities", "Enable_" + bird.name(), true).getBoolean(true)) + { + bird.register(); + } + } + // Post object creation, normally creative tab icon setup + if (RecipeLoader.blockPipe != null) + { + ResonantInductionTabs.tabHydraulic().setIconItemStack(FluidPartsMaterial.IRON.getStack()); + } + else + { + ResonantInductionTabs.tabHydraulic().setIconItemStack(new ItemStack(Item.bucketWater)); + } + if (RecipeLoader.itemMetals != null) + { + ResonantInductionTabs.tabIndustrial().itemStack = EnumMaterial.getStack(RecipeLoader.itemMetals, EnumMaterial.IRON, EnumOrePart.GEARS, 1); + RecipeLoader.parseOreNames(CONFIGURATION); + } + else + { - } + } + if (RecipeLoader.blockConveyorBelt != null) + { + ResonantInductionTabs.tabAutomation().setIconItemStack(new ItemStack(RecipeLoader.blockConveyorBelt)); + } + else + { + ResonantInductionTabs.tabAutomation().setIconItemStack(new ItemStack(Block.pistonStickyBase)); + } - public void loadModMeta() - { - meta.modId = ResonantInductionTransport.MOD_ID; - meta.name = ResonantInductionTransport.MOD_NAME; - meta.version = ResonantInductionTransport.VERSION; - meta.description = "Simi Realistic factory system for minecraft bring in conveyor belts, robotic arms, and simple machines"; - meta.url = "http://www.universalelectricity.com/coremachine"; - meta.logoFile = "/al_logo.png"; + } - meta.authorList = Arrays.asList(new String[] { "DarkGuardsman" }); - meta.credits = "Archadia - Developer" + "LiQuiD - Dev of BioTech\n" + "Hangcow - Ex-Dev Greater Security\n" + "Calclavia - Ex-CoDev of assembly line\n" + "Briman0094 - Ex-CoDev of assembly line\n" + "Elrath18 - Colored Glass, Sand, & Stone\n" + "Doppelgangerous - Researcher\n" + "Freesound.org - Sound effects\n" + "MineMan1(wdtod) - asset creation\n" + "AlphaToOmega - asset creation\n" + "pinksheep - asset creation\n" + "X-wing9 - asset creation\n" + "Azkhare - asset creation\n" + "Vexatos - German Translation\n" + "crafteverywhere - Chinese Translations\n" + "PancakeCandy - French & Dutch Translations\n"; - meta.autogenerated = false; + public void loadModMeta() + { + meta.modId = ResonantInductionTransport.MOD_ID; + meta.name = ResonantInductionTransport.MOD_NAME; + meta.version = ResonantInductionTransport.VERSION; + meta.description = "Simi Realistic factory system for minecraft bring in conveyor belts, robotic arms, and simple machines"; + meta.url = "http://www.universalelectricity.com/coremachine"; + meta.logoFile = "/al_logo.png"; - } + meta.authorList = Arrays.asList(new String[] { "DarkGuardsman" }); + meta.credits = "Archadia - Developer" + "LiQuiD - Dev of BioTech\n" + "Hangcow - Ex-Dev Greater Security\n" + "Calclavia - Ex-CoDev of assembly line\n" + "Briman0094 - Ex-CoDev of assembly line\n" + "Elrath18 - Colored Glass, Sand, & Stone\n" + "Doppelgangerous - Researcher\n" + "Freesound.org - Sound effects\n" + "MineMan1(wdtod) - asset creation\n" + "AlphaToOmega - asset creation\n" + "pinksheep - asset creation\n" + "X-wing9 - asset creation\n" + "Azkhare - asset creation\n" + "Vexatos - German Translation\n" + "crafteverywhere - Chinese Translations\n" + "PancakeCandy - French & Dutch Translations\n"; + meta.autogenerated = false; + + } } diff --git a/src/main/java/resonantinduction/transport/levitator/BlockLevitator.java b/src/main/java/resonantinduction/transport/levitator/BlockLevitator.java index 0ece8ba20..043bd68e2 100644 --- a/src/main/java/resonantinduction/transport/levitator/BlockLevitator.java +++ b/src/main/java/resonantinduction/transport/levitator/BlockLevitator.java @@ -7,7 +7,7 @@ import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; -import resonantinduction.core.ResonantInduction; +import resonantinduction.Reference; import resonantinduction.core.base.BlockBase; import resonantinduction.core.render.BlockRenderingHandler; import cpw.mods.fml.relauncher.Side; @@ -18,7 +18,7 @@ public class BlockLevitator extends BlockBase implements ITileEntityProvider public BlockLevitator(int id) { super("levitator", id); - this.setTextureName(ResonantInduction.PREFIX + "machine"); + this.setTextureName(Reference.PREFIX + "machine"); } @SideOnly(Side.CLIENT) diff --git a/src/main/java/resonantinduction/transport/levitator/RenderLevitator.java b/src/main/java/resonantinduction/transport/levitator/RenderLevitator.java index d0fd64e5a..417378494 100644 --- a/src/main/java/resonantinduction/transport/levitator/RenderLevitator.java +++ b/src/main/java/resonantinduction/transport/levitator/RenderLevitator.java @@ -6,6 +6,7 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; +import resonantinduction.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.energy.model.ModelEMContractor; @@ -13,8 +14,8 @@ public class RenderLevitator extends TileEntitySpecialRenderer { public static final ModelEMContractor MODEL = new ModelEMContractor(false); public static final ModelEMContractor MODEL_SPIN = new ModelEMContractor(true); - public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "em_contractor.png"); - public static final ResourceLocation TEXTURE_PUSH = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "em_contractor_push.png"); + public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_TEXTURE_DIRECTORY + "em_contractor.png"); + public static final ResourceLocation TEXTURE_PUSH = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_TEXTURE_DIRECTORY + "em_contractor_push.png"); @Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)