From 11e81b501260a94bff6dac0cc699f6928c8fbb52 Mon Sep 17 00:00:00 2001 From: Lance5057 Date: Wed, 25 Feb 2015 01:27:53 -0600 Subject: Fixing some things --- .../gmail/Lance5057/com/mod_TinkersDefense.java | 12 +++-- .../Lance5057/containers/Container_CrestMount.java | 25 +-------- .../Lance5057/network/Message_CrestMount.java | 56 ++++++++------------- .../java/gmail/Lance5057/proxy/ClientProxy.java | 8 +++ .../java/gmail/Lance5057/proxy/CommonProxy.java | 5 ++ .../tileentities/TileEntity_CrestMount.java | 15 +++--- .../textures/items/Crest_feather.png | Bin 0 -> 359 bytes .../textures/items/Crest_triangles.png | Bin 0 -> 233 bytes src/main/resources/mcmod.info | 24 +++++---- 9 files changed, 64 insertions(+), 81 deletions(-) create mode 100644 src/main/resources/assets/tinkersdefense/textures/items/Crest_feather.png create mode 100644 src/main/resources/assets/tinkersdefense/textures/items/Crest_triangles.png (limited to 'src/main') diff --git a/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java b/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java index 1c90437..232b314 100644 --- a/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java +++ b/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java @@ -212,6 +212,9 @@ public void preInit(FMLPreInitializationEvent e) //item_TinkerArmor = new TinkerArmor(ArmorMaterial.IRON, 4, 1).setUnlocalizedName("Tinker_Armor"); //GameRegistry.registerItem(item_TinkerArmor,"Tinker Armor"); + + +//network.registerMessage(messageHandler, requestMessageType, discriminator, side); } @EventHandler @@ -228,11 +231,14 @@ public void init(FMLInitializationEvent e) { System.out.print(MODID); PatternBuilder pb = PatternBuilder.instance; + + //Aeonsteel pb.registerMaterialSet("AeonSteel", new ItemStack(TinkerTools.toolShard, 1, 10), new ItemStack(TinkerTools.toolRod, 1, 10), 10); - // Tool Materials: id, name, harvestlevel, durability, speed, damage, handlemodifier, reinforced, shoddy, style color, primary color for block use - //Aeonsteel + TConstructClientRegistry.addMaterialRenderMapping(201, "tinker", "aeonsteel", true); - TConstructRegistry.addToolMaterial(201, "AeonSteel", 4, 822, 1100, 3, 1.6F, 2, 0f, LIGHT_PURPLE.toString(), 0xb565e6); + + // Tool Materials: id, name, harvestlevel, durability, speed, damage, handlemodifier, reinforced, shoddy, style color, primary color for block use + TConstructRegistry.addToolMaterial(201, "AeonSteel", 4, 822, 1100, 3, 1.6F, 2, 0f, LIGHT_PURPLE.toString(), 0xb565e6); TinkerTools.registerPatternMaterial("AeonSteelIngot", 2, "AeonSteel"); TConstructRegistry.addDefaultToolPartMaterial(201); diff --git a/src/main/java/gmail/Lance5057/containers/Container_CrestMount.java b/src/main/java/gmail/Lance5057/containers/Container_CrestMount.java index 46ece0b..5dd4f19 100644 --- a/src/main/java/gmail/Lance5057/containers/Container_CrestMount.java +++ b/src/main/java/gmail/Lance5057/containers/Container_CrestMount.java @@ -19,31 +19,12 @@ public class Container_CrestMount extends Container this.inventory = TileEntity_CrestMount; int i; - - // ITEM INVENTORY - you'll need to adjust the slot locations to match your texture file - // I have them set vertically in columns of 4 to the right of the player model + for (i = 0; i < TileEntity_CrestMount.invSize; ++i) { - // You can make a custom Slot if you need different behavior, - // such as only certain item types can be put into this slot - // We made a custom slot to prevent our inventory-storing item - // from being stored within itself, but if you want to allow that and - // you followed my advice at the end of the above step, then you - // could get away with using the vanilla Slot class this.addSlotToContainer(new Slot(this.inventory, i, 80 + (18 * (int)(i/4)), 8 + (18*(i%4)))); } - // If you want, you can add ARMOR SLOTS here as well, but you need to - // make a public version of SlotArmor. I won't be doing that in this tutorial. - /* - for (i = 0; i < 4; ++i) - { - // These are the standard positions for survival inventory layout - this.addSlotToContainer(new SlotArmor(this.player, inventoryPlayer, inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, i)); - } - */ - - // PLAYER INVENTORY - uses default locations for standard inventory texture file for (i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) @@ -52,7 +33,6 @@ public class Container_CrestMount extends Container } } - // PLAYER ACTION BAR - uses default locations for standard action bar texture file for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); @@ -61,8 +41,7 @@ public class Container_CrestMount extends Container @Override public boolean canInteractWith(EntityPlayer player) { - // be sure to return the inventory's isUseableByPlayer method - // if you defined special behavior there: + return inventory.isUseableByPlayer(player); } diff --git a/src/main/java/gmail/Lance5057/network/Message_CrestMount.java b/src/main/java/gmail/Lance5057/network/Message_CrestMount.java index f556a31..f9567b5 100644 --- a/src/main/java/gmail/Lance5057/network/Message_CrestMount.java +++ b/src/main/java/gmail/Lance5057/network/Message_CrestMount.java @@ -1,57 +1,43 @@ package gmail.Lance5057.network; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import gmail.Lance5057.com.mod_TinkersDefense; import gmail.Lance5057.tileentities.TileEntity_CrestMount; import io.netty.buffer.ByteBuf; import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; public class Message_CrestMount implements IMessage -{ - public int x,y,z; - public int[] inv; +{ + private int id; Message_CrestMount() {} - Message_CrestMount(TileEntity_CrestMount te) + Message_CrestMount(int id) { - this.x = te.xCoord; - this.y = te.yCoord; - this.z = te.zCoord; - - inv = new int[te.invSize*3]; - for(int i = 0; i + { + @Override + public IMessage onMessage(Message_CrestMount message, MessageContext ctx) + { + EntityPlayer player = mod_TinkersDefense.proxy.getPlayerEntity(ctx); + player.openGui(mod_TinkersDefense.instance, message.id, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); + return null; + } +} } diff --git a/src/main/java/gmail/Lance5057/proxy/ClientProxy.java b/src/main/java/gmail/Lance5057/proxy/ClientProxy.java index 7c78794..c3c6afe 100644 --- a/src/main/java/gmail/Lance5057/proxy/ClientProxy.java +++ b/src/main/java/gmail/Lance5057/proxy/ClientProxy.java @@ -5,12 +5,14 @@ import gmail.Lance5057.containers.Container_CrestMount; import gmail.Lance5057.gui.Gui_CrestMount; import gmail.Lance5057.items.ModelTinkerArmor; import gmail.Lance5057.tileentities.TileEntity_CrestMount; +import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; public class ClientProxy extends CommonProxy @@ -33,4 +35,10 @@ public class ClientProxy extends CommonProxy } return tutChest; //default, if whenever you should have passed on a wrong id } + + @Override + public EntityPlayer getPlayerEntity(MessageContext ctx) + { + return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx)); + } } \ No newline at end of file diff --git a/src/main/java/gmail/Lance5057/proxy/CommonProxy.java b/src/main/java/gmail/Lance5057/proxy/CommonProxy.java index 2171029..3f82087 100644 --- a/src/main/java/gmail/Lance5057/proxy/CommonProxy.java +++ b/src/main/java/gmail/Lance5057/proxy/CommonProxy.java @@ -8,6 +8,7 @@ import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; public class CommonProxy implements IGuiHandler { @@ -21,6 +22,10 @@ public class CommonProxy implements IGuiHandler { } + public EntityPlayer getPlayerEntity(MessageContext ctx) { + return ctx.getServerHandler().playerEntity; + } + public ModelBiped getArmorModel(int id) { return null; diff --git a/src/main/java/gmail/Lance5057/tileentities/TileEntity_CrestMount.java b/src/main/java/gmail/Lance5057/tileentities/TileEntity_CrestMount.java index 924d982..505e3be 100644 --- a/src/main/java/gmail/Lance5057/tileentities/TileEntity_CrestMount.java +++ b/src/main/java/gmail/Lance5057/tileentities/TileEntity_CrestMount.java @@ -14,7 +14,6 @@ public class TileEntity_CrestMount extends TileEntity implements IInventory private final String name = "Crest Inventory"; - private final String tagName = "Crest InvTag"; @Override public int getSizeInventory() { @@ -108,9 +107,10 @@ public class TileEntity_CrestMount extends TileEntity implements IInventory return true; } - + @Override public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); NBTTagList items = new NBTTagList(); for (int i = 0; i < getSizeInventory(); ++i) @@ -123,19 +123,16 @@ public class TileEntity_CrestMount extends TileEntity implements IInventory items.appendTag(item); } } - - // We're storing our items in a custom tag list using our 'tagName' from above - // to prevent potential conflicts - compound.setTag(tagName, items); + compound.setTag("Items", items); } + @Override public void readFromNBT(NBTTagCompound compound) { - // now you must include the NBTBase type ID when getting the list; NBTTagCompound's ID is 10 - NBTTagList items = compound.getTagList(tagName, compound.getId()); + super.readFromNBT(compound); + NBTTagList items = compound.getTagList("Items", compound.getId()); for (int i = 0; i < items.tagCount(); ++i) { - // tagAt(int) has changed to getCompoundTagAt(int) NBTTagCompound item = items.getCompoundTagAt(i); byte slot = item.getByte("Slot"); diff --git a/src/main/resources/assets/tinkersdefense/textures/items/Crest_feather.png b/src/main/resources/assets/tinkersdefense/textures/items/Crest_feather.png new file mode 100644 index 0000000..09fb62c Binary files /dev/null and b/src/main/resources/assets/tinkersdefense/textures/items/Crest_feather.png differ diff --git a/src/main/resources/assets/tinkersdefense/textures/items/Crest_triangles.png b/src/main/resources/assets/tinkersdefense/textures/items/Crest_triangles.png new file mode 100644 index 0000000..e4c1d10 Binary files /dev/null and b/src/main/resources/assets/tinkersdefense/textures/items/Crest_triangles.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index f989c30..f480667 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,14 +1,16 @@ [ { -"modid": "tinkersdefense", -"name": "Tinkers' Defense", -"description": "An inbetween mod for Tinkers Construct and Mine and Blade 2 that adds new shields made using tinker parts", -"version": "1.0", -"mcversion": "1.7.10", -"url": "", -"authorList": ["Sir Lance"], -"requiredMods": [ "Forge", "TConstruct","battlegear2" ], -"dependencies": ["TConstruct","battlegear2"], -"useDependencyInformation": "true" + "modid": "examplemod", + "name": "Example Mod", + "description": "Example placeholder mod.", + "version": "${version}", + "mcversion": "${mcversion}", + "url": "", + "updateUrl": "", + "authorList": ["ExampleDude"], + "credits": "The Forge and FML guys, for making this example", + "logoFile": "", + "screenshots": [], + "dependencies": [] } -] \ No newline at end of file +] -- cgit v1.2.3