Transfer of item book lores to updated system

This commit is contained in:
Vaern 2023-06-18 21:58:17 -07:00
parent 6e04fcd720
commit 9183ea7d32
8 changed files with 84 additions and 99 deletions

View File

@ -45,13 +45,13 @@ public class ItemBookLore extends Item implements IGUIProvider {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) {
if(!stack.hasTagCompound()) return;
String key = stack.stackTagCompound.getString("k");
String key = stack.stackTagCompound.getString("k");
if(key.isEmpty()) return;
key = "book_lore." + key + ".author";
String loc = I18nUtil.resolveKey(key);
list.add(I18nUtil.resolveKey("book_lore.author", loc));
if(!loc.equals(key))
list.add(I18nUtil.resolveKey("book_lore.author", loc));
}
@Override
@ -143,7 +143,7 @@ public class ItemBookLore extends Item implements IGUIProvider {
book.stackTagCompound.setTag("p" + page, data);
}
//TODO remove this and fix any references
public enum BookLoreType {
/*public enum BookLoreType {
TEST(true, "test", 5),
BOOK_IODINE(true, "book_iodine", 3) {
public String resolveKey(String key, NBTTagCompound tag) {
@ -192,7 +192,7 @@ 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, NBTTagCompound tag) {
/*public String resolveKey(String key, NBTTagCompound tag) {
return I18nUtil.resolveKey(key, tag);
}
@ -220,5 +220,5 @@ public class ItemBookLore extends Item implements IGUIProvider {
return stack;
}
}
}*/
}

View File

@ -2,11 +2,6 @@ package com.hbm.items.tool;
import java.util.List;
import com.hbm.crafting.handlers.MKUCraftingHandler;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.items.ModItems;
import com.hbm.items.special.ItemBookLore;
import com.hbm.lib.Library;
import net.minecraft.entity.player.EntityPlayer;
@ -35,24 +30,6 @@ public class ItemWandD extends Item {
vnt.setSFX(new ExplosionEffectStandard());
vnt.explode();*/
MKUCraftingHandler.generateRecipe(world);
ItemStack[] recipe = MKUCraftingHandler.MKURecipe;
if(recipe == null) //take no chances
return stack;
int r = 0;
for(int i = 0; i < 9; i++) {
if(recipe[i] != null && recipe[i].getItem() == ModItems.powder_iodine) {
r = i + 1;
}
}
ItemStack book = ItemBookLore.createBook("book_iodine", 3, 0x4C407A, 0xFFF7C1);
ItemBookLore.addArgs(book, 2, String.valueOf(r));
player.inventory.addItemStackToInventory(book);
player.inventoryContainer.detectAndSendChanges();
//PollutionHandler.incrementPollution(world, pos.blockX, pos.blockY, pos.blockZ, PollutionType.SOOT, 15);
/*TimeAnalyzer.startCount("setBlock");

View File

@ -1,17 +1,20 @@
package com.hbm.lib;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.items.ItemAmmoEnums.Ammo357Magnum;
import com.hbm.items.ItemAmmoEnums.AmmoFatman;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemBreedingRod.*;
import com.hbm.items.machine.ItemBreedingRod.BreedingRodType;
import com.hbm.items.machine.ItemZirnoxRod.EnumZirnoxType;
import com.hbm.items.special.ItemBookLore.BookLoreType;
import com.hbm.items.special.ItemBookLore;
import com.hbm.items.tool.ItemBlowtorch;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandomChestContent;
public class HbmChestContents {
@ -407,15 +410,26 @@ public class HbmChestContents {
new WeightedRandomChestContent(Items.experience_bottle, 0, 1, 3, 1),
};
/** ITEMBOOKLORE ARRAYS */
//might make a wrapper class for this, if game-state knowledge using the nbt system becomes that relevant
public final static BookLoreType[] books_office_sch = new BookLoreType[] {
BookLoreType.RESIGNATION_NOTE,
BookLoreType.MEMO_STOCKS,
BookLoreType.MEMO_SCHRAB_GSA,
BookLoreType.MEMO_SCHRAB_RD,
BookLoreType.MEMO_SCHRAB_NUKE,
};
/** ITEMBOOKLORE SHIT */
//one downside of all this huge flexibility, make a wrapper if it's too annoying
public static ItemStack generateOfficeBook(Random rand) { //TODO rework this lore in general
String key;
int pages;
switch(rand.nextInt(5)) {
case 0:
key = "resignation_note"; pages = 3; break;
case 1:
key = "memo_stocks"; pages = 1; break;
case 2:
key = "memo_schrab_gsa"; pages = 2; break;
case 3:
key = "memo_schrab_rd"; pages = 4; break;
case 4:
key = "memo_schrab_nuke"; pages = 3; break;
default:
return null;
}
return ItemBookLore.createBook(key, pages, 0x6BC8FF, 0x0A0A0A);
}
}

View File

@ -568,7 +568,8 @@ public class CivilianFeatures {
this.fillWithBlocks(world, box, sizeX - 4, 3, sizeZ - 2, sizeX - 2, 3, sizeZ - 2, ModBlocks.steel_roof, Blocks.air, false);
if(!hasPlacedLoot[1]) {
this.hasPlacedLoot[1] = this.generateInvContents(world, box, rand, ModBlocks.crate_iron, sizeX - 2, 1, 3, HbmChestContents.nukeTrash, 9);
generateLoreBook(world, box, rand, sizeX - 2, 1, 3, 1, HbmChestContents.books_office_sch);
if(rand.nextInt(2) == 0)
generateLoreBook(world, box, sizeX - 2, 1, 3, 1, HbmChestContents.generateOfficeBook(rand));
}
return true;

View File

@ -8,9 +8,8 @@ import com.hbm.blocks.generic.BlockBobble.BobbleType;
import com.hbm.blocks.generic.BlockBobble.TileEntityBobble;
import com.hbm.config.StructureConfig;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.items.ModItems;
import com.hbm.items.special.ItemBookLore.BookLoreType;
import com.hbm.tileentity.machine.TileEntityLockableBase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockWeb;
import net.minecraft.block.material.Material;
@ -267,7 +266,7 @@ abstract public class Component extends StructureComponent {
case 2: //North
dirMeta ^= 2; break; //Flip second bit
case 3: //East
dirMeta = Math.abs(dirMeta - 1) % 4; break; //fuck you modulo
dirMeta = (dirMeta + 3) % 4; break; //fuck you modulo
}
//hee hoo
@ -383,7 +382,7 @@ abstract public class Component extends StructureComponent {
int posY = this.getYWithOffset(featureY);
int posZ = this.getZWithOffset(featureX, featureZ);
if(world.getBlock(posX, posY, posZ) == block) //replacement for hasPlacedLoot checks
if(!box.isVecInside(posX, posY, posZ) || world.getBlock(posX, posY, posZ) == block) //replacement for hasPlacedLoot checks
return true;
this.placeBlockAtCurrentPosition(world, block, meta, featureX, featureY, featureZ, box);
@ -414,7 +413,7 @@ abstract public class Component extends StructureComponent {
int posY = this.getYWithOffset(featureY);
int posZ = this.getZWithOffset(featureX, featureZ);
if(world.getBlock(posX, posY, posZ) == block) //replacement for hasPlacedLoot checks
if(!box.isVecInside(posX, posY, posZ) || world.getBlock(posX, posY, posZ) == block) //replacement for hasPlacedLoot checks
return false;
this.placeBlockAtCurrentPosition(world, block, meta, featureX, featureY, featureZ, box);
@ -435,19 +434,17 @@ abstract public class Component extends StructureComponent {
return false;
}
protected void generateLoreBook(World world, StructureBoundingBox box, Random rand, int featureX, int featureY, int featureZ, int slot, BookLoreType[] books) {
protected void generateLoreBook(World world, StructureBoundingBox box, int featureX, int featureY, int featureZ, int slot, ItemStack stack) { //kept for compat
int posX = this.getXWithOffset(featureX, featureZ);
int posY = this.getYWithOffset(featureY);
int posZ = this.getZWithOffset(featureX, featureZ);
if(!box.isVecInside(posX, posY, posZ)) return;
IInventory inventory = (IInventory) world.getTileEntity(posX, posY, posZ);
if(inventory != null) {
ItemStack book = new ItemStack(ModItems.book_lore);
int i = rand.nextInt(books.length);
BookLoreType.setTypeForStack(book, books[i]);
inventory.setInventorySlotContents(slot, book);
inventory.setInventorySlotContents(slot, stack);
}
}

View File

@ -201,7 +201,7 @@ public class OfficeFeatures {
randomlyFillWithBlocks(world, box, rand, 0.25F, 10, 3, 7, sizeX - 1, 3, sizeZ - 1, Blocks.web);
//Doors
placeDoor(world, box, ModBlocks.door_office, 3, false, rand.nextBoolean(), 2, 1, 7);
placeDoor(world, box, ModBlocks.door_office, 3, false, rand.nextBoolean(), 3, 1, 7);
placeDoor(world, box, ModBlocks.door_office, 3, true, rand.nextBoolean(), 3, 1, 7);
placeDoor(world, box, ModBlocks.door_office, 0, false, rand.nextBoolean(), 5, 1, 6);
//Woot
@ -209,7 +209,8 @@ public class OfficeFeatures {
this.hasPlacedLoot[0] = generateInvContents(world, box, rand, ModBlocks.filing_cabinet, getDecoModelMeta(0), sizeX - 4, 1, sizeZ - 1, HbmChestContents.officeTrash, 8);
if(!this.hasPlacedLoot[1]) {
this.hasPlacedLoot[1] = generateLockableContents(world, box, rand, ModBlocks.safe, getDecoMeta(3), 6, 1, 1, HbmChestContents.machineParts, 10, 0.5D);
generateLoreBook(world, box, rand, 6, 1, 1, 7, HbmChestContents.books_office_sch);
if(rand.nextInt(2) == 0)
generateLoreBook(world, box, 6, 1, 1, 7, HbmChestContents.generateOfficeBook(rand));
}
//0b00/0 West, 0b01/1 East, 0b10/2 North, 0b11/3 South, 0b100/4 West UD, 0b101 East UD, 0b110 North UD, 0b111 South UD
@ -431,12 +432,12 @@ public class OfficeFeatures {
placeDoor(world, box, Blocks.wooden_door, 3, true, rand.nextBoolean(), 2, 1, 14);
placeDoor(world, box, Blocks.wooden_door, 0, false, rand.nextBoolean(), 0, 1, 12);
placeDoor(world, box, Blocks.wooden_door, 0, true, rand.nextBoolean(), 0, 1, 13);
placeDoor(world, box, ModBlocks.door_office, 0, false, rand.nextBoolean(), 6, 1, 3);
placeDoor(world, box, ModBlocks.door_office, 0, false, rand.nextBoolean(), 5, 5, 3);
placeDoor(world, box, ModBlocks.door_office, 3, false, rand.nextBoolean(), 6, 1, 3);
placeDoor(world, box, ModBlocks.door_office, 3, false, rand.nextBoolean(), 5, 5, 3);
placeDoor(world, box, ModBlocks.door_office, 2, false, rand.nextBoolean(), 4, 5, 11);
placeDoor(world, box, ModBlocks.door_office, 0, false, rand.nextBoolean(), 10, 9, 3);
placeDoor(world, box, ModBlocks.door_office, 3, false, rand.nextBoolean(), 10, 9, 3);
placeDoor(world, box, ModBlocks.door_office, 1, false, rand.nextBoolean(), 3, 9, 10);
placeDoor(world, box, ModBlocks.door_metal, 0, false, rand.nextBoolean(), 5, 13, 3);
placeDoor(world, box, ModBlocks.door_metal, 3, false, rand.nextBoolean(), 5, 13, 3);
//Furniture
//Floor 1
int NorthStairMeta = getStairMeta(2);
@ -533,7 +534,8 @@ public class OfficeFeatures {
generateInvContents(world, box, rand, ModBlocks.filing_cabinet, getDecoModelMeta(0), 2, 9, 5, HbmChestContents.filingCabinet, 4);
generateLockableContents(world, box, rand, ModBlocks.safe, getDecoMeta(2), 1, 9, 13, HbmChestContents.officeTrash, 10, 1.0D);
generateLoreBook(world, box, rand, 1, 9, 13, 7, HbmChestContents.books_office_sch);
if(rand.nextInt(2) == 0)
generateLoreBook(world, box, 1, 9, 13, 7, HbmChestContents.generateOfficeBook(rand));
generateInvContents(world, box, rand, ModBlocks.filing_cabinet, getDecoModelMeta(0), 2, 9, 13, HbmChestContents.filingCabinet, 4);
generateInvContents(world, box, rand, ModBlocks.filing_cabinet, getDecoModelMeta(0), 3, 9, 13, HbmChestContents.filingCabinet, 4);

View File

@ -3,7 +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.items.special.ItemBookLore;
import com.hbm.tileentity.machine.storage.TileEntitySafe;
import com.hbm.world.generator.CellularDungeon;
import com.hbm.world.generator.CellularDungeonRoom;
@ -53,7 +53,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, generateMKU(world));
((TileEntitySafe)world.getTileEntity(x + parent.width / 2, y + 2, z + parent.width / 2)).setInventorySlotContents(7, generateBook(world));
else
((TileEntitySafe)world.getTileEntity(x + parent.width / 2, y + 2, z + parent.width / 2)).setInventorySlotContents(7, new ItemStack(Items.book));
}
@ -61,57 +61,51 @@ public class TestDungeonRoom8 extends CellularDungeonRoom {
}
}
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) {
public static ItemStack generateBook(World world) {
MKUCraftingHandler.generateRecipe(world);
ItemStack[] recipe = MKUCraftingHandler.MKURecipe;
if(recipe == null) return new ItemStack(ModItems.flame_pony);
String key;
int pages;
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:
switch(world.rand.nextInt(6)) {
case 0:
key = "book_iodine"; pages = 3;
item = ModItems.powder_iodine; break;
case BOOK_MERCURY:
item = ModItems.ingot_mercury; break;
case BOOK_PHOSPHOROUS:
case 1:
key = "book_phosphorous"; pages = 2;
item = ModItems.powder_fire; break;
case BOOK_SYRINGE:
case 2:
key = "book_dust"; pages = 3;
item = ModItems.dust; break;
case 3:
key = "book_mercury"; pages = 2;
item = ModItems.ingot_mercury; break;
case 4:
key = "book_flower"; pages = 2;
item = ModItems.morning_glory; break;
case 5:
key = "book_syringe"; pages = 2;
item = ModItems.syringe_metal_empty; break;
default:
item = ModItems.nothing; break;
return new ItemStack(ModItems.flame_pony);
}
if(recipe == null) //take no chances
return -2;
int s = 1;
for(int i = 0; i < 9; i++) {
if(recipe[i] != null && recipe[i].getItem() == item) {
return i + 1;
s = i + 1; break;
}
}
return -1;
ItemStack book = ItemBookLore.createBook(key, pages, 0x271E44, 0xFBFFF4);
ItemBookLore.addArgs(book, pages - 1, String.valueOf(s));
return book;
}
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);

View File

@ -321,8 +321,8 @@ book.starter.page18=vær is just a guy who has been trapped in the grey void fea
#book.rbmk.page16=§4§lAvoid.
book_lore.author=By %s
book_lore.test.name=Test
book_lore.test.author=the dude
book_lore.test.name=this book doesn't work...
book_lore.test.author=me i trolled you hehe :3c
book_lore.test.page.0=>hello anons before i begin let me clarify that i'm not gay. >Be me >This night >18 > At hanging out with my best friend with my parents gone for a few days >We've been best friends for a year now >Been drinking a bit and playing lots of video games and ordered a pizza >We were having a blast >At a certain point in the night like around 9:00 he makes a really funny joke that I don't remember but I know that it made us both laugh really hard > With out thinking I brush my right hand through his semi-curly black hair and call him a funny boy >He blushes >I realize I'm feeling flustered >We're kinda close >All of the sudden he kisses me and for some reason I kiss him back >We make love >Cuddle together and fall asleep >Wake up in the middle of the night with his head snuggled up on my chest and neck area >It feels nice but I'm not a homosexual
book_lore.test.page.1=I'm typing this as he's asleep in my arms. How do I let my best friend down nicely? I don't want to be a [redacted] /b/
book_lore.test.page.2=3