mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 10:05:12 +01:00
Cleanup modern entity types
This commit is contained in:
parent
69609d536b
commit
64b7e74d80
@ -6,7 +6,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
// TODO auto generate 18w11a with PAaaS
|
||||
public class Entity1_13Types {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
||||
|
@ -2,26 +2,11 @@ package us.myles.ViaVersion.api.entities;
|
||||
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Entity1_14Types {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID) {
|
||||
Optional<EntityType> type = EntityType.findById(typeID);
|
||||
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.14 type id " + typeID);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
|
||||
return type.get();
|
||||
}
|
||||
|
||||
public enum EntityType implements us.myles.ViaVersion.api.entities.EntityType {
|
||||
// Auto generated
|
||||
public enum Entity1_14Types implements EntityType {
|
||||
|
||||
ENTITY(-1),
|
||||
|
||||
@ -194,20 +179,19 @@ public class Entity1_14Types {
|
||||
COMMAND_BLOCK_MINECART(43, MINECART_ABSTRACT),
|
||||
TNT_MINECART(47, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(46, MINECART_ABSTRACT),
|
||||
BOAT(5, ENTITY),
|
||||
;
|
||||
BOAT(5, ENTITY);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final EntityType[] TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
Entity1_14Types(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
Entity1_14Types(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
}
|
||||
@ -223,15 +207,23 @@ public class Entity1_14Types {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
List<Entity1_14Types> types = new ArrayList<>();
|
||||
for (Entity1_14Types type : values()) {
|
||||
if (type.id != -1) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
}
|
||||
types.sort(Comparator.comparingInt(Entity1_14Types::getId));
|
||||
TYPES = types.toArray(new EntityType[0]);
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(int typeId) {
|
||||
EntityType type;
|
||||
if (typeId < 0 || typeId >= TYPES.length || (type = TYPES[typeId]) == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.14 type id " + typeId);
|
||||
return ENTITY;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
@ -2,25 +2,12 @@ package us.myles.ViaVersion.api.entities;
|
||||
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public enum Entity1_15Types implements EntityType {
|
||||
|
||||
public class Entity1_15Types {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID) {
|
||||
Optional<EntityType> type = EntityType.findById(typeID);
|
||||
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.15 type id " + typeID);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
|
||||
return type.get();
|
||||
}
|
||||
|
||||
public enum EntityType implements us.myles.ViaVersion.api.entities.EntityType {
|
||||
ENTITY(-1),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
@ -196,17 +183,17 @@ public class Entity1_15Types {
|
||||
SPAWNER_MINECART(47, MINECART_ABSTRACT),
|
||||
BOAT(6, ENTITY);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final EntityType[] TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
Entity1_15Types(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
Entity1_15Types(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
}
|
||||
@ -222,15 +209,23 @@ public class Entity1_15Types {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
List<Entity1_15Types> types = new ArrayList<>();
|
||||
for (Entity1_15Types type : values()) {
|
||||
if (type.id != -1) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
}
|
||||
types.sort(Comparator.comparingInt(Entity1_15Types::getId));
|
||||
TYPES = types.toArray(new EntityType[0]);
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(int typeId) {
|
||||
EntityType type;
|
||||
if (typeId < 0 || typeId >= TYPES.length || (type = TYPES[typeId]) == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.15 type id " + typeId);
|
||||
return ENTITY;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
@ -2,25 +2,12 @@ package us.myles.ViaVersion.api.entities;
|
||||
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public enum Entity1_16Types implements EntityType {
|
||||
|
||||
public class Entity1_16Types {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID) {
|
||||
Optional<EntityType> type = EntityType.findById(typeID);
|
||||
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.16 type id " + typeID);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
|
||||
return type.get();
|
||||
}
|
||||
|
||||
public enum EntityType implements us.myles.ViaVersion.api.entities.EntityType {
|
||||
ENTITY(-1),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
@ -201,17 +188,17 @@ public class Entity1_16Types {
|
||||
SPAWNER_MINECART(50, MINECART_ABSTRACT),
|
||||
BOAT(6, ENTITY);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final EntityType[] TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
Entity1_16Types(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
Entity1_16Types(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
}
|
||||
@ -227,15 +214,23 @@ public class Entity1_16Types {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
List<Entity1_16Types> types = new ArrayList<>();
|
||||
for (Entity1_16Types type : values()) {
|
||||
if (type.id != -1) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
}
|
||||
types.sort(Comparator.comparingInt(Entity1_16Types::getId));
|
||||
TYPES = types.toArray(new EntityType[0]);
|
||||
}
|
||||
|
||||
public static us.myles.ViaVersion.api.entities.EntityType getTypeFromId(int typeId) {
|
||||
us.myles.ViaVersion.api.entities.EntityType type;
|
||||
if (typeId < 0 || typeId >= TYPES.length || (type = TYPES[typeId]) == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.16 type id " + typeId);
|
||||
return ENTITY;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,12 @@ package us.myles.ViaVersion.api.entities;
|
||||
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public enum Entity1_16_2Types implements EntityType {
|
||||
|
||||
public class Entity1_16_2Types {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID) {
|
||||
Optional<EntityType> type = EntityType.findById(typeID);
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.16.2 type id " + typeID);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
return type.get();
|
||||
}
|
||||
|
||||
public enum EntityType implements us.myles.ViaVersion.api.entities.EntityType {
|
||||
ENTITY(-1),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
@ -203,17 +192,17 @@ public class Entity1_16_2Types {
|
||||
SPAWNER_MINECART(50, MINECART_ABSTRACT),
|
||||
BOAT(6, ENTITY);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final EntityType[] TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
Entity1_16_2Types(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
Entity1_16_2Types(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
}
|
||||
@ -229,15 +218,23 @@ public class Entity1_16_2Types {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
List<Entity1_16_2Types> types = new ArrayList<>();
|
||||
for (Entity1_16_2Types type : values()) {
|
||||
if (type.id != -1) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
}
|
||||
types.sort(Comparator.comparingInt(Entity1_16_2Types::getId));
|
||||
TYPES = types.toArray(new EntityType[0]);
|
||||
}
|
||||
|
||||
public static us.myles.ViaVersion.api.entities.EntityType getTypeFromId(int typeId) {
|
||||
EntityType type;
|
||||
if (typeId < 0 || typeId >= TYPES.length || (type = TYPES[typeId]) == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.16.2 type id " + typeId);
|
||||
return ENTITY;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
@ -2,22 +2,13 @@ package us.myles.ViaVersion.api.entities;
|
||||
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class Entity1_17Types {
|
||||
public enum Entity1_17Types implements EntityType {
|
||||
|
||||
public static EntityType getTypeFromId(int typeID) {
|
||||
Optional<EntityType> type = EntityType.findById(typeID);
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.17 type id " + typeID);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
return type.get();
|
||||
}
|
||||
|
||||
public enum EntityType implements us.myles.ViaVersion.api.entities.EntityType {
|
||||
ENTITY(-1),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
@ -205,17 +196,17 @@ public class Entity1_17Types {
|
||||
SPAWNER_MINECART(53, MINECART_ABSTRACT),
|
||||
BOAT(7, ENTITY);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
private static final EntityType[] TYPES;
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
Entity1_17Types(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
EntityType(int id, EntityType parent) {
|
||||
Entity1_17Types(int id, EntityType parent) {
|
||||
this.id = id;
|
||||
this.parent = parent;
|
||||
}
|
||||
@ -231,15 +222,23 @@ public class Entity1_17Types {
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
List<Entity1_17Types> types = new ArrayList<>();
|
||||
for (Entity1_17Types type : values()) {
|
||||
if (type.id != -1) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.empty();
|
||||
return Optional.ofNullable(TYPES.get(id));
|
||||
}
|
||||
types.sort(Comparator.comparingInt(Entity1_17Types::getId));
|
||||
TYPES = types.toArray(new EntityType[0]);
|
||||
}
|
||||
|
||||
public static EntityType getTypeFromId(int typeId) {
|
||||
EntityType type;
|
||||
if (typeId < 0 || typeId >= TYPES.length || (type = TYPES[typeId]) == null) {
|
||||
Via.getPlatform().getLogger().severe("Could not find 1.17 type id " + typeId);
|
||||
return ENTITY;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface EntityType {
|
||||
|
||||
/**
|
||||
* @return entity id
|
||||
*/
|
||||
int getId();
|
||||
|
||||
/**
|
||||
* @return parent entity type if present
|
||||
*/
|
||||
@Nullable
|
||||
EntityType getParent();
|
||||
|
||||
@ -23,6 +29,10 @@ public interface EntityType {
|
||||
return this == type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type entity type to check against
|
||||
* @return true if the current type is equal to the given type, or has it as a parent type
|
||||
*/
|
||||
default boolean isOrHasParent(EntityType type) {
|
||||
EntityType parent = this;
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
package us.myles.ViaVersion.api.entities;
|
||||
|
||||
/**
|
||||
* Represents a legacy object entity type.
|
||||
*/
|
||||
public interface ObjectType {
|
||||
|
||||
int getId();
|
||||
|
@ -20,7 +20,7 @@ public class MetadataRewriter1_14_1To1_14 extends MetadataRewriter {
|
||||
public void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) {
|
||||
if (type == null) return;
|
||||
|
||||
if (type == Entity1_14Types.EntityType.VILLAGER || type == Entity1_14Types.EntityType.WANDERING_TRADER) {
|
||||
if (type == Entity1_14Types.VILLAGER || type == Entity1_14Types.WANDERING_TRADER) {
|
||||
if (metadata.getId() >= 15) {
|
||||
metadata.setId(metadata.getId() + 1);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class EntityPackets {
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_14.METADATA_LIST); // 7 - Metadata
|
||||
|
||||
handler(metadataRewriter.getTrackerAndRewriter(Types1_14.METADATA_LIST, Entity1_14Types.EntityType.PLAYER));
|
||||
handler(metadataRewriter.getTrackerAndRewriter(Types1_14.METADATA_LIST, Entity1_14Types.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_14Types.EntityType;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_14Types;
|
||||
import us.myles.ViaVersion.api.storage.EntityTracker;
|
||||
|
||||
public class EntityTracker1_14_1 extends EntityTracker {
|
||||
|
||||
public EntityTracker1_14_1(UserConnection user) {
|
||||
super(user, EntityType.PLAYER);
|
||||
super(user, Entity1_14Types.PLAYER);
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
|
||||
public MetadataRewriter1_14To1_13_2(Protocol1_14To1_13_2 protocol) {
|
||||
super(protocol, EntityTracker1_14.class);
|
||||
mapTypes(Entity1_13Types.EntityType.values(), Entity1_14Types.EntityType.class);
|
||||
mapType(Entity1_13Types.EntityType.OCELOT, Entity1_14Types.EntityType.CAT); //TODO remap untamed ocelots to ocelots?
|
||||
mapTypes(Entity1_13Types.EntityType.values(), Entity1_14Types.class);
|
||||
mapType(Entity1_13Types.EntityType.OCELOT, Entity1_14Types.CAT); //TODO remap untamed ocelots to ocelots?
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,7 +49,7 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
if (metadata.getId() > 5) {
|
||||
metadata.setId(metadata.getId() + 1);
|
||||
}
|
||||
if (metadata.getId() == 8 && type.isOrHasParent(Entity1_14Types.EntityType.LIVINGENTITY)) {
|
||||
if (metadata.getId() == 8 && type.isOrHasParent(Entity1_14Types.LIVINGENTITY)) {
|
||||
final float v = ((Number) metadata.getValue()).floatValue();
|
||||
if (Float.isNaN(v) && Via.getConfig().is1_14HealthNaNFix()) {
|
||||
metadata.setValue(1F);
|
||||
@ -57,11 +57,11 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
}
|
||||
|
||||
//Metadata 12 added to living_entity
|
||||
if (metadata.getId() > 11 && type.isOrHasParent(Entity1_14Types.EntityType.LIVINGENTITY)) {
|
||||
if (metadata.getId() > 11 && type.isOrHasParent(Entity1_14Types.LIVINGENTITY)) {
|
||||
metadata.setId(metadata.getId() + 1);
|
||||
}
|
||||
|
||||
if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_INSENTIENT)) {
|
||||
if (type.isOrHasParent(Entity1_14Types.ABSTRACT_INSENTIENT)) {
|
||||
if (metadata.getId() == 13) {
|
||||
tracker.setInsentientData(entityId, (byte) ((((Number) metadata.getValue()).byteValue() & ~0x4)
|
||||
| (tracker.getInsentientData(entityId) & 0x4))); // New attacking metadata
|
||||
@ -69,7 +69,7 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
if (type.isOrHasParent(Entity1_14Types.EntityType.PLAYER)) {
|
||||
if (type.isOrHasParent(Entity1_14Types.PLAYER)) {
|
||||
if (entityId != tracker.getClientEntityId()) {
|
||||
if (metadata.getId() == 0) {
|
||||
byte flags = ((Number) metadata.getValue()).byteValue();
|
||||
@ -82,7 +82,7 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
metadatas.add(new Metadata(6, MetaType1_14.Pose, recalculatePlayerPose(entityId, tracker)));
|
||||
}
|
||||
}
|
||||
} else if (type.isOrHasParent(Entity1_14Types.EntityType.ZOMBIE)) {
|
||||
} else if (type.isOrHasParent(Entity1_14Types.ZOMBIE)) {
|
||||
if (metadata.getId() == 16) {
|
||||
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
|
||||
| ((boolean) metadata.getValue() ? 0x4 : 0))); // New attacking
|
||||
@ -93,13 +93,13 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
if (type.isOrHasParent(Entity1_14Types.EntityType.MINECART_ABSTRACT)) {
|
||||
if (type.isOrHasParent(Entity1_14Types.MINECART_ABSTRACT)) {
|
||||
if (metadata.getId() == 10) {
|
||||
// New block format
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
}
|
||||
} else if (type.is(Entity1_14Types.EntityType.HORSE)) {
|
||||
} else if (type.is(Entity1_14Types.HORSE)) {
|
||||
if (metadata.getId() == 18) {
|
||||
metadatas.remove(metadata);
|
||||
|
||||
@ -119,29 +119,29 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, armorItem);
|
||||
equipmentPacket.send(Protocol1_14To1_13_2.class);
|
||||
}
|
||||
} else if (type.is(Entity1_14Types.EntityType.VILLAGER)) {
|
||||
} else if (type.is(Entity1_14Types.VILLAGER)) {
|
||||
if (metadata.getId() == 15) {
|
||||
// plains
|
||||
metadata.setValue(new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0));
|
||||
metadata.setMetaType(MetaType1_14.VillagerData);
|
||||
}
|
||||
} else if (type.is(Entity1_14Types.EntityType.ZOMBIE_VILLAGER)) {
|
||||
} else if (type.is(Entity1_14Types.ZOMBIE_VILLAGER)) {
|
||||
if (metadata.getId() == 18) {
|
||||
// plains
|
||||
metadata.setValue(new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0));
|
||||
metadata.setMetaType(MetaType1_14.VillagerData);
|
||||
}
|
||||
} else if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_ARROW)) {
|
||||
} else if (type.isOrHasParent(Entity1_14Types.ABSTRACT_ARROW)) {
|
||||
if (metadata.getId() >= 9) { // New piercing
|
||||
metadata.setId(metadata.getId() + 1);
|
||||
}
|
||||
} else if (type.is(Entity1_14Types.EntityType.FIREWORK_ROCKET)) {
|
||||
} else if (type.is(Entity1_14Types.FIREWORK_ROCKET)) {
|
||||
if (metadata.getId() == 8) {
|
||||
if (metadata.getValue().equals(0))
|
||||
metadata.setValue(null); // https://bugs.mojang.com/browse/MC-111480
|
||||
metadata.setMetaType(MetaType1_14.OptVarInt);
|
||||
}
|
||||
} else if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_SKELETON)) {
|
||||
} else if (type.isOrHasParent(Entity1_14Types.ABSTRACT_SKELETON)) {
|
||||
if (metadata.getId() == 14) {
|
||||
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
|
||||
| ((boolean) metadata.getValue() ? 0x4 : 0))); // New attacking
|
||||
@ -150,7 +150,7 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_ILLAGER_BASE)) {
|
||||
if (type.isOrHasParent(Entity1_14Types.ABSTRACT_ILLAGER_BASE)) {
|
||||
if (metadata.getId() == 14) {
|
||||
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
|
||||
| (((Number) metadata.getValue()).byteValue() != 0 ? 0x4 : 0))); // New attacking
|
||||
@ -160,7 +160,7 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
}
|
||||
|
||||
// TODO Are witch and ravager also abstract illagers? They all inherit the new metadata 14 added in 19w13a
|
||||
if (type.is(Entity1_14Types.EntityType.WITCH) || type.is(Entity1_14Types.EntityType.RAVAGER) || type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_ILLAGER_BASE)) {
|
||||
if (type.is(Entity1_14Types.WITCH) || type.is(Entity1_14Types.RAVAGER) || type.isOrHasParent(Entity1_14Types.ABSTRACT_ILLAGER_BASE)) {
|
||||
if (metadata.getId() >= 14) { // TODO 19w13 added a new boolean (raid participant - is celebrating) with id 14
|
||||
metadata.setId(metadata.getId() + 1);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_14Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||
@ -50,37 +51,37 @@ public class EntityPackets {
|
||||
|
||||
Entity1_13Types.EntityType type1_13 = Entity1_13Types.getTypeFromId(typeId, true);
|
||||
typeId = metadataRewriter.getNewEntityId(type1_13.getId());
|
||||
Entity1_14Types.EntityType type1_14 = Entity1_14Types.getTypeFromId(typeId);
|
||||
EntityType type1_14 = Entity1_14Types.getTypeFromId(typeId);
|
||||
|
||||
if (type1_14 != null) {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
if (type1_14.is(Entity1_14Types.EntityType.FALLING_BLOCK)) {
|
||||
if (type1_14.is(Entity1_14Types.FALLING_BLOCK)) {
|
||||
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (type1_14.is(Entity1_14Types.EntityType.MINECART)) {
|
||||
} else if (type1_14.is(Entity1_14Types.MINECART)) {
|
||||
// default is 0 = rideable minecart
|
||||
switch (data) {
|
||||
case 1:
|
||||
typeId = Entity1_14Types.EntityType.CHEST_MINECART.getId();
|
||||
typeId = Entity1_14Types.CHEST_MINECART.getId();
|
||||
break;
|
||||
case 2:
|
||||
typeId = Entity1_14Types.EntityType.FURNACE_MINECART.getId();
|
||||
typeId = Entity1_14Types.FURNACE_MINECART.getId();
|
||||
break;
|
||||
case 3:
|
||||
typeId = Entity1_14Types.EntityType.TNT_MINECART.getId();
|
||||
typeId = Entity1_14Types.TNT_MINECART.getId();
|
||||
break;
|
||||
case 4:
|
||||
typeId = Entity1_14Types.EntityType.SPAWNER_MINECART.getId();
|
||||
typeId = Entity1_14Types.SPAWNER_MINECART.getId();
|
||||
break;
|
||||
case 5:
|
||||
typeId = Entity1_14Types.EntityType.HOPPER_MINECART.getId();
|
||||
typeId = Entity1_14Types.HOPPER_MINECART.getId();
|
||||
break;
|
||||
case 6:
|
||||
typeId = Entity1_14Types.EntityType.COMMAND_BLOCK_MINECART.getId();
|
||||
typeId = Entity1_14Types.COMMAND_BLOCK_MINECART.getId();
|
||||
break;
|
||||
}
|
||||
} else if ((type1_14.is(Entity1_14Types.EntityType.ITEM) && data > 0)
|
||||
|| type1_14.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_ARROW)) {
|
||||
if (type1_14.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_ARROW)) {
|
||||
} else if ((type1_14.is(Entity1_14Types.ITEM) && data > 0)
|
||||
|| type1_14.isOrHasParent(Entity1_14Types.ABSTRACT_ARROW)) {
|
||||
if (type1_14.isOrHasParent(Entity1_14Types.ABSTRACT_ARROW)) {
|
||||
wrapper.set(Type.INT, 0, data - 1);
|
||||
}
|
||||
// send velocity in separate packet, 1.14 is now ignoring the velocity
|
||||
@ -146,7 +147,7 @@ public class EntityPackets {
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_13_2.METADATA_LIST, Types1_14.METADATA_LIST); // 7 - Metadata
|
||||
|
||||
handler(metadataRewriter.getTrackerAndRewriter(Types1_14.METADATA_LIST, Entity1_14Types.EntityType.PLAYER));
|
||||
handler(metadataRewriter.getTrackerAndRewriter(Types1_14.METADATA_LIST, Entity1_14Types.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -288,7 +288,7 @@ public class WorldPackets {
|
||||
|
||||
int entityId = wrapper.get(Type.INT, 0);
|
||||
|
||||
Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER;
|
||||
Entity1_14Types entType = Entity1_14Types.PLAYER;
|
||||
// Register Type ID
|
||||
EntityTracker1_14 tracker = wrapper.user().get(EntityTracker1_14.class);
|
||||
tracker.addEntity(entityId, entType);
|
||||
|
@ -2,7 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_14Types.EntityType;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_14Types;
|
||||
import us.myles.ViaVersion.api.storage.EntityTracker;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
@ -21,7 +21,7 @@ public class EntityTracker1_14 extends EntityTracker {
|
||||
private int chunkCenterX, chunkCenterZ;
|
||||
|
||||
public EntityTracker1_14(UserConnection user) {
|
||||
super(user, EntityType.PLAYER);
|
||||
super(user, Entity1_14Types.PLAYER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public class MetadataRewriter1_15To1_14_4 extends MetadataRewriter {
|
||||
if (type == null) return;
|
||||
|
||||
// Metadata 12 added to abstract_living
|
||||
if (metadata.getId() > 11 && type.isOrHasParent(Entity1_15Types.EntityType.LIVINGENTITY)) {
|
||||
if (metadata.getId() > 11 && type.isOrHasParent(Entity1_15Types.LIVINGENTITY)) {
|
||||
metadata.setId(metadata.getId() + 1); //TODO is it 11 or 12? what is it for?
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class MetadataRewriter1_15To1_14_4 extends MetadataRewriter {
|
||||
//new boolean with id 11 for trident, default = false, added in 19w45a
|
||||
//new boolean with id 17 for enderman
|
||||
|
||||
if (type.isOrHasParent(Entity1_15Types.EntityType.WOLF)) {
|
||||
if (type.isOrHasParent(Entity1_15Types.WOLF)) {
|
||||
if (metadata.getId() == 18) {
|
||||
metadatas.remove(metadata);
|
||||
} else if (metadata.getId() > 18) {
|
||||
|
@ -18,7 +18,7 @@ public class EntityPackets {
|
||||
public static void register(Protocol1_15To1_14_4 protocol) {
|
||||
MetadataRewriter1_15To1_14_4 metadataRewriter = protocol.get(MetadataRewriter1_15To1_14_4.class);
|
||||
|
||||
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_14.SPAWN_ENTITY, Entity1_15Types.EntityType.FALLING_BLOCK);
|
||||
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_14.SPAWN_ENTITY, Entity1_15Types.FALLING_BLOCK);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
@ -62,7 +62,7 @@ public class EntityPackets {
|
||||
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
Entity1_15Types.EntityType entityType = Entity1_15Types.EntityType.PLAYER;
|
||||
Entity1_15Types entityType = Entity1_15Types.PLAYER;
|
||||
wrapper.user().get(EntityTracker1_15.class).addEntity(entityId, entityType);
|
||||
|
||||
List<Metadata> metadata = wrapper.read(Types1_14.METADATA_LIST);
|
||||
|
@ -30,7 +30,7 @@ public class PlayerPackets {
|
||||
// Register Type ID
|
||||
EntityTracker1_15 tracker = wrapper.user().get(EntityTracker1_15.class);
|
||||
int entityId = wrapper.get(Type.INT, 0);
|
||||
tracker.addEntity(entityId, Entity1_15Types.EntityType.PLAYER);
|
||||
tracker.addEntity(entityId, Entity1_15Types.PLAYER);
|
||||
});
|
||||
create(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types.EntityType;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||
import us.myles.ViaVersion.api.storage.EntityTracker;
|
||||
|
||||
public class EntityTracker1_15 extends EntityTracker {
|
||||
|
||||
public EntityTracker1_15(UserConnection user) {
|
||||
super(user, EntityType.PLAYER);
|
||||
super(user, Entity1_15Types.PLAYER);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class MetadataRewriter1_16_2To1_16_1 extends MetadataRewriter {
|
||||
|
||||
public MetadataRewriter1_16_2To1_16_1(Protocol1_16_2To1_16_1 protocol) {
|
||||
super(protocol, EntityTracker1_16_2.class);
|
||||
mapTypes(Entity1_16Types.EntityType.values(), Entity1_16_2Types.EntityType.class);
|
||||
mapTypes(Entity1_16Types.values(), Entity1_16_2Types.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -35,7 +35,7 @@ public class MetadataRewriter1_16_2To1_16_1 extends MetadataRewriter {
|
||||
|
||||
if (type == null) return;
|
||||
|
||||
if (type.isOrHasParent(Entity1_16_2Types.EntityType.ABSTRACT_PIGLIN)) {
|
||||
if (type.isOrHasParent(Entity1_16_2Types.ABSTRACT_PIGLIN)) {
|
||||
if (metadata.getId() == 15) {
|
||||
metadata.setId(16);
|
||||
} else if (metadata.getId() == 16) {
|
||||
|
@ -15,9 +15,9 @@ public class EntityPackets {
|
||||
|
||||
public static void register(Protocol1_16_2To1_16_1 protocol) {
|
||||
MetadataRewriter1_16_2To1_16_1 metadataRewriter = protocol.get(MetadataRewriter1_16_2To1_16_1.class);
|
||||
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16_2Types.EntityType.FALLING_BLOCK);
|
||||
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16_2Types.FALLING_BLOCK);
|
||||
metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_MOB);
|
||||
metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16_2Types.EntityType.PLAYER);
|
||||
metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16_2Types.PLAYER);
|
||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
metadataRewriter.registerEntityDestroy(ClientboundPackets1_16.DESTROY_ENTITIES);
|
||||
|
||||
@ -48,7 +48,7 @@ public class EntityPackets {
|
||||
map(Type.UNSIGNED_BYTE, Type.VAR_INT); // Max players
|
||||
// ...
|
||||
handler(wrapper -> {
|
||||
wrapper.user().get(EntityTracker1_16_2.class).addEntity(wrapper.get(Type.INT, 0), Entity1_16_2Types.EntityType.PLAYER);
|
||||
wrapper.user().get(EntityTracker1_16_2.class).addEntity(wrapper.get(Type.INT, 0), Entity1_16_2Types.PLAYER);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,12 +1,12 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16_2Types.EntityType;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16_2Types;
|
||||
import us.myles.ViaVersion.api.storage.EntityTracker;
|
||||
|
||||
public class EntityTracker1_16_2 extends EntityTracker {
|
||||
|
||||
public EntityTracker1_16_2(UserConnection user) {
|
||||
super(user, EntityType.PLAYER);
|
||||
super(user, Entity1_16_2Types.PLAYER);
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ public class MetadataRewriter1_16To1_15_2 extends MetadataRewriter {
|
||||
|
||||
public MetadataRewriter1_16To1_15_2(Protocol1_16To1_15_2 protocol) {
|
||||
super(protocol, EntityTracker1_16.class);
|
||||
mapType(Entity1_15Types.EntityType.ZOMBIE_PIGMAN, Entity1_16Types.EntityType.ZOMBIFIED_PIGLIN);
|
||||
mapTypes(Entity1_15Types.EntityType.values(), Entity1_16Types.EntityType.class);
|
||||
mapType(Entity1_15Types.ZOMBIE_PIGMAN, Entity1_16Types.ZOMBIFIED_PIGLIN);
|
||||
mapTypes(Entity1_15Types.values(), Entity1_16Types.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,7 +36,7 @@ public class MetadataRewriter1_16To1_15_2 extends MetadataRewriter {
|
||||
|
||||
if (type == null) return;
|
||||
|
||||
if (type.isOrHasParent(Entity1_16Types.EntityType.ABSTRACT_ARROW)) {
|
||||
if (type.isOrHasParent(Entity1_16Types.ABSTRACT_ARROW)) {
|
||||
if (metadata.getId() == 8) {
|
||||
metadatas.remove(metadata);
|
||||
} else if (metadata.getId() > 8) {
|
||||
|
@ -135,10 +135,10 @@ public class EntityPackets {
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.user().get(EntityTracker1_16.class).addEntity(entityId, Entity1_16Types.EntityType.LIGHTNING_BOLT);
|
||||
wrapper.user().get(EntityTracker1_16.class).addEntity(entityId, Entity1_16Types.LIGHTNING_BOLT);
|
||||
|
||||
wrapper.write(Type.UUID, UUID.randomUUID()); // uuid
|
||||
wrapper.write(Type.VAR_INT, Entity1_16Types.EntityType.LIGHTNING_BOLT.getId()); // entity type
|
||||
wrapper.write(Type.VAR_INT, Entity1_16Types.LIGHTNING_BOLT.getId()); // entity type
|
||||
|
||||
wrapper.read(Type.BYTE); // remove type
|
||||
|
||||
@ -155,9 +155,9 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_16Types.EntityType.FALLING_BLOCK);
|
||||
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_16Types.FALLING_BLOCK);
|
||||
metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_MOB);
|
||||
metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_PLAYER, Entity1_16Types.EntityType.PLAYER);
|
||||
metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_PLAYER, Entity1_16Types.PLAYER);
|
||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
metadataRewriter.registerEntityDestroy(ClientboundPackets1_15.DESTROY_ENTITIES);
|
||||
|
||||
@ -192,7 +192,7 @@ public class EntityPackets {
|
||||
map(Type.LONG); // Seed
|
||||
map(Type.UNSIGNED_BYTE); // Max players
|
||||
handler(wrapper -> {
|
||||
wrapper.user().get(EntityTracker1_16.class).addEntity(wrapper.get(Type.INT, 0), Entity1_16Types.EntityType.PLAYER);
|
||||
wrapper.user().get(EntityTracker1_16.class).addEntity(wrapper.get(Type.INT, 0), Entity1_16Types.PLAYER);
|
||||
|
||||
final String type = wrapper.read(Type.STRING);// level type
|
||||
wrapper.passthrough(Type.VAR_INT); // View distance
|
||||
|
@ -1,12 +1,12 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16Types.EntityType;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16Types;
|
||||
import us.myles.ViaVersion.api.storage.EntityTracker;
|
||||
|
||||
public class EntityTracker1_16 extends EntityTracker {
|
||||
|
||||
public EntityTracker1_16(UserConnection user) {
|
||||
super(user, EntityType.PLAYER);
|
||||
super(user, Entity1_16Types.PLAYER);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class MetadataRewriter1_17To1_16_4 extends MetadataRewriter {
|
||||
|
||||
public MetadataRewriter1_17To1_16_4(Protocol1_17To1_16_4 protocol) {
|
||||
super(protocol, EntityTracker1_17.class);
|
||||
mapTypes(Entity1_16_2Types.EntityType.values(), Entity1_17Types.EntityType.class);
|
||||
mapTypes(Entity1_16_2Types.values(), Entity1_17Types.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,13 +36,13 @@ public class MetadataRewriter1_17To1_16_4 extends MetadataRewriter {
|
||||
|
||||
if (type == null) return;
|
||||
|
||||
if (type.isOrHasParent(Entity1_17Types.EntityType.ENTITY)) {
|
||||
if (type.isOrHasParent(Entity1_17Types.ENTITY)) {
|
||||
if (metadata.getId() >= 7) {
|
||||
metadata.setId(metadata.getId() + 1); // Ticks frozen added with id 7
|
||||
}
|
||||
}
|
||||
|
||||
if (type == Entity1_17Types.EntityType.SHULKER) {
|
||||
if (type == Entity1_17Types.SHULKER) {
|
||||
// Attachment position removed
|
||||
if (metadata.getId() == 16) {
|
||||
metadatas.remove(metadata);
|
||||
|
@ -13,9 +13,9 @@ public class EntityPackets {
|
||||
|
||||
public static void register(Protocol1_17To1_16_4 protocol) {
|
||||
MetadataRewriter1_17To1_16_4 metadataRewriter = protocol.get(MetadataRewriter1_17To1_16_4.class);
|
||||
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, Entity1_17Types.EntityType.FALLING_BLOCK);
|
||||
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, Entity1_17Types.FALLING_BLOCK);
|
||||
metadataRewriter.registerTracker(ClientboundPackets1_16_2.SPAWN_MOB);
|
||||
metadataRewriter.registerTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_17Types.EntityType.PLAYER);
|
||||
metadataRewriter.registerTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_17Types.PLAYER);
|
||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_14.METADATA_LIST, Types1_17.METADATA_LIST);
|
||||
metadataRewriter.registerEntityDestroy(ClientboundPackets1_16_2.DESTROY_ENTITIES);
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class WorldPackets {
|
||||
|
||||
UserConnection user = wrapper.user();
|
||||
user.get(BiomeStorage.class).setWorld(world);
|
||||
user.get(EntityTracker1_17.class).addEntity(wrapper.get(Type.INT, 0), Entity1_17Types.EntityType.PLAYER);
|
||||
user.get(EntityTracker1_17.class).addEntity(wrapper.get(Type.INT, 0), Entity1_17Types.PLAYER);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,12 +1,12 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_17Types.EntityType;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_17Types;
|
||||
import us.myles.ViaVersion.api.storage.EntityTracker;
|
||||
|
||||
public class EntityTracker1_17 extends EntityTracker {
|
||||
|
||||
public EntityTracker1_17(UserConnection user) {
|
||||
super(user, EntityType.PLAYER);
|
||||
super(user, Entity1_17Types.PLAYER);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
package us.myles.ViaVersion.common.entities;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_14Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16_2Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_17Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Test to make sure the array storage approach of entity types works correctly.
|
||||
*/
|
||||
public class EntityTypesTest {
|
||||
|
||||
@Test
|
||||
void testArrayOrder() {
|
||||
testArrayOrder(Entity1_14Types.values(), Entity1_14Types::getTypeFromId);
|
||||
testArrayOrder(Entity1_15Types.values(), Entity1_15Types::getTypeFromId);
|
||||
testArrayOrder(Entity1_16Types.values(), Entity1_16Types::getTypeFromId);
|
||||
testArrayOrder(Entity1_16_2Types.values(), Entity1_16_2Types::getTypeFromId);
|
||||
testArrayOrder(Entity1_17Types.values(), Entity1_17Types::getTypeFromId);
|
||||
}
|
||||
|
||||
private void testArrayOrder(EntityType[] types, Function<Integer, EntityType> returnFunction) {
|
||||
for (EntityType type : types) {
|
||||
if (type.getId() != -1) {
|
||||
Assertions.assertEquals(type, returnFunction.apply(type.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package us.myles.ViaVersion.common.test.type;
|
||||
package us.myles.ViaVersion.common.type;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
@ -1,4 +1,4 @@
|
||||
package us.myles.ViaVersion.common.test.type;
|
||||
package us.myles.ViaVersion.common.type;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
Loading…
Reference in New Issue
Block a user