Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class Piece extends TemplateStructurePiece {
- private ResourceLocation resourceLocation;
- private Rotation rotation;
- public Piece(TemplateManager templateManagerIn, ResourceLocation resourceLocationIn, BlockPos pos,
- Rotation rotationIn) {
- super(FeatureInit.HOUSE_PIECE, 0);
- this.resourceLocation = resourceLocationIn;
- BlockPos blockpos = HousePieces.OFFSET.get(resourceLocation);
- this.templatePosition = pos.add(blockpos.getX(), blockpos.getY(), blockpos.getZ());
- this.rotation = rotationIn;
- this.setupPiece(templateManagerIn);
- }
- public Piece(TemplateManager templateManagerIn, CompoundNBT tagCompound) {
- super(FeatureInit.HOUSE_PIECE, tagCompound);
- this.resourceLocation = new ResourceLocation(tagCompound.getString("Template"));
- this.rotation = Rotation.valueOf(tagCompound.getString("Rot"));
- this.setupPiece(templateManagerIn);
- }
- private void setupPiece(TemplateManager templateManager) {
- Template template = templateManager.getTemplateDefaulted(this.resourceLocation);
- PlacementSettings placementsettings = (new PlacementSettings()).setRotation(this.rotation)
- .setMirror(Mirror.NONE);
- this.setup(template, this.templatePosition, placementsettings);
- }
- @Override
- protected void readAdditional(CompoundNBT tagCompound) {
- super.readAdditional(tagCompound);
- tagCompound.putString("Template", this.resourceLocation.toString());
- tagCompound.putString("Rot", this.rotation.name());
- }
- @Override
- protected void handleDataMarker(String function, BlockPos pos, IWorld worldIn, Random rand,
- MutableBoundingBox sbb) {
- if ("chest".equals(function)) {
- worldIn.setBlockState(pos, Blocks.CHEST.getDefaultState(), 2);
- TileEntity tileentity = worldIn.getTileEntity(pos);
- if (tileentity instanceof ChestTileEntity) {
- // here you can set any loot tables for the chests
- }
- }
- }
- // create
- @Override
- public boolean func_225577_a_(IWorld worldIn, ChunkGenerator<?> generator, Random randomIn,
- MutableBoundingBox structureBoundingBoxIn, ChunkPos chunkPos) {
- PlacementSettings placementsettings = (new PlacementSettings()).setRotation(this.rotation)
- .setMirror(Mirror.NONE);
- BlockPos blockpos = HousePieces.OFFSET.get(this.resourceLocation);
- this.templatePosition.add(Template.transformedBlockPos(placementsettings,
- new BlockPos(0 - blockpos.getX(), 0, 0 - blockpos.getZ())));
- return super.func_225577_a_(worldIn, generator, randomIn, structureBoundingBoxIn, chunkPos);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement