implemented immune_to_zombification property for hoglin

This commit is contained in:
D3v1s0m 2023-07-06 19:48:56 +05:30
parent 63b049bb8c
commit 03623a43da
No known key found for this signature in database
GPG Key ID: 3B6EC35367B8D82E
7 changed files with 35 additions and 4 deletions

@ -140,6 +140,12 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
// Ghast
registerType("attacking", false);
// Guardian
registerType("is_elder", false); // TODO: ensure it only works till 1.10. Note: index is wrong on wiki.vg
// Piglin / Hoglin
registerType("immune_to_zombification", true);
// Pufferfish
registerType("puff_state", null); // TODO: Make a puff state enum class
@ -201,9 +207,6 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
registerType("shield_height", 0); // TODO: figure this out
registerType("shulker_color", DyeColor.RED); // TODO
// Piglin / Hoglin
registerType("immune_to_zombification", false); // TODO
// Piglin
registerType("piglin_dancing", false); // TODO
registerType("piglin_charging_crossbow", false); // TODO

@ -91,6 +91,11 @@ public interface MetadataFactory {
EntityData goatHasLeftHorn(boolean hasLeftHorn);
EntityData goatHasRightHorn(boolean hasRightHorn);
// Guardian
// Hoglin
EntityData hoglinImmuneToZombification(boolean immuneToZombification);
// Villager
EntityData villagerData(int type, int profession, int level);
}

@ -1,10 +1,16 @@
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_16MetadataFactory extends V1_15MetadataFactory {
@Override
public EntityData skinLayers(boolean cape, boolean jacket, boolean leftSleeve, boolean rightSleeve, boolean leftLeg, boolean rightLeg, boolean hat) {
return createSkinLayers(16, cape, jacket, leftSleeve, rightSleeve, leftLeg, rightLeg, hat);
}
@Override
public EntityData hoglinImmuneToZombification(boolean immuneToZombification) {
return newEntityData(16, EntityDataTypes.BOOLEAN, immuneToZombification);
}
}

@ -190,6 +190,11 @@ public class V1_17MetadataFactory extends V1_16MetadataFactory {
return newEntityData(19, EntityDataTypes.BOOLEAN, hasRightHorn);
}
@Override
public EntityData hoglinImmuneToZombification(boolean immuneToZombification) {
return newEntityData(17, EntityDataTypes.BOOLEAN, immuneToZombification);
}
@Override
public EntityData villagerData(int type, int profession, int level) {
return newEntityData(18, EntityDataTypes.VILLAGER_DATA, new VillagerData(type, profession, level));

@ -215,6 +215,11 @@ public class V1_8MetadataFactory implements MetadataFactory {
throw new UnsupportedOperationException("The goat horn entity data isn't supported on this version");
}
@Override
public EntityData hoglinImmuneToZombification(boolean immuneToZombification) {
throw new UnsupportedOperationException("The hoglin zombification entity data isn't supported on this version");
}
@Override
public EntityData villagerData(int type, int profession, int level) {
return newEntityData(16, EntityDataTypes.INT, profession);

@ -282,7 +282,8 @@ public class NpcTypeRegistryImpl implements NpcTypeRegistry {
if (!version.isNewerThanOrEquals(ServerVersion.V_1_16)) return;
register(builder(p, "hoglin", EntityTypes.HOGLIN)
.setHologramOffset(-0.575));
.setHologramOffset(-0.575)
.addProperties("immune_to_zombification"));
register(builder(p, "piglin", EntityTypes.PIGLIN)
.setHologramOffset(-1.0)

@ -221,6 +221,12 @@ public class V1_8PacketFactory implements PacketFactory {
add(data, metadataFactory.goatHasLeftHorn(properties.getProperty(propertyRegistry.getByName("has_left_horn", Boolean.class))));
add(data, metadataFactory.goatHasRightHorn(properties.getProperty(propertyRegistry.getByName("has_right_horn", Boolean.class))));
}
else if (entity.getType().equals(EntityTypes.GUARDIAN)) {
// TODO
}
else if (entity.getType().equals(EntityTypes.HOGLIN)) {
add(data, metadataFactory.hoglinImmuneToZombification(properties.getProperty(propertyRegistry.getByName("immune_to_zombification", Boolean.class))));
}
else if (entity.getType().equals(EntityTypes.VILLAGER)) {
VillagerProfession profession = properties.getProperty(propertyRegistry.getByName("villager_profession", VillagerProfession.class));
int professionId = profession.ordinal();