From c2e61a2ef68edd85589e52932a48b990b2f06e0f Mon Sep 17 00:00:00 2001 From: SoundLogic Date: Wed, 20 Aug 2014 14:53:02 -0500 Subject: [PATCH] Initial Commit --- src/main/java/tconstruct/TConstruct.java | 4 ++++ .../api/IPlayerExtendedInventoryWrapper.java | 10 ++++++++++ src/main/java/tconstruct/api/TConstructAPI.java | 13 +++++++++++++ .../tconstruct/armor/player/TPlayerStats.java | 16 +++++++++++++++- 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/main/java/tconstruct/api/IPlayerExtendedInventoryWrapper.java create mode 100644 src/main/java/tconstruct/api/TConstructAPI.java diff --git a/src/main/java/tconstruct/TConstruct.java b/src/main/java/tconstruct/TConstruct.java index 3f7273d1..ca6c3dd0 100644 --- a/src/main/java/tconstruct/TConstruct.java +++ b/src/main/java/tconstruct/TConstruct.java @@ -25,8 +25,10 @@ import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; import mantle.pulsar.config.ForgeCFG; import mantle.pulsar.control.PulseManager; +import tconstruct.api.TConstructAPI; import tconstruct.armor.TinkerArmor; import tconstruct.armor.player.TPlayerHandler; +import tconstruct.armor.player.TPlayerStats; import tconstruct.client.TControls; import tconstruct.common.TConstructCreativeTab; import tconstruct.common.TProxyCommon; @@ -170,6 +172,8 @@ public class TConstruct MapGenStructureIO.func_143031_a(ComponentToolWorkshop.class, "TConstruct:ToolWorkshopStructure"); MapGenStructureIO.func_143031_a(ComponentSmeltery.class, "TConstruct:SmelteryStructure"); } + + TConstructAPI.PROP_NAME=TPlayerStats.PROP_NAME; } @EventHandler diff --git a/src/main/java/tconstruct/api/IPlayerExtendedInventoryWrapper.java b/src/main/java/tconstruct/api/IPlayerExtendedInventoryWrapper.java new file mode 100644 index 00000000..8e9cd5e1 --- /dev/null +++ b/src/main/java/tconstruct/api/IPlayerExtendedInventoryWrapper.java @@ -0,0 +1,10 @@ +package tconstruct.api; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; + +public interface IPlayerExtendedInventoryWrapper +{ + public IInventory getKnapsackInventory(EntityPlayer player); + public IInventory getAccessoryInventory(EntityPlayer player); +} diff --git a/src/main/java/tconstruct/api/TConstructAPI.java b/src/main/java/tconstruct/api/TConstructAPI.java new file mode 100644 index 00000000..8d1dbcff --- /dev/null +++ b/src/main/java/tconstruct/api/TConstructAPI.java @@ -0,0 +1,13 @@ +package tconstruct.api; + +import net.minecraft.entity.player.EntityPlayer; + +public class TConstructAPI +{ + public static String PROP_NAME; + + public static IPlayerExtendedInventoryWrapper getInventoryWrapper(EntityPlayer player) + { + return (IPlayerExtendedInventoryWrapper) player.getExtendedProperties(PROP_NAME); + } +} diff --git a/src/main/java/tconstruct/armor/player/TPlayerStats.java b/src/main/java/tconstruct/armor/player/TPlayerStats.java index 224b19a5..682d59e6 100644 --- a/src/main/java/tconstruct/armor/player/TPlayerStats.java +++ b/src/main/java/tconstruct/armor/player/TPlayerStats.java @@ -2,13 +2,15 @@ package tconstruct.armor.player; import java.lang.ref.WeakReference; +import tconstruct.api.IPlayerExtendedInventoryWrapper; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties; -public class TPlayerStats implements IExtendedEntityProperties //TODO: IExtendedEntityProperties is not appropriate! +public class TPlayerStats implements IExtendedEntityProperties, IPlayerExtendedInventoryWrapper //TODO: IExtendedEntityProperties is not appropriate! { public static final String PROP_NAME = "TConstruct"; @@ -104,4 +106,16 @@ public class TPlayerStats implements IExtendedEntityProperties //TODO: IExtended return (TPlayerStats) player.getExtendedProperties(PROP_NAME); } + @Override + public IInventory getKnapsackInventory(EntityPlayer player) + { + return this.knapsack; + } + + @Override + public IInventory getAccessoryInventory(EntityPlayer player) + { + return this.armor; + } + }