diff --git a/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java b/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java index 2084aa75..1adc3fa2 100644 --- a/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java +++ b/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java @@ -1,32 +1 @@ -package com.replaymod.recording.mixin; - -//#if MC>=10904 && MC<11400 -//$$ import com.replaymod.recording.handler.RecordingEventHandler; -//$$ import net.minecraft.client.Minecraft; -//$$ import net.minecraft.client.multiplayer.PlayerControllerMP; -//$$ import net.minecraft.util.math.BlockPos; -//$$ import net.minecraft.world.World; -//$$ 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; -//$$ -//$$ import static com.replaymod.core.versions.MCVer.*; -//$$ -//$$ @Mixin(PlayerControllerMP.class) -//$$ public abstract class MixinPlayerControllerMP implements RecordingEventHandler.RecordingEventSender { -//$$ -//$$ @Shadow -//$$ private Minecraft mc; -//$$ -//$$ // Redirects the call to playEvent without the initial player argument to the method with that argument -//$$ // The new method will then play it and (if applicable) record it. (See MixinWorldClient) -//$$ // This is necessary for the block break event (particles and sound) to be recorded. Otherwise it looks like the -//$$ // event was emitted because of a packet (player will be null) and not as it actually was (by the player). -//$$ @Redirect(method = "onPlayerDestroyBlock", at = @At(value = "INVOKE", -//$$ target = "Lnet/minecraft/world/World;playEvent(ILnet/minecraft/util/math/BlockPos;I)V")) -//$$ public void replayModRecording_playEvent_fixed(World world, int type, BlockPos pos, int data) { -//$$ world.playEvent(mc.player, type, pos, data); -//$$ } -//$$ } -//#endif +// 1.9.4 - 1.12.2 diff --git a/versions/1.12.2/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java b/versions/1.12.2/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java new file mode 100644 index 00000000..11e08b99 --- /dev/null +++ b/versions/1.12.2/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java @@ -0,0 +1,33 @@ +package com.replaymod.recording.mixin; + +//#if MC>=10904 && MC<11400 +import com.replaymod.recording.handler.RecordingEventHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.PlayerControllerMP; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Final; +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; + +import static com.replaymod.core.versions.MCVer.*; + +@Mixin(PlayerControllerMP.class) +public abstract class MixinPlayerControllerMP implements RecordingEventHandler.RecordingEventSender { + + @Final @Shadow + private Minecraft mc; + + // Redirects the call to playEvent without the initial player argument to the method with that argument + // The new method will then play it and (if applicable) record it. (See MixinWorldClient) + // This is necessary for the block break event (particles and sound) to be recorded. Otherwise it looks like the + // event was emitted because of a packet (player will be null) and not as it actually was (by the player). + @Redirect(method = "onPlayerDestroyBlock", at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/World;playEvent(ILnet/minecraft/util/math/BlockPos;I)V")) + public void replayModRecording_playEvent_fixed(World world, int type, BlockPos pos, int data) { + world.playEvent(mc.player, type, pos, data); + } +} +//#endif diff --git a/versions/1.8.9/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java b/versions/1.8.9/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java new file mode 100644 index 00000000..1adc3fa2 --- /dev/null +++ b/versions/1.8.9/src/main/java/com/replaymod/recording/mixin/MixinPlayerControllerMP.java @@ -0,0 +1 @@ +// 1.9.4 - 1.12.2