Search in sources :

Example 1 with FabricLootPoolBuilder

use of net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder in project Biome-Makeover by Lemonszz.

the class BiomeMakeover method onInitialize.

@Override
public void onInitialize() {
    GROUP = new BiomeMakeoverItemGroup(new Identifier(MODID, MODID));
    BMEffects.init();
    BoatTypes.init();
    BMBlocks.init();
    BMItems.init();
    BMEntities.init();
    BMBlockEntities.init();
    BMPotions.init();
    BMEnchantments.init();
    BMStructures.init();
    BMWorldGen.init();
    BMCriterion.init();
    BMScreens.init();
    BMWorldEvents.init();
    BMNetwork.initCommon();
    PoltergeistHandler.init();
    WitchQuestHandler.init();
    AdjudicatorRoomListener.init();
    ServerTickEvents.END_SERVER_TICK.register((e) -> WindSystem.update());
    ServerTickEvents.END_WORLD_TICK.register(TumbleweedSpawner::update);
    // TODO: Move
    CommandRegistrationCallback.EVENT.register((d, ded) -> d.register(CommandManager.literal("pillager").requires((serverCommandSource) -> serverCommandSource.hasPermissionLevel(2)).then(CommandManager.argument("pos", BlockPosArgumentType.blockPos()).then(CommandManager.argument("leader", BoolArgumentType.bool()).executes(c -> {
        ((PillagerSpawnerAccess) new PillagerSpawner()).bm_spawn(c.getSource().getWorld(), BlockPosArgumentType.getBlockPos(c, "pos"), BoolArgumentType.getBool(c, "leader"));
        return 1;
    })))));
    ServerPlayConnectionEvents.JOIN.register((ServerPlayNetworkHandler handler, PacketSender sender, MinecraftServer server) -> {
        NetworkUtil.sendSlideTime(handler.player, ((SlideEntity) handler.player).getSlideTime());
    });
    UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
        if (!player.isSpectator()) {
            ItemStack stack = player.getStackInHand(hand);
            if (!stack.isEmpty() && stack.getItem() == BMItems.ECTOPLASM) {
                BlockPos pos = hitResult.getBlockPos();
                BlockState state = world.getBlockState(pos);
                if (state.getBlock() == Blocks.COMPOSTER) {
                    int level = state.get(ComposterBlock.LEVEL);
                    if (level > 0) {
                        if (!world.isClient()) {
                            world.syncWorldEvent(1500, pos, 1);
                            world.setBlockState(pos, BMBlocks.ECTOPLASM_COMPOSTER.getDefaultState().with(ComposterBlock.LEVEL, level));
                            if (!player.isCreative())
                                stack.decrement(1);
                        }
                        return ActionResult.SUCCESS;
                    }
                }
            }
        }
        return ActionResult.PASS;
    });
    UseEntityCallback.EVENT.register((pl, world, hand, entity, hr) -> {
        ItemStack stack = pl.getStackInHand(hand);
        if (!stack.isEmpty() && (stack.getItem() == Items.GLASS_BOTTLE || stack.getItem() == Items.EXPERIENCE_BOTTLE)) {
            if (entity instanceof LightningBugEntity) {
                if (!world.isClient()) {
                    ItemStack result = ItemUsage.method_30012(stack, pl, new ItemStack(stack.getItem() == Items.GLASS_BOTTLE ? BMBlocks.LIGHTNING_BUG_BOTTLE : BMItems.LIGHTNING_BOTTLE));
                    pl.setStackInHand(hand, result);
                    entity.remove();
                    pl.playSound(SoundEvents.ITEM_BOTTLE_FILL, 1F, 1F);
                }
                return ActionResult.SUCCESS;
            }
        }
        return ActionResult.PASS;
    });
    final Identifier BAT_LT_ID = new Identifier("minecraft", "entities/bat");
    LootTableLoadingCallback.EVENT.register((rm, lm, id, supplier, setter) -> {
        if (id.equals(BAT_LT_ID)) {
            FabricLootPoolBuilder builder = FabricLootPoolBuilder.builder().rolls(BinomialLootTableRange.create(2, 0.5F)).withEntry(ItemEntry.builder(BMItems.BAT_WING).build());
            supplier.withPool(builder.build());
        }
    });
}
Also used : ServerTickEvents(net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents) PacketSender(net.fabricmc.fabric.api.networking.v1.PacketSender) FabricLootPoolBuilder(net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder) ComposterBlock(net.minecraft.block.ComposterBlock) BinomialLootTableRange(net.minecraft.loot.BinomialLootTableRange) BiomeMakeoverItemGroup(party.lemons.biomemakeover.crafting.itemgroup.BiomeMakeoverItemGroup) WindSystem(party.lemons.biomemakeover.world.WindSystem) WitchQuestHandler(party.lemons.biomemakeover.crafting.witch.WitchQuestHandler) CommandRegistrationCallback(net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback) LightningBugEntity(party.lemons.biomemakeover.entity.LightningBugEntity) BoatTypes(party.lemons.biomemakeover.util.boat.BoatTypes) TumbleweedSpawner(party.lemons.biomemakeover.world.TumbleweedSpawner) BoolArgumentType(com.mojang.brigadier.arguments.BoolArgumentType) UseEntityCallback(net.fabricmc.fabric.api.event.player.UseEntityCallback) ItemStack(net.minecraft.item.ItemStack) MinecraftServer(net.minecraft.server.MinecraftServer) AdjudicatorRoomListener(party.lemons.biomemakeover.entity.adjudicator.AdjudicatorRoomListener) ServerPlayConnectionEvents(net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents) SoundEvents(net.minecraft.sound.SoundEvents) UseBlockCallback(net.fabricmc.fabric.api.event.player.UseBlockCallback) PillagerSpawner(net.minecraft.world.gen.PillagerSpawner) party.lemons.biomemakeover.init(party.lemons.biomemakeover.init) BlockState(net.minecraft.block.BlockState) BlockPosArgumentType(net.minecraft.command.argument.BlockPosArgumentType) ItemUsage(net.minecraft.item.ItemUsage) NetworkUtil(party.lemons.biomemakeover.util.NetworkUtil) BMWorldEvents(party.lemons.biomemakeover.world.BMWorldEvents) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) ModInitializer(net.fabricmc.api.ModInitializer) ItemEntry(net.minecraft.loot.entry.ItemEntry) Blocks(net.minecraft.block.Blocks) CommandManager(net.minecraft.server.command.CommandManager) ActionResult(net.minecraft.util.ActionResult) LootTableLoadingCallback(net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback) SlideEntity(party.lemons.biomemakeover.util.extensions.SlideEntity) ItemGroup(net.minecraft.item.ItemGroup) Identifier(net.minecraft.util.Identifier) PoltergeistHandler(party.lemons.biomemakeover.world.PoltergeistHandler) PillagerSpawnerAccess(party.lemons.biomemakeover.util.access.PillagerSpawnerAccess) ServerPlayNetworkHandler(net.minecraft.server.network.ServerPlayNetworkHandler) TumbleweedSpawner(party.lemons.biomemakeover.world.TumbleweedSpawner) BiomeMakeoverItemGroup(party.lemons.biomemakeover.crafting.itemgroup.BiomeMakeoverItemGroup) PacketSender(net.fabricmc.fabric.api.networking.v1.PacketSender) ServerPlayNetworkHandler(net.minecraft.server.network.ServerPlayNetworkHandler) PillagerSpawnerAccess(party.lemons.biomemakeover.util.access.PillagerSpawnerAccess) FabricLootPoolBuilder(net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder) MinecraftServer(net.minecraft.server.MinecraftServer) PillagerSpawner(net.minecraft.world.gen.PillagerSpawner) Identifier(net.minecraft.util.Identifier) BlockState(net.minecraft.block.BlockState) LightningBugEntity(party.lemons.biomemakeover.entity.LightningBugEntity) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 2 with FabricLootPoolBuilder

use of net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder in project Neutrino by FrostWizard4.

the class LootTableRegister method register.

public static void register() {
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.BASTION_TREASURE_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.SOUL_POUCH).weight(1)).with(EmptyEntry.Serializer().weight(14));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.WOODLAND_MANSION_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.SOUL_HEALER).weight(1)).with(EmptyEntry.Serializer().weight(2));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.HERO_OF_THE_VILLAGE_CLERIC_GIFT_GAMEPLAY.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(NeutrinoFoodComponents.DEATH_CAP_MUSHROOM).weight(1)).with(EmptyEntry.Serializer().weight(4));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.STRONGHOLD_LIBRARY_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.ENCHANTERS_TOME).weight(1)).with(EmptyEntry.Serializer().weight(4));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.HERO_OF_THE_VILLAGE_LIBRARIAN_GIFT_GAMEPLAY.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.UPDRAFT_TOME).weight(1)).with(EmptyEntry.Serializer().weight(6));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.ABANDONED_MINESHAFT_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.HARVESTER).weight(1)).with(EmptyEntry.Serializer().weight(9));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.END_CITY_TREASURE_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.LIGHTNING_ROD_ARTIFACT).weight(1)).with(EmptyEntry.Serializer().weight(7));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.VILLAGE_WEAPONSMITH_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1.0F)).with(ItemEntry.builder(ItemRegistry.GOAT_HORN).weight(1)).with(EmptyEntry.Serializer().weight(4));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.JUNGLE_TEMPLE_CHEST.equals(id) || LootTables.DESERT_PYRAMID_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.RUSTY_SWORD).weight(1)).with(EmptyEntry.Serializer().weight(3));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.BASTION_BRIDGE_CHEST.equals(id) || LootTables.END_CITY_TREASURE_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.SHATTERED_SWORD).weight(1)).with(EmptyEntry.Serializer().weight(5));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.SIMPLE_DUNGEON_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.GRAY_JEWEL).weight(1)).with(EmptyEntry.Serializer().weight(5));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.END_CITY_TREASURE_CHEST.equals(id) || LootTables.WOODLAND_MANSION_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(NeutrinoFoodComponents.ENCHANTED_DIAMOND_APPLE).weight(1)).with(EmptyEntry.Serializer().weight(5));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.FISHING_GAMEPLAY.equals(id) || LootTables.FISHING_FISH_GAMEPLAY.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.WISHBONE).weight(1)).with(EmptyEntry.Serializer().weight(10));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.JUNGLE_TEMPLE_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.DATURA_BLADE).weight(1)).with(EmptyEntry.Serializer().weight(10));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.PILLAGER_OUTPOST_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(BlockRegistry.ALPACA_COLLECTIBLE.asItem()).weight(1)).with(EmptyEntry.Serializer().weight(10));
            table.pool(poolBuilder);
        }
    });
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, table, setter) -> {
        if (LootTables.JUNGLE_TEMPLE_CHEST.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).with(ItemEntry.builder(ItemRegistry.MUSIC_DISC_PARADISE).weight(1)).with(EmptyEntry.Serializer().weight(20));
            table.pool(poolBuilder);
        }
    });
}
Also used : FabricLootPoolBuilder(net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder)

Example 3 with FabricLootPoolBuilder

use of net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder in project EnvironmentZ by Globox1997.

the class LootInit method init.

public static void init() {
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
        if ("minecraft:entities/wolf".equals(id.toString())) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(BinomialLootNumberProvider.create(3, 0.6F)).with(ItemEntry.builder(ItemInit.WOLF_PELT_ITEM));
            supplier.pool(poolBuilder);
        }
        if ("minecraft:entities/polar_bear".equals(id.toString())) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(BinomialLootNumberProvider.create(2, 0.5F)).with(ItemEntry.builder(ItemInit.POLAR_BEAR_FUR_ITEM));
            supplier.pool(poolBuilder);
        }
    });
}
Also used : FabricLootPoolBuilder(net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder)

Example 4 with FabricLootPoolBuilder

use of net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder in project artifality by PinkGoosik.

the class ArtifalityLootTables method overworldChest.

static void overworldChest(Item item, Float chance) {
    String chest = id.toString();
    if (!isBlacklisted(chest) && !isNetherChest(chest)) {
        FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootNumberProvider.create(1)).withCondition(RandomChanceLootCondition.builder(chance).build()).withEntry(ItemEntry.builder(item).build());
        supplier.withPool(poolBuilder.build());
    }
}
Also used : FabricLootPoolBuilder(net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder)

Example 5 with FabricLootPoolBuilder

use of net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder in project Architects-Palette-Fabric by Slomaxonical-907.

the class LootTableModifications method registerWitheredBones.

public static void registerWitheredBones() {
    LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
        if (WITHER_SKELETON_LOOT_TABLE_ID.equals(id)) {
            FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder().rolls(ConstantLootTableRange.create(1)).with(ItemEntry.builder(APItems.WITHERED_BONE)).withFunction(SetCountLootFunction.builder(UniformLootTableRange.between(0.0f, 2.0f)).build()).withFunction(LootingEnchantLootFunction.builder(UniformLootTableRange.between(0.0f, 1.0f)).build());
            supplier.withPool(poolBuilder.build());
        }
    });
}
Also used : FabricLootPoolBuilder(net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder)

Aggregations

FabricLootPoolBuilder (net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder)5 BoolArgumentType (com.mojang.brigadier.arguments.BoolArgumentType)1 ModInitializer (net.fabricmc.api.ModInitializer)1 CommandRegistrationCallback (net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback)1 ServerTickEvents (net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents)1 UseBlockCallback (net.fabricmc.fabric.api.event.player.UseBlockCallback)1 UseEntityCallback (net.fabricmc.fabric.api.event.player.UseEntityCallback)1 LootTableLoadingCallback (net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback)1 PacketSender (net.fabricmc.fabric.api.networking.v1.PacketSender)1 ServerPlayConnectionEvents (net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents)1 BlockState (net.minecraft.block.BlockState)1 Blocks (net.minecraft.block.Blocks)1 ComposterBlock (net.minecraft.block.ComposterBlock)1 BlockPosArgumentType (net.minecraft.command.argument.BlockPosArgumentType)1 ItemGroup (net.minecraft.item.ItemGroup)1 ItemStack (net.minecraft.item.ItemStack)1 ItemUsage (net.minecraft.item.ItemUsage)1 Items (net.minecraft.item.Items)1 BinomialLootTableRange (net.minecraft.loot.BinomialLootTableRange)1 ItemEntry (net.minecraft.loot.entry.ItemEntry)1