Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
audaki committed Dec 15, 2024
2 parents 926717b + dc10027 commit ea57e11
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
16 changes: 16 additions & 0 deletions src/main/java/audaki/cart_engine/mixin/GameRulesMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package audaki.cart_engine.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.world.flag.FeatureFlag;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.level.GameRules;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(GameRules.class)
public abstract class GameRulesMixin {
@ModifyExpressionValue(method = "<clinit>", at = @At(value = "FIELD", target = "Lnet/minecraft/world/flag/FeatureFlags;MINECART_IMPROVEMENTS:Lnet/minecraft/world/flag/FeatureFlag;"))
private static FeatureFlag enableMinecartSpeed(FeatureFlag featureFlag) {
return FeatureFlags.VANILLA;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ protected NewMinecartBehaviorMixin(AbstractMinecart abstractMinecart) {

@Inject(at = @At("HEAD"), method = "getMaxSpeed", cancellable = true)
public void _getMaxSpeed(ServerLevel level, CallbackInfoReturnable<Double> cir) {
int speedBlocksPerSecond = 8;
if (minecart.isRideable()) {
speedBlocksPerSecond = level.getGameRules().getInt(AceGameRules.ACE_CART_SPEED);;
int speedBlocksPerSecond = level.getGameRules().getInt(AceGameRules.ACE_CART_SPEED);
cir.setReturnValue(speedBlocksPerSecond * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0);
cir.cancel();
}
cir.setReturnValue(speedBlocksPerSecond * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0);
cir.cancel();
}
}
1 change: 1 addition & 0 deletions src/main/resources/audaki_cart_engine.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"AbstractMinecartMixin",
"GameRulesMixin",
"NewMinecartBehaviorMixin"
],
"injectors": {
Expand Down

0 comments on commit ea57e11

Please sign in to comment.