Fix Packets for Effects + Syncing

This commit is contained in:
Kam committed 2025-02-10 16:38:50 -05:00
1 parent 070e032907
commit d2c7e634ec
18 files changed
+502 -41

No files matched your search

@@ -11,10 +11,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.controllers.DialogController;
import noppes.npcs.controllers.FactionController;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.*;
import noppes.npcs.controllers.data.*;
import java.util.HashMap;
@@ -69,6 +66,13 @@ public class SyncController {
anvilNBT()
), player);
PacketHandler.Instance.sendToPlayer(new SyncPacket(
EnumSyncType.CUSTOM_EFFECTS,
EnumSyncAction.RELOAD,
-1,
customEffectsNBT()
), player);
DBCAddon.instance.syncPlayer(player);
syncPlayerData(player, false);
}
@@ -154,6 +158,16 @@ public class SyncController {
return compound;
}
public static NBTTagCompound customEffectsNBT(){
NBTTagList list = new NBTTagList();
NBTTagCompound compound = new NBTTagCompound();
for (CustomEffect effect : StatusEffectController.getInstance().customEffects.values()) {
list.appendTag(effect.writeToNBT(false));
}
compound.setTag("Data", list);
return compound;
}
public static void syncPlayerData(EntityPlayerMP player, boolean update){
PlayerData data = PlayerData.get(player);
if(data != null){
@@ -228,6 +242,15 @@ public class SyncController {
));
}
public static void syncAllCustomEffects() {
PacketHandler.Instance.sendToAll(new SyncPacket(
EnumSyncType.CUSTOM_EFFECTS,
EnumSyncAction.RELOAD,
-1,
customEffectsNBT()
));
}
@SideOnly(Side.CLIENT)
public static void clientSync(EnumSyncType enumSyncType, NBTTagCompound fullCompound) {
switch (enumSyncType){
@@ -367,6 +390,18 @@ public class SyncController {
RecipeController.syncAnvilRecipes = new HashMap<Integer, RecipeAnvil>();
break;
}
case CUSTOM_EFFECTS: {
NBTTagList list = fullCompound.getTagList("Data", 10);
for (int i = 0; i < list.tagCount(); i++) {
CustomEffect effect = new CustomEffect();
effect.readFromNBT(list.getCompoundTagAt(i));
StatusEffectController.getInstance().customEffectsSync.put(effect.id, effect);
}
StatusEffectController.getInstance().customEffects = StatusEffectController.getInstance().customEffectsSync;
StatusEffectController.getInstance().customEffectsSync = new HashMap<>();
break;
}
}
}
@@ -440,6 +475,14 @@ public class SyncController {
ClientCacheHandler.playerData.setSyncNBT(compound);
break;
}
case CUSTOM_EFFECTS: {
CustomEffect effect = new CustomEffect();
effect.readFromNBT(compound);
ClientCacheHandler.getImageData(effect.icon);
StatusEffectController.Instance.customEffects.put(effect.id, effect);
break;
}
}
}
@@ -509,6 +552,9 @@ public class SyncController {
break;
case MAGIC:
break;
case CUSTOM_EFFECTS:
StatusEffectController.Instance.customEffects.remove(id);
break;
}
}
}
@@ -121,6 +121,7 @@ public class PacketHandler {
REQUEST_PACKET.registerPacket(new NPCScriptPacket());
REQUEST_PACKET.registerPacket(new PlayerScriptPacket());
REQUEST_PACKET.registerPacket(new ScriptInfoPacket());
REQUEST_PACKET.registerPacket(new EffectScriptPacket());
// Cloner Packets
REQUEST_PACKET.registerPacket(new CloneListPacket());
@@ -168,6 +168,13 @@ public enum EnumRequestPacket {
BlockScript,
NPCScript,
ScriptInfo,
EffectScript,
DimensionTeleport
DimensionTeleport,
EffectList,
EffectGet,
EffectScriptGet,
EffectRemove,
EffectSave,
}
@@ -11,4 +11,5 @@ public enum EnumSyncType {
WORKBENCH_RECIPES,
CARPENTRY_RECIPES,
ANVIL_RECIPES,
CUSTOM_EFFECTS
}
@@ -0,0 +1,56 @@
package kamkeel.npcs.network.packets.request.effects;
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 net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.controllers.StatusEffectController;
import noppes.npcs.controllers.data.CustomEffect;
import java.io.IOException;
public final class EffectGetPacket extends AbstractPacket {
public static final String packetName = "NPC|GetEffect";
private int effectID;
public EffectGetPacket(int EffectID) {
this.effectID = EffectID;
}
public EffectGetPacket() {
}
@Override
public Enum getType() {
return EnumRequestPacket.EffectGet;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(this.effectID);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
effectID = in.readInt();
NBTTagCompound compound = new NBTTagCompound();
if (effectID != -1 && StatusEffectController.getInstance().has(effectID)) {
CustomEffect Effect = (CustomEffect) StatusEffectController.getInstance().get(effectID);
if (Effect != null) {
compound = Effect.writeToNBT(false);
compound.setString("Type", "ViewEffect");
}
}
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
}
}
@@ -0,0 +1,52 @@
package kamkeel.npcs.network.packets.request.effects;
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 net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.StatusEffectController;
import noppes.npcs.controllers.data.CustomEffect;
import java.io.IOException;
public class EffectRemovePacket extends AbstractPacket {
public static final String packetName = "NPC|EffectRemove";
private int effectID;
public EffectRemovePacket(int outlineID) {
this.effectID = outlineID;
}
public EffectRemovePacket() {}
@Override
public Enum getType() {
return EnumRequestPacket.EffectRemove;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(this.effectID);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
effectID = in.readInt();
StatusEffectController.getInstance().delete(effectID);
NoppesUtilServer.sendCustomEffectDataAll((EntityPlayerMP) player);
NBTTagCompound compound = (new CustomEffect()).writeToNBT(false);
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
}
}
@@ -0,0 +1,62 @@
package kamkeel.npcs.network.packets.request.effects;
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 net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.StatusEffectController;
import noppes.npcs.controllers.data.CustomEffect;
import java.io.IOException;
public class EffectSavePacket extends AbstractPacket {
public static final String packetName = "NPC|EffectSave";
private String prevName;
private NBTTagCompound effectCompound;
public EffectSavePacket(NBTTagCompound compound, String prev){
this.effectCompound = compound;
this.prevName = prev;
}
public EffectSavePacket() {}
@Override
public Enum getType() {
return EnumRequestPacket.EffectSave;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@Override
public void sendData(ByteBuf out) throws IOException {
ByteBufUtils.writeString(out, prevName);
ByteBufUtils.writeNBT(out, effectCompound);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
String prevName = ByteBufUtils.readString(in);
CustomEffect effect = new CustomEffect();
effect.readFromNBT(ByteBufUtils.readNBT(in));
StatusEffectController.getInstance().saveEffect(effect);
if(!prevName.isEmpty() && !prevName.equals(effect.name)){
StatusEffectController.getInstance().deleteEffectFile(prevName);
}
NoppesUtilServer.sendCustomEffectDataAll((EntityPlayerMP) player);
}
}
@@ -0,0 +1,58 @@
package kamkeel.npcs.network.packets.request.effects;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import kamkeel.npcs.network.LargeAbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.script.GuiScriptEffect;
import java.io.IOException;
public class EffectScriptGetPacket extends LargeAbstractPacket {
public static final String packetName = "NPC|EffectScriptGetPacket";
private NBTTagCompound compound;
public EffectScriptGetPacket() {}
public EffectScriptGetPacket(NBTTagCompound compound) {
this.compound = compound;
}
@Override
public Enum getType() {
return EnumRequestPacket.EffectScriptGet;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@Override
protected byte[] getData() throws IOException {
ByteBuf byteBuf = Unpooled.buffer();
ByteBufUtils.writeNBT(byteBuf, compound);
return byteBuf.array();
}
@SideOnly(Side.CLIENT)
@Override
protected void handleCompleteData(ByteBuf data, EntityPlayer player) throws IOException {
NBTTagCompound scriptData = ByteBufUtils.readNBT(data);
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
if (screen instanceof GuiScriptEffect) {
GuiScriptEffect scriptGui = (GuiScriptEffect) screen;
scriptGui.setGuiData(scriptData);
}
}
}
@@ -0,0 +1,58 @@
package kamkeel.npcs.network.packets.request.effects;
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 net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.StatusEffectController;
import noppes.npcs.controllers.data.CustomEffect;
import java.io.IOException;
public final class EffectsGetPacket extends AbstractPacket {
public static final String packetName = "NPC|EffectsGetPacket";
private int effectID;
public EffectsGetPacket(int outlineID) {
this.effectID = outlineID;
}
public EffectsGetPacket() {}
@Override
public Enum getType() {
return EnumRequestPacket.EffectList;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(this.effectID);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
this.effectID = in.readInt();
if (effectID != -1) {
CustomEffect effect = (CustomEffect) StatusEffectController.getInstance().get(effectID);
if (effect != null) {
NBTTagCompound compound = effect.writeToNBT(false);
compound.setString("PACKETTYPE", "Effect");
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
}
} else {
NoppesUtilServer.sendCustomEffectDataAll((EntityPlayerMP) player);
}
}
}
@@ -0,0 +1,109 @@
package kamkeel.npcs.network.packets.request.script;
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.*;
import kamkeel.npcs.network.enums.EnumItemPacketType;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.LogWriter;
import noppes.npcs.config.ConfigDebug;
import noppes.npcs.config.ConfigScript;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.StatusEffectController;
import noppes.npcs.controllers.data.CustomEffect;
import noppes.npcs.controllers.data.EffectScriptHandler;
import noppes.npcs.controllers.data.IScriptHandler;
import noppes.npcs.controllers.data.PlayerDataScript;
import java.io.IOException;
public final class EffectScriptPacket extends AbstractPacket {
public static String packetName = "Request|EffectScript";
private EffectScriptPacket.Action type;
private int id;
private int page;
private int maxSize;
private NBTTagCompound compound;
public EffectScriptPacket() {}
public EffectScriptPacket(Action type, int id, int page, int maxSize, NBTTagCompound compound) {
this.type = type;
this.id = id;
this.page = page;
this.maxSize = maxSize;
this.compound = compound;
}
@Override
public Enum getType() {
return EnumRequestPacket.EffectScript;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@Override
public CustomNpcsPermissions.Permission getPermission(){
return CustomNpcsPermissions.SCRIPT_PLAYER;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(type.ordinal());
out.writeInt(type.ordinal());
if(type == Action.SAVE){
out.writeInt(this.page);
out.writeInt(this.maxSize);
ByteBufUtils.writeNBT(out, this.compound);
}
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT))
return;
Action requestedAction = Action.values()[in.readInt()];
CustomEffect effect = StatusEffectController.getInstance().get(in.readInt());
if(effect == null)
return;
EffectScriptHandler data = effect.getOrCreateScriptHandler();
if(requestedAction == Action.GET){
PacketUtil.getScripts((IScriptHandler) data, (EntityPlayerMP) player);
} else {
data.saveScript(in);
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s SAVED EFFECT %s [%s]", "EFFECT SCRIPTS", player.getCommandSenderName(), effect.getName()));
}
}
}
public static void Save(int effectID, int id, int maxSize, NBTTagCompound compound) {
PacketClient.sendClient(new EffectScriptPacket(Action.SAVE, effectID, id, maxSize, compound));
}
public static void Get(int effectID) {
PacketClient.sendClient(new EffectScriptPacket(Action.GET, effectID, -1, -1, new NBTTagCompound()));
}
private enum Action {
GET,
SAVE
}
}
@@ -7,6 +7,7 @@ import kamkeel.npcs.network.packets.data.gui.GuiClosePacket;
import kamkeel.npcs.network.packets.data.gui.GuiErrorPacket;
import kamkeel.npcs.network.packets.data.gui.GuiOpenPacket;
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
import kamkeel.npcs.network.packets.data.large.ScrollDataPacket;
import kamkeel.npcs.network.packets.data.large.ScrollListPacket;
import kamkeel.npcs.network.packets.data.npc.DialogPacket;
import kamkeel.npcs.network.packets.data.ParticlePacket;
@@ -655,6 +656,14 @@ public class NoppesUtilServer {
sendScrollGroup(player, map);
}
public static void sendCustomEffectDataAll(EntityPlayerMP player) {
Map<String, Integer> map = new HashMap<String, Integer>();
for (CustomEffect effect : StatusEffectController.getInstance().customEffects.values()) {
map.put(effect.name, effect.id);
}
ScrollDataPacket.sendScrollData(player, map);
}
public static void sendTransportCategoryData(EntityPlayerMP player) {
HashMap<String,Integer> map = new HashMap<String,Integer>();
for(TransportCategory category : TransportController.getInstance().categories.values()){
@@ -289,6 +289,9 @@ public class ClientProxy extends CommonProxy {
else if (gui == EnumGuiType.ManageBanks)
return new GuiNPCManageBanks(npc, (ContainerManageBanks) container);
else if (gui == EnumGuiType.ManageEffects)
return new GuiNPCManageEffects(npc);
else if (gui == EnumGuiType.MainMenuGlobal)
return new GuiNPCGlobalMainMenu(npc);
@@ -1,5 +1,7 @@
package noppes.npcs.client.gui;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.effects.EffectSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
@@ -193,8 +195,7 @@ public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldLi
return;
}
if (id == -2) {
// TODO: FIX PACKET
// DBCPacketHandler.Instance.sendToServer(new DBCSaveEffect(effect.writeToNBT(false), originalName));
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), originalName));
GuiScriptEffect scriptGUI = new GuiScriptEffect(parent, effect);
scriptGUI.setWorldAndResolution(mc, width, height);
scriptGUI.initGui();
@@ -249,7 +250,6 @@ public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldLi
@Override
public void close() {
super.close();
// TODO: FIX Packet
// DBCPacketHandler.Instance.sendToServer(new DBCSaveEffect(effect.writeToNBT(false), originalName));
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), originalName));
}
}
@@ -1,5 +1,10 @@
package noppes.npcs.client.gui.global;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.effects.EffectGetPacket;
import kamkeel.npcs.network.packets.request.effects.EffectRemovePacket;
import kamkeel.npcs.network.packets.request.effects.EffectSavePacket;
import kamkeel.npcs.network.packets.request.effects.EffectsGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
@@ -35,8 +40,7 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro
public GuiNPCManageEffects(EntityNPCInterface npc) {
super(npc);
// TODO: Fix Packet
// DBCPacketHandler.Instance.sendToServer(new DBCRequestEffect(-1));
PacketClient.sendClient(new EffectsGetPacket(-1));
}
public void initGui() {
@@ -77,9 +81,7 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro
while (data.containsKey(name))
name += "_";
CustomEffect effect = new CustomEffect(-1, name);
// TODO: Fix Packet
// DBCPacketHandler.Instance.sendToServer(new DBCSaveEffect(effect.writeToNBT(false), ""));
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), ""));
} else if (button.id == 1) {
if (data.containsKey(scrollEffects.getSelected())) {
GuiYesNo guiyesno = new GuiYesNo(this, scrollEffects.getSelected(), StatCollector.translateToLocal("gui.delete"), 1);
@@ -89,8 +91,7 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro
CustomEffect effect = this.effect.cloneEffect();
while (data.containsKey(effect.name))
effect.name += "_";
// TODO: Fix Packet
// DBCPacketHandler.Instance.sendToServer(new DBCSaveEffect(effect.writeToNBT(false), ""));
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), ""));
}
if (effect == null)
@@ -110,13 +111,9 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro
this.effect = new CustomEffect();
effect.readFromNBT(compound);
setSelected(effect.name);
if (effect.id != -1) {
StatusEffectController.getInstance().customEffects.replace(effect.id, effect);
}
initGui();
}
@@ -248,8 +245,7 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro
selected = scrollEffects.getSelected();
originalName = scrollEffects.getSelected();
if (selected != null && !selected.isEmpty()) {
// TODO: Fix Packet
// DBCPacketHandler.Instance.sendToServer(new DBCGetEffect(data.get(selected)));
PacketClient.sendClient(new EffectGetPacket(data.get(selected)));
}
}
}
@@ -262,9 +258,7 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro
@Override
public void save() {
if (this.selected != null && this.data.containsKey(this.selected) && this.effect != null) {
// TODO: Fix Packet
// DBCPacketHandler.Instance.sendToServer(new DBCSaveEffect(effect.writeToNBT(false), originalName));
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), originalName));
}
}
@@ -281,9 +275,7 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro
return;
if (id == 1) {
if (data.containsKey(scrollEffects.getSelected())) {
// TODO: Fix Packet
// DBCPacketHandler.Instance.sendToServer(new DBCRemoveEffect(data.get(scrollEffects.getSelected())));
PacketClient.sendClient(new EffectRemovePacket(data.get(scrollEffects.getSelected())));
scrollEffects.clear();
effect = new CustomEffect();
initGui();
@@ -36,6 +36,7 @@ public class GuiNPCGlobalMainMenu extends GuiNPCInterface2 {
private GuiNpcSquareButton linkedButton;
private GuiNpcSquareButton animationButton;
private GuiNpcSquareButton tagButton;
private GuiNpcSquareButton effectsButton;
public GuiNPCGlobalMainMenu(EntityNPCInterface npc) {
super(npc, 5);
@@ -86,6 +87,9 @@ public class GuiNPCGlobalMainMenu extends GuiNPCInterface2 {
registerButton(tagButton = new GuiNpcSquareButton(17, 0, 0, 20, "menu.tags", 0xFF333333));
tagButton.setIconPos(24, 24, 192, 32).setIconTexture(specialIcons);
registerButton(effectsButton = new GuiNpcSquareButton(19, 0, 0, 20, "global.customeffects", 0xFF333333));
effectsButton.setIconPos(24, 24, 192, 32).setIconTexture(specialIcons);
// Layout composite buttons optimally.
layoutButtons();
// Add all composite buttons to the GUI.
@@ -221,6 +225,9 @@ public class GuiNPCGlobalMainMenu extends GuiNPCInterface2 {
if (id == 16) {
NoppesUtil.requestOpenGUI(EnumGuiType.ManageLinked);
}
if (id == 19) {
NoppesUtil.requestOpenGUI(EnumGuiType.ManageEffects);
}
}
@Override
@@ -1,5 +1,8 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.effects.EffectScriptGetPacket;
import kamkeel.npcs.network.packets.request.script.EffectScriptPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiYesNo;
@@ -46,8 +49,7 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
this.hookList.add(type.function);
}
// TODO: FIX PACKET
// DBCPacketClient.sendClient(new DBCRequestEffectScript(effect.id));
EffectScriptPacket.Get(effect.id);
}
public void initGui() {
@@ -365,16 +367,14 @@ public class GuiScriptEffect extends GuiNPCInterface implements GuiYesNoCallback
List<ScriptContainer> containers = this.scriptHandler.getScripts();
for (int i = 0; i < containers.size(); i++) {
ScriptContainer container = containers.get(i);
// TODO: FIX PACKET
// DBCSaveEffectScript.Save(effect.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
EffectScriptPacket.Save(effect.id, i, containers.size(), container.writeToNBT(new NBTTagCompound()));
}
NBTTagCompound scriptData = new NBTTagCompound();
scriptData.setString("ScriptLanguage", this.scriptHandler.getLanguage());
scriptData.setBoolean("ScriptEnabled", this.scriptHandler.getEnabled());
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.scriptHandler.getConsoleText()));
// TODO: FIX PACKET
// DBCSaveEffectScript.Save(effect.id, -1, containers.size(), scriptData);
EffectScriptPacket.Save(effect.id, -1, containers.size(), scriptData);
}
public void textUpdate(String text) {
@@ -37,6 +37,7 @@ public enum EnumGuiType {
PlayerAnvil,
QuestReward,
ManageRecipes,
ManageEffects,
QuestItem,
NpcRemote,
GlobalRemote,
@@ -1,5 +1,8 @@
package noppes.npcs.controllers;
import kamkeel.npcs.controllers.SyncController;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.enums.EnumSyncType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools;
@@ -132,8 +135,7 @@ public class StatusEffectController implements IStatusEffectHandler {
if (file.getName().equals(foundEffect.name + ".json")) {
file.delete();
// TODO: Fix Packets
// DBCPacketHandler.Instance.sendToAll(new DBCInfoSyncPacket(DBCSyncType.CUSTOM_EFFECT, EnumSyncAction.REMOVE, foundEffect.getID(), new NBTTagCompound()));
SyncController.syncRemove(EnumSyncType.CUSTOM_EFFECTS, foundEffect.getID());
break;
}
}
@@ -154,9 +156,7 @@ public class StatusEffectController implements IStatusEffectHandler {
continue;
if (file.getName().equals(foundEffect.name + ".json")) {
file.delete();
// TODO: Fix Packets
// DBCPacketHandler.Instance.sendToAll(new DBCInfoSyncPacket(DBCSyncType.CUSTOM_EFFECT, EnumSyncAction.REMOVE, foundEffect.getID(), new NBTTagCompound()));
SyncController.syncRemove(EnumSyncType.CUSTOM_EFFECTS, foundEffect.getID());
break;
}
}
@@ -338,8 +338,7 @@ public class StatusEffectController implements IStatusEffectHandler {
file2.delete();
file.renameTo(file2);
nbtTagCompound.removeTag("ScriptData");
// TODO: Add Packets
// DBCPacketHandler.Instance.sendToAll(new DBCInfoSyncPacket(DBCSyncType.CUSTOM_EFFECT, EnumSyncAction.UPDATE, -1, nbtTagCompound));
SyncController.syncUpdate(EnumSyncType.CUSTOM_EFFECTS, -1, nbtTagCompound);
} catch (Exception e) {
LogWriter.except(e);
}