From c83164234badd4d13512428438f4819650ce3f55 Mon Sep 17 00:00:00 2001 From: FX Date: Tue, 22 Jun 2021 22:14:16 -0400 Subject: [PATCH] Added Rule: `fishingOutsideWaterFix` --- README.md | 8 +++++ .../java/carpetfixes/CarpetFixesSettings.java | 8 +++++ .../coreSystemFixes/World_seaLevelMixin.java | 3 +- ...FishingBobberEntity_outsideWaterMixin.java | 30 +++++++++++++++++++ src/main/resources/carpetfixes.accesswidener | 1 + src/main/resources/carpetfixes.mixins.json | 1 + 6 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/main/java/carpetfixes/mixins/entityFixes/FishingBobberEntity_outsideWaterMixin.java diff --git a/README.md b/README.md index fdde46ab..d021327b 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,14 @@ Fixes incorrect sea level height being used when datapacks change the sea height * Categories: `CARPETFIXES`,`BUGFIX` * Fixes: [MC-226687](https://bugs.mojang.com/browse/MC-226687) +## fishingOutsideWaterFix +Fixes being able to fish outside of water +* Type: `boolean` +* Default value: `false` +* Required options: `false`,`true` +* Categories: `CARPETFIXES`,`BUGFIX` +* Fixes: [MC-175544](https://bugs.mojang.com/browse/MC-175544) + ## drownedEnchantedTridentsFix Makes enchantments work on tridents thrown by drowned * Type: `boolean` diff --git a/src/main/java/carpetfixes/CarpetFixesSettings.java b/src/main/java/carpetfixes/CarpetFixesSettings.java index 13b03606..89109c05 100644 --- a/src/main/java/carpetfixes/CarpetFixesSettings.java +++ b/src/main/java/carpetfixes/CarpetFixesSettings.java @@ -294,6 +294,14 @@ public enum PresetSettings { ) public static boolean hardcodedSeaLevelFix = false; + //by FX - PR0CESS + @Rule( + desc = "Fixes being able to fish outside of water", + extra = "Fixes [MC-175544](https://bugs.mojang.com/browse/MC-175544)", + category = {CARPETFIXES,BUGFIX} + ) + public static boolean fishingOutsideWaterFix = false; + /* BACKPORTS diff --git a/src/main/java/carpetfixes/mixins/coreSystemFixes/World_seaLevelMixin.java b/src/main/java/carpetfixes/mixins/coreSystemFixes/World_seaLevelMixin.java index fe8f3d17..b231fca8 100644 --- a/src/main/java/carpetfixes/mixins/coreSystemFixes/World_seaLevelMixin.java +++ b/src/main/java/carpetfixes/mixins/coreSystemFixes/World_seaLevelMixin.java @@ -2,7 +2,6 @@ import carpetfixes.CarpetFixesSettings; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.math.ChunkSectionPos; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; @@ -20,6 +19,8 @@ public abstract class World_seaLevelMixin implements WorldAccess { @Shadow @Final private RegistryKey registryKey; + // Doing the biome hardcoded values is going to need a lot of work, so im waiting for 1.18 since all biome code will change + @Inject(method= "getSeaLevel()I",at=@At("HEAD"),cancellable = true) public void getSeaLevel(CallbackInfoReturnable cir) { if (CarpetFixesSettings.hardcodedSeaLevelFix) { diff --git a/src/main/java/carpetfixes/mixins/entityFixes/FishingBobberEntity_outsideWaterMixin.java b/src/main/java/carpetfixes/mixins/entityFixes/FishingBobberEntity_outsideWaterMixin.java new file mode 100644 index 00000000..b57047e3 --- /dev/null +++ b/src/main/java/carpetfixes/mixins/entityFixes/FishingBobberEntity_outsideWaterMixin.java @@ -0,0 +1,30 @@ +package carpetfixes.mixins.entityFixes; + +import carpetfixes.CarpetFixesSettings; +import net.minecraft.entity.projectile.FishingBobberEntity; +import net.minecraft.fluid.Fluid; +import net.minecraft.fluid.FluidState; +import net.minecraft.tag.FluidTags; +import net.minecraft.tag.Tag; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(FishingBobberEntity.class) +public abstract class FishingBobberEntity_outsideWaterMixin { + @Shadow private boolean inOpenWater; + @Shadow private FishingBobberEntity.State state; + @Shadow private int hookCountdown; + + @Redirect(method= "tick()V",at=@At(value="INVOKE",target="Lnet/minecraft/fluid/FluidState;isIn(Lnet/minecraft/tag/Tag;)Z")) + private boolean betterTick(FluidState fluidState, Tag tag) { + boolean state = fluidState.isIn(FluidTags.WATER); + if (CarpetFixesSettings.fishingOutsideWaterFix && !state) { + this.state = FishingBobberEntity.State.FLYING; + this.inOpenWater = false; + this.hookCountdown = 0; + } + return state; + } +} diff --git a/src/main/resources/carpetfixes.accesswidener b/src/main/resources/carpetfixes.accesswidener index 0b8698b2..8e9adfc3 100644 --- a/src/main/resources/carpetfixes.accesswidener +++ b/src/main/resources/carpetfixes.accesswidener @@ -1 +1,2 @@ accessWidener v1 named +extendable class net/minecraft/entity/projectile/FishingBobberEntity$State diff --git a/src/main/resources/carpetfixes.mixins.json b/src/main/resources/carpetfixes.mixins.json index 9c93021c..f60c3b04 100644 --- a/src/main/resources/carpetfixes.mixins.json +++ b/src/main/resources/carpetfixes.mixins.json @@ -34,6 +34,7 @@ "entityFixes.Entity_directionalBlockSlowdownMixin", "entityFixes.Entity_incorrectLogicMixin", "entityFixes.FallingBlockEntity_netherPortalMixin", + "entityFixes.FishingBobberEntity_outsideWaterMixin", "entityFixes.LivingEntity_sleepingKillsMixin", "entityFixes.MobEntity_leashUpdateOrderMixin", "entityFixes.TntEntity_netherPortalMixin",