Magic GUI WIP Push

This commit is contained in:
Kam committed 2025-03-03 05:13:07 -05:00
1 parent 758485b4d0
commit 58ff772e3c
18 files changed
+1002 -81

No files matched your search

@@ -44,6 +44,7 @@ import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
import kamkeel.npcs.network.packets.request.jobs.JobSpawnerAddPacket;
import kamkeel.npcs.network.packets.request.jobs.JobSpawnerRemovePacket;
import kamkeel.npcs.network.packets.request.linked.*;
import kamkeel.npcs.network.packets.request.magic.*;
import kamkeel.npcs.network.packets.request.mainmenu.*;
import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnGetAllPacket;
import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnGetPacket;
@@ -334,6 +335,13 @@ public class PacketHandler {
REQUEST_PACKET.registerPacket(new ProfileRenamePacket());
REQUEST_PACKET.registerPacket(new ProfileChangePacket());
// Job Packets
REQUEST_PACKET.registerPacket(new MagicCycleRemovePacket());
REQUEST_PACKET.registerPacket(new MagicCycleSavePacket());
REQUEST_PACKET.registerPacket(new MagicGetAllPacket());
REQUEST_PACKET.registerPacket(new MagicSavePacket());
REQUEST_PACKET.registerPacket(new MagicRemovePacket());
// Other Packets
REQUEST_PACKET.registerPacket(new IsGuiOpenInform());
REQUEST_PACKET.registerPacket(new GuiRequestPacket());
@@ -195,5 +195,5 @@ public enum EnumRequestPacket {
ProfileCreate,
ProfileRemove,
ProfileRename,
ProfileChange
MagicCycleRemove, MagicCycleSave, MagicGetAll, MagicRemove, MagicSave, ProfileChange
}
@@ -0,0 +1,52 @@
package kamkeel.npcs.network.packets.request.magic;
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.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import noppes.npcs.controllers.MagicController;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import java.io.IOException;
public class MagicCycleRemovePacket extends AbstractPacket {
public static String packetName = "Request|MagicCycleRemove";
private int cycleId;
public MagicCycleRemovePacket() { }
public MagicCycleRemovePacket(int cycleId) {
this.cycleId = cycleId;
}
@Override
public Enum getType() {
return EnumRequestPacket.MagicCycleRemove;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(cycleId);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
int id = in.readInt();
MagicController.getInstance().cycles.remove(id);
MagicController.getInstance().saveMagicData();
}
}
@@ -0,0 +1,56 @@
package kamkeel.npcs.network.packets.request.magic;
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.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.util.ByteBufUtils;
import noppes.npcs.controllers.MagicController;
import noppes.npcs.controllers.data.MagicCycle;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import java.io.IOException;
public class MagicCycleSavePacket extends AbstractPacket {
public static String packetName = "Request|MagicCycleSave";
private NBTTagCompound compound;
public MagicCycleSavePacket() { }
public MagicCycleSavePacket(NBTTagCompound compound) {
this.compound = compound;
}
@Override
public Enum getType() {
return EnumRequestPacket.MagicCycleSave;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
ByteBufUtils.writeNBT(out, compound);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
NBTTagCompound comp = ByteBufUtils.readNBT(in);
MagicCycle cycle = new MagicCycle();
cycle.readNBT(comp);
MagicController.getInstance().cycles.put(cycle.id, cycle);
MagicController.getInstance().saveMagicData();
}
}
@@ -0,0 +1,58 @@
package kamkeel.npcs.network.packets.request.magic;
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.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
import noppes.npcs.controllers.MagicController;
import noppes.npcs.controllers.data.Magic;
import noppes.npcs.controllers.data.MagicCycle;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import java.io.IOException;
public class MagicGetAllPacket extends AbstractPacket {
public static String packetName = "Request|MagicGetAll";
public MagicGetAllPacket() { }
@Override
public Enum getType() {
return EnumRequestPacket.MagicGetAll;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
NBTTagCompound compound = new NBTTagCompound();
StringBuilder cycleNames = new StringBuilder();
for (MagicCycle cycle : MagicController.getInstance().cycles.values()) {
cycleNames.append(cycle.title).append(",");
}
compound.setString("CycleNames", cycleNames.toString());
// Build comma-separated list of magic names.
StringBuilder magicNames = new StringBuilder();
for (Magic magic : MagicController.getInstance().magics.values()) {
magicNames.append(magic.name).append(",");
}
compound.setString("MagicNames", magicNames.toString());
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
}
}
@@ -0,0 +1,52 @@
package kamkeel.npcs.network.packets.request.magic;
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.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import noppes.npcs.controllers.MagicController;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import java.io.IOException;
public class MagicRemovePacket extends AbstractPacket {
public static String packetName = "Request|MagicRemove";
private int magicId;
public MagicRemovePacket() { }
public MagicRemovePacket(int magicId) {
this.magicId = magicId;
}
@Override
public Enum getType() {
return EnumRequestPacket.MagicRemove;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(magicId);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
int id = in.readInt();
MagicController.getInstance().magics.remove(id);
MagicController.getInstance().saveMagicData();
}
}
@@ -0,0 +1,56 @@
package kamkeel.npcs.network.packets.request.magic;
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.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.util.ByteBufUtils;
import noppes.npcs.controllers.MagicController;
import noppes.npcs.controllers.data.Magic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import java.io.IOException;
public class MagicSavePacket extends AbstractPacket {
public static String packetName = "Request|MagicSave";
private NBTTagCompound compound;
public MagicSavePacket() { }
public MagicSavePacket(NBTTagCompound compound) {
this.compound = compound;
}
@Override
public Enum getType() {
return EnumRequestPacket.MagicSave;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
ByteBufUtils.writeNBT(out, compound);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
NBTTagCompound comp = ByteBufUtils.readNBT(in);
Magic magic = new Magic();
magic.readNBT(comp);
MagicController.getInstance().saveMagic(magic);
}
}