mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Update to support MCProtocolLib entity metadata changes
This commit is contained in:
parent
f797f84878
commit
1e0b312d9d
71 changed files with 301 additions and 324 deletions
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -45,8 +44,8 @@ public class AbstractArrowEntity extends Entity {
|
|||
setMotion(motion);
|
||||
}
|
||||
|
||||
public void setArrowFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte data = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setArrowFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte data = entityMetadata.getPrimitiveValue();
|
||||
|
||||
setFlag(EntityFlag.CRITICAL, (data & 0x01) == 0x01);
|
||||
}
|
||||
|
|
|
@ -56,13 +56,13 @@ public class AreaEffectCloudEntity extends Entity {
|
|||
setFlag(EntityFlag.FIRE_IMMUNE, true);
|
||||
}
|
||||
|
||||
public void setRadius(EntityMetadata<Float> entityMetadata) {
|
||||
float value = ((FloatEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setRadius(FloatEntityMetadata entityMetadata) {
|
||||
float value = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.AREA_EFFECT_CLOUD_RADIUS, value);
|
||||
dirtyMetadata.put(EntityData.BOUNDING_BOX_WIDTH, 2.0f * value);
|
||||
}
|
||||
|
||||
public void setParticle(EntityMetadata<Particle> entityMetadata) {
|
||||
public void setParticle(EntityMetadata<Particle, ?> entityMetadata) {
|
||||
Particle particle = entityMetadata.getValue();
|
||||
int particleId = EffectUtils.getParticleId(session, particle.getType());
|
||||
if (particleId != -1) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -114,13 +113,13 @@ public class BoatEntity extends Entity {
|
|||
moveRelative(0, 0, 0, yaw + 90, 0, 0, isOnGround);
|
||||
}
|
||||
|
||||
public void setVariant(EntityMetadata<Integer> entityMetadata) {
|
||||
variant = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setVariant(IntEntityMetadata entityMetadata) {
|
||||
variant = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.VARIANT, variant);
|
||||
}
|
||||
|
||||
public void setPaddlingLeft(EntityMetadata<Boolean> entityMetadata) {
|
||||
isPaddlingLeft = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setPaddlingLeft(BooleanEntityMetadata entityMetadata) {
|
||||
isPaddlingLeft = entityMetadata.getPrimitiveValue();
|
||||
if (isPaddlingLeft) {
|
||||
// Java sends simply "true" and "false" (is_paddling_left), Bedrock keeps sending packets as you're rowing
|
||||
// This is an asynchronous method that emulates Bedrock rowing until "false" is sent.
|
||||
|
@ -138,8 +137,8 @@ public class BoatEntity extends Entity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setPaddlingRight(EntityMetadata<Boolean> entityMetadata) {
|
||||
isPaddlingRight = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setPaddlingRight(BooleanEntityMetadata entityMetadata) {
|
||||
isPaddlingRight = entityMetadata.getPrimitiveValue();
|
||||
if (isPaddlingRight) {
|
||||
paddleTimeRight = 0f;
|
||||
if (!this.passengers.isEmpty()) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -56,7 +55,7 @@ public class DefaultBlockMinecartEntity extends MinecartEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCustomBlock(EntityMetadata<Integer> entityMetadata) {
|
||||
public void setCustomBlock(IntEntityMetadata entityMetadata) {
|
||||
customBlock = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
|
||||
if (showCustomBlock) {
|
||||
|
@ -65,8 +64,8 @@ public class DefaultBlockMinecartEntity extends MinecartEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCustomBlockOffset(EntityMetadata<Integer> entityMetadata) {
|
||||
customBlockOffset = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setCustomBlockOffset(IntEntityMetadata entityMetadata) {
|
||||
customBlockOffset = entityMetadata.getPrimitiveValue();
|
||||
|
||||
if (showCustomBlock) {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, customBlockOffset);
|
||||
|
@ -74,8 +73,8 @@ public class DefaultBlockMinecartEntity extends MinecartEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setShowCustomBlock(EntityMetadata<Boolean> entityMetadata) {
|
||||
if (((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()) {
|
||||
public void setShowCustomBlock(BooleanEntityMetadata entityMetadata) {
|
||||
if (entityMetadata.getPrimitiveValue()) {
|
||||
showCustomBlock = true;
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(customBlock));
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, customBlockOffset);
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
|||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EnderCrystalEntity extends Entity {
|
||||
|
@ -48,12 +49,13 @@ public class EnderCrystalEntity extends Entity {
|
|||
setFlag(EntityFlag.FIRE_IMMUNE, true);
|
||||
}
|
||||
|
||||
public void setBlockTarget(EntityMetadata<Position> entityMetadata) {
|
||||
public void setBlockTarget(EntityMetadata<Optional<Position>, ?> entityMetadata) {
|
||||
// Show beam
|
||||
// Usually performed client-side on Bedrock except for Ender Dragon respawn event
|
||||
Position position = entityMetadata.getValue();
|
||||
if (position != null) {
|
||||
dirtyMetadata.put(EntityData.BLOCK_TARGET, Vector3i.from(position.getX(), position.getY(), position.getZ()));
|
||||
Optional<Position> optionalPos = entityMetadata.getValue();
|
||||
if (optionalPos.isPresent()) {
|
||||
Position pos = optionalPos.get();
|
||||
dirtyMetadata.put(EntityData.BLOCK_TARGET, Vector3i.from(pos.getX(), pos.getY(), pos.getZ()));
|
||||
} else {
|
||||
dirtyMetadata.put(EntityData.BLOCK_TARGET, Vector3i.ZERO);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.geysermc.connector.network.session.GeyserSession;
|
|||
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||
import org.geysermc.connector.utils.MathUtils;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
|
@ -120,7 +121,7 @@ public class Entity {
|
|||
this.valid = false;
|
||||
|
||||
setPosition(position);
|
||||
setAir(getMaxAir());
|
||||
setAirSupply(getMaxAir());
|
||||
|
||||
initializeMetadata();
|
||||
}
|
||||
|
@ -304,8 +305,8 @@ public class Entity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.ON_FIRE, ((xd & 0x01) == 0x01) && !getFlag(EntityFlag.FIRE_IMMUNE)); // Otherwise immune entities sometimes flicker onfire
|
||||
setFlag(EntityFlag.SNEAKING, (xd & 0x02) == 0x02);
|
||||
setFlag(EntityFlag.SPRINTING, (xd & 0x08) == 0x08);
|
||||
|
@ -327,11 +328,11 @@ public class Entity {
|
|||
/**
|
||||
* Set an int from 0 - this entity's maximum air - (air / maxAir) represents the percentage of bubbles left
|
||||
*/
|
||||
public final void setAir(EntityMetadata<?> entityMetadata) {
|
||||
setAir(((IntEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public final void setAir(IntEntityMetadata entityMetadata) {
|
||||
setAirSupply(entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
protected void setAir(int amount) {
|
||||
protected void setAirSupply(int amount) {
|
||||
dirtyMetadata.put(EntityData.AIR_SUPPLY, (short) MathUtils.constrain(amount, 0, getMaxAir()));
|
||||
}
|
||||
|
||||
|
@ -339,10 +340,10 @@ public class Entity {
|
|||
return 300;
|
||||
}
|
||||
|
||||
public void setDisplayName(EntityMetadata<Component> entityMetadata) {
|
||||
Component name = entityMetadata.getValue();
|
||||
if (name != null) {
|
||||
nametag = MessageTranslator.convertMessage(name, session.getLocale());
|
||||
public void setDisplayName(EntityMetadata<Optional<Component>, ?> entityMetadata) {
|
||||
Optional<Component> name = entityMetadata.getValue();
|
||||
if (name.isPresent()) {
|
||||
nametag = MessageTranslator.convertMessage(name.get(), session.getLocale());
|
||||
dirtyMetadata.put(EntityData.NAMETAG, nametag);
|
||||
} else if (!nametag.isEmpty()) {
|
||||
// Clear nametag
|
||||
|
@ -350,18 +351,18 @@ public class Entity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setDisplayNameVisible(EntityMetadata<Boolean> entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.NAMETAG_ALWAYS_SHOW, (byte) (((BooleanEntityMetadata) entityMetadata).getPrimitiveValue() ? 1 : 0));
|
||||
public void setDisplayNameVisible(BooleanEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.NAMETAG_ALWAYS_SHOW, (byte) (entityMetadata.getPrimitiveValue() ? 1 : 0));
|
||||
}
|
||||
|
||||
public void setGravity(EntityMetadata<Boolean> entityMetadata) {
|
||||
setFlag(EntityFlag.HAS_GRAVITY, !((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public void setGravity(BooleanEntityMetadata entityMetadata) {
|
||||
setFlag(EntityFlag.HAS_GRAVITY, !entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Usually used for bounding box and not animation.
|
||||
*/
|
||||
public void setPose(EntityMetadata<Pose> entityMetadata) {
|
||||
public void setPose(EntityMetadata<Pose, ?> entityMetadata) {
|
||||
Pose pose = entityMetadata.getValue();
|
||||
|
||||
setFlag(EntityFlag.SLEEPING, pose.equals(Pose.SLEEPING));
|
||||
|
@ -396,7 +397,7 @@ public class Entity {
|
|||
/**
|
||||
* Set a float from 0-1 - how strong the "frozen" overlay should be on screen.
|
||||
*/
|
||||
public float setFreezing(EntityMetadata<Integer> entityMetadata) {
|
||||
public float setFreezing(IntEntityMetadata entityMetadata) {
|
||||
// The value that Java edition gives us is in ticks, but Bedrock uses a float percentage of the strength 0.0 -> 1.0
|
||||
// The Java client caps its freezing tick percentage at 140
|
||||
int freezingTicks = Math.min(((IntEntityMetadata) entityMetadata).getPrimitiveValue(), 140);
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
|||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.entity.factory.BaseEntityFactory;
|
||||
import org.geysermc.connector.entity.factory.EntityFactory;
|
||||
import org.geysermc.connector.registry.Registries;
|
||||
|
@ -47,7 +48,7 @@ import java.util.function.BiConsumer;
|
|||
* @param <T> the entity type this definition represents
|
||||
*/
|
||||
public record EntityDefinition<T extends Entity>(EntityFactory<T> factory, EntityType entityType, String identifier,
|
||||
float width, float height, float offset, List<EntityMetadataTranslator<? super T, ?>> translators) {
|
||||
float width, float height, float offset, List<EntityMetadataTranslator<? super T, ?, ?>> translators) {
|
||||
|
||||
public static <T extends Entity> Builder<T> inherited(BaseEntityFactory<T> factory, EntityDefinition<? super T> parent) {
|
||||
return inherited((EntityFactory<T>) factory, parent);
|
||||
|
@ -61,6 +62,25 @@ public record EntityDefinition<T extends Entity>(EntityFactory<T> factory, Entit
|
|||
return new Builder<>(factory);
|
||||
}
|
||||
|
||||
|
||||
public <M> void translateMetadata(T entity, EntityMetadata<M, ? extends MetadataType<M>> metadata) {
|
||||
EntityMetadataTranslator<? super T, M, EntityMetadata<M, ? extends MetadataType<M>>> translator = (EntityMetadataTranslator<? super T, M, EntityMetadata<M, ? extends MetadataType<M>>>) this.translators.get(metadata.getId());
|
||||
if (translator == null) {
|
||||
// This can safely happen; it means we don't translate this entity metadata
|
||||
return;
|
||||
}
|
||||
|
||||
if (translator.acceptedType() != metadata.getType()) {
|
||||
GeyserConnector.getInstance().getLogger().warning("Metadata ID " + metadata.getId() + " was received with type " + metadata.getType() + " but we expected " + translator.acceptedType() + " for " + entity.getDefinition().entityType());
|
||||
if (GeyserConnector.getInstance().getConfig().isDebugMode()) {
|
||||
GeyserConnector.getInstance().getLogger().debug(metadata.toString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
translator.translateFunction().accept(entity, metadata);
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Accessors(fluent = true, chain = true)
|
||||
public static class Builder<T extends Entity> {
|
||||
|
@ -70,14 +90,14 @@ public record EntityDefinition<T extends Entity>(EntityFactory<T> factory, Entit
|
|||
private float width;
|
||||
private float height;
|
||||
private float offset;
|
||||
private final List<EntityMetadataTranslator<? super T, ?>> translators;
|
||||
private final List<EntityMetadataTranslator<? super T, ?, ?>> translators;
|
||||
|
||||
private Builder(EntityFactory<T> factory) {
|
||||
this.factory = factory;
|
||||
translators = new ObjectArrayList<>();
|
||||
}
|
||||
|
||||
public Builder(EntityFactory<T> factory, EntityType type, String identifier, float width, float height, float offset, List<EntityMetadataTranslator<? super T, ?>> translators) {
|
||||
public Builder(EntityFactory<T> factory, EntityType type, String identifier, float width, float height, float offset, List<EntityMetadataTranslator<? super T, ?, ?>> translators) {
|
||||
this.factory = factory;
|
||||
this.type = type;
|
||||
this.identifier = identifier;
|
||||
|
@ -105,12 +125,12 @@ public record EntityDefinition<T extends Entity>(EntityFactory<T> factory, Entit
|
|||
return this;
|
||||
}
|
||||
|
||||
public <U> Builder<T> addTranslator(MetadataType type, BiConsumer<T, EntityMetadata<U>> translateFunction) {
|
||||
public <U, EM extends EntityMetadata<U, ? extends MetadataType<U>>> Builder<T> addTranslator(MetadataType<U> type, BiConsumer<T, EM> translateFunction) {
|
||||
translators.add(new EntityMetadataTranslator<>(type, translateFunction));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> addTranslator(EntityMetadataTranslator<T, ?> translator) {
|
||||
public Builder<T> addTranslator(EntityMetadataTranslator<T, ?, ?> translator) {
|
||||
translators.add(translator);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEnt
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.geysermc.connector.entity.factory.BaseEntityFactory;
|
||||
import org.geysermc.connector.entity.factory.ExperienceOrbEntityFactory;
|
||||
import org.geysermc.connector.entity.factory.PaintingEntityFactory;
|
||||
|
@ -182,7 +181,7 @@ public final class EntityDefinitions {
|
|||
.addTranslator(MetadataType.INT, Entity::setAir) // Air/bubbles
|
||||
.addTranslator(MetadataType.OPTIONAL_CHAT, Entity::setDisplayName)
|
||||
.addTranslator(MetadataType.BOOLEAN, Entity::setDisplayNameVisible)
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN, (entity, entityMetadata) -> entity.setFlag(EntityFlag.SILENT, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, (entity, entityMetadata) -> entity.setFlag(EntityFlag.SILENT, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, Entity::setGravity)
|
||||
.addTranslator(MetadataType.POSE, Entity::setPose)
|
||||
.addTranslator(MetadataType.INT, Entity::setFreezing)
|
||||
|
@ -204,7 +203,7 @@ public final class EntityDefinitions {
|
|||
.offset(0.35f)
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.HURT_TIME, entityMetadata.getValue())) // Time since last hit
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.HURT_DIRECTION, entityMetadata.getValue())) // Rocking direction
|
||||
.<Float>addTranslator(MetadataType.FLOAT, (boatEntity, entityMetadata) ->
|
||||
.addTranslator(MetadataType.FLOAT, (boatEntity, entityMetadata) ->
|
||||
// 'Health' in Bedrock, damage taken in Java - it makes motion in Bedrock
|
||||
boatEntity.getDirtyMetadata().put(EntityData.HEALTH, 40 - ((int) ((FloatEntityMetadata) entityMetadata).getPrimitiveValue())))
|
||||
.addTranslator(MetadataType.INT, BoatEntity::setVariant)
|
||||
|
@ -220,7 +219,7 @@ public final class EntityDefinitions {
|
|||
.type(EntityType.END_CRYSTAL)
|
||||
.heightAndWidth(2.0f)
|
||||
.addTranslator(MetadataType.OPTIONAL_POSITION, EnderCrystalEntity::setBlockTarget)
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN,
|
||||
.addTranslator(MetadataType.BOOLEAN,
|
||||
(enderCrystalEntity, entityMetadata) -> enderCrystalEntity.setFlag(EntityFlag.SHOW_BOTTOM, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue())) // There is a base located on the ender crystal
|
||||
.build();
|
||||
EXPERIENCE_ORB = EntityDefinition.inherited((ExperienceOrbEntityFactory) ExpOrbEntity::new, entityBase)
|
||||
|
@ -337,7 +336,7 @@ public final class EntityDefinitions {
|
|||
.type(EntityType.TRIDENT)
|
||||
.identifier("minecraft:thrown_trident")
|
||||
.addTranslator(null) // Loyalty
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN, (tridentEntity, entityMetadata) -> tridentEntity.setFlag(EntityFlag.ENCHANTED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, (tridentEntity, entityMetadata) -> tridentEntity.setFlag(EntityFlag.ENCHANTED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.build();
|
||||
|
||||
// Item frames are handled differently as they are blocks, not items, in Bedrock
|
||||
|
@ -356,7 +355,7 @@ public final class EntityDefinitions {
|
|||
.offset(0.35f)
|
||||
.addTranslator(MetadataType.INT, (minecartEntity, entityMetadata) -> minecartEntity.getDirtyMetadata().put(EntityData.HEALTH, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.INT, (minecartEntity, entityMetadata) -> minecartEntity.getDirtyMetadata().put(EntityData.HURT_DIRECTION, entityMetadata.getValue())) // Direction in which the minecart is shaking
|
||||
.<Float>addTranslator(MetadataType.FLOAT, (minecartEntity, entityMetadata) ->
|
||||
.addTranslator(MetadataType.FLOAT, (minecartEntity, entityMetadata) ->
|
||||
// Power in Java, time in Bedrock
|
||||
minecartEntity.getDirtyMetadata().put(EntityData.HURT_TIME, Math.min((int) ((FloatEntityMetadata) entityMetadata).getPrimitiveValue(), 15)))
|
||||
.addTranslator(MetadataType.INT, MinecartEntity::setCustomBlock)
|
||||
|
@ -371,7 +370,7 @@ public final class EntityDefinitions {
|
|||
.type(EntityType.MINECART_COMMAND_BLOCK)
|
||||
.identifier("minecraft:command_block_minecart")
|
||||
.addTranslator(MetadataType.STRING, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_COMMAND, entityMetadata.getValue()))
|
||||
.<Component>addTranslator(MetadataType.CHAT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_LAST_OUTPUT, MessageTranslator.convertMessage(entityMetadata.getValue())))
|
||||
.addTranslator(MetadataType.CHAT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_LAST_OUTPUT, MessageTranslator.convertMessage(entityMetadata.getValue())))
|
||||
.build();
|
||||
MINECART_FURNACE = EntityDefinition.inherited(FurnaceMinecartEntity::new, MINECART)
|
||||
.type(EntityType.MINECART_FURNACE)
|
||||
|
@ -403,9 +402,9 @@ public final class EntityDefinitions {
|
|||
EntityDefinition<LivingEntity> livingEntityBase = EntityDefinition.inherited(LivingEntity::new, entityBase)
|
||||
.addTranslator(MetadataType.BYTE, LivingEntity::setLivingEntityFlags)
|
||||
.addTranslator(MetadataType.FLOAT, LivingEntity::setHealth)
|
||||
.<Float>addTranslator(MetadataType.INT,
|
||||
.addTranslator(MetadataType.INT,
|
||||
(livingEntity, entityMetadata) -> livingEntity.getDirtyMetadata().put(EntityData.EFFECT_COLOR, entityMetadata.getValue()))
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN,
|
||||
.addTranslator(MetadataType.BOOLEAN,
|
||||
(livingEntity, entityMetadata) -> livingEntity.getDirtyMetadata().put(EntityData.EFFECT_AMBIENT, (byte) (((BooleanEntityMetadata) entityMetadata).getPrimitiveValue() ? 1 : 0)))
|
||||
.addTranslator(null) // Arrow count
|
||||
.addTranslator(null) // Stinger count
|
||||
|
@ -460,7 +459,7 @@ public final class EntityDefinitions {
|
|||
.height(1.7f).width(0.6f)
|
||||
.offset(1.62f)
|
||||
.addTranslator(MetadataType.INT, CreeperEntity::setSwelling)
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN, (entity, entityMetadata) -> entity.setFlag(EntityFlag.POWERED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, (entity, entityMetadata) -> entity.setFlag(EntityFlag.POWERED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, CreeperEntity::setIgnited)
|
||||
.build();
|
||||
DOLPHIN = EntityDefinition.inherited(WaterEntity::new, mobEntityBase)
|
||||
|
@ -746,12 +745,12 @@ public final class EntityDefinitions {
|
|||
MOOSHROOM = EntityDefinition.inherited(MooshroomEntity::new, ageableEntityBase) // TODO remove class
|
||||
.type(EntityType.MOOSHROOM)
|
||||
.height(1.4f).width(0.9f)
|
||||
.<String>addTranslator(MetadataType.STRING, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.VARIANT, entityMetadata.getValue().equals("brown") ? 1 : 0))
|
||||
.addTranslator(MetadataType.STRING, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.VARIANT, entityMetadata.getValue().equals("brown") ? 1 : 0))
|
||||
.build();
|
||||
OCELOT = EntityDefinition.inherited(OcelotEntity::new, ageableEntityBase)
|
||||
.type(EntityType.OCELOT)
|
||||
.height(0.35f).width(0.3f)
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN, (ocelotEntity, entityMetadata) -> ocelotEntity.setFlag(EntityFlag.TRUSTING, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, (ocelotEntity, entityMetadata) -> ocelotEntity.setFlag(EntityFlag.TRUSTING, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.build();
|
||||
PANDA = EntityDefinition.inherited(PandaEntity::new, ageableEntityBase)
|
||||
.type(EntityType.PANDA)
|
||||
|
@ -766,13 +765,13 @@ public final class EntityDefinitions {
|
|||
PIG = EntityDefinition.inherited(PigEntity::new, ageableEntityBase)
|
||||
.type(EntityType.PIG)
|
||||
.heightAndWidth(0.9f)
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN, (pigEntity, entityMetadata) -> pigEntity.setFlag(EntityFlag.SADDLED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, (pigEntity, entityMetadata) -> pigEntity.setFlag(EntityFlag.SADDLED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(null) // Boost time
|
||||
.build();
|
||||
POLAR_BEAR = EntityDefinition.inherited(PolarBearEntity::new, ageableEntityBase)
|
||||
.type(EntityType.POLAR_BEAR)
|
||||
.height(1.4f).width(1.3f)
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN, (entity, entityMetadata) -> entity.setFlag(EntityFlag.STANDING, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, (entity, entityMetadata) -> entity.setFlag(EntityFlag.STANDING, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.build();
|
||||
RABBIT = EntityDefinition.inherited(RabbitEntity::new, ageableEntityBase)
|
||||
.type(EntityType.RABBIT)
|
||||
|
@ -839,7 +838,7 @@ public final class EntityDefinitions {
|
|||
.height(1.6f).width(1.3965f)
|
||||
.build();
|
||||
EntityDefinition<ChestedHorseEntity> chestedHorseEntityBase = EntityDefinition.inherited(ChestedHorseEntity::new, abstractHorseEntityBase)
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN, (horseEntity, entityMetadata) -> horseEntity.setFlag(EntityFlag.CHESTED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, (horseEntity, entityMetadata) -> horseEntity.setFlag(EntityFlag.CHESTED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.build();
|
||||
DONKEY = EntityDefinition.inherited(chestedHorseEntityBase.factory(), chestedHorseEntityBase)
|
||||
.type(EntityType.DONKEY)
|
||||
|
@ -852,7 +851,7 @@ public final class EntityDefinitions {
|
|||
LLAMA = EntityDefinition.inherited(LlamaEntity::new, chestedHorseEntityBase)
|
||||
.type(EntityType.LLAMA)
|
||||
.height(1.87f).width(0.9f)
|
||||
.<Integer>addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.STRENGTH, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.STRENGTH, entityMetadata.getValue()))
|
||||
.addTranslator(MetadataType.INT, LlamaEntity::setCarpetedColor)
|
||||
.addTranslator(MetadataType.INT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.VARIANT, entityMetadata.getValue()))
|
||||
.build();
|
||||
|
@ -883,7 +882,7 @@ public final class EntityDefinitions {
|
|||
.type(EntityType.WOLF)
|
||||
.height(0.85f).width(0.6f)
|
||||
// "Begging" on wiki.vg, "Interested" in Nukkit - the tilt of the head
|
||||
.<Boolean>addTranslator(MetadataType.BOOLEAN, (wolfEntity, entityMetadata) -> wolfEntity.setFlag(EntityFlag.INTERESTED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.BOOLEAN, (wolfEntity, entityMetadata) -> wolfEntity.setFlag(EntityFlag.INTERESTED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()))
|
||||
.addTranslator(MetadataType.INT, WolfEntity::setCollarColor)
|
||||
.addTranslator(MetadataType.INT, WolfEntity::setWolfAngerTime)
|
||||
.build();
|
||||
|
|
|
@ -33,8 +33,7 @@ import java.util.function.BiConsumer;
|
|||
/**
|
||||
* Translates a given Java {@link EntityMetadata} into a similar/same construct for Bedrock
|
||||
*/
|
||||
|
||||
public record EntityMetadataTranslator<E extends Entity, T>(
|
||||
MetadataType acceptedType,
|
||||
BiConsumer<E, EntityMetadata<T>> translateFunction) {
|
||||
public record EntityMetadataTranslator<E extends Entity, T, EM extends EntityMetadata<T, ? extends MetadataType<T>>>(
|
||||
MetadataType<T> acceptedType,
|
||||
BiConsumer<E, EM> translateFunction) {
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -49,9 +48,9 @@ public class FallingBlockEntity extends Entity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setGravity(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setGravity(BooleanEntityMetadata entityMetadata) {
|
||||
super.setGravity(entityMetadata);
|
||||
// Set the NO_AI flag based on the no gravity flag to prevent movement
|
||||
setFlag(EntityFlag.NO_AI, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
setFlag(EntityFlag.NO_AI, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class FireworkEntity extends Entity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setFireworkItem(EntityMetadata<ItemStack> entityMetadata) {
|
||||
public void setFireworkItem(EntityMetadata<ItemStack, ?> entityMetadata) {
|
||||
ItemStack item = entityMetadata.getValue();
|
||||
if (item == null) {
|
||||
return;
|
||||
|
@ -135,7 +135,7 @@ public class FireworkEntity extends Entity {
|
|||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, builder.build());
|
||||
}
|
||||
|
||||
public void setPlayerGliding(EntityMetadata<OptionalInt> entityMetadata) {
|
||||
public void setPlayerGliding(EntityMetadata<OptionalInt, ?> entityMetadata) {
|
||||
OptionalInt optional = entityMetadata.getValue();
|
||||
// Checks if the firework has an entity ID (used when a player is gliding)
|
||||
// and checks to make sure the player that is gliding is the one getting sent the packet
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -76,8 +75,8 @@ public class FishingHookEntity extends ThrowableEntity {
|
|||
super.spawnEntity();
|
||||
}
|
||||
|
||||
public void setHookedEntity(EntityMetadata<Integer> entityMetadata) {
|
||||
int hookedEntityId = ((IntEntityMetadata) entityMetadata).getPrimitiveValue() - 1;
|
||||
public void setHookedEntity(IntEntityMetadata entityMetadata) {
|
||||
int hookedEntityId = entityMetadata.getPrimitiveValue() - 1;
|
||||
Entity entity;
|
||||
if (session.getPlayerEntity().getEntityId() == hookedEntityId) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -41,8 +40,8 @@ public class FurnaceMinecartEntity extends DefaultBlockMinecartEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setHasFuel(EntityMetadata<Boolean> entityMetadata) {
|
||||
hasFuel = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setHasFuel(BooleanEntityMetadata entityMetadata) {
|
||||
hasFuel = entityMetadata.getPrimitiveValue();
|
||||
updateDefaultBlockMetadata();
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public class ItemEntity extends ThrowableEntity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setItem(EntityMetadata<ItemStack> entityMetadata) {
|
||||
public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
|
||||
ItemData item = ItemTranslator.translateToBedrock(session, entityMetadata.getValue());
|
||||
if (this.item == null) {
|
||||
this.item = item;
|
||||
|
|
|
@ -109,7 +109,7 @@ public class ItemFrameEntity extends Entity {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
public void setItemInFrame(EntityMetadata<ItemStack> entityMetadata) {
|
||||
public void setItemInFrame(EntityMetadata<ItemStack, ?> entityMetadata) {
|
||||
if (entityMetadata.getValue() != null) {
|
||||
this.heldItem = entityMetadata.getValue();
|
||||
ItemData itemData = ItemTranslator.translateToBedrock(session, heldItem);
|
||||
|
@ -134,8 +134,8 @@ public class ItemFrameEntity extends Entity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setItemRotation(EntityMetadata<Integer> entityMetadata) {
|
||||
rotation = ((IntEntityMetadata) entityMetadata).getPrimitiveValue() * 45;
|
||||
public void setItemRotation(IntEntityMetadata entityMetadata) {
|
||||
rotation = entityMetadata.getPrimitiveValue() * 45;
|
||||
if (cachedTag == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.AttributeData;
|
||||
|
@ -53,6 +54,7 @@ import org.geysermc.connector.utils.ChunkUtils;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
|
@ -87,8 +89,8 @@ public class LivingEntity extends Entity {
|
|||
dirtyMetadata.put(EntityData.HEALTH, 1);
|
||||
}
|
||||
|
||||
public void setLivingEntityFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setLivingEntityFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
|
||||
// Blocking gets triggered when using a bow, but if we set USING_ITEM for all items, it may look like
|
||||
// you're "mining" with ex. a shield.
|
||||
|
@ -102,8 +104,8 @@ public class LivingEntity extends Entity {
|
|||
setFlag(EntityFlag.DAMAGE_NEARBY_MOBS, (xd & 0x04) == 0x04);
|
||||
}
|
||||
|
||||
public void setHealth(EntityMetadata<Float> entityMetadata) {
|
||||
this.health = ((FloatEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setHealth(FloatEntityMetadata entityMetadata) {
|
||||
this.health = entityMetadata.getPrimitiveValue();
|
||||
|
||||
AttributeData healthData = createHealthAttribute();
|
||||
UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket();
|
||||
|
@ -112,9 +114,10 @@ public class LivingEntity extends Entity {
|
|||
session.sendUpstreamPacket(attributesPacket);
|
||||
}
|
||||
|
||||
public Vector3i setBedPosition(EntityMetadata<Position> entityMetadata) {
|
||||
Position bedPosition = entityMetadata.getValue();
|
||||
if (bedPosition != null) {
|
||||
public Vector3i setBedPosition(EntityMetadata<Optional<Position>, ?> entityMetadata) {
|
||||
Optional<Position> optionalPos = entityMetadata.getValue();
|
||||
if (optionalPos.isPresent()) {
|
||||
Position bedPosition = optionalPos.get();
|
||||
Vector3i vector = Vector3i.from(bedPosition.getX(), bedPosition.getY(), bedPosition.getZ());
|
||||
dirtyMetadata.put(EntityData.BED_POSITION, vector);
|
||||
int bed = session.getConnector().getWorldManager().getBlockAt(session, bedPosition);
|
||||
|
@ -148,7 +151,7 @@ public class LivingEntity extends Entity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public float setFreezing(EntityMetadata<Integer> entityMetadata) {
|
||||
public float setFreezing(IntEntityMetadata entityMetadata) {
|
||||
float freezingPercentage = super.setFreezing(entityMetadata);
|
||||
this.isMaxFrozenState = freezingPercentage >= 1.0f;
|
||||
setFlag(EntityFlag.SHAKING, isShaking());
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -40,18 +39,18 @@ public class MinecartEntity extends Entity {
|
|||
super(session, entityId, geyserId, uuid, definition, position.add(0d, definition.offset(), 0d), motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setCustomBlock(EntityMetadata<Integer> entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(((IntEntityMetadata) entityMetadata).getPrimitiveValue()));
|
||||
public void setCustomBlock(IntEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_ITEM, session.getBlockMappings().getBedrockBlockId(entityMetadata.getPrimitiveValue()));
|
||||
}
|
||||
|
||||
public void setCustomBlockOffset(EntityMetadata<Integer> entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, entityMetadata.getValue());
|
||||
public void setCustomBlockOffset(IntEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.DISPLAY_OFFSET, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
public void setShowCustomBlock(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setShowCustomBlock(BooleanEntityMetadata entityMetadata) {
|
||||
// If the custom block should be enabled
|
||||
// Needs a byte based off of Java's boolean
|
||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, (byte) (((BooleanEntityMetadata) entityMetadata).getPrimitiveValue() ? 1 : 0));
|
||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, (byte) (entityMetadata.getPrimitiveValue() ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,7 +42,7 @@ public class TNTEntity extends Entity implements Tickable {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setFuseLength(EntityMetadata<Integer> entityMetadata) {
|
||||
public void setFuseLength(IntEntityMetadata entityMetadata) {
|
||||
currentTick = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
setFlag(EntityFlag.IGNITED, true);
|
||||
dirtyMetadata.put(EntityData.FUSE_LENGTH, currentTick);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ThrownPotionEntity extends ThrowableItemEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setPotion(EntityMetadata<ItemStack> entityMetadata) {
|
||||
public void setPotion(EntityMetadata<ItemStack, ?> entityMetadata) {
|
||||
ItemStack itemStack = entityMetadata.getValue();
|
||||
ItemMapping mapping = session.getItemMappings().getMapping(itemStack);
|
||||
if (mapping.getJavaIdentifier().endsWith("potion") && itemStack.getNbt() != null) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -43,8 +42,8 @@ public class TippedArrowEntity extends AbstractArrowEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setPotionEffectColor(EntityMetadata<Integer> entityMetadata) {
|
||||
int potionColor = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setPotionEffectColor(IntEntityMetadata entityMetadata) {
|
||||
int potionColor = entityMetadata.getPrimitiveValue();
|
||||
// -1 means no color
|
||||
if (potionColor == -1) {
|
||||
dirtyMetadata.put(EntityData.CUSTOM_DISPLAY, 0);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -41,8 +40,8 @@ public class WitherSkullEntity extends ItemedFireballEntity {
|
|||
this.futureTicks = 1;
|
||||
}
|
||||
|
||||
public void setDangerous(EntityMetadata<Boolean> entityMetadata) {
|
||||
boolean newDangerous = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setDangerous(BooleanEntityMetadata entityMetadata) {
|
||||
boolean newDangerous = entityMetadata.getPrimitiveValue();
|
||||
if (newDangerous != isCharged) {
|
||||
isCharged = newDangerous;
|
||||
// Is an entirely new entity in Bedrock but just a metadata type in Java
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -41,8 +40,8 @@ public class AgeableEntity extends CreatureEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setBaby(EntityMetadata<Boolean> entityMetadata) {
|
||||
boolean isBaby = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setBaby(BooleanEntityMetadata entityMetadata) {
|
||||
boolean isBaby = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.SCALE, isBaby ? getBabySize() : getAdultSize());
|
||||
setFlag(EntityFlag.BABY, isBaby);
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.geysermc.connector.entity.EntityDefinitions;
|
|||
import org.geysermc.connector.entity.LivingEntity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ArmorStandEntity extends LivingEntity {
|
||||
|
@ -117,13 +118,13 @@ public class ArmorStandEntity extends LivingEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(EntityMetadata<Component> entityMetadata) {
|
||||
public void setDisplayName(EntityMetadata<Optional<Component>, ?> entityMetadata) {
|
||||
super.setDisplayName(entityMetadata);
|
||||
updateSecondEntityStatus(false);
|
||||
}
|
||||
|
||||
public void setArmorStandFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setArmorStandFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
|
||||
// isSmall
|
||||
boolean newIsSmall = (xd & 0x01) == 0x01;
|
||||
|
@ -161,27 +162,27 @@ public class ArmorStandEntity extends LivingEntity {
|
|||
setFlag(EntityFlag.ADMIRING, (xd & 0x08) == 0x08); // Has no baseplate
|
||||
}
|
||||
|
||||
public void setHeadRotation(EntityMetadata<Rotation> entityMetadata) {
|
||||
public void setHeadRotation(EntityMetadata<Rotation, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.MARK_VARIANT, EntityFlag.INTERESTED, EntityFlag.CHARGED, EntityFlag.POWERED, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setBodyRotation(EntityMetadata<Rotation> entityMetadata) {
|
||||
public void setBodyRotation(EntityMetadata<Rotation, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.VARIANT, EntityFlag.IN_LOVE, EntityFlag.CELEBRATING, EntityFlag.CELEBRATING_SPECIAL, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setLeftArmRotation(EntityMetadata<Rotation> entityMetadata) {
|
||||
public void setLeftArmRotation(EntityMetadata<Rotation, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.TRADE_TIER, EntityFlag.CHARGING, EntityFlag.CRITICAL, EntityFlag.DANCING, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setRightArmRotation(EntityMetadata<Rotation> entityMetadata) {
|
||||
public void setRightArmRotation(EntityMetadata<Rotation, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.MAX_TRADE_TIER, EntityFlag.ELDER, EntityFlag.EMOTING, EntityFlag.IDLING, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setLeftLegRotation(EntityMetadata<Rotation> entityMetadata) {
|
||||
public void setLeftLegRotation(EntityMetadata<Rotation, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.SKIN_ID, EntityFlag.IS_ILLAGER_CAPTAIN, EntityFlag.IS_IN_UI, EntityFlag.LINGERING, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
public void setRightLegRotation(EntityMetadata<Rotation> entityMetadata) {
|
||||
public void setRightLegRotation(EntityMetadata<Rotation, ?> entityMetadata) {
|
||||
onRotationUpdate(EntityData.HURT_DIRECTION, EntityFlag.IS_PREGNANT, EntityFlag.SHEARED, EntityFlag.STALKING, entityMetadata.getValue());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -40,8 +39,8 @@ public class BatEntity extends AmbientEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setBatFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setBatFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.RESTING, (xd & 0x01) == 0x01);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -54,8 +53,8 @@ public class MobEntity extends LivingEntity {
|
|||
setLeashHolderBedrockId(-1);
|
||||
}
|
||||
|
||||
public void setMobFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setMobFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.NO_AI, (xd & 0x01) == 0x01);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -40,7 +39,7 @@ public class SlimeEntity extends MobEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setScale(EntityMetadata<Integer> entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.SCALE, 0.10f + ((IntEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public void setScale(IntEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.SCALE, 0.10f + entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -40,8 +39,8 @@ public class SnowGolemEntity extends GolemEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setSnowGolemFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setSnowGolemFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
// Handle the visibility of the pumpkin
|
||||
setFlag(EntityFlag.SHEARED, (xd & 0x10) != 0x10);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -42,8 +41,8 @@ public class AxolotlEntity extends AnimalEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setVariant(EntityMetadata<Integer> entityMetadata) {
|
||||
int variant = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setVariant(IntEntityMetadata entityMetadata) {
|
||||
int variant = entityMetadata.getPrimitiveValue();
|
||||
switch (variant) {
|
||||
case 1 -> variant = 3; // Java - "Wild" (brown)
|
||||
case 3 -> variant = 1; // Java - cyan
|
||||
|
@ -51,8 +50,8 @@ public class AxolotlEntity extends AnimalEntity {
|
|||
dirtyMetadata.put(EntityData.VARIANT, variant);
|
||||
}
|
||||
|
||||
public void setPlayingDead(EntityMetadata<Boolean> entityMetadata) {
|
||||
setFlag(EntityFlag.PLAYING_DEAD, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public void setPlayingDead(BooleanEntityMetadata entityMetadata) {
|
||||
setFlag(EntityFlag.PLAYING_DEAD, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -45,8 +44,8 @@ public class BeeEntity extends AnimalEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setBeeFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setBeeFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
// Bee is performing sting attack; trigger animation
|
||||
if ((xd & 0x02) == 0x02) {
|
||||
EntityEventPacket packet = new EntityEventPacket();
|
||||
|
@ -61,9 +60,9 @@ public class BeeEntity extends AnimalEntity {
|
|||
setFlag(EntityFlag.POWERED, (xd & 0x08) == 0x08);
|
||||
}
|
||||
|
||||
public void setAngerTime(EntityMetadata<Integer> entityMetadata) {
|
||||
public void setAngerTime(IntEntityMetadata entityMetadata) {
|
||||
// Converting "anger time" to a boolean
|
||||
setFlag(EntityFlag.ANGRY, ((IntEntityMetadata) entityMetadata).getPrimitiveValue() > 0);
|
||||
setFlag(EntityFlag.ANGRY, entityMetadata.getPrimitiveValue() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -42,12 +42,12 @@ public class FoxEntity extends AnimalEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setFoxVariant(EntityMetadata<Integer> entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.VARIANT, entityMetadata.getValue());
|
||||
public void setFoxVariant(IntEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.VARIANT, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
public void setFoxFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setFoxFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.SITTING, (xd & 0x01) == 0x01);
|
||||
setFlag(EntityFlag.SNEAKING, (xd & 0x04) == 0x04);
|
||||
setFlag(EntityFlag.INTERESTED, (xd & 0x08) == 0x08);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -46,9 +45,9 @@ public class GoatEntity extends AnimalEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setScreamer(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setScreamer(BooleanEntityMetadata entityMetadata) {
|
||||
// Metadata not used in Bedrock Edition
|
||||
isScreamer = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
isScreamer = entityMetadata.getPrimitiveValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -43,9 +42,9 @@ public class HoglinEntity extends AnimalEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setImmuneToZombification(BooleanEntityMetadata entityMetadata) {
|
||||
// Apply shaking effect if not in the nether and zombification is possible
|
||||
this.isImmuneToZombification = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
this.isImmuneToZombification = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.SHAKING, isShaking());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -47,8 +46,8 @@ public class PandaEntity extends AnimalEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setEatingCounter(EntityMetadata<Integer> entityMetadata) {
|
||||
int count = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setEatingCounter(IntEntityMetadata entityMetadata) {
|
||||
int count = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.EATING, count > 0);
|
||||
dirtyMetadata.put(EntityData.EATING_COUNTER, count);
|
||||
if (count != 0) {
|
||||
|
@ -61,18 +60,18 @@ public class PandaEntity extends AnimalEntity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setMainGene(EntityMetadata<Byte> entityMetadata) {
|
||||
mainGene = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setMainGene(ByteEntityMetadata entityMetadata) {
|
||||
mainGene = entityMetadata.getPrimitiveValue();
|
||||
updateAppearance();
|
||||
}
|
||||
|
||||
public void setHiddenGene(EntityMetadata<Byte> entityMetadata) {
|
||||
hiddenGene = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setHiddenGene(ByteEntityMetadata entityMetadata) {
|
||||
hiddenGene = entityMetadata.getPrimitiveValue();
|
||||
updateAppearance();
|
||||
}
|
||||
|
||||
public void setPandaFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setPandaFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.SNEEZING, (xd & 0x02) == 0x02);
|
||||
setFlag(EntityFlag.ROLLING, (xd & 0x04) == 0x04);
|
||||
setFlag(EntityFlag.SITTING, (xd & 0x08) == 0x08);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -41,8 +40,8 @@ public class PufferFishEntity extends AbstractFishEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setPufferfishSize(EntityMetadata<Integer> entityMetadata) {
|
||||
int puffsize = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setPufferfishSize(IntEntityMetadata entityMetadata) {
|
||||
int puffsize = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.PUFFERFISH_SIZE, (byte) puffsize);
|
||||
dirtyMetadata.put(EntityData.VARIANT, puffsize);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -43,12 +43,12 @@ public class RabbitEntity extends AnimalEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setBaby(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setBaby(BooleanEntityMetadata entityMetadata) {
|
||||
super.setBaby(entityMetadata);
|
||||
}
|
||||
|
||||
public void setRabbitVariant(EntityMetadata<Integer> entityMetadata) {
|
||||
int variant = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setRabbitVariant(IntEntityMetadata entityMetadata) {
|
||||
int variant = entityMetadata.getPrimitiveValue();
|
||||
|
||||
// Change the killer bunny to display as white since it only exists on Java Edition
|
||||
boolean isKillerBunny = variant == 99;
|
||||
|
|
|
@ -41,7 +41,7 @@ public class SheepEntity extends AnimalEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setSheepFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
public void setSheepFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
setFlag(EntityFlag.SHEARED, (xd & 0x10) == 0x10);
|
||||
dirtyMetadata.put(EntityData.COLOR, xd);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -47,12 +46,12 @@ public class StriderEntity extends AnimalEntity {
|
|||
setFlag(EntityFlag.BREATHING, true);
|
||||
}
|
||||
|
||||
public void setCold(EntityMetadata<Boolean> entityMetadata) {
|
||||
isCold = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setCold(BooleanEntityMetadata entityMetadata) {
|
||||
isCold = entityMetadata.getPrimitiveValue();
|
||||
}
|
||||
|
||||
public void setSaddled(EntityMetadata<Boolean> entityMetadata) {
|
||||
setFlag(EntityFlag.SADDLED, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public void setSaddled(BooleanEntityMetadata entityMetadata) {
|
||||
setFlag(EntityFlag.SADDLED, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -53,8 +52,8 @@ public class TropicalFishEntity extends AbstractFishEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setFishVariant(EntityMetadata<Integer> entityMetadata) {
|
||||
int varNumber = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setFishVariant(IntEntityMetadata entityMetadata) {
|
||||
int varNumber = entityMetadata.getPrimitiveValue();
|
||||
|
||||
dirtyMetadata.put(EntityData.VARIANT, getShape(varNumber)); // Shape 0-1
|
||||
dirtyMetadata.put(EntityData.MARK_VARIANT, getPattern(varNumber)); // Pattern 0-5
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -41,12 +40,12 @@ public class TurtleEntity extends AnimalEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setPregnant(EntityMetadata<Boolean> entityMetadata) {
|
||||
setFlag(EntityFlag.IS_PREGNANT, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public void setPregnant(BooleanEntityMetadata entityMetadata) {
|
||||
setFlag(EntityFlag.IS_PREGNANT, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
public void setLayingEgg(EntityMetadata<Boolean> entityMetadata) {
|
||||
setFlag(EntityFlag.LAYING_EGG, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public void setLayingEgg(BooleanEntityMetadata entityMetadata) {
|
||||
setFlag(EntityFlag.LAYING_EGG, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal.horse;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -79,8 +78,8 @@ public class AbstractHorseEntity extends AnimalEntity {
|
|||
session.sendUpstreamPacket(attributesPacket);
|
||||
}
|
||||
|
||||
public void setHorseFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setHorseFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
boolean tamed = (xd & 0x02) == 0x02;
|
||||
boolean saddled = (xd & 0x04) == 0x04;
|
||||
setFlag(EntityFlag.TAMED, tamed);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal.horse;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -40,8 +39,8 @@ public class HorseEntity extends AbstractHorseEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setHorseVariant(EntityMetadata<Integer> entityMetadata) {
|
||||
int value = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setHorseVariant(IntEntityMetadata entityMetadata) {
|
||||
int value = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.VARIANT, value & 255);
|
||||
dirtyMetadata.put(EntityData.MARK_VARIANT, (value >> 8) % 5);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal.horse;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -48,12 +47,12 @@ public class LlamaEntity extends ChestedHorseEntity {
|
|||
/**
|
||||
* Color equipped on the llama
|
||||
*/
|
||||
public void setCarpetedColor(EntityMetadata<Integer> entityMetadata) {
|
||||
public void setCarpetedColor(IntEntityMetadata entityMetadata) {
|
||||
// Bedrock treats llama decoration as armor
|
||||
MobArmorEquipmentPacket equipmentPacket = new MobArmorEquipmentPacket();
|
||||
equipmentPacket.setRuntimeEntityId(geyserId);
|
||||
// -1 means no armor
|
||||
int carpetIndex = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
int carpetIndex = entityMetadata.getPrimitiveValue();
|
||||
if (carpetIndex > -1 && carpetIndex <= 15) {
|
||||
// The damage value is the dye color that Java sends us, for pre-1.16.220
|
||||
// The item is always going to be a carpet
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal.tameable;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -61,7 +61,7 @@ public class CatEntity extends TameableEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setTameableFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
public void setTameableFlags(ByteEntityMetadata entityMetadata) {
|
||||
super.setTameableFlags(entityMetadata);
|
||||
// Update collar color if tamed
|
||||
if (getFlag(EntityFlag.TAMED)) {
|
||||
|
@ -69,9 +69,9 @@ public class CatEntity extends TameableEntity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setCatVariant(EntityMetadata<Integer> entityMetadata) {
|
||||
public void setCatVariant(IntEntityMetadata entityMetadata) {
|
||||
// Different colors in Java and Bedrock for some reason
|
||||
int metadataValue = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
int metadataValue = entityMetadata.getPrimitiveValue();
|
||||
int variantColor = switch (metadataValue) {
|
||||
case 0 -> 8;
|
||||
case 8 -> 0;
|
||||
|
@ -82,12 +82,12 @@ public class CatEntity extends TameableEntity {
|
|||
dirtyMetadata.put(EntityData.VARIANT, variantColor);
|
||||
}
|
||||
|
||||
public void setResting(EntityMetadata<Boolean> entityMetadata) {
|
||||
setFlag(EntityFlag.RESTING, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public void setResting(BooleanEntityMetadata entityMetadata) {
|
||||
setFlag(EntityFlag.RESTING, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
public void setCollarColor(EntityMetadata<Integer> entityMetadata) {
|
||||
collarColor = (byte) ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setCollarColor(IntEntityMetadata entityMetadata) {
|
||||
collarColor = (byte) entityMetadata.getPrimitiveValue();
|
||||
// Needed or else wild cats are a red color
|
||||
if (getFlag(EntityFlag.TAMED)) {
|
||||
dirtyMetadata.put(EntityData.COLOR, collarColor);
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.geysermc.connector.entity.EntityDefinition;
|
|||
import org.geysermc.connector.entity.living.animal.AnimalEntity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TameableEntity extends AnimalEntity {
|
||||
|
@ -49,18 +50,18 @@ public class TameableEntity extends AnimalEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setTameableFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setTameableFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.SITTING, (xd & 0x01) == 0x01);
|
||||
setFlag(EntityFlag.ANGRY, (xd & 0x02) == 0x02);
|
||||
setFlag(EntityFlag.TAMED, (xd & 0x04) == 0x04);
|
||||
}
|
||||
|
||||
public void setOwner(EntityMetadata<UUID> entityMetadata) {
|
||||
public void setOwner(EntityMetadata<Optional<UUID>, ?> entityMetadata) {
|
||||
// Note: Must be set for wolf collar color to work
|
||||
if (entityMetadata.getValue() != null) {
|
||||
if (entityMetadata.getValue().isPresent()) {
|
||||
// Owner UUID of entity
|
||||
Entity entity = session.getEntityCache().getPlayerEntity(entityMetadata.getValue());
|
||||
Entity entity = session.getEntityCache().getPlayerEntity(entityMetadata.getValue().get());
|
||||
// Used as both a check since the player isn't in the entity cache and a normal fallback
|
||||
if (entity == null) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.animal.tameable;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -55,18 +54,18 @@ public class WolfEntity extends TameableEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setTameableFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
public void setTameableFlags(ByteEntityMetadata entityMetadata) {
|
||||
super.setTameableFlags(entityMetadata);
|
||||
// Reset wolf color
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
boolean angry = (xd & 0x02) == 0x02;
|
||||
if (angry) {
|
||||
dirtyMetadata.put(EntityData.COLOR, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCollarColor(EntityMetadata<Integer> entityMetadata) {
|
||||
collarColor = (byte) ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setCollarColor(IntEntityMetadata entityMetadata) {
|
||||
collarColor = (byte) entityMetadata.getPrimitiveValue();
|
||||
if (getFlag(EntityFlag.ANGRY)) {
|
||||
return;
|
||||
}
|
||||
|
@ -80,8 +79,8 @@ public class WolfEntity extends TameableEntity {
|
|||
}
|
||||
|
||||
// 1.16+
|
||||
public void setWolfAngerTime(EntityMetadata<Integer> entityMetadata) {
|
||||
int time = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setWolfAngerTime(IntEntityMetadata entityMetadata) {
|
||||
int time = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.ANGRY, time != 0);
|
||||
dirtyMetadata.put(EntityData.COLOR, time != 0 ? (byte) 0 : collarColor);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.geysermc.connector.entity.EntityDefinition;
|
|||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.registry.BlockRegistries;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VillagerEntity extends AbstractMerchantEntity {
|
||||
|
@ -91,7 +92,7 @@ public class VillagerEntity extends AbstractMerchantEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setVillagerData(EntityMetadata<VillagerData> entityMetadata) {
|
||||
public void setVillagerData(EntityMetadata<VillagerData, ?> entityMetadata) {
|
||||
VillagerData villagerData = entityMetadata.getValue();
|
||||
// Profession
|
||||
int profession = VILLAGER_PROFESSIONS.get(villagerData.getProfession());
|
||||
|
@ -105,7 +106,7 @@ public class VillagerEntity extends AbstractMerchantEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vector3i setBedPosition(EntityMetadata<Position> entityMetadata) {
|
||||
public Vector3i setBedPosition(EntityMetadata<Optional<Position>, ?> entityMetadata) {
|
||||
return bedPosition = super.setBedPosition(entityMetadata);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -41,9 +40,9 @@ public class AbstractSkeletonEntity extends MonsterEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setMobFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
public void setMobFlags(ByteEntityMetadata entityMetadata) {
|
||||
super.setMobFlags(entityMetadata);
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
// A bit of a loophole so the hands get raised - set the target ID to its own ID
|
||||
dirtyMetadata.put(EntityData.TARGET_EID, ((xd & 4) == 4) ? geyserId : 0);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -42,9 +41,9 @@ public class BasePiglinEntity extends MonsterEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setImmuneToZombification(BooleanEntityMetadata entityMetadata) {
|
||||
// Apply shaking effect if not in the nether and zombification is possible
|
||||
this.isImmuneToZombification = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
this.isImmuneToZombification = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.SHAKING, isShaking());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -40,8 +39,8 @@ public class BlazeEntity extends MonsterEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setBlazeFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setBlazeFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.ON_FIRE, (xd & 0x01) == 0x01);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -37,8 +36,8 @@ import java.util.UUID;
|
|||
|
||||
public class CreeperEntity extends MonsterEntity {
|
||||
/**
|
||||
* Whether the creeper has been ignited and is using {@link #setIgnited(EntityMetadata)}.
|
||||
* In this instance we ignore {@link #setSwelling(EntityMetadata)} since it's sending us -1 which confuses poor Bedrock.
|
||||
* Whether the creeper has been ignited and is using {@link #setIgnited(BooleanEntityMetadata)}.
|
||||
* In this instance we ignore {@link #setSwelling(IntEntityMetadata)} since it's sending us -1 which confuses poor Bedrock.
|
||||
*/
|
||||
private boolean ignitedByFlintAndSteel = false;
|
||||
|
||||
|
@ -46,14 +45,14 @@ public class CreeperEntity extends MonsterEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setSwelling(EntityMetadata<Integer> entityMetadata) {
|
||||
public void setSwelling(IntEntityMetadata entityMetadata) {
|
||||
if (!ignitedByFlintAndSteel) {
|
||||
setFlag(EntityFlag.IGNITED, ((IntEntityMetadata) entityMetadata).getPrimitiveValue() == 1);
|
||||
setFlag(EntityFlag.IGNITED, entityMetadata.getPrimitiveValue() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIgnited(EntityMetadata<Boolean> entityMetadata) {
|
||||
ignitedByFlintAndSteel = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setIgnited(BooleanEntityMetadata entityMetadata) {
|
||||
ignitedByFlintAndSteel = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.IGNITED, ignitedByFlintAndSteel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
|
@ -90,7 +90,7 @@ public class EnderDragonEntity extends MobEntity implements Tickable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(EntityMetadata<Float> entityMetadata) {
|
||||
public void setHealth(FloatEntityMetadata entityMetadata) {
|
||||
super.setHealth(entityMetadata);
|
||||
if (phase == 9 && this.health <= 0) { // Dying phase
|
||||
EntityEventPacket entityEventPacket = new EntityEventPacket();
|
||||
|
@ -101,8 +101,8 @@ public class EnderDragonEntity extends MobEntity implements Tickable {
|
|||
}
|
||||
}
|
||||
|
||||
public void setPhase(EntityMetadata<Integer> entityMetadata) {
|
||||
phase = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setPhase(IntEntityMetadata entityMetadata) {
|
||||
phase = entityMetadata.getPrimitiveValue();
|
||||
phaseTicks = 0;
|
||||
setFlag(EntityFlag.SITTING, isSitting());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -44,17 +43,17 @@ public class EndermanEntity extends MonsterEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setCarriedBlock(EntityMetadata<Integer> entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.CARRIED_BLOCK, session.getBlockMappings().getBedrockBlockId(((IntEntityMetadata) entityMetadata).getPrimitiveValue()));
|
||||
public void setCarriedBlock(IntEntityMetadata entityMetadata) {
|
||||
dirtyMetadata.put(EntityData.CARRIED_BLOCK, session.getBlockMappings().getBedrockBlockId(entityMetadata.getPrimitiveValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the screaming sound
|
||||
*/
|
||||
public void setScreaming(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setScreaming(BooleanEntityMetadata entityMetadata) {
|
||||
//TODO see if Bedrock controls this differently
|
||||
// Java Edition this controls which ambient sound is used
|
||||
if (((BooleanEntityMetadata) entityMetadata).getPrimitiveValue()) {
|
||||
if (entityMetadata.getPrimitiveValue()) {
|
||||
LevelSoundEvent2Packet packet = new LevelSoundEvent2Packet();
|
||||
packet.setSound(SoundEvent.STARE);
|
||||
packet.setPosition(this.position);
|
||||
|
@ -64,8 +63,8 @@ public class EndermanEntity extends MonsterEntity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setAngry(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setAngry(BooleanEntityMetadata entityMetadata) {
|
||||
// "Is staring/provoked" - controls visuals
|
||||
setFlag(EntityFlag.ANGRY, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
setFlag(EntityFlag.ANGRY, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -41,8 +40,8 @@ public class GhastEntity extends FlyingEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setGhastAttacking(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setGhastAttacking(BooleanEntityMetadata entityMetadata) {
|
||||
// If the ghast is attacking
|
||||
dirtyMetadata.put(EntityData.CHARGE_AMOUNT, (byte) (((BooleanEntityMetadata) entityMetadata).getPrimitiveValue() ? 1 : 0));
|
||||
dirtyMetadata.put(EntityData.CHARGE_AMOUNT, (byte) (entityMetadata.getPrimitiveValue() ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -41,8 +40,8 @@ public class GuardianEntity extends MonsterEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setGuardianTarget(EntityMetadata<Integer> entityMetadata) {
|
||||
int entityId = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setGuardianTarget(IntEntityMetadata entityMetadata) {
|
||||
int entityId = entityMetadata.getPrimitiveValue();
|
||||
Entity entity;
|
||||
if (session.getPlayerEntity().getEntityId() == entityId) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -40,8 +39,8 @@ public class PhantomEntity extends FlyingEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setPhantomScale(EntityMetadata<Integer> entityMetadata) {
|
||||
int size = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setPhantomScale(IntEntityMetadata entityMetadata) {
|
||||
int size = entityMetadata.getPrimitiveValue();
|
||||
float modelScale = 1f + 0.15f * size;
|
||||
float boundsScale = (1f + (0.2f * size) / definition.width()) / modelScale;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -41,18 +40,18 @@ public class PiglinEntity extends BasePiglinEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setBaby(EntityMetadata<Boolean> entityMetadata) {
|
||||
boolean isBaby = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setBaby(BooleanEntityMetadata entityMetadata) {
|
||||
boolean isBaby = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.SCALE, isBaby? .55f : 1f);
|
||||
setFlag(EntityFlag.BABY, isBaby);
|
||||
}
|
||||
|
||||
public void setChargingCrossbow(EntityMetadata<Boolean> entityMetadata) {
|
||||
setFlag(EntityFlag.CHARGING, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public void setChargingCrossbow(BooleanEntityMetadata entityMetadata) {
|
||||
setFlag(EntityFlag.CHARGING, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
public void setDancing(EntityMetadata<Boolean> entityMetadata) {
|
||||
setFlag(EntityFlag.DANCING, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue());
|
||||
public void setDancing(BooleanEntityMetadata entityMetadata) {
|
||||
setFlag(EntityFlag.DANCING, entityMetadata.getPrimitiveValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,13 +27,13 @@ package org.geysermc.connector.entity.living.monster;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.connector.entity.EntityDefinition;
|
||||
import org.geysermc.connector.entity.living.GolemEntity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.utils.Direction;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -45,17 +45,17 @@ public class ShulkerEntity extends GolemEntity {
|
|||
setFlag(EntityFlag.BRIBED, true);
|
||||
}
|
||||
|
||||
public void setAttachedFace(EntityMetadata<Direction> entityMetadata) {
|
||||
public void setAttachedFace(EntityMetadata<Direction, ?> entityMetadata) {
|
||||
Direction direction = entityMetadata.getValue();
|
||||
dirtyMetadata.put(EntityData.SHULKER_ATTACH_FACE, (byte) direction.ordinal());
|
||||
}
|
||||
|
||||
public void setShulkerHeight(EntityMetadata<Byte> entityMetadata) {
|
||||
int height = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setShulkerHeight(ByteEntityMetadata entityMetadata) {
|
||||
int height = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.SHULKER_PEEK_ID, height);
|
||||
}
|
||||
|
||||
public void setShulkerColor(EntityMetadata<Byte> entityMetadata) {
|
||||
public void setShulkerColor(ByteEntityMetadata entityMetadata) {
|
||||
byte color = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
if (color == 16) {
|
||||
// 16 is default on both editions
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -41,8 +40,8 @@ public class SkeletonEntity extends AbstractSkeletonEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setConvertingToStray(EntityMetadata<Boolean> entityMetadata) {
|
||||
this.convertingToStray = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setConvertingToStray(BooleanEntityMetadata entityMetadata) {
|
||||
this.convertingToStray = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.SHAKING, isShaking());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -40,8 +39,8 @@ public class SpiderEntity extends MonsterEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setSpiderFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setSpiderFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.WALL_CLIMBING, (xd & 0x01) == 0x01);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -40,8 +39,8 @@ public class VexEntity extends MonsterEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setVexFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setVexFlags(ByteEntityMetadata entityMetadata) {
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
// Set the target to the player to force the attack animation
|
||||
// even if the player isn't the target as we dont get the target on Java
|
||||
dirtyMetadata.put(EntityData.TARGET_EID, (xd & 0x01) == 0x01 ? session.getPlayerEntity().getGeyserId() : 0);
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -47,20 +46,20 @@ public class WitherEntity extends MonsterEntity {
|
|||
dirtyMetadata.put(EntityData.WITHER_AERIAL_ATTACK, (short) 1);
|
||||
}
|
||||
|
||||
public void setTarget1(EntityMetadata<Integer> entityMetadata) {
|
||||
public void setTarget1(IntEntityMetadata entityMetadata) {
|
||||
setTargetId(EntityData.WITHER_TARGET_1, entityMetadata);
|
||||
}
|
||||
|
||||
public void setTarget2(EntityMetadata<Integer> entityMetadata) {
|
||||
public void setTarget2(IntEntityMetadata entityMetadata) {
|
||||
setTargetId(EntityData.WITHER_TARGET_2, entityMetadata);
|
||||
}
|
||||
|
||||
public void setTarget3(EntityMetadata<Integer> entityMetadata) {
|
||||
public void setTarget3(IntEntityMetadata entityMetadata) {
|
||||
setTargetId(EntityData.WITHER_TARGET_3, entityMetadata);
|
||||
}
|
||||
|
||||
private void setTargetId(EntityData entityData, EntityMetadata<Integer> entityMetadata) {
|
||||
int entityId = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
private void setTargetId(EntityData entityData, IntEntityMetadata entityMetadata) {
|
||||
int entityId = entityMetadata.getPrimitiveValue();
|
||||
Entity entity;
|
||||
if (session.getPlayerEntity().getEntityId() == entityId) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
@ -73,8 +72,8 @@ public class WitherEntity extends MonsterEntity {
|
|||
}
|
||||
}
|
||||
|
||||
public void setInvulnerableTicks(EntityMetadata<Integer> entityMetadata) {
|
||||
int value = ((IntEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setInvulnerableTicks(IntEntityMetadata entityMetadata) {
|
||||
int value = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.WITHER_INVULNERABLE_TICKS, value);
|
||||
|
||||
// Show the shield for the first few seconds of spawning (like Java)
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -41,8 +40,8 @@ public class ZoglinEntity extends MonsterEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setBaby(EntityMetadata<Boolean> entityMetadata) {
|
||||
boolean isBaby = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setBaby(BooleanEntityMetadata entityMetadata) {
|
||||
boolean isBaby = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.SCALE, isBaby? .55f : 1f);
|
||||
setFlag(EntityFlag.BABY, isBaby);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -42,14 +41,14 @@ public class ZombieEntity extends MonsterEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setZombieBaby(EntityMetadata<Boolean> entityMetadata) {
|
||||
boolean isBaby = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setZombieBaby(BooleanEntityMetadata entityMetadata) {
|
||||
boolean isBaby = entityMetadata.getPrimitiveValue();
|
||||
dirtyMetadata.put(EntityData.SCALE, isBaby ? .55f : 1.0f);
|
||||
setFlag(EntityFlag.BABY, isBaby);
|
||||
}
|
||||
|
||||
public void setConvertingToDrowned(EntityMetadata<Boolean> entityMetadata) {
|
||||
convertingToDrowned = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setConvertingToDrowned(BooleanEntityMetadata entityMetadata) {
|
||||
convertingToDrowned = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.SHAKING, isShaking());
|
||||
}
|
||||
|
||||
|
|
|
@ -44,13 +44,13 @@ public class ZombieVillagerEntity extends ZombieEntity {
|
|||
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
|
||||
}
|
||||
|
||||
public void setTransforming(EntityMetadata<Boolean> entityMetadata) {
|
||||
isTransforming = ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setTransforming(BooleanEntityMetadata entityMetadata) {
|
||||
isTransforming = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.IS_TRANSFORMING, isTransforming);
|
||||
setFlag(EntityFlag.SHAKING, isShaking());
|
||||
}
|
||||
|
||||
public void setZombieVillagerData(EntityMetadata<VillagerData> entityMetadata) {
|
||||
public void setZombieVillagerData(EntityMetadata<VillagerData, ?> entityMetadata) {
|
||||
VillagerData villagerData = entityMetadata.getValue();
|
||||
dirtyMetadata.put(EntityData.VARIANT, VillagerEntity.VILLAGER_PROFESSIONS.get(villagerData.getProfession())); // Actually works properly with the OptionalPack
|
||||
dirtyMetadata.put(EntityData.MARK_VARIANT, VillagerEntity.VILLAGER_REGIONS.get(villagerData.getType()));
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster.raid;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -47,8 +46,8 @@ public class SpellcasterIllagerEntity extends AbstractIllagerEntity {
|
|||
setFlag(EntityFlag.BRIBED, this.definition == EntityDefinitions.ILLUSIONER);
|
||||
}
|
||||
|
||||
public void setSpellType(EntityMetadata<Byte> entityMetadata) {
|
||||
int spellType = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
public void setSpellType(ByteEntityMetadata entityMetadata) {
|
||||
int spellType = entityMetadata.getPrimitiveValue();
|
||||
// Summon vex, attack, or wololo
|
||||
setFlag(EntityFlag.CASTING, spellType == 1 || spellType == 2 || spellType == 3);
|
||||
int rgbData = switch (spellType) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.connector.entity.living.monster.raid;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -41,10 +40,10 @@ public class VindicatorEntity extends AbstractIllagerEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setMobFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
public void setMobFlags(ByteEntityMetadata entityMetadata) {
|
||||
super.setMobFlags(entityMetadata);
|
||||
// Allow the axe to be shown if necessary
|
||||
byte xd = ((ByteEntityMetadata) entityMetadata).getPrimitiveValue();
|
||||
byte xd = entityMetadata.getPrimitiveValue();
|
||||
setFlag(EntityFlag.ANGRY, (xd & 4) == 4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.github.steveice10.mc.auth.data.GameProfile;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreboardPosition;
|
||||
|
@ -60,6 +61,7 @@ import org.geysermc.connector.scoreboard.UpdateType;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Getter @Setter
|
||||
|
@ -255,33 +257,33 @@ public class PlayerEntity extends LivingEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vector3i setBedPosition(EntityMetadata<Position> entityMetadata) {
|
||||
public Vector3i setBedPosition(EntityMetadata<Optional<Position>, ?> entityMetadata) {
|
||||
return bedPosition = super.setBedPosition(entityMetadata);
|
||||
}
|
||||
|
||||
public void setAbsorptionHearts(EntityMetadata<Float> entityMetadata) {
|
||||
public void setAbsorptionHearts(FloatEntityMetadata entityMetadata) {
|
||||
// Extra hearts - is not metadata but an attribute on Bedrock
|
||||
UpdateAttributesPacket attributesPacket = new UpdateAttributesPacket();
|
||||
attributesPacket.setRuntimeEntityId(geyserId);
|
||||
// Setting to a higher maximum since plugins/datapacks can probably extend the Bedrock soft limit
|
||||
attributesPacket.setAttributes(Collections.singletonList(
|
||||
new AttributeData("minecraft:absorption", 0.0f, 1024f, ((FloatEntityMetadata) entityMetadata).getPrimitiveValue(), 0.0f)));
|
||||
new AttributeData("minecraft:absorption", 0.0f, 1024f, entityMetadata.getPrimitiveValue(), 0.0f)));
|
||||
session.sendUpstreamPacket(attributesPacket);
|
||||
}
|
||||
|
||||
public void setSkinVisibility(EntityMetadata<Byte> entityMetadata) {
|
||||
public void setSkinVisibility(ByteEntityMetadata entityMetadata) {
|
||||
// OptionalPack usage for toggling skin bits
|
||||
// In Java Edition, a bit being set means that part should be enabled
|
||||
// However, to ensure that the pack still works on other servers, we invert the bit so all values by default
|
||||
// are true (0).
|
||||
dirtyMetadata.put(EntityData.MARK_VARIANT, ~((ByteEntityMetadata) entityMetadata).getPrimitiveValue() & 0xff);
|
||||
dirtyMetadata.put(EntityData.MARK_VARIANT, ~entityMetadata.getPrimitiveValue() & 0xff);
|
||||
}
|
||||
|
||||
public void setLeftParrot(EntityMetadata<CompoundTag> entityMetadata) {
|
||||
public void setLeftParrot(EntityMetadata<CompoundTag, ?> entityMetadata) {
|
||||
setParrot(entityMetadata.getValue(), true);
|
||||
}
|
||||
|
||||
public void setRightParrot(EntityMetadata<CompoundTag> entityMetadata) {
|
||||
public void setRightParrot(EntityMetadata<CompoundTag, ?> entityMetadata) {
|
||||
setParrot(entityMetadata.getValue(), false);
|
||||
}
|
||||
|
||||
|
@ -330,7 +332,7 @@ public class PlayerEntity extends LivingEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(EntityMetadata<Component> entityMetadata) {
|
||||
public void setDisplayName(EntityMetadata<Optional<Component>, ?> entityMetadata) {
|
||||
// Doesn't do anything for players
|
||||
}
|
||||
|
||||
|
@ -385,7 +387,7 @@ public class PlayerEntity extends LivingEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayNameVisible(EntityMetadata<Boolean> entityMetadata) {
|
||||
public void setDisplayNameVisible(BooleanEntityMetadata entityMetadata) {
|
||||
// Doesn't do anything for players
|
||||
}
|
||||
|
||||
|
|
|
@ -110,14 +110,14 @@ public class SessionPlayerEntity extends PlayerEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setFlags(EntityMetadata<Byte> entityMetadata) {
|
||||
public void setFlags(ByteEntityMetadata entityMetadata) {
|
||||
super.setFlags(entityMetadata);
|
||||
session.setSwimmingInWater((((ByteEntityMetadata) entityMetadata).getPrimitiveValue() & 0x10) == 0x10 && getFlag(EntityFlag.SPRINTING));
|
||||
session.setSwimmingInWater((entityMetadata.getPrimitiveValue() & 0x10) == 0x10 && getFlag(EntityFlag.SPRINTING));
|
||||
refreshSpeed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPose(EntityMetadata<Pose> entityMetadata) {
|
||||
public void setPose(EntityMetadata<Pose, ?> entityMetadata) {
|
||||
super.setPose(entityMetadata);
|
||||
session.setPose(entityMetadata.getValue());
|
||||
refreshSpeed = true;
|
||||
|
@ -132,11 +132,11 @@ public class SessionPlayerEntity extends PlayerEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void setAir(int amount) {
|
||||
protected void setAirSupply(int amount) {
|
||||
if (amount == getMaxAir()) {
|
||||
super.setAir(0); // Hide the bubble counter from the UI for the player
|
||||
super.setAirSupply(0); // Hide the bubble counter from the UI for the player
|
||||
} else {
|
||||
super.setAir(amount);
|
||||
super.setAirSupply(amount);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,10 @@
|
|||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEntityDataPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.EntityDefinition;
|
||||
import org.geysermc.connector.entity.EntityMetadataTranslator;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
|
@ -39,6 +41,7 @@ import java.util.List;
|
|||
@Translator(packet = ClientboundSetEntityDataPacket.class)
|
||||
public class JavaSetEntityDataTranslator extends PacketTranslator<ClientboundSetEntityDataPacket> {
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public void translate(GeyserSession session, ClientboundSetEntityDataPacket packet) {
|
||||
Entity entity;
|
||||
|
@ -49,30 +52,17 @@ public class JavaSetEntityDataTranslator extends PacketTranslator<ClientboundSet
|
|||
}
|
||||
if (entity == null) return;
|
||||
|
||||
List<EntityMetadataTranslator<?, ?>> translators = (List<EntityMetadataTranslator<?, ?>>) entity.getDefinition().translators();
|
||||
|
||||
for (EntityMetadata<?> metadata : packet.getMetadata()) {
|
||||
if (metadata.getId() >= translators.size()) {
|
||||
session.getConnector().getLogger().warning("Metadata ID " + metadata.getId() + " is out of bounds of known entity metadata size " + translators.size() + " for entity type " + entity.getDefinition().entityType());
|
||||
EntityDefinition<?> definition = entity.getDefinition();
|
||||
for (EntityMetadata<?, ?> metadata : packet.getMetadata()) {
|
||||
if (metadata.getId() >= definition.translators().size()) {
|
||||
session.getConnector().getLogger().warning("Metadata ID " + metadata.getId() + " is out of bounds of known entity metadata size " + definition.translators().size() + " for entity type " + entity.getDefinition().entityType());
|
||||
if (session.getConnector().getConfig().isDebugMode()) {
|
||||
session.getConnector().getLogger().debug(metadata.toString());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
EntityMetadataTranslator<? super Entity, Object> translator = (EntityMetadataTranslator<? super Entity, Object>) translators.get(metadata.getId());
|
||||
if (translator == null) {
|
||||
// This can safely happen; it means we don't translate this entity metadata
|
||||
continue;
|
||||
}
|
||||
if (translator.acceptedType() != metadata.getType()) {
|
||||
session.getConnector().getLogger().warning("Metadata ID " + metadata.getId() + " was received with type " + metadata.getType() + " but we expected " + translator.acceptedType() + " for " + entity.getDefinition().entityType());
|
||||
if (session.getConnector().getConfig().isDebugMode()) {
|
||||
session.getConnector().getLogger().debug(metadata.toString());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
translator.translateFunction().accept(entity, (EntityMetadata<Object>) metadata);
|
||||
((EntityDefinition) definition).translateMetadata(entity, metadata);
|
||||
}
|
||||
|
||||
entity.updateBedrockMetadata();
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.geysermc.connector.utils.FileUtils;
|
|||
import java.io.InputStream;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
|||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.registry.type.ParticleMapping;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
|
Loading…
Reference in a new issue