use of com.wuest.prefab.structures.config.ModerateHouseConfiguration in project MC-Prefab by Brian-Wuest.
the class StructureModerateHouse 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) {
ModerateHouseConfiguration houseConfig = (ModerateHouseConfiguration) configuration;
EntityPlayerConfiguration playerConfig = EntityPlayerConfiguration.loadFromEntityData(player);
BuildingMethods.FillFurnaces(world, this.furnacePosition);
if (this.chestPosition != null && !playerConfig.builtStarterHouse && houseConfig.addChestContents) {
// Fill the chest if the player hasn't generated the starting house yet.
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);
}
Aggregations