mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 21:05:06 +00:00
Fix Packets for Effects + Syncing
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user