use of net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket in project SpongeCommon by SpongePowered.
the class ServerEntityMixin method impl$createSpoofedPacket.
@Redirect(method = "sendDirtyEntityData", at = @At(value = "NEW", target = "net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket"))
private ClientboundSetEntityDataPacket impl$createSpoofedPacket(int entityId, SynchedEntityData dataManager, boolean p_i46917_3_) {
if (!(this.entity instanceof ServerPlayerBridge && ((ServerPlayerBridge) this.entity).bridge$isHealthScaled())) {
return new ClientboundSetEntityDataPacket(entityId, dataManager, p_i46917_3_);
}
final float scaledHealth = ((ServerPlayerBridge) this.entity).bridge$getInternalScaledHealth();
final Float actualHealth = dataManager.get(LivingEntityAccessor.accessor$DATA_HEALTH_ID());
dataManager.set(LivingEntityAccessor.accessor$DATA_HEALTH_ID(), scaledHealth);
final ClientboundSetEntityDataPacket spoofed = new ClientboundSetEntityDataPacket(entityId, dataManager, p_i46917_3_);
dataManager.set(LivingEntityAccessor.accessor$DATA_HEALTH_ID(), actualHealth);
return spoofed;
}
Aggregations