Search in sources :

Example 71 with ServerPlayer

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);
}
Also used : PlayerEntityTagMessage(com.wuest.prefab.proxy.messages.PlayerEntityTagMessage) EntityPlayerConfiguration(com.wuest.prefab.config.EntityPlayerConfiguration) ServerPlayer(net.minecraft.server.level.ServerPlayer) HouseConfiguration(com.wuest.prefab.structures.config.HouseConfiguration)

Aggregations

ServerPlayer (net.minecraft.server.level.ServerPlayer)71 TamableAnimal (net.minecraft.world.entity.TamableAnimal)12 Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)11 ServerLevel (net.minecraft.server.level.ServerLevel)11 ArmorStand (net.minecraft.world.entity.decoration.ArmorStand)11 ItemStack (net.minecraft.world.item.ItemStack)10 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)10 Player (org.bukkit.entity.Player)10 MyPet (de.Keyle.MyPet.api.entity.MyPet)8 EntityMyPet (de.Keyle.MyPet.compat.v1_17_R1.entity.EntityMyPet)8 CraftPlayer (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)8 Player (net.minecraft.world.entity.player.Player)7 EntityMyPet (de.Keyle.MyPet.compat.v1_18_R1.entity.EntityMyPet)6 ArrayList (java.util.ArrayList)6 ClientboundRemoveEntitiesPacket (net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket)6 ChunkMap (net.minecraft.server.level.ChunkMap)6 ServerGamePacketListenerImpl (net.minecraft.server.network.ServerGamePacketListenerImpl)6 LivingEntity (net.minecraft.world.entity.LivingEntity)6 ItemEntity (net.minecraft.world.entity.item.ItemEntity)6 PlayerEntityTagMessage (com.wuest.prefab.proxy.messages.PlayerEntityTagMessage)5