diff --git a/build.gradle b/build.gradle index ac02b47..0d1060e 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.0.1.1" +version = "1.7.10-1.0.1.2" group= "com.azanor.baubles" archivesBaseName = "Baubles" diff --git a/src/main/java/baubles/client/ClientProxy.java b/src/main/java/baubles/client/ClientProxy.java index 98d4b8d..5ba2084 100644 --- a/src/main/java/baubles/client/ClientProxy.java +++ b/src/main/java/baubles/client/ClientProxy.java @@ -4,6 +4,8 @@ package baubles.client; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import baubles.client.gui.GuiEvents; import baubles.client.gui.GuiPlayerExpanded; import baubles.common.Baubles; import baubles.common.CommonProxy; @@ -20,6 +22,7 @@ public class ClientProxy extends CommonProxy { public void registerKeyBindings() { keyHandler = new KeyHandler(); FMLCommonHandler.instance().bus().register(keyHandler); + MinecraftForge.EVENT_BUS.register(new GuiEvents()); } @Override diff --git a/src/main/java/baubles/client/gui/GuiBaublesButton.java b/src/main/java/baubles/client/gui/GuiBaublesButton.java new file mode 100644 index 0000000..aba3e78 --- /dev/null +++ b/src/main/java/baubles/client/gui/GuiBaublesButton.java @@ -0,0 +1,45 @@ +package baubles.client.gui; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.OpenGlHelper; + +public class GuiBaublesButton extends GuiButton { + + public GuiBaublesButton(int p_i1021_1_, int p_i1021_2_, int p_i1021_3_, + int p_i1021_4_, int p_i1021_5_, String p_i1021_6_) { + super(p_i1021_1_, p_i1021_2_, p_i1021_3_, p_i1021_4_, p_i1021_5_, p_i1021_6_); + } + + public void drawButton(Minecraft mc, int xx, int yy) + { + if (this.visible) + { + FontRenderer fontrenderer = mc.fontRenderer; + mc.getTextureManager().bindTexture(GuiPlayerExpanded.background); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_146123_n = xx >= this.xPosition && yy >= this.yPosition && xx < this.xPosition + this.width && yy < this.yPosition + this.height; + int k = this.getHoverState(this.field_146123_n); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + + if (k==1) { + this.drawTexturedModalRect(this.xPosition, this.yPosition, 200, 48, 10, 10); + } else { + this.drawTexturedModalRect(this.xPosition, this.yPosition, 210, 48, 10, 10); + this.drawCenteredString(fontrenderer, this.displayString, + this.xPosition + 5, this.yPosition + this.height, 0xffffff); + } + + this.mouseDragged(mc, xx, yy); + + + } + } + +} diff --git a/src/main/java/baubles/client/gui/GuiEvents.java b/src/main/java/baubles/client/gui/GuiEvents.java new file mode 100644 index 0000000..3a82e0e --- /dev/null +++ b/src/main/java/baubles/client/gui/GuiEvents.java @@ -0,0 +1,55 @@ +package baubles.client.gui; + +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.resources.I18n; +import net.minecraftforge.client.event.GuiScreenEvent; +import baubles.common.network.PacketHandler; +import baubles.common.network.PacketOpenBaublesInventory; +import baubles.common.network.PacketOpenNormalInventory; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class GuiEvents { + + @SideOnly(value = Side.CLIENT) + @SubscribeEvent + public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { + + if (event.gui instanceof GuiInventory || event.gui instanceof GuiPlayerExpanded) { + + int xSize = 176; + int ySize = 166; + + int guiLeft = (event.gui.width - xSize) / 2; + int guiTop = (event.gui.height - ySize) / 2; + + if (!event.gui.mc.thePlayer.getActivePotionEffects().isEmpty()) { + guiLeft = 160 + (event.gui.width - xSize - 200) / 2; + } + + event.buttonList.add(new GuiBaublesButton(55, guiLeft + 66, guiTop + 9, 10, 10, + I18n.format((event.gui instanceof GuiInventory)?"button.baubles":"button.normal", new Object[0]))); + } + + } + + + @SideOnly(value = Side.CLIENT) + @SubscribeEvent + public void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event) { + + if (event.gui instanceof GuiInventory) { + if (event.button.id == 55) { + PacketHandler.INSTANCE.sendToServer(new PacketOpenBaublesInventory(event.gui.mc.thePlayer)); + } + } + + if (event.gui instanceof GuiPlayerExpanded) { + if (event.button.id == 55) { + event.gui.mc.displayGuiScreen(new GuiInventory(event.gui.mc.thePlayer)); + PacketHandler.INSTANCE.sendToServer(new PacketOpenNormalInventory(event.gui.mc.thePlayer)); + } + } + } +} diff --git a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java index 2f4bd1b..6b20ae7 100644 --- a/src/main/java/baubles/client/gui/GuiPlayerExpanded.java +++ b/src/main/java/baubles/client/gui/GuiPlayerExpanded.java @@ -21,7 +21,7 @@ import baubles.common.container.ContainerPlayerExpanded; public class GuiPlayerExpanded extends InventoryEffectRenderer { - protected static final ResourceLocation background = + public static final ResourceLocation background = new ResourceLocation("baubles","textures/gui/expanded_inventory.png"); /** diff --git a/src/main/java/baubles/common/Baubles.java b/src/main/java/baubles/common/Baubles.java index 136e9a9..8e44682 100644 --- a/src/main/java/baubles/common/Baubles.java +++ b/src/main/java/baubles/common/Baubles.java @@ -24,7 +24,7 @@ public class Baubles { public static final String MODID = "Baubles"; public static final String MODNAME = "Baubles"; - public static final String VERSION = "1.0.1.1"; + public static final String VERSION = "1.0.1.2"; @SidedProxy(clientSide = "baubles.client.ClientProxy", serverSide = "baubles.common.CommonProxy") public static CommonProxy proxy; diff --git a/src/main/java/baubles/common/Config.java b/src/main/java/baubles/common/Config.java index a2cb226..e87a315 100644 --- a/src/main/java/baubles/common/Config.java +++ b/src/main/java/baubles/common/Config.java @@ -34,11 +34,11 @@ public class Config { } public static void initRecipe() { - GameRegistry.addShapedRecipe( - new ItemStack(itemRing), new Object[] { - "PIP", "IPI", "PIP", - Character.valueOf('I'), new ItemStack(Items.iron_ingot), - Character.valueOf('P'), new ItemStack(Items.potionitem,1,8226)}); +// GameRegistry.addShapedRecipe( +// new ItemStack(itemRing), new Object[] { +// "PIP", "IPI", "PIP", +// Character.valueOf('I'), new ItemStack(Items.iron_ingot), +// Character.valueOf('P'), new ItemStack(Items.potionitem,1,8226)}); } diff --git a/src/main/java/baubles/common/network/PacketHandler.java b/src/main/java/baubles/common/network/PacketHandler.java index da461cf..00eac45 100644 --- a/src/main/java/baubles/common/network/PacketHandler.java +++ b/src/main/java/baubles/common/network/PacketHandler.java @@ -12,7 +12,8 @@ public class PacketHandler public static void init() { INSTANCE.registerMessage(PacketOpenBaublesInventory.class, PacketOpenBaublesInventory.class, 0, Side.SERVER); - INSTANCE.registerMessage(PacketSyncBauble.class, PacketSyncBauble.class, 1, Side.CLIENT); + INSTANCE.registerMessage(PacketOpenNormalInventory.class, PacketOpenNormalInventory.class, 1, Side.SERVER); + INSTANCE.registerMessage(PacketSyncBauble.class, PacketSyncBauble.class, 2, Side.CLIENT); } diff --git a/src/main/java/baubles/common/network/PacketOpenNormalInventory.java b/src/main/java/baubles/common/network/PacketOpenNormalInventory.java new file mode 100644 index 0000000..5acf8cb --- /dev/null +++ b/src/main/java/baubles/common/network/PacketOpenNormalInventory.java @@ -0,0 +1,28 @@ +package baubles.common.network; + +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +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 PacketOpenNormalInventory implements IMessage, IMessageHandler { + + public PacketOpenNormalInventory() {} + + public PacketOpenNormalInventory(EntityPlayer player) {} + + @Override + public void toBytes(ByteBuf buffer) {} + + @Override + public void fromBytes(ByteBuf buffer) {} + + @Override + public IMessage onMessage(PacketOpenNormalInventory message, MessageContext ctx) { + ctx.getServerHandler().playerEntity.openContainer = ctx.getServerHandler().playerEntity.inventoryContainer; + return null; + } + + +} diff --git a/src/main/resources/assets/baubles/lang/en_US.lang b/src/main/resources/assets/baubles/lang/en_US.lang index 2864f26..43942f3 100644 --- a/src/main/resources/assets/baubles/lang/en_US.lang +++ b/src/main/resources/assets/baubles/lang/en_US.lang @@ -1,3 +1,7 @@ # # ITEMS item.Ring.0.name=Miner's Ring +# +# GUI +button.baubles=Baubles +button.normal=Normal diff --git a/src/main/resources/assets/baubles/textures/gui/expanded_inventory.png b/src/main/resources/assets/baubles/textures/gui/expanded_inventory.png index 5949853..98a63f7 100644 Binary files a/src/main/resources/assets/baubles/textures/gui/expanded_inventory.png and b/src/main/resources/assets/baubles/textures/gui/expanded_inventory.png differ diff --git a/src/main/resources/changelog.txt b/src/main/resources/changelog.txt index 9fa3dd3..5a32b3a 100644 --- a/src/main/resources/changelog.txt +++ b/src/main/resources/changelog.txt @@ -1,3 +1,7 @@ +1.0.1.2 +- added a simple way to switch between the normal and baubles inventory. Thanks to Vazkii for the idea and permission to port it to base Baubles. +- removed the Miners Ring crafting recipe... it is a bit op. I will leave the item in so it is attainable in creative and so it can still serve as an example bauble for devs. + 1.0.1.1 - added backwards compatibility for legacy (pre 1.7.10) savefiles