net.minecraft.structure.StructurePiece Java Examples
The following examples show how to use
net.minecraft.structure.StructurePiece.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpiderLairFeature.java From the-hallow with MIT License | 6 votes |
@Override public boolean generate(IWorld iWorld, ChunkGenerator<? extends ChunkGeneratorConfig> chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig defaultFeatureConfig) { if (iWorld.getBlockState(pos.down()).getBlock() == HallowedBlocks.DECEASED_GRASS_BLOCK) { setSpawner(iWorld, pos, EntityType.SPIDER); for (int i = 0; i < 64; ++i) { BlockPos pos_2 = pos.add(random.nextInt(6) - random.nextInt(6), random.nextInt(3) - random.nextInt(3), random.nextInt(6) - random.nextInt(6)); if (iWorld.isAir(pos_2) || iWorld.getBlockState(pos_2).getBlock() == HallowedBlocks.DECEASED_GRASS_BLOCK) { iWorld.setBlockState(pos_2, Blocks.COBWEB.getDefaultState(), 2); } } BlockPos chestPos = pos.add(random.nextInt(4) - random.nextInt(4), 0, random.nextInt(4) - random.nextInt(4)); iWorld.setBlockState(chestPos, StructurePiece.method_14916(iWorld, chestPos, Blocks.CHEST.getDefaultState()), 2); LootableContainerBlockEntity.setLootTable(iWorld, random, chestPos, TheHallow.id("chests/spider_lair")); return true; } else { return false; } }
Example #2
Source File: CarpetExpression.java From fabric-carpet with MIT License | 6 votes |
private static Value structureToValue(StructureStart structure) { if (structure == null || structure == StructureStart.DEFAULT) return Value.NULL; List<Value> pieces = new ArrayList<>(); for (StructurePiece piece : structure.getChildren()) { BlockBox box = piece.getBoundingBox(); pieces.add(ListValue.of( new StringValue( NBTSerializableValue.nameFromRegistryId(Registry.STRUCTURE_PIECE.getId(piece.getType()))), (piece.getFacing()== null)?Value.NULL: new StringValue(piece.getFacing().getName()), ListValue.fromTriple(box.minX, box.minY, box.minZ), ListValue.fromTriple(box.maxX, box.maxY, box.maxZ) )); }; BlockBox boundingBox = structure.getBoundingBox(); Map<Value, Value> ret = new HashMap<>(); ret.put(new StringValue("box"), ListValue.of( ListValue.fromTriple(boundingBox.minX, boundingBox.minY, boundingBox.minZ), ListValue.fromTriple(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ) )); ret.put(new StringValue("pieces"), ListValue.wrap(pieces)); return MapValue.wrap(ret); }