fix(wrapper): streamline potion effect handling and packet creation
This commit is contained in:
parent
0868a75617
commit
35111c0149
2 changed files with 20 additions and 19 deletions
|
@ -93,9 +93,7 @@ public class WrapperEntity implements Tickable {
|
||||||
|
|
||||||
if (this instanceof WrapperLivingEntity) {
|
if (this instanceof WrapperLivingEntity) {
|
||||||
WrapperLivingEntity wrapperLivingEntity = (WrapperLivingEntity) this;
|
WrapperLivingEntity wrapperLivingEntity = (WrapperLivingEntity) this;
|
||||||
wrapperLivingEntity.createSpawnPackets().forEach(packetWrapper -> {
|
wrapperLivingEntity.createSpawnPackets().forEach(packetWrapper -> sendPacket(uuid, packetWrapper));
|
||||||
sendPacket(uuid, packetWrapper);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
@ -219,9 +217,7 @@ public class WrapperEntity implements Tickable {
|
||||||
|
|
||||||
if (this instanceof WrapperLivingEntity) {
|
if (this instanceof WrapperLivingEntity) {
|
||||||
WrapperLivingEntity wrapperLivingEntity = (WrapperLivingEntity) this;
|
WrapperLivingEntity wrapperLivingEntity = (WrapperLivingEntity) this;
|
||||||
wrapperLivingEntity.createSpawnPackets().forEach(packetWrapper -> {
|
wrapperLivingEntity.createSpawnPackets().forEach(packetWrapper -> sendPacket(uuid, packetWrapper));
|
||||||
sendPacket(uuid, packetWrapper);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,15 +40,11 @@ public class WrapperEntityPotionEffect implements Tickable {
|
||||||
boolean showIcons,
|
boolean showIcons,
|
||||||
@Nullable NBTCompound factorData
|
@Nullable NBTCompound factorData
|
||||||
) {
|
) {
|
||||||
this.effects.put(type, new WrapperPotionEffect(
|
WrapperPotionEffect effect = new WrapperPotionEffect(type, amplifier, duration, ambient, visible, showIcons, factorData);
|
||||||
type,
|
|
||||||
amplifier,
|
this.effects.put(type, effect);
|
||||||
duration,
|
|
||||||
ambient,
|
this.entity.sendPacketToViewers(createEffectPacket(effect));
|
||||||
visible,
|
|
||||||
showIcons,
|
|
||||||
factorData
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,16 +145,25 @@ public class WrapperEntityPotionEffect implements Tickable {
|
||||||
remainingDuration = Math.max(duration - elapsedTicks, 0);
|
remainingDuration = Math.max(duration - elapsedTicks, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
WrapperPlayServerEntityEffect wrapperPlayServerEntityEffect = new WrapperPlayServerEntityEffect(0, null, 0, 0, (byte) 0);
|
int flags = 0;
|
||||||
|
|
||||||
|
flags |= ambient ? 1 : 0; // Bit 0 para ambient
|
||||||
|
flags |= visible ? (1 << 1) : 0; // Bit 1 para visible
|
||||||
|
flags |= icons ? (1 << 2) : 0; // Bit 2 para icons
|
||||||
|
|
||||||
|
WrapperPlayServerEntityEffect wrapperPlayServerEntityEffect = new WrapperPlayServerEntityEffect(
|
||||||
|
0,
|
||||||
|
null,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(byte) flags
|
||||||
|
);
|
||||||
|
|
||||||
wrapperPlayServerEntityEffect.setEntityId(this.entity.getEntityId());
|
wrapperPlayServerEntityEffect.setEntityId(this.entity.getEntityId());
|
||||||
wrapperPlayServerEntityEffect.setPotionType(potionType);
|
wrapperPlayServerEntityEffect.setPotionType(potionType);
|
||||||
wrapperPlayServerEntityEffect.setEffectAmplifier(amplifier);
|
wrapperPlayServerEntityEffect.setEffectAmplifier(amplifier);
|
||||||
wrapperPlayServerEntityEffect.setEffectDurationTicks(remainingDuration);
|
wrapperPlayServerEntityEffect.setEffectDurationTicks(remainingDuration);
|
||||||
wrapperPlayServerEntityEffect.setFactorData(factorData);
|
wrapperPlayServerEntityEffect.setFactorData(factorData);
|
||||||
wrapperPlayServerEntityEffect.setAmbient(ambient);
|
|
||||||
wrapperPlayServerEntityEffect.setVisible(visible);
|
|
||||||
wrapperPlayServerEntityEffect.setShowIcon(icons);
|
|
||||||
|
|
||||||
return wrapperPlayServerEntityEffect;
|
return wrapperPlayServerEntityEffect;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue