mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
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:
parent
1f87f26b4f
commit
34558e75ee
@ -88,7 +88,7 @@ record EntityTypeImpl(Registry.EntityEntry registry) implements EntityType {
|
||||
entry("minecraft:blaze", BlazeMeta::new),
|
||||
entry("minecraft:block_display", BlockDisplayMeta::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:cat", CatMeta::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:vindicator", VindicatorMeta::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:wither", WitherMeta::new),
|
||||
entry("minecraft:wither_skeleton", WitherSkeletonMeta::new),
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.entity.metadata.animal;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FrogMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
@ -20,14 +21,16 @@ public class FrogMeta extends AnimalMeta {
|
||||
super.metadata.setIndex(OFFSET, Metadata.FrogVariant(value));
|
||||
}
|
||||
|
||||
public int getTongueTarget() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
public @Nullable Integer getTongueTarget() {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
public enum Variant {
|
||||
TEMPERATE,
|
||||
WARM,
|
||||
|
@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GoatMeta extends AnimalMeta {
|
||||
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) {
|
||||
super(entity, metadata);
|
||||
@ -19,4 +19,20 @@ public class GoatMeta extends AnimalMeta {
|
||||
public void setScreaming(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));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
@ -6,10 +6,18 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PillagerMeta extends AbstractIllagerMeta {
|
||||
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) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isChargingCrossbow() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setChargingCrossbow(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -76,7 +76,10 @@ public class BoatMeta extends EntityMeta {
|
||||
BIRCH,
|
||||
JUNGLE,
|
||||
ACACIA,
|
||||
DARK_OAK;
|
||||
CHERRY,
|
||||
DARK_OAK,
|
||||
MANGROVE,
|
||||
BAMBOO;
|
||||
|
||||
private final static Type[] VALUES = values();
|
||||
}
|
||||
|
@ -23,20 +23,19 @@ public class DolphinMeta extends WaterAnimalMeta {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Position(value));
|
||||
}
|
||||
|
||||
public boolean isCanFindTreasure() {
|
||||
public boolean isHasFish() {
|
||||
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));
|
||||
}
|
||||
|
||||
public boolean isHasFish() {
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
public int getMoistureLevel() {
|
||||
return super.metadata.getIndex(OFFSET + 2, 2400);
|
||||
}
|
||||
|
||||
public void setHasFish(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
public void setMoistureLevel(int value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user