Search in sources :

Example 1 with StructureAlternateStart

use of com.wuest.prefab.structures.predefined.StructureAlternateStart in project MC-Prefab by Brian-Wuest.

the class HouseConfiguration method ConfigurationSpecificBuildStructure.

/**
 * This is used to actually build the structure as it creates the structure instance and calls build structure.
 *
 * @param player      The player which requested the build.
 * @param world       The world instance where the build will occur.
 * @param hitBlockPos This hit block position.
 */
@Override
protected void ConfigurationSpecificBuildStructure(Player player, ServerLevel world, BlockPos hitBlockPos) {
    boolean houseBuilt = true;
    // Build the alternate starter house instead.
    StructureAlternateStart structure = StructureAlternateStart.CreateInstance(this.houseStyle.getStructureLocation(), StructureAlternateStart.class);
    houseBuilt = structure.BuildStructure(this, world, hitBlockPos, player);
    // The house was successfully built, remove the item from the inventory.
    if (houseBuilt) {
        EntityPlayerConfiguration playerConfig = EntityPlayerConfiguration.loadFromEntityData(player);
        playerConfig.builtStarterHouse = true;
        playerConfig.saveToPlayer(player);
        this.RemoveStructureItemFromPlayer(player, ModRegistry.StartHouse.get());
        // 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 : StructureAlternateStart(com.wuest.prefab.structures.predefined.StructureAlternateStart) PlayerEntityTagMessage(com.wuest.prefab.proxy.messages.PlayerEntityTagMessage) EntityPlayerConfiguration(com.wuest.prefab.config.EntityPlayerConfiguration) ServerPlayer(net.minecraft.server.level.ServerPlayer)

Aggregations

EntityPlayerConfiguration (com.wuest.prefab.config.EntityPlayerConfiguration)1 PlayerEntityTagMessage (com.wuest.prefab.proxy.messages.PlayerEntityTagMessage)1 StructureAlternateStart (com.wuest.prefab.structures.predefined.StructureAlternateStart)1 ServerPlayer (net.minecraft.server.level.ServerPlayer)1