MCMod_HDL_1_10/temp.txt
2024-01-05 18:49:00 -08:00

57 lines
2.5 KiB
Plaintext

public void placeInWorld(World worldIn, BlockPos pos, EnumFacing direction) {
int width = blocks.size();
int height = blocks.get(0).size();
int length = blocks.get(0).get(0).size();
int start_x = pos.getX();
int start_y = pos.getY();
int start_z = pos.getZ();
if (direction == EnumFacing.NORTH){
start_z += 2;
} else if (direction == EnumFacing.SOUTH) {
start_z -= length + 1;
} else if (direction == EnumFacing.EAST){
start_x -= width + 1;
} else if (direction == EnumFacing.WEST) {
start_x -= width + 1;
}
int y = start_y - 1;
for (int z = start_z - 1; z < start_z + length + 1; z ++){
for (int x = start_x - 1; x < start_x + width + 1; x++){
worldIn.setBlockState(new BlockPos(x, y, z), Blocks.WOOL.getDefaultState());
}
}
HashMap<Vec3i ,IBlockState> torches = new HashMap<Vec3i, IBlockState>();
for (int i = 0; i < width; i++){
for (int j = 0; j < height; j++) {
for (int k = 0; k < length; k++) {
if (this.getState(i, j, k).getBlock().getDefaultState() == Blocks.REDSTONE_TORCH.getDefaultState()) {
torches.put(new Vec3i(i, j, k), this.getState(i, j, k));
} else {
BlockPos blk_pos = new BlockPos(start_x + i, start_y + j, start_z + k);
worldIn.setBlockState(blk_pos, this.getState(i, j, k));
TileEntity te = this.te_map.get(new Vec3i(i, j, k));
if (te != null) {
worldIn.setTileEntity(blk_pos, te);
}
}
}
}
}
for (Map.Entry<Vec3i, IBlockState> set : torches.entrySet()){
worldIn.setBlockState(new BlockPos(start_x + set.getKey().getX(), start_y + set.getKey().getY(), start_z + set.getKey().getZ()), set.getValue());
}
for (int z = start_z - 1; z < start_z + length + 1; z ++) {
for (int x = start_x - 1; x < start_x + width + 1; x++) {
if (worldIn.getBlockState(new BlockPos(x, y + 1, z)).getBlock() == Blocks.AIR | worldIn.getBlockState(new BlockPos(x, y + 1, z)).getBlock() == Blocks.WOOL) {
worldIn.setBlockState(new BlockPos(x, y, z), Blocks.AIR.getDefaultState());
}
}
}
}