Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for MC-177381 #185

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/carpetfixes/CFSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,10 @@ public class CFSettings {
)
public static boolean structuresIgnorePassengersFix = false;

@Rule(
categories = {BUGFIX, RECOMMENDED}
)
public static boolean locateCommandDistanceFix = false;

/*

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package carpetfixes.mixins.commandFixes;

import carpetfixes.CFSettings;
import net.minecraft.server.command.LocateCommand;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

/**
* Fixes the LocateCommand distance calculation when the structure is more than 46340 blocks away.
*/

@Mixin(LocateCommand.class)
public class LocateCommand_distanceFixMixin {

@Inject(at = @At("TAIL"), method = "getDistance", cancellable = true)
private static void getDistance(int x1, int y1, int x2, int y2, CallbackInfoReturnable<Float> cir) {
if (CFSettings.locateCommandDistanceFix) {
double d = x2 - x1;
double e = y2 - y1;
cir.setReturnValue((float) Math.hypot(d, e));
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/carpet-fixes/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"carpet-fixes.rule.lecternBlockDupeFix.desc": "Fixes a lectern block dupe, it just dupes the lectern block",
"carpet-fixes.rule.lightningKillsDropsFix.desc": "Fixes Lightning killing the items that drop from entities it kills",
"carpet-fixes.rule.lightningKillsDropsFix.extra": "[MC-206922](https://bugs.mojang.com/browse/MC-206922)",
"carpet-fixes.rule.locateCommandDistanceFix.desc": "[MC-177381](https://bugs.mojang.com/browse/MC-177381), fixes the locate command reporting wrong distances",
"carpet-fixes.rule.markerArmorStandsCreateBubblesFix.desc": "Fixes marker armor stands creating bubbles in water",
"carpet-fixes.rule.markerArmorStandsCreateBubblesFix.extra": "[MC-78314](https://bugs.mojang.com/browse/MC-78314)",
"carpet-fixes.rule.markerArmorStandsTriggerBlocksFix.desc": "Fixes marker armor stands being able to trigger traps such as pressure plates, and string",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/carpet-fixes.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"blockUpdates.TreeDirtMissingUpdates.TrunkPlacer_logMixin",
"brainFixes.FrogBrain_frictionMixin",
"brainFixes.GoatBrain_frictionMixin",
"commandFixes.LocateCommand_distanceFixMixin",
"conversionFixes.MobEntity_conversionMixin",
"conversionFixes.MooshroomEntity_conversionMixin",
"conversionFixes.SlimeEntity_conversionMixin",
Expand Down