Implemented Fox properties
This commit is contained in:
parent
8c83cb3428
commit
4cc468b919
10 changed files with 63 additions and 9 deletions
6
api/src/main/java/lol/pyr/znpcsplus/util/FoxVariant.java
Normal file
6
api/src/main/java/lol/pyr/znpcsplus/util/FoxVariant.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package lol.pyr.znpcsplus.util;
|
||||
|
||||
public enum FoxVariant {
|
||||
RED,
|
||||
SNOW
|
||||
}
|
|
@ -285,6 +285,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
|||
registerEnumParser(manager, CreeperState.class, incorrectUsageMessage);
|
||||
registerEnumParser(manager, ParrotVariant.class, incorrectUsageMessage);
|
||||
registerEnumParser(manager, SpellType.class, incorrectUsageMessage);
|
||||
registerEnumParser(manager, FoxVariant.class, incorrectUsageMessage);
|
||||
|
||||
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
|
||||
.addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry))
|
||||
|
|
|
@ -126,6 +126,7 @@ public class PropertySetCommand implements CommandHandler {
|
|||
if (type == ParrotVariant.class) return context.suggestEnum(ParrotVariant.values());
|
||||
if (type == BlockState.class) return context.suggestLiteral("hand", "looking_at", "block");
|
||||
if (type == SpellType.class) return context.suggestEnum(SpellType.values());
|
||||
if (type == FoxVariant.class) return context.suggestEnum(FoxVariant.values());
|
||||
}
|
||||
else if (context.argSize() == 4) {
|
||||
if (type == BlockState.class) {
|
||||
|
|
|
@ -39,6 +39,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
registerEnumSerializer(CreeperState.class);
|
||||
registerEnumSerializer(ParrotVariant.class);
|
||||
registerEnumSerializer(SpellType.class);
|
||||
registerEnumSerializer(FoxVariant.class);
|
||||
|
||||
registerType("glow", NamedTextColor.class);
|
||||
registerType("fire", false);
|
||||
|
@ -122,6 +123,13 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
// Evoker
|
||||
registerType("evoker_spell", SpellType.NONE);
|
||||
|
||||
// Fox
|
||||
registerType("fox_variant", FoxVariant.RED);
|
||||
registerType("fox_sitting", false);
|
||||
registerType("fox_crouching", false);
|
||||
registerType("fox_sleeping", false);
|
||||
registerType("fox_faceplanted", false);
|
||||
|
||||
// Pufferfish
|
||||
registerType("puff_state", null); // TODO: Make a puff state enum class
|
||||
|
||||
|
@ -140,13 +148,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
|||
registerType("carpet_color", DyeColor.class); // TODO
|
||||
registerType("llama_variant", 0); // TODO
|
||||
|
||||
// Fox
|
||||
registerType("fox_variant", 0); // TODO: 0 = red, 1 = snow
|
||||
registerType("fox_sitting", false); // TODO
|
||||
registerType("fox_crouching", false); // TODO
|
||||
registerType("fox_sleeping", false); // TODO
|
||||
registerType("fox_faceplanting", false); // TODO
|
||||
|
||||
// Frog
|
||||
registerType("frog_type", null); // TODO: It has a custom type read on wiki.vg
|
||||
|
||||
|
|
|
@ -76,4 +76,8 @@ public interface MetadataFactory {
|
|||
|
||||
// Evoker
|
||||
EntityData evokerSpell(int spell);
|
||||
|
||||
// Fox
|
||||
EntityData foxVariant(int variant);
|
||||
EntityData foxProperties(boolean sitting, boolean crouching, boolean sleeping, boolean facePlanted);
|
||||
}
|
||||
|
|
|
@ -103,4 +103,14 @@ public class V1_15MetadataFactory extends V1_14MetadataFactory {
|
|||
public EntityData evokerSpell(int spell) {
|
||||
return newEntityData(16, EntityDataTypes.BYTE, (byte) spell);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData foxVariant(int variant) {
|
||||
return newEntityData(16, EntityDataTypes.INT, variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData foxProperties(boolean sitting, boolean crouching, boolean sleeping, boolean facePlanted) {
|
||||
return newEntityData(17, EntityDataTypes.BYTE, (byte) ((sitting ? 0x01 : 0) | (crouching ? 0x04 : 0) | (sleeping ? 0x20 : 0) | (facePlanted ? 0x40 : 0)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,4 +163,14 @@ public class V1_17MetadataFactory extends V1_16MetadataFactory {
|
|||
public EntityData evokerSpell(int spell) {
|
||||
return newEntityData(17, EntityDataTypes.BYTE, (byte) spell);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData foxVariant(int variant) {
|
||||
return newEntityData(17, EntityDataTypes.INT, variant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData foxProperties(boolean sitting, boolean crouching, boolean sleeping, boolean facePlanted) {
|
||||
return newEntityData(18, EntityDataTypes.BYTE, (byte) ((sitting ? 0x01 : 0) | (crouching ? 0x04 : 0) | (sleeping ? 0x20 : 0) | (facePlanted ? 0x40 : 0)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,6 +185,16 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
|||
throw new UnsupportedOperationException("The evoker spell entity data isn't supported on this version");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData foxVariant(int variant) {
|
||||
throw new UnsupportedOperationException("The fox variant entity data isn't supported on this version");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData foxProperties(boolean sitting, boolean crouching, boolean sleeping, boolean facePlanted) {
|
||||
throw new UnsupportedOperationException("The fox properties entity data isn't supported on this version");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityData silent(boolean enabled) {
|
||||
return newEntityData(4, EntityDataTypes.BYTE, (byte) (enabled ? 1 : 0));
|
||||
|
|
|
@ -246,7 +246,7 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
|
|||
|
||||
register(builder(p, "fox", EntityTypes.FOX)
|
||||
.setHologramOffset(-1.275)
|
||||
.addProperties("hand"));
|
||||
.addProperties("hand", "fox_variant", "fox_sitting", "fox_crouching", "fox_sleeping", "fox_faceplanted"));
|
||||
|
||||
register(builder(p, "panda", EntityTypes.PANDA)
|
||||
.setHologramOffset(-0.725));
|
||||
|
|
|
@ -195,9 +195,20 @@ public class V1_8PacketFactory implements PacketFactory {
|
|||
);
|
||||
add(data, metadataFactory.endermanScreaming(properties.getProperty(propertyRegistry.getByName("enderman_screaming", Boolean.class))));
|
||||
add(data, metadataFactory.endermanStaring(properties.getProperty(propertyRegistry.getByName("enderman_staring", Boolean.class))));
|
||||
} else if (entity.getType().equals(EntityTypes.EVOKER)) {
|
||||
}
|
||||
else if (entity.getType().equals(EntityTypes.EVOKER)) {
|
||||
add(data, metadataFactory.evokerSpell(properties.getProperty(propertyRegistry.getByName("evoker_spell", SpellType.class)).ordinal()));
|
||||
}
|
||||
else if (entity.getType().equals(EntityTypes.FOX)) {
|
||||
// Not sure if this should be in here or in 1.14 PacketFactory
|
||||
add(data, metadataFactory.foxVariant(properties.getProperty(propertyRegistry.getByName("fox_variant", FoxVariant.class)).ordinal()));
|
||||
add(data, metadataFactory.foxProperties(
|
||||
properties.getProperty(propertyRegistry.getByName("fox_sitting", Boolean.class)),
|
||||
properties.getProperty(propertyRegistry.getByName("fox_crouching", Boolean.class)),
|
||||
properties.getProperty(propertyRegistry.getByName("fox_sleeping", Boolean.class)),
|
||||
properties.getProperty(propertyRegistry.getByName("fox_faceplanted", Boolean.class))
|
||||
));
|
||||
}
|
||||
|
||||
if (properties.getProperty(propertyRegistry.getByName("dinnerbone", Boolean.class))) {
|
||||
add(data, metadataFactory.name(Component.text("Dinnerbone")));
|
||||
|
|
Loading…
Reference in a new issue