Go back to old and working code

This commit is contained in:
ayunami2000 2022-08-24 16:23:01 -04:00
parent fa349e7af9
commit c08e07b292
8 changed files with 14439 additions and 14418 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.LinkedList;
import java.util.UnknownFormatConversionException;
import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0CPlayerChannel;
import net.minecraft.server.MinecraftServer;
@ -94,7 +95,12 @@ public class WorkerNetworkManager implements INetworkManager {
//System.out.println("[Server][" + ipcChannel + "]: packet '" + pkt.getClass().getSimpleName() + "' recieved");
try {
pkt.processPacket(theNetHandler);
try {
pkt.processPacket(theNetHandler);
} catch (UnknownFormatConversionException breuh) {
System.err.println("!!! 0x" + Integer.toHexString(pkt.getPacketId()) + " class '" + pkt.getClass().getSimpleName() + "' channel 'NET|" + ipcChannel + "' " + breuh.getMessage() + " !!!");
breuh.printStackTrace();
}
}catch(Throwable t) {
System.err.println("Could not process minecraft packet 0x" + Integer.toHexString(pkt.getPacketId()) + " class '" + pkt.getClass().getSimpleName() + "' on channel 'NET|" + ipcChannel + "'");
t.printStackTrace();

View File

@ -137,7 +137,7 @@ public class EntityTracker {
while (var3.hasNext()) {
EntityTrackerEntry var4 = (EntityTrackerEntry) var3.next();
var4.removeFromTrackedPlayers(var2);
var4.removeFromTrackedPlayers(var2, asap);
}
}
@ -193,11 +193,14 @@ public class EntityTracker {
}
public void removePlayerFromTrackers(EntityPlayerMP par1EntityPlayerMP) {
removePlayerFromTrackers(par1EntityPlayerMP, false);
}
public void removePlayerFromTrackers(EntityPlayerMP par1EntityPlayerMP, boolean asap) {
Iterator var2 = this.trackedEntities.iterator();
while (var2.hasNext()) {
EntityTrackerEntry var3 = (EntityTrackerEntry) var2.next();
var3.removeTrackedPlayerSymmetric(par1EntityPlayerMP);
var3.removeTrackedPlayerSymmetric(par1EntityPlayerMP, asap);
}
}

View File

@ -286,9 +286,16 @@ public class EntityTrackerEntry {
}
public void removeFromTrackedPlayers(EntityPlayerMP par1EntityPlayerMP) {
removeFromTrackedPlayers(par1EntityPlayerMP, false);
}
public void removeFromTrackedPlayers(EntityPlayerMP par1EntityPlayerMP, boolean asap) {
if (this.trackingPlayers.contains(par1EntityPlayerMP)) {
//System.out.println(this.trackedEntity.getEntityName() + ": removeFromTrackedPlayers");
par1EntityPlayerMP.destroyedItemsNetCache.add(Integer.valueOf(this.trackedEntity.entityId));
if (asap) {
par1EntityPlayerMP.playerNetServerHandler.sendPacket(new Packet29DestroyEntity(Integer.valueOf(this.trackedEntity.entityId)));
} else {
par1EntityPlayerMP.destroyedItemsNetCache.add(Integer.valueOf(this.trackedEntity.entityId));
}
this.trackingPlayers.remove(par1EntityPlayerMP);
}
}
@ -475,10 +482,17 @@ public class EntityTrackerEntry {
* us from their world.
*/
public void removeTrackedPlayerSymmetric(EntityPlayerMP par1EntityPlayerMP) {
removeTrackedPlayerSymmetric(par1EntityPlayerMP, false);
}
public void removeTrackedPlayerSymmetric(EntityPlayerMP par1EntityPlayerMP, boolean asap) {
if (this.trackingPlayers.contains(par1EntityPlayerMP)) {
this.trackingPlayers.remove(par1EntityPlayerMP);
//System.out.println(this.trackedEntity.getEntityName() + ": removeTrackedPlayerSymmetric");
par1EntityPlayerMP.destroyedItemsNetCache.add(Integer.valueOf(this.trackedEntity.entityId));
if (asap) {
par1EntityPlayerMP.playerNetServerHandler.sendPacket(new Packet29DestroyEntity(Integer.valueOf(this.trackedEntity.entityId)));
} else {
par1EntityPlayerMP.destroyedItemsNetCache.add(Integer.valueOf(this.trackedEntity.entityId));
}
}
}
}

View File

@ -40,11 +40,7 @@ public class Packet204ClientInfo extends Packet {
* Passes this Packet on to the NetHandler for processing.
*/
public void processPacket(NetHandler par1NetHandler) {
try {
par1NetHandler.handleClientInfo(this);
} catch (Throwable e) {
e.printStackTrace();
}
par1NetHandler.handleClientInfo(this);
}
/**

View File

@ -86,21 +86,23 @@ public class PlayerManager {
}
}
public void cycleRenderDistance(EntityPlayerMP player) {
public EntityPlayerMP cycleRenderDistance(EntityPlayerMP player) {
if(player.lastRenderDistance != player.renderDistance) {
player.lastRenderDistance = player.renderDistance;
player.mcServer.getConfigurationManager().updateOnRenderDistanceChange(player);
player.playerNetServerHandler.playerEntity = player.mcServer.getConfigurationManager().recreatePlayerEntity(player, player.dimension, true, false);
player = player.playerNetServerHandler.playerEntity;
}
if(player.mcServer.getServerOwner().equals(player.username)) {
cycleAllRenderDistance(player);
}
return player;
}
public void cycleAllRenderDistance(EntityPlayerMP player) {
player.mcServer.getConfigurationManager().viewDistance = player.renderDistance;
player.lastRenderDistance = player.renderDistance;
List curList = new ArrayList();
curList.addAll(players);
curList.addAll(player.mcServer.getConfigurationManager().playerEntityList);
curList.remove(player);
int limited = player.renderDistance > 10 ? 10 : player.renderDistance;
for(int i = 0, l = curList.size(); i < l; ++i) {
@ -108,7 +110,8 @@ public class PlayerManager {
int targetRenderDist = player.renderDistance > limited ? limited : player.renderDistance;
if (playerReload.renderDistance != targetRenderDist) {
playerReload.lastRenderDistance = playerReload.renderDistance = targetRenderDist;
playerReload.mcServer.getConfigurationManager().updateOnRenderDistanceChange(playerReload);
playerReload.playerNetServerHandler.playerEntity = playerReload.mcServer.getConfigurationManager().recreatePlayerEntity(playerReload, playerReload.dimension, true, false);
// playerReload = playerReload.playerNetServerHandler.playerEntity;
}
}
}
@ -144,7 +147,7 @@ public class PlayerManager {
*/
public EntityPlayerMP filterChunkLoadQueue(EntityPlayerMP par1EntityPlayerMP) {
if(par1EntityPlayerMP.lastRenderDistance != par1EntityPlayerMP.renderDistance) {
cycleRenderDistance(par1EntityPlayerMP);
par1EntityPlayerMP = cycleRenderDistance(par1EntityPlayerMP);
}
ArrayList var2 = new ArrayList(par1EntityPlayerMP.loadedChunks);
int var3 = 0;
@ -227,7 +230,7 @@ public class PlayerManager {
*/
public EntityPlayerMP updateMountedMovingPlayer(EntityPlayerMP par1EntityPlayerMP) {
if(par1EntityPlayerMP.renderDistance != par1EntityPlayerMP.lastRenderDistance) {
cycleRenderDistance(par1EntityPlayerMP);
par1EntityPlayerMP = cycleRenderDistance(par1EntityPlayerMP);
}
int var2 = (int) par1EntityPlayerMP.posX >> 4;
int var3 = (int) par1EntityPlayerMP.posZ >> 4;

View File

@ -290,13 +290,11 @@ public class ServerConfigurationManager {
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().untrackEntity(par1EntityPlayerMP, true);
par1EntityPlayerMP.getServerForPlayer().getPlayerManager().removePlayer(par1EntityPlayerMP);
par1EntityPlayerMP.getServerForPlayer().getPlayerManager().addPlayer(par1EntityPlayerMP);
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().trackEntity(par1EntityPlayerMP);
/*
for (Object loadedChunk : par1EntityPlayerMP.loadedChunks) {
Chunk chunk = (Chunk) loadedChunk;
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().func_85172_a(par1EntityPlayerMP, chunk);
}
*/
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().trackEntity(par1EntityPlayerMP);
}
/**
@ -306,8 +304,8 @@ public class ServerConfigurationManager {
return recreatePlayerEntity(par1EntityPlayerMP, par2, par3, true);
}
public EntityPlayerMP recreatePlayerEntity(EntityPlayerMP par1EntityPlayerMP, int par2, boolean par3, boolean teleport) {
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removePlayerFromTrackers(par1EntityPlayerMP);
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().untrackEntity(par1EntityPlayerMP, true);
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removePlayerFromTrackers(par1EntityPlayerMP, !teleport);
par1EntityPlayerMP.getServerForPlayer().getEntityTracker().untrackEntity(par1EntityPlayerMP, !teleport);
par1EntityPlayerMP.getServerForPlayer().getPlayerManager().removePlayer(par1EntityPlayerMP);
this.playerEntityList.remove(par1EntityPlayerMP);
this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension)