public static StructureBoundingBox findPieceBox(StructureVillagePieces.Start start, List<StructureComponent> structureComponents, Random rand, int structureMinX, int structureMinY, int structureMinZ, EnumFacing facing) { // for the Grove, find the largest unoccupied space in the village. we will later plant that with trees/saplings StructureBoundingBox villagebb = new StructureBoundingBox(start.getBoundingBox()); MuonHeightMap found = MuonHooks.findTerrain(villagebb, villagebb); MuonHeightMap original = null; for (StructureComponent piece : structureComponents) { villagebb.expandTo(piece.getBoundingBox()); } if (found != null) { original = MuonHeightMap.defaultHeights(found.world, found.mapbb); } // call recursive function to find best gap in bounding box StructureBoundingBox position = null; position = findPieceGap(villagebb, start, structureComponents, found, original); if (position == null) { // if we couldn't find a spot within the strict village boundary, look around the edges as well. if (found != null) { // use actual terraformed area. position = findPieceGap(MuonUtils.chunksBoundingBox(found.mapbb), start, structureComponents, found, original); } else { position = findPieceGap(MuonUtils.chunksBoundingBox(villagebb), start, structureComponents, found, original); } } return position; }
public static void addExtraVillageComponents(List<PieceWeight> list, Random random, int i) { List<StructureVillagePieces.PieceWeight> parts = list; for (IVillageCreationHandler handler : instance().villageCreationHandlers.values()) { parts.add(handler.getVillagePieceWeight(random, i)); } }
public MuonVillageGrove(StructureVillagePieces.Start start, int type, Random rand, StructureBoundingBox structurebb, EnumFacing facing) { super(start, type); this.boundingBox = structurebb; this.setCoordBaseMode(facing); this.sapling = Blocks.SAPLING.getDefaultState(); }
private static int areaMetric(StructureBoundingBox current, StructureVillagePieces.Start start) { // int area = (current.maxX-current.minX)*(current.maxZ-current.minZ); int xSize = current.maxX-current.minX; int zSize = current.maxZ-current.minZ; int shortSide = Math.min(xSize, zSize); int longSide = Math.max(xSize, zSize); int smallArea = (shortSide * shortSide); if (shortSide > 12) { smallArea = shortSide * (24-shortSide); } int dist = Math.abs(current.maxX - start.getBoundingBox().maxX) + Math.abs(current.maxZ - start.getBoundingBox().maxZ); int area = smallArea + longSide - dist; return area; }
public static void addExtraVillageComponents(@SuppressWarnings("rawtypes") ArrayList components, Random random, int i) { @SuppressWarnings("unchecked") List<StructureVillagePieces.PieceWeight> parts = components; for (IVillageCreationHandler handler : instance().villageCreationHandlers.values()) { parts.add(handler.getVillagePieceWeight(random, i)); } }
public static VillagePieceGuardTower2 createPiece(StructureVillagePieces.Start start, List<StructureComponent> structures, Random rand, int x, int y, int z, EnumFacing facing, int p_175850_7_) { BlockPos size = new BlockMapMeasurer(NAME).measure(); StructureBoundingBox bounds = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, size.getX(), size.getY(), size.getZ(), facing); return canVillageGoDeeper(bounds) && StructureComponent.findIntersecting(structures, bounds) == null ? new VillagePieceGuardTower2(start, p_175850_7_, rand, bounds, facing) : null; }
public static VillagePieceKeep createPiece(StructureVillagePieces.Start start, List<StructureComponent> structures, Random rand, int x, int y, int z, EnumFacing facing, int p_175850_7_) { BlockPos size = new BlockMapMeasurer(NAME).measure(); StructureBoundingBox bounds = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, size.getX(), size.getY(), size.getZ(), facing); return canVillageGoDeeper(bounds) && StructureComponent.findIntersecting(structures, bounds) == null ? new VillagePieceKeep(start, p_175850_7_, rand, bounds, facing) : null; }
public ComponentVillageUndertaker(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox structureBoundingBox, EnumFacing direction) { super(startPiece, componentType); this.setCoordBaseMode(direction); this.boundingBox = structureBoundingBox; if (ExtendedConfig.generateCemeteries) { isCemetery = random.nextBoolean(); } }
@Override public boolean generate(World world, Random rand, int x, int z, EnumFacing facing, double chance, boolean isCommand) { if (isCommand) { StructureBoundingBox boundingBox = ComponentVillageUndertaker.getBoundingBox(facing, x, z); new ComponentVillageUndertaker(new StructureVillagePieces.Start(), 0, rand, boundingBox, facing) .generateComponent(world, rand, boundingBox, true); return true; } return false; }
@Override public boolean generate(World world, Random rand, int x, int z, EnumFacing facing, double chance, boolean isCommand) { if (isCommand) { StructureBoundingBox boundingBox = ComponentVillageUndertaker.getBoundingBox(facing, x, z); new ComponentVillageUndertaker(new StructureVillagePieces.Start(), 0, rand, boundingBox, facing) .generateComponent(world, rand, boundingBox, false); return true; } return false; }
public ComponentCornField(StructureVillagePieces.Start start, int type, Random rand, StructureBoundingBox box, EnumFacing facing) { super(start, type); this.setCoordBaseMode(facing); this.boundingBox = box; this.crop = ObjectList.CORN; }
@SuppressWarnings("rawtypes") @Override public Object buildComponent(PieceWeight villagePiece, Start startPiece, List pieces, Random random, int p1, int p2, int p3, int p4, int p5) { // BiomeGenBase biome = // world.getBiomeGenForCoords(startPiece.getBoundingBox().minX, startPiece.getBoundingBox().minZ); // if (biome != ModBiomes.biomeCityPlains) // return null; return StructureVillagePieces.WoodHut.func_74908_a(startPiece, pieces, random, p1, p2, p3, p4, p5); }
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 5, 8, 5, direction); if (canVillageGoDeeper(_boundingBox)) { if (StructureComponent.findIntersecting(pieces, _boundingBox) == null) { return new CatapultTower(startPiece, type, random, _boundingBox, direction); } } return null; }
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 5, 8, 5, direction); if (canVillageGoDeeper(_boundingBox)) { if (StructureComponent.findIntersecting(pieces, _boundingBox) == null) { return new BallistaTower(startPiece, type, random, _boundingBox, direction); } } return null; }
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 7, 14, 6, direction); if (canVillageGoDeeper(_boundingBox)) { if (StructureComponent.findIntersecting(pieces, _boundingBox) == null) { return new VillageGuardTower(startPiece, type, _boundingBox, direction); } } return null; }
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 23, 12, 21, direction); if (canVillageGoDeeper(_boundingBox)) { if (StructureComponent.findIntersecting(pieces, _boundingBox) == null) { return new VillageKingCastle(startPiece, type, random, _boundingBox, direction); } } return null; }
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 5, 10, 5, direction); if (canVillageGoDeeper(_boundingBox)) { if (StructureComponent.findIntersecting(pieces, _boundingBox) == null) { return new TestBallistaTower(startPiece, type, random, _boundingBox, direction); } } return null; }
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 11, 6, 11, direction); if(canVillageGoDeeper(_boundingBox)){ if(StructureComponent.findIntersecting(pieces, _boundingBox) == null){ return new ComponentBakery(startPiece, type, random, _boundingBox, direction); } } return null; }
public static StructureVillagePieces.Village buildComponent(Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 14, 10, 8, direction); if(canVillageGoDeeper(_boundingBox)){ if(StructureComponent.findIntersecting(pieces, _boundingBox) == null){ return new VillageTavern(startPiece, type, random, _boundingBox, direction); } } return null; }
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 5, 10, 5, direction); if (canVillageGoDeeper(_boundingBox)) { if (StructureComponent.findIntersecting(pieces, _boundingBox) == null) { return new TestCatapultTower(startPiece, type, random, _boundingBox, direction); } } return null; }
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 14, 10, 8, direction); if(canVillageGoDeeper(_boundingBox)){ if(StructureComponent.findIntersecting(pieces, _boundingBox) == null){ return new VillageWall(startPiece, type, random, _boundingBox, direction); } } return null; }
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(x, y, z, 0, 0, 0, 14, 14, 12, direction); if (canVillageGoDeeper(_boundingBox)) { if (StructureComponent.findIntersecting(pieces, _boundingBox) == null) { return new VillageBaronCastle(startPiece, type, random, _boundingBox, direction); } } return null; }
@SuppressWarnings("rawtypes") @Override public Object buildComponent(PieceWeight villagePiece, Start startPiece, List pieces, Random random, int x, int y, int z, int coordBaseMode, int p5) { int totalWeight = getTotalWieght(pieceWeights); if(totalWeight <= 0) { return null; } for (int i = 0; i < 5; ++i) { int randomWeight = random.nextInt(totalWeight); Iterator<WeightedCreationHandler> iterator = pieceWeights.iterator(); while (iterator.hasNext()) { WeightedCreationHandler el = iterator.next(); PieceWeight pieceweight = el.weight; randomWeight -= pieceweight.villagePieceWeight; if(randomWeight < 0) { int notUsed = 0; if(!pieceweight.canSpawnMoreVillagePiecesOfType(notUsed) || pieceweight == startPiece.structVillagePieceWeight && pieceWeights.size() > 1) { break; } StructureVillagePieces.Village village = (Village) el.handler.buildComponent(pieceweight, startPiece, pieces, random, x, y, z, coordBaseMode, p5); if(village != null) { ++pieceweight.villagePiecesSpawned; startPiece.structVillagePieceWeight = pieceweight; if(!pieceweight.canSpawnMoreVillagePieces()) { pieceWeights.remove(el); } return village; } } } } return null; }
private int getTotalWieght(List<WeightedCreationHandler> handlers) { boolean result = false; int totalWeight = 0; StructureVillagePieces.PieceWeight pieceweight; for (Iterator<WeightedCreationHandler> iterator = handlers.iterator(); iterator.hasNext(); totalWeight += pieceweight.villagePieceWeight) { pieceweight = iterator.next().weight; if(pieceweight.villagePiecesLimit > 0 && pieceweight.villagePiecesSpawned < pieceweight.villagePiecesLimit) { result = true; } } return result ? totalWeight : -1; }
protected VendingVillageStructure(StructureVillagePieces.Start startPiece, int type, Random random, StructureBoundingBox _boundingBox, int direction) { super(startPiece, type); coordBaseMode = direction; boundingBox = _boundingBox; }
@SuppressWarnings("rawtypes") public static Object buildComponent( StructureVillagePieces.Start startPiece, List pieces, Random random, int x, int y, int z, int direction, int type) { StructureBoundingBox _boundingBox = StructureBoundingBox .getComponentToAddBoundingBox(x, y, z, 0, 0, 0, WIDTH, HEIGHT, LENGTH, direction); if (canVillageGoDeeper(_boundingBox)) { if (StructureComponent.findIntersecting(pieces, _boundingBox) == null) { return new VendingVillageStructure(startPiece, type, random, _boundingBox, direction); } } return null; }
public static final void addAllPieces(ArrayList list) { Iterator<StructureVillagePieces.PieceWeight> iterator = pieces.iterator(); while (iterator.hasNext()) { list.add(iterator.next()); } }
protected StructureComponent func_74891_a(ComponentVillageStartPiece p_74891_1_, List p_74891_2_, Random p_74891_3_, int p_74891_4_, int p_74891_5_) { switch(this.field_74885_f) { case 0: return StructureVillagePieces.func_75078_a(p_74891_1_, p_74891_2_, p_74891_3_, this.field_74887_e.field_78897_a - 1, this.field_74887_e.field_78895_b + p_74891_4_, this.field_74887_e.field_78896_c + p_74891_5_, 1, this.func_74877_c()); case 1: return StructureVillagePieces.func_75078_a(p_74891_1_, p_74891_2_, p_74891_3_, this.field_74887_e.field_78897_a + p_74891_5_, this.field_74887_e.field_78895_b + p_74891_4_, this.field_74887_e.field_78896_c - 1, 2, this.func_74877_c()); case 2: return StructureVillagePieces.func_75078_a(p_74891_1_, p_74891_2_, p_74891_3_, this.field_74887_e.field_78897_a - 1, this.field_74887_e.field_78895_b + p_74891_4_, this.field_74887_e.field_78896_c + p_74891_5_, 1, this.func_74877_c()); case 3: return StructureVillagePieces.func_75078_a(p_74891_1_, p_74891_2_, p_74891_3_, this.field_74887_e.field_78897_a + p_74891_5_, this.field_74887_e.field_78895_b + p_74891_4_, this.field_74887_e.field_78896_c - 1, 2, this.func_74877_c()); default: return null; } }
protected StructureComponent func_74894_b(ComponentVillageStartPiece p_74894_1_, List p_74894_2_, Random p_74894_3_, int p_74894_4_, int p_74894_5_) { switch(this.field_74885_f) { case 0: return StructureVillagePieces.func_75078_a(p_74894_1_, p_74894_2_, p_74894_3_, this.field_74887_e.field_78893_d + 1, this.field_74887_e.field_78895_b + p_74894_4_, this.field_74887_e.field_78896_c + p_74894_5_, 3, this.func_74877_c()); case 1: return StructureVillagePieces.func_75078_a(p_74894_1_, p_74894_2_, p_74894_3_, this.field_74887_e.field_78897_a + p_74894_5_, this.field_74887_e.field_78895_b + p_74894_4_, this.field_74887_e.field_78892_f + 1, 0, this.func_74877_c()); case 2: return StructureVillagePieces.func_75078_a(p_74894_1_, p_74894_2_, p_74894_3_, this.field_74887_e.field_78893_d + 1, this.field_74887_e.field_78895_b + p_74894_4_, this.field_74887_e.field_78896_c + p_74894_5_, 3, this.func_74877_c()); case 3: return StructureVillagePieces.func_75078_a(p_74894_1_, p_74894_2_, p_74894_3_, this.field_74887_e.field_78897_a + p_74894_5_, this.field_74887_e.field_78895_b + p_74894_4_, this.field_74887_e.field_78892_f + 1, 0, this.func_74877_c()); default: return null; } }
@Override public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) { return new StructureVillagePieces.PieceWeight(Cave.class, 3, 1); }