From a0332d42415186cfe7b0e8fc374c90cb8262e1d2 Mon Sep 17 00:00:00 2001 From: Vaern Date: Fri, 21 Oct 2022 14:52:33 -0700 Subject: [PATCH] mh --- .../com/hbm/inventory/gui/GUIBookLore.java | 17 ++++++---- .../com/hbm/items/special/ItemBookLore.java | 31 +++++++++++++++--- .../java/com/hbm/items/tool/ItemWandD.java | 12 +++++-- .../assets/hbm/textures/items/paper_loose.png | Bin 0 -> 239 bytes 4 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 src/main/resources/assets/hbm/textures/items/paper_loose.png diff --git a/src/main/java/com/hbm/inventory/gui/GUIBookLore.java b/src/main/java/com/hbm/inventory/gui/GUIBookLore.java index fef6a8986..85f3bd5cd 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIBookLore.java +++ b/src/main/java/com/hbm/inventory/gui/GUIBookLore.java @@ -16,17 +16,19 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; // and you may ask yourself: vaer, why do this? this is basically just a copy of GUIScreenGuide. // and I would answer, shut the fuck up nerd, the guide book system is too involved for my small // brain to use for god knows how many tidbits of lore. i'll settle for a text box and cool textures, thanks public class GUIBookLore extends GuiScreen { - + //TODO: refactor some of these variables protected int xSize; protected int ySize; protected int guiLeft; protected int guiTop; + private World world; //Used for save-dependent information, like the MKU recipe private BookLoreType type; private GUIAppearance setup; @@ -35,6 +37,7 @@ public class GUIBookLore extends GuiScreen { public GUIBookLore(EntityPlayer player) { + world = player.worldObj; type = BookLoreType.getTypeFromStack(player.getHeldItem()); setup = type.appearance; @@ -134,12 +137,14 @@ public class GUIBookLore extends GuiScreen { // turn page buttons, one-page, both page textures, sizes, positions, etc. public enum GUIAppearance { GUIDEBOOK(new GUIPage(272, 182, 20, 20, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/book.png")).setScale(2F), - new GUIPageButton(18, 10, 24, 155, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/starter6.png")).setUV(0, 0, 500, 200), - 0), - LOOSEPAPER(new GUIPage(133, 165, 10, 24, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(2F), - new GUIPage(130, 165, 10, 24, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(2F).setUV(133, 0), new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512), - 1); + 0), + LOOSEPAPER(new GUIPage(130, 165, 10, 24, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(2F).setUV(133, 0), + new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512), + 1), //Singular loose page + LOOSEPAPERS(new GUIPage(133, 165, 10, 24, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(2F), + new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512), + 2); public int itemTexture; diff --git a/src/main/java/com/hbm/items/special/ItemBookLore.java b/src/main/java/com/hbm/items/special/ItemBookLore.java index 2df994562..403786a39 100644 --- a/src/main/java/com/hbm/items/special/ItemBookLore.java +++ b/src/main/java/com/hbm/items/special/ItemBookLore.java @@ -12,6 +12,7 @@ import com.hbm.util.I18nUtil; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -62,8 +63,8 @@ public class ItemBookLore extends Item implements IGUIProvider { } protected IIcon[] icons; - //fuck you, fuck enums, fuck guis, fuck this shitty ass fork. shove that string array up your ass. - public static String[] itemTextures = new String[] { ":book_guide", ":papers_loose" }; + + public final static String[] itemTextures = new String[] { ":book_guide", ":paper_loose", ":papers_loose" }; @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister reg) { @@ -98,7 +99,9 @@ public class ItemBookLore extends Item implements IGUIProvider { } public enum BookLoreType { - TEST(true, "test", 5, GUIAppearance.LOOSEPAPER); + TEST(true, "test", 5, GUIAppearance.GUIDEBOOK), + REL_RAMBLINGS("rel_ramblings", 3, GUIAppearance.LOOSEPAPERS); + //Why? it's quite simple; i am too burnt out and also doing it the other way //is too inflexible for my taste @@ -121,15 +124,35 @@ public class ItemBookLore extends Item implements IGUIProvider { this.appearance = appearance; } + //TODO: actually shove this into the gui + /** Function to resolve I18n keys using potential save-dependent information, a la format specifiers. */ + public String resolveKey(String key, World world) { + return I18nUtil.resolveKey(key); + } + public static BookLoreType getTypeFromStack(ItemStack stack) { if(!stack.hasTagCompound()) { stack.stackTagCompound = new NBTTagCompound(); } NBTTagCompound tag = stack.getTagCompound(); - int ordinal = tag.getInteger("bookLoreOrdinal"); + int ordinal = tag.getInteger("Book_Lore_Type"); return BookLoreType.values()[Math.abs(ordinal) % BookType.values().length]; } + + public static ItemStack setTypeForStack(ItemStack stack, BookLoreType num) { + + if(stack.getItem() instanceof ItemBookLore) { + if(!stack.hasTagCompound()) { + stack.stackTagCompound = new NBTTagCompound(); + } + + NBTTagCompound tag = stack.getTagCompound(); + tag.setInteger("Book_Lore_Type", num.ordinal()); + } + + return stack; + } } } diff --git a/src/main/java/com/hbm/items/tool/ItemWandD.java b/src/main/java/com/hbm/items/tool/ItemWandD.java index 6260e9ec2..cb1308cca 100644 --- a/src/main/java/com/hbm/items/tool/ItemWandD.java +++ b/src/main/java/com/hbm/items/tool/ItemWandD.java @@ -6,6 +6,8 @@ import com.hbm.blocks.ModBlocks; import com.hbm.entity.effect.EntityNukeTorex; import com.hbm.entity.mob.siege.EntitySiegeTunneler; import com.hbm.items.ModItems; +import com.hbm.items.special.ItemBookLore; +import com.hbm.items.special.ItemBookLore.BookLoreType; import com.hbm.items.special.ItemKitCustom; import com.hbm.lib.Library; import com.hbm.world.feature.OilSpot; @@ -34,12 +36,18 @@ public class ItemWandD extends Item { if(pos != null) { - //use sparingly + ItemStack itemStack = new ItemStack(ModItems.book_lore); + BookLoreType.setTypeForStack(itemStack, BookLoreType.REL_RAMBLINGS); + + player.inventory.addItemStackToInventory(itemStack); + player.inventoryContainer.detectAndSendChanges(); + + /*//use sparingly int k = ((pos.blockX >> 4) << 4) + 8; int l = ((pos.blockZ >> 4) << 4) + 8; Start start = new Start(world, world.rand, pos.blockX >> 4, pos.blockZ >> 4); - start.generateStructure(world, world.rand, new StructureBoundingBox(k - 124, l - 124, k + 15 + 124, l + 15 + 124)); + start.generateStructure(world, world.rand, new StructureBoundingBox(k - 124, l - 124, k + 15 + 124, l + 15 + 124));*/ /*OilSpot.generateOilSpot(world, pos.blockX, pos.blockZ, 20, 500);*/ diff --git a/src/main/resources/assets/hbm/textures/items/paper_loose.png b/src/main/resources/assets/hbm/textures/items/paper_loose.png new file mode 100644 index 0000000000000000000000000000000000000000..446c7207111f7ff44fa3be5491f4f4d98eba71cd GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf_<+T`&Lu literal 0 HcmV?d00001