diff --git a/src/main/java/org/betterx/betterend/registry/EndTags.java b/src/main/java/org/betterx/betterend/registry/EndTags.java index 9c6f0c28..aed4c6df 100644 --- a/src/main/java/org/betterx/betterend/registry/EndTags.java +++ b/src/main/java/org/betterx/betterend/registry/EndTags.java @@ -125,6 +125,8 @@ public class EndTags { TagManager.ITEMS.add(ALLOYING_IRON, Items.IRON_ORE, Items.DEEPSLATE_IRON_ORE, Items.RAW_IRON); TagManager.ITEMS.add(ALLOYING_GOLD, Items.GOLD_ORE, Items.DEEPSLATE_GOLD_ORE, Items.RAW_GOLD); TagManager.ITEMS.add(ALLOYING_COPPER, Items.COPPER_ORE, Items.DEEPSLATE_COPPER_ORE, Items.RAW_COPPER); + + TagManager.ITEMS.add(ItemTags.FISHES, EndItems.END_FISH_RAW, EndItems.END_FISH_COOKED); } public static void addEndGround(Block bl) { diff --git a/src/main/java/org/betterx/betterend/util/LootTableUtil.java b/src/main/java/org/betterx/betterend/util/LootTableUtil.java index 1fcd0861..ef33521b 100644 --- a/src/main/java/org/betterx/betterend/util/LootTableUtil.java +++ b/src/main/java/org/betterx/betterend/util/LootTableUtil.java @@ -1,6 +1,20 @@ package org.betterx.betterend.util; +import net.minecraft.advancements.critereon.EntityPredicate; +import net.minecraft.advancements.critereon.FishingHookPredicate; +import net.minecraft.advancements.critereon.LocationPredicate; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.storage.loot.BuiltInLootTables; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.entries.*; +import net.minecraft.world.level.storage.loot.functions.EnchantWithLevelsFunction; +import net.minecraft.world.level.storage.loot.functions.SetItemDamageFunction; +import net.minecraft.world.level.storage.loot.predicates.LocationCheck; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.LootItemEntityPropertyCondition; +import org.betterx.bclib.BCLib; import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome; +import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry; import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI; import org.betterx.bclib.complexmaterials.WoodenComplexMaterial; import org.betterx.betterend.BetterEnd; @@ -15,12 +29,12 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.LootTable; -import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; import net.fabricmc.fabric.api.loot.v2.LootTableEvents; +import org.betterx.betterend.world.biome.EndBiome; public class LootTableUtil { private static final ResourceLocation END_CITY_TREASURE_ID = new ResourceLocation("chests/end_city_treasure"); @@ -30,6 +44,34 @@ public class LootTableUtil { private static final ResourceLocation SHADOW_FOREST = BetterEnd.makeID("chests/shadow_forest"); private static final ResourceLocation LANTERN_WOODS = BetterEnd.makeID("chests/lantern_woods"); private static final ResourceLocation UMBRELLA_JUNGLE = BetterEnd.makeID("chests/umbrella_jungle"); + private static final ResourceLocation FISHING_FISH = BetterEnd.makeID("gameplay/fishing/fish"); + private static final ResourceLocation FISHING_TREASURE = BetterEnd.makeID("gameplay/fishing/treasure"); + private static final ResourceLocation FISHING_JUNK = BetterEnd.makeID("gameplay/fishing/junk"); + + private static final LootItemCondition.Builder IN_END + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setDimension(Level.END)); + private static final LootItemCondition.Builder IN_FOGGY_MUSHROOMLAND + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.FOGGY_MUSHROOMLAND.getBiomeKey())); + private static final LootItemCondition.Builder IN_CHORUS_FOREST + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.CHORUS_FOREST.getBiomeKey())); + private static final LootItemCondition.Builder IN_AMBER_LAND + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.AMBER_LAND.getBiomeKey())); + private static final LootItemCondition.Builder IN_GLOWING_GRASSLANDS + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.GLOWING_GRASSLANDS.getBiomeKey())); + private static final LootItemCondition.Builder IN_LANTERN_WOODS + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.LANTERN_WOODS.getBiomeKey())); + private static final LootItemCondition.Builder IN_MEGALAKE + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.MEGALAKE.getBiomeKey())); + private static final LootItemCondition.Builder IN_MEGALAKE_GROVE + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.MEGALAKE_GROVE.getBiomeKey())); + private static final LootItemCondition.Builder IN_NEON_OASIS + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.NEON_OASIS.getBiomeKey())); + private static final LootItemCondition.Builder IN_SHADOW_FOREST + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.SHADOW_FOREST.getBiomeKey())); + private static final LootItemCondition.Builder IN_SULPHUR_SPRINGS + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.SULPHUR_SPRINGS.getBiomeKey())); + private static final LootItemCondition.Builder IN_UMBRELLA_JUNGLE + = LocationCheck.checkLocation(LocationPredicate.Builder.location().setBiome(EndBiomes.UMBRELLA_JUNGLE.getBiomeKey())); public static void init() { LootTableEvents.MODIFY.register((resourceManager, lootManager, id, table, setter) -> { @@ -48,6 +90,37 @@ public class LootTableUtil { builder.add(LootItem.lootTableItem(EndItems.MUSIC_DISC_EO_DRACONA)); table.withPool(builder); } else if (id.getNamespace().equals(BetterEnd.MOD_ID)) { + if (FISHING_FISH.equals(id)) { + LootPool.Builder builder = LootPool.lootPool() + .add(LootItem.lootTableItem(EndItems.END_FISH_RAW)); + table.withPool(builder); + return; + } else if (FISHING_JUNK.equals(id)) { + LootPool.Builder builder = LootPool.lootPool() + .add(LootItem.lootTableItem(EndItems.END_LILY_LEAF)) + .add(LootItem.lootTableItem(Items.ENDER_PEARL)) + .add(LootItem.lootTableItem(Items.CHORUS_FRUIT)) + .add(LootItem.lootTableItem(EndItems.GELATINE)) + .add(LootItem.lootTableItem(EndItems.CRYSTAL_SHARDS)); + addCharnia(builder); + table.withPool(builder); + return; + } else if (FISHING_TREASURE.equals(id)) { + LootPool.Builder builder = LootPool.lootPool() + .add(LootItem.lootTableItem(EndItems.AETERNIUM_SWORD_BLADE)) + .add(LootItem.lootTableItem(EndItems.AETERNIUM_FORGED_PLATE)) + .add(LootItem.lootTableItem(EndBlocks.MENGER_SPONGE)) + .add(LootItem.lootTableItem(Items.BOW) + .apply(SetItemDamageFunction.setDamage(UniformGenerator.between(0.0F, 0.25F))) + .apply(EnchantWithLevelsFunction.enchantWithLevels(ConstantValue.exactly(30.0F)).allowTreasure())) + .add(LootItem.lootTableItem(Items.FISHING_ROD) + .apply(SetItemDamageFunction.setDamage(UniformGenerator.between(0.0F, 0.25F))) + .apply(EnchantWithLevelsFunction.enchantWithLevels(ConstantValue.exactly(30.0F)).allowTreasure())) + .add(LootItem.lootTableItem(Items.BOOK) + .apply(EnchantWithLevelsFunction.enchantWithLevels(ConstantValue.exactly(30.0F)).allowTreasure())); + table.withPool(builder); + return; + } addCommonItems(table); if (FOGGY_MUSHROOMLAND.equals(id)) { LootPool.Builder builder = LootPool.lootPool(); @@ -88,6 +161,24 @@ public class LootTableUtil { } } }); + + LootTableEvents.REPLACE.register((resourceManager, lootManager, id, originalTable, setter) -> { + if (BuiltInLootTables.FISHING.equals(id)) { + LootTable.Builder builder = LootTable.lootTable() + .withPool(LootPool.lootPool().when(IN_END.invert()).setRolls(ConstantValue.exactly(1.0F)) + .add(LootTableReference.lootTableReference(BuiltInLootTables.FISHING_JUNK).setWeight(10).setQuality(-2)) + .add(LootTableReference.lootTableReference(BuiltInLootTables.FISHING_TREASURE).setWeight(5).setQuality(2) + .when(LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, + EntityPredicate.Builder.entity().subPredicate(FishingHookPredicate.inOpenWater(true))))) + .add(LootTableReference.lootTableReference(BuiltInLootTables.FISHING_FISH).setWeight(85).setQuality(-1))) + .withPool(LootPool.lootPool().when(IN_END).setRolls(ConstantValue.exactly(1.0F)) + .add(LootTableReference.lootTableReference(FISHING_FISH).setWeight(85).setQuality(-1)) + .add(LootTableReference.lootTableReference(FISHING_TREASURE).setWeight(5).setQuality(2)) + .add(LootTableReference.lootTableReference(FISHING_JUNK).setWeight(10).setQuality(-2))); + return builder.build(); + } + return null; + }); } public static ResourceLocation getTable(Holder biome) { @@ -106,6 +197,21 @@ public class LootTableUtil { return COMMON; } + private static void addCharnia(LootPool.Builder pool) { + pool.add(LootItem.lootTableItem(EndBlocks.CHARNIA_CYAN) + .when(IN_GLOWING_GRASSLANDS.or(IN_MEGALAKE).or(IN_MEGALAKE_GROVE).or(IN_NEON_OASIS))); + pool.add(LootItem.lootTableItem(EndBlocks.CHARNIA_LIGHT_BLUE) + .when(IN_FOGGY_MUSHROOMLAND.or(IN_GLOWING_GRASSLANDS).or(IN_MEGALAKE).or(IN_MEGALAKE_GROVE).or(IN_UMBRELLA_JUNGLE))); + pool.add(LootItem.lootTableItem(EndBlocks.CHARNIA_GREEN) + .when(IN_GLOWING_GRASSLANDS.or(IN_NEON_OASIS).or(IN_SULPHUR_SPRINGS).or(IN_UMBRELLA_JUNGLE))); + pool.add(LootItem.lootTableItem(EndBlocks.CHARNIA_RED) + .when(IN_AMBER_LAND.or(IN_LANTERN_WOODS).or(IN_NEON_OASIS))); + pool.add(LootItem.lootTableItem(EndBlocks.CHARNIA_ORANGE) + .when(IN_AMBER_LAND.or(IN_LANTERN_WOODS).or(IN_SULPHUR_SPRINGS))); + pool.add(LootItem.lootTableItem(EndBlocks.CHARNIA_PURPLE) + .when(IN_CHORUS_FOREST.or(IN_SHADOW_FOREST))); + } + private static void addCommonItems(LootTable.Builder table) { LootPool.Builder builder = LootPool.lootPool(); builder.setRolls(UniformGenerator.between(0, 2)); diff --git a/src/main/resources/data/betterend/loot_tables/gameplay/fishing/fish.json b/src/main/resources/data/betterend/loot_tables/gameplay/fishing/fish.json new file mode 100644 index 00000000..16cac10a --- /dev/null +++ b/src/main/resources/data/betterend/loot_tables/gameplay/fishing/fish.json @@ -0,0 +1,4 @@ +{ + "type": "minecraft:fishing", + "pools": [] +} diff --git a/src/main/resources/data/betterend/loot_tables/gameplay/fishing/junk.json b/src/main/resources/data/betterend/loot_tables/gameplay/fishing/junk.json new file mode 100644 index 00000000..16cac10a --- /dev/null +++ b/src/main/resources/data/betterend/loot_tables/gameplay/fishing/junk.json @@ -0,0 +1,4 @@ +{ + "type": "minecraft:fishing", + "pools": [] +} diff --git a/src/main/resources/data/betterend/loot_tables/gameplay/fishing/treasure.json b/src/main/resources/data/betterend/loot_tables/gameplay/fishing/treasure.json new file mode 100644 index 00000000..16cac10a --- /dev/null +++ b/src/main/resources/data/betterend/loot_tables/gameplay/fishing/treasure.json @@ -0,0 +1,4 @@ +{ + "type": "minecraft:fishing", + "pools": [] +}