remove atrributes, rework item modifiers

This commit is contained in:
Sen 2025-06-15 20:21:08 +02:00
parent 339a7679f7
commit fcc5e9b640
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
62 changed files with 482 additions and 1588 deletions

View file

@ -1003,7 +1003,7 @@ public class Client implements IThreadListener {
int absorb = entity.getAbsorptionAmount();
int armor = entity.getTotalArmorValue();
int stats = 1 + (absorb > 0 ? 1 : 0) + (armor > 0 ? 1 : 0) + (entity.vehicle instanceof EntityLiving ? 1 : 0)
+ (entity instanceof EntityNPC && ((EntityNPC)entity).canUseMagic() ? 1 : 0);
+ (entity instanceof EntityNPC npc && npc.getManaPoints() > 0 ? 1 : 0);
for(Energy energy : Energy.values()) {
if(entity.getEnergy(energy) > 0)
stats += 1;
@ -1023,9 +1023,9 @@ public class Client implements IThreadListener {
int vhMax = living.getMaxHealth();
y = stats(x, y, living.getDisplayName() /* + " (Reittier)" */, vh, vhMax, 0xff6060);
}
if(entity instanceof EntityNPC && ((EntityNPC)entity).canUseMagic()) {
int mana = entity.getManaPoints();
int maxm = entity.getMaxMana();
if(entity instanceof EntityNPC npc && npc.getManaPoints() > 0) {
int mana = npc.getManaPoints();
int maxm = npc.getMaxMana();
y = stats(x, y, TextColor.CYAN + "Mana", mana, maxm, 0x0000ff);
}
for(int z = 0; z < Energy.values().length; z++) {

View file

@ -26,10 +26,6 @@ import client.renderer.texture.EntityTexManager;
import client.util.PlayerController;
import client.world.ChunkClient;
import client.world.WorldClient;
import common.attributes.Attribute;
import common.attributes.AttributeInstance;
import common.attributes.AttributeMap;
import common.attributes.AttributeModifier;
import common.block.Block;
import common.block.tech.BlockWorkbench;
import common.dimension.Dimension;
@ -68,7 +64,6 @@ import common.packet.SPacketEntityAttach;
import common.packet.SPacketEntityMetadata;
import common.packet.SPacketEntityEffect;
import common.packet.SPacketRemoveEntityEffect;
import common.packet.SPacketEntityProperties;
import common.packet.SPacketExplosion;
import common.packet.SPacketEffect;
import common.packet.SPacketSoundEffect;
@ -1874,42 +1869,6 @@ public class ClientPlayer implements IClientPlayer
}
}
/**
* Updates en entity's attributes and their respective modifiers, which are used for speed bonusses (player
* sprinting, animals fleeing, baby speed), weapon/tool attackDamage, hostiles followRange randomization, zombie
* maxHealth and knockback resistance as well as reinforcement spawning chance.
*/
public void handleEntityProperties(SPacketEntityProperties packetIn)
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
Entity entity = this.world.getEntityByID(packetIn.getEntityId());
if (entity != null)
{
if (!(entity instanceof EntityLiving living))
throw new IllegalStateException("Server tried to update attributes of a non-living entity (actually: " + entity + ")");
AttributeMap baseattributemap = living.getAttributeMap();
for (SPacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d())
{
AttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a());
if (iattributeinstance == null)
{
iattributeinstance = baseattributemap.registerAttribute(Attribute.getAttribute(s20packetentityproperties$snapshot.func_151409_a()));
}
iattributeinstance.setBaseValue(s20packetentityproperties$snapshot.func_151410_b());
iattributeinstance.removeAllModifiers();
for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c())
{
iattributeinstance.applyModifier(attributemodifier);
}
}
}
}
public void handleSkin(SPacketSkin packetIn) {
NetHandler.checkThread(packetIn, this, this.gm, this.world);