WE KEEPPPP ON GOING

This commit is contained in:
Kam committed 2025-01-29 23:33:35 -05:00
1 parent 4eae773f86
commit 29f9774d1f
12 files changed
+88 -55

No files matched your search

@@ -6,29 +6,22 @@ import cpw.mods.fml.common.network.FMLNetworkEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import kamkeel.npcs.network.enums.EnumPacketType;
import kamkeel.npcs.network.packets.client.AchievementPacket;
import kamkeel.npcs.network.packets.client.ChatAlertPacket;
import kamkeel.npcs.network.packets.client.ChatBubblePacket;
import kamkeel.npcs.network.packets.client.EditNpcPacket;
import kamkeel.npcs.network.packets.client.gui.GuiClosePacket;
import kamkeel.npcs.network.packets.client.gui.GuiDataPacket;
import kamkeel.npcs.network.packets.client.gui.GuiErrorPacket;
import kamkeel.npcs.network.packets.client.gui.GuiOpenPacket;
import kamkeel.npcs.network.packets.client.*;
import kamkeel.npcs.network.packets.client.gui.*;
import kamkeel.npcs.network.packets.client.large.LargeScrollDataPacket;
import kamkeel.npcs.network.packets.client.large.LargeScrollGroupPacket;
import kamkeel.npcs.network.packets.client.large.LargeScrollListPacket;
import kamkeel.npcs.network.packets.client.large.sync.LargeSyncPacket;
import kamkeel.npcs.network.packets.client.npc.DeleteNpcPacket;
import kamkeel.npcs.network.packets.client.npc.EditNpcPacket;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import noppes.npcs.constants.EnumPacketClient;
import java.io.IOException;
import java.util.*;
public final class PacketHandler {
@@ -63,12 +56,22 @@ public final class PacketHandler {
CLIENT_PACKET.registerPacket(new ChatAlertPacket());
CLIENT_PACKET.registerPacket(new AchievementPacket());
CLIENT_PACKET.registerPacket(new EditNpcPacket());
CLIENT_PACKET.registerPacket(new RolePacket());
CLIENT_PACKET.registerPacket(new GuiTeleporterPacket());
// Client | GUI Packets
CLIENT_PACKET.registerPacket(new GuiClosePacket());
CLIENT_PACKET.registerPacket(new GuiOpenPacket());
CLIENT_PACKET.registerPacket(new GuiErrorPacket());
CLIENT_PACKET.registerPacket(new GuiDataPacket());
CLIENT_PACKET.registerPacket(new GuiClonerPacket());
// Client | NPC Packets
CLIENT_PACKET.registerPacket(new DeleteNpcPacket());
// Client | Other
CLIENT_PACKET.registerPacket(new ParticlePacket());
CLIENT_PACKET.registerPacket(new ScriptedParticlePacket());
}
private void registerChannels() {
@@ -5,6 +5,7 @@ import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumClientPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.client.NoppesUtil;
@@ -13,8 +14,28 @@ import java.io.IOException;
public final class ParticlePacket extends AbstractPacket {
public static final String packetName = "Client|Particle";
private double x;
private double y;
private double z;
private float height;
private float width;
private float yOffset;
private String particle;
public ParticlePacket() {}
public ParticlePacket(double x, double y, double z, float height, float width, float yOffset, String particle) {
this.x = x;
this.y = y;
this.z = z;
this.height = height;
this.width = width;
this.yOffset = yOffset;
this.particle = particle;
}
@Override
public Enum getType() {
return EnumClientPacket.PARTICLE;
@@ -27,7 +48,15 @@ public final class ParticlePacket extends AbstractPacket {
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
out.writeDouble(x);
out.writeDouble(y);
out.writeDouble(z);
out.writeFloat(height);
out.writeFloat(width);
out.writeFloat(yOffset);
ByteBufUtils.writeString(out, particle);
}
@Override
@@ -5,7 +5,9 @@ import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumClientPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.NoppesUtil;
import java.io.IOException;
@@ -13,8 +15,14 @@ import java.io.IOException;
public final class ScriptedParticlePacket extends AbstractPacket {
public static final String packetName = "Client|ScriptedParticle";
private NBTTagCompound compound;
public ScriptedParticlePacket() {}
public ScriptedParticlePacket(NBTTagCompound compound) {
this.compound = compound;
}
@Override
public Enum getType() {
return EnumClientPacket.SCRIPTED_PARTICLE;
@@ -27,7 +35,7 @@ public final class ScriptedParticlePacket extends AbstractPacket {
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
ByteBufUtils.writeNBT(out, compound);
}
@Override
@@ -6,21 +6,25 @@ import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumClientPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.Server;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.GuiNpcMobSpawnerAdd;
import java.io.IOException;
public final class GUIClonerPacket extends AbstractPacket {
public final class GuiClonerPacket extends AbstractPacket {
public static final String packetName = "Client|Clone";
public GUIClonerPacket() {}
private NBTTagCompound compound;
public GUIClonerPacket(boolean ok) {}
public GuiClonerPacket() {}
public GuiClonerPacket(NBTTagCompound comp){
this.compound = comp;
}
@Override
public Enum getType() {
@@ -34,14 +38,14 @@ public final class GUIClonerPacket extends AbstractPacket {
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
ByteBufUtils.writeNBT(out, compound);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if(CustomNpcs.side() != Side.CLIENT)
return;
NBTTagCompound nbt = Server.readNBT(in);
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
NoppesUtil.openGUI(player, new GuiNpcMobSpawnerAdd(nbt));
}
}
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.client;
package kamkeel.npcs.network.packets.client.gui;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
@@ -12,10 +12,10 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.io.IOException;
public final class TeleporterPacket extends AbstractPacket {
public final class GuiTeleporterPacket extends AbstractPacket {
public static final String packetName = "Client|Teleporter";
public TeleporterPacket() {}
public GuiTeleporterPacket(){}
@Override
public Enum getType() {
@@ -28,12 +28,10 @@ public final class TeleporterPacket extends AbstractPacket {
}
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
}
public void sendData(ByteBuf out) throws IOException {}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
CustomNpcs.proxy.openGui((EntityNPCInterface)null,EnumGuiType.NpcDimensions);
CustomNpcs.proxy.openGui((EntityNPCInterface)null, EnumGuiType.NpcDimensions);
}
}
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.client;
package kamkeel.npcs.network.packets.client.gui;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.client;
package kamkeel.npcs.network.packets.client.npc;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
@@ -15,8 +15,14 @@ import java.io.IOException;
public final class DeleteNpcPacket extends AbstractPacket {
public static final String packetName = "Client|DeleteNpc";
private int entityId;
public DeleteNpcPacket() {}
public DeleteNpcPacket(int id){
this.entityId = id;
}
@Override
public Enum getType() {
return EnumClientPacket.DELETE_NPC;
@@ -29,7 +35,7 @@ public final class DeleteNpcPacket extends AbstractPacket {
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
out.writeInt(this.entityId);
}
@Override
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.client;
package kamkeel.npcs.network.packets.client.npc;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.client;
package kamkeel.npcs.network.packets.client.npc;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
@@ -5,8 +5,12 @@ import kamkeel.npcs.controllers.SyncMaster;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.PacketUtil;
import kamkeel.npcs.network.packets.client.DialogPacket;
import kamkeel.npcs.network.packets.client.EditNpcPacket;
import kamkeel.npcs.network.packets.client.ParticlePacket;
import kamkeel.npcs.network.packets.client.ScriptedParticlePacket;
import kamkeel.npcs.network.packets.client.npc.DeleteNpcPacket;
import kamkeel.npcs.network.packets.client.npc.EditNpcPacket;
import kamkeel.npcs.network.packets.client.RolePacket;
import kamkeel.npcs.network.packets.client.gui.GuiTeleporterPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.command.server.CommandBlockLogic;
import net.minecraft.entity.Entity;
@@ -359,16 +363,11 @@ public class NoppesUtilServer {
return null;
}
public static void spawnParticle(Entity entity,String particle, int dimension){
BOB.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
PacketHandler.Instance.sendTracking(new ParticlePacket(entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle), entity);
}
public static void spawnScriptedParticle(NBTTagCompound compound, int dimensionId){
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
for (EntityPlayer player : list) {
if (player.worldObj.provider.dimensionId == dimensionId) {
BOB.sendData((EntityPlayerMP) player, EnumPacketClient.SCRIPTED_PARTICLE, compound);
}
}
PacketHandler.Instance.sendToDimension(new ScriptedParticlePacket(compound), dimensionId);
}
public static void playSound(int id, ScriptSound sound) {
@@ -414,7 +413,7 @@ public class NoppesUtilServer {
}
public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) {
BOB.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId());
PacketHandler.Instance.sendTracking(new DeleteNpcPacket(npc.getEntityId()), npc);
}
public static void createMobSpawner(int x, int y, int z, NBTTagCompound comp, EntityPlayer player) {
@@ -715,7 +714,7 @@ public class NoppesUtilServer {
public static void setTeleporterGUI(EntityPlayerMP player){
if(player == null)
return;
BOB.sendData(player, EnumPacketClient.TELEPORTER);
PacketHandler.Instance.sendToPlayer(new GuiTeleporterPacket(), player);
}
public static void setRecipeGui(EntityPlayerMP player, RecipeCarpentry recipe){
@@ -89,12 +89,6 @@ public class PacketHandlerClient extends PacketHandlerServer{
return;
NoppesUtil.openDialog(Server.readNBT(buffer), (EntityNPCInterface) entity, player);
}
else if(type == EnumPacketClient.DIALOG_DUMMY){
EntityDialogNpc npc = new EntityDialogNpc(player.worldObj);
npc.display.name = Server.readString(buffer);
EntityUtil.Copy(player, npc);
NoppesUtil.openDialog(Server.readNBT(buffer), npc, player);
}
else if(type == EnumPacketClient.QUEST_COMPLETION){
NoppesUtil.guiQuestCompletion(player, Server.readNBT(buffer));
}
@@ -160,12 +154,6 @@ public class PacketHandlerClient extends PacketHandlerServer{
NBTTagCompound compound = Server.readNBT(buffer);
NoppesUtil.openGUI(player, new GuiNpcMobSpawnerAdd(compound));
}
else if(type == EnumPacketClient.CLONER){
int x = buffer.readInt();
int y = buffer.readInt();
int z = buffer.readInt();
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Cloner, player);
}
else if(type == EnumPacketClient.TELEPORTER){
CustomNpcs.proxy.openGui((EntityNPCInterface)null,EnumGuiType.NpcDimensions);
}
@@ -24,10 +24,8 @@ public enum EnumPacketClient {
VILLAGER_LIST,
SYNCRECIPES_CARPENTRYBENCH,
CLONE,
CLONER,
TELEPORTER,
OPEN_BOOK,
DIALOG_DUMMY,
CONFIG,
ISGUIOPEN,
SCRIPT_OVERLAY_DATA,