added camel_sitting property
This commit is contained in:
parent
eead4ced66
commit
e6c00472b5
3 changed files with 37 additions and 2 deletions
|
@ -612,7 +612,9 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
if (!ver.isNewerThanOrEquals(ServerVersion.V_1_20)) return;
|
||||
|
||||
// Camel
|
||||
register(new BooleanProperty("bashing", 18, false, legacyBooleans));
|
||||
int camelIndex = 18;
|
||||
register(new BooleanProperty("bashing", camelIndex++, false, legacyBooleans));
|
||||
register(new CamelSittingProperty(6, camelIndex));
|
||||
|
||||
// Sniffer
|
||||
register(new CustomTypeProperty<>("sniffer_state", 17, SnifferState.IDLING, EntityDataTypes.SNIFFER_STATE, state -> com.github.retrooper.packetevents.protocol.entity.sniffer.SnifferState.valueOf(state.name())));
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package lol.pyr.znpcsplus.entity.properties;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import lol.pyr.znpcsplus.entity.EntityPropertyImpl;
|
||||
import lol.pyr.znpcsplus.entity.PacketEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CamelSittingProperty extends EntityPropertyImpl<Boolean> {
|
||||
private final int poseIndex;
|
||||
private final int lastPoseTickIndex;
|
||||
|
||||
public CamelSittingProperty(int poseIndex, int lastPoseTickIndex) {
|
||||
super("camel_sitting", false, Boolean.class);
|
||||
this.poseIndex = poseIndex;
|
||||
this.lastPoseTickIndex = lastPoseTickIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Player player, PacketEntity entity, boolean isSpawned, Map<Integer, EntityData> properties) {
|
||||
boolean value = entity.getProperty(this);
|
||||
if (value) {
|
||||
properties.put(poseIndex, newEntityData(poseIndex, EntityDataTypes.ENTITY_POSE, EntityPose.SITTING));
|
||||
properties.put(lastPoseTickIndex, newEntityData(lastPoseTickIndex, EntityDataTypes.LONG, -1L));
|
||||
} else {
|
||||
properties.put(poseIndex, newEntityData(poseIndex, EntityDataTypes.ENTITY_POSE, EntityPose.STANDING));
|
||||
properties.put(lastPoseTickIndex, newEntityData(lastPoseTickIndex, EntityDataTypes.LONG, 0L));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -367,7 +367,7 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
|
|||
|
||||
register(builder(p, "camel", EntityTypes.CAMEL)
|
||||
.setHologramOffset(0.25)
|
||||
.addProperties("bashing"));
|
||||
.addProperties("bashing", "camel_sitting"));
|
||||
}
|
||||
|
||||
public Collection<NpcType> getAll() {
|
||||
|
|
Loading…
Reference in a new issue