aaaaaaaaaaaaaaaaaaaaaaaaa

This commit is contained in:
Vaern 2022-10-22 14:55:49 -07:00
parent 3526af3bdb
commit 009e8cd31a
5 changed files with 151 additions and 41 deletions

View File

@ -22,6 +22,7 @@ import com.hbm.wiaj.GuiWorldInAJar;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
@ -43,6 +44,12 @@ public class GUIHandler implements IGuiHandler {
return ((IGUIProvider) block).provideContainer(ID, player, world, x, y, z);
}
ItemStack item = player.getHeldItem();
if(item != null && item.getItem() instanceof IGUIProvider) {
return ((IGUIProvider) item.getItem()).provideContainer(ID, player, world, x, y, z);
}
//notice: stop doing this, unless you absolutely have to \/
if(entity instanceof TileEntityCrateIron) { return new ContainerCrateIron(player.inventory, (TileEntityCrateIron) entity); }
@ -848,10 +855,10 @@ public class GUIHandler implements IGuiHandler {
return ((IGUIProvider) block).provideGUI(ID, player, world, x, y, z);
}
Item item = player.getHeldItem().getItem();
ItemStack item = player.getHeldItem();
if(item instanceof IGUIProvider) {
return ((IGUIProvider) item).provideGUI(ID, player, world, x, y, z);
if(item != null && item.getItem() instanceof IGUIProvider) {
return ((IGUIProvider) item.getItem()).provideGUI(ID, player, world, x, y, z);
}
//stop doing this unless you absolutely have to \/

View File

@ -15,6 +15,7 @@ import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@ -28,7 +29,7 @@ public class GUIBookLore extends GuiScreen {
protected int guiLeft;
protected int guiTop;
private World world; //Used for save-dependent information, like the MKU recipe
private NBTTagCompound tag; //Used for save-dependent information, like the MKU recipe
private BookLoreType type;
public int itemTexture;
@ -42,8 +43,8 @@ public class GUIBookLore extends GuiScreen {
public GUIBookLore(EntityPlayer player) {
world = player.worldObj;
type = BookLoreType.getTypeFromStack(player.getHeldItem());
tag = player.getHeldItem().getTagCompound(); //compound is created or gotten in method above
GUIAppearance setup = type.appearance;
mainPage = setup.mainPage;
@ -103,18 +104,18 @@ public class GUIBookLore extends GuiScreen {
if(mainPage.isTwoPages) {
int defacto = page * 2 + 1;
String text = type.resolveKey(key + defacto, world);
String text = type.resolveKey(key + defacto, tag);
if((page + 1) * 2 <= type.pages) { //Checks if text should be rendered as an aux or a main page
mainPage.renderText(text, fontRendererObj, guiLeft, guiTop, false);
text = type.resolveKey(key + (defacto + 1), world); //kinda awkward, but no way around it
text = type.resolveKey(key + (defacto + 1), tag); //kinda awkward, but no way around it
mainPage.renderText(text, fontRendererObj, guiLeft, guiTop, true);
} else
auxPage.renderText(text, fontRendererObj, guiLeft, guiTop, false);
} else {
String text = type.resolveKey(key + (page + 1), world);
String text = type.resolveKey(key + (page + 1), tag);
if(page < maxPage)
mainPage.renderText(text, fontRendererObj, guiLeft, guiTop, false);
@ -149,17 +150,17 @@ 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),
GUIDEBOOK(new GUIPage(272, 182, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/book.png")).setScale(2F).setMargins(20, 20, 20),
new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512),
0), //Guide Book
LOOSEPAPER(new GUIPage(130, 165, 10, 10, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(1F).setUV(133, 0),
LOOSEPAPER(new GUIPage(130, 165, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setMargins(12, 10, 16).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, 10, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(1F),
LOOSEPAPERS(new GUIPage(133, 165, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setMargins(12, 10, 16),
new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512),
2), //Collection of loose pages
NOTEBOOK(new GUIPage(133, 165, 10, 20, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(1F).setUV(0, 165),
new GUIPage(133, 165, 10, 20, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setScale(1F).setUV(133, 165),
NOTEBOOK(new GUIPage(133, 165, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setMargins(10, 10, 16).setUV(0, 165),
new GUIPage(133, 165, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png"), false).setMargins(10, 10, 16).setUV(133, 165),
new GUIPageButton(18, 10, 17, 148, new ResourceLocation(RefStrings.MODID + ":textures/gui/book/notebook_and_papers.png")).setUV(263, 0, 512, 512),
3);
@ -190,33 +191,30 @@ public class GUIBookLore extends GuiScreen {
protected ResourceLocation texture;
//UV positioning
protected int u = 0;
protected int v = 0;
protected int u = 0; //X/U pos in texture
protected int v = 0; //Y/V pos in texture
protected int sizeX;
protected int sizeY;
protected int sizeX; //X size of the page
protected int sizeY; //Y size of the page
//Text positioning
protected int marginX; //Boundaries of the textbook, relative to the pages' edges.
protected int marginY; //Mirrored on both sides if two-sided.
protected boolean isTwoPages = true;
protected float scale = 1.0F;
protected int spacing = 9; //12
//TODO: split marginX into a left and right margin
protected GUIPage(int x, int y, int marX, int marY, ResourceLocation texture, boolean twoPages) {
protected int marginInner = 10; //Margin from inner edge of page
protected int marginOuter = 10; //Margin from outer edge of page
protected int marginY = 20; //Margin from upper edge of page
protected boolean isTwoPages = true; //Has two pages to display text
protected float scale = 1.0F; //Scale of the text; larger values are smaller
protected int spacing = 9; //12 is a more comfortable spacing
protected GUIPage(int x, int y, ResourceLocation texture, boolean twoPages) {
this.sizeX = x;
this.sizeY = y;
this.marginX = marX;
this.marginY = marY;
this.texture = texture;
this.isTwoPages = twoPages;
}
protected GUIPage(int x, int y, int marX, int marY, ResourceLocation texture) {
protected GUIPage(int x, int y, ResourceLocation texture) {
this.sizeX = x;
this.sizeY = y;
this.marginX = marX;
this.marginY = marY;
this.texture = texture;
}
@ -231,13 +229,20 @@ public class GUIBookLore extends GuiScreen {
return this;
}
protected GUIPage setMargins(int inner, int outer, int upper) {
this.marginInner = inner;
this.marginOuter = outer;
this.marginY = upper;
return this;
}
protected GUIPage setSpacing(int spacing) {
this.spacing = spacing;
return this;
}
protected void renderText(String text, FontRenderer renderer, int left, int top, boolean secondPage) {
int width = isTwoPages ? (sizeX / 2) - (marginX * 2) : sizeX - (marginX * 2);
int width = (isTwoPages ? sizeX / 2 : sizeX) - marginInner - marginOuter;
int widthScaled = (int) (width * scale);
List<String> lines = new ArrayList();
@ -262,7 +267,7 @@ public class GUIBookLore extends GuiScreen {
GL11.glPushMatrix();
GL11.glScalef(1F/scale, 1F/scale, 1F);
int sideOffset = secondPage ? sizeX - marginX - width : marginX;
int sideOffset = secondPage ? sizeX / 2 + marginInner : marginOuter;
for(int l = 0; l < lines.size(); l++) {
renderer.drawString(lines.get(l), (int)((left + sideOffset) * scale), (int)((top + marginY) * scale + (spacing * l)), 4210752);

View File

@ -103,9 +103,29 @@ public class ItemBookLore extends Item implements IGUIProvider {
public enum BookLoreType {
TEST(true, "test", 5, GUIAppearance.NOTEBOOK),
BOOK_IODINE(true, "book_iodine", 3, GUIAppearance.LOOSEPAPERS) {
public String resolveKey(String key, World world) {
int slot = TestDungeonRoom8.getSlot(world, ModItems.powder_iodine);
return I18nUtil.resolveKey(key, slot); }}
public String resolveKey(String key, NBTTagCompound tag) {
return I18nUtil.resolveKey(key, tag.getInteger("mku_slot"));
}},
BOOK_PHOSPHOROUS(true, "book_phosphorous", 2, GUIAppearance.LOOSEPAPERS) {
public String resolveKey(String key, NBTTagCompound tag) {
return I18nUtil.resolveKey(key, tag.getInteger("mku_slot"));
}},
BOOK_DUST(true, "book_dust", 3, GUIAppearance.LOOSEPAPERS) {
public String resolveKey(String key, NBTTagCompound tag) {
return I18nUtil.resolveKey(key, tag.getInteger("mku_slot"));
}},
BOOK_MERCURY(true, "book_mercury", 2, GUIAppearance.LOOSEPAPERS) {
public String resolveKey(String key, NBTTagCompound tag) {
return I18nUtil.resolveKey(key, tag.getInteger("mku_slot"));
}},
BOOK_FLOWER(true, "book_flower", 2, GUIAppearance.LOOSEPAPERS) {
public String resolveKey(String key, NBTTagCompound tag) {
return I18nUtil.resolveKey(key, tag.getInteger("mku_slot"));
}},
BOOK_SYRINGE(true, "book_syringe", 2, GUIAppearance.LOOSEPAPERS) {
public String resolveKey(String key, NBTTagCompound tag) {
return I18nUtil.resolveKey(key, tag.getInteger("mku_slot"));
}},
;
//Why? it's quite simple; i am too burnt out and also doing it the other way
@ -130,8 +150,8 @@ public class ItemBookLore extends Item implements IGUIProvider {
}
/** 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 String resolveKey(String key, NBTTagCompound tag) {
return I18nUtil.resolveKey(key, tag);
}
public static BookLoreType getTypeFromStack(ItemStack stack) {
@ -142,7 +162,7 @@ public class ItemBookLore extends Item implements IGUIProvider {
NBTTagCompound tag = stack.getTagCompound();
int ordinal = tag.getInteger("Book_Lore_Type");
return BookLoreType.values()[Math.abs(ordinal) % BookType.values().length];
return BookLoreType.values()[Math.abs(ordinal) % BookLoreType.values().length];
}
public static ItemStack setTypeForStack(ItemStack stack, BookLoreType num) {

View File

@ -3,6 +3,7 @@ package com.hbm.world.generator.room;
import com.hbm.blocks.ModBlocks;
import com.hbm.crafting.handlers.MKUCraftingHandler;
import com.hbm.items.ModItems;
import com.hbm.items.special.ItemBookLore.BookLoreType;
import com.hbm.tileentity.machine.storage.TileEntitySafe;
import com.hbm.world.generator.CellularDungeon;
import com.hbm.world.generator.CellularDungeonRoom;
@ -55,7 +56,7 @@ public class TestDungeonRoom8 extends CellularDungeonRoom {
if(r == 0)
((TileEntitySafe)world.getTileEntity(x + parent.width / 2, y + 2, z + parent.width / 2)).setInventorySlotContents(7, new ItemStack(ModItems.book_of_));
else if(r < 4)
((TileEntitySafe)world.getTileEntity(x + parent.width / 2, y + 2, z + parent.width / 2)).setInventorySlotContents(7, genetateMKU(world));
((TileEntitySafe)world.getTileEntity(x + parent.width / 2, y + 2, z + parent.width / 2)).setInventorySlotContents(7, generateMKU(world));
else
((TileEntitySafe)world.getTileEntity(x + parent.width / 2, y + 2, z + parent.width / 2)).setInventorySlotContents(7, new ItemStack(Items.book));
}
@ -63,7 +64,58 @@ public class TestDungeonRoom8 extends CellularDungeonRoom {
}
}
public static ItemStack genetateMKU(World world) {
public static ItemStack generateMKU(World world) {
ItemStack book = new ItemStack(ModItems.book_lore);
int i = world.rand.nextInt(books.length);
BookLoreType.setTypeForStack(book, books[i]);
book.stackTagCompound.setInteger("mku_slot", getSlot(world, books[i]));
return book;
}
public static int getSlot(World world, BookLoreType type) {
MKUCraftingHandler.generateRecipe(world);
ItemStack[] recipe = MKUCraftingHandler.MKURecipe;
Item item;
//fucking kill me
switch(type) {
case BOOK_DUST:
item = ModItems.dust; break;
case BOOK_FLOWER:
item = ModItems.morning_glory; break;
case BOOK_IODINE:
item = ModItems.powder_iodine; break;
case BOOK_MERCURY:
item = ModItems.ingot_mercury; break;
case BOOK_PHOSPHOROUS:
item = ModItems.powder_fire; break;
case BOOK_SYRINGE:
item = ModItems.syringe_metal_empty; break;
default:
item = ModItems.nothing; break;
}
if(recipe == null) //take no chances
return -2;
for(int i = 0; i < 9; i++) {
if(recipe[i] != null && recipe[i].getItem() == item) {
return i + 1;
}
}
return -1;
}
private final static BookLoreType[] books = new BookLoreType[] {
BookLoreType.BOOK_IODINE, BookLoreType.BOOK_PHOSPHOROUS, BookLoreType.BOOK_DUST, BookLoreType.BOOK_MERCURY, BookLoreType.BOOK_FLOWER, BookLoreType.BOOK_SYRINGE
};
/*public static ItemStack genetateMKU(World world) {
ItemStack book = new ItemStack(Items.written_book);
book.stackTagCompound = new NBTTagCompound();
@ -155,7 +207,7 @@ public class TestDungeonRoom8 extends CellularDungeonRoom {
return copy;
}
public static int getSlot(World world, Item item) {
public static int getSlot(World world, Item item) {
MKUCraftingHandler.generateRecipe(world);
ItemStack[] recipe = MKUCraftingHandler.MKURecipe;
@ -171,5 +223,5 @@ public class TestDungeonRoom8 extends CellularDungeonRoom {
}
return -1;
}
}*/
}

View File

@ -329,6 +329,32 @@ book_lore.book_iodine.page.1=alright you will not believe this, but old man weat
book_lore.book_iodine.page.2=apparently the morons from R&D discovered a compound that is mostly inorganic, pretty much like a toxin in nature, but get this: the dying cells will reproduce said toxin and excrete it through the skin, creating an aerosol that is highly contagious.
book_lore.book_iodine.page.3=it's just like a virus, but not a virus. the composition is weird, you can mix it in any household bottle but you do have to get the order right. the doc told me that the first ingredient which is just powdered iodine crystals goes into slot %d
book_lore.book_phosphorous.name=Note
book_lore.book_phosphorous.author=Dave
book_lore.book_phosphorous.page.1=heyo, it's me again. i assume you got my last memo, the doc wasn't too happy about it. i'll have to do this quick, the dunderheads from R&D are currently moaning again, probably over money. again. anyway, doc weathervane found that the second
book_lore.book_phosphorous.page.2=ingredient is red phosphorous, whihc has to be mixed into slot %d
book_lore.book_dust.name=Note
book_lore.book_dust.author=Dave
book_lore.book_dust.page.1=the doc was furious when he found out that the R&D dorks kept the one remaining sample, ranting about gross negligence this and a doomsday scenario that. i told him to chill for a minute, getting all worked up isn't good for his blood pressure, not
book_lore.book_dust.page.2=that he has much blood left to begin with. one of the R&D morons slipped some more info into last week's circular, they call their little concoction \"MKU\" whatever that means, and that it contains actual household lint. can you believe that? one of the most
book_lore.book_dust.page.3=dangerous inventions of theirs and it contains dust. strangely they also mentioned that it goes into slot %d
book_lore.book_mercury.name=Note
book_lore.book_mercury.author=Dave
book_lore.book_mercury.page.1=well that settles that. not counting the vomitting blood part, the toxicological report mostly resembles that of mercury poisoning. why? because our little mix also contains mercury! i just wonder where all that stuff comes from when being
book_lore.book_mercury.page.2=replicated by the body? whatever, the mercury goes into slot %d
book_lore.book_flower.name=Note
book_lore.book_flower.author=Dave
book_lore.book_flower.page.1=remember when i mentioned in my first memo that the compound is mostly anorganic? well guess what, the old man shared the fourth ingredient: ipomoea nil, a genus of flower. morning glory! it might be due to its low sulfur content, whatever might be the case,
book_lore.book_flower.page.2=it does not work with other flowers. the morning glory goes into slot %d
book_lore.book_syringe.name=Note
book_lore.book_syringe.author=Dave
book_lore.book_syringe.page.1=a little addendum to my fifth message, obviously you have to store this MKU stuff in a container. the R&D nuts used regular metal syringes that they got from medical. surplus ware i presume, they got thousands of needles just lying around. the metal
book_lore.book_syringe.page.2=syringe goes into slot %d
cannery.f1=[ Press F1 for help ]
cannery.centrifuge=Gas Centrifuge