use of net.minecraft.server.level.ServerPlayer 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);
}
Aggregations