Skip to content

Commit

Permalink
Don't send update attribute packet to non-living npcs
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Oct 22, 2024
1 parent b364fdd commit 70be291
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
import net.minecraft.server.level.ClientInformation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Display;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -282,13 +279,15 @@ public void update(Player player) {

}

Holder.Reference<Attribute> scaleAttribute = BuiltInRegistries.ATTRIBUTE.getHolder(new ResourceLocation("generic.scale")).get();
AttributeInstance attributeInstance = new AttributeInstance(scaleAttribute, (a) -> {
});
attributeInstance.setBaseValue(data.getScale());
if (npc instanceof LivingEntity) {
Holder.Reference<Attribute> scaleAttribute = BuiltInRegistries.ATTRIBUTE.getHolder(new ResourceLocation("generic.scale")).get();
AttributeInstance attributeInstance = new AttributeInstance(scaleAttribute, (a) -> {
});
attributeInstance.setBaseValue(data.getScale());

ClientboundUpdateAttributesPacket updateAttributesPacket = new ClientboundUpdateAttributesPacket(npc.getId(), List.of(attributeInstance));
serverPlayer.connection.send(updateAttributesPacket);
ClientboundUpdateAttributesPacket updateAttributesPacket = new ClientboundUpdateAttributesPacket(npc.getId(), List.of(attributeInstance));
serverPlayer.connection.send(updateAttributesPacket);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import net.minecraft.server.level.ServerEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Display;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -294,13 +291,16 @@ public void update(Player player) {

}

Holder.Reference<Attribute> scaleAttribute = BuiltInRegistries.ATTRIBUTE.getHolder(ResourceLocation.parse("generic.scale")).get();
AttributeInstance attributeInstance = new AttributeInstance(scaleAttribute, (a) -> {
});
attributeInstance.setBaseValue(data.getScale());
if (npc instanceof LivingEntity) {
Holder.Reference<Attribute> scaleAttribute = BuiltInRegistries.ATTRIBUTE.getHolder(ResourceLocation.parse("generic.scale")).get();
AttributeInstance attributeInstance = new AttributeInstance(scaleAttribute, (a) -> {
});
attributeInstance.setBaseValue(data.getScale());

ClientboundUpdateAttributesPacket updateAttributesPacket = new ClientboundUpdateAttributesPacket(npc.getId(), List.of(attributeInstance));
serverPlayer.connection.send(updateAttributesPacket);
ClientboundUpdateAttributesPacket updateAttributesPacket = new ClientboundUpdateAttributesPacket(npc.getId(), List.of(attributeInstance));
serverPlayer.connection.send(updateAttributesPacket);

}
}

@Override
Expand Down

0 comments on commit 70be291

Please sign in to comment.