Skip to content

Commit

Permalink
Added Rule: fishingOutsideWaterFix
Browse files Browse the repository at this point in the history
  • Loading branch information
FxMorin committed Jun 23, 2021
1 parent 69079d7 commit c831642
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/carpetfixes/CarpetFixesSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,6 +19,8 @@ public abstract class World_seaLevelMixin implements WorldAccess {

@Shadow @Final private RegistryKey<World> 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<Integer> cir) {
if (CarpetFixesSettings.hardcodedSeaLevelFix) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Fluid> tag) {
boolean state = fluidState.isIn(FluidTags.WATER);
if (CarpetFixesSettings.fishingOutsideWaterFix && !state) {
this.state = FishingBobberEntity.State.FLYING;
this.inOpenWater = false;
this.hookCountdown = 0;
}
return state;
}
}
1 change: 1 addition & 0 deletions src/main/resources/carpetfixes.accesswidener
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
accessWidener v1 named
extendable class net/minecraft/entity/projectile/FishingBobberEntity$State
1 change: 1 addition & 0 deletions src/main/resources/carpetfixes.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c831642

Please sign in to comment.