/** * Generates a stores potential room positions off of the current template. Note: this does not take into account existing rooms. Check for existing rooms when spawning each specific room position. * @param currentTemplate */ private List<DungeonRoomPosition> generatePotentialRooms(TemplateManager manager, World world, Template currentTemplate, Rotation currentTemplateRotation, BlockPos currentCenter, Rotation currentSide) { List<DungeonRoomPosition> list = Lists.newArrayList(); //Rotation side = Rotation.values()[(int) (Math.random() * 4)]; for (Rotation side : Rotation.values()) { Template nextTemplate = DungeonHelper.getRandomizedDungeonTemplate(manager, world); Rotation nextTemplateRotation = Rotation.values()[(int) (Math.random() * 4)]; BlockPos centeredPosition = DungeonHelper.translateToNextRoom(currentTemplate, nextTemplate, currentCenter, side, currentTemplateRotation, nextTemplateRotation); StructureBoundingBox boundingBox = DungeonHelper.getStructureBoundingBox(nextTemplate, nextTemplateRotation, centeredPosition); if (currentSide == null || (currentSide != null && currentSide.add(Rotation.CLOCKWISE_180) != side)) // check to make sure we aren't spawning a room on the side we just spawned from. { list.add(new DungeonRoomPosition(centeredPosition, nextTemplate, nextTemplateRotation, side, boundingBox)); } } return list; }
/** * second Part of Structure generating, this for example places Spiderwebs, * Mob Spawners, it closes Mineshafts at the end, it adds Fences... */ @Override public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) { final Block var4 = this.getBiomeSpecificBlock(Blocks.planks, 0); for (int var5 = this.boundingBox.minX; var5 <= this.boundingBox.maxX; ++var5) { for (int var6 = this.boundingBox.minZ; var6 <= this.boundingBox.maxZ; ++var6) { if (par3StructureBoundingBox.isVecInside(var5, 64, var6) && (par1World.getBlock(var5, par1World.getTopSolidOrLiquidBlock(var5, var6) - 1, var6) == GCBlocks.blockMoon && par1World.getBlockMetadata(var5, par1World.getTopSolidOrLiquidBlock(var5, var6) - 1, var6) == 5 || Blocks.air == par1World.getBlock(var5, par1World.getTopSolidOrLiquidBlock(var5, var6) - 1, var6))) { final int var7 = par1World.getTopSolidOrLiquidBlock(var5, var6) - 1; par1World.setBlock(var5, var7, var6, var4, 1, 3); } } } return true; }
public static StructureBoundingBox getComponentToAddBoundingBox(int x, int y, int z, int lengthOffset, int heightOffset, int widthOffset, int length, int height, int width, int coordBaseMode) { switch (coordBaseMode) { case 0: return new StructureBoundingBox(x + lengthOffset, y + heightOffset, z + widthOffset, x + length + lengthOffset, y + height + heightOffset, z + width + widthOffset); case 1: return new StructureBoundingBox(x - width + widthOffset, y + heightOffset, z + lengthOffset, x + widthOffset, y + height + heightOffset, z + length + lengthOffset); case 2: return new StructureBoundingBox(x - length - lengthOffset, y + heightOffset, z - width - widthOffset, x - lengthOffset, y + height + heightOffset, z - widthOffset); case 3: return new StructureBoundingBox(x + widthOffset, y + heightOffset, z - length, x + width + widthOffset, y + height + heightOffset, z + lengthOffset); default: return new StructureBoundingBox(x + lengthOffset, y + heightOffset, z + widthOffset, x + length + lengthOffset, y + height + heightOffset, z + width + widthOffset); } }
protected void placeSpawnerAtCurrentPosition(World var1, Random var2, int var3, int var4, int var5, String var6, StructureBoundingBox var7) { final int var8 = this.getXWithOffset(var3, var5); final int var9 = this.getYWithOffset(var4); final int var10 = this.getZWithOffset(var3, var5); if (var7.isVecInside(var8, var9, var10) && var1.getBlock(var8, var9, var10) != Blocks.mob_spawner) { var1.setBlock(var8, var9, var10, Blocks.mob_spawner, 0, 3); final TileEntityMobSpawner var11 = (TileEntityMobSpawner) var1.getTileEntity(var8, var9, var10); if (var11 != null) { var11.func_145881_a().setEntityName(var6); } } }
public static StructureBoundingBox getComponentToAddBoundingBox(int var0, int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9) { switch (var9) { case 0: return new StructureBoundingBox(var0 + var3, var1 + var4, var2 + var5, var0 + var6 + var3, var1 + var7 + var4, var2 + var8 + var5); case 1: return new StructureBoundingBox(var0 - var8 + var5, var1 + var4, var2 + var3, var0 + var5, var1 + var7 + var4, var2 + var6 + var3); case 2: return new StructureBoundingBox(var0 - var6 - var3, var1 + var4, var2 - var8 - var5, var0 - var3, var1 + var7 + var4, var2 - var5); case 3: return new StructureBoundingBox(var0 + var5, var1 + var4, var2 - var6, var0 + var8 + var5, var1 + var7 + var4, var2 + var3); default: return new StructureBoundingBox(var0 + var3, var1 + var4, var2 + var5, var0 + var6 + var3, var1 + var7 + var4, var2 + var8 + var5); } }
@Override public boolean addComponentParts(World world, Random random, StructureBoundingBox boundingBox) { this.fillWithAir(world, boundingBox, 0, 0, 0, 15, 150, 15); world.setBlock(0, 0, 0, AntiMatterModRegistry.explosionTestBlock); int X = 0, Y = 2 << 4, Z = 0, R = 5 << 4; Y:for (int y = Y - R; y <= Y; y++) { for (int x = X - R; x <= X + R; x++) { for (int z = Z - R; z <= Z + R; z++) { if (y <= 0) break Y; double dis = ((X - x) * (X - x) + ((Z - z) * (Z - z)) + ((Y - y) * (Y - y))); if (dis < R * R && y > 0) { world.setBlock(x, y, z, Blocks.air, 0, 2); } } } } return true; }
private static StructureComponent getNextComponentVillagePath(VillageStructureComponentStartPiece par0ComponentVillageStartPiece, List<StructureComponent> par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) { if (par7 > 3 + par0ComponentVillageStartPiece.terrainType) { return null; } else if (Math.abs(par3 - par0ComponentVillageStartPiece.getBoundingBox().minX) <= 112 && Math.abs(par5 - par0ComponentVillageStartPiece.getBoundingBox().minZ) <= 112) { final StructureBoundingBox var8 = VillageStructureComponentPathGen.func_74933_a(par0ComponentVillageStartPiece, par1List, par2Random, par3, par4, par5, par6); if (var8 != null && var8.minY > 10) { final VillageStructureComponentPathGen var9 = new VillageStructureComponentPathGen(par0ComponentVillageStartPiece, par7, par2Random, var8, par6); par1List.add(var9); par0ComponentVillageStartPiece.field_74930_j.add(var9); return var9; } return null; } else { return null; } }
/** * Spawns a number of villagers in this component. Parameters: world, component bounding box, x offset, y * offset, z offset, number of villagers */ protected void spawnVillagers(World p_74893_1_, StructureBoundingBox p_74893_2_, int p_74893_3_, int p_74893_4_, int p_74893_5_, int p_74893_6_) { if (this.villagersSpawned < p_74893_6_) { for (int i1 = this.villagersSpawned; i1 < p_74893_6_; ++i1) { int j1 = this.getXWithOffset(p_74893_3_ + i1, p_74893_5_); int k1 = this.getYWithOffset(p_74893_4_); int l1 = this.getZWithOffset(p_74893_3_ + i1, p_74893_5_); if (!p_74893_2_.isVecInside(j1, k1, l1)) { break; } ++this.villagersSpawned; EntityVillager entityvillager = new EntityVillager(p_74893_1_, this.getVillagerType(i1)); entityvillager.setLocationAndAngles((double)j1 + 0.5D, (double)k1, (double)l1 + 0.5D, 0.0F, 0.0F); p_74893_1_.spawnEntityInWorld(entityvillager); } } }
/** * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at the end, it adds Fences... */ @Override public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) { if (this.averageGroundLevel < 0) { this.averageGroundLevel = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); if (this.averageGroundLevel < 0) { return true; } this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + 4 - 1, 0); } this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 2, 3, 1, Blocks.air, Blocks.air, false); this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 0, 0, par3StructureBoundingBox); this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 1, 0, par3StructureBoundingBox); this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 2, 0, par3StructureBoundingBox); this.placeBlockAtCurrentPosition(par1World, Blocks.wool, 15, 1, 3, 0, par3StructureBoundingBox); this.placeBlockAtCurrentPosition(par1World, GCBlocks.glowstoneTorch, 0, 0, 3, 0, par3StructureBoundingBox); this.placeBlockAtCurrentPosition(par1World, GCBlocks.glowstoneTorch, 0, 1, 3, 1, par3StructureBoundingBox); this.placeBlockAtCurrentPosition(par1World, GCBlocks.glowstoneTorch, 0, 2, 3, 0, par3StructureBoundingBox); this.placeBlockAtCurrentPosition(par1World, GCBlocks.glowstoneTorch, 0, 1, 3, -1, par3StructureBoundingBox); return true; }
@Override public boolean addComponentParts(World p_74875_1_, Random p_74875_2_, StructureBoundingBox p_74875_3_) { if(this.isLiquidInStructureBoundingBox(p_74875_1_, p_74875_3_)) { return false; } // 指定の色の羊毛ブロックで範囲を埋める this.fillWithMetadataBlocks(p_74875_1_, p_74875_3_, 0, 0, 0, 4, 10, 4, Blocks.wool, this.color, Blocks.air, 0, false); this.fillWithAir(p_74875_1_, p_74875_3_, 1, 1, 1, 3, 9, 3); this.placeBlockAtCurrentPosition(p_74875_1_, Blocks.air, 0, 0, 1, 2, p_74875_3_); this.placeBlockAtCurrentPosition(p_74875_1_, Blocks.air, 0, 0, 2, 2, p_74875_3_); this.placeBlockAtCurrentPosition(p_74875_1_, Blocks.air, 0, 0, 3, 2, p_74875_3_); return true; }
public static StructureBoundingBox biasBoundingBox(StructureBoundingBox bb, EnumFacing facing, int distance) { if (facing != null) { switch (facing) { case NORTH: return new StructureBoundingBox(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ + distance); case SOUTH: return new StructureBoundingBox(bb.minX, bb.minY, bb.minZ - distance, bb.maxX, bb.maxY, bb.maxZ); case WEST: return new StructureBoundingBox(bb.minX, bb.minY, bb.minZ, bb.maxX + distance, bb.maxY, bb.maxZ); case EAST: return new StructureBoundingBox(bb.minX - distance, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); case UP: return new StructureBoundingBox(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY + distance, bb.maxZ); case DOWN: return new StructureBoundingBox(bb.minX, bb.minY - distance, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); } } return new StructureBoundingBox(bb.minX - distance, bb.minY - distance, bb.minZ - distance, bb.maxX + distance, bb.maxY + distance, bb.maxZ + distance); }
@Override public boolean addComponentParts(World p_74875_1_, Random p_74875_2_, StructureBoundingBox p_74875_3_) { if(this.isLiquidInStructureBoundingBox(p_74875_1_,p_74875_3_)) return false; // 占有範囲(structureboundingbox)内の指定範囲を指定ブロック&メタデータで埋める // 占有範囲内の指定範囲は占有範囲原点を基準として(0,0,0)-(4,10,4)の範囲 this.fillWithMetadataBlocks(p_74875_1_, p_74875_3_, 0, 0, 0, 4, 10, 4, Blocks.stone,0 ,Blocks.air, 0, false); // 占有範囲(structureboundingbox)内の指定範囲を空気ブロックで埋める // 占有範囲内の指定範囲は占有範囲原点を基準として(1,1,1)-(3,9,3)の範囲 // 要するに中をくりぬいてるってことです this.fillWithAir(p_74875_1_, p_74875_3_, 1, 1, 1, 3, 9, 3); // 占有範囲(structureboundingbox)内の指定範囲を置き換える // 占有範囲内の指定範囲は占有範囲原点を基準として(0,1,2), (0,2,2), (0,3,2)の位置を空気ブロックに置き換えている // 入り口っぽく壁に穴を空けている。coordBaseModeでランダムな方向になってることを確認できるようにするためです this.placeBlockAtCurrentPosition(p_74875_1_, Blocks.air, 0, 0, 1, 2, p_74875_3_); this.placeBlockAtCurrentPosition(p_74875_1_, Blocks.air, 0, 0, 2, 2, p_74875_3_); this.placeBlockAtCurrentPosition(p_74875_1_, Blocks.air, 0, 0, 3, 2, p_74875_3_); return true; }
/** * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes * Mineshafts at the end, it adds Fences... */ public boolean addComponentParts(World p_74875_1_, Random p_74875_2_, StructureBoundingBox p_74875_3_) { Block block = this.func_151558_b(Blocks.gravel, 0); for (int i = this.boundingBox.minX; i <= this.boundingBox.maxX; ++i) { for (int j = this.boundingBox.minZ; j <= this.boundingBox.maxZ; ++j) { if (p_74875_3_.isVecInside(i, 64, j)) { int k = p_74875_1_.getTopSolidOrLiquidBlock(i, j) - 1; p_74875_1_.setBlock(i, k, j, block, 0, 2); } } } return true; }
void fillEmpty(StructureBoundingBox bb, int value) { if (bb.minX > mapbb.maxX || mapbb.minX > bb.maxX || bb.minZ > mapbb.maxZ || mapbb.minZ > bb.maxZ) { return; } StructureBoundingBox ibb = MuonUtils.intersectionBoundingBox(bb, mapbb); for (int xoffs = ibb.minX - mapbb.minX; xoffs <= ibb.maxX - mapbb.minX; ++xoffs) { for (int zoffs = ibb.minZ - mapbb.minZ; zoffs <= ibb.maxZ - mapbb.minZ; ++zoffs) { if (heightmap[xoffs][zoffs] == -1) { heightmap[xoffs][zoffs] = value; if (value != -1) { isBlank = false; } } } } }
public DungeonRoomPosition(BlockPos pos, Template template, Rotation templateRotation, Rotation side, StructureBoundingBox boundingBox) { this.pos = pos; this.template = template; this.templateRotation = templateRotation; this.side = side; this.boundingBox = boundingBox; }
/** * Procedurally generate a dungeon through recursion using a simple 'Procedurally Build' algorithm. * @param manager * @param world * @param startingPos - this position will ALWAYS be the position of the entrance. */ public void procedurallyGenerate(TemplateManager manager, World world, BlockPos startingPos, List<DungeonRoomPosition> nextPos) { List<DungeonRoomPosition> nextPos2 = Lists.newArrayList(); // list which will hold the positions to be tried in the NEXT recursion of the method. if (roomCount > roomTries) return; else { ArrayList<StructureBoundingBox> roomListCopy = Lists.newArrayList(roomList); for (DungeonRoomPosition room : nextPos) { // check to make sure rooms don't overlap for (StructureBoundingBox existingBB : roomListCopy) { // if structures don't overlap if (!DungeonHelper.checkOverlap(existingBB, room.getBoundingBox())) { LootSlashConquer.LOGGER.info("Room generated successfully."); List<DungeonRoomPosition> nextRooms = this.generateRoom(manager, world, room); // copy new generated rooms into bigger list for (DungeonRoomPosition nextRoom : nextRooms) { nextPos2.add(nextRoom); } } else { LootSlashConquer.LOGGER.info("Room failed to generate."); } } } } roomCount++; procedurallyGenerate(manager, world, startingPos, nextPos2); }
/** Returns the bounding box of the specific template. Used to make sure it doesn't intersect with other rooms. */ public static StructureBoundingBox getStructureBoundingBox(Template template, Rotation rotation, BlockPos center) { int minX = 0; int maxX = 0; int minY = 0; int maxY = 0; int minZ = 0; int maxZ = 0; // we offset everything by one to get the inner room with walls, ceilings, or floors. Rooms can connect through walls so we want those checks to pass. if (rotation == Rotation.NONE || rotation == Rotation.CLOCKWISE_180) { minX = center.getX() - (template.getSize().getX() / 2) - 1; maxX = center.getX() + (template.getSize().getX() / 2) - 1; minY = center.getY() + 1; maxY = center.getY() + template.getSize().getY() - 1; minZ = center.getZ() - (template.getSize().getZ() / 2) - 1; maxZ = center.getZ() + (template.getSize().getZ() / 2) - 1; } else { minX = center.getX() - (template.getSize().getZ() / 2) - 1; maxX = center.getX() + (template.getSize().getZ() / 2) - 1; minY = center.getY() + 1; maxY = center.getY() + template.getSize().getY() - 1; minZ = center.getZ() - (template.getSize().getX() / 2) - 1; maxZ = center.getZ() + (template.getSize().getX() / 2) - 1; } return new StructureBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); }
/** Returns true if the two structures overlap. */ public static boolean checkOverlap(StructureBoundingBox existingStructure, StructureBoundingBox nextStructure) { /*if (existingStructure.minX > nextStructure.maxX) return false; if (existingStructure.maxX < nextStructure.minX) return false; if (existingStructure.minY > nextStructure.maxY) return false; if (existingStructure.maxY < nextStructure.minY) return false; if (existingStructure.minZ > nextStructure.maxZ) return false; if (existingStructure.maxZ < nextStructure.minZ) return false;*/ return false; }
public Map<BlockPos, String> getDataBlocks(BlockPos pos, PlacementSettings placementIn) { Map<BlockPos, String> map = Maps.<BlockPos, String>newHashMap(); StructureBoundingBox structureboundingbox = placementIn.getBoundingBox(); for (Template.BlockInfo template$blockinfo : this.blocks) { BlockPos blockpos = transformedBlockPos(placementIn, template$blockinfo.pos).add(pos); if (structureboundingbox == null || structureboundingbox.isVecInside(blockpos)) { IBlockState iblockstate = template$blockinfo.blockState; if (iblockstate.getBlock() instanceof BlockStructure && template$blockinfo.tileentityData != null) { TileEntityStructure.Mode tileentitystructure$mode = TileEntityStructure.Mode.valueOf(template$blockinfo.tileentityData.getString("mode")); if (tileentitystructure$mode == TileEntityStructure.Mode.DATA) { map.put(blockpos, template$blockinfo.tileentityData.getString("metadata")); } } } } return map; }
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb) { for (Template.EntityInfo template$entityinfo : this.entities) { BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos); if (aabb == null || aabb.isVecInside(blockpos)) { NBTTagCompound nbttagcompound = template$entityinfo.entityData; Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn); Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); NBTTagList nbttaglist = new NBTTagList(); nbttaglist.appendTag(new NBTTagDouble(vec3d1.x)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.y)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.z)); nbttagcompound.setTag("Pos", nbttaglist); nbttagcompound.setUniqueId("UUID", UUID.randomUUID()); Entity entity; try { entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn); } catch (Exception var15) { entity = null; } if (entity != null) { float f = entity.getMirroredYaw(mirrorIn); f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn)); entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch); worldIn.spawnEntity(entity); } } } }
public List<NextTickListEntry> getPendingBlockUpdates(Chunk chunkIn, boolean p_72920_2_) { ChunkCoordIntPair chunkcoordintpair = chunkIn.getChunkCoordIntPair(); int i = (chunkcoordintpair.chunkXPos << 4) - 2; int j = i + 16 + 2; int k = (chunkcoordintpair.chunkZPos << 4) - 2; int l = k + 16 + 2; return this.func_175712_a(new StructureBoundingBox(i, 0, k, j, 256, l), p_72920_2_); }
@Override public boolean isAreaLoaded(StructureBoundingBox box) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.isAreaLoaded(box); } else if (m_realWorld != null) { return m_realWorld.isAreaLoaded(box); } else { return super.isAreaLoaded(box); } }
@Override public boolean isAreaLoaded(StructureBoundingBox box, boolean allowEmpty) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.isAreaLoaded(box, allowEmpty); } else if (m_realWorld != null) { return m_realWorld.isAreaLoaded(box, allowEmpty); } else { return super.isAreaLoaded(box, allowEmpty); } }
@Override public List<NextTickListEntry> getPendingBlockUpdates(StructureBoundingBox structureBB, boolean remove) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.getPendingBlockUpdates(structureBB, remove); } else if (m_realWorld != null) { return m_realWorld.getPendingBlockUpdates(structureBB, remove); } else { return super.getPendingBlockUpdates(structureBB, remove); } }
@Nullable public List<NextTickListEntry> getPendingBlockUpdates(Chunk chunkIn, boolean p_72920_2_) { ChunkPos chunkpos = chunkIn.getChunkCoordIntPair(); int i = (chunkpos.chunkXPos << 4) - 2; int j = i + 16 + 2; int k = (chunkpos.chunkZPos << 4) - 2; int l = k + 16 + 2; return this.getPendingBlockUpdates(new StructureBoundingBox(i, 0, k, j, 256, l), p_72920_2_); }
@Nullable public StructureBoundingBox getBoundingBox() { if (this.boundingBox == null && this.chunk != null) { this.setBoundingBoxFromChunk(); } return this.boundingBox; }
@Nullable private StructureBoundingBox getBoundingBoxFromChunk(@Nullable ChunkPos pos) { if (pos == null) { return null; } else { int i = pos.chunkXPos * 16; int j = pos.chunkZPos * 16; return new StructureBoundingBox(i, 0, j, i + 16 - 1, 255, j + 16 - 1); } }
public Map<BlockPos, String> getDataBlocks(BlockPos pos, PlacementSettings placementIn) { Map<BlockPos, String> map = Maps.<BlockPos, String>newHashMap(); StructureBoundingBox structureboundingbox = placementIn.getBoundingBox(); for (Template.BlockInfo template$blockinfo : this.blocks) { BlockPos blockpos = transformedBlockPos(placementIn, template$blockinfo.pos).add(pos); if (structureboundingbox == null || structureboundingbox.isVecInside(blockpos)) { IBlockState iblockstate = template$blockinfo.blockState; if (iblockstate.getBlock() == Blocks.STRUCTURE_BLOCK && template$blockinfo.tileentityData != null) { TileEntityStructure.Mode tileentitystructure$mode = TileEntityStructure.Mode.valueOf(template$blockinfo.tileentityData.getString("mode")); if (tileentitystructure$mode == TileEntityStructure.Mode.DATA) { map.put(blockpos, template$blockinfo.tileentityData.getString("metadata")); } } } } return map; }
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb) { for (Template.EntityInfo template$entityinfo : this.entities) { BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos); if (aabb == null || aabb.isVecInside(blockpos)) { NBTTagCompound nbttagcompound = template$entityinfo.entityData; Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn); Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); NBTTagList nbttaglist = new NBTTagList(); nbttaglist.appendTag(new NBTTagDouble(vec3d1.xCoord)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.yCoord)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.zCoord)); nbttagcompound.setTag("Pos", nbttaglist); nbttagcompound.setUniqueId("UUID", UUID.randomUUID()); Entity entity; try { entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn); } catch (Exception var15) { entity = null; } if (entity != null) { float f = entity.getMirroredYaw(mirrorIn); f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn)); entity.setLocationAndAngles(vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, f, entity.rotationPitch); worldIn.spawnEntityInWorld(entity); } } } }
public boolean generate(World worldIn, Random rand, BlockPos position) { Random random = worldIn.getChunkFromBlockCoords(position).getRandomWithSeed(987234911L); MinecraftServer minecraftserver = worldIn.getMinecraftServer(); Rotation[] arotation = Rotation.values(); Rotation rotation = arotation[random.nextInt(arotation.length)]; int i = random.nextInt(FOSSILS.length); TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager(); Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]); Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]); ChunkPos chunkpos = new ChunkPos(position); StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd()); PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random); BlockPos blockpos = template.transformedSize(rotation); int j = random.nextInt(16 - blockpos.getX()); int k = random.nextInt(16 - blockpos.getZ()); int l = 256; for (int i1 = 0; i1 < blockpos.getX(); ++i1) { for (int j1 = 0; j1 < blockpos.getX(); ++j1) { l = Math.min(l, worldIn.getHeight(position.getX() + i1 + j, position.getZ() + j1 + k)); } } int k1 = Math.max(l - 15 - random.nextInt(10), 10); BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation); placementsettings.setIntegrity(0.9F); template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20); placementsettings.setIntegrity(0.1F); template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20); return true; }
public boolean detectSize() { if (this.mode != TileEntityStructure.Mode.SAVE) { return false; } else { BlockPos blockpos = this.getPos(); int i = 80; BlockPos blockpos1 = new BlockPos(blockpos.getX() - 80, 0, blockpos.getZ() - 80); BlockPos blockpos2 = new BlockPos(blockpos.getX() + 80, 255, blockpos.getZ() + 80); List<TileEntityStructure> list = this.getNearbyCornerBlocks(blockpos1, blockpos2); List<TileEntityStructure> list1 = this.filterRelatedCornerBlocks(list); if (list1.size() < 1) { return false; } else { StructureBoundingBox structureboundingbox = this.calculateEnclosingBoundingBox(blockpos, list1); if (structureboundingbox.maxX - structureboundingbox.minX > 1 && structureboundingbox.maxY - structureboundingbox.minY > 1 && structureboundingbox.maxZ - structureboundingbox.minZ > 1) { this.position = new BlockPos(structureboundingbox.minX - blockpos.getX() + 1, structureboundingbox.minY - blockpos.getY() + 1, structureboundingbox.minZ - blockpos.getZ() + 1); this.size = new BlockPos(structureboundingbox.maxX - structureboundingbox.minX - 1, structureboundingbox.maxY - structureboundingbox.minY - 1, structureboundingbox.maxZ - structureboundingbox.minZ - 1); this.markDirty(); IBlockState iblockstate = this.world.getBlockState(blockpos); this.world.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 3); return true; } else { return false; } } } }
@Override public Village buildComponent(PieceWeight villagePiece, Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) { StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 14, 16, 11, facing); return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(pieces, structureboundingbox) == null ? new MannCoBuilding(startPiece, p5, random, structureboundingbox, facing) : null; }