mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 00:55:38 +00:00
Whoops Forgot to Sync NBTs
This commit is contained in:
1 parent
06809933ed
commit
12c50d5f6a
6 files changed
+128
-11
No files matched your search
@@ -7,6 +7,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.data.EnergyDisplayData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.EnergyLightningData;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -314,12 +315,30 @@ public abstract class EntityEnergyAbility extends Entity implements IEntityAddit
|
||||
|
||||
// ==================== SPAWN DATA ====================
|
||||
|
||||
/**
|
||||
* Write entity data for client sync. Subclasses override this
|
||||
* to serialize their fields. Separate from writeEntityToNBT
|
||||
* which is intentionally empty (entities are transient, not saved to world).
|
||||
*/
|
||||
protected void writeSpawnNBT(NBTTagCompound nbt) {
|
||||
writeEnergyBaseNBT(nbt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read entity data from client sync. Subclasses override this
|
||||
* to deserialize their fields. Separate from readEntityFromNBT
|
||||
* which is intentionally empty (entities are transient, not saved to world).
|
||||
*/
|
||||
protected void readSpawnNBT(NBTTagCompound nbt) {
|
||||
readEnergyBaseNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData(ByteBuf buffer) {
|
||||
try {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
this.writeEntityToNBT(compound);
|
||||
cpw.mods.fml.common.network.ByteBufUtils.writeTag(buffer, compound);
|
||||
this.writeSpawnNBT(compound);
|
||||
ByteBufUtils.writeNBT(buffer, compound);
|
||||
} catch (Exception e) {
|
||||
noppes.npcs.LogWriter.error("Error writing energy ability spawn data", e);
|
||||
}
|
||||
@@ -328,9 +347,9 @@ public abstract class EntityEnergyAbility extends Entity implements IEntityAddit
|
||||
@Override
|
||||
public void readSpawnData(ByteBuf buffer) {
|
||||
try {
|
||||
NBTTagCompound compound = cpw.mods.fml.common.network.ByteBufUtils.readTag(buffer);
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(buffer);
|
||||
if (compound != null) {
|
||||
this.readEntityFromNBT(compound);
|
||||
this.readSpawnNBT(compound);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
noppes.npcs.LogWriter.error("Error reading energy ability spawn data", e);
|
||||
|
||||
Reference in new issue
Block a user