hollow-cube/entity-metadata-patches (#35)

* feat: add more boat types

* feat: goat horn api

* feat: pillager crossbow meta

* feat: use boat metadata for chestboat

* feat: add warden meta

* fix: incorrect dolphin meta

* feat: allow to set null values for tounge target

* feat: nullable tounge target

* fix: update max offset in goat
This commit is contained in:
David Mayr 2023-08-07 03:32:39 +02:00 committed by GitHub
parent 1f87f26b4f
commit 34558e75ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 68 additions and 15 deletions

View File

@ -88,7 +88,7 @@ record EntityTypeImpl(Registry.EntityEntry registry) implements EntityType {
entry("minecraft:blaze", BlazeMeta::new), entry("minecraft:blaze", BlazeMeta::new),
entry("minecraft:block_display", BlockDisplayMeta::new), entry("minecraft:block_display", BlockDisplayMeta::new),
entry("minecraft:boat", BoatMeta::new), entry("minecraft:boat", BoatMeta::new),
entry("minecraft:chest_boat", EntityMeta::new), // TODO dedicated metadata entry("minecraft:chest_boat", BoatMeta::new),
entry("minecraft:camel", CamelMeta::new), entry("minecraft:camel", CamelMeta::new),
entry("minecraft:cat", CatMeta::new), entry("minecraft:cat", CatMeta::new),
entry("minecraft:cave_spider", CaveSpiderMeta::new), entry("minecraft:cave_spider", CaveSpiderMeta::new),
@ -189,7 +189,7 @@ record EntityTypeImpl(Registry.EntityEntry registry) implements EntityType {
entry("minecraft:villager", VillagerMeta::new), entry("minecraft:villager", VillagerMeta::new),
entry("minecraft:vindicator", VindicatorMeta::new), entry("minecraft:vindicator", VindicatorMeta::new),
entry("minecraft:wandering_trader", WanderingTraderMeta::new), entry("minecraft:wandering_trader", WanderingTraderMeta::new),
entry("minecraft:warden", EntityMeta::new), // TODO dedicated metadata entry("minecraft:warden", WardenMeta::new),
entry("minecraft:witch", WitchMeta::new), entry("minecraft:witch", WitchMeta::new),
entry("minecraft:wither", WitherMeta::new), entry("minecraft:wither", WitherMeta::new),
entry("minecraft:wither_skeleton", WitherSkeletonMeta::new), entry("minecraft:wither_skeleton", WitherSkeletonMeta::new),

View File

@ -3,6 +3,7 @@ package net.minestom.server.entity.metadata.animal;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Metadata; import net.minestom.server.entity.Metadata;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class FrogMeta extends AnimalMeta { public class FrogMeta extends AnimalMeta {
public static final byte OFFSET = AnimalMeta.MAX_OFFSET; public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
@ -20,14 +21,16 @@ public class FrogMeta extends AnimalMeta {
super.metadata.setIndex(OFFSET, Metadata.FrogVariant(value)); super.metadata.setIndex(OFFSET, Metadata.FrogVariant(value));
} }
public int getTongueTarget() { public @Nullable Integer getTongueTarget() {
return super.metadata.getIndex(OFFSET + 1, 0); return super.metadata.getIndex(OFFSET + 1, null);
} }
public void setTongueTarget(int value) {
public void setTongueTarget(@Nullable Integer value) {
super.metadata.setIndex(OFFSET + 1, Metadata.OptVarInt(value)); super.metadata.setIndex(OFFSET + 1, Metadata.OptVarInt(value));
} }
public enum Variant { public enum Variant {
TEMPERATE, TEMPERATE,
WARM, WARM,

View File

@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
public class GoatMeta extends AnimalMeta { public class GoatMeta extends AnimalMeta {
public static final byte OFFSET = AnimalMeta.MAX_OFFSET; public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
public static final byte MAX_OFFSET = OFFSET + 1; public static final byte MAX_OFFSET = OFFSET + 3;
public GoatMeta(@NotNull Entity entity, @NotNull Metadata metadata) { public GoatMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
super(entity, metadata); super(entity, metadata);
@ -19,4 +19,20 @@ public class GoatMeta extends AnimalMeta {
public void setScreaming(boolean screaming) { public void setScreaming(boolean screaming) {
metadata.setIndex(OFFSET, Metadata.Boolean(screaming)); metadata.setIndex(OFFSET, Metadata.Boolean(screaming));
} }
public boolean hasLeftHorn() {
return metadata.getIndex(OFFSET + 1, true);
}
public void setLeftHorn(boolean leftHorn) {
metadata.setIndex(OFFSET + 1, Metadata.Boolean(leftHorn));
}
public boolean hasRightHorn() {
return metadata.getIndex(OFFSET + 2, true);
}
public void setRightHorn(boolean rightHorn) {
metadata.setIndex(OFFSET + 2, Metadata.Boolean(rightHorn));
}
} }

View File

@ -0,0 +1,24 @@
package net.minestom.server.entity.metadata.monster;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Metadata;
import org.jetbrains.annotations.NotNull;
public class WardenMeta extends MonsterMeta {
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
public static final byte MAX_OFFSET = OFFSET + 1;
public WardenMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
super(entity, metadata);
}
public int getAngerLevel() {
return super.metadata.getIndex(OFFSET, 0);
}
public void setAngerLevel(int value) {
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
}
}

View File

@ -6,10 +6,18 @@ import org.jetbrains.annotations.NotNull;
public class PillagerMeta extends AbstractIllagerMeta { public class PillagerMeta extends AbstractIllagerMeta {
public static final byte OFFSET = AbstractIllagerMeta.MAX_OFFSET; public static final byte OFFSET = AbstractIllagerMeta.MAX_OFFSET;
public static final byte MAX_OFFSET = OFFSET + 0; public static final byte MAX_OFFSET = OFFSET + 1;
public PillagerMeta(@NotNull Entity entity, @NotNull Metadata metadata) { public PillagerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
super(entity, metadata); super(entity, metadata);
} }
public boolean isChargingCrossbow() {
return super.metadata.getIndex(OFFSET, false);
}
public void setChargingCrossbow(boolean value) {
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
}
} }

View File

@ -76,7 +76,10 @@ public class BoatMeta extends EntityMeta {
BIRCH, BIRCH,
JUNGLE, JUNGLE,
ACACIA, ACACIA,
DARK_OAK; CHERRY,
DARK_OAK,
MANGROVE,
BAMBOO;
private final static Type[] VALUES = values(); private final static Type[] VALUES = values();
} }

View File

@ -23,20 +23,19 @@ public class DolphinMeta extends WaterAnimalMeta {
super.metadata.setIndex(OFFSET, Metadata.Position(value)); super.metadata.setIndex(OFFSET, Metadata.Position(value));
} }
public boolean isCanFindTreasure() { public boolean isHasFish() {
return super.metadata.getIndex(OFFSET + 1, false); return super.metadata.getIndex(OFFSET + 1, false);
} }
public void setCanFindTreasure(boolean value) { public void setHasFish(boolean value) {
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value)); super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
} }
public boolean isHasFish() { public int getMoistureLevel() {
return super.metadata.getIndex(OFFSET + 2, false); return super.metadata.getIndex(OFFSET + 2, 2400);
} }
public void setHasFish(boolean value) { public void setMoistureLevel(int value) {
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value)); super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value));
} }
} }