Skip to content

Commit

Permalink
fix wrong block placement distance check (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pilzinsel64 authored Dec 27, 2024
1 parent 16ed4e0 commit 61a0245
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ public class FixesConfig {
@Config.RequiresMcRestart
public static boolean fixHitEffectBrightness;

@Config.Comment("Fix server-side check of block placement distance by players being not identical client-side checks")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean fixWrongBlockPlacementDistanceCheck;

/* ====== Minecraft fixes end ===== */

// bukkit fixes
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ public enum Mixins {
.setSide(Side.BOTH).addMixinClasses("ic2.MixinDirection_Memory")
.setApplyIf(() -> FixesConfig.enableMemoryFixes).addTargetedMod(TargetedMod.IC2)),

FIX_PLAYER_BLOCK_PLACEMENT_DISTANCE_CHECK(new Builder("Fix wrong block placement distance check")
.setPhase(Phase.EARLY).setSide(Side.BOTH)
.addMixinClasses("minecraft.MixinNetHandlePlayServer_FixWrongBlockPlacementCheck")
.setApplyIf(() -> FixesConfig.fixWrongBlockPlacementDistanceCheck).addTargetedMod(TargetedMod.VANILLA)),

// Ic2 adjustments
IC2_UNPROTECTED_GET_BLOCK_FIX(new Builder("IC2 Kinetic Fix").setPhase(Phase.EARLY).setSide(Side.BOTH)
.addMixinClasses("ic2.MixinIc2WaterKinetic").setApplyIf(() -> FixesConfig.fixIc2UnprotectedGetBlock)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;

@Mixin(NetHandlerPlayServer.class)
public class MixinNetHandlePlayServer_FixWrongBlockPlacementCheck {

@WrapOperation(
method = "processPlayerBlockPlacement",
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayerMP;getDistanceSq(DDD)D"))
private double hodgepodge$fixWrongBlockPlacementCheck(EntityPlayerMP entity, double x, double y, double z,
Operation<Double> original) {
y -= entity.getEyeHeight();
return original.call(entity, x, y, z);
}
}

0 comments on commit 61a0245

Please sign in to comment.