diff --git a/.gradle/1.10/taskArtifacts/cache.properties b/.gradle/1.10/taskArtifacts/cache.properties index 824ce11..c23772e 100644 --- a/.gradle/1.10/taskArtifacts/cache.properties +++ b/.gradle/1.10/taskArtifacts/cache.properties @@ -1 +1 @@ -#Mon Mar 31 07:47:27 CAT 2014 +#Sat Mar 08 11:07:02 CAT 2014 diff --git a/.gradle/1.10/taskArtifacts/cache.properties.lock b/.gradle/1.10/taskArtifacts/cache.properties.lock index 2994abb..02afcd3 100644 Binary files a/.gradle/1.10/taskArtifacts/cache.properties.lock and b/.gradle/1.10/taskArtifacts/cache.properties.lock differ diff --git a/.gradle/1.10/taskArtifacts/fileHashes.bin b/.gradle/1.10/taskArtifacts/fileHashes.bin index fc14827..a66af6d 100644 Binary files a/.gradle/1.10/taskArtifacts/fileHashes.bin and b/.gradle/1.10/taskArtifacts/fileHashes.bin differ diff --git a/.gradle/1.10/taskArtifacts/fileSnapshots.bin b/.gradle/1.10/taskArtifacts/fileSnapshots.bin index a21bf55..fcc6285 100644 Binary files a/.gradle/1.10/taskArtifacts/fileSnapshots.bin and b/.gradle/1.10/taskArtifacts/fileSnapshots.bin differ diff --git a/.gradle/1.10/taskArtifacts/outputFileStates.bin b/.gradle/1.10/taskArtifacts/outputFileStates.bin index d8a0205..e19d298 100644 Binary files a/.gradle/1.10/taskArtifacts/outputFileStates.bin and b/.gradle/1.10/taskArtifacts/outputFileStates.bin differ diff --git a/.gradle/1.10/taskArtifacts/taskArtifacts.bin b/.gradle/1.10/taskArtifacts/taskArtifacts.bin index 26e35c5..5df57ee 100644 Binary files a/.gradle/1.10/taskArtifacts/taskArtifacts.bin and b/.gradle/1.10/taskArtifacts/taskArtifacts.bin differ diff --git a/README.md b/README.md index a1ead04..2f88a1d 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,4 @@ A mod api that adds 4 bauble slots to the players inventory. The mod has no real content - the idea is that other mods will use this one and its API to add their own baubles. The 4 slots added are an amulet, belt and 2 ring slots. + diff --git a/src/main/java/baubles/api/BaublesApi.java b/src/main/java/baubles/api/BaublesApi.java index 92d620d..ca94fcd 100644 --- a/src/main/java/baubles/api/BaublesApi.java +++ b/src/main/java/baubles/api/BaublesApi.java @@ -1,14 +1,34 @@ package baubles.api; +import java.lang.reflect.Method; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import cpw.mods.fml.common.FMLLog; + /** * @author Azanor - * - * - * */ public class BaublesApi { + static Method getBaubles; + /** + * Retrieves the baubles inventory for the supplied player + */ + public static IInventory getBaubles(EntityPlayer player) { + IInventory ot = null; + try { + if(getBaubles == null) { + Class fake = Class.forName("baubles.common.lib.PlayerHandler"); + getBaubles = fake.getMethod("getPlayerBaubles", EntityPlayer.class); + } + ot = (IInventory) getBaubles.invoke(null, player); + } catch(Exception ex) { + FMLLog.warning("[Baubles API] Could not invoke baubles.common.lib.PlayerHandler method getPlayerBaubles"); + } + return ot; + } } diff --git a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java index a503c28..4702b32 100644 --- a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java +++ b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java @@ -3,7 +3,6 @@ package baubles.client.gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.achievement.GuiAchievements; import net.minecraft.client.gui.achievement.GuiStats; -import net.minecraft.client.gui.inventory.GuiContainerCreative; import net.minecraft.client.renderer.InventoryEffectRenderer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; @@ -45,10 +44,10 @@ public class GuiPlayerExpanded extends InventoryEffectRenderer { @Override public void updateScreen() { - if (this.mc.playerController.isInCreativeMode()) - { - this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); - } +// if (this.mc.playerController.isInCreativeMode()) +// { +// this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); +// } } /** @@ -59,14 +58,14 @@ public class GuiPlayerExpanded extends InventoryEffectRenderer { { this.buttonList.clear(); - if (this.mc.playerController.isInCreativeMode()) - { - this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); - } - else - { +// if (this.mc.playerController.isInCreativeMode()) +// { +// this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); +// } +// else +// { super.initGui(); - } +// } } /** diff --git a/src/main/java/baubles/common/Baubles.java b/src/main/java/baubles/common/Baubles.java index bc27891..7b02445 100644 --- a/src/main/java/baubles/common/Baubles.java +++ b/src/main/java/baubles/common/Baubles.java @@ -2,14 +2,12 @@ package baubles.common; import java.io.File; -import net.minecraft.creativetab.CreativeTabs; import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import baubles.common.event.EventHandlerEntity; -import baubles.common.lib.CreativeTabBaubles; import baubles.common.lib.PlayerHandler; import baubles.common.network.EventHandlerNetwork; import baubles.common.network.PacketPipeline; @@ -40,13 +38,11 @@ public class Baubles { public EventHandlerNetwork networkEventHandler; public EventHandlerEntity entityEventHandler; - public PlayerHandler playerHandler; public File modDir; public static final PacketPipeline packetPipeline = new PacketPipeline(); public static final Logger logger = LogManager.getLogger("Baubles"); public static final int GUI = 0; - public static CreativeTabs tabBaubles = new CreativeTabBaubles(CreativeTabs.getNextID(), "baubles"); @EventHandler public void preInit(FMLPreInitializationEvent event) { @@ -62,7 +58,6 @@ public class Baubles { } entityEventHandler = new EventHandlerEntity(); - playerHandler = new PlayerHandler(); MinecraftForge.EVENT_BUS.register(entityEventHandler); FMLCommonHandler.instance().bus().register(new EventHandlerNetwork()); diff --git a/src/main/java/baubles/common/container/ContainerPlayerExpanded.java b/src/main/java/baubles/common/container/ContainerPlayerExpanded.java index ecec711..d812807 100644 --- a/src/main/java/baubles/common/container/ContainerPlayerExpanded.java +++ b/src/main/java/baubles/common/container/ContainerPlayerExpanded.java @@ -13,7 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import baubles.api.BaubleType; import baubles.api.IBauble; -import baubles.common.Baubles; +import baubles.common.lib.PlayerHandler; public class ContainerPlayerExpanded extends Container { @@ -36,7 +36,7 @@ public class ContainerPlayerExpanded extends Container baubles = new InventoryBaubles(player); baubles.setEventHandler(this); if (!player.worldObj.isRemote) { - baubles.stackList = Baubles.instance.playerHandler.getPlayerBaubles(player).stackList; + baubles.stackList = PlayerHandler.getPlayerBaubles(player).stackList; } this.addSlotToContainer(new SlotCrafting(playerInv.player, this.craftMatrix, this.craftResult, 0, 144, 36)); @@ -117,8 +117,8 @@ public class ContainerPlayerExpanded extends Container this.craftResult.setInventorySlotContents(0, (ItemStack)null); if (!player.worldObj.isRemote) { - Baubles.instance.playerHandler.setPlayerBaubles(player, baubles); - Baubles.instance.playerHandler.updatePlayerBaubles(player); + PlayerHandler.setPlayerBaubles(player, baubles); + PlayerHandler.updatePlayerBaubles(player); } } @@ -185,7 +185,7 @@ public class ContainerPlayerExpanded extends Container return null; } } - else if (itemstack.getItem() instanceof IBauble && + else if (par2>11 && itemstack.getItem() instanceof IBauble && ((IBauble)itemstack.getItem()).getBaubleType(itemstack)==BaubleType.RING && !((Slot)this.inventorySlots.get(10)).getHasStack()) { @@ -195,7 +195,7 @@ public class ContainerPlayerExpanded extends Container return null; } } - else if (itemstack.getItem() instanceof IBauble && + else if (par2>11 && itemstack.getItem() instanceof IBauble && ((IBauble)itemstack.getItem()).getBaubleType(itemstack)==BaubleType.RING && !((Slot)this.inventorySlots.get(11)).getHasStack()) { diff --git a/src/main/java/baubles/common/event/EventHandlerEntity.java b/src/main/java/baubles/common/event/EventHandlerEntity.java index 747e153..de6b973 100644 --- a/src/main/java/baubles/common/event/EventHandlerEntity.java +++ b/src/main/java/baubles/common/event/EventHandlerEntity.java @@ -4,8 +4,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import baubles.api.IBauble; -import baubles.common.Baubles; import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class EventHandlerEntity { @@ -17,7 +17,7 @@ public class EventHandlerEntity { if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)event.entity; - InventoryBaubles baubles = Baubles.instance.playerHandler.getPlayerBaubles(player); + InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); for (int a=0;a playerBaubles = new HashMap(); + private static HashMap playerBaubles = new HashMap(); - public InventoryBaubles getPlayerBaubles(EntityPlayer player) { + public static InventoryBaubles getPlayerBaubles(EntityPlayer player) { if (!playerBaubles.containsKey(player.getCommandSenderName())) { InventoryBaubles inventory = new InventoryBaubles(player); playerBaubles.put(player.getCommandSenderName(), inventory); @@ -17,16 +17,16 @@ public class PlayerHandler { return playerBaubles.get(player.getCommandSenderName()); } - public void setPlayerBaubles(EntityPlayer player, InventoryBaubles inventory) { + public static void setPlayerBaubles(EntityPlayer player, InventoryBaubles inventory) { playerBaubles.put(player.getCommandSenderName(), inventory); } - public void updatePlayerBaubles(EntityPlayer player) { + public static void updatePlayerBaubles(EntityPlayer player) { InventoryBaubles inventory = getPlayerBaubles(player); inventory.saveNBT(player); } - public void loadPlayerBaubles(EntityPlayer player) { + public static void loadPlayerBaubles(EntityPlayer player) { NBTTagCompound data = player.getEntityData(); if (!data.hasKey("Baubles")) { data.setTag("Baubles", new NBTTagCompound()); diff --git a/src/main/java/baubles/common/network/EventHandlerNetwork.java b/src/main/java/baubles/common/network/EventHandlerNetwork.java index 2192412..26005fe 100644 --- a/src/main/java/baubles/common/network/EventHandlerNetwork.java +++ b/src/main/java/baubles/common/network/EventHandlerNetwork.java @@ -2,7 +2,7 @@ package baubles.common.network; import java.util.HashMap; -import baubles.common.Baubles; +import baubles.common.lib.PlayerHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; @@ -14,7 +14,7 @@ public class EventHandlerNetwork { public void playerLoggedInEvent (PlayerEvent.PlayerLoggedInEvent event) { Side side = FMLCommonHandler.instance().getEffectiveSide(); if (side == Side.SERVER) { - Baubles.instance.playerHandler.loadPlayerBaubles(event.player); + PlayerHandler.loadPlayerBaubles(event.player); } } @@ -24,7 +24,7 @@ public class EventHandlerNetwork { public void playerUpdateEvent (PlayerEvent event) { Side side = FMLCommonHandler.instance().getEffectiveSide(); if (side == Side.SERVER) { - Baubles.instance.playerHandler.updatePlayerBaubles(event.player); + PlayerHandler.updatePlayerBaubles(event.player); } } diff --git a/src/main/resources/BLogo.png b/src/main/resources/BLogo.png new file mode 100644 index 0000000..c3a4563 Binary files /dev/null and b/src/main/resources/BLogo.png differ diff --git a/src/main/resources/assets/baubles/lang/en_US.lang b/src/main/resources/assets/baubles/lang/en_US.lang index 4769f8a..2864f26 100644 --- a/src/main/resources/assets/baubles/lang/en_US.lang +++ b/src/main/resources/assets/baubles/lang/en_US.lang @@ -1,8 +1,3 @@ # # ITEMS item.Ring.0.name=Miner's Ring -# -# GUI -# -# OTHER -itemGroup.baubles=Baubles diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 14faeae..953e125 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -9,7 +9,7 @@ "url": "http://www.minecraftforum.net/topic/838839-100-thaumcraft/", "updateUrl": "", "authors": ["Azanor"], - "credits": "", + "credits": "Special thanks to chicken_bones", "parent": "", "screenshots": [], "dependencies": [] diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index c1c2b30..ac7756d 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "pack_format": 1, - "description": "Resources used for Baubles + "description": "Resources used for Baubles" } } \ No newline at end of file