diff options
Diffstat (limited to 'src/Java/miscutil')
56 files changed, 3859 insertions, 0 deletions
diff --git a/src/Java/miscutil/MiscUtils.java b/src/Java/miscutil/MiscUtils.java new file mode 100644 index 0000000000..518d570d67 --- /dev/null +++ b/src/Java/miscutil/MiscUtils.java @@ -0,0 +1,118 @@ +package miscutil; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import miscutil.core.CommonProxy; +import miscutil.core.commands.CommandMath; +import miscutil.core.creativetabs.TMCreativeTabs; +import miscutil.core.handler.CraftingManager; +import miscutil.core.lib.Strings; +import miscutil.core.util.Utils; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +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.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.FMLServerStoppingEvent; + +@Mod(modid=Strings.MODID, name="Misc. Utils", version=Strings.VERSION, dependencies="required-after:gregtech") +public class MiscUtils +implements ActionListener +{ + + //Vars + + + @Mod.Instance(Strings.MODID) + public static MiscUtils instance; + + @SidedProxy(clientSide="miscutil.core.proxy.ClientProxy", serverSide="miscutil.core.proxy.ServerProxy") + public static CommonProxy proxy; + + + //Pre-Init + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent event) + { + + Utils.LOG_INFO("Doing some house cleaning."); + TMCreativeTabs.initialiseTabs(); + //TMEntity.mainRegistry(); + CraftingManager.mainRegistry(); + //TMWorld.mainRegistry(); + //TMHooks.mainRegistry(); + proxy.registerTileEntities(); + proxy.registerRenderThings(); + proxy.preInit(event); + + + + } + + //Init + @Mod.EventHandler + public void init(FMLInitializationEvent event) + { + /* Utils.LOG_INFO("Double checking floating point precision."); + try { + Thread.sleep(100); + Benchmark GammeRayBurst = new Benchmark(); + GammeRayBurst.math(); + } catch (InterruptedException | ParseException | NumberFormatException | UnknownFormatConversionException | MissingFormatArgumentException e) { + if (Strings.DEBUG){ + e.printStackTrace(); + Utils.LOG_INFO("Math went wrong somewhere."); + } + ; + }*/ + proxy.init(event); + /*if (Strings.DEBUG){ + Benchmark GammeRayBurst = new Benchmark(); + String Insight = GammeRayBurst.superhash("This is Absolution"); + FMLLog.info(Insight); + Utils.LOG_INFO("Math is ok."); + }*/ + + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + proxy.registerNetworkStuff(); + } + + //Post-Init + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent event) { + Utils.LOG_INFO("Tidying things up."); + proxy.postInit(event); + } + + @EventHandler + public void serverStarting(FMLServerStartingEvent event) + { + + event.registerServerCommand(new CommandMath()); + + //while (Strings.DEBUG){ + //Thread.setDefaultUncaughtExceptionHandler(null); + //} + + } + + @Mod.EventHandler + public void serverStopping(FMLServerStoppingEvent event) + { + + + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/Java/miscutil/core/CommonProxy.java b/src/Java/miscutil/core/CommonProxy.java new file mode 100644 index 0000000000..8b0f6c8b2a --- /dev/null +++ b/src/Java/miscutil/core/CommonProxy.java @@ -0,0 +1,70 @@ +package miscutil.core; + +import miscutil.core.block.ModBlocks; +import miscutil.core.gui.ModGUI; +import miscutil.core.item.ModItems; +import miscutil.core.lib.Strings; +import miscutil.core.tileentities.ModTileEntities; +import miscutil.core.util.Utils; +import miscutil.gregtech.init.InitGregtech; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class CommonProxy { + + public void preInit(FMLPreInitializationEvent e) { + ModItems.init(); + ModBlocks.init(); + + + //Register Gregtech related items + if (Loader.isModLoaded("gregtech") == true) { + Utils.LOG_INFO("Gregtech Found - Loading Resources."); + Strings.GREGTECH = true; + Utils.LOG_INFO("Begining registration & initialization of Gregtech related content."); + // Init Gregtech + InitGregtech.run(); + + } + else { + Utils.LOG_WARNING("Gregtech not Found - Skipping Resources."); + Strings.GREGTECH = false; + } + + } + + public void init(FMLInitializationEvent e) { + + + + } + + public void postInit(FMLPostInitializationEvent e) { + + } + + public void registerNetworkStuff(){ + ModGUI.init(); + //NetworkRegistry.INSTANCE.registerGuiHandler(MiscUtils.instance, new BloodSteelFurnaceGuiHandler()); + + } + + public void registerTileEntities(){ + ModTileEntities.init(); + //GameRegistry.registerTileEntity(TileEntityBloodSteelChest.class, "tileEntityBloodSteelChest"); + //GameRegistry.registerTileEntity(TileEntityBloodSteelFurnace.class, "tileEntityBloodSteelFurnace"); + //GameRegistry.registerTileEntity(TileEntityBloodSteelChest.class, Strings.MODID); + //GameRegistry.registerTileEntity(TileEntityArcaneInfuser.class, "TileEntityArcaneInfuser"); + } + + public void registerRenderThings() { + + } + + public int addArmor(String armor) { + return 0; + } + +} diff --git a/src/Java/miscutil/core/block/AdvancedBlock.java b/src/Java/miscutil/core/block/AdvancedBlock.java new file mode 100644 index 0000000000..2a81341838 --- /dev/null +++ b/src/Java/miscutil/core/block/AdvancedBlock.java @@ -0,0 +1,31 @@ +package miscutil.core.block; + +import miscutil.core.lib.Strings; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class AdvancedBlock extends Block { + + protected AdvancedBlock(String unlocalizedName, Material material, CreativeTabs x, float blockHardness, float blockResistance, float blockLightLevel, + String blockHarvestTool, int blockHarvestLevel, SoundType BlockSound) { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(Strings.MODID + ":" + unlocalizedName); + this.setCreativeTab(x); + this.setHardness(blockHardness); //block Hardness + this.setResistance(blockResistance); + this.setLightLevel(blockLightLevel); + this.setHarvestLevel(blockHarvestTool, blockHarvestLevel); + this.setStepSound(BlockSound); + } + + @Override + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + return false; + } + +} diff --git a/src/Java/miscutil/core/block/BasicBlock.java b/src/Java/miscutil/core/block/BasicBlock.java new file mode 100644 index 0000000000..63c1044b03 --- /dev/null +++ b/src/Java/miscutil/core/block/BasicBlock.java @@ -0,0 +1,22 @@ +package miscutil.core.block; + +import miscutil.core.creativetabs.TMCreativeTabs; +import miscutil.core.lib.Strings; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; + +public class BasicBlock extends Block { + + protected BasicBlock(String unlocalizedName, Material material) { + super(material); + this.setBlockName(unlocalizedName); + this.setBlockTextureName(Strings.MODID + ":" + unlocalizedName); + this.setCreativeTab(TMCreativeTabs.tabBlock); + this.setHardness(2.0F); + this.setResistance(6.0F); + this.setLightLevel(0.0F); + this.setHarvestLevel("pickaxe", 2); + this.setStepSound(soundTypeMetal); + } + +} diff --git a/src/Java/miscutil/core/block/ModBlocks.java b/src/Java/miscutil/core/block/ModBlocks.java new file mode 100644 index 0000000000..7f1df843be --- /dev/null +++ b/src/Java/miscutil/core/block/ModBlocks.java @@ -0,0 +1,90 @@ +package miscutil.core.block; + +import miscutil.core.util.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import cpw.mods.fml.common.registry.GameRegistry; + +public final class ModBlocks { + + //Blood Steel + public static Block blockBloodSteel; + public static Block blockStaballoy; + public static Block blockToolBuilder; + //public static Block blockBloodSteelChest; + + //BloodSteelorial Furnace + //public static Block tutFurnace; + //public static Block tutFurnaceActive; + + //BloodSteelorial Chest + //public static Block tutChest; + + //Arcane Infuser + //public static Block arcaneInfuser; + //public static Block arcaneInfuserActive; + + //Block Storage + //public static Block emxBlockStorage; + + + public static void init() { + Utils.LOG_INFO("Initializing Blocks."); + //BloodSteelorial Furnace - Must Init blocks first as they're not static. + /** if (Strings.DEBUG){ + FMLLog.info("Loading Furnace.");} + tutFurnace= new BloodSteelFurnace(false).setBlockName("BloodSteelFurnace").setCreativeTab(TMCreativeTabs.tabBlock); + tutFurnaceActive= new BloodSteelFurnace(true).setBlockName("BloodSteelFurnaceActive"); + + //Arcane Infuser - Must Init blocks first as they're not static. + if (Strings.DEBUG){ + FMLLog.info("Loading Arcane Infuser.");} + arcaneInfuser = new ArcaneInfuser(false).setBlockName("ArcaneInfuser").setCreativeTab(TMCreativeTabs.tabBlock); + arcaneInfuserActive = new ArcaneInfuser(true).setBlockName("ArcaneInfuserActive"); + + //Blood Steel Chest + if (Strings.DEBUG){ + FMLLog.info("Loading Blood Steel Chest.");} + tutChest = new BloodSteelChest(0).setBlockName("BloodSteelChest").setCreativeTab(TMCreativeTabs.tabBlock); + + */ + //BlockStorage + //emxBlockStorage = new BlockStorage(); + + //Register Blocks next - TODO + registerBlocks(); + } + + public static void registerBlocks(){ + + Utils.LOG_INFO("Registering Blocks."); + + //Blood Steel Block + GameRegistry.registerBlock(blockBloodSteel = new BasicBlock("blockBloodSteel", Material.iron), "blockBloodSteel"); + + //Staballoy Block + GameRegistry.registerBlock(blockStaballoy = new BasicBlock("blockStaballoy", Material.iron), "blockStaballoy"); + + //Blood Steel Block //Name, Material, Hardness, Resistance, Light level, Tool, tool level, sound + //GameRegistry.registerBlock(blockToolBuilder = new AdvancedBlock("blockToolBuilder", Material.circuits, TMCreativeTabs.tabMachines, 1F, 5F, 0F, "pickaxe", 1, Block.soundTypeWood), "blockToolBuilder"); + + /** TODO re-enable blocks when working. + + + //Blood Steel Chest + GameRegistry.registerBlock(tutChest, tutChest.getUnlocalizedName()); + + //BloodSteelorial Furnace + GameRegistry.registerBlock(tutFurnace, tutFurnace.getUnlocalizedName()); + GameRegistry.registerBlock(tutFurnaceActive, tutFurnaceActive.getUnlocalizedName()); + + //Arcane Infuser + GameRegistry.registerBlock(arcaneInfuser, arcaneInfuser.getUnlocalizedName()); + GameRegistry.registerBlock(arcaneInfuserActive, arcaneInfuserActive.getUnlocalizedName()); + **/ + + //Block Storage + //GameRegistry.registerBlock(emxBlockStorage, emxBlockStorage.getUnlocalizedName()); + } + +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/commands/CommandMath.java b/src/Java/miscutil/core/commands/CommandMath.java new file mode 100644 index 0000000000..933684d277 --- /dev/null +++ b/src/Java/miscutil/core/commands/CommandMath.java @@ -0,0 +1,195 @@ +package miscutil.core.commands; + +import java.util.ArrayList; +import java.util.List; + +import miscutil.core.util.Utils; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + + +public class CommandMath implements ICommand +{ + private final List aliases; + + protected String fullEntityName; + protected Entity conjuredEntity; + + public CommandMath() + { + aliases = new ArrayList(); + + aliases.add("hometele"); + + aliases.add("warphome"); + + } + + @Override + public int compareTo(Object o) + { + return 0; + + } + + @Override + public String getCommandName() + { + return "bed"; + + } + + @Override + public String getCommandUsage(ICommandSender var1) + { + return "/bed [Teleports you to your bed for XP]"; + + } + + @Override + public List getCommandAliases() + { + return this.aliases; + + } + + public void processCommand(ICommandSender S, String[] argString) + { + World W = S.getEntityWorld(); + CommandUtils C = new CommandUtils(); + EntityPlayer P = C.getPlayer(S); + //System.out.println(P.getCommandSenderName()); + //System.out.println(P.getDisplayName()); + if (W.isRemote) + + { + + System.out.println("Not processing on Client side"); + + } + + else + + { + + System.out.println("Processing on Server side - Home Teleport engaged by: "+P.getDisplayName()); + + int XP_TOTAL = P.experienceTotal; + Utils.LOG_WARNING("Total Xp:" + XP_TOTAL); + ChunkCoordinates X = P.getPlayerCoordinates(); + Utils.LOG_WARNING("Player Location: "+X); + ChunkCoordinates Y = null; + Utils.LOG_WARNING("Bed Location: "+Y); + if (!P.getBedLocation(0).equals(null)){ + Y = P.getBedLocation(0); + Utils.LOG_WARNING("Bed Location: "+Y); + } + else { + Y = W.getSpawnPoint(); + Utils.LOG_WARNING("Spawn Location: "+Y); + } + if (Y == null) { + Y = W.getSpawnPoint(); + Utils.LOG_WARNING("Spawn Location: "+Y); + } + + int x1 = X.posX; + Utils.LOG_WARNING("X1: "+x1); + int x2 = Y.posX; + Utils.LOG_WARNING("X2: "+x2); + int y1 = X.posY; + Utils.LOG_WARNING("Y1: "+y1); + int y2 = Y.posY; + Utils.LOG_WARNING("Y2: "+y2); + int z1 = X.posZ; + Utils.LOG_WARNING("Z1: "+z1); + int z2 = Y.posZ; + Utils.LOG_WARNING("Z2: "+z2); + + + double d = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1)); + String xpCost = String.valueOf((int)(d*0.15)); + + Utils.LOG_WARNING("d:" + d); + Utils.LOG_WARNING("-----------------------------------------"); + Utils.LOG_WARNING("Actual math formulae"); + Utils.LOG_WARNING(String.valueOf(d)); + Utils.LOG_WARNING("-----------------------------------------"); + Utils.LOG_WARNING("Xp Cost based on answer B."); + Utils.LOG_WARNING(String.valueOf(d*0.15) + " | " + String.valueOf(xpCost)); + Utils.LOG_WARNING("-----------------------------------------"); + Utils.LOG_WARNING("Xp Total"); + Utils.LOG_WARNING(String.valueOf(XP_TOTAL)); + Utils.LOG_WARNING("-----------------------------------------"); + + + + if ((XP_TOTAL-Float.valueOf(xpCost)) > 0){ + EntityXPOrb E = new EntityXPOrb(W, P.posX, P.posY + 1.62D - (double) P.yOffset, P.posZ, 1); + //E.moveTowards((double) Y.posX + 0.5D, (int) Y.posY + 3, (double) Y.posZ + 0.5D); + E.setVelocity((double) Y.posX + 0.5D, (int) Y.posY + 0.1, (double) Y.posZ + 0.5D); + W.spawnEntityInWorld(E); + W.playAuxSFXAtEntity((EntityPlayer) null, 1002, (int) P.posX, (int) P.posY, (int) P.posZ, 0); + P.setPositionAndUpdate(x2, y2+1, z2); + + //gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Movement | X:"+x2+" | Y:"+y2+" | Z:"+z2); + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Distance Traveled | "+String.valueOf((int)(d)) + " Blocks & " + xpCost + "xp"); + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You suddenly feel at home."); + P.experienceTotal = (int) (XP_TOTAL-Float.valueOf(xpCost)); + if (!xpCost.equals("0") && Float.valueOf(xpCost) > 0){ + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "...At the loss of "+xpCost+" xp."); + } + else if (xpCost.equals("0")){ + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "...At the loss of very little xp."); + } + else { + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "Something went wrong with the math, have this one on the house. :)"); + } + } + + else { + gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You don't feel you're able to do this yet."); + } + + } + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender var1) + { + return true; + + } + + @Override + public List addTabCompletionOptions(ICommandSender var1, String[] var2) + { + // TODO Auto-generated method stub + + return null; + + } + + @Override + public boolean isUsernameIndex(String[] var1, int var2) + { + // TODO Auto-generated method stub + + return false; + + } + + public boolean playerUsesCommand(World W, EntityPlayer P, int cost) + { + + + return true; + } + +} + diff --git a/src/Java/miscutil/core/commands/CommandUtils.java b/src/Java/miscutil/core/commands/CommandUtils.java new file mode 100644 index 0000000000..f33263fa40 --- /dev/null +++ b/src/Java/miscutil/core/commands/CommandUtils.java @@ -0,0 +1,20 @@ +package miscutil.core.commands; + +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; + +public class CommandUtils { + + public EntityPlayer getPlayer(ICommandSender icommandsender){ + EntityPlayer player; + + if(icommandsender instanceof EntityPlayer){ + player = (EntityPlayer)icommandsender; + return player; + } + else { + return null; + } + } + +} diff --git a/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabBlock.java b/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabBlock.java new file mode 100644 index 0000000000..2db845e04c --- /dev/null +++ b/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabBlock.java @@ -0,0 +1,18 @@ +package miscutil.core.creativetabs; + +import miscutil.core.block.ModBlocks; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabBlock extends CreativeTabs { + + public MiscUtilCreativeTabBlock(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return Item.getItemFromBlock(ModBlocks.blockBloodSteel); + } + +} diff --git a/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabMachines.java b/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabMachines.java new file mode 100644 index 0000000000..620648d6c0 --- /dev/null +++ b/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabMachines.java @@ -0,0 +1,18 @@ +package miscutil.core.creativetabs; + +import miscutil.core.block.ModBlocks; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabMachines extends CreativeTabs { + + public MiscUtilCreativeTabMachines(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return Item.getItemFromBlock(ModBlocks.blockToolBuilder); + } + +} diff --git a/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabMisc.java b/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabMisc.java new file mode 100644 index 0000000000..2893146f93 --- /dev/null +++ b/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabMisc.java @@ -0,0 +1,18 @@ +package miscutil.core.creativetabs; + +import miscutil.core.item.ModItems; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabMisc extends CreativeTabs { + + public MiscUtilCreativeTabMisc(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ModItems.itemIngotBloodSteel; + } + +} diff --git a/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabTools.java b/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabTools.java new file mode 100644 index 0000000000..aa7cf227aa --- /dev/null +++ b/src/Java/miscutil/core/creativetabs/MiscUtilCreativeTabTools.java @@ -0,0 +1,18 @@ +package miscutil.core.creativetabs; + +import miscutil.core.item.ModItems; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class MiscUtilCreativeTabTools extends CreativeTabs { + + public MiscUtilCreativeTabTools(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ModItems.itemStaballoyPickaxe; + } + +} diff --git a/src/Java/miscutil/core/creativetabs/TMCreativeTabs.java b/src/Java/miscutil/core/creativetabs/TMCreativeTabs.java new file mode 100644 index 0000000000..05d170d6e1 --- /dev/null +++ b/src/Java/miscutil/core/creativetabs/TMCreativeTabs.java @@ -0,0 +1,20 @@ +package miscutil.core.creativetabs; + +import net.minecraft.creativetab.CreativeTabs; + +public class TMCreativeTabs { + + public static CreativeTabs tabBlock; + public static CreativeTabs tabMisc; + public static CreativeTabs tabCombat; + public static CreativeTabs tabTools; + public static CreativeTabs tabMachines; + + public static void initialiseTabs(){ + tabBlock = new MiscUtilCreativeTabBlock("MiscUtilBlockTab"); + tabMisc = new MiscUtilCreativeTabMisc("MiscUtilMiscTab"); + //tabMachines = new MiscUtilCreativeTabMachines("MiscUtilMachineTab"); + //tabCombat = new MiscUtilCreativeTabCombat("MiscUtilCombatTab"); + tabTools = new MiscUtilCreativeTabTools("MiscUtilToolsTab"); + } +} diff --git a/src/Java/miscutil/core/gui/GUI_Bat_Buf.java b/src/Java/miscutil/core/gui/GUI_Bat_Buf.java new file mode 100644 index 0000000000..efe42c7257 --- /dev/null +++ b/src/Java/miscutil/core/gui/GUI_Bat_Buf.java @@ -0,0 +1,247 @@ +package miscutil.core.gui; + +import miscutil.core.lib.Strings; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + + + +public class GUI_Bat_Buf extends GuiScreen +{ + private final int bookImageHeight = 192; + private final int bookImageWidth = 192; + private int currPage = 0; + private static final int bookTotalPages = 4; + private static ResourceLocation[] bookPageTextures = + + new ResourceLocation[bookTotalPages]; + private static String[] stringPageText = new String[bookTotalPages]; + private GuiButton buttonDone; + private NextPageButton buttonNextPage; + private NextPageButton buttonPreviousPage; + + public GUI_Bat_Buf() + { + + bookPageTextures[0] = new ResourceLocation( + + Strings.MODID+":textures/gui/book_cover.png"); + + bookPageTextures[1] = new ResourceLocation( + + Strings.MODID+":textures/gui/book.png"); + + bookPageTextures[2] = new ResourceLocation( + + Strings.MODID+":textures/gui/book.png"); + + stringPageText[0] = ""; + + stringPageText[1] = "The Mysterious Stranger admired your family cow and asked if it was for sale.\n\nWhen you nodded, he offered to trade some Magic Beans, that (if planted in tilled dirt) would lead to more wealth than you could imagine."; + + stringPageText[2]="So you handed him your cow, and grabbed the Magic Beans.\n\nPleased with yourself, you hurried away, looking for tilled dirt in which to plant the Magic Beans.\n\nYou couldn't wait to see how proud your mother would be for"; + stringPageText[3]="being so shrewd! Untold wealth in return for an old, milkless cow; what a good deal you made!\n\nSo off you went, looking for a place to plant the Magic Beans with room to grow..."; + } + + /** + * Adds the buttons (and other controls) to the screen in question. + */ + @Override + public void initGui() + { + // DEBUG + System.out.println("GuiMysteriousStranger initGUI()"); + buttonList.clear(); + Keyboard.enableRepeatEvents(true); + + buttonDone = new GuiButton(0, width / 2 + 2, 4 + bookImageHeight, + + 98, 20, I18n.format("gui.done", new Object[0])); + + buttonList.add(buttonDone); + int offsetFromScreenLeft = (width - bookImageWidth) / 2; + buttonList.add(buttonNextPage = new NextPageButton(1, + + offsetFromScreenLeft + 120, 156, true)); + buttonList.add(buttonPreviousPage = new NextPageButton(2, + + offsetFromScreenLeft + 38, 156, false)); + } + + /** + * Called from the main game loop to update the screen. + */ + @Override + public void updateScreen() + { + buttonDone.visible = (currPage == bookTotalPages - 1); + buttonNextPage.visible = (currPage < bookTotalPages - 1); + buttonPreviousPage.visible = currPage > 0; + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(int parWidth, int parHeight, float p_73863_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + if (currPage == 0) + { + mc.getTextureManager().bindTexture(bookPageTextures[0]); + } + else + { + mc.getTextureManager().bindTexture(bookPageTextures[1]); + } + int offsetFromScreenLeft = (width - bookImageWidth ) / 2; + drawTexturedModalRect(offsetFromScreenLeft, 2, 0, 0, bookImageWidth, + + bookImageHeight); + int widthOfString; + String stringPageIndicator = I18n.format("book.pageIndicator", + + new Object[] {Integer.valueOf(currPage + 1), bookTotalPages}); + + widthOfString = fontRendererObj.getStringWidth(stringPageIndicator); + fontRendererObj.drawString(stringPageIndicator, + + offsetFromScreenLeft - widthOfString + bookImageWidth - 44, + + 18, 0); + + fontRendererObj.drawSplitString(stringPageText[currPage], + + offsetFromScreenLeft + 36, 34, 116, 0); + + super.drawScreen(parWidth, parHeight, p_73863_3_); + + } + + /** + * Called when a mouse button is pressed and the mouse is moved around. + + * Parameters are : mouseX, mouseY, lastButtonClicked & + + * timeSinceMouseClick. + */ + @Override + protected void mouseClickMove(int parMouseX, int parMouseY, + + int parLastButtonClicked, long parTimeSinceMouseClick) + + { + + } + + @Override + protected void actionPerformed(GuiButton parButton) + { + if (parButton == buttonDone) + { + // You can send a packet to server here if you need server to do + + // something + mc.displayGuiScreen((GuiScreen)null); + } + else if (parButton == buttonNextPage) + { + if (currPage < bookTotalPages - 1) + { + ++currPage; + } + } + else if (parButton == buttonPreviousPage) + { + if (currPage > 0) + { + --currPage; + } + } + } + + /** + * Called when the screen is unloaded. Used to disable keyboard repeat + + * events + */ + @Override + public void onGuiClosed() + { + + } + + /** + * Returns true if this GUI should pause the game when it is displayed in + + * single-player + */ + @Override + public boolean doesGuiPauseGame() + { + return true; + } + + @SideOnly(Side.CLIENT) + static class NextPageButton extends GuiButton + { + private final boolean isNextButton; + + public NextPageButton(int parButtonId, int parPosX, int parPosY, + + boolean parIsNextButton) + { + super(parButtonId, parPosX, parPosY, 23, 13, ""); + isNextButton = parIsNextButton; + } + + /** + * Draws this button to the screen. + */ + @Override + public void drawButton(Minecraft mc, int parX, int parY) + { + if (visible) + { + boolean isButtonPressed = (parX >= xPosition + + && parY >= yPosition + + && parX < xPosition + width + + && parY < yPosition + height); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(bookPageTextures[1]); + int textureX = 0; + int textureY = 192; + + if (isButtonPressed) + { + textureX += 23; + } + + if (!isNextButton) + { + textureY += 13; + } + + drawTexturedModalRect(xPosition, yPosition, + + textureX, textureY, + + 23, 13); + } + } + } +} + diff --git a/src/Java/miscutil/core/gui/GUI_Battery_Buffer.java b/src/Java/miscutil/core/gui/GUI_Battery_Buffer.java new file mode 100644 index 0000000000..c4bdf3666b --- /dev/null +++ b/src/Java/miscutil/core/gui/GUI_Battery_Buffer.java @@ -0,0 +1,51 @@ +package miscutil.core.gui; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; + +public class GUI_Battery_Buffer extends GuiScreen { + + private GuiButton a; + private GuiButton b; + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + this.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + /* + @SuppressWarnings("unchecked") + public void initGui() { + this.buttonList.add(this.a = new GuiButton(0, this.width / 2 - 100, this.height / 2 - 24, "This is button a")); + this.buttonList.add(this.b = new GuiButton(1, this.width / 2 - 100, this.height / 2 + 4, "This is button b")); + }*/ + + /* @Override + protected void actionPerformed(GuiButton button) { + if (button == this.a) { + //Main.packetHandler.sendToServer(...); + this.mc.displayGuiScreen(null); + if (this.mc.currentScreen == null) + this.mc.setIngameFocus(); + } + if (button == this.b){ + //Main.packetHandler.sendToServer(...); + this.mc.displayGuiScreen(null); + if (this.mc.currentScreen == null) + this.mc.setIngameFocus(); + } + }*/ + /** + * if (worldIn.isRemote) { + playerIn.openGui(Main.instance, 0, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ); + } + */ + + +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/gui/GUI_Tool_Builder.java b/src/Java/miscutil/core/gui/GUI_Tool_Builder.java new file mode 100644 index 0000000000..e6a81a7d80 --- /dev/null +++ b/src/Java/miscutil/core/gui/GUI_Tool_Builder.java @@ -0,0 +1,5 @@ +package miscutil.core.gui; + +public class GUI_Tool_Builder { + +} diff --git a/src/Java/miscutil/core/gui/Gui_No_Inventory_Base.java b/src/Java/miscutil/core/gui/Gui_No_Inventory_Base.java new file mode 100644 index 0000000000..7a8f7d3e97 --- /dev/null +++ b/src/Java/miscutil/core/gui/Gui_No_Inventory_Base.java @@ -0,0 +1,51 @@ +package miscutil.core.gui; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; + +public class Gui_No_Inventory_Base extends GuiScreen { + + private GuiButton a; + private GuiButton b; + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + this.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + /* + @SuppressWarnings("unchecked") + public void initGui() { + this.buttonList.add(this.a = new GuiButton(0, this.width / 2 - 100, this.height / 2 - 24, "This is button a")); + this.buttonList.add(this.b = new GuiButton(1, this.width / 2 - 100, this.height / 2 + 4, "This is button b")); + }*/ + + /* @Override + protected void actionPerformed(GuiButton button) { + if (button == this.a) { + //Main.packetHandler.sendToServer(...); + this.mc.displayGuiScreen(null); + if (this.mc.currentScreen == null) + this.mc.setIngameFocus(); + } + if (button == this.b){ + //Main.packetHandler.sendToServer(...); + this.mc.displayGuiScreen(null); + if (this.mc.currentScreen == null) + this.mc.setIngameFocus(); + } + }*/ + /** + * if (worldIn.isRemote) { + playerIn.openGui(Main.instance, 0, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ); + } + */ + + +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/gui/ModGUI.java b/src/Java/miscutil/core/gui/ModGUI.java new file mode 100644 index 0000000000..28987ccc1b --- /dev/null +++ b/src/Java/miscutil/core/gui/ModGUI.java @@ -0,0 +1,15 @@ +package miscutil.core.gui; + +import miscutil.core.util.Utils; + +public class ModGUI { + + + public static void init(){ + + Utils.LOG_INFO("Registering GUIs."); + + //Register GuiHandler + //NetworkRegistry.INSTANCE.registerGuiHandler(MiscUtils.instance, new GuiHandler()); + } +} diff --git a/src/Java/miscutil/core/handler/CraftingManager.java b/src/Java/miscutil/core/handler/CraftingManager.java new file mode 100644 index 0000000000..42b602440d --- /dev/null +++ b/src/Java/miscutil/core/handler/CraftingManager.java @@ -0,0 +1,21 @@ +package miscutil.core.handler; + +public class CraftingManager { + + public static void mainRegistry() { + addCraftingRecipies(); + addSmeltingRecipies(); + } + + public static void addCraftingRecipies() { + // Shaped Recipie + //GameRegistry.addRecipe(new ItemStack(ModItems.tutPickaxe, 1), new Object[] { "###", " S ", " S ", '#', ModItems.tutItem, 'S', Items.stick }); + + //Shapeless Recipie + //GameRegistry.addShapelessRecipe(new ItemStack(ModItems.tutItem, 10), new Object[]{Blocks.dirt , Blocks.cobblestone}); + } + + public static void addSmeltingRecipies() { + //GameRegistry.addSmelting(ModItems.tutItem, new ItemStack(Blocks.diamond_block, 5), 20.0F); + } +} diff --git a/src/Java/miscutil/core/handler/GuiHandler.java b/src/Java/miscutil/core/handler/GuiHandler.java new file mode 100644 index 0000000000..9412ed8983 --- /dev/null +++ b/src/Java/miscutil/core/handler/GuiHandler.java @@ -0,0 +1,39 @@ +package miscutil.core.handler; + +import miscutil.core.gui.GUI_Bat_Buf; +import miscutil.core.gui.GUI_Battery_Buffer; +import miscutil.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.IGuiHandler; + +public class GuiHandler implements IGuiHandler { + + private static final int GUI1 = 0; //Nothing Yet + private static final int GUI2 = 1; //Energy Buffer + + + + @Override //ContainerModTileEntity + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + if (ID == GUI1) + return new GUI_Battery_Buffer(); + + return null; + } + + @Override //GuiModTileEntity + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + Utils.LOG_WARNING("getClientGuiElement Called by: "+player+", in world: "+player.dimension+" at x:"+x+", y:"+y+", z:"+z+"."); + if (ID == GUI1){ + Utils.LOG_WARNING("Opening Gui with Id: "+ID); + return new GUI_Battery_Buffer(); + } + else if (ID == GUI2){ + Utils.LOG_WARNING("Opening Gui with Id: "+ID+" Energy Buffer"); + return new GUI_Bat_Buf(); + } + return null; + } + +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/handler/ResourceHandler.java b/src/Java/miscutil/core/handler/ResourceHandler.java new file mode 100644 index 0000000000..e8f81f4d02 --- /dev/null +++ b/src/Java/miscutil/core/handler/ResourceHandler.java @@ -0,0 +1,83 @@ +package miscutil.core.handler; + +import org.apache.commons.lang3.Validate; + +public class ResourceHandler +{ + private final String resourceDomain; + private final String resourcePath; + private static final String __OBFID = "CL_00001082"; + + public ResourceHandler(String p_i1292_1_, String p_i1292_2_) + { + Validate.notNull(p_i1292_2_); + + if (p_i1292_1_ != null && p_i1292_1_.length() != 0) + { + this.resourceDomain = p_i1292_1_; + } + else + { + this.resourceDomain = "minecraft"; + } + + this.resourcePath = p_i1292_2_; + } + + public ResourceHandler(String p_i1293_1_) + { + String s1 = "miscUtils"; + String s2 = p_i1293_1_; + int i = p_i1293_1_.indexOf(58); + + if (i >= 0) + { + s2 = p_i1293_1_.substring(i + 1, p_i1293_1_.length()); + + if (i > 1) + { + s1 = p_i1293_1_.substring(0, i); + } + } + + this.resourceDomain = s1.toLowerCase(); + this.resourcePath = s2; + } + + public String getResourcePath() + { + return this.resourcePath; + } + + public String getResourceDomain() + { + return this.resourceDomain; + } + + public String toString() + { + return this.resourceDomain + ":" + this.resourcePath; + } + + public boolean equals(Object p_equals_1_) + { + if (this == p_equals_1_) + { + return true; + } + else if (!(p_equals_1_ instanceof ResourceHandler)) + { + return false; + } + else + { + ResourceHandler resourcelocation = (ResourceHandler)p_equals_1_; + return this.resourceDomain.equals(resourcelocation.resourceDomain) && this.resourcePath.equals(resourcelocation.resourcePath); + } + } + + public int hashCode() + { + return 31 * this.resourceDomain.hashCode() + this.resourcePath.hashCode(); + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/item/BaseMetaItemTool.java b/src/Java/miscutil/core/item/BaseMetaItemTool.java new file mode 100644 index 0000000000..c0b552f721 --- /dev/null +++ b/src/Java/miscutil/core/item/BaseMetaItemTool.java @@ -0,0 +1,5 @@ +package miscutil.core.item; + +public class BaseMetaItemTool { + +} diff --git a/src/Java/miscutil/core/item/EntityTeleportFX.java b/src/Java/miscutil/core/item/EntityTeleportFX.java new file mode 100644 index 0000000000..d67ee77968 --- /dev/null +++ b/src/Java/miscutil/core/item/EntityTeleportFX.java @@ -0,0 +1,236 @@ +package miscutil.core.item; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class EntityTeleportFX extends Entity +{ + /** 'x' location the eye should float towards. */ + private double targetX; + /** 'y' location the eye should float towards. */ + private double targetY; + /** 'z' location the eye should float towards. */ + private double targetZ; + private int despawnTimer; + private boolean shatterOrDrop; + private static final String __OBFID = "CL_00001716"; + + public EntityTeleportFX(World p_i1757_1_) + { + super(p_i1757_1_); + this.setSize(0.25F, 0.25F); + } + + protected void entityInit() {} + + /** + * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge + * length * 64 * renderDistanceWeight Args: distance + */ + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double p_70112_1_) + { + double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return p_70112_1_ < d1 * d1; + } + + public EntityTeleportFX(World p_i1758_1_, double p_i1758_2_, double p_i1758_4_, double p_i1758_6_) + { + super(p_i1758_1_); + this.despawnTimer = 0; + this.setSize(0.25F, 0.25F); + this.setPosition(p_i1758_2_, p_i1758_4_, p_i1758_6_); + this.yOffset = 0.0F; + } + + /** + * The location the eye should float/move towards. Currently used for moving towards the nearest stronghold. Args: + * strongholdX, strongholdY, strongholdZ + */ + public void moveTowards(double p_70220_1_, int p_70220_3_, double p_70220_4_) + { + double d2 = p_70220_1_ - this.posX; + double d3 = p_70220_4_ - this.posZ; + float f = MathHelper.sqrt_double(d2 * d2 + d3 * d3); + + if (f > 12.0F) + { + this.targetX = this.posX + d2 / (double)f * 12.0D; + this.targetZ = this.posZ + d3 / (double)f * 12.0D; + this.targetY = this.posY + 8.0D; + } + else + { + this.targetX = p_70220_1_; + this.targetY = (double)p_70220_3_; + this.targetZ = p_70220_4_; + } + + this.despawnTimer = 0; + this.shatterOrDrop = this.rand.nextInt(5) > 0; + } + + /** + * Sets the velocity to the args. Args: x, y, z + */ + @SideOnly(Side.CLIENT) + public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_) + { + this.motionX = p_70016_1_; + this.motionY = p_70016_3_; + this.motionZ = p_70016_5_; + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI); + } + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + this.lastTickPosX = this.posX; + this.lastTickPosY = this.posY; + this.lastTickPosZ = this.posZ; + super.onUpdate(); + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + + if (!this.worldObj.isRemote) + { + double d0 = this.targetX - this.posX; + double d1 = this.targetZ - this.posZ; + float f1 = (float)Math.sqrt(d0 * d0 + d1 * d1); + float f2 = (float)Math.atan2(d1, d0); + double d2 = (double)f + (double)(f1 - f) * 0.0025D; + + if (f1 < 1.0F) + { + d2 *= 0.8D; + this.motionY *= 0.8D; + } + + this.motionX = Math.cos((double)f2) * d2; + this.motionZ = Math.sin((double)f2) * d2; + + if (this.posY < this.targetY) + { + this.motionY += (1.0D - this.motionY) * 0.014999999664723873D; + } + else + { + this.motionY += (-1.0D - this.motionY) * 0.014999999664723873D; + } + } + + float f3 = 0.25F; + + if (this.isInWater()) + { + for (int i = 0; i < 4; ++i) + { + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ); + } + } + else + { + this.worldObj.spawnParticle("portal", this.posX - this.motionX * (double)f3 + this.rand.nextDouble() * 0.6D - 0.3D, this.posY - this.motionY * (double)f3 - 0.5D, this.posZ - this.motionZ * (double)f3 + this.rand.nextDouble() * 0.6D - 0.3D, this.motionX, this.motionY, this.motionZ); + } + + if (!this.worldObj.isRemote) + { + this.setPosition(this.posX, this.posY, this.posZ); + ++this.despawnTimer; + + if (this.despawnTimer > 80 && !this.worldObj.isRemote) + { + this.setDead(); + + if (this.shatterOrDrop) + { + this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(Items.ender_eye))); + } + else + { + this.worldObj.playAuxSFX(2003, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), 0); + } + } + } + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT(NBTTagCompound p_70014_1_) {} + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound p_70037_1_) {} + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + /** + * Gets how bright this entity is. + */ + public float getBrightness(float p_70013_1_) + { + return 1.0F; + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float p_70070_1_) + { + return 15728880; + } + + /** + * If returns false, the item will not inflict any damage against entities. + */ + public boolean canAttackWithItem() + { + return false; + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/item/ModItems.java b/src/Java/miscutil/core/item/ModItems.java new file mode 100644 index 0000000000..7b84f3c589 --- /dev/null +++ b/src/Java/miscutil/core/item/ModItems.java @@ -0,0 +1,311 @@ +package miscutil.core.item; + +import miscutil.core.creativetabs.TMCreativeTabs; +import miscutil.core.item.effects.RarityUncommon; +import miscutil.core.item.tool.staballoy.StaballoyPickaxe; +import miscutil.core.lib.Strings; +import miscutil.core.util.Utils; +import net.minecraft.item.Item; +import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemArmor.ArmorMaterial; +import net.minecraftforge.common.util.EnumHelper; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameRegistry; + +public final class ModItems { +/* A name for the material. This should be the same as the name of the variable we use to store the material (in this case "TUTORIAL"). + A harvest level for pickaxes. This is a value between 0 and 3 and defines which blocks can be mined with this tool. Its also possible to create blocks which need a higher harvest level than 3, but then you are not able to mine them with vanilla tools. + Common values for the harvest level are: + Wood/Gold Tool: 0 + Stone Tool: 1 + Iron Tool: 2 + Diamond Tool: 3 + The durability of the tool or sword. This value defines how often you can use a tool until it breaks. The tools always last one use longer than the entered value. + Common values for the durability are: + Wood Tool: 59 + Stone Tool: 131 + Iron Tool: 250 + Diamond Tool: 1561 + Gold Tool: 32 + The mining speed of the tool. This value defines how much faster you are with this tool than with your hand. + Common values for the mining speed are: + Wood Tool: 2.0F + Stone Tool: 4.0F + Iron Tool: 6.0F + Diamond Tool: 8.0F + Gold Tool: 12.0F + The damage versus Entites. This value is used to calculate the damage an entity takes if you hit it with this tool/sword. This value defines the basic damage to which different values are added, depending on the type of tool. A sword always causes 4 more damage than written in the ToolMaterial. So, if you want to create a sword which adds 10 damage to your normal damage, the value in the ToolMaterial needs to be 6.0F. Of course the values can be below zero. + Common values for the damage versus Entities are: + Wood Tool: 0.0F (Sword adds 4.0 damage) + Stone Tool: 1.0F (Sword adds 5.0 damage) + Iron Tool: 2.0F (Sword adds 6.0 damage) + Diamond Tool: 3.0F (Sword adds 7.0 damage) + Gold Tool: 0.0F (Sword adds 4.0 damage) + The enchantability of this tool. This value is quite complex to understand and I have to admit that I don't quite know how it is calculated. Basically you can say that a higher enchantability leads to better enchantements with the same amount of XP. + Common values for the enchantability are: + Wood Tool: 15 + Stone Tool: 5 + Iron Tool: 14 + Diamond Tool: 10 + Gold Tool: 22*/ + + //Tool Materials + //public static ToolMaterial TUTORIAL = EnumHelper.addToolMaterial("TUTORIAL", harvestLevel, durability, miningSpeed, damageVsEntities, enchantability); + public static ToolMaterial tutMaterial = EnumHelper.addToolMaterial("BloodSteel Tool Material", 3, 200, 15.0F, 4.0F, 10); + public static ToolMaterial STABALLOY = EnumHelper.addToolMaterial("Staballoy", 3, 2500, 7, 1.0F, 18); + + //Armour Materials + public static ArmorMaterial tutArmorMaterial = EnumHelper.addArmorMaterial("BloodSteel Armor Material", 33, new int[]{2, 5, 4, 2}, 10); + + //Base Classes For Items + public static Item tutPickaxe; + public static Item tutAxe; + public static Item tutSword; + public static Item tutHoe; + public static Item tutSpade; + + //Base Classes For Armour + public static Item tutHelmet; + public static Item tutPlate; + public static Item tutPants; + public static Item tutBoots; + + //EnderIO + public static Item itemPlateSoularium; + public static Item itemPlateRedstoneAlloy; + public static Item itemPlateElectricalSteel; + public static Item itemPlatePulsatingIron; + public static Item itemPlateEnergeticAlloy; + public static Item itemPlateVibrantAlloy; + public static Item itemPlateConductiveIron; + public static Item itemPlateDarkSteel; + + //Big Reactors + public static Item itemPlateBlutonium; + public static Item itemPlateCyanite; + public static Item itemPlateLudicrite; + + //Thaumcraft + public static Item itemPlateVoidMetal; + + //ExtraUtils + public static Item itemPlateBedrockium; + + //Pneumaticraft + public static Item itemPlateCompressedIron; + + //SimplyJetpacks + public static Item itemPlateEnrichedSoularium; + + //rfTools + public static Item itemPlateDimensionShard; + + //Misc Items + public static Item itemIngotBloodSteel; + public static Item itemPlateBloodSteel; + + //Staballoy + public static Item itemStaballoyPickaxe; + public static Item itemPlateStaballoy; + public static Item itemIngotStaballoy; + + + + + //@SuppressWarnings("unused") + @SuppressWarnings("unused") + public static final void init(){ + + /* + * + * Strings.DEBUG Parameters area + * + */ + //Logs + if (!Strings.DEBUG){ + Utils.LOG_INFO("Development mode not enabled."); + } + else if (Strings.DEBUG){ + Utils.LOG_INFO("Development mode enabled."); + } + else { + Utils.LOG_WARNING("Development mode not set."); + } + /* + * End Strings.DEBUG + */ + + + + /* //Blood Steel Equipment + + //Item Init + tutPickaxe = new BloodSteelPickaxe(tutMaterial).setUnlocalizedName("BloodSteelPickaxe").setCreativeTab(TMCreativeTabs.tabTools).setTextureName(Strings.MODID + ":BloodSteelPickaxe"); + tutAxe = new BloodSteelAxe(tutMaterial).setUnlocalizedName("BloodSteelAxe").setCreativeTab(TMCreativeTabs.tabTools).setTextureName(Strings.MODID + ":BloodSteelAxe"); + tutSword = new BloodSteelSword(tutMaterial).setUnlocalizedName("BloodSteelSword").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(Strings.MODID + ":BloodSteelSword"); + tutHoe = new BloodSteelHoe(tutMaterial).setUnlocalizedName("BloodSteelHoe").setCreativeTab(TMCreativeTabs.tabTools).setTextureName(Strings.MODID + ":BloodSteelHoe"); + tutSpade = new BloodSteelSpade(tutMaterial).setUnlocalizedName("BloodSteelSpade").setCreativeTab(TMCreativeTabs.tabTools).setTextureName(Strings.MODID + ":BloodSteelSpade"); + tutHelmet = new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 0).setUnlocalizedName("BloodSteelHelmet").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(Strings.MODID + ":BloodSteelHelmet"); + tutPlate = new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 1).setUnlocalizedName("BloodSteelPlate").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(Strings.MODID + ":BloodSteelPlate"); + tutPants = new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 2).setUnlocalizedName("BloodSteelPants").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(Strings.MODID + ":BloodSteelPants"); + tutBoots = new BloodSteelArmor(tutArmorMaterial, MiscUtils.proxy.addArmor("BloodSteelArmor"), 3).setUnlocalizedName("BloodSteelBoots").setCreativeTab(TMCreativeTabs.tabCombat).setTextureName(Strings.MODID + ":BloodSteelBoots"); + + //Registry + GameRegistry.registerItem(tutPickaxe, tutPickaxe.getUnlocalizedName()); + GameRegistry.registerItem(tutAxe, tutAxe.getUnlocalizedName()); + GameRegistry.registerItem(tutSword, tutSword.getUnlocalizedName()); + GameRegistry.registerItem(tutHoe, tutHoe.getUnlocalizedName()); + GameRegistry.registerItem(tutSpade, tutSpade.getUnlocalizedName()); + GameRegistry.registerItem(tutHelmet, tutHelmet.getUnlocalizedName()); + GameRegistry.registerItem(tutPlate, tutPlate.getUnlocalizedName()); + GameRegistry.registerItem(tutPants, tutPants.getUnlocalizedName()); + GameRegistry.registerItem(tutBoots, tutBoots.getUnlocalizedName()); */ + + + + + + + //EnderIO Resources + if (Loader.isModLoaded("EnderIO") == true || Strings.LOAD_ALL_CONTENT){ + Utils.LOG_INFO("EnderIO Found - Loading Resources."); + //Item Init + itemPlateSoularium = new Item().setUnlocalizedName("itemPlateSoularium").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateSoularium");; + itemPlateRedstoneAlloy = new Item().setUnlocalizedName("itemPlateRedstoneAlloy").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateRedstoneAlloy");; + itemPlateElectricalSteel = new Item().setUnlocalizedName("itemPlateElectricalSteel").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateElectricalSteel");; + itemPlatePulsatingIron = new Item().setUnlocalizedName("itemPlatePulsatingIron").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlatePulsatingIron");; + itemPlateEnergeticAlloy = new Item().setUnlocalizedName("itemPlateEnergeticAlloy").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateEnergeticAlloy");; + itemPlateVibrantAlloy = new Item().setUnlocalizedName("itemPlateVibrantAlloy").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateVibrantAlloy");; + itemPlateConductiveIron = new Item().setUnlocalizedName("itemPlateConductiveIron").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateConductiveIron");; + itemPlateDarkSteel = new Item().setUnlocalizedName("itemPlateDarkSteel").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateDarkSteel");; + + + //Registry + GameRegistry.registerItem(itemPlateSoularium, "itemPlateSoularium"); + GameRegistry.registerItem(itemPlateRedstoneAlloy, "itemPlateRedstoneAlloy"); + GameRegistry.registerItem(itemPlateElectricalSteel, "itemPlateElectricalSteel"); + GameRegistry.registerItem(itemPlatePulsatingIron, "itemPlatePulsatingIron"); + GameRegistry.registerItem(itemPlateEnergeticAlloy, "itemPlateEnergeticAlloy"); + GameRegistry.registerItem(itemPlateVibrantAlloy, "itemPlateVibrantAlloy"); + GameRegistry.registerItem(itemPlateConductiveIron, "itemPlateConductiveIron"); + GameRegistry.registerItem(itemPlateDarkSteel, "itemPlateDarkSteel"); + } + else { + Utils.LOG_WARNING("EnderIO not Found - Skipping Resources."); + } + + //Big Reactors + if (Loader.isModLoaded("BigReactors") == true || Strings.LOAD_ALL_CONTENT){ + Utils.LOG_INFO("BigReactors Found - Loading Resources."); + //Item Init + itemPlateBlutonium = new Item().setUnlocalizedName("itemPlateBlutonium").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateBlutonium");; + itemPlateCyanite = new Item().setUnlocalizedName("itemPlateCyanite").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateCyanite");; + itemPlateLudicrite = new Item().setUnlocalizedName("itemPlateLudicrite").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateLudicrite");; + + //Registry + GameRegistry.registerItem(itemPlateBlutonium, "itemPlateBlutonium"); + GameRegistry.registerItem(itemPlateCyanite, "itemPlateCyanite"); + GameRegistry.registerItem(itemPlateLudicrite, "itemPlateLudicrite"); + + } + else { + Utils.LOG_WARNING("BigReactors not Found - Skipping Resources."); + } + + //Thaumcraft + if (Loader.isModLoaded("Thaumcraft") == true || Strings.LOAD_ALL_CONTENT){ + Utils.LOG_INFO("Thaumcraft Found - Loading Resources."); + //Item Init + itemPlateVoidMetal = new Item().setUnlocalizedName("itemPlateVoidMetal").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateVoidMetal");; + + //Registry + GameRegistry.registerItem(itemPlateVoidMetal, "itemPlateVoidMetal"); + + } + else { + Utils.LOG_WARNING("Thaumcraft not Found - Skipping Resources."); + } + + //ExtraUtils + if (Loader.isModLoaded("ExtraUtilities") == true || Strings.LOAD_ALL_CONTENT){ + Utils.LOG_INFO("ExtraUtilities Found - Loading Resources."); + //Item Init + itemPlateBedrockium = new Item().setUnlocalizedName("itemPlateBedrockium").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateBedrockium");; + + //Registry + GameRegistry.registerItem(itemPlateBedrockium, "itemPlateBedrockium"); + + } + else { + Utils.LOG_WARNING("ExtraUtilities not Found - Skipping Resources."); + } + + //Pneumaticraft + if (Loader.isModLoaded("PneumaticCraft") == true || Strings.LOAD_ALL_CONTENT){ + Utils.LOG_INFO("PneumaticCraft Found - Loading Resources."); + //Item Init + itemPlateCompressedIron = new Item().setUnlocalizedName("itemPlateCompressedIron").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateCompressedIron");; + + //Registry + GameRegistry.registerItem(itemPlateCompressedIron, "itemPlateCompressedIron"); + + } + else { + Utils.LOG_WARNING("PneumaticCraft not Found - Skipping Resources."); + } + + //Simply Jetpacks + if (Loader.isModLoaded("simplyjetpacks") == true || Strings.LOAD_ALL_CONTENT){ + Utils.LOG_INFO("SimplyJetpacks Found - Loading Resources."); + //Item Init + itemPlateEnrichedSoularium = new RarityUncommon().setUnlocalizedName("itemPlateEnrichedSoularium").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateSoularium");; + + //Registry + GameRegistry.registerItem(itemPlateEnrichedSoularium, "itemPlateEnrichedSoularium"); + + } + else { + Utils.LOG_WARNING("SimplyJetpacks not Found - Skipping Resources."); + } + + + //rfTools + if (Loader.isModLoaded("rftools") == true || Strings.LOAD_ALL_CONTENT){ + Utils.LOG_INFO("rfTools Found - Loading Resources."); + //Item Init + itemPlateDimensionShard = new Item().setUnlocalizedName("itemPlateDimensionShard").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateDimensionShard");; + + //Registry + GameRegistry.registerItem(itemPlateDimensionShard, "itemPlateDimensionShard"); + + } + else { + Utils.LOG_WARNING("rfTools not Found - Skipping Resources."); + } + + /* + * Misc Items + */ + + //Staballoy Equipment + Utils.LOG_INFO("Interest in Stablloy Found - Loading Resources."); + //Pickaxe + itemStaballoyPickaxe = new StaballoyPickaxe("itemStaballoyPickaxe", STABALLOY).setCreativeTab(TMCreativeTabs.tabTools); + GameRegistry.registerItem(itemStaballoyPickaxe, itemStaballoyPickaxe.getUnlocalizedName()); + //Staballoy Ingot/Plate + itemIngotStaballoy = new Item().setUnlocalizedName("itemIngotStaballoy").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemIngotStaballoy");; + GameRegistry.registerItem(itemIngotStaballoy, "itemIngotStaballoy"); + itemPlateStaballoy = new Item().setUnlocalizedName("itemPlateStaballoy").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemPlateStaballoy");; + GameRegistry.registerItem(itemPlateStaballoy, "itemPlateStaballoy"); + //GregTech_API.sRecipeAdder.addAlloySmelterRecipe(, aInput2, aOutput1, aDuration, aEUt) + + + + //Blood Steel Ingot + itemIngotBloodSteel = new Item().setUnlocalizedName("itemIngotBloodSteel").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemIngotBloodSteel");; + GameRegistry.registerItem(itemIngotBloodSteel, "itemIngotBloodSteel"); + + + } + +} diff --git a/src/Java/miscutil/core/item/effects/RarityEffect.java b/src/Java/miscutil/core/item/effects/RarityEffect.java new file mode 100644 index 0000000000..41ba2d6baf --- /dev/null +++ b/src/Java/miscutil/core/item/effects/RarityEffect.java @@ -0,0 +1,41 @@ +package miscutil.core.item.effects; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/* + * +This determines the name colour. EnumRarity can be: +EnumRarity.common - the standard white colour. +EnumRarity.uncommon - a yellow colour. +EnumRarity.rare - a light blue colour. This is used for enchanted items. +EnumRarity.epic - the purple colour used on the Golden Apple. +@SideOnly is an FML annotation. It marks the method below it for existing only on one side. Possible values are: +Side.CLIENT is probably the most common one. This marks the method as existing only on the client side. +Side.SERVER marks the method as existing only on the server side. + * + */ + +public class RarityEffect extends Item { + + public RarityEffect(int par1){ + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.common; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/miscutil/core/item/effects/RarityEpic.java b/src/Java/miscutil/core/item/effects/RarityEpic.java new file mode 100644 index 0000000000..dfcaaa9007 --- /dev/null +++ b/src/Java/miscutil/core/item/effects/RarityEpic.java @@ -0,0 +1,28 @@ +package miscutil.core.item.effects; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RarityEpic extends Item { + + public RarityEpic(int par1){ + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.epic; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/miscutil/core/item/effects/RarityRare.java b/src/Java/miscutil/core/item/effects/RarityRare.java new file mode 100644 index 0000000000..6afc9b6733 --- /dev/null +++ b/src/Java/miscutil/core/item/effects/RarityRare.java @@ -0,0 +1,28 @@ +package miscutil.core.item.effects; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RarityRare extends Item { + + public RarityRare(int par1){ + super(); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.rare; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/miscutil/core/item/effects/RarityUncommon.java b/src/Java/miscutil/core/item/effects/RarityUncommon.java new file mode 100644 index 0000000000..4347dc70f5 --- /dev/null +++ b/src/Java/miscutil/core/item/effects/RarityUncommon.java @@ -0,0 +1,22 @@ +package miscutil.core.item.effects; + +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RarityUncommon extends Item { + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return true; + } + +} diff --git a/src/Java/miscutil/core/item/materials/MaterialHandler.java b/src/Java/miscutil/core/item/materials/MaterialHandler.java new file mode 100644 index 0000000000..3c57d21f90 --- /dev/null +++ b/src/Java/miscutil/core/item/materials/MaterialHandler.java @@ -0,0 +1,9 @@ +package miscutil.core.item.materials; + +public class MaterialHandler { + + private String Staballoy; + + + +} diff --git a/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelArmor.java b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelArmor.java new file mode 100644 index 0000000000..11bc400587 --- /dev/null +++ b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelArmor.java @@ -0,0 +1,56 @@ +package miscutil.core.item.tool.bloodsteel; + +import miscutil.core.item.ModItems; +import miscutil.core.lib.Strings; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; + +public class BloodSteelArmor extends ItemArmor { + + public BloodSteelArmor(ArmorMaterial p_i45325_1_, int p_i45325_2_, int p_i45325_3_) { + super(p_i45325_1_, p_i45325_2_, p_i45325_3_); + // TODO Auto-generated constructor stub + } + + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + if (stack.getItem() == ModItems.tutHelmet || stack.getItem() == ModItems.tutPlate || stack.getItem() == ModItems.tutBoots) { + return Strings.MODID + ":textures/armor/BloodSteelArmor1.png"; + } else if (stack.getItem() == ModItems.tutPants) { + return Strings.MODID + ":textures/armor/BloodSteelArmor2.png"; + } else { + return null; + } + } + + /** + * Called to tick armor in the armor slot. Override to do something + * + * @param world + * @param player + * @param itemStack + */ + public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { + if(player.getCurrentArmor(3) != null && player.getCurrentArmor(2) != null && player.getCurrentArmor(1) != null){ + ItemStack helmet = player.getCurrentArmor(3); + ItemStack plate = player.getCurrentArmor(2); + ItemStack pants = player.getCurrentArmor(1); + if(helmet.getItem() == ModItems.tutHelmet && plate.getItem() == ModItems.tutPlate && pants.getItem() == ModItems.tutPants){ + //player.addPotionEffect(new PotionEffect(Potion.confusion.getId(), 100, 1)); + player.capabilities.allowFlying = true; + } + } + + if(player.getCurrentArmor(0) != null){ + ItemStack boots = player.getCurrentArmor(0); + if(boots.getItem() == ModItems.tutBoots){ + player.addPotionEffect(new PotionEffect(Potion.jump.getId(), 100, 1)); + } + } + } + +} diff --git a/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelAxe.java b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelAxe.java new file mode 100644 index 0000000000..6353aa3631 --- /dev/null +++ b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelAxe.java @@ -0,0 +1,12 @@ +package miscutil.core.item.tool.bloodsteel; + +import net.minecraft.item.ItemAxe; + +public class BloodSteelAxe extends ItemAxe{ + + protected BloodSteelAxe(ToolMaterial p_i45327_1_) { + super(p_i45327_1_); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelHoe.java b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelHoe.java new file mode 100644 index 0000000000..0115c08d00 --- /dev/null +++ b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelHoe.java @@ -0,0 +1,12 @@ +package miscutil.core.item.tool.bloodsteel; + +import net.minecraft.item.ItemHoe; + +public class BloodSteelHoe extends ItemHoe{ + + public BloodSteelHoe(ToolMaterial p_i45343_1_) { + super(p_i45343_1_); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelPickaxe.java b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelPickaxe.java new file mode 100644 index 0000000000..d2c5d467b5 --- /dev/null +++ b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelPickaxe.java @@ -0,0 +1,12 @@ +package miscutil.core.item.tool.bloodsteel; + +import net.minecraft.item.ItemPickaxe; + +public class BloodSteelPickaxe extends ItemPickaxe{ + + protected BloodSteelPickaxe(ToolMaterial p_i45347_1_) { + super(p_i45347_1_); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelSpade.java b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelSpade.java new file mode 100644 index 0000000000..15318d7382 --- /dev/null +++ b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelSpade.java @@ -0,0 +1,12 @@ +package miscutil.core.item.tool.bloodsteel; + +import net.minecraft.item.ItemSpade; + +public class BloodSteelSpade extends ItemSpade{ + + public BloodSteelSpade(ToolMaterial p_i45353_1_) { + super(p_i45353_1_); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelSword.java b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelSword.java new file mode 100644 index 0000000000..96d11331a0 --- /dev/null +++ b/src/Java/miscutil/core/item/tool/bloodsteel/BloodSteelSword.java @@ -0,0 +1,12 @@ +package miscutil.core.item.tool.bloodsteel; + +import net.minecraft.item.ItemSword; + +public class BloodSteelSword extends ItemSword{ + + public BloodSteelSword(ToolMaterial p_i45356_1_) { + super(p_i45356_1_); + // TODO Auto-generated constructor stub + } + +} diff --git a/src/Java/miscutil/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/miscutil/core/item/tool/staballoy/StaballoyPickaxe.java new file mode 100644 index 0000000000..2453f9f6e2 --- /dev/null +++ b/src/Java/miscutil/core/item/tool/staballoy/StaballoyPickaxe.java @@ -0,0 +1,14 @@ +package miscutil.core.item.tool.staballoy; + +import miscutil.core.lib.Strings; +import net.minecraft.item.ItemPickaxe; + +public class StaballoyPickaxe extends ItemPickaxe{ + + public StaballoyPickaxe(String unlocalizedName, ToolMaterial material) { + super(material); + this.setUnlocalizedName(unlocalizedName); + this.setTextureName(Strings.MODID + ":" + unlocalizedName); + } + +} diff --git a/src/Java/miscutil/core/lib/Strings.java b/src/Java/miscutil/core/lib/Strings.java new file mode 100644 index 0000000000..1213dc56ef --- /dev/null +++ b/src/Java/miscutil/core/lib/Strings.java @@ -0,0 +1,19 @@ +package miscutil.core.lib; + +public class Strings { + + public static final String name = "Misc. Utils"; + public static final String MODID = "miscutils"; + public static final String VERSION = "0.7.8gtu"; + public static final boolean DEBUG = true; + public static boolean GREGTECH; + public static final boolean LOAD_ALL_CONTENT = false; + public static final int GREG_FIRST_ID = 760; + + //GUIS + public enum GUI_ENUM + { + ENERGYBUFFER, TOOLBUILDER, NULL, NULL1, NULL2 + } + +} diff --git a/src/Java/miscutil/core/proxy/ClientProxy.java b/src/Java/miscutil/core/proxy/ClientProxy.java new file mode 100644 index 0000000000..f0f21549e8 --- /dev/null +++ b/src/Java/miscutil/core/proxy/ClientProxy.java @@ -0,0 +1,42 @@ +package miscutil.core.proxy; + +import miscutil.core.CommonProxy; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class ClientProxy extends CommonProxy{ + + @Override + public void preInit(FMLPreInitializationEvent e) { + // TODO Auto-generated method stub + super.preInit(e); + } + + @Override + public void init(FMLInitializationEvent e) { + // TODO Auto-generated method stub + super.init(e); + } + + @Override + public void postInit(FMLPostInitializationEvent e) { + // TODO Auto-generated method stub + super.postInit(e); + } + + public void registerRenderThings(){ + //RenderingRegistry.registerEntityRenderingHandler(EntityBloodSteelMob.class, new RenderBloodSteelMob(new ModelBloodSteelMob(), 0)); + //RenderingRegistry.registerEntityRenderingHandler(EntityBloodSteelHostileMob.class, new RenderBloodSteelMobHostile(new ModelBloodSteelMob(), 0)); + //RenderingRegistry.registerEntityRenderingHandler(EntityGrenade.class, new RenderSnowball(ModItems.tutGrenade)); + + //ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBloodSteelChest.class, new BloodSteelChestRenderer()); + //MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.tutChest), new ItemRenderBloodSteelChest()); + } + + public int addArmor(String armor){ + return RenderingRegistry.addNewArmourRendererPrefix(armor); + } + +} diff --git a/src/Java/miscutil/core/proxy/ServerProxy.java b/src/Java/miscutil/core/proxy/ServerProxy.java new file mode 100644 index 0000000000..59e625eaed --- /dev/null +++ b/src/Java/miscutil/core/proxy/ServerProxy.java @@ -0,0 +1,28 @@ +package miscutil.core.proxy; + +import miscutil.core.CommonProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class ServerProxy extends CommonProxy{ + + @Override + public void preInit(FMLPreInitializationEvent e) { + // TODO Auto-generated method stub + super.preInit(e); + } + + @Override + public void init(FMLInitializationEvent e) { + // TODO Auto-generated method stub + super.init(e); + } + + @Override + public void postInit(FMLPostInitializationEvent e) { + // TODO Auto-generated method stub + super.postInit(e); + } + +} diff --git a/src/Java/miscutil/core/tileentities/ModTileEntities.java b/src/Java/miscutil/core/tileentities/ModTileEntities.java new file mode 100644 index 0000000000..6126c5793e --- /dev/null +++ b/src/Java/miscutil/core/tileentities/ModTileEntities.java @@ -0,0 +1,13 @@ +package miscutil.core.tileentities; + +import miscutil.core.util.Utils; + +public class ModTileEntities { + + + public static void init(){ + Utils.LOG_INFO("Registering Tile Entities."); + //GameRegistry.registerTileEntity(TileEntityStorage.class, "TE_Storage"); + } + +} diff --git a/src/Java/miscutil/core/util/Benchmark.java b/src/Java/miscutil/core/util/Benchmark.java new file mode 100644 index 0000000000..1e17175c3b --- /dev/null +++ b/src/Java/miscutil/core/util/Benchmark.java @@ -0,0 +1,153 @@ +package miscutil.core.util; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Random; + +import cpw.mods.fml.common.FMLLog; + +@SuppressWarnings("unused") +public class Benchmark { + + public void math() throws ParseException{ + Random r = new Random(); + + FMLLog.info("Looking at the stars in the sky"); + + // generate some random boolean values + boolean[] booleans = new boolean[10]; + for (int i = 0; i < booleans.length; i++) { + booleans[i] = r.nextBoolean(); + } + + //FMLLog.info(getSha256(booleans.toString())); + + /*for (boolean b : booleans) { + FMLLog.info(b + ", "); + }*/ + + // generate a uniformly distributed int random numbers + int[] integers = new int[10]; + for (int i = 0; i < integers.length; i++) { + integers[i] = r.nextInt(); + } + + FMLLog.info(getSha256(integers.toString())); + + /*for (int i : integers) {s + FMLLog.info(i + ", "); + }*/ + + // generate a uniformly distributed float random numbers + float[] floats = new float[10]; + for (int i = 0; i < floats.length; i++) { + floats[i] = r.nextFloat(); + } + + FMLLog.info(getSha256(floats.toString())); + + /*for (float f : floats) { + FMLLog.info(f + ", "); + }*/ + + // generate a Gaussian normally distributed random numbers + double[] gaussians = new double[10]; + for (int i = 0; i < gaussians.length; i++) { + gaussians[i] = r.nextGaussian(); + } + + FMLLog.info(getSha256(gaussians.toString())); + } + + private String dateTime(){ + DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd - HH:mm:ss"); + //get current date time with Calendar() + Calendar cal = Calendar.getInstance(); + return dateFormat.format(cal.getTime()); + } + + public String superhash(String a){ + FMLLog.info("Calculating the cost of life & the universe"); + int i = 1; + String b = a; + while (i < 3358 && i > 0){ + if (!b.equals(a)){ + b = a; + } + getSha256(b); + a = b; + try { + Thread.sleep(2); + } catch (InterruptedException e) { + FMLLog.info("Hashbrown order failed"); + e.printStackTrace(); + } + if (i == 500 || i == 1000 || i == 1500 || i == 2000 || i == 2500 || i == 3000 || i == 3500 || i == 4000 || i == 5000){ + //FMLLog.info("Calculating orbits around the sun: "+i); + } + i++; + } + return b; + } + + private String getSha256(String message) { + if (message == null || message.isEmpty()) { + return ""; + } + String chiper = generateString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!@#$%^&*()_+`~[];',./{}:<>?|'", 32); + String key = generateString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-=!@#$%^&*()_+`~[];',./{}:<>?|'", 16); // key is used to construct a new SHA-256 key/salt + + // Initialize SHA-256 + MessageDigest digest = null; + try { + digest = MessageDigest.getInstance("SHA-256"); + } catch (NoSuchAlgorithmException e) { + System.err.println(e.getMessage()); + } + + // Hashing entered key to construct a new key/salt + byte[] keyAsSHA256 = digest.digest(key.getBytes()); + + // Encoding the message with CBC + char[] messageAsChars = message.toCharArray(); + messageAsChars[0] ^= keyAsSHA256[0]; // Avoiding buffer underflow + for (int i = 1; i < messageAsChars.length; i++) { + messageAsChars[i] ^= messageAsChars[i - 1]; // XOR with previous character + messageAsChars[i] ^= keyAsSHA256[i % keyAsSHA256.length]; // XOR with keys hash + } + // build cipher from the chars + chiper = new String(messageAsChars); + String cipher = MD5(chiper); + return chiper + "|" + cipher; + } + + public String MD5(String md5) { + try { + java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); + byte[] array = md.digest(md5.getBytes()); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < array.length; ++i) { + sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3)); + } + return sb.toString(); + } catch (java.security.NoSuchAlgorithmException e) { + } + return null; + } + + public static String generateString(String characters, int length) + { + Random r = new Random(); + char[] text = new char[length]; + for (int i = 0; i < length; i++) + { + text[i] = characters.charAt(r.nextInt(characters.length())); + } + return new String(text); + } + +}
\ No newline at end of file diff --git a/src/Java/miscutil/core/util/Utils.java b/src/Java/miscutil/core/util/Utils.java new file mode 100644 index 0000000000..00acfba45f --- /dev/null +++ b/src/Java/miscutil/core/util/Utils.java @@ -0,0 +1,61 @@ +package miscutil.core.util; + +import java.awt.Graphics; + +import miscutil.core.lib.Strings; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.FMLLog; + +public class Utils { + + public static final int WILDCARD_VALUE = Short.MAX_VALUE; + public static boolean containsMatch(boolean strict, ItemStack[] inputs, ItemStack... targets) + { + for (ItemStack input : inputs) + { + for (ItemStack target : targets) + { + if (itemMatches(target, input, strict)) + { + return true; + } + } + } + return false; + } + + public static boolean itemMatches(ItemStack target, ItemStack input, boolean strict) + { + if (input == null && target != null || input != null && target == null) + { + return false; + } + return (target.getItem() == input.getItem() && ((target.getItemDamage() == WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage())); + } + + //Non-Dev Comments + public static void LOG_INFO(String s){ + //if (Strings.DEBUG){ + FMLLog.info("MiscUtils: "+s); + //} + } + + //Developer Comments + public static void LOG_WARNING(String s){ + if (Strings.DEBUG){ + FMLLog.warning("MiscUtils: "+s); + } + } + + //Errors + public static void LOG_ERROR(String s){ + if (Strings.DEBUG){ + FMLLog.severe("MiscUtils: "+s); + } + } + + public static void paintBox(Graphics g, int MinA, int MinB, int MaxA, int MaxB){ + g.drawRect (MinA, MinB, MaxA, MaxB); + } + +} diff --git a/src/Java/miscutil/gregtech/energy/IC2ElectricItem.java b/src/Java/miscutil/gregtech/energy/IC2ElectricItem.java new file mode 100644 index 0000000000..1e8ecd563a --- /dev/null +++ b/src/Java/miscutil/gregtech/energy/IC2ElectricItem.java @@ -0,0 +1,55 @@ +package miscutil.gregtech.energy; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Provides the ability to store energy on the implementing item. + * + * The item should have a maximum damage of 13. + */ +public interface IC2ElectricItem { + /** + * Determine if the item can be used in a machine or as an armor part to supply energy. + * + * @return Whether the item can supply energy + */ + boolean canProvideEnergy(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy greater than 0. + * + * @return Item ID to use + */ + Item getChargedItem(ItemStack itemStack); + + /** + * Get the item ID to use for a charge energy of 0. + * + * @return Item ID to use + */ + Item getEmptyItem(ItemStack itemStack); + + /** + * Get the item's maximum charge energy in EU. + * + * @return Maximum charge energy + */ + double getMaxCharge(ItemStack itemStack); + + /** + * Get the item's tier, lower tiers can't send energy to higher ones. + * Batteries are Tier 1, Energy Crystals are Tier 2, Lapotron Crystals are Tier 3. + * + * @return Item's tier + */ + int getTier(ItemStack itemStack); + + /** + * Get the item's transfer limit in EU per transfer operation. + * + * @return Transfer limit + */ + double getTransferLimit(ItemStack itemStack); +} + diff --git a/src/Java/miscutil/gregtech/energy/IC2ElectricItemManager.java b/src/Java/miscutil/gregtech/energy/IC2ElectricItemManager.java new file mode 100644 index 0000000000..8607d2109b --- /dev/null +++ b/src/Java/miscutil/gregtech/energy/IC2ElectricItemManager.java @@ -0,0 +1,95 @@ +package miscutil.gregtech.energy; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +/** + * This interface specifies a manager to handle the various tasks for electric items. + * + * The default implementation does the following: + * - store and retrieve the charge + * - handle charging, taking amount, tier, transfer limit, canProvideEnergy and simulate into account + * - replace item IDs if appropriate (getChargedItemId() and getEmptyItemId()) + * - update and manage the damage value for the visual charge indicator + * + * @note If you're implementing your own variant (ISpecialElectricItem), you can delegate to the + * default implementations through ElectricItem.rawManager. The default implementation is designed + * to minimize its dependency on its own constraints/structure and delegates most work back to the + * more atomic features in the gateway manager. + */ +public interface IC2ElectricItemManager { + /** + * Charge an item with a specified amount of energy. + * + * @param itemStack electric item's stack + * @param amount amount of energy to charge in EU + * @param tier tier of the charging device, has to be at least as high as the item to charge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param simulate don't actually change the item, just determine the return value + * @return Energy transferred into the electric item + */ + double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate); + + /** + * Discharge an item by a specified amount of energy + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param tier tier of the discharging device, has to be at least as high as the item to discharge + * @param ignoreTransferLimit ignore the transfer limit specified by getTransferLimit() + * @param externally use the supplied item externally, i.e. to power something else as if it was a battery + * @param simulate don't actually discharge the item, just determine the return value + * @return Energy retrieved from the electric item + */ + double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate); + + /** + * Determine the charge level for the specified item. + * + * @param itemStack ItemStack containing the electric item + * @return charge level in EU + */ + double getCharge(ItemStack stack); + + /** + * Determine if the specified electric item has at least a specific amount of EU. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * BatPacks are not taken into account. + * + * @param itemStack electric item's stack + * @param amount minimum amount of energy required + * @return true if there's enough energy + */ + boolean canUse(ItemStack stack, double amount); + + /** + * Try to retrieve a specific amount of energy from an Item, and if applicable, a BatPack. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * + * @param itemStack electric item's stack + * @param amount amount of energy to discharge in EU + * @param entity entity holding the item + * @return true if the operation succeeded + */ + boolean use(ItemStack stack, double amount, EntityLivingBase entity); + + /** + * Charge an item from the BatPack a player is wearing. + * This is supposed to be used in the item code during operation, for example if you want to implement your own electric item. + * use() already contains this functionality. + * + * @param itemStack electric item's stack + * @param entity entity holding the item + */ + void chargeFromArmor(ItemStack stack, EntityLivingBase entity); + + /** + * Get the tool tip to display for electric items. + * + * @param itemStack ItemStack to determine the tooltip for + * @return tool tip string or null for none + */ + String getToolTip(ItemStack stack); + + // TODO: add tier getter +} diff --git a/src/Java/miscutil/gregtech/enums/AddExtraOreDict.java b/src/Java/miscutil/gregtech/enums/AddExtraOreDict.java new file mode 100644 index 0000000000..4b3e352292 --- /dev/null +++ b/src/Java/miscutil/gregtech/enums/AddExtraOreDict.java @@ -0,0 +1,16 @@ +package miscutil.gregtech.enums; + +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.loaders.preload.GT_Loader_OreDictionary; +import miscutil.gregtech.init.machines.GregtechEnergyBuffer; +import net.minecraft.item.ItemStack; + +public class AddExtraOreDict extends GT_Loader_OreDictionary { + + @Override + public void run() + { + GT_OreDictUnificator.registerOre(ExtraOreDictNames.buffer_core, new ItemStack(GregtechEnergyBuffer.itemBufferCore)); + } + +} diff --git a/src/Java/miscutil/gregtech/enums/ExtraOreDictNames.java b/src/Java/miscutil/gregtech/enums/ExtraOreDictNames.java new file mode 100644 index 0000000000..aca2b63434 --- /dev/null +++ b/src/Java/miscutil/gregtech/enums/ExtraOreDictNames.java @@ -0,0 +1,5 @@ +package miscutil.gregtech.enums; + +public enum ExtraOreDictNames { + buffer_core +} diff --git a/src/Java/miscutil/gregtech/enums/GregtechItemList.java b/src/Java/miscutil/gregtech/enums/GregtechItemList.java new file mode 100644 index 0000000000..fb09dc36cb --- /dev/null +++ b/src/Java/miscutil/gregtech/enums/GregtechItemList.java @@ -0,0 +1,153 @@ +package miscutil.gregtech.enums; + +import static gregtech.api.enums.GT_Values.W; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import miscutil.gregtech.interfaces.GregtechItemContainer; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +/** + * Class containing all non-OreDict Items of GregTech. + */ +public enum GregtechItemList implements GregtechItemContainer { + + Credit_Copper, + Credit_Iron, + Credit_Silver, + Credit_Gold, + Credit_Platinum, + Credit_Osmium, + Credit_Greg_Copper, + Credit_Greg_Cupronickel, + Credit_Greg_Silver, + Credit_Greg_Gold, + Credit_Greg_Platinum, + Credit_Greg_Osmium, + Credit_Greg_Naquadah, + Energy_Buffer_CREATIVE, + //Energy Buffes + Energy_Buffer_1by1_ULV, Energy_Buffer_1by1_LV, Energy_Buffer_1by1_MV, Energy_Buffer_1by1_HV, Energy_Buffer_1by1_EV, Energy_Buffer_1by1_IV, Energy_Buffer_1by1_LuV, Energy_Buffer_1by1_ZPM, Energy_Buffer_1by1_UV, Energy_Buffer_1by1_MAX, + Cobble_Generator_ULV, Cobble_Generator_LV, Cobble_Generator_MV, Cobble_Generator_HV, Cobble_Generator_EV, Cobble_Generator_IV, Cobble_Generator_LuV, Cobble_Generator_ZPM, Cobble_Generator_UV, Cobble_Generator_MAX; + + public static final GregtechItemList[] + DYE_ONLY_ITEMS = { + Energy_Buffer_1by1_EV, Energy_Buffer_1by1_EV }; + private ItemStack mStack; + private boolean mHasNotBeenSet = true; + + public static Fluid sOilExtraHeavy, sOilHeavy, sOilMedium, sOilLight, sNaturalGas; + + @Override + public GregtechItemList set(Item aItem) { + mHasNotBeenSet = false; + if (aItem == null) return this; + ItemStack aStack = new ItemStack(aItem, 1, 0); + mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public GregtechItemList set(ItemStack aStack) { + mHasNotBeenSet = false; + mStack = GT_Utility.copyAmount(1, aStack); + return this; + } + + @Override + public Item getItem() { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(mStack)) return null; + return mStack.getItem(); + } + + @Override + public Block getBlock() { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + return GT_Utility.getBlockFromStack(getItem()); + } + + @Override + public final boolean hasBeenSet() { + return !mHasNotBeenSet; + } + + @Override + public boolean isStackEqual(Object aStack) { + return isStackEqual(aStack, false, false); + } + + @Override + public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) { + if (GT_Utility.isStackInvalid(aStack)) return false; + return GT_Utility.areUnificationsEqual((ItemStack)aStack, aWildcard?getWildcard(1):get(1), aIgnoreNBT); + } + + @Override + public ItemStack get(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getWildcard(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getUndamaged(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, mStack.getMaxDamage()-1, GT_OreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements) { + ItemStack rStack = get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) return null; + rStack.setStackDisplayName(aDisplayName); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements) { + ItemStack rStack = get(1, aReplacements); + if (GT_Utility.isStackInvalid(rStack)) return null; + GT_ModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); + return GT_Utility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(mStack)); + } + + @Override + public GregtechItemList registerOre(Object... aOreNames) { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, get(1)); + return this; + } + + @Override + public GregtechItemList registerWildcardAsOre(Object... aOreNames) { + if (mHasNotBeenSet) throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, getWildcard(1)); + return this; + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/gregtech/init/InitGregtech.java b/src/Java/miscutil/gregtech/init/InitGregtech.java new file mode 100644 index 0000000000..46e9217f24 --- /dev/null +++ b/src/Java/miscutil/gregtech/init/InitGregtech.java @@ -0,0 +1,23 @@ +package miscutil.gregtech.init; + +import miscutil.core.lib.Strings; +import miscutil.gregtech.init.machines.GregtechEnergyBuffer; +import cpw.mods.fml.common.FMLLog; + +public class InitGregtech { + + public static void run() { + if (Strings.GREGTECH) { + FMLLog.info("MiscUtils|Gregtech5u Content: Registering MetaTileEntities."); + } + + /*** + * Load up Blocks classes + ***/ + + // Machines + // GregtechCobbleGenerator.run(); TODO - Weird Textures + GregtechEnergyBuffer.run(); + + } +} diff --git a/src/Java/miscutil/gregtech/init/machines/GregtechCobbleGenerator.java b/src/Java/miscutil/gregtech/init/machines/GregtechCobbleGenerator.java new file mode 100644 index 0000000000..bb83ea91b2 --- /dev/null +++ b/src/Java/miscutil/gregtech/init/machines/GregtechCobbleGenerator.java @@ -0,0 +1,51 @@ +package miscutil.gregtech.init.machines; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OreDictNames; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import miscutil.core.lib.Strings; +import miscutil.gregtech.enums.GregtechItemList; +import miscutil.gregtech.metatileentity.implementations.GregtechSteelBoiler; +import cpw.mods.fml.common.FMLLog; + +public class GregtechCobbleGenerator +{ + public static void run() + { + if (Strings.GREGTECH){ + FMLLog.info("MiscUtils: Registering Cobblestone Powered Engines."); + } + run1(); + } + + private static void run1() + { + //Cobble Generators + // ItemList.Machine_Steel_Boiler.set(new GT_MetaTileEntity_Boiler_Steel(101, "boiler.steel", "High Pressure Coal Boiler").getStackForm(1L)); + // GT_ModHandler.addCraftingRecipe(ItemList.Machine_Steel_Boiler.get(1L, new Object[0]), GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "PPP", "P P", "BFB", Character.valueOf('F'), OreDictNames.craftingFurnace, Character.valueOf('P'), OrePrefixes.plate.get(Materials.Steel), Character.valueOf('B'), new ItemStack(Blocks.brick_block, 1) }); + + GregtechItemList.Cobble_Generator_ULV.set(new GregtechSteelBoiler(760, "CobGen.01.tier.00", "Ultra Low Voltage Cobblestone Generator", 0, "You're shit.").getStackForm(1L)); + GregtechItemList.Cobble_Generator_LV.set(new GregtechSteelBoiler(761, "CobGen.01.tier.01", "Low Voltage Cobblestone Generator", 1, "Still Pretty garbage, bro.").getStackForm(1L)); + GregtechItemList.Cobble_Generator_MV.set(new GregtechSteelBoiler(762, "CobGen.01.tier.02", "Medium Voltage Cobblestone Generator", 2, "Testy Test.").getStackForm(1L)); + GregtechItemList.Cobble_Generator_HV.set(new GregtechSteelBoiler(763, "CobGen.01.tier.03", "High Voltage Cobblestone Generator", 3, "").getStackForm(1L)); + GregtechItemList.Cobble_Generator_EV.set(new GregtechSteelBoiler(764, "CobGen.01.tier.04", "Extreme Voltage Cobblestone Generator", 4, "").getStackForm(1L)); + GregtechItemList.Cobble_Generator_IV.set(new GregtechSteelBoiler(765, "CobGen.01.tier.05", "Insane Voltage Cobblestone Generator", 5, "").getStackForm(1L)); + GregtechItemList.Cobble_Generator_LuV.set(new GregtechSteelBoiler(766, "CobGen.01.tier.06", "Ludicrous Voltage Cobblestone Generator", 6, "").getStackForm(1L)); + GregtechItemList.Cobble_Generator_ZPM.set(new GregtechSteelBoiler(767, "CobGen.01.tier.07", "ZPM Voltage Cobblestone Generator", 7, "").getStackForm(1L)); + GregtechItemList.Cobble_Generator_UV.set(new GregtechSteelBoiler(768, "CobGen.01.tier.08", "Ultimate Voltage Cobblestone Generator", 8, "").getStackForm(1L)); + GregtechItemList.Cobble_Generator_MAX.set(new GregtechSteelBoiler(769, "CobGen.01.tier.09", "MAX Voltage Cobblestone Generator", 9, "").getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_ULV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_ULV, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Lead), Character.valueOf('T'), OreDictNames.craftingChest }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_LV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_LV, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Tin), Character.valueOf('T'), OreDictNames.craftingChest }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_MV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.AnyCopper), Character.valueOf('T'), OreDictNames.craftingChest }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_HV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Gold), Character.valueOf('T'), OreDictNames.craftingChest }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_EV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Aluminium), Character.valueOf('T'), OreDictNames.craftingChest }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_IV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Tungsten), Character.valueOf('T'), OreDictNames.craftingChest }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_LuV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Osmium), Character.valueOf('T'), OreDictNames.craftingChest }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_ZPM.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_ZPM, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Osmium), Character.valueOf('T'), OreDictNames.craftingChest }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_UV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_UV, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Osmium), Character.valueOf('T'), OreDictNames.craftingChest }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Cobble_Generator_MAX.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_MAX, Character.valueOf('W'), OrePrefixes.wireGt04.get(Materials.Superconductor), Character.valueOf('T'), OreDictNames.craftingChest }); + } +} diff --git a/src/Java/miscutil/gregtech/init/machines/GregtechEnergyBuffer.java b/src/Java/miscutil/gregtech/init/machines/GregtechEnergyBuffer.java new file mode 100644 index 0000000000..8f74f71b69 --- /dev/null +++ b/src/Java/miscutil/gregtech/init/machines/GregtechEnergyBuffer.java @@ -0,0 +1,88 @@ +package miscutil.gregtech.init.machines; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import miscutil.core.creativetabs.TMCreativeTabs; +import miscutil.core.lib.Strings; +import miscutil.gregtech.enums.ExtraOreDictNames; +import miscutil.gregtech.enums.GregtechItemList; +import miscutil.gregtech.metatileentity.implementations.GregtechMetaCreativeEnergyBuffer; +import miscutil.gregtech.metatileentity.implementations.GregtechMetaEnergyBuffer; +import net.minecraft.item.Item; +import net.minecraftforge.oredict.OreDictionary; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; + +public class GregtechEnergyBuffer +{ + + //Misc Items + public static Item itemBufferCore; + + public static void run() + { + if (Strings.GREGTECH){ + FMLLog.info("MiscUtils: Registering Energy Buffer Blocks."); + } + run1(); + } + + @SuppressWarnings("deprecation") + private static void run1() + { + + itemBufferCore = new Item().setUnlocalizedName("itemBufferCore").setCreativeTab(TMCreativeTabs.tabMisc).setTextureName(Strings.MODID + ":itemBufferCore");; + + //Registry + GameRegistry.registerItem(itemBufferCore, "itemBufferCore"); + LanguageRegistry.addName(itemBufferCore, "Buffer Core"); + OreDictionary.registerOre("itemBufferCore", itemBufferCore); + + + //Energy Buffers + GregtechItemList.Energy_Buffer_1by1_ULV.set(new GregtechMetaEnergyBuffer(770, "energybuffer.01.tier.00", "Ultra Low Voltage Energy Buffer", 0, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_LV.set(new GregtechMetaEnergyBuffer(771, "energybuffer.01.tier.01", "Low Voltage Energy Buffer", 1, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_MV.set(new GregtechMetaEnergyBuffer(772, "energybuffer.01.tier.02", "Medium Voltage Energy Buffer", 2, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_HV.set(new GregtechMetaEnergyBuffer(773, "energybuffer.01.tier.03", "High Voltage Energy Buffer", 3, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_EV.set(new GregtechMetaEnergyBuffer(774, "energybuffer.01.tier.04", "Extreme Voltage Energy Buffer", 4, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_IV.set(new GregtechMetaEnergyBuffer(775, "energybuffer.01.tier.05", "Insane Voltage Energy Buffer", 5, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_LuV.set(new GregtechMetaEnergyBuffer(776, "energybuffer.01.tier.06", "Ludicrous Voltage Energy Buffer", 6, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_ZPM.set(new GregtechMetaEnergyBuffer(777, "energybuffer.01.tier.07", "ZPM Voltage Energy Buffer", 7, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_UV.set(new GregtechMetaEnergyBuffer(778, "energybuffer.01.tier.08", "Ultimate Voltage Energy Buffer", 8, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_MAX.set(new GregtechMetaEnergyBuffer(779, "energybuffer.01.tier.09", "MAX Voltage Energy Buffer", 9, "", 1).getStackForm(1L)); + // Creative Buffer Has Special ID + GregtechItemList.Energy_Buffer_CREATIVE + .set(new GregtechMetaCreativeEnergyBuffer(750, + "energybuffer.01.tier.xx", + "512V Creative Energy Buffer", 3, "", 0) + .getStackForm(1L)); + + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_ULV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_ULV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Lead), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_LV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_LV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Tin), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_MV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.AnyCopper), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_HV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Gold), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_EV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Aluminium), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_IV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_IV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Tungsten), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_LuV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_LuV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Osmium), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_ZPM.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_ZPM, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Osmium), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_UV.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_UV, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Osmium), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Energy_Buffer_1by1_MAX.get(1L, new Object[0]), GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "WTW", "WMW", Character.valueOf('M'), ItemList.Hull_MAX, Character.valueOf('W'), OrePrefixes.wireGt08.get(Materials.Superconductor), Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + GT_ModHandler.addCraftingRecipe( + GregtechItemList.Energy_Buffer_1by1_MAX.get(1L, new Object[0]), + GT_ModHandler.RecipeBits.DISMANTLEABLE + | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE + | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { + "WTW", "WMW", Character.valueOf('M'), + ItemList.Hull_MAX, Character.valueOf('W'), + OrePrefixes.wireGt08.get(Materials.Superconductor), + Character.valueOf('T'), ExtraOreDictNames.buffer_core }); + + + + + } +} diff --git a/src/Java/miscutil/gregtech/interfaces/GregtechItemContainer.java b/src/Java/miscutil/gregtech/interfaces/GregtechItemContainer.java new file mode 100644 index 0000000000..e871c19fcf --- /dev/null +++ b/src/Java/miscutil/gregtech/interfaces/GregtechItemContainer.java @@ -0,0 +1,24 @@ +package miscutil.gregtech.interfaces; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public interface GregtechItemContainer { + public Item getItem(); + public Block getBlock(); + public boolean isStackEqual(Object aStack); + public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT); + public ItemStack get(long aAmount, Object... aReplacements); + public ItemStack getWildcard(long aAmount, Object... aReplacements); + public ItemStack getUndamaged(long aAmount, Object... aReplacements); + public ItemStack getAlmostBroken(long aAmount, Object... aReplacements); + public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements); + public GregtechItemContainer set(Item aItem); + public GregtechItemContainer set(ItemStack aStack); + public GregtechItemContainer registerOre(Object... aOreNames); + public GregtechItemContainer registerWildcardAsOre(Object... aOreNames); + public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements); + public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements); + public boolean hasBeenSet(); +}
\ No newline at end of file diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCreativeEnergyBuffer.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCreativeEnergyBuffer.java new file mode 100644 index 0000000000..a176aab00f --- /dev/null +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCreativeEnergyBuffer.java @@ -0,0 +1,261 @@ +package miscutil.gregtech.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.V; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_1by1; +import gregtech.api.gui.GT_Container_2by2; +import gregtech.api.gui.GT_Container_3by3; +import gregtech.api.gui.GT_Container_4by4; +import gregtech.api.gui.GT_GUIContainer_1by1; +import gregtech.api.gui.GT_GUIContainer_2by2; +import gregtech.api.gui.GT_GUIContainer_3by3; +import gregtech.api.gui.GT_GUIContainer_4by4; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import ic2.api.item.IElectricItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * + * This is the main construct for my Basic Machines such as the Automatic Extractor + * Extend this class to make a simple Machine + */ +public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { + + + public GregtechMetaCreativeEnergyBuffer(String aName, int aTier, + String aDescription, ITexture[][][] aTextures, int aSlotCount) { + super(aName, aTier, aDescription, aTextures, aSlotCount); + // TODO Auto-generated constructor stub + } + + public GregtechMetaCreativeEnergyBuffer(int aID, String aName, + String aNameRegional, int aTier, String aDescription, int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); + } + + public boolean mCharge = false, mDecharge = false; + public int mBatteryCount = 1, mChargeableCount = 1; + + /* + * MACHINE_STEEL_SIDE + */ + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[2][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_STEEL_SIDE) }; + rTextures[1][i + 1] = new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_STEEL_SIDE), + mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] + : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, byte aFacing, byte aColorIndex, boolean aActive, + boolean aRedstone) { + return mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaCreativeEnergyBuffer(mName, mTier, mDescription, + mTextures, mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(int aIndex) {return true;} + @Override public boolean isFacingValid(byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isEnetOutput() {return true;} + @Override public boolean isInputFacing(byte aSide) {return aSide!=getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(byte aSide) {return aSide==getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + + @Override + public long getMinimumStoredEU() { + return 1; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUOutput() { + return V[mTier]; + } + + @Override + public long maxAmperesIn() { + return mChargeableCount * 16; + } + + @Override + public long maxAmperesOut() { + return mChargeableCount * 16; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return mCharge?mInventory.length:0;} + @Override public int dechargerSlotCount() {return mDecharge?mInventory.length:0;} + @Override public int getProgresstime() {return Integer.MAX_VALUE;} + @Override public int maxProgresstime() {return (int)getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + // + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + // + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, + IGregTechTileEntity aBaseMetaTileEntity) { + switch (mInventory.length) { + case 1: return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); + case 4: return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); + case 9: return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); + case 16: return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); + } + return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, + IGregTechTileEntity aBaseMetaTileEntity) { + switch (mInventory.length) { + case 1: return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + case 4: return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + case 9: return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + case 16: return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + this.getBaseMetaTileEntity().increaseStoredEnergyUnits(Integer.MAX_VALUE, true); + if (aBaseMetaTileEntity.isServerSide()) { + mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity + .getEUCapacity() / 3; + mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; + mBatteryCount = 1; + mChargeableCount = 1; + this.getBaseMetaTileEntity().increaseStoredEnergyUnits(mMax, true); + for (ItemStack tStack : mInventory) if (GT_ModHandler.isElectricItem(tStack, mTier)) { + if (GT_ModHandler.isChargerItem(tStack)) mBatteryCount++; + mChargeableCount++; + } + } + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if(GT_ModHandler.isElectricItem(aStack)&&aStack.getUnlocalizedName().startsWith("gt.metaitem.01.")){ + String name = aStack.getUnlocalizedName(); + if(name.equals("gt.metaitem.01.32510")|| + name.equals("gt.metaitem.01.32511")|| + name.equals("gt.metaitem.01.32520")|| + name.equals("gt.metaitem.01.32521")|| + name.equals("gt.metaitem.01.32530")|| + name.equals("gt.metaitem.01.32531")){ + return true; + } + } + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if(!GT_Utility.isStackValid(aStack)){ + return false; + } + if(GT_ModHandler.isElectricItem(aStack, this.mTier)){ + return true; + } + return false; + } + + @Override + public long[] getStoredEnergy(){ + long tScale = getBaseMetaTileEntity().getEUCapacity(); + long tStored = getBaseMetaTileEntity().getStoredEU(); + if (mInventory != null) { + for (ItemStack aStack : mInventory) { + if (GT_ModHandler.isElectricItem(aStack)) { + + if (aStack.getItem() instanceof GT_MetaBase_Item) { + Long[] stats = ((GT_MetaBase_Item) aStack.getItem()) + .getElectricStats(aStack); + if (stats != null) { + tScale = tScale + stats[0]; + tStored = tStored + + ((GT_MetaBase_Item) aStack.getItem()) + .getRealCharge(aStack); + } + } else if (aStack.getItem() instanceof IElectricItem) { + tStored = tStored + + (long) ic2.api.item.ElectricItem.manager + .getCharge(aStack); + tScale = tScale + + (long) ((IElectricItem) aStack.getItem()) + .getMaxCharge(aStack); + } + } + } + + } + return new long[] { tStored, tScale }; + } + + private long count=0; + private long mStored=0; + private long mMax=0; + + @Override + public String[] getInfoData() { + count++; + if(mMax==0||count%20==0){ + long[] tmp = getStoredEnergy(); + mStored=tmp[0]; + mMax=tmp[1]; + } + + return new String[] { + getLocalName(), + "Stored Items:", + GT_Utility.formatNumbers(mStored)+" EU /", + GT_Utility.formatNumbers(mMax)+" EU"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaEnergyBuffer.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaEnergyBuffer.java new file mode 100644 index 0000000000..46add14c15 --- /dev/null +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaEnergyBuffer.java @@ -0,0 +1,401 @@ +package miscutil.gregtech.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.V; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_1by1; +import gregtech.api.gui.GT_Container_2by2; +import gregtech.api.gui.GT_Container_3by3; +import gregtech.api.gui.GT_Container_4by4; +import gregtech.api.gui.GT_GUIContainer_1by1; +import gregtech.api.gui.GT_GUIContainer_2by2; +import gregtech.api.gui.GT_GUIContainer_3by3; +import gregtech.api.gui.GT_GUIContainer_4by4; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import ic2.api.item.IElectricItem; +import miscutil.core.handler.GuiHandler; +import miscutil.core.util.Utils; +import miscutil.gregtech.util.IMessage; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * + * This is the main construct for my Basic Machines such as the Automatic Extractor + * Extend this class to make a simple Machine + */ +public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { + + /* + * public GregtechMetaEnergyBuffer() { super.this + * setCreativeTab(GregTech_API.TAB_GREGTECH); } + */ + + public boolean mCharge = false, mDecharge = false; + public int mBatteryCount = 1, mChargeableCount = 1; + + public GregtechMetaEnergyBuffer(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { + super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); + } + + public GregtechMetaEnergyBuffer(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { + super(aName, aTier, aSlotCount, aDescription, aTextures); + } + + @Override + public String[] getDescription() { + return new String[] {mDescription, mInventory.length + " Slots"}; + } + + /* + * MACHINE_STEEL_SIDE + */ + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[2][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_CASING_FROST_PROOF) }; + rTextures[1][i + 1] = new ITexture[] { + new GT_RenderedTexture( + Textures.BlockIcons.MACHINE_CASING_FROST_PROOF), + mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] + : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; + } + return rTextures; + } + + /* + * @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { + * ITexture[][][] rTextures = new ITexture[5][17][]; for (byte i = -1; i < + * 16; i = (byte) (i + 1)) { ITexture[] tmp0 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)) }; rTextures[0][(i + 1)] = tmp0; ITexture[] tmp1 = { + * new GT_RenderedTexture( Textures.BlockIcons.MACHINE_STEEL_TOP) }; + * rTextures[1][(i + 1)] = tmp1; ITexture[] tmp2 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)), new + * GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; rTextures[2][(i + + * 1)] = tmp2; ITexture[] tmp4 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)), new + * GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; rTextures[3][(i + + * 1)] = tmp4; ITexture[] tmp5 = { new GT_RenderedTexture( + * Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, + * Dyes._NULL.mRGBa)), new GT_RenderedTexture( + * Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; rTextures[4][(i + 1)] = tmp5; + * } return rTextures; } + */ + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1]; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaEnergyBuffer(mName, mTier, mDescription, mTextures, mInventory.length); + } + + @Override public boolean isSimpleMachine() {return false;} + @Override public boolean isElectric() {return true;} + @Override public boolean isValidSlot(int aIndex) {return true;} + @Override public boolean isFacingValid(byte aFacing) {return true;} + @Override public boolean isEnetInput() {return true;} + @Override public boolean isEnetOutput() {return true;} + @Override public boolean isInputFacing(byte aSide) {return aSide!=getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isOutputFacing(byte aSide) {return aSide==getBaseMetaTileEntity().getFrontFacing();} + @Override public boolean isTeleporterCompatible() {return false;} + @Override public long getMinimumStoredEU() {return V[mTier]*16*mInventory.length;} + @Override public long maxEUStore() {return V[mTier]*250000;} + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUOutput() { + return V[mTier]; + } + + @Override + public long maxAmperesIn() { + return mChargeableCount * 4; + } + + @Override + public long maxAmperesOut() { + return mChargeableCount * 4; + } + @Override public int rechargerSlotStartIndex() {return 0;} + @Override public int dechargerSlotStartIndex() {return 0;} + @Override public int rechargerSlotCount() {return mCharge?mInventory.length:0;} + @Override public int dechargerSlotCount() {return mDecharge?mInventory.length:0;} + @Override public int getProgresstime() {return (int)getBaseMetaTileEntity().getUniversalEnergyStored();} + @Override public int maxProgresstime() {return (int)getBaseMetaTileEntity().getUniversalEnergyCapacity();} + @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + // + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + // + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + Utils.LOG_WARNING("Right Click on MTE by Player"); + if (aBaseMetaTileEntity.isClientSide()) return true; + //aBaseMetaTileEntity.openGUI(aPlayer); + + Utils.LOG_WARNING("MTE is Client-side"); + showEnergy(aPlayer.getEntityWorld(), aPlayer); + return true; + } + + private void showEnergy(World worldIn, EntityPlayer playerIn){ + Utils.LOG_WARNING("Begin Show Energy"); + final double c = ((double) getProgresstime() / maxProgresstime()) * 100; + Utils.LOG_WARNING(""+c); + final double roundOff = Math.round(c * 100.0) / 100.0; + IMessage.messageThePlayer("Energy: " + getProgresstime() + " EU at "+V[mTier]+"v ("+roundOff+"%)"); + Utils.LOG_WARNING("Making new instance of Guihandler"); + GuiHandler block = new GuiHandler(); + Utils.LOG_WARNING("Guihandler.toString(): "+block.toString()); + block.getClientGuiElement(1, playerIn, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ); + + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, + IGregTechTileEntity aBaseMetaTileEntity) { + switch (mInventory.length) { + case 1: return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); + case 4: return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); + case 9: return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); + case 16: return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); + } + return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, + IGregTechTileEntity aBaseMetaTileEntity) { + switch (mInventory.length) { + case 1: return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + case 4: return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + case 9: return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + case 16: return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity + .getEUCapacity() / 3; + mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; + mBatteryCount = 1; + mChargeableCount = 1; + for (ItemStack tStack : mInventory) if (GT_ModHandler.isElectricItem(tStack, mTier)) { + if (GT_ModHandler.isChargerItem(tStack)) mBatteryCount++; + mChargeableCount++; + } + } + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if(GT_ModHandler.isElectricItem(aStack)&&aStack.getUnlocalizedName().startsWith("gt.metaitem.01.")){ + String name = aStack.getUnlocalizedName(); + if(name.equals("gt.metaitem.01.32510")|| + name.equals("gt.metaitem.01.32511")|| + name.equals("gt.metaitem.01.32520")|| + name.equals("gt.metaitem.01.32521")|| + name.equals("gt.metaitem.01.32530")|| + name.equals("gt.metaitem.01.32531")){ + return true; + } + } + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if(!GT_Utility.isStackValid(aStack)){ + return false; + } + if(GT_ModHandler.isElectricItem(aStack, this.mTier)){ + return true; + } + return false; + } + + public long[] getStoredEnergy(){ + long tScale = getBaseMetaTileEntity().getEUCapacity(); + long tStored = getBaseMetaTileEntity().getStoredEU(); + if (mInventory != null) { + for (ItemStack aStack : mInventory) { + if (GT_ModHandler.isElectricItem(aStack)) { + + if (aStack.getItem() instanceof GT_MetaBase_Item) { + Long[] stats = ((GT_MetaBase_Item) aStack.getItem()) + .getElectricStats(aStack); + if (stats != null) { + tScale = tScale + stats[0]; + tStored = tStored + + ((GT_MetaBase_Item) aStack.getItem()) + .getRealCharge(aStack); + } + } else if (aStack.getItem() instanceof IElectricItem) { + tStored = tStored + + (long) ic2.api.item.ElectricItem.manager + .getCharge(aStack); + tScale = tScale + + (long) ((IElectricItem) aStack.getItem()) + .getMaxCharge(aStack); + } + } + } + + } + return new long[] { tStored, tScale }; + } + + private long count=0; + private long mStored=0; + private long mMax=0; + + @Override + public String[] getInfoData() { + count++; + if(mMax==0||count%20==0){ + long[] tmp = getStoredEnergy(); + mStored=tmp[0]; + mMax=tmp[1]; + } + + return new String[] { + getLocalName(), + "Stored Items:", + GT_Utility.formatNumbers(mStored)+" EU /", + GT_Utility.formatNumbers(mMax)+" EU"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, + int p_102007_3_) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, + int p_102008_3_) { + // TODO Auto-generated method stub + return false; + } + + @Override + public int getSizeInventory() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public ItemStack getStackInSlot(int p_70301_1_) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + // TODO Auto-generated method stub + + } + + @Override + public String getInventoryName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean hasCustomInventoryName() { + // TODO Auto-generated method stub + return false; + } + + @Override + public int getInventoryStackLimit() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void markDirty() { + // TODO Auto-generated method stub + + } + + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void openInventory() { + // TODO Auto-generated method stub + + } + + @Override + public void closeInventory() { + // TODO Auto-generated method stub + + } + + @Override + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + // TODO Auto-generated method stub + return false; + } +}
\ No newline at end of file diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaTileEntity.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaTileEntity.java new file mode 100644 index 0000000000..c95c7ba75a --- /dev/null +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaTileEntity.java @@ -0,0 +1,65 @@ +package miscutil.gregtech.metatileentity.implementations; + +import static gregtech.api.enums.GT_Values.GT; +import gregtech.api.interfaces.ITexture; +import gregtech.api.metatileentity.MetaTileEntity; + +public abstract class GregtechMetaTileEntity extends MetaTileEntity { + /** + * Value between [0 - 9] to describe the Tier of this Machine. + */ + public final byte mTier; + + /** + * A simple Description. + */ + public final String mDescription; + + /** + * Contains all Textures used by this Block. + */ + public final ITexture[][][] mTextures; + + public GregtechMetaTileEntity(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aInvSlotCount); + mTier = (byte)Math.max(0, Math.min(aTier, 9)); + mDescription = aDescription; + + // must always be the last call! + if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null; + } + + public GregtechMetaTileEntity(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aInvSlotCount); + mTier = (byte)aTier; + mDescription = aDescription; + mTextures = aTextures; + } + + @Override + public byte getTileEntityBaseType() { + return (byte)(Math.min(3, mTier<=0?0:1+((mTier-1) / 4))); + } + + @Override + public long getInputTier() { + return mTier; + } + + @Override + public long getOutputTier() { + return mTier; + } + + @Override + public String[] getDescription() { + return new String[] {mDescription}; + } + + /** + * Used Client Side to get a Texture Set for this Block. + * Called after setting the Tier and the Description so that those two are accessible. + * @param aTextures is the optional Array you can give to the Constructor. + */ + public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); +}
\ No newline at end of file diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechSteelBoiler.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechSteelBoiler.java new file mode 100644 index 0000000000..45b6fa5f86 --- /dev/null +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechSteelBoiler.java @@ -0,0 +1,290 @@ +package miscutil.gregtech.metatileentity.implementations; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.gui.GT_Container_Boiler; +import gregtech.common.gui.GT_GUIContainer_Boiler; +import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +public class GregtechSteelBoiler + extends GT_MetaTileEntity_Boiler +{ + public GregtechSteelBoiler(int aID, String aName, String aNameRegional, int aTier, String aDescription) + { + super(aID, aName, aNameRegional, "Put it to good use!", new ITexture[0]); + } + + public GregtechSteelBoiler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) + { + super(aName, aTier, aDescription, aTextures); + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) + { + ITexture[][][] rTextures = new ITexture[5][17][]; + for (byte i = -1; i < 16; i = (byte)(i + 1)) + {ITexture[] tmp0 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa)) }; + rTextures[0][(i + 1)] = tmp0; + ITexture[] tmp1 ={ new GT_RenderedTexture(Textures.BlockIcons.STEAM_TURBINE_SIDE)}; +rTextures[1][(i + 1)] = tmp1; + ITexture[] tmp2 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; +rTextures[2][(i + 1)] = tmp2; + ITexture[] tmp4 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT) }; +rTextures[3][(i + 1)] = tmp4; + ITexture[] tmp5 ={ new GT_RenderedTexture(Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_FRONT_ACTIVE) }; +rTextures[4][(i + 1)] = tmp5; + } + return rTextures; + } + + public int maxProgresstime() + { + return 1000; + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 32000); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) + { + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) + { + return new GregtechSteelBoiler(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) + { + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) + { + if (this.mTemperature <= 20) + { + this.mTemperature = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 40) + { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) { + if (i != aBaseMetaTileEntity.getFrontFacing()) + { + IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) + { + FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) + { + int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); + } + } + } + } + } + if (aTick % 10L == 0L) { + if (this.mTemperature > 100) + { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) + { + this.mHadNoWater = true; + } + else + { + if (this.mHadNoWater) + { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(150L); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += 150; + } else { + this.mSteam = GT_ModHandler.getSteam(150L); + } + } + } + else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && + (this.mSteam.amount > 32000)) + { + sendSound((byte)1); + this.mSteam.amount = 24000; + } + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && + (this.mInventory[2] != null)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal)))) + { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Charcoal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Charcoal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Charcoal)))) + { + this.mProcessingEnergy += 160; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } + else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke")) + { + this.mProcessingEnergy += 640; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(2) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); + } + } + else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite)))) + { + this.mProcessingEnergy += 40; + aBaseMetaTileEntity.decrStackSize(2, 1); + if (aBaseMetaTileEntity.getRandomNumber(8) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); + } + } + } + if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) + { + this.mProcessingEnergy -= 2; + this.mTemperature += 1; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } + +@Override +public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + // TODO Auto-generated method stub + return null; +} + +@Override +public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, + int p_102007_3_) { + // TODO Auto-generated method stub + return false; +} + +@Override +public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, + int p_102008_3_) { + // TODO Auto-generated method stub + return false; +} + +@Override +public int getSizeInventory() { + // TODO Auto-generated method stub + return 0; +} + +@Override +public ItemStack getStackInSlot(int p_70301_1_) { + // TODO Auto-generated method stub + return null; +} + +@Override +public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + // TODO Auto-generated method stub + return null; +} + +@Override +public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + // TODO Auto-generated method stub + return null; +} + +@Override +public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + // TODO Auto-generated method stub + +} + +@Override +public String getInventoryName() { + // TODO Auto-generated method stub + return null; +} + +@Override +public boolean hasCustomInventoryName() { + // TODO Auto-generated method stub + return false; +} + +@Override +public int getInventoryStackLimit() { + // TODO Auto-generated method stub + return 0; +} + +@Override +public void markDirty() { + // TODO Auto-generated method stub + +} + +@Override +public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + // TODO Auto-generated method stub + return false; +} + +@Override +public void openInventory() { + // TODO Auto-generated method stub + +} + +@Override +public void closeInventory() { + // TODO Auto-generated method stub + +} + +@Override +public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + // TODO Auto-generated method stub + return false; +} +} + + + +/* Location: F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar + + * Qualified Name: gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler_Steel + + * JD-Core Version: 0.7.0.1 + + */
\ No newline at end of file diff --git a/src/Java/miscutil/gregtech/util/IMessage.java b/src/Java/miscutil/gregtech/util/IMessage.java new file mode 100644 index 0000000000..8891e2adde --- /dev/null +++ b/src/Java/miscutil/gregtech/util/IMessage.java @@ -0,0 +1,21 @@ +package miscutil.gregtech.util; + +import net.minecraft.client.Minecraft; +import net.minecraft.util.ChatComponentText; + +public class IMessage { + + public static void messageThePlayer(String s){ + if(Minecraft.getMinecraft().thePlayer.worldObj.isRemote){ + Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(s)); + } + else if(!Minecraft.getMinecraft().thePlayer.worldObj.isRemote){ + Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(s)); + } + } + + public void messageOtherPlayer(String s){ + Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText(s)); + } + +} diff --git a/src/Java/miscutil/gregtech/util/VanillaChatCommandSender.java b/src/Java/miscutil/gregtech/util/VanillaChatCommandSender.java new file mode 100644 index 0000000000..ee77211b21 --- /dev/null +++ b/src/Java/miscutil/gregtech/util/VanillaChatCommandSender.java @@ -0,0 +1,35 @@ +package miscutil.gregtech.util; + +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; + +public interface VanillaChatCommandSender { + + /** + * Gets the name of this command sender (usually username, but possibly "Rcon") + */ + String getCommandSenderName(); + + IChatComponent func_145748_c_(); + + /** + * Notifies this sender of some sort of information. This is for messages intended to display to the user. Used + * for typical output (like "you asked for whether or not this game rule is set, so here's your answer"), warnings + * (like "I fetched this block for you by ID, but I'd like you to know that every time you do this, I die a little + * inside"), and errors (like "it's not called iron_pixacke, silly"). + */ + void addChatMessage(IChatComponent p_145747_1_); + + /** + * Returns true if the command sender is allowed to use the given command. + */ + boolean canCommandSenderUseCommand(int p_70003_1_, String p_70003_2_); + + /** + * Return the position for this command sender. + */ + ChunkCoordinates getPlayerCoordinates(); + + World getEntityWorld(); + } |