Skip to content

Commit

Permalink
Don't set piglin target unless attacking
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ-Ferguson committed May 3, 2024
1 parent 3422e2c commit 6289fb9
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;

import java.util.UUID;
Expand All @@ -41,12 +42,18 @@ public class BasePiglinEntity extends MonsterEntity {
public BasePiglinEntity(GeyserSession session, int entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
// Both TARGET_EID and BLOCK are needed for melee attack animation
dirtyMetadata.put(EntityDataTypes.TARGET_EID, session.getPlayerEntity().getGeyserId());
if (definition.entityType() == EntityType.PIGLIN_BRUTE) {
dirtyMetadata.put(EntityDataTypes.BLOCK, session.getBlockMappings().getDefinition(1));
}
}

@Override
public void setMobFlags(ByteEntityMetadata entityMetadata) {
super.setMobFlags(entityMetadata);
byte xd = entityMetadata.getPrimitiveValue();
dirtyMetadata.put(EntityDataTypes.TARGET_EID, (xd & 4) == 4 ? session.getPlayerEntity().getGeyserId() : 0);
}

public void setImmuneToZombification(BooleanEntityMetadata entityMetadata) {
// Apply shaking effect if not in the nether and zombification is possible
this.isImmuneToZombification = entityMetadata.getPrimitiveValue();
Expand Down

0 comments on commit 6289fb9

Please sign in to comment.