convert Entity.java to kotlin

This commit is contained in:
Bixilon 2021-03-31 20:11:36 +02:00
parent 59e873a69e
commit a910122ce2
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
98 changed files with 465 additions and 565 deletions

View File

@ -26,6 +26,6 @@ public abstract class AgeableMob extends PathfinderMob {
@EntityMetaDataFunction(name = "Is baby")
public boolean isBaby() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.AGEABLE_IS_BABY);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.AGEABLE_IS_BABY);
}
}

View File

@ -27,23 +27,23 @@ public class AreaEffectCloud extends Entity {
@EntityMetaDataFunction(name = "Radius")
public float getRadius() {
return getMetaData().getSets().getFloat(EntityMetaDataFields.AREA_EFFECT_CLOUD_RADIUS);
return getEntityMetaData().getSets().getFloat(EntityMetaDataFields.AREA_EFFECT_CLOUD_RADIUS);
}
@EntityMetaDataFunction(name = "Color")
public int getColor() {
return getMetaData().getSets().getInt(EntityMetaDataFields.AREA_EFFECT_CLOUD_COLOR);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.AREA_EFFECT_CLOUD_COLOR);
}
// ignore radius???
@EntityMetaDataFunction(name = "Is waiting")
public boolean isWaiting() {
return getMetaData().getSets().getBoolean(EntityMetaDataFields.AREA_EFFECT_CLOUD_WAITING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.AREA_EFFECT_CLOUD_WAITING);
}
@EntityMetaDataFunction(name = "Particle")
public ParticleData getParticle() {
return getMetaData().getSets().getParticle(EntityMetaDataFields.AREA_EFFECT_CLOUD_PARTICLE);
return getEntityMetaData().getSets().getParticle(EntityMetaDataFields.AREA_EFFECT_CLOUD_PARTICLE);
}
}

View File

@ -1,345 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.entities.entities;
import de.bixilon.minosoft.config.StaticConfiguration;
import de.bixilon.minosoft.data.Axes;
import de.bixilon.minosoft.data.entities.*;
import de.bixilon.minosoft.data.entities.meta.EntityMetaData;
import de.bixilon.minosoft.data.inventory.InventorySlots;
import de.bixilon.minosoft.data.inventory.ItemStack;
import de.bixilon.minosoft.data.mappings.StatusEffect;
import de.bixilon.minosoft.data.mappings.blocks.BlockState;
import de.bixilon.minosoft.data.text.ChatComponent;
import de.bixilon.minosoft.gui.rendering.Camera;
import de.bixilon.minosoft.gui.rendering.chunk.VoxelShape;
import de.bixilon.minosoft.gui.rendering.chunk.models.AABB;
import de.bixilon.minosoft.modding.event.events.annotations.Unsafe;
import de.bixilon.minosoft.protocol.network.Connection;
import de.bixilon.minosoft.util.logging.Log;
import glm_.vec3.Vec3;
import glm_.vec3.Vec3i;
import javax.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
public abstract class Entity {
private static final AABB DEFAULT_PLAYER_AABB = new AABB(
new Vec3(-Camera.PLAYER_WIDTH / 2, 0, -Camera.PLAYER_WIDTH / 2),
new Vec3(Camera.PLAYER_WIDTH / 2, 1.8, Camera.PLAYER_WIDTH / 2)
);
protected final Connection connection;
protected final EntityInformation information;
protected final HashMap<Integer, ItemStack> equipment = new HashMap<>();
protected final HashSet<StatusEffectInstance> effectList = new HashSet<>();
protected final int versionId;
protected Vec3 position;
protected EntityRotation rotation;
protected int attachedTo = -1;
protected EntityMetaData metaData;
protected boolean hasCollisions = true;
public Entity(Connection connection, Vec3 position, EntityRotation rotation) {
this.connection = connection;
this.information = connection.getMapping().getEntityInformation(getClass());
this.versionId = connection.getVersion().getVersionId();
this.position = position;
this.rotation = rotation;
}
@Deprecated
public int getEntityId() {
return this.connection.getWorld().getEntityIdMap().inverse().get(this);
}
public Vec3 getPosition() {
return this.position;
}
public void setLocation(Vec3 position) {
this.position = position;
}
public void addLocation(Vec3 relativePosition) {
this.position = new Vec3(this.position.x + relativePosition.x, this.position.y + relativePosition.y, this.position.z + relativePosition.z);
}
public ItemStack getEquipment(InventorySlots.EquipmentSlots slot) {
return this.equipment.get(slot);
}
public HashMap<Integer, ItemStack> getEquipment() {
return this.equipment;
}
public void setEquipment(HashMap<Integer, ItemStack> slots) {
this.equipment.putAll(slots);
}
public UUID getUUID() {
return this.connection.getWorld().getEntityUUIDMap().inverse().get(this);
}
public HashSet<StatusEffectInstance> getEffectList() {
return this.effectList;
}
public void addEffect(StatusEffectInstance effect) {
// effect already applied, maybe the duration or the amplifier changed?
this.effectList.removeIf(listEffect -> listEffect.getStatusEffect() == effect.getStatusEffect());
this.effectList.add(effect);
}
public void removeEffect(StatusEffect effect) {
this.effectList.removeIf(listEffect -> listEffect.getStatusEffect() == effect);
}
public void attachTo(int vehicleId) {
this.attachedTo = vehicleId;
}
public boolean isAttached() {
return this.attachedTo != -1;
}
public int getAttachedEntity() {
return this.attachedTo;
}
public void detach() {
this.attachedTo = -1;
}
public EntityRotation getRotation() {
return this.rotation;
}
public void setRotation(EntityRotation rotation) {
this.rotation = rotation;
}
public void setRotation(int yaw, int pitch) {
this.rotation = new EntityRotation(yaw, pitch, this.rotation.getHeadYaw());
}
public void setRotation(int yaw, int pitch, int headYaw) {
this.rotation = new EntityRotation(yaw, pitch, headYaw);
}
public void setHeadRotation(int headYaw) {
this.rotation = new EntityRotation(this.rotation.getYaw(), this.rotation.getPitch(), headYaw);
}
@Unsafe
public EntityMetaData getMetaData() {
return this.metaData;
}
@Unsafe
public void setMetaData(EntityMetaData metaData) {
this.metaData = metaData;
if (StaticConfiguration.VERBOSE_ENTITY_META_DATA_LOGGING) {
Log.verbose(String.format("Metadata of entity %s (entityId=%d): %s", toString(), getEntityId(), getEntityMetaDataAsString()));
}
}
public EntityInformation getEntityInformation() {
return this.information;
}
private boolean getEntityFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.ENTITY_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "On fire")
public boolean isOnFire() {
return getEntityFlag(0x01);
}
private boolean isCrouching() {
return getEntityFlag(0x02);
}
@EntityMetaDataFunction(name = "Is sprinting")
public boolean isSprinting() {
return getEntityFlag(0x08);
}
private boolean isSwimming() {
return getEntityFlag(0x10);
}
@EntityMetaDataFunction(name = "Is invisible")
public boolean isInvisible() {
return getEntityFlag(0x20);
}
@EntityMetaDataFunction(name = "Has glowing effect")
public boolean hasGlowingEffect() {
return getEntityFlag(0x20);
}
private boolean isFlyingWithElytra() {
return getEntityFlag(0x80);
}
@EntityMetaDataFunction(name = "Air supply")
private int getAirSupply() {
return this.metaData.getSets().getInt(EntityMetaDataFields.ENTITY_AIR_SUPPLY);
}
@EntityMetaDataFunction(name = "Custom name")
@Nullable
private ChatComponent getCustomName() {
return this.metaData.getSets().getChatComponent(EntityMetaDataFields.ENTITY_CUSTOM_NAME);
}
@EntityMetaDataFunction(name = "Is custom name visible")
public boolean isCustomNameVisible() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ENTITY_CUSTOM_NAME_VISIBLE);
}
@EntityMetaDataFunction(name = "Is silent")
public boolean isSilent() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ENTITY_SILENT);
}
@EntityMetaDataFunction(name = "Has no gravity")
public boolean hasNoGravity() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ENTITY_NO_GRAVITY);
}
@EntityMetaDataFunction(name = "Pose")
public Poses getPose() {
if (isCrouching()) {
return Poses.SNEAKING;
}
if (isSwimming()) {
return Poses.SWIMMING;
}
if (isFlyingWithElytra()) {
return Poses.FLYING;
}
return this.metaData.getSets().getPose(EntityMetaDataFields.ENTITY_POSE);
}
@EntityMetaDataFunction(name = "Ticks frozen")
public int getTicksFrozen() {
return this.metaData.getSets().getInt(EntityMetaDataFields.ENTITY_TICKS_FROZEN);
}
@Override
public String toString() {
if (this.information == null) {
return this.getClass().getCanonicalName();
}
return String.format("%s", this.information);
}
public String getEntityMetaDataAsString() {
return getEntityMetaDataFormatted().toString();
}
public TreeMap<String, Object> getEntityMetaDataFormatted() {
// scan all methods of current class for EntityMetaDataFunction annotation and write it into a list
TreeMap<String, Object> values = new TreeMap<>();
if (this.metaData == null) {
return values;
}
Class<?> clazz = this.getClass();
while (clazz != Object.class) {
for (Method method : clazz.getDeclaredMethods()) {
if (!method.isAnnotationPresent(EntityMetaDataFunction.class)) {
continue;
}
if (method.getParameterCount() > 0) {
continue;
}
method.setAccessible(true);
try {
String resourceLocation = method.getAnnotation(EntityMetaDataFunction.class).name();
if (values.containsKey(resourceLocation)) {
continue;
}
Object methodRetValue = method.invoke(this);
if (methodRetValue == null) {
continue;
}
values.put(resourceLocation, methodRetValue);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
clazz = clazz.getSuperclass();
}
return values;
}
public void move(Vec3 deltaPosition) {
if (!this.hasCollisions) {
this.position = new Vec3(this.position.plus(deltaPosition));
Log.debug(String.format("new Position: %s", this.position));
return;
}
AABB aabb = getAABB();
VoxelShape collisionsToCheck = getCollisionsToCheck(deltaPosition, aabb);
Vec3 realMovement = collide(deltaPosition, collisionsToCheck, aabb);
this.position = new Vec3(this.position.plus(realMovement));
}
private VoxelShape getCollisionsToCheck(Vec3 deltaPosition, AABB originalAABB) {
List<Vec3i> blockPositions = originalAABB.extend(deltaPosition).getBlockPositions();
VoxelShape result = new VoxelShape();
for (Vec3i blockPosition : blockPositions) {
BlockState blockState = this.connection.getWorld().getBlockState(blockPosition);
if (blockState == null) {
continue;
}
VoxelShape blockShape = blockState.getCollision();
result.add(blockShape.plus(blockPosition));
}
return result;
}
private Vec3 collide(Vec3 deltaPosition, VoxelShape collisionsToCheck, AABB aabb) {
Vec3 delta = new Vec3(deltaPosition);
if (deltaPosition.y != 0) {
delta.y = collisionsToCheck.computeOffset(aabb, deltaPosition.y, Axes.Y);
aabb.offsetAssign(new Vec3(0f, (float) delta.y, 0f));
}
if (deltaPosition.x != 0) {
delta.x = collisionsToCheck.computeOffset(aabb, deltaPosition.x, Axes.X);
aabb.offsetAssign(new Vec3((float) delta.x, 0f, 0f));
}
return delta;
}
private AABB getAABB() {
return DEFAULT_PLAYER_AABB.plus(this.position);
}
public boolean hasCollisions() {
return this.hasCollisions;
}
public void setHasCollisions(boolean hasCollisions) {
this.hasCollisions = hasCollisions;
}
public void setPosition(Vec3 position) {
this.position = position;
}
}

View File

@ -0,0 +1,236 @@
/*
* Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.entities.entities
import de.bixilon.minosoft.data.Axes
import de.bixilon.minosoft.data.entities.*
import de.bixilon.minosoft.data.entities.meta.EntityMetaData
import de.bixilon.minosoft.data.inventory.InventorySlots.EquipmentSlots
import de.bixilon.minosoft.data.inventory.ItemStack
import de.bixilon.minosoft.data.mappings.StatusEffect
import de.bixilon.minosoft.data.text.ChatComponent
import de.bixilon.minosoft.gui.rendering.Camera
import de.bixilon.minosoft.gui.rendering.chunk.VoxelShape
import de.bixilon.minosoft.gui.rendering.chunk.models.AABB
import de.bixilon.minosoft.protocol.network.Connection
import de.bixilon.minosoft.util.logging.Log
import glm_.vec3.Vec3
import java.lang.reflect.InvocationTargetException
import java.util.*
abstract class Entity(
protected val connection: Connection,
var position: Vec3,
var rotation: EntityRotation,
) {
val entityInformation: EntityInformation?
val equipment: MutableMap<EquipmentSlots, ItemStack> = mutableMapOf()
val effectList: MutableSet<StatusEffectInstance> = mutableSetOf()
@JvmField
protected val versionId: Int
open var attachedEntity: Int? = null
var entityMetaData: EntityMetaData = EntityMetaData(connection)
@JvmField
protected var hasCollisions = true
fun forceMove(relativePosition: Vec3) {
position = Vec3(position.x + relativePosition.x, position.y + relativePosition.y, position.z + relativePosition.z)
}
fun addEffect(effect: StatusEffectInstance) {
// effect already applied, maybe the duration or the amplifier changed?
effectList.removeIf { (statusEffect) -> statusEffect === effect.statusEffect }
effectList.add(effect)
}
fun removeEffect(effect: StatusEffect) {
effectList.removeIf { (statusEffect) -> statusEffect === effect }
}
fun attachTo(vehicleId: Int?) {
attachedEntity = vehicleId
}
fun setRotation(yaw: Int, pitch: Int) {
rotation = EntityRotation(yaw.toFloat(), pitch.toFloat(), rotation.headYaw)
}
fun setRotation(yaw: Int, pitch: Int, headYaw: Int) {
rotation = EntityRotation(yaw.toFloat(), pitch.toFloat(), headYaw.toFloat())
}
fun setHeadRotation(headYaw: Int) {
rotation = EntityRotation(rotation.yaw, rotation.pitch, headYaw.toFloat())
}
private fun getEntityFlag(bitMask: Int): Boolean {
return entityMetaData.sets.getBitMask(EntityMetaDataFields.ENTITY_FLAGS, bitMask)
}
@get:EntityMetaDataFunction(name = "On fire")
val isOnFire: Boolean
get() = getEntityFlag(0x01)
open val isCrouching: Boolean
get() = getEntityFlag(0x02)
@get:EntityMetaDataFunction(name = "Is sprinting")
val isSprinting: Boolean
get() = getEntityFlag(0x08)
val isSwimming: Boolean
get() = getEntityFlag(0x10)
@get:EntityMetaDataFunction(name = "Is invisible")
val isInvisible: Boolean
get() = getEntityFlag(0x20)
@EntityMetaDataFunction(name = "Has glowing effect")
fun hasGlowingEffect(): Boolean {
return getEntityFlag(0x20)
}
val isFlyingWithElytra: Boolean
get() = getEntityFlag(0x80)
@get:EntityMetaDataFunction(name = "Air supply")
val airSupply: Int
get() = entityMetaData.sets.getInt(EntityMetaDataFields.ENTITY_AIR_SUPPLY)
@get:EntityMetaDataFunction(name = "Custom name")
val customName: ChatComponent?
get() = entityMetaData.sets.getChatComponent(EntityMetaDataFields.ENTITY_CUSTOM_NAME)
@get:EntityMetaDataFunction(name = "Is custom name visible")
val isCustomNameVisible: Boolean
get() = entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_CUSTOM_NAME_VISIBLE)
@get:EntityMetaDataFunction(name = "Is silent")
val isSilent: Boolean
get() = entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_SILENT)
@EntityMetaDataFunction(name = "Has no gravity")
val hasNoGravity: Boolean
get() = entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_NO_GRAVITY)
@get:EntityMetaDataFunction(name = "Pose")
val pose: Poses?
get() {
return when {
isCrouching -> Poses.SNEAKING
isSwimming -> Poses.SWIMMING
isFlyingWithElytra -> Poses.FLYING
else -> entityMetaData.sets.getPose(EntityMetaDataFields.ENTITY_POSE)
}
}
@get:EntityMetaDataFunction(name = "Ticks frozen")
val ticksFrozen: Int
get() = entityMetaData.sets.getInt(EntityMetaDataFields.ENTITY_TICKS_FROZEN)
override fun toString(): String {
return entityInformation.toString()
}
val entityMetaDataAsString: String
get() = entityMetaDataFormatted.toString()
// scan all methods of current class for EntityMetaDataFunction annotation and write it into a list
val entityMetaDataFormatted: TreeMap<String, Any>
get() {
// scan all methods of current class for EntityMetaDataFunction annotation and write it into a list
val values = TreeMap<String, Any>()
var clazz: Class<*> = this.javaClass
while (clazz != Any::class.java) {
for (method in clazz.declaredMethods) {
if (!method.isAnnotationPresent(EntityMetaDataFunction::class.java)) {
continue
}
if (method.parameterCount > 0) {
continue
}
method.isAccessible = true
try {
val resourceLocation: String = method.getAnnotation(EntityMetaDataFunction::class.java).name
if (values.containsKey(resourceLocation)) {
continue
}
val methodRetValue = method.invoke(this) ?: continue
values[resourceLocation] = methodRetValue
} catch (e: IllegalAccessException) {
e.printStackTrace()
} catch (e: InvocationTargetException) {
e.printStackTrace()
}
}
clazz = clazz.superclass
}
return values
}
fun move(deltaPosition: Vec3) {
if (!hasCollisions) {
position = Vec3(position + deltaPosition)
Log.debug("New Position: $position")
return
}
val aabb = aabb
val collisionsToCheck = getCollisionsToCheck(deltaPosition, aabb)
val realMovement = collide(deltaPosition, collisionsToCheck, aabb)
position = Vec3(position + realMovement)
}
private fun getCollisionsToCheck(deltaPosition: Vec3, originalAABB: AABB): VoxelShape {
val blockPositions = (originalAABB extend deltaPosition).getBlockPositions()
val result = VoxelShape()
for (blockPosition in blockPositions) {
val blockState = connection.world.getBlockState(blockPosition) ?: continue
result.add(blockState.collisionShape + blockPosition)
}
return result
}
private fun collide(deltaPosition: Vec3, collisionsToCheck: VoxelShape, aabb: AABB): Vec3 {
val delta = Vec3(deltaPosition)
if (deltaPosition.y != 0.0f) {
delta.y = collisionsToCheck.computeOffset(aabb, deltaPosition.y, Axes.Y)
aabb.offsetAssign(Vec3(0f, delta.y, 0f))
}
if (deltaPosition.x != 0.0f) {
delta.x = collisionsToCheck.computeOffset(aabb, deltaPosition.x, Axes.X)
aabb.offsetAssign(Vec3(delta.x, 0f, 0f))
}
return delta
}
private val aabb: AABB
get() = DEFAULT_PLAYER_AABB + position
fun hasCollisions(): Boolean {
return hasCollisions
}
companion object {
private val DEFAULT_PLAYER_AABB = AABB(
Vec3(-Camera.PLAYER_WIDTH / 2, 0, -Camera.PLAYER_WIDTH / 2),
Vec3(Camera.PLAYER_WIDTH / 2, 1.8, Camera.PLAYER_WIDTH / 2)
)
}
init {
entityInformation = connection.mapping.getEntityInformation(javaClass)
versionId = connection.version.versionId
}
}

View File

@ -29,7 +29,7 @@ public abstract class LivingEntity extends Entity {
}
private boolean getLivingEntityFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.LIVING_ENTITY_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.LIVING_ENTITY_FLAGS, bitMask);
}
// = isUsingItem
@ -50,33 +50,33 @@ public abstract class LivingEntity extends Entity {
@EntityMetaDataFunction(name = "Health")
public float getHealth() {
return this.metaData.getSets().getFloat(EntityMetaDataFields.LIVING_ENTITY_HEALTH);
return getEntityMetaData().getSets().getFloat(EntityMetaDataFields.LIVING_ENTITY_HEALTH);
}
@EntityMetaDataFunction(name = "Effect color")
public int getEffectColor() {
return this.metaData.getSets().getInt(EntityMetaDataFields.LIVING_ENTITY_EFFECT_COLOR);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.LIVING_ENTITY_EFFECT_COLOR);
}
@EntityMetaDataFunction(name = "Is effect ambient")
public boolean getEffectAmbient() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.LIVING_ENTITY_EFFECT_AMBIENCE);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.LIVING_ENTITY_EFFECT_AMBIENCE);
}
@EntityMetaDataFunction(name = "Arrows in entity")
public int getArrowCount() {
return this.metaData.getSets().getInt(EntityMetaDataFields.LIVING_ENTITY_ARROW_COUNT);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.LIVING_ENTITY_ARROW_COUNT);
}
@EntityMetaDataFunction(name = "Absorption hearts")
public int getAbsorptionHearts() {
return this.metaData.getSets().getInt(EntityMetaDataFields.LIVING_ENTITY_ABSORPTION_HEARTS);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.LIVING_ENTITY_ABSORPTION_HEARTS);
}
@EntityMetaDataFunction(name = "Bed location")
@Nullable
public Vec3i getBedPosition() {
return this.metaData.getSets().getBlockPosition(EntityMetaDataFields.LIVING_ENTITY_BED_POSITION);
return getEntityMetaData().getSets().getBlockPosition(EntityMetaDataFields.LIVING_ENTITY_BED_POSITION);
}
}

View File

@ -24,7 +24,7 @@ public abstract class Mob extends LivingEntity {
}
private boolean getMobFlags(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.MOB_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.MOB_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "isNoAI")

View File

@ -28,7 +28,7 @@ public abstract class TamableAnimal extends Animal {
}
private boolean getTameableFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.TAMABLE_ENTITY_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.TAMABLE_ENTITY_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is sitting")
@ -44,6 +44,6 @@ public abstract class TamableAnimal extends Animal {
@EntityMetaDataFunction(name = "Owner UUID")
@Nullable
public UUID getOwner() {
return this.metaData.getSets().getUUID(EntityMetaDataFields.TAMABLE_ENTITY_OWNER_UUID);
return getEntityMetaData().getSets().getUUID(EntityMetaDataFields.TAMABLE_ENTITY_OWNER_UUID);
}
}

View File

@ -26,7 +26,7 @@ public class Bat extends AmbientCreature {
}
private boolean getBatFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.BAT_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.BAT_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Hanging")

View File

@ -27,17 +27,17 @@ public class Axolotl extends Animal {
@EntityMetaDataFunction(name = "Axolotl variant")
public AxolotlVariants getVariant() {
return AxolotlVariants.byId(this.metaData.getSets().getInt(EntityMetaDataFields.AXOLOTL_VARIANT));
return AxolotlVariants.byId(getEntityMetaData().getSets().getInt(EntityMetaDataFields.AXOLOTL_VARIANT));
}
@EntityMetaDataFunction(name = "Is playing dead")
public boolean isPlayingDead() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.AXOLOTL_PLAYING_DEAD);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.AXOLOTL_PLAYING_DEAD);
}
@EntityMetaDataFunction(name = "Is from bucket")
public boolean isFromBucket() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.AXOLOTL_FROM_BUCKET);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.AXOLOTL_FROM_BUCKET);
}
public enum AxolotlVariants {

View File

@ -26,7 +26,7 @@ public class Bee extends Animal {
}
private boolean getBeeFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.BEE_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.BEE_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is angry")
@ -46,6 +46,6 @@ public class Bee extends Animal {
@EntityMetaDataFunction(name = "Remaining angar time")
public int getRemainingAngerTimer() {
return this.metaData.getSets().getInt(EntityMetaDataFields.BEE_REMAINING_ANGER_TIME);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.BEE_REMAINING_ANGER_TIME);
}
}

View File

@ -30,22 +30,22 @@ public class Cat extends TamableAnimal {
@EntityMetaDataFunction(name = "Variant")
public CatVariants getVariant() {
return CatVariants.byId(this.metaData.getSets().getInt(EntityMetaDataFields.CAT_VARIANT));
return CatVariants.byId(getEntityMetaData().getSets().getInt(EntityMetaDataFields.CAT_VARIANT));
}
@EntityMetaDataFunction(name = "Lying")
public boolean isLying() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.CAT_IS_LYING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.CAT_IS_LYING);
}
@EntityMetaDataFunction(name = "Relaxed")
public boolean isRelaxed() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.CAT_IS_RELAXED);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.CAT_IS_RELAXED);
}
@EntityMetaDataFunction(name = "Collar color")
public RGBColor getCollarColor() {
return ChatColors.getColorById(this.metaData.getSets().getInt(EntityMetaDataFields.CAT_GET_COLLAR_COLOR));
return ChatColors.getColorById(getEntityMetaData().getSets().getInt(EntityMetaDataFields.CAT_GET_COLLAR_COLOR));
}
public enum CatVariants {

View File

@ -30,11 +30,11 @@ public class Fox extends Animal {
@EntityMetaDataFunction(name = "Variant")
public int getVariant() {
return this.metaData.getSets().getInt(EntityMetaDataFields.FOX_VARIANT);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.FOX_VARIANT);
}
private boolean getFoxFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.FOX_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.FOX_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is sitting")
@ -75,12 +75,12 @@ public class Fox extends Animal {
@EntityMetaDataFunction(name = "Trusted 1")
@Nullable
public UUID getFirstTrusted() {
return this.metaData.getSets().getUUID(EntityMetaDataFields.FOX_TRUSTED_1);
return getEntityMetaData().getSets().getUUID(EntityMetaDataFields.FOX_TRUSTED_1);
}
@EntityMetaDataFunction(name = "Trusted 2")
@Nullable
public UUID getSecondTrusted() {
return this.metaData.getSets().getUUID(EntityMetaDataFields.FOX_TRUSTED_2);
return getEntityMetaData().getSets().getUUID(EntityMetaDataFields.FOX_TRUSTED_2);
}
}

View File

@ -26,7 +26,7 @@ public class IronGolem extends AbstractGolem {
}
private boolean getIronGolemFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.IRON_GOLEM_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.IRON_GOLEM_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is player created")

View File

@ -27,6 +27,6 @@ public class Mooshroom extends Cow {
@EntityMetaDataFunction(name = "Variant")
public String getVariant() {
return this.metaData.getSets().getString(EntityMetaDataFields.MOOSHROOM_VARIANT);
return getEntityMetaData().getSets().getString(EntityMetaDataFields.MOOSHROOM_VARIANT);
}
}

View File

@ -27,6 +27,6 @@ public class Ocelot extends Animal {
@EntityMetaDataFunction(name = "Trusting")
public boolean isTrusting() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.OCELOT_IS_TRUSTING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.OCELOT_IS_TRUSTING);
}
}

View File

@ -27,31 +27,31 @@ public class Panda extends Animal {
@EntityMetaDataFunction(name = "Unhappy timer")
public int getUnhappyTimer() {
return this.metaData.getSets().getInt(EntityMetaDataFields.PANDA_UNHAPPY_TIMER);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.PANDA_UNHAPPY_TIMER);
}
@EntityMetaDataFunction(name = "Sneeze timer")
public int getSneezeTimer() {
return this.metaData.getSets().getInt(EntityMetaDataFields.PANDA_SNEEZE_TIMER);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.PANDA_SNEEZE_TIMER);
}
@EntityMetaDataFunction(name = "Eat timer")
public int getEatTimer() {
return this.metaData.getSets().getInt(EntityMetaDataFields.PANDA_EAT_TIMER);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.PANDA_EAT_TIMER);
}
@EntityMetaDataFunction(name = "Main gene")
public Genes getMainGene() {
return Genes.byId(this.metaData.getSets().getInt(EntityMetaDataFields.PANDA_MAIN_GENE));
return Genes.byId(getEntityMetaData().getSets().getInt(EntityMetaDataFields.PANDA_MAIN_GENE));
}
@EntityMetaDataFunction(name = "Hidden gene")
public Genes getHiddenGene() {
return Genes.byId(this.metaData.getSets().getInt(EntityMetaDataFields.PANDA_HIDDEN_GAME));
return Genes.byId(getEntityMetaData().getSets().getInt(EntityMetaDataFields.PANDA_HIDDEN_GAME));
}
private boolean getPandaFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.PANDA_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.PANDA_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is sneezing")

View File

@ -27,7 +27,7 @@ public class Parrot extends ShoulderRidingAnimal {
@EntityMetaDataFunction(name = "Variant")
public ParrotVariants getVariant() {
return ParrotVariants.byId(this.metaData.getSets().getInt(EntityMetaDataFields.PARROT_VARIANT));
return ParrotVariants.byId(getEntityMetaData().getSets().getInt(EntityMetaDataFields.PARROT_VARIANT));
}
public enum ParrotVariants {

View File

@ -27,11 +27,11 @@ public class Pig extends Animal {
@EntityMetaDataFunction(name = "Has saddle")
public boolean hasSaddle() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.PIG_HAS_SADDLE);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.PIG_HAS_SADDLE);
}
@EntityMetaDataFunction(name = "Boost time")
public int getBoostTime() {
return this.metaData.getSets().getInt(EntityMetaDataFields.PIG_BOOST_TIME);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.PIG_BOOST_TIME);
}
}

View File

@ -27,6 +27,6 @@ public class PolarBear extends Animal {
@EntityMetaDataFunction(name = "Is standing")
public boolean isStanding() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.POLAR_BEAR_STANDING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.POLAR_BEAR_STANDING);
}
}

View File

@ -27,6 +27,6 @@ public class Rabbit extends Animal {
@EntityMetaDataFunction(name = "Variant")
public int getVariant() {
return this.metaData.getSets().getInt(EntityMetaDataFields.RABBIT_VARIANT);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.RABBIT_VARIANT);
}
}

View File

@ -29,11 +29,11 @@ public class Sheep extends Animal {
@EntityMetaDataFunction(name = "Color")
private RGBColor getColor() {
return ChatColors.getColorById(this.metaData.getSets().getByte(EntityMetaDataFields.SHEEP_FLAGS) & 0xF);
return ChatColors.getColorById(getEntityMetaData().getSets().getByte(EntityMetaDataFields.SHEEP_FLAGS) & 0xF);
}
@EntityMetaDataFunction(name = "Is sheared")
private boolean isSheared() {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.SHEEP_FLAGS, 0x10);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.SHEEP_FLAGS, 0x10);
}
}

View File

@ -26,7 +26,7 @@ public class SnowGolem extends AbstractGolem {
}
private boolean getPumpkinFlags(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.SNOW_GOLEM_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.SNOW_GOLEM_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Pumpkin hat")

View File

@ -27,16 +27,16 @@ public class Strider extends Animal {
@EntityMetaDataFunction(name = "Boost stime")
private int getBoostTime() {
return this.metaData.getSets().getInt(EntityMetaDataFields.STRIDER_TIME_TO_BOOST);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.STRIDER_TIME_TO_BOOST);
}
@EntityMetaDataFunction(name = "Is suffocating")
private boolean isSuffocating() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.STRIDER_IS_SUFFOCATING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.STRIDER_IS_SUFFOCATING);
}
@EntityMetaDataFunction(name = "Has saddle")
private boolean hasSaddle() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.STRIDER_HAS_SADDLE);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.STRIDER_HAS_SADDLE);
}
}

View File

@ -31,32 +31,32 @@ public class Turtle extends Animal {
@EntityMetaDataFunction(name = "Home Position")
@Nullable
public Vec3i getHomePosition() {
return this.metaData.getSets().getBlockPosition(EntityMetaDataFields.TURTLE_HOME_POSITION);
return getEntityMetaData().getSets().getBlockPosition(EntityMetaDataFields.TURTLE_HOME_POSITION);
}
@EntityMetaDataFunction(name = "Has egg")
public boolean hasEgg() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.TURTLE_HAS_EGG);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.TURTLE_HAS_EGG);
}
@EntityMetaDataFunction(name = "Is laying egg")
public boolean isLayingEgg() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.TURTLE_IS_LAYING_EGG);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.TURTLE_IS_LAYING_EGG);
}
@EntityMetaDataFunction(name = "Travel position")
@Nullable
public Vec3i getTravelPosition() {
return this.metaData.getSets().getBlockPosition(EntityMetaDataFields.TURTLE_TRAVEL_POSITION);
return getEntityMetaData().getSets().getBlockPosition(EntityMetaDataFields.TURTLE_TRAVEL_POSITION);
}
@EntityMetaDataFunction(name = "Is going home")
public boolean isGoingHome() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.TURTLE_IS_GOING_HOME);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.TURTLE_IS_GOING_HOME);
}
@EntityMetaDataFunction(name = "Is traveling")
public boolean isTraveling() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.TURTLE_IS_TRAVELING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.TURTLE_IS_TRAVELING);
}
}

View File

@ -33,20 +33,20 @@ public class Wolf extends TamableAnimal {
@EntityMetaDataFunction(name = "Is beging")
public boolean isBegging() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.WOLF_IS_BEGGING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.WOLF_IS_BEGGING);
}
@EntityMetaDataFunction(name = "Collar color")
public RGBColor getCollarColor() {
return ChatColors.getColorById(this.metaData.getSets().getInt(EntityMetaDataFields.WOLF_COLLAR_COLOR));
return ChatColors.getColorById(getEntityMetaData().getSets().getInt(EntityMetaDataFields.WOLF_COLLAR_COLOR));
}
@EntityMetaDataFunction(name = "Anger time")
public int getAngerTime() {
if (this.versionId <= V_1_8_9) {// ToDo
return this.metaData.getSets().getBitMask(EntityMetaDataFields.TAMABLE_ENTITY_FLAGS, 0x02) ? 1 : 0;
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.TAMABLE_ENTITY_FLAGS, 0x02) ? 1 : 0;
}
return this.metaData.getSets().getInt(EntityMetaDataFields.WOLF_ANGER_TIME);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.WOLF_ANGER_TIME);
}
@EntityMetaDataFunction(name = "Health")
@ -55,6 +55,6 @@ public class Wolf extends TamableAnimal {
if (this.versionId > V_19W45B) {
return super.getHealth();
}
return this.metaData.getSets().getFloat(EntityMetaDataFields.WOLF_HEALTH);
return getEntityMetaData().getSets().getFloat(EntityMetaDataFields.WOLF_HEALTH);
}
}

View File

@ -28,6 +28,6 @@ public class Hoglin extends Animal {
@EntityMetaDataFunction(name = "Immune zo zombification")
public boolean isImmuneToZombification() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.HOGLIN_IMMUNE_TO_ZOMBIFICATION);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.HOGLIN_IMMUNE_TO_ZOMBIFICATION);
}
}

View File

@ -27,6 +27,6 @@ public abstract class AbstractChestedHorse extends AbstractHorse {
@EntityMetaDataFunction(name = "Has chest")
public boolean hasChest() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ABSTRACT_CHESTED_HORSE_HAS_CHEST);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.ABSTRACT_CHESTED_HORSE_HAS_CHEST);
}
}

View File

@ -30,7 +30,7 @@ public abstract class AbstractHorse extends Animal {
}
private boolean getAbstractHorseFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.ABSTRACT_HORSE_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.ABSTRACT_HORSE_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is tame")
@ -66,6 +66,6 @@ public abstract class AbstractHorse extends Animal {
@EntityMetaDataFunction(name = "Owner UUID")
@Nullable
public UUID getOwner() {
return this.metaData.getSets().getUUID(EntityMetaDataFields.ABSTRACT_HORSE_OWNER_UUID);
return getEntityMetaData().getSets().getUUID(EntityMetaDataFields.ABSTRACT_HORSE_OWNER_UUID);
}
}

View File

@ -24,11 +24,11 @@ import glm_.vec3.Vec3
class Horse(connection: Connection, location: Vec3, rotation: EntityRotation) : AbstractHorse(connection, location, rotation) {
private fun getAbstractHorseFlag(bitMask: Int): Boolean {
return metaData.sets.getBitMask(EntityMetaDataFields.ABSTRACT_HORSE_FLAGS, bitMask)
return entityMetaData.sets.getBitMask(EntityMetaDataFields.ABSTRACT_HORSE_FLAGS, bitMask)
}
private val variant: Int
get() = metaData.sets.getInt(EntityMetaDataFields.HORSE_VARIANT)
get() = entityMetaData.sets.getInt(EntityMetaDataFields.HORSE_VARIANT)
@get:EntityMetaDataFunction(name = "Color")
val color: HorseColors
@ -45,7 +45,7 @@ class Horse(connection: Connection, location: Vec3, rotation: EntityRotation) :
if (versionId <= ProtocolVersions.V_1_8_9) { // ToDo
return null
}
return connection.mapping.itemRegistry.get(when (this.metaData.sets.getInt(EntityMetaDataFields.LEGACY_HORSE_ARMOR)) {
return connection.mapping.itemRegistry.get(when (this.entityMetaData.sets.getInt(EntityMetaDataFields.LEGACY_HORSE_ARMOR)) {
1 -> LEGACY_IRON_ARMOR
2 -> LEGACY_GOLD_ARMOR
3 -> LEGACY_DIAMOND_ARMOR

View File

@ -27,16 +27,16 @@ public class Llama extends AbstractChestedHorse {
@EntityMetaDataFunction(name = "Strength")
public int getStrength() {
return this.metaData.getSets().getInt(EntityMetaDataFields.LLAMA_STRENGTH);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.LLAMA_STRENGTH);
}
@EntityMetaDataFunction(name = "CarpetColor")
public int getCarpetColor() {
return this.metaData.getSets().getInt(EntityMetaDataFields.LLAMA_CARPET_COLOR);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.LLAMA_CARPET_COLOR);
}
@EntityMetaDataFunction(name = "Variant")
public int getVariant() {
return this.metaData.getSets().getInt(EntityMetaDataFields.LLAMA_VARIANT);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.LLAMA_VARIANT);
}
}

View File

@ -27,7 +27,7 @@ public abstract class AbstractFish extends WaterAnimal {
@EntityMetaDataFunction(name = "Is from bucket")
public boolean isFromBucket() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ABSTRACT_FISH_FROM_BUCKET);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.ABSTRACT_FISH_FROM_BUCKET);
}
}

View File

@ -31,17 +31,17 @@ public class Dolphin extends WaterAnimal {
@EntityMetaDataFunction(name = "Treasure position")
@Nullable
public Vec3i getTreasurePosition() {
return this.metaData.getSets().getBlockPosition(EntityMetaDataFields.DOLPHIN_TREASURE_POSITION);
return getEntityMetaData().getSets().getBlockPosition(EntityMetaDataFields.DOLPHIN_TREASURE_POSITION);
}
@EntityMetaDataFunction(name = "Has fish")
public boolean hasFish() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.DOLPHIN_HAS_FISH);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.DOLPHIN_HAS_FISH);
}
@EntityMetaDataFunction(name = "Moistness level")
public int getMoistnessLevel() {
return this.metaData.getSets().getInt(EntityMetaDataFields.DOLPHIN_MOISTNESS_LEVEL);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.DOLPHIN_MOISTNESS_LEVEL);
}
}

View File

@ -27,7 +27,7 @@ public class GlowSquid extends Squid {
@EntityMetaDataFunction(name = "Dark ticks remaining")
public int getDarkTicksRemaining() {
return this.metaData.getSets().getInt(EntityMetaDataFields.GLOW_SQUID_DARK_TICKS_REMAINING);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.GLOW_SQUID_DARK_TICKS_REMAINING);
}
}

View File

@ -27,6 +27,6 @@ public class PufferFish extends AbstractFish {
@EntityMetaDataFunction(name = "Puff state")
public int getPuffState() {
return this.metaData.getSets().getInt(EntityMetaDataFields.PUFFERFISH_PUFF_STATE);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.PUFFERFISH_PUFF_STATE);
}
}

View File

@ -27,6 +27,6 @@ public class TropicalFish extends AbstractSchoolingFish {
@EntityMetaDataFunction(name = "Variant")
public int getVariant() {
return this.metaData.getSets().getInt(EntityMetaDataFields.TROPICAL_FISH_VARIANT);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.TROPICAL_FISH_VARIANT);
}
}

View File

@ -32,12 +32,12 @@ public class EndCrystal extends Entity {
@EntityMetaDataFunction(name = "Beam target")
@Nullable
public Vec3i getBeamTarget() {
return getMetaData().getSets().getBlockPosition(EntityMetaDataFields.END_CRYSTAL_BEAM_TARGET);
return getEntityMetaData().getSets().getBlockPosition(EntityMetaDataFields.END_CRYSTAL_BEAM_TARGET);
}
@EntityMetaDataFunction(name = "Show bottom")
public boolean shotBottom() {
return getMetaData().getSets().getBoolean(EntityMetaDataFields.END_CRYSTAL_SHOW_BOTTOM);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.END_CRYSTAL_SHOW_BOTTOM);
}
}

View File

@ -28,7 +28,7 @@ public class EnderDragon extends Mob {
@EntityMetaDataFunction(name = "Phase")
public DragonPhases getPhase() {
return DragonPhases.byId(this.metaData.getSets().getInt(EntityMetaDataFields.ENDER_DRAGON_PHASE));
return DragonPhases.byId(getEntityMetaData().getSets().getInt(EntityMetaDataFields.ENDER_DRAGON_PHASE));
}
public enum DragonPhases {

View File

@ -28,21 +28,21 @@ public class WitherBoss extends Monster {
@EntityMetaDataFunction(name = "Center head target entity id")
public int getCenterHeadTargetEntityId() {
return this.metaData.getSets().getInt(EntityMetaDataFields.WITHER_BOSS_CENTER_HEAD_TARGET_ENTITY_ID);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.WITHER_BOSS_CENTER_HEAD_TARGET_ENTITY_ID);
}
@EntityMetaDataFunction(name = "Left head target entity id")
public int getLeftHeadTargetEntityId() {
return this.metaData.getSets().getInt(EntityMetaDataFields.WITHER_BOSS_LEFT_HEAD_TARGET_ENTITY_ID);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.WITHER_BOSS_LEFT_HEAD_TARGET_ENTITY_ID);
}
@EntityMetaDataFunction(name = "Right head target entity id")
public int getRightHeadTargetEntityId() {
return this.metaData.getSets().getInt(EntityMetaDataFields.WITHER_BOSS_RIGHT_HEAD_TARGET_ENTITY_ID);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.WITHER_BOSS_RIGHT_HEAD_TARGET_ENTITY_ID);
}
@EntityMetaDataFunction(name = "Invulnerable time")
public int getInvulnerableTime() {
return this.metaData.getSets().getInt(EntityMetaDataFields.WITHER_BOSS_INVULNERABLE_TIME);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.WITHER_BOSS_INVULNERABLE_TIME);
}
}

View File

@ -27,7 +27,7 @@ public class ArmorStand extends LivingEntity {
}
private boolean getArmorStandFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.ARMOR_STAND_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.ARMOR_STAND_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is small")
@ -52,32 +52,32 @@ public class ArmorStand extends LivingEntity {
@EntityMetaDataFunction(name = "Head rotation")
public EntityRotation getHeadRotation() {
return this.metaData.getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_HEAD_ROTATION);
return getEntityMetaData().getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_HEAD_ROTATION);
}
@EntityMetaDataFunction(name = "Body rotation")
public EntityRotation getBodyRotation() {
return this.metaData.getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_BODY_ROTATION);
return getEntityMetaData().getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_BODY_ROTATION);
}
@EntityMetaDataFunction(name = "Left arm rotation")
public EntityRotation getLeftArmRotation() {
return this.metaData.getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_LEFT_ARM_ROTATION);
return getEntityMetaData().getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_LEFT_ARM_ROTATION);
}
@EntityMetaDataFunction(name = "Right arm rotation")
public EntityRotation getRightArmRotation() {
return this.metaData.getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_RIGHT_ARM_ROTATION);
return getEntityMetaData().getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_RIGHT_ARM_ROTATION);
}
@EntityMetaDataFunction(name = "Left leg rotation")
public EntityRotation getLeftLegRotation() {
return this.metaData.getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_LEFT_LAG_ROTATION);
return getEntityMetaData().getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_LEFT_LAG_ROTATION);
}
@EntityMetaDataFunction(name = "Right leg rotation")
public EntityRotation getRightLegRotation() {
return this.metaData.getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_RIGHT_LAG_ROTATION);
return getEntityMetaData().getSets().getRotation(EntityMetaDataFields.ARMOR_STAND_RIGHT_LAG_ROTATION);
}
}

View File

@ -31,12 +31,12 @@ public class ItemFrame extends HangingEntity {
@EntityMetaDataFunction(name = "Item")
@Nullable
public ItemStack getItem() {
return this.metaData.getSets().getItemStack(EntityMetaDataFields.ITEM_FRAME_ITEM);
return getEntityMetaData().getSets().getItemStack(EntityMetaDataFields.ITEM_FRAME_ITEM);
}
@EntityMetaDataFunction(name = "Item rotation level")
public int getItemRotation() {
return this.metaData.getSets().getInt(EntityMetaDataFields.ITEM_FRAME_ROTATION);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.ITEM_FRAME_ROTATION);
}
}

View File

@ -32,7 +32,7 @@ public class FallingBlock extends Entity {
@EntityMetaDataFunction(name = "Spawn position")
@Nullable
public Vec3i getSpawnPosition() {
return getMetaData().getSets().getBlockPosition(EntityMetaDataFields.FALLING_BLOCK_SPAWN_POSITION);
return getEntityMetaData().getSets().getBlockPosition(EntityMetaDataFields.FALLING_BLOCK_SPAWN_POSITION);
}
}

View File

@ -32,7 +32,7 @@ public class ItemEntity extends Entity {
@EntityMetaDataFunction(name = "Item")
@Nullable
public ItemStack getItem() {
return this.metaData.getSets().getItemStack(EntityMetaDataFields.ITEM_ITEM);
return getEntityMetaData().getSets().getItemStack(EntityMetaDataFields.ITEM_ITEM);
}
}

View File

@ -28,6 +28,6 @@ public class PrimedTNT extends Entity {
@EntityMetaDataFunction(name = "Fuse time")
public int getFuseTime() {
return this.metaData.getSets().getInt(EntityMetaDataFields.PRIMED_TNT_FUSE_TIME);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.PRIMED_TNT_FUSE_TIME);
}
}

View File

@ -26,7 +26,7 @@ public class Blaze extends Monster {
}
private boolean getBlazeFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.BLAZE_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.BLAZE_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is Burning")

View File

@ -27,16 +27,16 @@ public class Creeper extends Monster {
@EntityMetaDataFunction(name = "State")
public int getState() {
return this.metaData.getSets().getInt(EntityMetaDataFields.CREEPER_STATE);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.CREEPER_STATE);
}
@EntityMetaDataFunction(name = "Is charged")
public boolean isCharged() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.CREEPER_IS_CHARGED);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.CREEPER_IS_CHARGED);
}
@EntityMetaDataFunction(name = "Is ignited")
public boolean isIgnited() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.CREEPER_IS_IGNITED);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.CREEPER_IS_IGNITED);
}
}

View File

@ -34,18 +34,18 @@ public class Enderman extends AbstractSkeleton {
@Nullable
public BlockState getCarriedBlock() {
if (this.versionId <= V_1_8_9) { // ToDo: No clue here
return this.connection.getMapping().getBlockState(this.metaData.getSets().getInt(EntityMetaDataFields.LEGACY_ENDERMAN_CARRIED_BLOCK) << 4 | this.metaData.getSets().getInt(EntityMetaDataFields.LEGACY_ENDERMAN_CARRIED_BLOCK_DATA));
return this.getConnection().getMapping().getBlockState(getEntityMetaData().getSets().getInt(EntityMetaDataFields.LEGACY_ENDERMAN_CARRIED_BLOCK) << 4 | getEntityMetaData().getSets().getInt(EntityMetaDataFields.LEGACY_ENDERMAN_CARRIED_BLOCK_DATA));
}
return this.metaData.getSets().getBlock(EntityMetaDataFields.ENDERMAN_CARRIED_BLOCK);
return getEntityMetaData().getSets().getBlock(EntityMetaDataFields.ENDERMAN_CARRIED_BLOCK);
}
@EntityMetaDataFunction(name = "Is screaming")
public boolean isScreaming() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ENDERMAN_IS_SCREAMING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.ENDERMAN_IS_SCREAMING);
}
@EntityMetaDataFunction(name = "Is starring")
public boolean isStarring() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ENDERMAN_IS_STARRING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.ENDERMAN_IS_STARRING);
}
}

View File

@ -28,6 +28,6 @@ public class Ghast extends FlyingMob {
@EntityMetaDataFunction(name = "Is attacking")
public boolean isAttacking() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.GHAST_IS_ATTACKING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.GHAST_IS_ATTACKING);
}
}

View File

@ -27,11 +27,11 @@ public class Guardian extends Monster {
@EntityMetaDataFunction(name = "Is moving")
public boolean isMoving() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.GUARDIAN_IS_MOVING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.GUARDIAN_IS_MOVING);
}
@EntityMetaDataFunction(name = "Attacked entity id")
public int getAttackEntityId() {
return this.metaData.getSets().getInt(EntityMetaDataFields.GUARDIAN_TARGET_ENTITY_ID);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.GUARDIAN_TARGET_ENTITY_ID);
}
}

View File

@ -28,6 +28,6 @@ public class Phantom extends FlyingMob {
@EntityMetaDataFunction(name = "Size")
public int getSize() {
return this.metaData.getSets().getInt(EntityMetaDataFields.PHANTOM_SIZE);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.PHANTOM_SIZE);
}
}

View File

@ -34,22 +34,22 @@ public class Shulker extends AbstractGolem {
@EntityMetaDataFunction(name = "Attachment face")
public Directions getAttachmentFace() {
return this.metaData.getSets().getDirection(EntityMetaDataFields.SHULKER_ATTACH_FACE);
return getEntityMetaData().getSets().getDirection(EntityMetaDataFields.SHULKER_ATTACH_FACE);
}
@EntityMetaDataFunction(name = "Attachment position")
@Nullable
public Vec3i getAttachmentPosition() {
return this.metaData.getSets().getBlockPosition(EntityMetaDataFields.SHULKER_ATTACHMENT_POSITION);
return getEntityMetaData().getSets().getBlockPosition(EntityMetaDataFields.SHULKER_ATTACHMENT_POSITION);
}
@EntityMetaDataFunction(name = "Peek")
public byte getPeek() {
return this.metaData.getSets().getByte(EntityMetaDataFields.SHULKER_PEEK);
return getEntityMetaData().getSets().getByte(EntityMetaDataFields.SHULKER_PEEK);
}
@EntityMetaDataFunction(name = "Color")
public RGBColor getColor() {
return ChatColors.getColorById(this.metaData.getSets().getByte(EntityMetaDataFields.SHULKER_COLOR));
return ChatColors.getColorById(getEntityMetaData().getSets().getByte(EntityMetaDataFields.SHULKER_COLOR));
}
}

View File

@ -25,6 +25,6 @@ public class Skeleton extends AbstractSkeleton {
}
public boolean isFreezeConverting() {
return this.metaData.getSets().get(EntityMetaDataFields.SKELETON_STRAY_FREEZE_CONVERTING);
return getEntityMetaData().getSets().get(EntityMetaDataFields.SKELETON_STRAY_FREEZE_CONVERTING);
}
}

View File

@ -30,6 +30,6 @@ public class Slime extends Mob {
@IntRange(from = 0)
@EntityMetaDataFunction(name = "Size")
public int getSize() {
return this.metaData.getSets().getInt(EntityMetaDataFields.SLIME_SIZE);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.SLIME_SIZE);
}
}

View File

@ -26,7 +26,7 @@ public class Spider extends Monster {
}
private boolean getSpiderFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.SPIDER_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.SPIDER_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is climbing")

View File

@ -26,7 +26,7 @@ public class Vex extends Monster {
}
private boolean getVexFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.VEX_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.VEX_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is attacking")

View File

@ -27,6 +27,6 @@ public class Zoglin extends Monster {
@EntityMetaDataFunction(name = "Is baby")
public boolean isBaby() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ZOGLIN_IS_BABY);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.ZOGLIN_IS_BABY);
}
}

View File

@ -27,17 +27,17 @@ public class Zombie extends Monster {
@EntityMetaDataFunction(name = "Is baby")
public boolean isBaby() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ZOMBIE_IS_BABY);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.ZOMBIE_IS_BABY);
}
@EntityMetaDataFunction(name = "Special type")
public int getSpecialType() {
return this.metaData.getSets().getInt(EntityMetaDataFields.ZOMBIE_SPECIAL_TYPE);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.ZOMBIE_SPECIAL_TYPE);
}
@EntityMetaDataFunction(name = "Is converting to drowned")
public boolean isConvertingToDrowned() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ZOMBIE_DROWNING_CONVERSION);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.ZOMBIE_DROWNING_CONVERSION);
}
}

View File

@ -28,12 +28,12 @@ public class ZombieVillager extends Zombie {
@EntityMetaDataFunction(name = "Is converting")
public boolean isConverting() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ZOMBIE_VILLAGER_IS_CONVERTING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.ZOMBIE_VILLAGER_IS_CONVERTING);
}
@EntityMetaDataFunction(name = "Villager data")
public VillagerData getVillagerData() {
return this.metaData.getSets().getVillagerData(EntityMetaDataFields.ZOMBIE_VILLAGER_DATA);
return getEntityMetaData().getSets().getVillagerData(EntityMetaDataFields.ZOMBIE_VILLAGER_DATA);
}
}

View File

@ -28,7 +28,7 @@ public abstract class AbstractPiglin extends Monster {
@EntityMetaDataFunction(name = "Is immune to zombification")
public boolean isImmuneToZombification() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.ABSTRACT_PIGLIN_IMMUNE_TO_ZOMBIFICATION);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.ABSTRACT_PIGLIN_IMMUNE_TO_ZOMBIFICATION);
}
}

View File

@ -33,22 +33,22 @@ public class Piglin extends AbstractPiglin {
if (this.versionId < V_20W27A) {
return super.isImmuneToZombification();
}
return this.metaData.getSets().getBoolean(EntityMetaDataFields.PIGLIN_IMMUNE_TO_ZOMBIFICATION);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.PIGLIN_IMMUNE_TO_ZOMBIFICATION);
}
@EntityMetaDataFunction(name = "Is baby")
public boolean isBaby() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.PIGLIN_IS_BABY);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.PIGLIN_IS_BABY);
}
@EntityMetaDataFunction(name = "Is charging crossbow")
public boolean isChargingCrossbow() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.PIGLIN_IS_CHARGING_CROSSBOW);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.PIGLIN_IS_CHARGING_CROSSBOW);
}
@EntityMetaDataFunction(name = "Is dancing")
public boolean isDancing() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.PIGLIN_IS_DANCING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.PIGLIN_IS_DANCING);
}
}

View File

@ -27,6 +27,6 @@ public class Pillager extends AbstractIllager {
@EntityMetaDataFunction(name = "Is charging crossbow")
public boolean isChargingCrossbow() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.PILLAGER_IS_CHARGING_CROSSBOW);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.PILLAGER_IS_CHARGING_CROSSBOW);
}
}

View File

@ -28,6 +28,6 @@ public abstract class Raider extends PatrollingMonster {
@EntityMetaDataFunction(name = "Is celebrating")
public boolean isCelebrating() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.RAIDER_IS_CELEBRATING);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.RAIDER_IS_CELEBRATING);
}
}

View File

@ -27,7 +27,7 @@ public class SpellcasterIllager extends AbstractIllager {
@EntityMetaDataFunction(name = "Spell")
public Spells getSpell() {
return Spells.byId(this.metaData.getSets().getInt(EntityMetaDataFields.SPELLCASTER_ILLAGER_SPELL));
return Spells.byId(getEntityMetaData().getSets().getInt(EntityMetaDataFields.SPELLCASTER_ILLAGER_SPELL));
}
public enum Spells {

View File

@ -27,10 +27,10 @@ public class Witch extends Raider {
@EntityMetaDataFunction(name = "Is drinking Potion")
public boolean isDrinkingPotion() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.WITCH_IS_DRINKING_POTION);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.WITCH_IS_DRINKING_POTION);
}
public boolean isAggressive() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.LEGACY_WITCH_IS_AGGRESSIVE);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.LEGACY_WITCH_IS_AGGRESSIVE);
}
}

View File

@ -28,6 +28,6 @@ public abstract class AbstractVillager extends AgeableMob {
@EntityMetaDataFunction(name = "Unhappy timer")
public int getUnhappyTimer() {
return this.metaData.getSets().getInt(EntityMetaDataFields.ABSTRACT_VILLAGER_UNHAPPY_TIMER);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.ABSTRACT_VILLAGER_UNHAPPY_TIMER);
}
}

View File

@ -27,6 +27,6 @@ public class Villager extends AbstractVillager {
@EntityMetaDataFunction(name = "Villager data")
public VillagerData getVillagerDate() {
return this.metaData.getSets().getVillagerData(EntityMetaDataFields.VILLAGER_VILLAGER_DATA);
return getEntityMetaData().getSets().getVillagerData(EntityMetaDataFields.VILLAGER_VILLAGER_DATA);
}
}

View File

@ -26,9 +26,11 @@ import glm_.vec3.Vec3;
import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.UUID;
public class PlayerEntity extends LivingEntity {
private String name;
private UUID uuid;
private final HashSet<PlayerPropertyData> properties;
private Gamemodes gamemode;
@ -38,9 +40,10 @@ public class PlayerEntity extends LivingEntity {
this.properties = null;
}
public PlayerEntity(Connection connection, Vec3 position, EntityRotation rotation, String name, @Nullable HashSet<PlayerPropertyData> properties, Gamemodes gamemode) {
public PlayerEntity(Connection connection, Vec3 position, EntityRotation rotation, String name, UUID uuid, @Nullable HashSet<PlayerPropertyData> properties, Gamemodes gamemode) {
super(connection, position, rotation);
this.name = name;
this.uuid = uuid;
this.properties = properties;
this.gamemode = gamemode;
this.hasCollisions = gamemode != Gamemodes.SPECTATOR;
@ -48,33 +51,33 @@ public class PlayerEntity extends LivingEntity {
@EntityMetaDataFunction(name = "Absorption hearts")
public float getPlayerAbsorptionHearts() {
return this.metaData.getSets().getFloat(EntityMetaDataFields.PLAYER_ABSORPTION_HEARTS);
return getEntityMetaData().getSets().getFloat(EntityMetaDataFields.PLAYER_ABSORPTION_HEARTS);
}
@EntityMetaDataFunction(name = "Score")
public int getScore() {
return this.metaData.getSets().getInt(EntityMetaDataFields.PLAYER_SCORE);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.PLAYER_SCORE);
}
private boolean getSkinPartsFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.PLAYER_SKIN_PARTS_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.PLAYER_SKIN_PARTS_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Main hand")
public Hands getMainHand() {
return this.metaData.getSets().getByte(EntityMetaDataFields.PLAYER_SKIN_MAIN_HAND) == 0x01 ? Hands.OFF_HAND : Hands.MAIN_HAND;
return getEntityMetaData().getSets().getByte(EntityMetaDataFields.PLAYER_SKIN_MAIN_HAND) == 0x01 ? Hands.OFF_HAND : Hands.MAIN_HAND;
}
@EntityMetaDataFunction(name = "Left shoulder entity data")
@Nullable
public CompoundTag getLeftShoulderData() {
return this.metaData.getSets().getNBT(EntityMetaDataFields.PLAYER_LEFT_SHOULDER_DATA);
return getEntityMetaData().getSets().getNBT(EntityMetaDataFields.PLAYER_LEFT_SHOULDER_DATA);
}
@EntityMetaDataFunction(name = "Right shoulder entity data")
@Nullable
public CompoundTag getRightShoulderData() {
return this.metaData.getSets().getNBT(EntityMetaDataFields.PLAYER_RIGHT_SHOULDER_DATA);
return getEntityMetaData().getSets().getNBT(EntityMetaDataFields.PLAYER_RIGHT_SHOULDER_DATA);
}
@EntityMetaDataFunction(name = "Name")
@ -100,5 +103,13 @@ public class PlayerEntity extends LivingEntity {
public void setName(String name) {
this.name = name;
}
public UUID getUUID() {
return this.uuid;
}
public void setUUID(UUID uuid) {
this.uuid = uuid;
}
}

View File

@ -28,7 +28,7 @@ public abstract class AbstractArrow extends Projectile {
}
private boolean getAbstractArrowFlag(int bitMask) {
return this.metaData.getSets().getBitMask(EntityMetaDataFields.ABSTRACT_ARROW_FLAGS, bitMask);
return getEntityMetaData().getSets().getBitMask(EntityMetaDataFields.ABSTRACT_ARROW_FLAGS, bitMask);
}
@EntityMetaDataFunction(name = "Is critical")
@ -43,12 +43,12 @@ public abstract class AbstractArrow extends Projectile {
@EntityMetaDataFunction(name = "Piercing level")
public byte getPiercingLevel() {
return this.metaData.getSets().getByte(EntityMetaDataFields.ABSTRACT_ARROW_PIERCE_LEVEL);
return getEntityMetaData().getSets().getByte(EntityMetaDataFields.ABSTRACT_ARROW_PIERCE_LEVEL);
}
@EntityMetaDataFunction(name = "Owner UUID")
public UUID getOwnerUUID() {
return this.metaData.getSets().getUUID(EntityMetaDataFields.ABSTRACT_ARROW_OWNER_UUID);
return getEntityMetaData().getSets().getUUID(EntityMetaDataFields.ABSTRACT_ARROW_OWNER_UUID);
}
}

View File

@ -27,6 +27,6 @@ public class Arrow extends AbstractArrow {
@EntityMetaDataFunction(name = "Effect color")
public int getEffectColor() {
return this.metaData.getSets().getInt(EntityMetaDataFields.ARROW_EFFECT_COLOR);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.ARROW_EFFECT_COLOR);
}
}

View File

@ -31,7 +31,7 @@ public abstract class Fireball extends AbstractHurtingProjectile {
@EntityMetaDataFunction(name = "Item")
@Nullable
private ItemStack getItem() {
ItemStack itemStack = this.metaData.getSets().getItemStack(EntityMetaDataFields.FIREBALL_ITEM);
ItemStack itemStack = getEntityMetaData().getSets().getItemStack(EntityMetaDataFields.FIREBALL_ITEM);
if (itemStack == null) {
return getDefaultItem();
}

View File

@ -30,17 +30,17 @@ public class FireworkRocketEntity extends Projectile {
@EntityMetaDataFunction(name = "Item")
@Nullable
public ItemStack getFireworkItem() {
return getMetaData().getSets().getItemStack(EntityMetaDataFields.FIREWORK_ROCKET_ENTITY_ITEM);
return getEntityMetaData().getSets().getItemStack(EntityMetaDataFields.FIREWORK_ROCKET_ENTITY_ITEM);
}
@EntityMetaDataFunction(name = "Attached entity id")
public int getAttachedEntity() {
return getMetaData().getSets().getInt(EntityMetaDataFields.FIREWORK_ROCKET_ENTITY_ATTACHED_ENTITY);
public Integer getAttachedEntity() {
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.FIREWORK_ROCKET_ENTITY_ATTACHED_ENTITY);
}
@EntityMetaDataFunction(name = "Shot at angle")
public boolean isShotAtAngle() {
return getMetaData().getSets().getBoolean(EntityMetaDataFields.FIREWORK_ROCKET_ENTITY_SHOT_AT_ANGLE);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.FIREWORK_ROCKET_ENTITY_SHOT_AT_ANGLE);
}
}

View File

@ -27,11 +27,11 @@ public class FishingHook extends Projectile {
@EntityMetaDataFunction(name = "Hooked entity id")
public int getHookedEntityId() {
return getMetaData().getSets().getInt(EntityMetaDataFields.FISHING_HOOK_HOOKED_ENTITY);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.FISHING_HOOK_HOOKED_ENTITY);
}
@EntityMetaDataFunction(name = "Is catchable")
public boolean isCatchable() {
return getMetaData().getSets().getBoolean(EntityMetaDataFields.FISHING_HOOK_CATCHABLE);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.FISHING_HOOK_CATCHABLE);
}
}

View File

@ -28,7 +28,7 @@ public abstract class ThrowableItemProjectile extends ThrowableProjectile {
@EntityMetaDataFunction(name = "Item")
public ItemStack getItem() {
ItemStack itemStack = this.metaData.getSets().getItemStack(EntityMetaDataFields.THROWABLE_ITEM_PROJECTILE_ITEM);
ItemStack itemStack = getEntityMetaData().getSets().getItemStack(EntityMetaDataFields.THROWABLE_ITEM_PROJECTILE_ITEM);
if (itemStack == null) {
return getDefaultItem();
}

View File

@ -25,7 +25,7 @@ class ThrownEyeOfEnder(connection: Connection, location: Vec3, rotation: EntityR
@get:EntityMetaDataFunction(name = "Item")
val item: ItemStack
get() = metaData.sets.getItemStack(EntityMetaDataFields.THROWN_EYE_OF_ENDER_ITEM) ?: getDefaultItem()
get() = entityMetaData.sets.getItemStack(EntityMetaDataFields.THROWN_EYE_OF_ENDER_ITEM) ?: getDefaultItem()
fun getDefaultItem(): ItemStack {
return ItemStack(connection.mapping.itemRegistry.get(DEFAULT_ITEM)!!, connection.version)

View File

@ -35,7 +35,7 @@ public class ThrownPotion extends ThrowableItemProjectile {
if (this.versionId > V_20W09A) {
return super.getItem();
}
ItemStack itemStack = this.metaData.getSets().getItemStack(EntityMetaDataFields.THROWN_POTION_ITEM);
ItemStack itemStack = getEntityMetaData().getSets().getItemStack(EntityMetaDataFields.THROWN_POTION_ITEM);
if (itemStack == null) {
return getDefaultItem();
}

View File

@ -27,12 +27,12 @@ public class ThrownTrident extends AbstractArrow {
@EntityMetaDataFunction(name = "Loyalty level")
public byte getLoyaltyLevel() {
return getMetaData().getSets().getByte(EntityMetaDataFields.THROWN_TRIDENT_LOYALTY_LEVEL);
return getEntityMetaData().getSets().getByte(EntityMetaDataFields.THROWN_TRIDENT_LOYALTY_LEVEL);
}
@EntityMetaDataFunction(name = "Is enchanted")
public boolean isEnchanted() {
return getMetaData().getSets().getBoolean(EntityMetaDataFields.THROWN_TRIDENT_FOIL);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.THROWN_TRIDENT_FOIL);
}
}

View File

@ -27,7 +27,7 @@ public class WitherSkull extends AbstractHurtingProjectile {
@EntityMetaDataFunction(name = "Is dangerous")
public boolean isDangerous() {
return getMetaData().getSets().getBoolean(EntityMetaDataFields.WITHER_SKULL_DANGEROUS);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.WITHER_SKULL_DANGEROUS);
}
}

View File

@ -28,31 +28,31 @@ public abstract class AbstractMinecart extends Entity {
@EntityMetaDataFunction(name = "Shaking power")
public int getShakingPower() {
return this.metaData.getSets().getInt(EntityMetaDataFields.MINECART_HURT);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.MINECART_HURT);
}
@EntityMetaDataFunction(name = "Shaking direction")
public int getShakingDirection() {
return this.metaData.getSets().getInt(EntityMetaDataFields.MINECART_HURT_DIRECTION);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.MINECART_HURT_DIRECTION);
}
@EntityMetaDataFunction(name = "Shaking multiplier")
public float getShakingMultiplier() {
return this.metaData.getSets().getInt(EntityMetaDataFields.MINECART_DAMAGE_TAKEN);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.MINECART_DAMAGE_TAKEN);
}
@EntityMetaDataFunction(name = "Block id")
public int getBlockId() {
return this.metaData.getSets().getInt(EntityMetaDataFields.MINECART_BLOCK_ID);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.MINECART_BLOCK_ID);
}
@EntityMetaDataFunction(name = "Block Y offset")
public int getBlockYOffset() {
return this.metaData.getSets().getInt(EntityMetaDataFields.MINECART_BLOCK_Y_OFFSET);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.MINECART_BLOCK_Y_OFFSET);
}
@EntityMetaDataFunction(name = "Is showing block")
public boolean isShowingBlock() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.MINECART_SHOW_BLOCK);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.MINECART_SHOW_BLOCK);
}
}

View File

@ -28,37 +28,37 @@ public class Boat extends Entity {
@EntityMetaDataFunction(name = "Time since last hit")
public int getTimeSinceLastHit() {
return getMetaData().getSets().getInt(EntityMetaDataFields.BOAT_HURT);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.BOAT_HURT);
}
@EntityMetaDataFunction(name = "Forward direction")
public int getForwardDirection() {
return getMetaData().getSets().getInt(EntityMetaDataFields.BOAT_HURT_DIRECTION);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.BOAT_HURT_DIRECTION);
}
@EntityMetaDataFunction(name = "Damage taken")
public float getDamageTaken() {
return getMetaData().getSets().getFloat(EntityMetaDataFields.BOAT_DAMAGE_TAKEN);
return getEntityMetaData().getSets().getFloat(EntityMetaDataFields.BOAT_DAMAGE_TAKEN);
}
@EntityMetaDataFunction(name = "Material")
public BoatMaterials getMaterial() {
return BoatMaterials.byId(getMetaData().getSets().getInt(EntityMetaDataFields.BOAT_MATERIAL));
return BoatMaterials.byId(getEntityMetaData().getSets().getInt(EntityMetaDataFields.BOAT_MATERIAL));
}
@EntityMetaDataFunction(name = "Left paddle turning")
public boolean isLeftPaddleTurning() {
return getMetaData().getSets().getBoolean(EntityMetaDataFields.BOAT_PADDLE_LEFT);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.BOAT_PADDLE_LEFT);
}
@EntityMetaDataFunction(name = "Right paddle turning")
public boolean isRightPaddleTurning() {
return getMetaData().getSets().getBoolean(EntityMetaDataFields.BOAT_PADDLE_RIGHT);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.BOAT_PADDLE_RIGHT);
}
@EntityMetaDataFunction(name = "Splash timer")
public int getSplashTimer() {
return getMetaData().getSets().getInt(EntityMetaDataFields.BOAT_BUBBLE_TIME);
return getEntityMetaData().getSets().getInt(EntityMetaDataFields.BOAT_BUBBLE_TIME);
}
public enum BoatMaterials {

View File

@ -28,11 +28,11 @@ public class MinecartCommandBlock extends AbstractMinecart {
@EntityMetaDataFunction(name = "Command")
public String getCommand() {
return this.metaData.getSets().getString(EntityMetaDataFields.MINECART_COMMAND_BLOCK_COMMAND);
return getEntityMetaData().getSets().getString(EntityMetaDataFields.MINECART_COMMAND_BLOCK_COMMAND);
}
@EntityMetaDataFunction(name = "Last output")
public ChatComponent getLastOutput() {
return this.metaData.getSets().getChatComponent(EntityMetaDataFields.MINECART_COMMAND_BLOCK_LAST_OUTPUT);
return getEntityMetaData().getSets().getChatComponent(EntityMetaDataFields.MINECART_COMMAND_BLOCK_LAST_OUTPUT);
}
}

View File

@ -27,6 +27,6 @@ public class MinecartFurnace extends AbstractMinecartContainer {
@EntityMetaDataFunction(name = "Has fuel")
public boolean hasFuel() {
return this.metaData.getSets().getBoolean(EntityMetaDataFields.MINECART_FURNACE_HAS_FUEL);
return getEntityMetaData().getSets().getBoolean(EntityMetaDataFields.MINECART_FURNACE_HAS_FUEL);
}
}

View File

@ -38,7 +38,7 @@ data class BlockState(
val renders: MutableList<BlockRenderInterface> = mutableListOf(),
val tintColor: RGBColor? = null,
val material: Material,
val collision: VoxelShape,
val collisionShape: VoxelShape,
) {
override fun hashCode(): Int {
@ -181,7 +181,7 @@ data class BlockState(
renders = renders,
tintColor = tintColor,
material = material,
collision = collision
collisionShape = collision
)
}

View File

@ -19,7 +19,6 @@ import de.bixilon.minosoft.data.entities.entities.player.PlayerEntity
import de.bixilon.minosoft.gui.rendering.util.VecUtil
import de.bixilon.minosoft.protocol.network.Connection
import glm_.vec3.Vec3i
import java.util.*
class Player(
val account: Account,
@ -29,8 +28,7 @@ class Player(
val experienceCondition = PlayerExperienceCondition()
val inventoryManager = PlayerInventoryManager()
var spawnPosition: Vec3i = VecUtil.EMPTY_VEC3I
val entity: PlayerEntity = PlayerEntity(connection, VecUtil.EMPTY_VEC3, EntityRotation(0.0, 0.0), account.username, null, Gamemodes.SPECTATOR)
var playerUUID: UUID = account.uuid
val entity: PlayerEntity = PlayerEntity(connection, VecUtil.EMPTY_VEC3, EntityRotation(0.0, 0.0), account.username, account.uuid, null, Gamemodes.SPECTATOR)
@Deprecated(message = "Will be replaced with some kind of teleport manager, ...")
var isSpawnConfirmed = false

View File

@ -83,7 +83,7 @@ class AABB {
return Axes.choose(axis, max)
}
fun extend(vec3: Vec3): AABB {
infix fun extend(vec3: Vec3): AABB {
val newMin = Vec3(min)
val newMax = Vec3(max)

View File

@ -14,6 +14,7 @@
package de.bixilon.minosoft.modding.event.events;
import de.bixilon.minosoft.data.entities.entities.Entity;
import de.bixilon.minosoft.data.inventory.InventorySlots;
import de.bixilon.minosoft.data.inventory.ItemStack;
import de.bixilon.minosoft.protocol.network.Connection;
import de.bixilon.minosoft.protocol.packets.clientbound.play.PacketEntityEquipment;
@ -22,9 +23,9 @@ import java.util.HashMap;
public class EntityEquipmentChangeEvent extends ConnectionEvent {
private final int entityId;
private final HashMap<Integer, ItemStack> slots;
private final HashMap<InventorySlots.EquipmentSlots, ItemStack> slots;
public EntityEquipmentChangeEvent(Connection connection, int entityId, HashMap<Integer, ItemStack> slots) {
public EntityEquipmentChangeEvent(Connection connection, int entityId, HashMap<InventorySlots.EquipmentSlots, ItemStack> slots) {
super(connection);
this.entityId = entityId;
this.slots = slots;
@ -44,7 +45,7 @@ public class EntityEquipmentChangeEvent extends ConnectionEvent {
return this.entityId;
}
public HashMap<Integer, ItemStack> getSlots() {
public HashMap<InventorySlots.EquipmentSlots, ItemStack> getSlots() {
return this.slots;
}
}

View File

@ -41,7 +41,7 @@ public class PacketLoginSuccess extends ClientboundPacket {
public void handle(Connection connection) {
connection.setConnectionState(ConnectionStates.PLAY);
connection.getPlayer().setPlayerUUID(getUUID());
connection.getPlayer().getEntity().setUUID(getUUID());
connection.getPlayer().getEntity().setName(getPlayerName());
}

View File

@ -14,6 +14,7 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.data.entities.entities.Entity;
import de.bixilon.minosoft.data.inventory.InventorySlots;
import de.bixilon.minosoft.data.inventory.ItemStack;
import de.bixilon.minosoft.modding.event.events.EntityEquipmentChangeEvent;
import de.bixilon.minosoft.protocol.network.Connection;
@ -28,17 +29,17 @@ import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_15W31A;
import static de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_16_PRE7;
public class PacketEntityEquipment extends ClientboundPacket {
private final HashMap<Integer, ItemStack> slots = new HashMap<>();
private final HashMap<InventorySlots.EquipmentSlots, ItemStack> slots = new HashMap<>();
private final int entityId;
public PacketEntityEquipment(InByteBuffer buffer) {
this.entityId = buffer.readEntityId();
if (buffer.getVersionId() < V_15W31A) {
this.slots.put((int) buffer.readShort(), buffer.readItemStack());
this.slots.put(buffer.getConnection().getMapping().getEquipmentSlotRegistry().get(buffer.readShort()), buffer.readItemStack());
return;
}
if (buffer.getVersionId() < V_1_16_PRE7) {
this.slots.put(buffer.readVarInt(), buffer.readItemStack());
this.slots.put(buffer.getConnection().getMapping().getEquipmentSlotRegistry().get(buffer.readVarInt()), buffer.readItemStack());
return;
}
boolean slotAvailable = true;
@ -48,7 +49,7 @@ public class PacketEntityEquipment extends ClientboundPacket {
slotAvailable = false;
}
slotId &= 0x7F;
this.slots.put(slotId, buffer.readItemStack());
this.slots.put(buffer.getConnection().getMapping().getEquipmentSlotRegistry().get(slotId), buffer.readItemStack());
}
}
@ -61,13 +62,14 @@ public class PacketEntityEquipment extends ClientboundPacket {
// thanks mojang
return;
}
entity.setEquipment(getSlots());
entity.getEquipment().clear();
entity.getEquipment().putAll(getSlots());
}
@Override
public void log() {
if (this.slots.size() == 1) {
Map.Entry<Integer, ItemStack> set = this.slots.entrySet().iterator().next();
Map.Entry<InventorySlots.EquipmentSlots, ItemStack> set = this.slots.entrySet().iterator().next();
if (set.getValue() == null) {
Log.protocol(String.format("[IN] Entity equipment changed (entityId=%d, slot=%s): AIR", this.entityId, set.getKey()));
return;
@ -82,7 +84,7 @@ public class PacketEntityEquipment extends ClientboundPacket {
return this.entityId;
}
public HashMap<Integer, ItemStack> getSlots() {
public HashMap<InventorySlots.EquipmentSlots, ItemStack> getSlots() {
return this.slots;
}
}

View File

@ -34,7 +34,7 @@ class PacketEntityMetadata() : ClientboundPacket() {
override fun handle(connection: Connection) {
val entity = connection.world.getEntity(entityId) ?: return
entity.metaData = entityData
entity.entityMetaData = entityData
connection.fireEvent(EntityMetaDataChangeEvent(connection, entity))
if (entity === connection.player.entity) {

View File

@ -47,7 +47,7 @@ public class PacketEntityMovement extends ClientboundPacket {
// thanks mojang
return;
}
entity.setLocation(getRelativePosition());
entity.forceMove(getRelativePosition());
}
@Override

View File

@ -52,7 +52,7 @@ public class PacketEntityMovementAndRotation extends ClientboundPacket {
// thanks mojang
return;
}
entity.setLocation(getRelativePosition());
entity.setPosition(getRelativePosition());
entity.setRotation(getYaw(), getPitch());
}

View File

@ -53,7 +53,7 @@ public class PacketEntityTeleport extends ClientboundPacket {
// thanks mojang
return;
}
entity.setLocation(getRelativePosition());
entity.forceMove(getRelativePosition());
entity.setRotation(getYaw(), getPitch());
}

View File

@ -143,7 +143,7 @@ class PacketJoinGame(buffer: InByteBuffer) : ClientboundPacket() {
connection.mapping.dimensionRegistry.setData(dimensions)
connection.world.dimension = dimension
connection.world.addEntity(entityId, connection.player.playerUUID, playerEntity)
connection.world.addEntity(entityId, connection.player.entity.uuid, playerEntity)
connection.world.hashedSeed = hashedSeed
connection.world.biomeAccessor = if (connection.version.versionId < ProtocolVersions.V_19W36A) {
BlockBiomeAccessor(connection.world)

View File

@ -53,7 +53,7 @@ public class PacketPlayerPositionAndRotation extends ClientboundPacket {
@Override
public void handle(Connection connection) {
// ToDo: GUI should do this
connection.getPlayer().getEntity().setLocation(getPosition());
connection.getPlayer().getEntity().setPosition(getPosition());
if (connection.getVersion().getVersionId() >= V_15W42A) {
connection.sendPacket(new PacketConfirmTeleport(getTeleportId()));
} else {

View File

@ -13,6 +13,7 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.config.StaticConfiguration;
import de.bixilon.minosoft.data.entities.EntityRotation;
import de.bixilon.minosoft.data.entities.Velocity;
import de.bixilon.minosoft.data.entities.entities.Entity;
@ -70,7 +71,10 @@ public class PacketSpawnMob extends ClientboundPacket {
this.entity = typeClass.getConstructor(Connection.class, Vec3.class, EntityRotation.class).newInstance(buffer.getConnection(), position, rotation);
if (metaData != null) {
this.entity.setMetaData(metaData);
this.entity.setEntityMetaData(metaData);
if (StaticConfiguration.VERBOSE_ENTITY_META_DATA_LOGGING) {
Log.verbose(String.format("Metadata of entity %s (entityId=%d): %s", this.entity.toString(), this.entityId, this.entity.getEntityMetaDataAsString()));
}
}
}

View File

@ -13,6 +13,7 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.config.StaticConfiguration;
import de.bixilon.minosoft.data.Gamemodes;
import de.bixilon.minosoft.data.PlayerPropertyData;
import de.bixilon.minosoft.data.entities.EntityRotation;
@ -66,9 +67,12 @@ public class PacketSpawnPlayer extends ClientboundPacket {
if (buffer.getVersionId() < V_19W34A) {
metaData = buffer.readMetaData();
}
this.entity = new PlayerEntity(buffer.getConnection(), position, new EntityRotation(yaw, pitch, 0), name, properties, Gamemodes.CREATIVE); // ToDo
this.entity = new PlayerEntity(buffer.getConnection(), position, new EntityRotation(yaw, pitch, 0), name, this.entityUUID, properties, Gamemodes.CREATIVE); // ToDo
if (metaData != null) {
this.entity.setMetaData(metaData);
this.entity.setEntityMetaData(metaData);
if (StaticConfiguration.VERBOSE_ENTITY_META_DATA_LOGGING) {
Log.verbose(String.format("Metadata of entity %s (entityId=%d): %s", this.entity.toString(), this.entityId, this.entity.getEntityMetaDataAsString()));
}
}
}

View File

@ -31,22 +31,11 @@ public class PacketInteractEntity implements ServerboundPacket {
private EntityInteractionClicks click;
private boolean sneaking;
public PacketInteractEntity(Entity entity, EntityInteractionClicks click) {
this.entityId = entity.getEntityId();
public PacketInteractEntity(Connection connection, Entity entity, EntityInteractionClicks click) {
this.entityId = connection.getWorld().getEntityIdMap().inverse().get(entity);
this.click = click;
}
public PacketInteractEntity(int entityId, EntityInteractionClicks click) {
this.entityId = entityId;
this.click = click;
}
public PacketInteractEntity(int entityId, EntityInteractionClicks click, Vec3 position) {
this.entityId = entityId;
this.click = click;
this.position = position;
}
public PacketInteractEntity(int entityId, EntityInteractionClicks click, Vec3 position, Hands hand) {
this.entityId = entityId;
this.click = click;

View File

@ -71,11 +71,11 @@ public class PacketSender {
}
public void sendAction(PacketEntityAction.EntityActions action) {
this.connection.sendPacket(new PacketEntityAction(this.connection.getPlayer().getEntity().getEntityId(), action));
this.connection.sendPacket(new PacketEntityAction(this.connection.getWorld().getEntityIdMap().inverse().get(this.connection.getPlayer().getEntity()), action));
}
public void jumpWithHorse(int jumpBoost) {
this.connection.sendPacket(new PacketEntityAction(this.connection.getPlayer().getEntity().getEntityId(), PacketEntityAction.EntityActions.START_HORSE_JUMP, jumpBoost));
this.connection.sendPacket(new PacketEntityAction(this.connection.getWorld().getEntityIdMap().inverse().get(this.connection.getPlayer().getEntity()), PacketEntityAction.EntityActions.START_HORSE_JUMP, jumpBoost));
}
public void dropItem() {
@ -124,7 +124,7 @@ public class PacketSender {
public void setLocation(Vec3 position, EntityRotation rotation, boolean onGround) {
this.connection.sendPacket(new PacketPlayerPositionAndRotationSending(position, rotation, onGround));
this.connection.getPlayer().getEntity().setLocation(position);
this.connection.getPlayer().getEntity().setPosition(position);
this.connection.getPlayer().getEntity().setRotation(rotation);
}

View File

@ -33,7 +33,7 @@ public class CommandEntities extends Command {
ArrayList<Object[]> tableData = new ArrayList<>();
for (var entry : connection.getWorld().getEntityIdMap().entrySet()) {
tableData.add(new Object[]{entry.getKey(), entry.getValue().getUUID(), entry.getValue().getEntityInformation(), entry.getValue().getEquipment(), entry.getValue().getPosition(), entry.getValue().getRotation()});
tableData.add(new Object[]{entry.getKey(), connection.getWorld().getEntityIdMap().inverse().get(entry.getValue()), entry.getValue().getEntityInformation(), entry.getValue().getEquipment(), entry.getValue().getPosition(), entry.getValue().getRotation()});
}
print(AsciiTable.getTable(new String[]{"ID", "UUID", "TYPE", "EQUIPMENT", "LOCATION", "ROTATION"}, tableData.toArray(new Object[0][0])));
@ -48,8 +48,8 @@ public class CommandEntities extends Command {
}
ArrayList<Object[]> tableData = new ArrayList<>();
tableData.add(new Object[]{"Entity id", entity.getEntityId()});
tableData.add(new Object[]{"UUID", entity.getUUID()});
tableData.add(new Object[]{"Entity id", connection.getWorld().getEntityIdMap().inverse().get(entity)});
tableData.add(new Object[]{"UUID", connection.getWorld().getEntityUUIDMap().inverse().get(entity)});
tableData.add(new Object[]{"Type", entity.getEntityInformation()});
tableData.add(new Object[]{"Class", entity.getClass().getName()});
tableData.add(new Object[]{"Location", entity.getPosition()});

View File

@ -70,7 +70,7 @@ public class CommandTabList extends Command {
for (var entry : connection.getTabList().getPlayerList().entrySet()) {
PlayerEntity playerEntity = (PlayerEntity) connection.getWorld().getEntity(entry.getValue().getUUID());
Integer entityId = playerEntity != null ? playerEntity.getEntityId() : null;
Integer entityId = playerEntity != null ? connection.getWorld().getEntityIdMap().inverse().get(playerEntity) : null;
tableData.add(new Object[]{entry.getKey(), entityId, entry.getValue().getName(), entry.getValue().getDisplayName(), entry.getValue().getGamemode(), entry.getValue().getPing() + "ms"});
}