diff --git a/build.gradle b/build.gradle index 619cbe1..ba04960 100644 --- a/build.gradle +++ b/build.gradle @@ -51,6 +51,7 @@ def allIntegrationSourceSets = [ "twilightdelight", "tide", "starcatcher", + "hybridaquatic", "confluence", "vanillabackport", ] @@ -388,6 +389,14 @@ dependencies { starcatcherLocalImplementation("curse.maven:starcatcher-1357603:${starcatcher_version}") } + if (hasIntegration("hybridaquatic")) { + hybridaquaticLocalImplementation("maven.modrinth:hybrid-api:${hybrid_api_version}") + hybridaquaticLocalImplementation("maven.modrinth:hybrid-aquatic:${hybrid_aquatic_version}") + hybridaquaticLocalImplementation("maven.modrinth:geckolib:${geckolib_version}") + hybridaquaticLocalImplementation("maven.modrinth:lithostitched:${lithostitched_version}") + hybridaquaticLocalImplementation("maven.modrinth:kotlin-for-forge:${kotlin_for_forge_version}") + } + if (hasIntegration("confluence")) { confluenceLocalImplementation("maven.modrinth:geckolib:${geckolib_version}") confluenceLocalImplementation("curse.maven:confluence-1209464:${confluence_version}") @@ -466,6 +475,8 @@ var generateModMetadata = tasks.register("generateModMetadata", ProcessResources nether_depths_upgrade_version_range : nether_depths_upgrade_version_range, tide_version_range : tide_version_range, starcatcher_version_range : starcatcher_version_range, + hybrid_api_version_range : hybrid_api_version_range, + hybrid_aquatic_version_range : hybrid_aquatic_version_range, confluence_version_range : confluence_version_range, vanilla_backport_version_range : vanilla_backport_version_range, integration_mixin_blocks : integrationMixinBlocks diff --git a/gradle.properties b/gradle.properties index 536ff09..4d66e4e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,8 +46,15 @@ nether_depths_upgrade_version_range = [3.2,) tide_version = 1ki6UyqV tide_version_range = [2.1.1,3) cloth_config_version = 15.0.140 -starcatcher_version = 8431589 -starcatcher_version_range = [3.0.6,4) +starcatcher_version = 9204486 +starcatcher_version_range = [3.2,4,4) +hybrid_api_version = mc1.21.1-1.1.3-neoforge +hybrid_api_version_range = [1.1.3,) +hybrid_aquatic_version = mc1.21.1-1.7.4-neoforge +hybrid_aquatic_version_range = [1.7.4,2) +lithostitched_version = 1.8.1-neoforge-21.1 +kotlin_for_forge_version = 5.13.0 +### v1.2.9 confluence_version = 9146510 confluence_version_range = [1.2.9,2) ### v1.1.7.10 diff --git a/src/integration/hybridaquatic/java/plus/dragons/createintegratedfarming/integration/hybridaquatic/HybridAquaticIntegration.java b/src/integration/hybridaquatic/java/plus/dragons/createintegratedfarming/integration/hybridaquatic/HybridAquaticIntegration.java new file mode 100644 index 0000000..929005c --- /dev/null +++ b/src/integration/hybridaquatic/java/plus/dragons/createintegratedfarming/integration/hybridaquatic/HybridAquaticIntegration.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2025 DragonsPlus + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package plus.dragons.createintegratedfarming.integration.hybridaquatic; + +import dev.hybridlabs.hapi.entity.base.aquatic.BaseWaterAnimal; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLConstructModEvent; +import plus.dragons.createintegratedfarming.common.CIFCommon; +import plus.dragons.createintegratedfarming.common.fishing.net.FishingNetEntityCaptures; +import plus.dragons.createintegratedfarming.integration.ModIntegration; + +@Mod(CIFCommon.ID) +public class HybridAquaticIntegration { + public HybridAquaticIntegration(IEventBus modBus) { + if (ModIntegration.HYBRID_AQUATIC.enabled()) + modBus.register(new Common()); + } + + public static class Common { + @SubscribeEvent + public void construct(final FMLConstructModEvent event) { + FishingNetEntityCaptures.register(BaseWaterAnimal.class::isInstance); + } + } +} diff --git a/src/integration/starcatcher/java/plus/dragons/createintegratedfarming/integration/starcatcher/StarcatcherFishingNetCatchProvider.java b/src/integration/starcatcher/java/plus/dragons/createintegratedfarming/integration/starcatcher/StarcatcherFishingNetCatchProvider.java index 702c196..d5c0882 100644 --- a/src/integration/starcatcher/java/plus/dragons/createintegratedfarming/integration/starcatcher/StarcatcherFishingNetCatchProvider.java +++ b/src/integration/starcatcher/java/plus/dragons/createintegratedfarming/integration/starcatcher/StarcatcherFishingNetCatchProvider.java @@ -56,7 +56,7 @@ public List getCatch(FishingNetCatchContext context) { if (selected == null) return List.of(); ItemStack stack = FishApi.makeItemStackNonBucket( - selected, context.random().nextFloat() * 100.0F, false, context.player(), false); + bob, selected, context.random().nextFloat() * 100.0F, false, context.player(), false); return stack.isEmpty() ? List.of() : List.of(stack); } finally { bob.discard(); diff --git a/src/main/java/plus/dragons/createintegratedfarming/common/fishing/net/AbstractFishingNetMovementBehaviour.java b/src/main/java/plus/dragons/createintegratedfarming/common/fishing/net/AbstractFishingNetMovementBehaviour.java index cecd084..6f55315 100644 --- a/src/main/java/plus/dragons/createintegratedfarming/common/fishing/net/AbstractFishingNetMovementBehaviour.java +++ b/src/main/java/plus/dragons/createintegratedfarming/common/fishing/net/AbstractFishingNetMovementBehaviour.java @@ -24,8 +24,12 @@ import java.util.ArrayList; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Mob; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.EnchantmentEffectComponents; +import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.entity.EntityTypeTest; import net.minecraft.world.phys.AABB; @@ -51,6 +55,14 @@ protected void onCaptureEntity(MovementContext context, ServerLevel level, T fis var lootTable = level.getServer().reloadableRegistries().getLootTable(entity.getLootTable()); var lootParams = fishing.buildCaptureLootContext(context, level, entity); lootTable.getRandomItems(lootParams, entity.getLootTableSeed(), item -> collectOrDropItem(context, item)); + if (entity instanceof Mob mob) { + for (var slot : EquipmentSlot.values()) { + var stack = mob.getItemBySlot(slot); + if (!stack.isEmpty() && !EnchantmentHelper.has(stack, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP) + && mob.getEquipmentDropChance(slot) > 1.0F) + collectOrDropItem(context, stack); + } + } if (CIFConfig.server().fishingNetCapturedCreatureDropExpNugget.get()) { int experience = EventHooks.getExperienceDrop(entity, fishing.player, entity.getExperienceReward(level, entity)); collectOrDropItem(context, new ItemStack(AllItems.EXP_NUGGET.get(), Math.ceilDiv(experience, 3))); diff --git a/src/main/java/plus/dragons/createintegratedfarming/common/fishing/net/FishingNetEntityCaptures.java b/src/main/java/plus/dragons/createintegratedfarming/common/fishing/net/FishingNetEntityCaptures.java index aae0106..3dee2de 100644 --- a/src/main/java/plus/dragons/createintegratedfarming/common/fishing/net/FishingNetEntityCaptures.java +++ b/src/main/java/plus/dragons/createintegratedfarming/common/fishing/net/FishingNetEntityCaptures.java @@ -52,6 +52,6 @@ public static boolean canCapture(LivingEntity entity) { return false; var dimensions = entity.getDimensions(Pose.SWIMMING); float maxSize = CIFConfig.server().fishingNetCapturedCreatureMaxSize.getF(); - return dimensions.height() < maxSize && dimensions.width() < maxSize; + return dimensions.height() <= maxSize && dimensions.width() <= maxSize; } } diff --git a/src/main/java/plus/dragons/createintegratedfarming/config/CIFServerConfig.java b/src/main/java/plus/dragons/createintegratedfarming/config/CIFServerConfig.java index 0abb8a7..71d95bf 100644 --- a/src/main/java/plus/dragons/createintegratedfarming/config/CIFServerConfig.java +++ b/src/main/java/plus/dragons/createintegratedfarming/config/CIFServerConfig.java @@ -108,7 +108,8 @@ static class Comments { "\"Process\" means captured entity will be discard and all drops will be collected." }; static final String[] fishingNetCapturedCreatureMaxSize = { - "The maximum size (width and height) of creatures that can be caught by the Fishing Net." + "The maximum size (width and height) of creatures that can be caught by the Fishing Net.", + "Creatures of exactly this size are also captured." }; static final String[] fishingNetCapturedCreatureDropExpNugget = { "If creatures captured by Fishing Net should drop Nugget of Experience." diff --git a/src/main/java/plus/dragons/createintegratedfarming/integration/ModIntegration.java b/src/main/java/plus/dragons/createintegratedfarming/integration/ModIntegration.java index c13d956..f3f024a 100644 --- a/src/main/java/plus/dragons/createintegratedfarming/integration/ModIntegration.java +++ b/src/main/java/plus/dragons/createintegratedfarming/integration/ModIntegration.java @@ -50,6 +50,7 @@ public enum ModIntegration { SABLE(Mods.SABLE), TIDE(Mods.TIDE), STARCATCHER(Mods.STARCATCHER), + HYBRID_AQUATIC(Mods.HYBRID_AQUATIC), CONFLUENCE(Mods.CONFLUENCE), VANILLA_BACKPORT(Mods.VANILLA_BACKPORT), TWILIGHT_FOREST(Mods.TWILIGHT_FOREST), @@ -108,6 +109,7 @@ public static class Mods { public static final String SABLE = "sable"; public static final String TIDE = "tide"; public static final String STARCATCHER = "starcatcher"; + public static final String HYBRID_AQUATIC = "hybrid_aquatic"; public static final String CONFLUENCE = "confluence"; public static final String VANILLA_BACKPORT = "vanillabackport"; public static final String SIMULATED = "simulated"; diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index f2f7fcd..4470578 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -3,6 +3,7 @@ public net.minecraft.world.entity.projectile.FishingHook getOpenWaterTypeForBloc public net.minecraft.world.entity.projectile.FishingHook getOpenWaterTypeForArea(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/entity/projectile/FishingHook$OpenWaterType; # getOpenWaterTypeForArea public net.minecraft.world.entity.projectile.FishingHook openWater # openWater public net.minecraft.world.entity.animal.sheep.Sheep eatBlockGoal # eatBlockGoal +public net.minecraft.world.entity.Mob getEquipmentDropChance(Lnet/minecraft/world/entity/EquipmentSlot;)F # getEquipmentDropChance public net.minecraft.world.level.BaseSpawner spawnPotentials public net.minecraft.world.level.BaseSpawner nextSpawnData public-f net.minecraft.data.recipes.RecipeProvider getName()Ljava/lang/String; \ No newline at end of file diff --git a/src/main/templates/META-INF/neoforge.mods.toml b/src/main/templates/META-INF/neoforge.mods.toml index 7684920..9ca6cdc 100644 --- a/src/main/templates/META-INF/neoforge.mods.toml +++ b/src/main/templates/META-INF/neoforge.mods.toml @@ -141,6 +141,20 @@ ${integration_mixin_blocks} ordering="AFTER" side="BOTH" +[[dependencies.${mod_id}]] + modId="hapi" + type="optional" + versionRange="${hybrid_api_version_range}" + ordering="AFTER" + side="BOTH" + +[[dependencies.${mod_id}]] + modId="hybrid_aquatic" + type="optional" + versionRange="${hybrid_aquatic_version_range}" + ordering="AFTER" + side="BOTH" + [[dependencies.${mod_id}]] modId="confluence" type="optional"