Still going

This commit is contained in:
Kam committed 2025-01-29 22:56:28 -05:00
1 parent d91d4668d6
commit 4eae773f86
13 files changed
+110 -74

No files matched your search

@@ -11,6 +11,11 @@ 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.large.LargeScrollDataPacket;
import kamkeel.npcs.network.packets.client.large.LargeScrollGroupPacket;
import kamkeel.npcs.network.packets.client.large.LargeScrollListPacket;
@@ -57,6 +62,13 @@ public final class PacketHandler {
CLIENT_PACKET.registerPacket(new ChatBubblePacket());
CLIENT_PACKET.registerPacket(new ChatAlertPacket());
CLIENT_PACKET.registerPacket(new AchievementPacket());
CLIENT_PACKET.registerPacket(new EditNpcPacket());
// Client | GUI Packets
CLIENT_PACKET.registerPacket(new GuiClosePacket());
CLIENT_PACKET.registerPacket(new GuiOpenPacket());
CLIENT_PACKET.registerPacket(new GuiErrorPacket());
CLIENT_PACKET.registerPacket(new GuiDataPacket());
}
private void registerChannels() {
@@ -2,10 +2,16 @@ package kamkeel.npcs.network;
import kamkeel.npcs.network.packets.client.ChatAlertPacket;
import kamkeel.npcs.network.packets.client.AchievementPacket;
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.large.LargeScrollGroupPacket;
import kamkeel.npcs.network.packets.client.large.LargeScrollDataPacket;
import kamkeel.npcs.network.packets.client.large.LargeScrollListPacket;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.constants.EnumGuiType;
import java.util.List;
import java.util.Map;
@@ -36,4 +42,24 @@ public class PacketUtil {
AchievementPacket packet = new AchievementPacket(isParty, description, message);
PacketHandler.Instance.sendToPlayer(packet, playerMP);
}
public static void openGUI(EntityPlayerMP playerMP, EnumGuiType type, int x, int y, int z){
GuiOpenPacket packet = new GuiOpenPacket(type, x, y, z);
PacketHandler.Instance.sendToPlayer(packet, playerMP);
}
public static void closeGUI(EntityPlayerMP playerMP, int closeCode, NBTTagCompound compound){
GuiClosePacket packet = new GuiClosePacket(closeCode, compound);
PacketHandler.Instance.sendToPlayer(packet, playerMP);
}
public static void errorGUI(EntityPlayerMP playerMP, int closeCode, NBTTagCompound compound){
GuiErrorPacket packet = new GuiErrorPacket(closeCode, compound);
PacketHandler.Instance.sendToPlayer(packet, playerMP);
}
public static void sendGuiData(EntityPlayerMP playerMP, NBTTagCompound compound){
GuiDataPacket packet = new GuiDataPacket(compound);
PacketHandler.Instance.sendToPlayer(packet, playerMP);
}
}
@@ -32,7 +32,6 @@ public enum EnumClientPacket {
CHATBUBBLE,
SYNCRECIPES_CARPENTRYBENCH,
CLONE,
CLONER,
TELEPORTER,
OPEN_BOOK,
CONFIG,
@@ -1,41 +0,0 @@
package kamkeel.npcs.network.packets.client.gui;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumClientPacket;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.constants.EnumGuiType;
import java.io.IOException;
public final class ClonerGUIPacket extends AbstractPacket {
public static final String packetName = "Client|Cloner";
public ClonerGUIPacket() {}
@Override
public Enum getType() {
return EnumClientPacket.CLONER;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.CLIENT_PACKET;
}
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
int x = in.readInt();
int y = in.readInt();
int z = in.readInt();
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.MobSpawner, player);
}
}
@@ -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.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
@@ -17,8 +18,16 @@ import java.io.IOException;
public final class GuiClosePacket extends AbstractPacket {
public static final String packetName = "Client|GuiClose";
private int code;
private NBTTagCompound compound;
public GuiClosePacket() {}
public GuiClosePacket(int code, NBTTagCompound compound) {
this.code = code;
this.compound = compound;
}
@Override
public Enum getType() {
return EnumClientPacket.GUI_CLOSE;
@@ -31,7 +40,8 @@ public final class GuiClosePacket extends AbstractPacket {
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
out.writeInt(code);
ByteBufUtils.writeNBT(out, compound);
}
@Override
@@ -39,7 +49,7 @@ public final class GuiClosePacket extends AbstractPacket {
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
if (gui instanceof IGuiClose) {
int closeCode = in.readInt();
NBTTagCompound nbt = Server.readNBT(in);
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
((IGuiClose) gui).setClose(closeCode, nbt);
}
Minecraft.getMinecraft().displayGuiScreen(null);
@@ -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.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
@@ -19,7 +20,13 @@ import java.io.IOException;
public final class GuiDataPacket extends AbstractPacket {
public static final String packetName = "Client|GuiData";
public GuiDataPacket() {}
private NBTTagCompound compound;
public GuiDataPacket(){}
public GuiDataPacket(NBTTagCompound comp){
this.compound = comp;
}
@Override
public Enum getType() {
@@ -33,7 +40,7 @@ public final class GuiDataPacket extends AbstractPacket {
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
ByteBufUtils.writeNBT(out, compound);
}
@Override
@@ -45,7 +52,7 @@ public final class GuiDataPacket extends AbstractPacket {
gui = (GuiScreen) ((GuiContainerNPCInterface) gui).getSubGui();
}
if (gui instanceof IGuiData) {
NBTTagCompound nbt = Server.readNBT(in);
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
((IGuiData) gui).setGuiData(nbt);
}
}
@@ -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.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
@@ -17,8 +18,16 @@ import java.io.IOException;
public final class GuiErrorPacket extends AbstractPacket {
public static final String packetName = "Client|GuiError";
private int code;
private NBTTagCompound compound;
public GuiErrorPacket() {}
public GuiErrorPacket(int code, NBTTagCompound compound) {
this.code = code;
this.compound = compound;
}
@Override
public Enum getType() {
return EnumClientPacket.GUI_ERROR;
@@ -31,7 +40,8 @@ public final class GuiErrorPacket extends AbstractPacket {
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
out.writeInt(code);
ByteBufUtils.writeNBT(out, compound);
}
@Override
@@ -39,7 +49,7 @@ public final class GuiErrorPacket extends AbstractPacket {
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
if (gui instanceof IGuiError) {
int errorCode = in.readInt();
NBTTagCompound nbt = Server.readNBT(in);
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
((IGuiError) gui).setError(errorCode, nbt);
}
}
@@ -1,5 +1,6 @@
package kamkeel.npcs.network.packets.client.gui;
import cpw.mods.fml.relauncher.Side;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
@@ -11,10 +12,22 @@ import noppes.npcs.constants.EnumGuiType;
import java.io.IOException;
public final class GuiPacket extends AbstractPacket {
public static final String packetName = "Client|Gui";
public final class GuiOpenPacket extends AbstractPacket {
public static final String packetName = "Client|OpenGui";
public GuiPacket() {}
private EnumGuiType type;
private int x;
private int y;
private int z;
public GuiOpenPacket() {}
public GuiOpenPacket(EnumGuiType type, int x, int y, int z) {
this.type = type;
this.x = x;
this.y = y;
this.z = z;
}
@Override
public Enum getType() {
@@ -28,11 +41,17 @@ public final class GuiPacket extends AbstractPacket {
@Override
public void sendData(ByteBuf out) throws IOException {
// TODO: Send Packet
out.writeInt(type.ordinal());
out.writeInt(x);
out.writeInt(y);
out.writeInt(z);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if(CustomNpcs.side() != Side.CLIENT)
return;
EnumGuiType gui = EnumGuiType.values()[in.readInt()];
int x = in.readInt();
int y = in.readInt();