use of de.sanandrew.core.manpack.util.javatuples.Pair in project ClaySoldiersMod by SanAndreasP.
the class EntityClayMan method updateUpgradeEffectRenders.
public void updateUpgradeEffectRenders() {
if (this.worldObj.isRemote) {
for (Byte renderId : SoldierUpgrades.getRegisteredRenderIds()) {
long renderFlag = 1L << (renderId % 64);
int renderStorageDw = (renderId / 64);
long dwValue = this.p_upgradeRenderFlags[renderStorageDw];
ASoldierUpgrade upgrade = SoldierUpgrades.getUpgrade(renderId);
if ((dwValue & renderFlag) == renderFlag) {
if (!this.p_upgrades.containsKey(upgrade)) {
this.p_upgrades.put(upgrade, new SoldierUpgradeInst(upgrade));
}
} else {
this.p_upgrades.remove(upgrade);
}
}
for (byte renderId : SoldierEffects.getRegisteredRenderIds()) {
long renderFlag = 1L << (renderId % 64);
int renderStorageDw = (renderId / 64);
long dwValue = this.p_effectRenderFlags[renderStorageDw];
ASoldierEffect effect = SoldierEffects.getEffect(renderId);
if ((dwValue & renderFlag) == renderFlag) {
if (!this.p_effects.containsKey(effect)) {
SoldierEffectInst effectInst = new SoldierEffectInst(effect);
this.p_effects.put(effect, effectInst);
effect.onConstruct(this, effectInst);
}
} else {
this.p_effects.remove(effect);
}
}
} else {
this.p_upgradeRenderFlags[0] = 0;
this.p_upgradeRenderFlags[1] = 0;
this.p_effectRenderFlags[0] = 0;
this.p_effectRenderFlags[1] = 0;
for (SoldierUpgradeInst upgInst : this.p_upgrades.values()) {
byte renderId = SoldierUpgrades.getRenderId(upgInst.getUpgrade());
if (renderId >= 0) {
long renderFlag = 1L << (renderId % 64);
int renderStorageDw = renderId / 64;
long prevDwValue = p_upgradeRenderFlags[renderStorageDw];
p_upgradeRenderFlags[renderStorageDw] = prevDwValue | renderFlag;
}
}
List<Pair<Byte, NBTTagCompound>> effectNbtToClt = new ArrayList<>();
for (SoldierEffectInst effInst : this.p_effects.values()) {
byte renderId = SoldierEffects.getRenderId(effInst.getEffect());
if (renderId >= 0) {
long renderFlag = 1L << (renderId % 64);
int renderStorageDw = renderId / 64;
long prevDwValue = this.p_effectRenderFlags[renderStorageDw];
this.p_effectRenderFlags[renderStorageDw] = prevDwValue | renderFlag;
if (effInst.getEffect().shouldNbtSyncToClient(this, effInst)) {
effectNbtToClt.add(Pair.with(renderId, effInst.getNbtTag()));
}
}
}
List<Pair<Byte, NBTTagCompound>> upgradeNbtToClt = new ArrayList<>();
for (SoldierUpgradeInst upgInst : this.p_upgrades.values()) {
byte renderId = SoldierUpgrades.getRenderId(upgInst.getUpgrade());
if (renderId >= 0) {
long renderFlag = 1L << (renderId % 64);
int renderStorageDw = renderId / 64;
long prevDwValue = this.p_upgradeRenderFlags[renderStorageDw];
this.p_upgradeRenderFlags[renderStorageDw] = prevDwValue | renderFlag;
if (upgInst.getUpgrade().shouldNbtSyncToClient(this, upgInst)) {
upgradeNbtToClt.add(Pair.with(renderId, upgInst.getNbtTag()));
}
}
}
PacketManager.sendToAllAround(PacketManager.PKG_SOLDIER_RENDERS, this.dimension, this.posX, this.posY, this.posZ, 64.0D, Triplet.with(this.getEntityId(), this.p_upgradeRenderFlags, this.p_effectRenderFlags));
for (Pair<Byte, NBTTagCompound> effNbt : effectNbtToClt) {
PacketManager.sendToAllAround(PacketManager.PKG_SOLDIER_EFFECT_NBT, this.dimension, this.posX, this.posY, this.posZ, 64.0D, Triplet.with(this.getEntityId(), effNbt.getValue0(), effNbt.getValue1()));
}
for (Pair<Byte, NBTTagCompound> upgNbt : upgradeNbtToClt) {
PacketManager.sendToAllAround(PacketManager.PKG_SOLDIER_UPGRADE_NBT, this.dimension, this.posX, this.posY, this.posZ, 64.0D, Triplet.with(this.getEntityId(), upgNbt.getValue0(), upgNbt.getValue1()));
}
}
}
Aggregations