/** * Place structures in chunk. * * @param buffer a MutableBlockVolume object to place blocks in * @param struct a StructureChunk to place * @param check a BlockState to replace (will replace with list later) */ private void placeBlocks(MutableBlockVolume buffer, StructureChunk struct) { BlockState state = struct.getBlock().getState(); BlockType intermediate; BlockType below; Random rand = new Random(); if (state != null) { for (ThreePoint point : struct.getPoints()) { if (point.y < 180 && point.y > 2) { intermediate = buffer.getRelativeBlockView().getBlock(point.x, point.y, point.z).getType(); below = buffer.getRelativeBlockView().getBlock(point.x, point.y - 1, point.z).getType(); if (blockStone(intermediate)) { buffer.getRelativeBlockView().setBlock(point.x, point.y, point.z, state); } else if (blockAir(intermediate)) { if (blockStone(below) && rand.nextInt(7) == 0) { buffer.getRelativeBlockView().setBlock(point.x, point.y, point.z, state); } else if (blockRegolith(below, state.getType()) && rand.nextInt(15) == 0) { buffer.getRelativeBlockView().setBlock(point.x, point.y, point.z, state); } } else if (blockRegolith(intermediate, state.getType())) { if (blockStone(below) && rand.nextInt(3) == 0) { buffer.getRelativeBlockView().setBlock(point.x, point.y, point.z, state); } else if (blockRegolith(below, state.getType()) && rand.nextInt(30) == 0) { buffer.getRelativeBlockView().setBlock(point.x, point.y, point.z, state); } } } } } }
@Override public SpongeBlockSnapshot createSpongeBlockSnapshot( IBlockState state, IBlockState extended, BlockPos pos, int updateFlag) { this.builder.reset(); Location<World> location = new Location<>((World) this, VecHelper.toVector(pos)); this.builder .blockState((BlockState) state) .extendedState((BlockState) extended) .worldId(location.getExtent().getUniqueId()) .position(location.getBlockPosition()); Optional<UUID> creator = getCreator(pos.getX(), pos.getY(), pos.getZ()); Optional<UUID> notifier = getNotifier(pos.getX(), pos.getY(), pos.getZ()); if (creator.isPresent()) { this.builder.creator(creator.get()); } if (notifier.isPresent()) { this.builder.notifier(notifier.get()); } if (state.getBlock() instanceof ITileEntityProvider) { net.minecraft.tileentity.TileEntity te = getTileEntity(pos); if (te != null) { TileEntity tile = (TileEntity) te; for (DataManipulator<?, ?> manipulator : tile.getContainers()) { this.builder.add(manipulator); } NBTTagCompound nbt = new NBTTagCompound(); te.writeToNBT(nbt); this.builder.unsafeNbt(nbt); } } return new SpongeBlockSnapshot(this.builder, updateFlag); }
/** * If this blockstate is a sign. * * @param block The blockstate to check * @return If it is a sign */ public static boolean isSign(BlockState block) { return block.getType() == BlockTypes.STANDING_SIGN || block.getType() == BlockTypes.WALL_SIGN; }