mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-22 23:31:37 +01:00
Use the tag api inside Entity, deprecate DataContainer
This commit is contained in:
parent
a9086e83f2
commit
b5c7106f9b
@ -6,7 +6,10 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
* Represents an element which can have a {@link Data} attached to it.
|
* Represents an element which can have a {@link Data} attached to it.
|
||||||
* <p>
|
* <p>
|
||||||
* The data will always be optional and can therefore be null.
|
* The data will always be optional and can therefore be null.
|
||||||
|
*
|
||||||
|
* @deprecated switch to the Tag API instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface DataContainer {
|
public interface DataContainer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,6 +33,8 @@ import net.minestom.server.permission.PermissionHandler;
|
|||||||
import net.minestom.server.potion.Potion;
|
import net.minestom.server.potion.Potion;
|
||||||
import net.minestom.server.potion.PotionEffect;
|
import net.minestom.server.potion.PotionEffect;
|
||||||
import net.minestom.server.potion.TimedPotion;
|
import net.minestom.server.potion.TimedPotion;
|
||||||
|
import net.minestom.server.tag.Tag;
|
||||||
|
import net.minestom.server.tag.TagHandler;
|
||||||
import net.minestom.server.thread.ThreadProvider;
|
import net.minestom.server.thread.ThreadProvider;
|
||||||
import net.minestom.server.utils.BlockPosition;
|
import net.minestom.server.utils.BlockPosition;
|
||||||
import net.minestom.server.utils.Position;
|
import net.minestom.server.utils.Position;
|
||||||
@ -49,6 +51,7 @@ import net.minestom.server.utils.validate.Check;
|
|||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -64,7 +67,7 @@ import java.util.function.UnaryOperator;
|
|||||||
* <p>
|
* <p>
|
||||||
* To create your own entity you probably want to extends {@link LivingEntity} or {@link EntityCreature} instead.
|
* To create your own entity you probably want to extends {@link LivingEntity} or {@link EntityCreature} instead.
|
||||||
*/
|
*/
|
||||||
public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, DataContainer, PermissionHandler, HoverEventSource<ShowEntity>, Sound.Emitter {
|
public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, DataContainer, TagHandler, PermissionHandler, HoverEventSource<ShowEntity>, Sound.Emitter {
|
||||||
|
|
||||||
private static final Map<Integer, Entity> ENTITY_BY_ID = new ConcurrentHashMap<>();
|
private static final Map<Integer, Entity> ENTITY_BY_ID = new ConcurrentHashMap<>();
|
||||||
private static final Map<UUID, Entity> ENTITY_BY_UUID = new ConcurrentHashMap<>();
|
private static final Map<UUID, Entity> ENTITY_BY_UUID = new ConcurrentHashMap<>();
|
||||||
@ -102,6 +105,7 @@ public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, Da
|
|||||||
protected final Set<Player> viewers = ConcurrentHashMap.newKeySet();
|
protected final Set<Player> viewers = ConcurrentHashMap.newKeySet();
|
||||||
private final Set<Player> unmodifiableViewers = Collections.unmodifiableSet(viewers);
|
private final Set<Player> unmodifiableViewers = Collections.unmodifiableSet(viewers);
|
||||||
private Data data;
|
private Data data;
|
||||||
|
private final NBTCompound nbtCompound = new NBTCompound();
|
||||||
private final Set<Permission> permissions = new CopyOnWriteArraySet<>();
|
private final Set<Permission> permissions = new CopyOnWriteArraySet<>();
|
||||||
|
|
||||||
protected UUID uuid;
|
protected UUID uuid;
|
||||||
@ -1629,6 +1633,16 @@ public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, Da
|
|||||||
return (Acquirable<T>) acquirable;
|
return (Acquirable<T>) acquirable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
|
||||||
|
return tag.read(nbtCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> void setTag(@NotNull Tag<T> tag, @Nullable T value) {
|
||||||
|
tag.write(nbtCompound, value);
|
||||||
|
}
|
||||||
|
|
||||||
public enum Pose {
|
public enum Pose {
|
||||||
STANDING,
|
STANDING,
|
||||||
FALL_FLYING,
|
FALL_FLYING,
|
||||||
|
Loading…
Reference in New Issue
Block a user