Redirect S19PacketEntityStatus to the Replay Player's entityID in ReplaySender

Removed unnecessary Event Listeners in RecordingHandler that injected S19PacketEntityStatus whenever the Player was damaged or died
This commit is contained in:
CrushedPixel
2015-08-14 16:26:25 +02:00
parent 130e45a33a
commit 599aa2cf53
3 changed files with 8 additions and 61 deletions

View File

@@ -312,67 +312,6 @@ public class RecordingHandler {
}
}
@SubscribeEvent
public void onHurt(LivingHurtEvent event) {
if(!ConnectionEventHandler.isRecording()) return;
try {
if(event.entity.getEntityId() != mc.thePlayer.getEntityId()) {
return;
}
S19PacketEntityStatus packet = new S19PacketEntityStatus();
ByteBuf buf = Unpooled.buffer();
PacketBuffer pbuf = new PacketBuffer(buf);
pbuf.writeInt(entityID);
pbuf.writeByte(2);
packet.readPacketData(pbuf);
ConnectionEventHandler.insertPacket(packet);
//Damage Animation
S0BPacketAnimation pac = new S0BPacketAnimation();
ByteBuf bb = Unpooled.buffer();
PacketBuffer pb = new PacketBuffer(bb);
pb.writeVarIntToBuffer(entityID);
pb.writeByte(1);
pac.readPacketData(pb);
ConnectionEventHandler.insertPacket(pac);
} catch(Exception e) {
e.printStackTrace();
}
}
@SubscribeEvent
public void onDeath(LivingDeathEvent event) {
if(!ConnectionEventHandler.isRecording()) return;
try {
if(event.entity.getEntityId() != mc.thePlayer.getEntityId()) {
return;
}
S19PacketEntityStatus packet = new S19PacketEntityStatus();
ByteBuf buf = Unpooled.buffer();
PacketBuffer pbuf = new PacketBuffer(buf);
pbuf.writeInt(entityID);
pbuf.writeByte(3);
packet.readPacketData(pbuf);
ConnectionEventHandler.insertPacket(packet);
} catch(Exception e) {
e.printStackTrace();
}
}
@SubscribeEvent
public void onStartEating(PlayerUseItemEvent.Start event) {
if(!ConnectionEventHandler.isRecording()) return;

View File

@@ -325,6 +325,13 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
}
}
if(p instanceof S19PacketEntityStatus) {
S19PacketEntityStatus packet = (S19PacketEntityStatus)p;
if(packet.field_149164_a == actualID) {
packet.field_149164_a = RecordingHandler.entityID;
}
}
if(p instanceof S01PacketJoinGame) {
S01PacketJoinGame packet = (S01PacketJoinGame) p;
allowMovement = true;

View File

@@ -30,6 +30,7 @@ public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149379_a
public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149378_b # list
public net.minecraft.network.play.server.S0BPacketAnimation field_148981_a # entityId
public net.minecraft.network.play.server.S02PacketChat field_179842_b # position
public net.minecraft.network.play.server.S19PacketEntityStatus field_149164_a # entityId
# GuiTextField
public net.minecraft.client.gui.GuiTextField field_146216_j # text