forked from maruohon/servux
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec8ae3e
commit b7c8346
Showing
10 changed files
with
146 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 52 additions & 1 deletion
53
src/main/java/fi/dy/masa/servux/mixin/MixinServerPlayNetworkHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,71 @@ | ||
package fi.dy.masa.servux.mixin; | ||
|
||
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.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
import fi.dy.masa.servux.Servux; | ||
import fi.dy.masa.servux.dataproviders.EntitiesDataProvider; | ||
|
||
@Mixin(value = ServerPlayNetworkHandler.class, priority = 1005) | ||
public class MixinServerPlayNetworkHandler | ||
{ | ||
@Shadow public ServerPlayerEntity player; | ||
|
||
@Redirect(method = "onPlayerInteractBlock", require = 0, | ||
at = @At(value = "INVOKE", | ||
at = @At(value = "INVOKE", | ||
target = "Lnet/minecraft/util/math/Vec3d;subtract(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;")) | ||
private Vec3d servux$removeHitPosCheck(Vec3d hitVec, Vec3d blockCenter) | ||
{ | ||
return Vec3d.ZERO; | ||
//return hitVec.subtract(blockCenter); | ||
} | ||
|
||
@ModifyConstant(method = "onQueryBlockNbt", constant = @Constant(intValue = 2)) | ||
private int servux_onQueryBlockNbt(int constant) | ||
{ | ||
if (EntitiesDataProvider.INSTANCE.hasNbtQueryOverride()) | ||
{ | ||
if (EntitiesDataProvider.INSTANCE.hasNbtQueryPermission(this.player)) | ||
{ | ||
Servux.debugLog("received NbtQueryBlock request from: {}", this.player.getName().getLiteralString()); | ||
return 0; | ||
} | ||
else | ||
{ | ||
return 4; | ||
} | ||
} | ||
else | ||
{ | ||
return constant; | ||
} | ||
} | ||
|
||
@ModifyConstant(method = "onQueryEntityNbt", constant = @Constant(intValue = 2)) | ||
private int servux_onQueryEntityNbt(int constant) | ||
{ | ||
if (EntitiesDataProvider.INSTANCE.hasNbtQueryOverride()) | ||
{ | ||
if (EntitiesDataProvider.INSTANCE.hasNbtQueryPermission(this.player)) | ||
{ | ||
Servux.debugLog("received NbtQueryEntity request from: {}", this.player.getName().getLiteralString()); | ||
return 0; | ||
} | ||
else | ||
{ | ||
return 4; | ||
} | ||
} | ||
else | ||
{ | ||
return constant; | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/fi/dy/masa/servux/mixin/test/MixinSharedConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package fi.dy.masa.servux.mixin.test; | ||
|
||
import net.minecraft.SharedConstants; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import fi.dy.masa.servux.dataproviders.DebugDataProvider; | ||
|
||
@Mixin(SharedConstants.class) | ||
public abstract class MixinSharedConstants | ||
{ | ||
@Shadow @Mutable | ||
public static boolean isDevelopment; | ||
|
||
public MixinSharedConstants() {} | ||
|
||
@Inject(method = "<clinit>", at = @At("TAIL")) | ||
private static void servux_enableServerDevelopmentMode(CallbackInfo ci) | ||
{ | ||
if (DebugDataProvider.INSTANCE.isEnabled() && | ||
DebugDataProvider.INSTANCE.isServerDevelopmentMode()) | ||
{ | ||
isDevelopment = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters