Uses Mixin Magic to add BlockBreakAnimation Packets to the Replay when a Player breaks a block

This commit is contained in:
CrushedPixel
2015-08-11 20:01:45 +02:00
parent 063a26d4ab
commit de082c3230
2 changed files with 28 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
package eu.crushedpixel.replaymod.mixin;
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.play.server.S25PacketBlockBreakAnim;
import net.minecraft.util.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(RenderGlobal.class)
public abstract class MixinRenderGlobal {
@Inject(method = "sendBlockBreakProgress", at = @At("HEAD"))
public void saveBlockBreakProgressPacket(int breakerId, BlockPos pos, int progress, CallbackInfo info) {
if(ConnectionEventHandler.isRecording()) {
EntityPlayer thePlayer = Minecraft.getMinecraft().thePlayer;
if(thePlayer != null && breakerId == thePlayer.getEntityId()) {
ConnectionEventHandler.insertPacket(new S25PacketBlockBreakAnim(breakerId, pos, progress));
}
}
}
}

View File

@@ -8,7 +8,8 @@
"MixinRender",
"MixinRendererLivingEntity",
"MixinRenderItem",
"MixinRenderManager"
"MixinRenderManager",
"MixinRenderGlobal"
],
"server": [],
"client": [],