use of com.wuest.prefab.structures.config.HouseConfiguration in project MC-Prefab by Brian-Wuest.
the class StructureAlternateStart method AfterBuilding.
/**
* This method is used after the main building is build for any additional structures or modifications.
*
* @param configuration The structure configuration.
* @param world The current world.
* @param originalPos The original position clicked on.
* @param player The player which initiated the construction.
*/
@Override
public void AfterBuilding(StructureConfiguration configuration, ServerLevel world, BlockPos originalPos, Player player) {
HouseConfiguration houseConfig = (HouseConfiguration) configuration;
EntityPlayerConfiguration playerConfig = EntityPlayerConfiguration.loadFromEntityData(player);
BuildingMethods.FillFurnaces(world, this.furnacePositions);
if (this.chestPosition != null && houseConfig.addChestContents) {
// Fill the chest.
BuildingMethods.FillChest(world, this.chestPosition);
}
int minimumHeightForMineshaft = world.getMinBuildHeight() + 21;
if (this.trapDoorPosition != null && this.trapDoorPosition.getY() > minimumHeightForMineshaft && houseConfig.addMineShaft) {
// Build the mineshaft.
BuildingMethods.PlaceMineShaft(world, this.trapDoorPosition.below(), houseConfig.houseFacing, false);
}
// Make sure to set this value so the player cannot fill the chest a second time.
playerConfig.builtStarterHouse = true;
playerConfig.saveToPlayer(player);
// Make sure to send a message to the client to sync up the server player information and the client player
// information.
Prefab.network.sendTo(new PlayerEntityTagMessage(playerConfig.getModIsPlayerNewTag(player)), ((ServerPlayer) player).connection.connection, NetworkDirection.PLAY_TO_CLIENT);
}
use of com.wuest.prefab.structures.config.HouseConfiguration in project MC-Prefab by Brian-Wuest.
the class StructureAlternateStart method CustomBlockProcessingHandled.
@Override
protected Boolean CustomBlockProcessingHandled(StructureConfiguration configuration, BuildBlock block, Level world, BlockPos originalPos, Block foundBlock, BlockState blockState, Player player) {
HouseConfiguration houseConfig = (HouseConfiguration) configuration;
if ((!houseConfig.addBed && foundBlock instanceof BedBlock) || (!houseConfig.addChest && foundBlock instanceof ChestBlock) || (!houseConfig.addTorches && foundBlock instanceof TorchBlock) || (!houseConfig.addCraftingTable && foundBlock instanceof CraftingTableBlock) || (!houseConfig.addFurnace && foundBlock instanceof FurnaceBlock) || (!houseConfig.addChest && foundBlock instanceof BarrelBlock) || (foundBlock instanceof SeagrassBlock) || (foundBlock instanceof TallSeagrassBlock)) {
// "handled"
return true;
}
if (foundBlock instanceof FurnaceBlock) {
this.furnacePositions.add(block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing));
} else if (foundBlock instanceof TrapDoorBlock && houseConfig.addMineShaft && this.trapDoorPosition == null) {
// The trap door will still be added, but the mine shaft may not be
// built.
this.trapDoorPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
} else if ((foundBlock instanceof ChestBlock && this.chestPosition == null) || (foundBlock instanceof BarrelBlock && this.chestPosition == null)) {
this.chestPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
} else if (foundBlock == Blocks.SPONGE && houseConfig.addMineShaft) {
// Sponges are sometimes used in-place of trapdoors when trapdoors are used for decoration.
this.trapDoorPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing).above();
} else if (foundBlock instanceof BedBlock && houseConfig.addBed) {
BlockPos bedHeadPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
BlockPos bedFootPosition = block.getSubBlock().getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
Tuple<BlockState, BlockState> blockStateTuple = BuildingMethods.getBedState(bedHeadPosition, bedFootPosition, houseConfig.bedColor);
block.setBlockState(blockStateTuple.getFirst());
block.getSubBlock().setBlockState(blockStateTuple.getSecond());
this.priorityOneBlocks.add(block);
// Return true so the bed is not placed.
return true;
}
return false;
}
Aggregations