Writes S38PacketPlayerListItem when Player joins
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
package eu.crushedpixel.replaymod.events;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -14,6 +15,8 @@ import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S0CPacketSpawnPlayer;
|
||||
import net.minecraft.network.play.server.S14PacketEntity.S17PacketEntityLookMove;
|
||||
import net.minecraft.network.play.server.S18PacketEntityTeleport;
|
||||
import net.minecraft.network.play.server.S38PacketPlayerListItem;
|
||||
import net.minecraft.network.play.server.S38PacketPlayerListItem.Action;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -31,6 +34,27 @@ public class RecordingHandler {
|
||||
if(e.entity != mc.thePlayer) return;
|
||||
if(!ConnectionEventHandler.isRecording()) return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer)e.entity;
|
||||
|
||||
S38PacketPlayerListItem ppli = new S38PacketPlayerListItem();
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
PacketBuffer pbuf = new PacketBuffer(buf);
|
||||
|
||||
pbuf.writeEnumValue(Action.ADD_PLAYER);
|
||||
pbuf.writeVarIntToBuffer(1);
|
||||
pbuf.writeUuid(e.entity.getUniqueID());
|
||||
|
||||
pbuf.writeString(player.getName());
|
||||
pbuf.writeVarIntToBuffer(0);
|
||||
pbuf.writeVarIntToBuffer(mc.playerController.getCurrentGameType().getID());
|
||||
pbuf.writeVarIntToBuffer(0);
|
||||
|
||||
pbuf.writeBoolean(true);
|
||||
pbuf.writeChatComponent(player.getDisplayName());
|
||||
|
||||
ppli.readPacketData(pbuf);
|
||||
ConnectionEventHandler.insertPacket(ppli);
|
||||
|
||||
//Packet packet = new S0CPacketSpawnPlayer((EntityPlayer)e.entity);
|
||||
Packet packet = new S0CPacketSpawnPlayer();
|
||||
|
||||
@@ -39,7 +63,7 @@ public class RecordingHandler {
|
||||
|
||||
pb.writeVarIntToBuffer(entityID);
|
||||
//pb.writeUuid((e.entity).getUniqueID());
|
||||
pb.writeUuid(UUID.randomUUID());
|
||||
pb.writeUuid(e.entity.getUniqueID());
|
||||
|
||||
pb.writeInt(MathHelper.floor_double(e.entity.posX * 32.0D));
|
||||
pb.writeInt(MathHelper.floor_double(e.entity.posY * 32.0D));
|
||||
|
||||
@@ -284,7 +284,7 @@ public class ReplayHandler {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void startReplay(File file) throws NoSuchMethodException, SecurityException, NoSuchFieldException {
|
||||
public static void startReplay(File file) throws NoSuchMethodException, SecurityException, NoSuchFieldException {
|
||||
|
||||
ChatMessageRequests.initialize();
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||
|
||||
@@ -319,7 +319,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
});
|
||||
|
||||
private List<Class> packetClasses = new ArrayList<Class>();
|
||||
|
||||
|
||||
private static Field field_149074_a; //TODO: REMOVE
|
||||
static {
|
||||
try {
|
||||
@@ -344,7 +344,7 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
byte[] ba = (byte[])msg;
|
||||
|
||||
try {
|
||||
ByteBuf bb = Unpooled.buffer(ba.length);
|
||||
ByteBuf bb = Unpooled.wrappedBuffer(ba);
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
pb.writeBytes(ba);
|
||||
@@ -397,24 +397,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
if(p instanceof S1CPacketEntityMetadata) {
|
||||
int entityId = (Integer)metadataPacketEntityId.get(p);
|
||||
}
|
||||
|
||||
if(p instanceof S0BPacketAnimation) {
|
||||
int entityId = (Integer)animationPacketEntityId.get(p);
|
||||
if(entityId == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(p instanceof S1DPacketEntityEffect) {
|
||||
int entityId = (Integer)effectPacketEntityId.get(p);
|
||||
if(entityId == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(p instanceof S37PacketStatistics) {
|
||||
return;
|
||||
}
|
||||
@@ -469,7 +451,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Entity ent = ReplayHandler.getCameraEntity();
|
||||
if(ent == null || !(ent instanceof CameraEntity)) ent = new CameraEntity(mc.theWorld);
|
||||
CameraEntity cent = (CameraEntity)ent;
|
||||
|
||||
Reference in New Issue
Block a user