diff --git a/src/main/java/com/hbm/items/tool/ItemWandD.java b/src/main/java/com/hbm/items/tool/ItemWandD.java index 1560b01d8..18fde60fa 100644 --- a/src/main/java/com/hbm/items/tool/ItemWandD.java +++ b/src/main/java/com/hbm/items/tool/ItemWandD.java @@ -3,21 +3,16 @@ package com.hbm.items.tool; import java.util.List; import com.hbm.entity.effect.EntityNukeTorex; -import com.hbm.handler.pollution.PollutionHandler; -import com.hbm.handler.pollution.PollutionHandler.PollutionType; import com.hbm.lib.Library; import com.hbm.util.TrackerUtil; +import com.hbm.world.gen.MapGenNTMFeatures; -import cpw.mods.fml.relauncher.ReflectionHelper; -import net.minecraft.entity.EntityTracker; -import net.minecraft.entity.EntityTrackerEntry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.IntHashMap; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; +import net.minecraft.world.gen.structure.StructureBoundingBox; public class ItemWandD extends Item { @@ -40,18 +35,14 @@ public class ItemWandD extends Item { vnt.explode();*/ //PollutionHandler.incrementPollution(world, pos.blockX, pos.blockY, pos.blockZ, PollutionType.SOOT, 15); - - //HbmWorld.worldGenerator.specialFeatureGen.findClosestPosition(pos.blockX >> 4, pos.blockZ >> 4); - + int i = pos.blockX >> 4; int j = pos.blockZ >> 4; - //MapGenNTMFeatures.Start start = new MapGenNTMFeatures.Start(world, world.rand, i, j); + MapGenNTMFeatures.Start start = new MapGenNTMFeatures.Start(world, world.rand, i, j); i = (i << 4) + 8; j = (j << 4) + 8; - LargeOfficeCorner corner = new LargeOfficeCorner(world.rand, i, 64, j); - corner.addComponentParts(world, world.rand, corner.getBoundingBox()); - //start.generateStructure(world, world.rand, new StructureBoundingBox(i, j, i + 32, j + 32)); + start.generateStructure(world, world.rand, new StructureBoundingBox(i, j, i + 32, j + 32)); /*TimeAnalyzer.startCount("setBlock"); world.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.dirt); @@ -73,7 +64,7 @@ public class ItemWandD extends Item { tom.destructionRange = 600; world.spawnEntityInWorld(tom);*/ - EntityNukeTorex torex = new EntityNukeTorex(world); + /*EntityNukeTorex torex = new EntityNukeTorex(world); torex.setPositionAndRotation(pos.blockX, pos.blockY + 1, pos.blockZ, 0, 0); torex.getDataWatcher().updateObject(10, 1.5F); world.spawnEntityInWorld(torex); @@ -81,7 +72,7 @@ public class ItemWandD extends Item { IntHashMap map = ReflectionHelper.getPrivateValue(EntityTracker.class, entitytracker, "trackedEntityIDs", "field_72794_c"); EntityTrackerEntry entry = (EntityTrackerEntry) map.lookup(torex.getEntityId()); entry.blocksDistanceThreshold = 1000;*/ - TrackerUtil.setTrackingRange(world, torex, 1000); + //TrackerUtil.setTrackingRange(world, torex, 1000); //world.spawnEntityInWorld(EntityNukeExplosionMK5.statFacNoRad(world, 150, pos.blockX, pos.blockY + 1, pos.blockZ)); //DungeonToolbox.generateBedrockOreWithChance(world, world.rand, pos.blockX, pos.blockZ, EnumBedrockOre.TITANIUM, new FluidStack(Fluids.SULFURIC_ACID, 500), 2, 1); diff --git a/src/main/java/com/hbm/lib/HbmChestContents.java b/src/main/java/com/hbm/lib/HbmChestContents.java index 045896b42..d166e3bab 100644 --- a/src/main/java/com/hbm/lib/HbmChestContents.java +++ b/src/main/java/com/hbm/lib/HbmChestContents.java @@ -16,6 +16,7 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.ChunkCoordIntPair; public class HbmChestContents { @@ -452,4 +453,28 @@ public class HbmChestContents { return ItemBookLore.createBook(key, pages, 0x1E1E1E, 0x46EA44); } + + public static ItemStack generateRuinBook(Random rand, int chunkX, int chunkZ) { + ChunkCoordIntPair pair = HbmWorld.worldGenerator.specialFeatureGen.findClosestPosition(chunkX, chunkZ); + int[] vec = new int[] { pair.chunkXPos - chunkX, pair.chunkZPos - chunkZ }; + int dist = (int) Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1]); + + String conf = "book_lore.ruin_special."; + if(dist > 128) { + dist -= dist * .5F * (.5F - rand.nextFloat()); + conf += "low"; + } else if(dist > 64) { + dist -= dist * .25F * (.5F - rand.nextFloat()); + conf += "med"; + } else { + conf += "high"; + } + + String angle = Math.round(Math.toDegrees(Math.atan2(vec[0], vec[1])) * 10000D) / 10000D + ""; + String res = (Math.round((dist * 16) / 1000D * 100D) / 100D) + ""; + + ItemStack book = ItemBookLore.createBook("ruin_special", 1, 0x770011, 0xFFFFFF); + ItemBookLore.addArgs(book, 0, res, angle, conf); + return book; + } } diff --git a/src/main/java/com/hbm/world/gen/MapGenNTMFeatures.java b/src/main/java/com/hbm/world/gen/MapGenNTMFeatures.java index 79c863242..5b24ea05a 100644 --- a/src/main/java/com/hbm/world/gen/MapGenNTMFeatures.java +++ b/src/main/java/com/hbm/world/gen/MapGenNTMFeatures.java @@ -161,8 +161,6 @@ public class MapGenNTMFeatures extends MapGenStructure { this.components.add(officeCorner); break; } } - //ElevatedLab1 lab1 = new ElevatedLab1(rand, chunkX * 16 + 8, posY, chunkZ * 16 + 8); - //this.components.add(lab1); if(GeneralConfig.enableDebugMode) { System.out.print("[Debug] StructureStart at " + (chunkX * 16 + 8) + ", " + posY + ", " + (chunkZ * 16 + 8) + "\n[Debug] Components: "); diff --git a/src/main/java/com/hbm/world/gen/MapGenSpecialFeatures.java b/src/main/java/com/hbm/world/gen/MapGenSpecialFeatures.java index 5cca710ce..e6a104c8d 100644 --- a/src/main/java/com/hbm/world/gen/MapGenSpecialFeatures.java +++ b/src/main/java/com/hbm/world/gen/MapGenSpecialFeatures.java @@ -23,8 +23,6 @@ public class MapGenSpecialFeatures extends MapGenStructure { //suuuuuper efficient for .contains() //do i even need chunkcoordintpairs? idk Set locs = new HashSet(); - //efficient enough for books n shit - List bookLocs = new ArrayList(); /** String ID for this MapGen */ @Override @@ -46,13 +44,13 @@ public class MapGenSpecialFeatures extends MapGenStructure { //i'll probs make a system to predict which locations are what in advance //seems like biomes can be cached/gen'd without creating the chunk, thankfully - //vec3 will be the angle + distance from provided coords, given in chunk coords - public Vec3 findClosestPosition(int chunkX, int chunkZ) { - createBookList(); + public ChunkCoordIntPair findClosestPosition(int chunkX, int chunkZ) { + if(locs.isEmpty()) + generatePositions(); ChunkCoordIntPair pair = new ChunkCoordIntPair(0, 0); long dist = Long.MAX_VALUE; - for(ChunkCoordIntPair loc : bookLocs) { + for(ChunkCoordIntPair loc : locs) { int x = loc.chunkXPos - chunkX; int z = loc.chunkZPos - chunkZ; long cont = x * x + z * z; @@ -63,18 +61,7 @@ public class MapGenSpecialFeatures extends MapGenStructure { } } - return Vec3.createVectorHelper(pair.chunkXPos - chunkX, 0, pair.chunkZPos - chunkZ); - } - - protected void createBookList() { - if(locs.isEmpty()) - generatePositions(); - - if(!bookLocs.isEmpty()) return; - - for(ChunkCoordIntPair loc : locs) { - bookLocs.add(loc); - } + return pair; } protected void generatePositions() { @@ -111,8 +98,6 @@ public class MapGenSpecialFeatures extends MapGenStructure { @Override protected StructureStart getStructureStart(int chunkX, int chunkZ) { - locs.remove(new ChunkCoordIntPair(chunkX, chunkZ)); - return new SpecialStart(this.worldObj, this.rand, chunkX, chunkZ); } diff --git a/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java b/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java index 172c9bd2d..45d7a24a2 100644 --- a/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java +++ b/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java @@ -17,9 +17,9 @@ import static net.minecraftforge.event.terraingen.TerrainGen.*; import net.minecraftforge.event.world.WorldEvent; public class NTMWorldGenerator implements IWorldGenerator { - - private MapGenNTMFeatures scatteredFeatureGen; //looks like it's based! thank god! - public MapGenSpecialFeatures specialFeatureGen; //change back if it's actually cringe and throws NPEs + //turns out minecraft is cringe and WorldEvent.Load can be/is called after chunks are provided + private MapGenNTMFeatures scatteredFeatureGen = new MapGenNTMFeatures(); + public MapGenSpecialFeatures specialFeatureGen = new MapGenSpecialFeatures(); private final Random rand = new Random(); //A central random, used to cleanly generate our stuff without affecting vanilla or modded seeds. diff --git a/src/main/java/com/hbm/world/gen/component/Component.java b/src/main/java/com/hbm/world/gen/component/Component.java index d64f95ef4..e11e5aca5 100644 --- a/src/main/java/com/hbm/world/gen/component/Component.java +++ b/src/main/java/com/hbm/world/gen/component/Component.java @@ -528,7 +528,7 @@ abstract public class Component extends StructureComponent { //Turns out, this entire time every single minecraft structure is mirrored instead of rotated when facing East and North //Also turns out, it's a scarily easy fix that they somehow didn't see *entirely* @Override - protected int getXWithOffset(int x, int z) { + public int getXWithOffset(int x, int z) { switch(this.coordBaseMode) { case 0: return this.boundingBox.minX + x; @@ -544,7 +544,7 @@ abstract public class Component extends StructureComponent { } @Override - protected int getZWithOffset(int x, int z) { + public int getZWithOffset(int x, int z) { switch(this.coordBaseMode) { case 0: return this.boundingBox.minZ + z; diff --git a/src/main/java/com/hbm/world/gen/component/OfficeFeatures.java b/src/main/java/com/hbm/world/gen/component/OfficeFeatures.java index a6322c4c6..244c1c8f4 100644 --- a/src/main/java/com/hbm/world/gen/component/OfficeFeatures.java +++ b/src/main/java/com/hbm/world/gen/component/OfficeFeatures.java @@ -3,16 +3,11 @@ package com.hbm.world.gen.component; import java.util.Random; import com.hbm.blocks.ModBlocks; -import com.hbm.items.special.ItemBookLore; import com.hbm.lib.HbmChestContents; -import com.hbm.lib.HbmWorld; import com.hbm.util.LootGenerator; import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.Vec3; -import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraft.world.gen.structure.StructureBoundingBox; @@ -551,12 +546,6 @@ public class OfficeFeatures { LootGenerator.lootCapStash(world, this.getXWithOffset(6, 11), this.getYWithOffset(13), this.getZWithOffset(6, 11)); placeBlockAtCurrentPosition(world, ModBlocks.deco_loot, 0, 1, 10, 11, box); LootGenerator.lootMedicine(world, this.getXWithOffset(1, 11), this.getYWithOffset(10), this.getZWithOffset(1, 11)); - - //if(rand.nextInt(3) == 0) { - Vec3 pair = HbmWorld.worldGenerator.specialFeatureGen.findClosestPosition(this.boundingBox.minX >> 4, this.boundingBox.minZ >> 4); - ItemStack book = ItemBookLore.createBook(pair.xCoord * 16 + ", " + pair.zCoord * 16, 1, 0x7F0037, 0xFFFFFF); - placeLootBlock(world, box, rand, 8, 10, 10, book); - //} //this hurt my soul return true; diff --git a/src/main/java/com/hbm/world/gen/component/RuinFeatures.java b/src/main/java/com/hbm/world/gen/component/RuinFeatures.java index 914b01b7e..ff494c6b0 100644 --- a/src/main/java/com/hbm/world/gen/component/RuinFeatures.java +++ b/src/main/java/com/hbm/world/gen/component/RuinFeatures.java @@ -3,8 +3,10 @@ package com.hbm.world.gen.component; import java.util.Random; import com.hbm.blocks.ModBlocks; +import com.hbm.lib.HbmChestContents; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraft.world.gen.structure.StructureBoundingBox; @@ -18,6 +20,21 @@ public class RuinFeatures { MapGenStructureIO.func_143031_a(NTMRuin4.class, "NTMRuin4"); } + public static void placeBook(World world, StructureBoundingBox box, Random rand, int minX, int minZ, int maxX, int maxZ, Component com) { + int i = minX + rand.nextInt(maxX); + int j = minZ + rand.nextInt(maxZ); + + int posX = com.getXWithOffset(i, j); + int posZ = com.getZWithOffset(i, j); + + if(box.isVecInside(posX, 64, posZ)) { + int topHeight = world.getTopSolidOrLiquidBlock(posX, posZ); + + ItemStack book = HbmChestContents.generateRuinBook(rand, posX >> 4, posZ >> 4); + com.placeLootBlock(world, box, rand, i, topHeight - com.getBoundingBox().minY, j, book); + } + } + public static class NTMRuin1 extends Component { private static ConcreteBricks RandomConcreteBricks = new ConcreteBricks(); @@ -86,6 +103,9 @@ public class RuinFeatures { this.randomlyFillWithBlocks(world, box, rand, 0.25F, 1, 0, 1, 8 - 1, 0, 10 - 1, Blocks.gravel, Blocks.air, false); + if(rand.nextInt(3) == 0) //it's all in one chunk so it's fine + placeBook(world, box, rand, 1, 1, 7, 9, this); + return true; } } @@ -206,6 +226,9 @@ public class RuinFeatures { this.randomlyFillWithBlocks(world, box, rand, 0.05F, 1, 0, 1, 8 - 1, 0, 3, Blocks.gravel, Blocks.air, false); this.randomlyFillWithBlocks(world, box, rand, 0.05F, 1, 0, 5, 8 - 1, 0, 10 - 1, Blocks.gravel, Blocks.air, false); + if(rand.nextInt(3) == 0) + placeBook(world, box, rand, 1, 5, 7, 9, this); + return true; } } @@ -267,6 +290,9 @@ public class RuinFeatures { this.randomlyFillWithBlocks(world, box, rand, 0.05F, 1, 0, 1, 4, 0, 5, Blocks.gravel, Blocks.air, false); this.randomlyFillWithBlocks(world, box, rand, 0.05F, 1, 0, 6, 10 - 1, 0, 11 - 1, Blocks.gravel, Blocks.air, false); + if(rand.nextInt(3) == 0) + placeBook(world, box, rand, 1, 1, 4, 10, this); + return true; } } diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index 87e424890..910f32ce9 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -446,6 +446,12 @@ book_lore.beacon.page.9=Once the desired peer has responded, give the "ACCEPT CO book_lore.beacon.page.10=using the FAR-5M standard. Communication will end immediately if no standard has been negotiated, serving as a "ping". Should communication continue, the connection can be ended using another long single tone "END CONNECTION". book_lore.beacon.page.11=Chapter 5: Warranty $ [ page intentionally left blank ] +book_lore.ruin_special.name=Detection Printout +book_lore.ruin_special.page.0=§lDETECTION $ ----------------- $ DIST: %1$s km $ THETA: %2$s° $ PROGNOSIS $ %3$s +book_lore.ruin_special.low=Low-confidence detection. Distance is large and imprecise; high chance of interference. +book_lore.ruin_special.med=Medium-confidence detection. Chance of interference is low; further investigation recommended. +book_lore.ruin_special.high=High-confidence detection. Location precisely triangulated by sensors; expedition urgently recommended. + cannery.f1=[ Press F1 for help ] cannery.centrifuge=Gas Centrifuge