diff --git a/build.gradle b/build.gradle index 9e652cb1d..455a1dce7 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id "dts.typescript-generator" } -version = "1.11-beta7" +version = "1.11-beta7.2" group= "kamkeel.customnpc-plus" archivesBaseName = "CustomNPC-Plus" diff --git a/src/main/java/kamkeel/npcs/network/PacketHandler.java b/src/main/java/kamkeel/npcs/network/PacketHandler.java index 93f978bf9..e6a525952 100644 --- a/src/main/java/kamkeel/npcs/network/PacketHandler.java +++ b/src/main/java/kamkeel/npcs/network/PacketHandler.java @@ -569,7 +569,7 @@ public class PacketHandler { DATA_PACKET.registerPacket(new DialogPacket()); DATA_PACKET.registerPacket(new RolePacket()); DATA_PACKET.registerPacket(new WeaponNpcPacket()); - // DATA_PACKET.registerPacket(new RequestProperSpawnData()); +// DATA_PACKET.registerPacket(new RequestProperSpawnData()); // Data | Script Packets DATA_PACKET.registerPacket(new ScriptedParticlePacket()); diff --git a/src/main/java/kamkeel/npcs/network/enums/EnumDataPacket.java b/src/main/java/kamkeel/npcs/network/enums/EnumDataPacket.java index 6d9a6f598..181956757 100644 --- a/src/main/java/kamkeel/npcs/network/enums/EnumDataPacket.java +++ b/src/main/java/kamkeel/npcs/network/enums/EnumDataPacket.java @@ -23,7 +23,7 @@ public enum EnumDataPacket { DELETE_NPC, CLONE_NPC, WEAPON_NPC, - REQUEST_SPAWN_DATA, + // REQUEST_SPAWN_DATA, // Data SCROLL_LIST, diff --git a/src/main/java/kamkeel/npcs/network/packets/data/RequestProperSpawnData.java b/src/main/java/kamkeel/npcs/network/packets/data/RequestProperSpawnData.java index 76e010660..d2ad045d1 100644 --- a/src/main/java/kamkeel/npcs/network/packets/data/RequestProperSpawnData.java +++ b/src/main/java/kamkeel/npcs/network/packets/data/RequestProperSpawnData.java @@ -1,127 +1,125 @@ -package kamkeel.npcs.network.packets.data; - -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import io.netty.buffer.ByteBuf; -import kamkeel.npcs.network.AbstractPacket; -import kamkeel.npcs.network.PacketChannel; -import kamkeel.npcs.network.PacketClient; -import kamkeel.npcs.network.PacketHandler; -import kamkeel.npcs.network.enums.EnumDataPacket; -import kamkeel.npcs.network.packets.data.npc.UpdateNpcPacket; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; -import noppes.npcs.LogWriter; -import noppes.npcs.entity.EntityNPCInterface; - -import java.io.IOException; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -public class RequestProperSpawnData extends AbstractPacket { - public static final String packetName = "Data|SpawnData"; - private static final int BATCH_LIMIT = 5; - - @SideOnly(Side.CLIENT) - private static Set entitiesToFix; - - @SideOnly(Side.CLIENT) - private static long lastBatchAttemptMillis; - - static { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { - entitiesToFix = new HashSet<>(); - lastBatchAttemptMillis = 0; - } - } - - private int entityId; - - public RequestProperSpawnData() {} - - @SideOnly(Side.CLIENT) - public RequestProperSpawnData(int entityId) { - this.entityId = entityId; - } - - public static void clear() { - entitiesToFix.clear(); - } - - @Override - public Enum getType() { - return EnumDataPacket.REQUEST_SPAWN_DATA; - } - - @Override - public PacketChannel getChannel() { - return PacketHandler.DATA_PACKET; - } - - @Override - @SideOnly(Side.CLIENT) - public void sendData(ByteBuf out) throws IOException { - out.writeInt(this.entityId); - } - - @Override - public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) - return; - - int entityId = in.readInt(); - Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(entityId); - if (entity instanceof EntityNPCInterface) { - EntityNPCInterface npc = (EntityNPCInterface) entity; - NBTTagCompound compound = npc.writeSpawnData(); - compound.setInteger("EntityId", npc.getEntityId()); - PacketHandler.Instance.sendToPlayer(new UpdateNpcPacket(compound), (EntityPlayerMP) player); - } - } - - @SideOnly(Side.CLIENT) - public static void reportMissingData(EntityNPCInterface npc) { - int entityID = npc.getEntityId(); - - if (npc.immediateSpawnDataFixAttempts++ < 3) { - PacketClient.sendClient(new RequestProperSpawnData(entityID)); - } else { - entitiesToFix.add(entityID); - } - } - - @SideOnly(Side.CLIENT) - public static boolean canDoBatchUpdate() { - return System.currentTimeMillis() - lastBatchAttemptMillis >= 5000; - } - - @SideOnly(Side.CLIENT) - public static void handleBacklog() { - Minecraft mc = Minecraft.getMinecraft(); - if (mc == null || mc.theWorld == null || mc.thePlayer == null) - return; - - if (entitiesToFix.isEmpty()) - return; - // Remove entity checks if they're no longer loaded - entitiesToFix.removeIf( value -> !(Minecraft.getMinecraft().theWorld.getEntityByID(value) instanceof EntityNPCInterface) ); - - Iterator it = entitiesToFix.iterator(); - int count = 0; - - while (it.hasNext() && count < BATCH_LIMIT) { - PacketClient.sendClient(new RequestProperSpawnData(it.next())); - it.remove(); - count++; - } - - if (count != 0) { - lastBatchAttemptMillis = System.currentTimeMillis(); - } - } -} +//package kamkeel.npcs.network.packets.data; +// +//import cpw.mods.fml.relauncher.Side; +//import cpw.mods.fml.relauncher.SideOnly; +//import io.netty.buffer.ByteBuf; +//import kamkeel.npcs.network.AbstractPacket; +//import kamkeel.npcs.network.PacketChannel; +//import kamkeel.npcs.network.PacketClient; +//import kamkeel.npcs.network.PacketHandler; +//import kamkeel.npcs.network.enums.EnumDataPacket; +//import kamkeel.npcs.network.packets.data.npc.UpdateNpcPacket; +//import net.minecraft.client.Minecraft; +//import net.minecraft.entity.Entity; +//import net.minecraft.entity.player.EntityPlayer; +//import net.minecraft.entity.player.EntityPlayerMP; +//import net.minecraft.nbt.NBTTagCompound; +//import noppes.npcs.entity.EntityNPCInterface; +// +//import java.io.IOException; +//import java.util.HashSet; +//import java.util.Iterator; +//import java.util.Set; +// +//public class RequestProperSpawnData extends AbstractPacket { +// public static final String packetName = "Data|SpawnData"; +// private static final int BATCH_LIMIT = 5; +// +// @SideOnly(Side.CLIENT) +// private static final Set entitiesToFix = new HashSet<>(); +// +// @SideOnly(Side.CLIENT) +// private static long lastBatchAttemptMillis = 0L; +// +// private int entityId; +// +// public RequestProperSpawnData() {} +// +// @SideOnly(Side.CLIENT) +// public RequestProperSpawnData(int entityId) { +// this.entityId = entityId; +// } +// +// @SideOnly(Side.CLIENT) +// public static void clear() { +// entitiesToFix.clear(); +// lastBatchAttemptMillis = 0L; +// } +// +// @Override +// public Enum getType() { +// return EnumDataPacket.REQUEST_SPAWN_DATA; +// } +// +// @Override +// public PacketChannel getChannel() { +// return PacketHandler.DATA_PACKET; +// } +// +// @Override +// @SideOnly(Side.CLIENT) +// public void sendData(ByteBuf out) throws IOException { +// out.writeInt(this.entityId); +// } +// +// @Override +// public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { +// if (!(player instanceof EntityPlayerMP) || player.worldObj == null || player.worldObj.isRemote) +// return; +// +// int entityId = in.readInt(); +// Entity entity = player.worldObj.getEntityByID(entityId); +// if (entity instanceof EntityNPCInterface) { +// EntityNPCInterface npc = (EntityNPCInterface) entity; +// NBTTagCompound compound = npc.writeSpawnData(); +// compound.setInteger("EntityId", npc.getEntityId()); +// PacketHandler.Instance.sendToPlayer(new UpdateNpcPacket(compound), (EntityPlayerMP) player); +// } +// } +// +// @SideOnly(Side.CLIENT) +// public static void reportMissingData(EntityNPCInterface npc) { +// if (npc == null || npc.worldObj == null || !npc.worldObj.isRemote) +// return; +// +// int entityID = npc.getEntityId(); +// if (entityID <= 0) +// return; +// +// if (npc.immediateSpawnDataFixAttempts++ < 3) { +// PacketClient.sendClient(new RequestProperSpawnData(entityID)); +// } else { +// entitiesToFix.add(entityID); +// } +// } +// +// @SideOnly(Side.CLIENT) +// public static boolean canDoBatchUpdate() { +// return System.currentTimeMillis() - lastBatchAttemptMillis >= 5000; +// } +// +// @SideOnly(Side.CLIENT) +// public static void handleBacklog() { +// Minecraft mc = Minecraft.getMinecraft(); +// if (mc == null || mc.theWorld == null || mc.thePlayer == null) +// return; +// +// if (entitiesToFix.isEmpty()) +// return; +// // Remove entity checks if they're no longer loaded +// entitiesToFix.removeIf(value -> !(mc.theWorld.getEntityByID(value) instanceof EntityNPCInterface)); +// +// Iterator it = entitiesToFix.iterator(); +// int count = 0; +// +// while (it.hasNext() && count < BATCH_LIMIT) { +// PacketClient.sendClient(new RequestProperSpawnData(it.next())); +// it.remove(); +// count++; +// } +// +// if (count != 0) { +// lastBatchAttemptMillis = System.currentTimeMillis(); +// } +// } +//} diff --git a/src/main/java/noppes/npcs/client/ClientTickHandler.java b/src/main/java/noppes/npcs/client/ClientTickHandler.java index 3e2742c37..bfd3b0cae 100644 --- a/src/main/java/noppes/npcs/client/ClientTickHandler.java +++ b/src/main/java/noppes/npcs/client/ClientTickHandler.java @@ -61,7 +61,7 @@ public class ClientTickHandler { if (mc.theWorld == null) { ClientCacheHandler.clearCache(); ClientAbilityState.reset(); - // RequestProperSpawnData.clear(); +// RequestProperSpawnData.clear(); if (EnergyChargePreviewManager.ClientInstance != null) { EnergyChargePreviewManager.ClientInstance.clear(); } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index a1daf1eb6..24579e4ab 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -11,7 +11,6 @@ import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.network.enums.EnumSoundOperation; import kamkeel.npcs.network.packets.data.ChatBubblePacket; import kamkeel.npcs.network.packets.data.QuestCompletionPacket; -import kamkeel.npcs.network.packets.data.RequestProperSpawnData; import kamkeel.npcs.network.packets.data.SoundManagementPacket; import kamkeel.npcs.network.packets.data.npc.UpdateNpcPacket; import kamkeel.npcs.network.packets.data.npc.WeaponNpcPacket; @@ -231,8 +230,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this); public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj); - @SideOnly(Side.CLIENT) - public int immediateSpawnDataFixAttempts = 0; +// @SideOnly(Side.CLIENT) +// public int immediateSpawnDataFixAttempts = 0; public EntityNPCInterface(World world) { super(world); @@ -1837,7 +1836,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti try { readSpawnData(ByteBufUtils.readNBT(buf)); } catch (IOException e) { -// if(this.worldObj != null && this.worldObj.isRemote){ +// if (this.worldObj != null && this.worldObj.isRemote) { // RequestProperSpawnData.reportMissingData(this); // } } @@ -1849,8 +1848,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti // RequestProperSpawnData.reportMissingData(this); // return; // } - - immediateSpawnDataFixAttempts = 0; +// +// immediateSpawnDataFixAttempts = 0; stats.maxHealth = compound.getDouble("MaxHealth"); ais.setWalkingSpeed(compound.getInteger("Speed")); stats.hideKilledBody = compound.getBoolean("DeadBody");