Move MixinPlayerControllerMP into 1.12.2 project
This commit is contained in:
@@ -1,32 +1 @@
|
|||||||
package com.replaymod.recording.mixin;
|
// 1.9.4 - 1.12.2
|
||||||
|
|
||||||
//#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
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
// 1.9.4 - 1.12.2
|
||||||
Reference in New Issue
Block a user