From 34d3b117139c8d07069184cf734b82744a7c6792 Mon Sep 17 00:00:00 2001 From: Vaern Date: Sat, 10 Sep 2022 20:07:57 -0700 Subject: [PATCH] bozo get btfo'd kekW --- .../java/com/hbm/lib/HbmChestContents.java | 33 +++++++++++++++++++ .../world/worldgen/components/Feature.java | 16 +++++++++ .../worldgen/components/OfficeFeatures.java | 8 ++++- src/main/resources/assets/hbm/lang/en_US.lang | 6 ++++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/hbm/lib/HbmChestContents.java b/src/main/java/com/hbm/lib/HbmChestContents.java index 56cb0a257..e8b53cd74 100644 --- a/src/main/java/com/hbm/lib/HbmChestContents.java +++ b/src/main/java/com/hbm/lib/HbmChestContents.java @@ -6,10 +6,16 @@ import com.hbm.blocks.ModBlocks; import com.hbm.inventory.fluid.Fluids; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemBreedingRod.*; +import com.hbm.util.I18nUtil; import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; public class HbmChestContents { @@ -350,4 +356,31 @@ public class HbmChestContents { new WeightedRandomChestContent(ModItems.can_mrsugar, 0, 1, 2, 2), new WeightedRandomChestContent(ModItems.book_guide, 3, 1, 1, 1), new WeightedRandomChestContent(Item.getItemFromBlock(ModBlocks.deco_computer), 0, 1, 1, 1)}; + + /** Nowhere else to put this and this seems like the most fitting place **/ + public static ItemStack genetateBook(String key) { + + String author = I18nUtil.resolveKey("book.lore." + key + ".author"); + String title = I18nUtil.resolveKey("book.lore." + key + ".title"); + + ItemStack book = new ItemStack(Items.written_book); + book.stackTagCompound = new NBTTagCompound(); + book.stackTagCompound.setString("author", author); + book.stackTagCompound.setString("title", title); + NBTTagList nbt = new NBTTagList(); + + for(byte i = 1; i <= 50; i++) { + String unloc = "book.lore." + key + ".page" + i; + String page = I18nUtil.resolveKey(unloc); + + if(page.equals(unloc)) + break; + else + nbt.appendTag(new NBTTagString(page)); + } + + book.stackTagCompound.setTag("pages", nbt); + + return book; + } } diff --git a/src/main/java/com/hbm/world/worldgen/components/Feature.java b/src/main/java/com/hbm/world/worldgen/components/Feature.java index d185fb4c3..4a7a82703 100644 --- a/src/main/java/com/hbm/world/worldgen/components/Feature.java +++ b/src/main/java/com/hbm/world/worldgen/components/Feature.java @@ -6,6 +6,7 @@ import com.hbm.blocks.ModBlocks; import com.hbm.blocks.generic.BlockBobble.BobbleType; import com.hbm.blocks.generic.BlockBobble.TileEntityBobble; import com.hbm.config.StructureConfig; +import com.hbm.lib.HbmChestContents; import com.hbm.tileentity.machine.TileEntityLockableBase; import com.hbm.tileentity.machine.storage.TileEntityCrateIron; @@ -14,6 +15,7 @@ import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemDoor; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.WeightedRandomChestContent; @@ -294,6 +296,20 @@ abstract public class Feature extends StructureComponent { return false; } + protected void generateLoreBook(World world, StructureBoundingBox box, int featureX, int featureY, int featureZ, int slot, String key) { + int posX = this.getXWithOffset(featureX, featureZ); + int posY = this.getYWithOffset(featureY); + int posZ = this.getZWithOffset(featureX, featureZ); + + IInventory inventory = (IInventory) world.getTileEntity(posX, posY, posZ); + + if(inventory != null) { + ItemStack book = HbmChestContents.genetateBook(key); + + inventory.setInventorySlotContents(slot, book); + } + } + /** * Places random bobblehead with a randomized orientation at specified location */ diff --git a/src/main/java/com/hbm/world/worldgen/components/OfficeFeatures.java b/src/main/java/com/hbm/world/worldgen/components/OfficeFeatures.java index 870f515a7..ebcdeb079 100644 --- a/src/main/java/com/hbm/world/worldgen/components/OfficeFeatures.java +++ b/src/main/java/com/hbm/world/worldgen/components/OfficeFeatures.java @@ -62,6 +62,10 @@ public class OfficeFeatures { placeFoundationUnderneath(world, Blocks.stonebrick, 0, 0, 8, 8, sizeZ, 0, box); placeFoundationUnderneath(world, Blocks.stonebrick, 0, 9, 8, sizeX, sizeZ, -1, box); + fillWithAir(world, box, 1, 1, 3, 4, 3, 6); + fillWithAir(world, box, 6, 1, 1, sizeX - 1, 3, 6); + fillWithAir(world, box, 10, 1, 7, sizeX - 1, 3, sizeZ - 1); + //Pillars //Back fillWithBlocks(world, box, 0, 0, 2, 0, 4, 2, ModBlocks.concrete_pillar); @@ -201,8 +205,10 @@ public class OfficeFeatures { //Woot if(!this.hasPlacedLoot[0]) this.hasPlacedLoot[0] = generateInvContents(world, box, rand, Blocks.chest, sizeX - 4, 1, sizeZ - 1, HbmChestContents.officeTrash, 10); - if(!this.hasPlacedLoot[1]) + if(!this.hasPlacedLoot[1]) { this.hasPlacedLoot[1] = generateLockableContents(world, box, rand, ModBlocks.safe, 6, 1, 1, HbmChestContents.machineParts, 10, 0.5D); + generateLoreBook(world, box, 6, 1, 1, 7, "office" + rand.nextInt(1)); + } //TODO: add book with funny lore to safe, add cobwebs too //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 diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index cb6f6b8b1..0cd04cc47 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -314,6 +314,12 @@ book.starter.page18=vær is just a guy who has been trapped in the grey void fea #book.rbmk.title16=Meltdown #book.rbmk.page16=§4§lAvoid. +book.lore.office0.title=Letter of Resignation +book.lore.office0.author=Kosma +book.lore.office0.page1=Management downsized our department again yesterday. Those idiots only have themselves to blame, I don't know what they were expecting after the Panay fiasco. Who the hell leaks that sort of information? We're losing millions and +book.lore.office0.page2=it's ME who's the one out of a job now. I'M the one being asked to resign. I hope you asshats finally learn from your overabundance of mistakes and take that stick out of your ass. +book.lore.office0.page3=I'm not coming back tomorrow. Just send the paycheck. + cannery.f1=[ Press F1 for help ] cannery.centrifuge=Gas Centrifuge