Implemented using item property
This commit is contained in:
parent
7858cdee8f
commit
1b3e95d445
9 changed files with 36 additions and 1 deletions
|
@ -227,6 +227,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
|||
versions.put(ServerVersion.V_1_8, LazyLoader.of(V1_8MetadataFactory::new));
|
||||
versions.put(ServerVersion.V_1_9, LazyLoader.of(V1_9MetadataFactory::new));
|
||||
versions.put(ServerVersion.V_1_10, LazyLoader.of(V1_10MetadataFactory::new));
|
||||
versions.put(ServerVersion.V_1_11, LazyLoader.of(V1_11MetadataFactory::new));
|
||||
versions.put(ServerVersion.V_1_13, LazyLoader.of(V1_13MetadataFactory::new));
|
||||
versions.put(ServerVersion.V_1_14, LazyLoader.of(V1_14MetadataFactory::new));
|
||||
versions.put(ServerVersion.V_1_16, LazyLoader.of(V1_16MetadataFactory::new));
|
||||
|
|
|
@ -27,6 +27,7 @@ public interface MetadataFactory {
|
|||
EntityData noGravity();
|
||||
EntityData pose(EntityPose pose);
|
||||
EntityData shaking(boolean enabled);
|
||||
EntityData usingItem(boolean enabled, boolean offhand, boolean riptide);
|
||||
EntityData potionColor(int color);
|
||||
EntityData potionAmbient(boolean ambient);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package lol.pyr.znpcsplus.metadata;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
|
||||
public class V1_11MetadataFactory extends V1_10MetadataFactory {
|
||||
@Override
|
||||
public EntityData usingItem(boolean usingItem, boolean offHand, boolean riptide) {
|
||||
return newEntityData(6, EntityDataTypes.BYTE, (byte) ((usingItem ? 0x01 : 0) | (offHand ? 0x02 : 0)));
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ import net.kyori.adventure.text.Component;
|
|||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
public class V1_13MetadataFactory extends V1_10MetadataFactory {
|
||||
public class V1_13MetadataFactory extends V1_11MetadataFactory {
|
||||
@Override
|
||||
public Collection<EntityData> name(Component name) {
|
||||
return list(
|
||||
|
@ -16,4 +16,9 @@ public class V1_13MetadataFactory extends V1_10MetadataFactory {
|
|||
newEntityData(3, EntityDataTypes.BOOLEAN, true)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData usingItem(boolean usingItem, boolean offHand, boolean riptide) {
|
||||
return newEntityData(6, EntityDataTypes.BYTE, (byte) ((usingItem ? 0x01 : 0) | (offHand ? 0x02 : 0) | (riptide ? 0x04 : 0)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,11 @@ public class V1_14MetadataFactory extends V1_13MetadataFactory {
|
|||
return newEntityData(6, EntityDataTypes.ENTITY_POSE, pose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData usingItem(boolean usingItem, boolean offHand, boolean riptide) {
|
||||
return newEntityData(7, EntityDataTypes.BYTE, (byte) ((usingItem ? 0x01 : 0) | (offHand ? 0x02 : 0) | (riptide ? 0x04 : 0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData potionColor(int color) {
|
||||
return newEntityData(9, EntityDataTypes.INT, color);
|
||||
|
|
|
@ -19,6 +19,11 @@ public class V1_17MetadataFactory extends V1_16MetadataFactory {
|
|||
return newEntityData(7, EntityDataTypes.INT, enabled ? 140 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData usingItem(boolean usingItem, boolean offHand, boolean riptide) {
|
||||
return newEntityData(8, EntityDataTypes.BYTE, (byte) ((usingItem ? 0x01 : 0) | (offHand ? 0x02 : 0) | (riptide ? 0x04 : 0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData potionColor(int color) {
|
||||
return newEntityData(10, EntityDataTypes.INT, color);
|
||||
|
|
|
@ -45,6 +45,11 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
|||
throw new UnsupportedOperationException("The shaking entity data isn't supported on this version");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData usingItem(boolean enabled, boolean offHand, boolean riptide) {
|
||||
return newEntityData(0, EntityDataTypes.BYTE, (byte) (enabled ? 0x10 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData potionColor(int color) {
|
||||
return newEntityData(7, EntityDataTypes.INT, color);
|
||||
|
|
|
@ -77,6 +77,7 @@ public class NpcTypeImpl implements NpcType {
|
|||
allowedProperties.add(propertyRegistry.getByName("silent"));
|
||||
allowedProperties.add(propertyRegistry.getByName("look"));
|
||||
allowedProperties.add(propertyRegistry.getByName("skin_cape"));
|
||||
allowedProperties.add(propertyRegistry.getByName("using_item"));
|
||||
allowedProperties.add(propertyRegistry.getByName("potion_color"));
|
||||
allowedProperties.add(propertyRegistry.getByName("potion_ambient"));
|
||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9))
|
||||
|
|
|
@ -143,6 +143,7 @@ public class V1_8PacketFactory implements PacketFactory {
|
|||
false)
|
||||
);
|
||||
add(data, metadataFactory.silent(properties.getProperty(propertyRegistry.getByName("silent", Boolean.class))));
|
||||
add(data, metadataFactory.usingItem(properties.getProperty(propertyRegistry.getByName("using_item", Boolean.class)), false, false));
|
||||
add(data, metadataFactory.potionColor(properties.getProperty(propertyRegistry.getByName("potion_color", PotionColor.class)).getColor()));
|
||||
add(data, metadataFactory.potionAmbient(properties.getProperty(propertyRegistry.getByName("potion_ambient", Boolean.class))));
|
||||
if (properties.hasProperty(propertyRegistry.getByName("name"))) addAll(data, metadataFactory.name(properties.getProperty(propertyRegistry.getByName("name", Component.class))));
|
||||
|
|
Loading…
Reference in a new issue