diff --git a/build.gradle b/build.gradle index 18579e29..55c7b1a9 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ loom { accessWidenerPath = file("src/main/resources/betterend.accesswidener") interfaceInjection { // When enabled injected interfaces from dependecies will be applied. - enableDependencyInterfaceInjection = false + enableDependencyInterfaceInjection = true } } diff --git a/src/main/java/org/betterx/betterend/registry/EndTags.java b/src/main/java/org/betterx/betterend/registry/EndTags.java index 3ba41b69..073fe6fe 100644 --- a/src/main/java/org/betterx/betterend/registry/EndTags.java +++ b/src/main/java/org/betterx/betterend/registry/EndTags.java @@ -124,6 +124,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 a406844d..8de38fbe 100644 --- a/src/main/java/org/betterx/betterend/util/LootTableUtil.java +++ b/src/main/java/org/betterx/betterend/util/LootTableUtil.java @@ -8,32 +8,67 @@ import org.betterx.betterend.registry.EndBiomes; import org.betterx.betterend.registry.EndBlocks; import org.betterx.betterend.registry.EndItems; +import net.minecraft.advancements.critereon.LocationPredicate; import net.minecraft.core.Holder; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Items; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.Level; 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.minecraft.world.level.storage.loot.BuiltInLootTables; +import net.minecraft.world.level.storage.loot.entries.LootItem; +import net.minecraft.world.level.storage.loot.entries.LootTableReference; +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.fabricmc.fabric.api.loot.v2.LootTableEvents; public class LootTableUtil { - private static final ResourceLocation END_CITY_TREASURE_ID = new ResourceLocation("chests/end_city_treasure"); private static final ResourceLocation COMMON = BetterEnd.makeID("chests/common"); private static final ResourceLocation FOGGY_MUSHROOMLAND = BetterEnd.makeID("chests/foggy_mushroomland"); private static final ResourceLocation CHORUS_FOREST = BetterEnd.makeID("chests/chorus_forest"); 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) -> { - if (END_CITY_TREASURE_ID.equals(id)) { + if (BuiltInLootTables.END_CITY_TREASURE.equals(id)) { LootPool.Builder builder = LootPool.lootPool(); builder.setRolls(ConstantValue.exactly(1)); builder.when(LootItemRandomChanceCondition.randomChance(0.2f)); @@ -47,7 +82,45 @@ public class LootTableUtil { builder.add(LootItem.lootTableItem(EndItems.MUSIC_DISC_ENDSEEKER)); builder.add(LootItem.lootTableItem(EndItems.MUSIC_DISC_EO_DRACONA)); table.withPool(builder); + } else if (BuiltInLootTables.FISHING.equals(id)) { + table.modifyPools((modifier) -> modifier.when(IN_END.invert())); + table.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))); } 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)) + .add(LootItem.lootTableItem(EndItems.HYDRALUX_PETAL).when(IN_SULPHUR_SPRINGS)); + addCharnia(builder); + table.withPool(builder); + return; + } else if (FISHING_TREASURE.equals(id)) { + LootPool.Builder builder = LootPool.lootPool() + .add(LootItem.lootTableItem(EndBlocks.TERMINITE.swordBlade)) + .add(LootItem.lootTableItem(EndBlocks.TERMINITE.forgedPlate)) + .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(); @@ -106,6 +179,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": [] +}