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();
@@ -295,7 +295,7 @@ public class NoppesUtilServer {
return;
}
else{
BOB.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
PacketUtil.openGUI((EntityPlayerMP)player, gui, i, j, k);
}
ArrayList<String> list = getScrollData(player, gui, npc);
if(list == null || list.isEmpty())
@@ -317,7 +317,7 @@ public class NoppesUtilServer {
return;
}
else{
BOB.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
PacketUtil.openGUI((EntityPlayerMP)player, gui, i, j, k);
}
ArrayList<String> list = getScrollData(player, gui, npc);
if(list == null || list.isEmpty())
@@ -358,7 +358,7 @@ public class NoppesUtilServer {
}
return null;
}
public static void spawnParticle(Entity entity,String particle,int dimension){
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);
}
@@ -673,7 +673,7 @@ public class NoppesUtilServer {
NBTTagCompound compound = option.writeNBT();
compound.setInteger("Position", pos);
BOB.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_DATA, compound);
PacketUtil.sendGuiData((EntityPlayerMP)player, compound);
}
}
@@ -709,7 +709,7 @@ public class NoppesUtilServer {
public static void setClonerGui(EntityPlayerMP player, int x, int y, int z){
if(player == null)
return;
BOB.sendData(player, EnumPacketClient.CLONER, x, y, z);
PacketUtil.openGUI(player, EnumGuiType.Cloner, x, y, z);
}
public static void setTeleporterGUI(EntityPlayerMP player){
@@ -726,14 +726,13 @@ public class NoppesUtilServer {
ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer;
container.setRecipe(recipe);
BOB.sendData(player, EnumPacketClient.GUI_DATA, recipe.writeNBT());
PacketUtil.sendGuiData((EntityPlayerMP)player, recipe.writeNBT());
}
public static void sendBank(EntityPlayerMP player,Bank bank) {
NBTTagCompound compound = new NBTTagCompound();
bank.writeEntityToNBT(compound);
BOB.sendData(player, EnumPacketClient.GUI_DATA, compound);
PacketUtil.sendGuiData((EntityPlayerMP)player, compound);
if(player.openContainer instanceof ContainerManageBanks){
((ContainerManageBanks)player.openContainer).setBank(bank);
@@ -759,14 +758,14 @@ public class NoppesUtilServer {
}
public static void sendGuiError(EntityPlayer player, int i) {
BOB.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_ERROR, i, new NBTTagCompound());
PacketUtil.errorGUI((EntityPlayerMP)player, i, new NBTTagCompound());
}
public static void sendGuiClose(EntityPlayerMP player, int i, NBTTagCompound comp) {
if(player.openContainer != player.inventoryContainer){
player.openContainer = player.inventoryContainer;
}
BOB.sendData(player, EnumPacketClient.GUI_CLOSE, i, comp);
PacketUtil.closeGUI(player, i, comp);
}
public static Entity spawnCloneWithProtection(NBTTagCompound compound, int x, int y,
@@ -672,7 +672,7 @@ public class PacketHandlerServer{
List<String> list = new ArrayList<String>();
for(LinkedData data : LinkedNpcController.Instance.list)
list.add(data.name);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
PacketUtil.sendList((EntityPlayerMP)player, list);
}
else if(type == EnumPacketServer.LinkedRemove){
LinkedNpcController.Instance.removeData(Server.readString(buffer));
@@ -680,13 +680,13 @@ public class PacketHandlerServer{
List<String> list = new ArrayList<String>();
for(LinkedData data : LinkedNpcController.Instance.list)
list.add(data.name);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
PacketUtil.sendList((EntityPlayerMP)player, list);
}
else if(type == EnumPacketServer.LinkedGetAll){
List<String> list = new ArrayList<String>();
for(LinkedData data : LinkedNpcController.Instance.list)
list.add(data.name);
Server.sendData(player, EnumPacketClient.SCROLL_LIST, list);
PacketUtil.sendList((EntityPlayerMP)player, list);
if(npc != null)
Server.sendData(player, EnumPacketClient.SCROLL_SELECTED, npc.linkedName);
}
@@ -365,7 +365,7 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.RedstoneBlock)
return new GuiNpcRedstoneBlock(x, y, z);
else if(gui == EnumGuiType.MobSpawner)
else if(gui == EnumGuiType.Cloner)
return new GuiNpcMobSpawner(x, y, z);
else if(gui == EnumGuiType.MobSpawnerMounter)
@@ -1,22 +1,17 @@
package noppes.npcs.client;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.achievement.GuiAchievement;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.PacketBuffer;
import net.minecraft.stats.Achievement;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.StatCollector;
import net.minecraft.village.MerchantRecipeList;
import noppes.npcs.*;
import noppes.npcs.client.ClientProxy.FontContainer;
@@ -169,7 +164,7 @@ public class PacketHandlerClient extends PacketHandlerServer{
int x = buffer.readInt();
int y = buffer.readInt();
int z = buffer.readInt();
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.MobSpawner, player);
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Cloner, player);
}
else if(type == EnumPacketClient.TELEPORTER){
CustomNpcs.proxy.openGui((EntityNPCInterface)null,EnumGuiType.NpcDimensions);
@@ -23,7 +23,7 @@ public enum EnumGuiType {
SetupTransporter,
ManageTransport,
ManageBanks,
MobSpawner,
Cloner,
SetupBank,
ManageDialogs,
ManageQuests,