Implemented Creeper Properties
This commit is contained in:
parent
2d7f573d7d
commit
ec1d4445e3
13 changed files with 103 additions and 9 deletions
16
api/src/main/java/lol/pyr/znpcsplus/util/CreeperState.java
Normal file
16
api/src/main/java/lol/pyr/znpcsplus/util/CreeperState.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package lol.pyr.znpcsplus.util;
|
||||
|
||||
public enum CreeperState {
|
||||
IDLE(-1),
|
||||
FUSE(1);
|
||||
|
||||
private final int state;
|
||||
|
||||
CreeperState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
|
@ -281,6 +281,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
|||
registerEnumParser(manager, NpcPose.class, incorrectUsageMessage);
|
||||
registerEnumParser(manager, DyeColor.class, incorrectUsageMessage);
|
||||
registerEnumParser(manager, CatVariant.class, incorrectUsageMessage);
|
||||
registerEnumParser(manager, CreeperState.class, incorrectUsageMessage);
|
||||
|
||||
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
|
||||
.addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry))
|
||||
|
|
|
@ -11,6 +11,7 @@ import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
|||
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||
import lol.pyr.znpcsplus.util.CatVariant;
|
||||
import lol.pyr.znpcsplus.util.CreeperState;
|
||||
import lol.pyr.znpcsplus.util.NpcPose;
|
||||
import lol.pyr.znpcsplus.util.Vector3f;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -84,6 +85,7 @@ public class PropertySetCommand implements CommandHandler {
|
|||
if (type == Color.class) return context.suggestLiteral("0x0F00FF", "#FFFFFF");
|
||||
if (type == DyeColor.class) return context.suggestEnum(DyeColor.values());
|
||||
if (type == CatVariant.class) return context.suggestEnum(CatVariant.values());
|
||||
if (type == CreeperState.class) return context.suggestEnum(CreeperState.values());
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
|
|
@ -7,6 +7,7 @@ import lol.pyr.znpcsplus.api.skin.SkinDescriptor;
|
|||
import lol.pyr.znpcsplus.entity.serializers.*;
|
||||
import lol.pyr.znpcsplus.skin.cache.SkinCache;
|
||||
import lol.pyr.znpcsplus.util.CatVariant;
|
||||
import lol.pyr.znpcsplus.util.CreeperState;
|
||||
import lol.pyr.znpcsplus.util.NpcPose;
|
||||
import lol.pyr.znpcsplus.util.Vector3f;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -37,6 +38,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
registerEnumSerializer(NpcPose.class);
|
||||
registerEnumSerializer(DyeColor.class);
|
||||
registerEnumSerializer(CatVariant.class);
|
||||
registerEnumSerializer(CreeperState.class);
|
||||
|
||||
registerType("glow", NamedTextColor.class);
|
||||
registerType("fire", false);
|
||||
|
@ -105,6 +107,10 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
registerType("cat_lying", false);
|
||||
registerType("cat_collar_color", DyeColor.RED);
|
||||
|
||||
// Creeper
|
||||
registerType("creeper_state", CreeperState.IDLE); // TODO: -1 = idle, 1 = fuse
|
||||
registerType("creeper_charged", false); // TODO
|
||||
|
||||
// Pufferfish
|
||||
registerType("puff_state", null); // TODO: Make a puff state enum class
|
||||
|
||||
|
@ -182,10 +188,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
registerType("piglin_dancing", false); // TODO
|
||||
registerType("piglin_charging_crossbow", false); // TODO
|
||||
|
||||
// Creeper
|
||||
registerType("creeper_state", null); // TODO: -1 = idle, 1 = fuse
|
||||
registerType("creeper_charged", false); // TODO
|
||||
|
||||
// Goat
|
||||
registerType("has_left_horn", true); // TODO
|
||||
registerType("has_right_horn", true); // TODO
|
||||
|
|
|
@ -3,6 +3,7 @@ package lol.pyr.znpcsplus.metadata;
|
|||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import lol.pyr.znpcsplus.util.CatVariant;
|
||||
import lol.pyr.znpcsplus.util.CreeperState;
|
||||
import lol.pyr.znpcsplus.util.Vector3f;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.DyeColor;
|
||||
|
@ -61,4 +62,8 @@ public interface MetadataFactory {
|
|||
EntityData catLying(boolean lying);
|
||||
EntityData catTamed(boolean tamed);
|
||||
EntityData catCollarColor(DyeColor collarColor);
|
||||
|
||||
// Creeper
|
||||
EntityData creeperState(CreeperState state);
|
||||
EntityData creeperCharged(boolean charged);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package lol.pyr.znpcsplus.metadata;
|
|||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import lol.pyr.znpcsplus.util.CreeperState;
|
||||
import lol.pyr.znpcsplus.util.Vector3f;
|
||||
|
||||
public class V1_10MetadataFactory extends V1_9MetadataFactory {
|
||||
|
@ -69,4 +70,14 @@ public class V1_10MetadataFactory extends V1_9MetadataFactory {
|
|||
public EntityData blazeOnFire(boolean onFire) {
|
||||
return newEntityData(12, EntityDataTypes.BYTE, (byte) (onFire ? 0x01 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperState(CreeperState state) {
|
||||
return newEntityData(12, EntityDataTypes.INT, state.getState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperCharged(boolean charged) {
|
||||
return newEntityData(13, EntityDataTypes.BOOLEAN, charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ 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.util.CatVariant;
|
||||
import lol.pyr.znpcsplus.util.CreeperState;
|
||||
import lol.pyr.znpcsplus.util.Vector3f;
|
||||
import org.bukkit.DyeColor;
|
||||
|
||||
|
@ -92,4 +93,14 @@ public class V1_14MetadataFactory extends V1_13MetadataFactory {
|
|||
public EntityData catCollarColor(DyeColor collarColor) {
|
||||
return newEntityData(20, EntityDataTypes.INT, collarColor.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperState(CreeperState state) {
|
||||
return newEntityData(14, EntityDataTypes.INT, state.getState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperCharged(boolean charged) {
|
||||
return newEntityData(15, EntityDataTypes.BOOLEAN, charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package lol.pyr.znpcsplus.metadata;
|
|||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import lol.pyr.znpcsplus.util.CatVariant;
|
||||
import lol.pyr.znpcsplus.util.CreeperState;
|
||||
import lol.pyr.znpcsplus.util.Vector3f;
|
||||
import org.bukkit.DyeColor;
|
||||
|
||||
|
@ -76,4 +77,14 @@ public class V1_15MetadataFactory extends V1_14MetadataFactory {
|
|||
public EntityData catCollarColor(DyeColor collarColor) {
|
||||
return newEntityData(21, EntityDataTypes.INT, collarColor.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperState(CreeperState state) {
|
||||
return newEntityData(15, EntityDataTypes.INT, state.getState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperCharged(boolean charged) {
|
||||
return newEntityData(16, EntityDataTypes.BOOLEAN, charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package lol.pyr.znpcsplus.metadata;
|
|||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import lol.pyr.znpcsplus.util.CatVariant;
|
||||
import lol.pyr.znpcsplus.util.CreeperState;
|
||||
import lol.pyr.znpcsplus.util.Vector3f;
|
||||
import org.bukkit.DyeColor;
|
||||
|
||||
|
@ -121,4 +122,14 @@ public class V1_17MetadataFactory extends V1_16MetadataFactory {
|
|||
public EntityData catCollarColor(DyeColor collarColor) {
|
||||
return newEntityData(22, EntityDataTypes.INT, collarColor.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperState(CreeperState state) {
|
||||
return newEntityData(16, EntityDataTypes.INT, state.getState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperCharged(boolean charged) {
|
||||
return newEntityData(17, EntityDataTypes.BOOLEAN, charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
|||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||
import lol.pyr.znpcsplus.util.CatVariant;
|
||||
import lol.pyr.znpcsplus.util.CreeperState;
|
||||
import lol.pyr.znpcsplus.util.Vector3f;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.DyeColor;
|
||||
|
@ -146,6 +147,16 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
|||
throw new UnsupportedOperationException("The cat collar color entity data isn't supported on this version");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperState(CreeperState state) {
|
||||
return newEntityData(16, EntityDataTypes.BYTE, (byte) state.getState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperCharged(boolean charged) {
|
||||
return newEntityData(17, EntityDataTypes.BYTE, (byte) (charged ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData silent(boolean enabled) {
|
||||
return newEntityData(4, EntityDataTypes.BYTE, (byte) (enabled ? 1 : 0));
|
||||
|
|
|
@ -3,6 +3,7 @@ package lol.pyr.znpcsplus.metadata;
|
|||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.util.adventure.AdventureSerializer;
|
||||
import lol.pyr.znpcsplus.util.CreeperState;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class V1_9MetadataFactory extends V1_8MetadataFactory {
|
||||
|
@ -37,6 +38,16 @@ public class V1_9MetadataFactory extends V1_8MetadataFactory {
|
|||
return newEntityData(16, EntityDataTypes.BYTE, (byte) (onFire ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperState(CreeperState state) {
|
||||
return newEntityData(11, EntityDataTypes.INT, state.getState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData creeperCharged(boolean charged) {
|
||||
return newEntityData(12, EntityDataTypes.BOOLEAN, charged);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData name(Component name) {
|
||||
return newEntityData(2, EntityDataTypes.STRING, AdventureSerializer.getGsonSerializer().serialize(name));
|
||||
|
|
|
@ -67,7 +67,8 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
|
|||
.setHologramOffset(-0.575));
|
||||
|
||||
register(builder(p, "creeper", EntityTypes.CREEPER)
|
||||
.setHologramOffset(-0.275));
|
||||
.setHologramOffset(-0.275)
|
||||
.addProperties("creeper_state", "creeper_charged"));
|
||||
|
||||
register(builder(p, "donkey", EntityTypes.DONKEY)
|
||||
.setHologramOffset(-0.475));
|
||||
|
|
|
@ -16,10 +16,7 @@ import lol.pyr.znpcsplus.entity.PacketEntity;
|
|||
import lol.pyr.znpcsplus.metadata.MetadataFactory;
|
||||
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
||||
import lol.pyr.znpcsplus.skin.BaseSkinDescriptor;
|
||||
import lol.pyr.znpcsplus.util.CatVariant;
|
||||
import lol.pyr.znpcsplus.util.NpcLocation;
|
||||
import lol.pyr.znpcsplus.util.PapiUtil;
|
||||
import lol.pyr.znpcsplus.util.Vector3f;
|
||||
import lol.pyr.znpcsplus.util.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
@ -186,6 +183,10 @@ public class V1_8PacketFactory implements PacketFactory {
|
|||
add(data, metadataFactory.catCollarColor(properties.getProperty(propertyRegistry.getByName("cat_collar_color", DyeColor.class))));
|
||||
add(data, metadataFactory.catTamed(properties.hasProperty(propertyRegistry.getByName("cat_collar_color", DyeColor.class))));
|
||||
}
|
||||
else if (entity.getType().equals(EntityTypes.CREEPER)) {
|
||||
add(data, metadataFactory.creeperState(properties.getProperty(propertyRegistry.getByName("creeper_state", CreeperState.class))));
|
||||
add(data, metadataFactory.creeperCharged(properties.getProperty(propertyRegistry.getByName("creeper_charged", Boolean.class))));
|
||||
}
|
||||
if (properties.hasProperty(propertyRegistry.getByName("name"))) {
|
||||
add(data, metadataFactory.name(PapiUtil.set(textSerializer, player, properties.getProperty(propertyRegistry.getByName("name", Component.class)))));
|
||||
add(data, metadataFactory.nameShown());
|
||||
|
|
Loading…
Reference in a new issue