Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 21:32:52 +02:00
Use VV entity types (#147)
Dieser Commit ist enthalten in:
Ursprung
f0da0624f7
Commit
6a0e553c96
@ -12,25 +12,23 @@ package nl.matsv.viabackwards.api.entities.meta;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@Getter
|
@Getter
|
||||||
public class MetaHandlerSettings {
|
public class MetaHandlerSettings {
|
||||||
private AbstractEntityType filterType;
|
private EntityType filterType;
|
||||||
private boolean filterFamily = false;
|
private boolean filterFamily = false;
|
||||||
private int filterIndex = -1;
|
private int filterIndex = -1;
|
||||||
private MetaHandler handler;
|
private MetaHandler handler;
|
||||||
|
|
||||||
public MetaHandlerSettings filter(AbstractEntityType type) {
|
public MetaHandlerSettings filter(EntityType type) {
|
||||||
return filter(type, filterFamily, filterIndex);
|
return filter(type, filterFamily, filterIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MetaHandlerSettings filter(AbstractEntityType type, boolean filterFamily) {
|
public MetaHandlerSettings filter(EntityType type, boolean filterFamily) {
|
||||||
return filter(type, filterFamily, filterIndex);
|
return filter(type, filterFamily, filterIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,11 +36,11 @@ public class MetaHandlerSettings {
|
|||||||
return filter(filterType, filterFamily, index);
|
return filter(filterType, filterFamily, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MetaHandlerSettings filter(AbstractEntityType type, int index) {
|
public MetaHandlerSettings filter(EntityType type, int index) {
|
||||||
return filter(type, filterFamily, index);
|
return filter(type, filterFamily, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MetaHandlerSettings filter(AbstractEntityType type, boolean filterFamily, int index) {
|
public MetaHandlerSettings filter(EntityType type, boolean filterFamily, int index) {
|
||||||
this.filterType = type;
|
this.filterType = type;
|
||||||
this.filterFamily = filterFamily;
|
this.filterFamily = filterFamily;
|
||||||
this.filterIndex = index;
|
this.filterIndex = index;
|
||||||
@ -63,7 +61,7 @@ public class MetaHandlerSettings {
|
|||||||
|
|
||||||
public void removed() {
|
public void removed() {
|
||||||
handle(e -> {
|
handle(e -> {
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,20 +81,20 @@ public class MetaHandlerSettings {
|
|||||||
return filterFamily;
|
return filterFamily;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGucci(AbstractEntityType type, Metadata metadata) {
|
public boolean isGucci(EntityType type, Metadata metadata) {
|
||||||
if (hasHandler()) {
|
if (!hasHandler()) return false;
|
||||||
if (hasType()) {
|
|
||||||
List<AbstractEntityType> family = type.getParents();
|
if (hasType()) {
|
||||||
if (isFilterFamily()) {
|
if (filterFamily) {
|
||||||
if (!family.contains(getFilterType()))
|
if (!type.isOrHasParent(filterType)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
if (!getFilterType().is(type))
|
} else {
|
||||||
return false;
|
if (!filterType.is(type)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !(hasIndex() && metadata.getId() != getFilterIndex());
|
|
||||||
}
|
}
|
||||||
return false;
|
return !hasIndex() || metadata.getId() == filterIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,16 @@ import lombok.Getter;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class EntityTracker extends StoredObject {
|
public class EntityTracker extends StoredObject {
|
||||||
private Map<BackwardsProtocol, ProtocolEntityTracker> trackers = new ConcurrentHashMap<>();
|
private final Map<BackwardsProtocol, ProtocolEntityTracker> trackers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public EntityTracker(UserConnection user) {
|
public EntityTracker(UserConnection user) {
|
||||||
super(user);
|
super(user);
|
||||||
@ -37,23 +37,20 @@ public class EntityTracker extends StoredObject {
|
|||||||
return trackers.get(protocol);
|
return trackers.get(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ProtocolEntityTracker {
|
public static class ProtocolEntityTracker {
|
||||||
private Map<Integer, StoredEntity> entityMap = new ConcurrentHashMap<>();
|
private final Map<Integer, StoredEntity> entityMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public void trackEntityType(int id, AbstractEntityType type) {
|
public void trackEntityType(int id, EntityType type) {
|
||||||
if (entityMap.containsKey(id))
|
entityMap.putIfAbsent(id, new StoredEntity(id, type));
|
||||||
return;
|
|
||||||
entityMap.put(id, new StoredEntity(id, type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeEntity(int id) {
|
public void removeEntity(int id) {
|
||||||
entityMap.remove(id);
|
entityMap.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractEntityType getEntityType(int id) {
|
public EntityType getEntityType(int id) {
|
||||||
if (containsEntity(id))
|
StoredEntity storedEntity = entityMap.get(id);
|
||||||
return getEntity(id).get().getType();
|
return storedEntity != null ? storedEntity.getType() : null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<StoredEntity> getEntity(int id) {
|
public Optional<StoredEntity> getEntity(int id) {
|
||||||
@ -68,10 +65,10 @@ public class EntityTracker extends StoredObject {
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
public class StoredEntity {
|
public static class StoredEntity {
|
||||||
private final int entityId;
|
private final int entityId;
|
||||||
private final AbstractEntityType type;
|
private final EntityType type;
|
||||||
Map<Class<? extends EntityStorage>, EntityStorage> storedObjects = new ConcurrentHashMap<>();
|
private final Map<Class<? extends EntityStorage>, EntityStorage> storedObjects = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an object from the storage
|
* Get an object from the storage
|
||||||
|
@ -19,17 +19,20 @@ import java.util.Optional;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ToString
|
@ToString
|
||||||
@AllArgsConstructor
|
|
||||||
public class MetaStorage {
|
public class MetaStorage {
|
||||||
@NonNull
|
@NonNull
|
||||||
private List<Metadata> metaDataList;
|
private List<Metadata> metaDataList;
|
||||||
|
|
||||||
|
public MetaStorage(List<Metadata> metaDataList) {
|
||||||
|
this.metaDataList = metaDataList;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean has(Metadata data) {
|
public boolean has(Metadata data) {
|
||||||
return this.getMetaDataList().contains(data);
|
return this.metaDataList.contains(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(Metadata data) {
|
public void delete(Metadata data) {
|
||||||
this.getMetaDataList().remove(data);
|
this.metaDataList.remove(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(int index) {
|
public void delete(int index) {
|
||||||
@ -39,11 +42,11 @@ public class MetaStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(Metadata data) {
|
public void add(Metadata data) {
|
||||||
this.getMetaDataList().add(data);
|
this.metaDataList.add(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Metadata> get(int index) {
|
public Optional<Metadata> get(int index) {
|
||||||
for (Metadata meta : this.getMetaDataList())
|
for (Metadata meta : this.metaDataList)
|
||||||
if (index == meta.getId())
|
if (index == meta.getId())
|
||||||
return Optional.of(meta);
|
return Optional.of(meta);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Matsv
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package nl.matsv.viabackwards.api.entities.types;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface AbstractEntityType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the metadata id
|
|
||||||
*
|
|
||||||
* @return the metadata index
|
|
||||||
*/
|
|
||||||
int getId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the parent class of the entity
|
|
||||||
*
|
|
||||||
* @return parent EntityType
|
|
||||||
*/
|
|
||||||
AbstractEntityType getParent();
|
|
||||||
|
|
||||||
boolean is(AbstractEntityType... types);
|
|
||||||
|
|
||||||
boolean is(AbstractEntityType type);
|
|
||||||
|
|
||||||
boolean isOrHasParent(AbstractEntityType type);
|
|
||||||
|
|
||||||
List<AbstractEntityType> getParents();
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Matsv
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package nl.matsv.viabackwards.api.entities.types;
|
|
||||||
|
|
||||||
public interface AbstractObjectType {
|
|
||||||
/**
|
|
||||||
* Get the metadata id
|
|
||||||
*
|
|
||||||
* @return the metadata index
|
|
||||||
*/
|
|
||||||
int getId();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the entity type
|
|
||||||
*
|
|
||||||
* @return Entity type
|
|
||||||
*/
|
|
||||||
AbstractEntityType getType();
|
|
||||||
}
|
|
@ -1,242 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Matsv
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package nl.matsv.viabackwards.api.entities.types;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
// 1.10 Entity / Object ids
|
|
||||||
public class EntityType1_10 {
|
|
||||||
|
|
||||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
|
||||||
Optional<EntityType> type;
|
|
||||||
|
|
||||||
if (isObject)
|
|
||||||
type = ObjectType.getPCEntity(typeID);
|
|
||||||
else
|
|
||||||
type = EntityType.findById(typeID);
|
|
||||||
|
|
||||||
if (!type.isPresent()) {
|
|
||||||
if (!Via.getConfig().isSuppressMetadataErrors())
|
|
||||||
ViaBackwards.getPlatform().getLogger().severe("[EntityType1_10] Could not find type id " + typeID + " isObject=" + isObject);
|
|
||||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
|
||||||
}
|
|
||||||
|
|
||||||
return type.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum EntityType implements AbstractEntityType {
|
|
||||||
ENTITY(-1),
|
|
||||||
DROPPED_ITEM(1, EntityType.ENTITY),
|
|
||||||
EXPERIENCE_ORB(2, EntityType.ENTITY),
|
|
||||||
LEASH_HITCH(8, EntityType.ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
|
||||||
PAINTING(9, EntityType.ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
|
||||||
ARROW(10, EntityType.ENTITY),
|
|
||||||
SNOWBALL(11, EntityType.ENTITY), // Actually EntityProjectile
|
|
||||||
FIREBALL(12, EntityType.ENTITY),
|
|
||||||
SMALL_FIREBALL(13, EntityType.ENTITY),
|
|
||||||
ENDER_PEARL(14, EntityType.ENTITY), // Actually EntityProjectile
|
|
||||||
ENDER_SIGNAL(15, EntityType.ENTITY),
|
|
||||||
THROWN_EXP_BOTTLE(17, EntityType.ENTITY),
|
|
||||||
ITEM_FRAME(18, EntityType.ENTITY), // Actually EntityHanging
|
|
||||||
WITHER_SKULL(19, EntityType.ENTITY),
|
|
||||||
PRIMED_TNT(20, EntityType.ENTITY),
|
|
||||||
FALLING_BLOCK(21, EntityType.ENTITY),
|
|
||||||
FIREWORK(22, EntityType.ENTITY),
|
|
||||||
TIPPED_ARROW(23, EntityType.ARROW),
|
|
||||||
SPECTRAL_ARROW(24, EntityType.ARROW),
|
|
||||||
SHULKER_BULLET(25, EntityType.ENTITY),
|
|
||||||
DRAGON_FIREBALL(26, EntityType.FIREBALL),
|
|
||||||
|
|
||||||
ENTITY_LIVING(-1, ENTITY),
|
|
||||||
ENTITY_INSENTIENT(-1, ENTITY_LIVING),
|
|
||||||
ENTITY_AGEABLE(-1, ENTITY_INSENTIENT),
|
|
||||||
ENTITY_TAMEABLE_ANIMAL(-1, ENTITY_AGEABLE),
|
|
||||||
ENTITY_HUMAN(-1, ENTITY_LIVING),
|
|
||||||
|
|
||||||
ARMOR_STAND(30, EntityType.ENTITY_LIVING),
|
|
||||||
|
|
||||||
// Vehicles
|
|
||||||
MINECART_ABSTRACT(-1, ENTITY),
|
|
||||||
MINECART_COMMAND(40, MINECART_ABSTRACT),
|
|
||||||
BOAT(41, ENTITY),
|
|
||||||
MINECART_RIDEABLE(42, MINECART_ABSTRACT),
|
|
||||||
MINECART_CHEST(43, MINECART_ABSTRACT),
|
|
||||||
MINECART_FURNACE(44, MINECART_ABSTRACT),
|
|
||||||
MINECART_TNT(45, MINECART_ABSTRACT),
|
|
||||||
MINECART_HOPPER(46, MINECART_ABSTRACT),
|
|
||||||
MINECART_MOB_SPAWNER(47, MINECART_ABSTRACT),
|
|
||||||
|
|
||||||
CREEPER(50, ENTITY_INSENTIENT),
|
|
||||||
SKELETON(51, ENTITY_INSENTIENT),
|
|
||||||
SPIDER(52, ENTITY_INSENTIENT),
|
|
||||||
GIANT(53, ENTITY_INSENTIENT),
|
|
||||||
ZOMBIE(54, ENTITY_INSENTIENT),
|
|
||||||
SLIME(55, ENTITY_INSENTIENT),
|
|
||||||
GHAST(56, ENTITY_INSENTIENT),
|
|
||||||
PIG_ZOMBIE(57, ZOMBIE),
|
|
||||||
ENDERMAN(58, ENTITY_INSENTIENT),
|
|
||||||
CAVE_SPIDER(59, SPIDER),
|
|
||||||
SILVERFISH(60, ENTITY_INSENTIENT),
|
|
||||||
BLAZE(61, ENTITY_INSENTIENT),
|
|
||||||
MAGMA_CUBE(62, SLIME),
|
|
||||||
ENDER_DRAGON(63, ENTITY_INSENTIENT),
|
|
||||||
WITHER(64, ENTITY_INSENTIENT),
|
|
||||||
BAT(65, ENTITY_INSENTIENT),
|
|
||||||
WITCH(66, ENTITY_INSENTIENT),
|
|
||||||
ENDERMITE(67, ENTITY_INSENTIENT),
|
|
||||||
GUARDIAN(68, ENTITY_INSENTIENT),
|
|
||||||
IRON_GOLEM(99, ENTITY_INSENTIENT), // moved up to avoid illegal forward references
|
|
||||||
SHULKER(69, EntityType.IRON_GOLEM),
|
|
||||||
PIG(90, ENTITY_AGEABLE),
|
|
||||||
SHEEP(91, ENTITY_AGEABLE),
|
|
||||||
COW(92, ENTITY_AGEABLE),
|
|
||||||
CHICKEN(93, ENTITY_AGEABLE),
|
|
||||||
SQUID(94, ENTITY_INSENTIENT),
|
|
||||||
WOLF(95, ENTITY_TAMEABLE_ANIMAL),
|
|
||||||
MUSHROOM_COW(96, COW),
|
|
||||||
SNOWMAN(97, EntityType.IRON_GOLEM),
|
|
||||||
OCELOT(98, ENTITY_TAMEABLE_ANIMAL),
|
|
||||||
HORSE(100, ENTITY_AGEABLE),
|
|
||||||
RABBIT(101, ENTITY_AGEABLE),
|
|
||||||
POLAR_BEAR(102, ENTITY_AGEABLE),
|
|
||||||
VILLAGER(120, ENTITY_AGEABLE),
|
|
||||||
ENDER_CRYSTAL(200, ENTITY),
|
|
||||||
SPLASH_POTION(-1, ENTITY),
|
|
||||||
LINGERING_POTION(-1, SPLASH_POTION),
|
|
||||||
AREA_EFFECT_CLOUD(-1, ENTITY),
|
|
||||||
EGG(-1, ENTITY),
|
|
||||||
FISHING_HOOK(-1, ENTITY),
|
|
||||||
LIGHTNING(-1, ENTITY),
|
|
||||||
WEATHER(-1, ENTITY),
|
|
||||||
PLAYER(-1, ENTITY_HUMAN),
|
|
||||||
COMPLEX_PART(-1, ENTITY);
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final EntityType parent;
|
|
||||||
|
|
||||||
EntityType(int id) {
|
|
||||||
this.id = id;
|
|
||||||
this.parent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<EntityType> findById(int id) {
|
|
||||||
if (id == -1) // Check if this is called
|
|
||||||
return Optional.empty();
|
|
||||||
|
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is(AbstractEntityType... types) {
|
|
||||||
for (AbstractEntityType type : types)
|
|
||||||
if (is(type))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is(AbstractEntityType type) {
|
|
||||||
return this == type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOrHasParent(AbstractEntityType type) {
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (parent.equals(type))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractEntityType> getParents() {
|
|
||||||
List<AbstractEntityType> types = new ArrayList<>();
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
types.add(parent);
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum ObjectType implements AbstractObjectType {
|
|
||||||
BOAT(1, EntityType.BOAT),
|
|
||||||
ITEM(2, EntityType.DROPPED_ITEM),
|
|
||||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
|
||||||
MINECART(10, EntityType.MINECART_ABSTRACT),
|
|
||||||
TNT_PRIMED(50, EntityType.PRIMED_TNT),
|
|
||||||
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
|
|
||||||
TIPPED_ARROW(60, EntityType.TIPPED_ARROW),
|
|
||||||
SNOWBALL(61, EntityType.SNOWBALL),
|
|
||||||
EGG(62, EntityType.EGG),
|
|
||||||
FIREBALL(63, EntityType.FIREBALL),
|
|
||||||
SMALL_FIREBALL(64, EntityType.SMALL_FIREBALL),
|
|
||||||
ENDER_PEARL(65, EntityType.ENDER_PEARL),
|
|
||||||
WITHER_SKULL(66, EntityType.WITHER_SKULL),
|
|
||||||
SHULKER_BULLET(67, EntityType.SHULKER_BULLET),
|
|
||||||
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
|
||||||
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
|
||||||
ENDER_SIGNAL(72, EntityType.ENDER_SIGNAL),
|
|
||||||
POTION(73, EntityType.SPLASH_POTION),
|
|
||||||
THROWN_EXP_BOTTLE(75, EntityType.THROWN_EXP_BOTTLE),
|
|
||||||
FIREWORK(76, EntityType.FIREWORK),
|
|
||||||
LEASH(77, EntityType.LEASH_HITCH),
|
|
||||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
|
||||||
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK),
|
|
||||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
|
||||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final EntityType type;
|
|
||||||
|
|
||||||
public static Optional<ObjectType> findById(int id) {
|
|
||||||
if (id == -1)
|
|
||||||
return Optional.empty();
|
|
||||||
|
|
||||||
for (ObjectType ent : ObjectType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<EntityType> getPCEntity(int id) {
|
|
||||||
Optional<ObjectType> output = findById(id);
|
|
||||||
|
|
||||||
if (!output.isPresent())
|
|
||||||
return Optional.empty();
|
|
||||||
return Optional.of(output.get().getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,271 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Matsv
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package nl.matsv.viabackwards.api.entities.types;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class EntityType1_11 {
|
|
||||||
|
|
||||||
public static EntityType getTypeFromId(int typeID, boolean isObject) throws Exception {
|
|
||||||
Optional<EntityType> type;
|
|
||||||
|
|
||||||
if (isObject)
|
|
||||||
type = ObjectType.getPCEntity(typeID);
|
|
||||||
else
|
|
||||||
type = EntityType.findById(typeID);
|
|
||||||
|
|
||||||
if (!type.isPresent()) {
|
|
||||||
if (!Via.getConfig().isSuppressMetadataErrors())
|
|
||||||
ViaBackwards.getPlatform().getLogger().severe("[EntityType1_11] Could not find type id " + typeID + " isObject=" + isObject);
|
|
||||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
|
||||||
}
|
|
||||||
|
|
||||||
return type.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum EntityType implements AbstractEntityType {
|
|
||||||
ENTITY(-1),
|
|
||||||
DROPPED_ITEM(1, ENTITY),
|
|
||||||
EXPERIENCE_ORB(2, ENTITY),
|
|
||||||
LEASH_HITCH(8, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
|
||||||
PAINTING(9, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
|
||||||
ARROW(10, ENTITY),
|
|
||||||
SNOWBALL(11, ENTITY), // Actually EntityProjectile
|
|
||||||
FIREBALL(12, ENTITY),
|
|
||||||
SMALL_FIREBALL(13, ENTITY),
|
|
||||||
ENDER_PEARL(14, ENTITY), // Actually EntityProjectile
|
|
||||||
ENDER_SIGNAL(15, ENTITY),
|
|
||||||
THROWN_EXP_BOTTLE(17, ENTITY),
|
|
||||||
ITEM_FRAME(18, ENTITY), // Actually EntityHanging
|
|
||||||
WITHER_SKULL(19, ENTITY),
|
|
||||||
PRIMED_TNT(20, ENTITY),
|
|
||||||
FALLING_BLOCK(21, ENTITY),
|
|
||||||
FIREWORK(22, ENTITY),
|
|
||||||
SPECTRAL_ARROW(24, ARROW),
|
|
||||||
SHULKER_BULLET(25, ENTITY),
|
|
||||||
DRAGON_FIREBALL(26, FIREBALL),
|
|
||||||
EVOCATION_FANGS(33, ENTITY),
|
|
||||||
|
|
||||||
|
|
||||||
ENTITY_LIVING(-1, ENTITY),
|
|
||||||
ENTITY_INSENTIENT(-1, ENTITY_LIVING),
|
|
||||||
ENTITY_AGEABLE(-1, ENTITY_INSENTIENT),
|
|
||||||
ENTITY_TAMEABLE_ANIMAL(-1, ENTITY_AGEABLE),
|
|
||||||
ENTITY_HUMAN(-1, ENTITY_LIVING),
|
|
||||||
|
|
||||||
ARMOR_STAND(30, ENTITY_LIVING),
|
|
||||||
EVOCATION_ILLAGER(34, ENTITY_INSENTIENT),
|
|
||||||
VEX(35, ENTITY_INSENTIENT),
|
|
||||||
VINDICATION_ILLAGER(36, ENTITY_INSENTIENT),
|
|
||||||
|
|
||||||
// Vehicles
|
|
||||||
MINECART_ABSTRACT(-1, ENTITY),
|
|
||||||
MINECART_COMMAND(40, MINECART_ABSTRACT),
|
|
||||||
BOAT(41, ENTITY),
|
|
||||||
MINECART_RIDEABLE(42, MINECART_ABSTRACT),
|
|
||||||
MINECART_CHEST(43, MINECART_ABSTRACT),
|
|
||||||
MINECART_FURNACE(44, MINECART_ABSTRACT),
|
|
||||||
MINECART_TNT(45, MINECART_ABSTRACT),
|
|
||||||
MINECART_HOPPER(46, MINECART_ABSTRACT),
|
|
||||||
MINECART_MOB_SPAWNER(47, MINECART_ABSTRACT),
|
|
||||||
|
|
||||||
CREEPER(50, ENTITY_INSENTIENT),
|
|
||||||
|
|
||||||
ABSTRACT_SKELETON(-1, ENTITY_INSENTIENT),
|
|
||||||
SKELETON(51, ABSTRACT_SKELETON),
|
|
||||||
WITHER_SKELETON(5, ABSTRACT_SKELETON),
|
|
||||||
STRAY(6, ABSTRACT_SKELETON),
|
|
||||||
|
|
||||||
SPIDER(52, ENTITY_INSENTIENT),
|
|
||||||
GIANT(53, ENTITY_INSENTIENT),
|
|
||||||
|
|
||||||
ZOMBIE(54, ENTITY_INSENTIENT),
|
|
||||||
HUSK(23, ZOMBIE),
|
|
||||||
ZOMBIE_VILLAGER(27, ZOMBIE),
|
|
||||||
|
|
||||||
SLIME(55, ENTITY_INSENTIENT),
|
|
||||||
GHAST(56, ENTITY_INSENTIENT),
|
|
||||||
PIG_ZOMBIE(57, ZOMBIE),
|
|
||||||
ENDERMAN(58, ENTITY_INSENTIENT),
|
|
||||||
CAVE_SPIDER(59, SPIDER),
|
|
||||||
SILVERFISH(60, ENTITY_INSENTIENT),
|
|
||||||
BLAZE(61, ENTITY_INSENTIENT),
|
|
||||||
MAGMA_CUBE(62, SLIME),
|
|
||||||
ENDER_DRAGON(63, ENTITY_INSENTIENT),
|
|
||||||
WITHER(64, ENTITY_INSENTIENT),
|
|
||||||
BAT(65, ENTITY_INSENTIENT),
|
|
||||||
WITCH(66, ENTITY_INSENTIENT),
|
|
||||||
ENDERMITE(67, ENTITY_INSENTIENT),
|
|
||||||
|
|
||||||
GUARDIAN(68, ENTITY_INSENTIENT),
|
|
||||||
ELDER_GUARDIAN(4, EntityType.GUARDIAN), // Moved down to avoid illegal forward reference
|
|
||||||
|
|
||||||
IRON_GOLEM(99, ENTITY_INSENTIENT), // moved up to avoid illegal forward references
|
|
||||||
SHULKER(69, EntityType.IRON_GOLEM),
|
|
||||||
PIG(90, ENTITY_AGEABLE),
|
|
||||||
SHEEP(91, ENTITY_AGEABLE),
|
|
||||||
COW(92, ENTITY_AGEABLE),
|
|
||||||
CHICKEN(93, ENTITY_AGEABLE),
|
|
||||||
SQUID(94, ENTITY_INSENTIENT),
|
|
||||||
WOLF(95, ENTITY_TAMEABLE_ANIMAL),
|
|
||||||
MUSHROOM_COW(96, COW),
|
|
||||||
SNOWMAN(97, EntityType.IRON_GOLEM),
|
|
||||||
OCELOT(98, ENTITY_TAMEABLE_ANIMAL),
|
|
||||||
|
|
||||||
ABSTRACT_HORSE(-1, ENTITY_AGEABLE),
|
|
||||||
HORSE(100, ABSTRACT_HORSE),
|
|
||||||
SKELETON_HORSE(28, ABSTRACT_HORSE),
|
|
||||||
ZOMBIE_HORSE(29, ABSTRACT_HORSE),
|
|
||||||
|
|
||||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
|
||||||
DONKEY(31, CHESTED_HORSE),
|
|
||||||
MULE(32, CHESTED_HORSE),
|
|
||||||
LIAMA(103, CHESTED_HORSE),
|
|
||||||
|
|
||||||
|
|
||||||
RABBIT(101, ENTITY_AGEABLE),
|
|
||||||
POLAR_BEAR(102, ENTITY_AGEABLE),
|
|
||||||
VILLAGER(120, ENTITY_AGEABLE),
|
|
||||||
ENDER_CRYSTAL(200, ENTITY),
|
|
||||||
SPLASH_POTION(-1, ENTITY),
|
|
||||||
LINGERING_POTION(-1, SPLASH_POTION),
|
|
||||||
AREA_EFFECT_CLOUD(-1, ENTITY),
|
|
||||||
EGG(-1, ENTITY),
|
|
||||||
FISHING_HOOK(-1, ENTITY),
|
|
||||||
LIGHTNING(-1, ENTITY),
|
|
||||||
WEATHER(-1, ENTITY),
|
|
||||||
PLAYER(-1, ENTITY_HUMAN),
|
|
||||||
COMPLEX_PART(-1, ENTITY),
|
|
||||||
LIAMA_SPIT(-1, ENTITY);
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final EntityType parent;
|
|
||||||
|
|
||||||
EntityType(int id) {
|
|
||||||
this.id = id;
|
|
||||||
this.parent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<EntityType> findById(int id) {
|
|
||||||
if (id == -1) // Check if this is called
|
|
||||||
return Optional.empty();
|
|
||||||
|
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is(AbstractEntityType... types) {
|
|
||||||
for (AbstractEntityType type : types)
|
|
||||||
if (is(type))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is(AbstractEntityType type) {
|
|
||||||
return this == type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOrHasParent(AbstractEntityType type) {
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (parent.equals(type))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractEntityType> getParents() {
|
|
||||||
List<AbstractEntityType> types = new ArrayList<>();
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
types.add(parent);
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum ObjectType implements AbstractObjectType {
|
|
||||||
BOAT(1, EntityType.BOAT),
|
|
||||||
ITEM(2, EntityType.DROPPED_ITEM),
|
|
||||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
|
||||||
MINECART(10, EntityType.MINECART_ABSTRACT),
|
|
||||||
TNT_PRIMED(50, EntityType.PRIMED_TNT),
|
|
||||||
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
|
|
||||||
TIPPED_ARROW(60, EntityType.ARROW),
|
|
||||||
SNOWBALL(61, EntityType.SNOWBALL),
|
|
||||||
EGG(62, EntityType.EGG),
|
|
||||||
FIREBALL(63, EntityType.FIREBALL),
|
|
||||||
SMALL_FIREBALL(64, EntityType.SMALL_FIREBALL),
|
|
||||||
ENDER_PEARL(65, EntityType.ENDER_PEARL),
|
|
||||||
WITHER_SKULL(66, EntityType.WITHER_SKULL),
|
|
||||||
SHULKER_BULLET(67, EntityType.SHULKER_BULLET),
|
|
||||||
LIAMA_SPIT(68, EntityType.LIAMA_SPIT),
|
|
||||||
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
|
||||||
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
|
||||||
ENDER_SIGNAL(72, EntityType.ENDER_SIGNAL),
|
|
||||||
POTION(73, EntityType.SPLASH_POTION),
|
|
||||||
THROWN_EXP_BOTTLE(75, EntityType.THROWN_EXP_BOTTLE),
|
|
||||||
FIREWORK(76, EntityType.FIREWORK),
|
|
||||||
LEASH(77, EntityType.LEASH_HITCH),
|
|
||||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
|
||||||
EVOCATION_FANGS(79, EntityType.EVOCATION_FANGS),
|
|
||||||
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK),
|
|
||||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
|
||||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final EntityType type;
|
|
||||||
|
|
||||||
public static Optional<ObjectType> findById(int id) {
|
|
||||||
if (id == -1)
|
|
||||||
return Optional.empty();
|
|
||||||
|
|
||||||
for (ObjectType ent : ObjectType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<EntityType> getPCEntity(int id) {
|
|
||||||
Optional<ObjectType> output = findById(id);
|
|
||||||
|
|
||||||
if (!output.isPresent())
|
|
||||||
return Optional.empty();
|
|
||||||
return Optional.of(output.get().getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,274 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016 Matsv
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package nl.matsv.viabackwards.api.entities.types;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class EntityType1_12 {
|
|
||||||
|
|
||||||
public static EntityType getTypeFromId(int typeID, boolean isObject) throws Exception {
|
|
||||||
Optional<EntityType> type;
|
|
||||||
|
|
||||||
if (isObject)
|
|
||||||
type = ObjectType.getPCEntity(typeID);
|
|
||||||
else
|
|
||||||
type = EntityType.findById(typeID);
|
|
||||||
|
|
||||||
if (!type.isPresent()) {
|
|
||||||
if (!Via.getConfig().isSuppressMetadataErrors())
|
|
||||||
ViaBackwards.getPlatform().getLogger().severe("[EntityType1_12] Could not find type id " + typeID + " isObject=" + isObject);
|
|
||||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
|
||||||
}
|
|
||||||
|
|
||||||
return type.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum EntityType implements AbstractEntityType {
|
|
||||||
ENTITY(-1),
|
|
||||||
DROPPED_ITEM(1, ENTITY),
|
|
||||||
EXPERIENCE_ORB(2, ENTITY),
|
|
||||||
LEASH_HITCH(8, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
|
||||||
PAINTING(9, ENTITY), // Actually entity hanging but it doesn't make a lot of difference for metadata
|
|
||||||
ARROW(10, ENTITY),
|
|
||||||
SNOWBALL(11, ENTITY), // Actually EntityProjectile
|
|
||||||
FIREBALL(12, ENTITY),
|
|
||||||
SMALL_FIREBALL(13, ENTITY),
|
|
||||||
ENDER_PEARL(14, ENTITY), // Actually EntityProjectile
|
|
||||||
ENDER_SIGNAL(15, ENTITY),
|
|
||||||
THROWN_EXP_BOTTLE(17, ENTITY),
|
|
||||||
ITEM_FRAME(18, ENTITY), // Actually EntityHanging
|
|
||||||
WITHER_SKULL(19, ENTITY),
|
|
||||||
PRIMED_TNT(20, ENTITY),
|
|
||||||
FALLING_BLOCK(21, ENTITY),
|
|
||||||
FIREWORK(22, ENTITY),
|
|
||||||
SPECTRAL_ARROW(24, ARROW),
|
|
||||||
SHULKER_BULLET(25, ENTITY),
|
|
||||||
DRAGON_FIREBALL(26, FIREBALL),
|
|
||||||
EVOCATION_FANGS(33, ENTITY),
|
|
||||||
|
|
||||||
|
|
||||||
ENTITY_LIVING(-1, ENTITY),
|
|
||||||
ENTITY_INSENTIENT(-1, ENTITY_LIVING),
|
|
||||||
ENTITY_AGEABLE(-1, ENTITY_INSENTIENT),
|
|
||||||
ENTITY_TAMEABLE_ANIMAL(-1, ENTITY_AGEABLE),
|
|
||||||
ENTITY_HUMAN(-1, ENTITY_LIVING),
|
|
||||||
|
|
||||||
ARMOR_STAND(30, ENTITY_LIVING),
|
|
||||||
ENTITY_ILLAGER_ABSTRACT(-1, ENTITY_INSENTIENT),
|
|
||||||
EVOCATION_ILLAGER(34, ENTITY_ILLAGER_ABSTRACT),
|
|
||||||
VEX(35, ENTITY_INSENTIENT),
|
|
||||||
VINDICATION_ILLAGER(36, ENTITY_ILLAGER_ABSTRACT),
|
|
||||||
ILLUSION_ILLAGER(37, EVOCATION_ILLAGER),
|
|
||||||
|
|
||||||
// Vehicles
|
|
||||||
MINECART_ABSTRACT(-1, ENTITY),
|
|
||||||
MINECART_COMMAND(40, MINECART_ABSTRACT),
|
|
||||||
BOAT(41, ENTITY),
|
|
||||||
MINECART_RIDEABLE(42, MINECART_ABSTRACT),
|
|
||||||
MINECART_CHEST(43, MINECART_ABSTRACT),
|
|
||||||
MINECART_FURNACE(44, MINECART_ABSTRACT),
|
|
||||||
MINECART_TNT(45, MINECART_ABSTRACT),
|
|
||||||
MINECART_HOPPER(46, MINECART_ABSTRACT),
|
|
||||||
MINECART_MOB_SPAWNER(47, MINECART_ABSTRACT),
|
|
||||||
|
|
||||||
CREEPER(50, ENTITY_INSENTIENT),
|
|
||||||
|
|
||||||
ABSTRACT_SKELETON(-1, ENTITY_INSENTIENT),
|
|
||||||
SKELETON(51, ABSTRACT_SKELETON),
|
|
||||||
WITHER_SKELETON(5, ABSTRACT_SKELETON),
|
|
||||||
STRAY(6, ABSTRACT_SKELETON),
|
|
||||||
|
|
||||||
SPIDER(52, ENTITY_INSENTIENT),
|
|
||||||
GIANT(53, ENTITY_INSENTIENT),
|
|
||||||
|
|
||||||
ZOMBIE(54, ENTITY_INSENTIENT),
|
|
||||||
HUSK(23, ZOMBIE),
|
|
||||||
ZOMBIE_VILLAGER(27, ZOMBIE),
|
|
||||||
|
|
||||||
SLIME(55, ENTITY_INSENTIENT),
|
|
||||||
GHAST(56, ENTITY_INSENTIENT),
|
|
||||||
PIG_ZOMBIE(57, ZOMBIE),
|
|
||||||
ENDERMAN(58, ENTITY_INSENTIENT),
|
|
||||||
CAVE_SPIDER(59, SPIDER),
|
|
||||||
SILVERFISH(60, ENTITY_INSENTIENT),
|
|
||||||
BLAZE(61, ENTITY_INSENTIENT),
|
|
||||||
MAGMA_CUBE(62, SLIME),
|
|
||||||
ENDER_DRAGON(63, ENTITY_INSENTIENT),
|
|
||||||
WITHER(64, ENTITY_INSENTIENT),
|
|
||||||
BAT(65, ENTITY_INSENTIENT),
|
|
||||||
WITCH(66, ENTITY_INSENTIENT),
|
|
||||||
ENDERMITE(67, ENTITY_INSENTIENT),
|
|
||||||
|
|
||||||
GUARDIAN(68, ENTITY_INSENTIENT),
|
|
||||||
ELDER_GUARDIAN(4, EntityType.GUARDIAN), // Moved down to avoid illegal forward reference
|
|
||||||
|
|
||||||
IRON_GOLEM(99, ENTITY_INSENTIENT), // moved up to avoid illegal forward references
|
|
||||||
SHULKER(69, EntityType.IRON_GOLEM),
|
|
||||||
PIG(90, ENTITY_AGEABLE),
|
|
||||||
SHEEP(91, ENTITY_AGEABLE),
|
|
||||||
COW(92, ENTITY_AGEABLE),
|
|
||||||
CHICKEN(93, ENTITY_AGEABLE),
|
|
||||||
SQUID(94, ENTITY_INSENTIENT),
|
|
||||||
WOLF(95, ENTITY_TAMEABLE_ANIMAL),
|
|
||||||
MUSHROOM_COW(96, COW),
|
|
||||||
SNOWMAN(97, EntityType.IRON_GOLEM),
|
|
||||||
OCELOT(98, ENTITY_TAMEABLE_ANIMAL),
|
|
||||||
PARROT(105, ENTITY_TAMEABLE_ANIMAL),
|
|
||||||
|
|
||||||
ABSTRACT_HORSE(-1, ENTITY_AGEABLE),
|
|
||||||
HORSE(100, ABSTRACT_HORSE),
|
|
||||||
SKELETON_HORSE(28, ABSTRACT_HORSE),
|
|
||||||
ZOMBIE_HORSE(29, ABSTRACT_HORSE),
|
|
||||||
|
|
||||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
|
||||||
DONKEY(31, CHESTED_HORSE),
|
|
||||||
MULE(32, CHESTED_HORSE),
|
|
||||||
LIAMA(103, CHESTED_HORSE),
|
|
||||||
|
|
||||||
|
|
||||||
RABBIT(101, ENTITY_AGEABLE),
|
|
||||||
POLAR_BEAR(102, ENTITY_AGEABLE),
|
|
||||||
VILLAGER(120, ENTITY_AGEABLE),
|
|
||||||
ENDER_CRYSTAL(200, ENTITY),
|
|
||||||
SPLASH_POTION(-1, ENTITY),
|
|
||||||
LINGERING_POTION(-1, SPLASH_POTION),
|
|
||||||
AREA_EFFECT_CLOUD(-1, ENTITY),
|
|
||||||
EGG(-1, ENTITY),
|
|
||||||
FISHING_HOOK(-1, ENTITY),
|
|
||||||
LIGHTNING(-1, ENTITY),
|
|
||||||
WEATHER(-1, ENTITY),
|
|
||||||
PLAYER(-1, ENTITY_HUMAN),
|
|
||||||
COMPLEX_PART(-1, ENTITY),
|
|
||||||
LIAMA_SPIT(-1, ENTITY);
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final EntityType parent;
|
|
||||||
|
|
||||||
EntityType(int id) {
|
|
||||||
this.id = id;
|
|
||||||
this.parent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<EntityType> findById(int id) {
|
|
||||||
if (id == -1) // Check if this is called
|
|
||||||
return Optional.empty();
|
|
||||||
|
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is(AbstractEntityType... types) {
|
|
||||||
for (AbstractEntityType type : types)
|
|
||||||
if (is(type))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is(AbstractEntityType type) {
|
|
||||||
return this == type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOrHasParent(AbstractEntityType type) {
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (parent.equals(type))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractEntityType> getParents() {
|
|
||||||
List<AbstractEntityType> types = new ArrayList<>();
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
types.add(parent);
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum ObjectType implements AbstractObjectType {
|
|
||||||
BOAT(1, EntityType.BOAT),
|
|
||||||
ITEM(2, EntityType.DROPPED_ITEM),
|
|
||||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
|
||||||
MINECART(10, EntityType.MINECART_ABSTRACT),
|
|
||||||
TNT_PRIMED(50, EntityType.PRIMED_TNT),
|
|
||||||
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
|
|
||||||
TIPPED_ARROW(60, EntityType.ARROW),
|
|
||||||
SNOWBALL(61, EntityType.SNOWBALL),
|
|
||||||
EGG(62, EntityType.EGG),
|
|
||||||
FIREBALL(63, EntityType.FIREBALL),
|
|
||||||
SMALL_FIREBALL(64, EntityType.SMALL_FIREBALL),
|
|
||||||
ENDER_PEARL(65, EntityType.ENDER_PEARL),
|
|
||||||
WITHER_SKULL(66, EntityType.WITHER_SKULL),
|
|
||||||
SHULKER_BULLET(67, EntityType.SHULKER_BULLET),
|
|
||||||
LIAMA_SPIT(68, EntityType.LIAMA_SPIT),
|
|
||||||
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
|
||||||
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
|
||||||
ENDER_SIGNAL(72, EntityType.ENDER_SIGNAL),
|
|
||||||
POTION(73, EntityType.SPLASH_POTION),
|
|
||||||
THROWN_EXP_BOTTLE(75, EntityType.THROWN_EXP_BOTTLE),
|
|
||||||
FIREWORK(76, EntityType.FIREWORK),
|
|
||||||
LEASH(77, EntityType.LEASH_HITCH),
|
|
||||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
|
||||||
EVOCATION_FANGS(79, EntityType.EVOCATION_FANGS),
|
|
||||||
FISHIHNG_HOOK(90, EntityType.FISHING_HOOK),
|
|
||||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
|
||||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL);
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final EntityType type;
|
|
||||||
|
|
||||||
public static Optional<ObjectType> findById(int id) {
|
|
||||||
if (id == -1)
|
|
||||||
return Optional.empty();
|
|
||||||
|
|
||||||
for (ObjectType ent : ObjectType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<EntityType> getPCEntity(int id) {
|
|
||||||
Optional<ObjectType> output = findById(id);
|
|
||||||
|
|
||||||
if (!output.isPresent())
|
|
||||||
return Optional.empty();
|
|
||||||
return Optional.of(output.get().getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,319 +0,0 @@
|
|||||||
package nl.matsv.viabackwards.api.entities.types;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
|
|
||||||
public class EntityType1_13 {
|
|
||||||
|
|
||||||
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
|
||||||
Optional<EntityType> type;
|
|
||||||
|
|
||||||
if (isObject)
|
|
||||||
type = ObjectType.getPCEntity(typeID);
|
|
||||||
else
|
|
||||||
type = EntityType.findById(typeID);
|
|
||||||
|
|
||||||
if (!type.isPresent()) {
|
|
||||||
ViaBackwards.getPlatform().getLogger().severe("[EntityType1_13] Could not find type id " + typeID + " isObject=" + isObject);
|
|
||||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
|
||||||
}
|
|
||||||
|
|
||||||
return type.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum EntityType implements AbstractEntityType {
|
|
||||||
|
|
||||||
|
|
||||||
ENTITY(-1), // abm
|
|
||||||
|
|
||||||
AREA_EFFECT_CLOUD(0, ENTITY), // abk
|
|
||||||
ENDER_CRYSTAL(16, ENTITY), // aho
|
|
||||||
EVOCATION_FANGS(20, ENTITY), // ala
|
|
||||||
XP_ORB(22, ENTITY), // abs
|
|
||||||
EYE_OF_ENDER_SIGNAL(23, ENTITY), // alb
|
|
||||||
FALLING_BLOCK(24, ENTITY), // aix
|
|
||||||
FIREWORKS_ROCKET(25, ENTITY), // alc
|
|
||||||
ITEM(32, ENTITY), // aiy
|
|
||||||
LLAMA_SPIT(37, ENTITY), // ale
|
|
||||||
TNT(55, ENTITY), // aiz
|
|
||||||
SHULKER_BULLET(60, ENTITY), // alh
|
|
||||||
FISHING_BOBBER(93, ENTITY), // ais
|
|
||||||
|
|
||||||
LIVINGENTITY(-1, ENTITY), // abv
|
|
||||||
ARMOR_STAND(1, LIVINGENTITY), // ail
|
|
||||||
PLAYER(92, LIVINGENTITY), // aks
|
|
||||||
|
|
||||||
ABSTRACT_INSENTIENT(-1, LIVINGENTITY), // abw
|
|
||||||
ENDER_DRAGON(17, ABSTRACT_INSENTIENT), // ahp
|
|
||||||
|
|
||||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT), // acd
|
|
||||||
|
|
||||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE), // abj
|
|
||||||
VILLAGER(79, ABSTRACT_AGEABLE), // akn
|
|
||||||
|
|
||||||
// Animals
|
|
||||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE), // agd
|
|
||||||
CHICKEN(7, ABSTRACT_ANIMAL), // age
|
|
||||||
COW(9, ABSTRACT_ANIMAL), // agg
|
|
||||||
MOOSHROOM(47, COW), // agi
|
|
||||||
PIG(51, ABSTRACT_ANIMAL), // agl
|
|
||||||
POLAR_BEAR(54, ABSTRACT_ANIMAL), // agm
|
|
||||||
RABBIT(56, ABSTRACT_ANIMAL), // ago
|
|
||||||
SHEEP(58, ABSTRACT_ANIMAL), // agq
|
|
||||||
TURTLE(73, ABSTRACT_ANIMAL), // agv
|
|
||||||
|
|
||||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL), // acg
|
|
||||||
OCELOT(48, ABSTRACT_TAMEABLE_ANIMAL), // agj
|
|
||||||
WOLF(86, ABSTRACT_TAMEABLE_ANIMAL), // agy
|
|
||||||
|
|
||||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), // agr
|
|
||||||
PARROT(50, ABSTRACT_PARROT), // agk
|
|
||||||
|
|
||||||
|
|
||||||
// Horses
|
|
||||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), // aha
|
|
||||||
CHESTED_HORSE(-1, ABSTRACT_HORSE), // agz
|
|
||||||
DONKEY(11, CHESTED_HORSE), // ahb
|
|
||||||
MULE(46, CHESTED_HORSE), // ahf
|
|
||||||
LLAMA(36, CHESTED_HORSE), // ahe
|
|
||||||
HORSE(29, ABSTRACT_HORSE), // ahc
|
|
||||||
SKELETON_HORSE(63, ABSTRACT_HORSE), // ahg
|
|
||||||
ZOMBIE_HORSE(88, ABSTRACT_HORSE), // ahi
|
|
||||||
|
|
||||||
// Golem
|
|
||||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE), // agc
|
|
||||||
SNOWMAN(66, ABSTRACT_GOLEM), // ags
|
|
||||||
VILLAGER_GOLEM(80, ABSTRACT_GOLEM), // agw
|
|
||||||
SHULKER(59, ABSTRACT_GOLEM), // ajx
|
|
||||||
|
|
||||||
// Fish
|
|
||||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE), // agb
|
|
||||||
COD_MOB(8, ABSTRACT_FISHES), // agf
|
|
||||||
PUFFER_FISH(52, ABSTRACT_FISHES), // agn
|
|
||||||
SALMON_MOB(57, ABSTRACT_FISHES), // agp
|
|
||||||
TROPICAL_FISH(72, ABSTRACT_FISHES), // agu
|
|
||||||
|
|
||||||
// Monsters
|
|
||||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE), // ajs
|
|
||||||
BLAZE(4, ABSTRACT_MONSTER), // ajd
|
|
||||||
CREEPER(10, ABSTRACT_MONSTER), // ajf
|
|
||||||
ENDERMITE(19, ABSTRACT_MONSTER), // ajj
|
|
||||||
ENDERMAN(18, ABSTRACT_MONSTER), // aji
|
|
||||||
GIANT(27, ABSTRACT_MONSTER), // ajn
|
|
||||||
SILVERFISH(61, ABSTRACT_MONSTER), // ajy
|
|
||||||
VEX(78, ABSTRACT_MONSTER), // ake
|
|
||||||
WITCH(82, ABSTRACT_MONSTER), // akg
|
|
||||||
WITHER(83, ABSTRACT_MONSTER), // aij
|
|
||||||
|
|
||||||
// Illagers
|
|
||||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER), // ajb
|
|
||||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE), // akb
|
|
||||||
EVOCATION_ILLAGER(21, ABSTRACT_EVO_ILLU_ILLAGER), // ajl
|
|
||||||
ILLUSION_ILLAGER(31, ABSTRACT_EVO_ILLU_ILLAGER), // ajq
|
|
||||||
VINDICATION_ILLAGER(81, ABSTRACT_ILLAGER_BASE), // akf
|
|
||||||
|
|
||||||
// Skeletons
|
|
||||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER), // ajc
|
|
||||||
SKELETON(62, ABSTRACT_SKELETON), // ajz
|
|
||||||
STRAY(71, ABSTRACT_SKELETON), // akd
|
|
||||||
WITHER_SKELETON(84, ABSTRACT_SKELETON), // akh
|
|
||||||
|
|
||||||
// Guardians
|
|
||||||
GUARDIAN(28, ABSTRACT_MONSTER), // ajo
|
|
||||||
ELDER_GUARDIAN(15, GUARDIAN), // ajh
|
|
||||||
|
|
||||||
// Spiders
|
|
||||||
SPIDER(69, ABSTRACT_MONSTER), // akc
|
|
||||||
CAVE_SPIDER(6, SPIDER), // aje
|
|
||||||
|
|
||||||
// Zombies - META CHECKED
|
|
||||||
ZOMBIE(87, ABSTRACT_MONSTER), // aki
|
|
||||||
DROWNED(14, ZOMBIE), // ajg
|
|
||||||
HUSK(30, ZOMBIE), // ajp
|
|
||||||
ZOMBIE_PIGMAN(53, ZOMBIE), // aju
|
|
||||||
ZOMBIE_VILLAGER(89, ZOMBIE), // akj
|
|
||||||
|
|
||||||
// Flying entities
|
|
||||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT), // abt
|
|
||||||
GHAST(26, ABSTRACT_FLYING), // ajm
|
|
||||||
PHANTOM(90, ABSTRACT_FLYING), // ajt
|
|
||||||
|
|
||||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT), // afy
|
|
||||||
BAT(3, ABSTRACT_AMBIENT), // afz
|
|
||||||
|
|
||||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), // agx
|
|
||||||
SQUID(70, ABSTRACT_WATERMOB), // agt
|
|
||||||
DOLPHIN(12, ABSTRACT_WATERMOB), // ajq
|
|
||||||
|
|
||||||
// Slimes
|
|
||||||
SLIME(64, ABSTRACT_INSENTIENT), // aka
|
|
||||||
MAGMA_CUBE(38, SLIME), // ajr
|
|
||||||
|
|
||||||
// Hangable objects
|
|
||||||
ABSTRACT_HANGING(-1, ENTITY), // aim
|
|
||||||
LEASH_KNOT(35, ABSTRACT_HANGING), // aio
|
|
||||||
ITEM_FRAME(33, ABSTRACT_HANGING), // ain
|
|
||||||
PAINTING(49, ABSTRACT_HANGING), // aiq
|
|
||||||
|
|
||||||
ABSTRACT_LIGHTNING(-1, ENTITY), // aiu
|
|
||||||
LIGHTNING_BOLT(91, ABSTRACT_LIGHTNING), // aiv
|
|
||||||
|
|
||||||
// Arrows
|
|
||||||
ABSTRACT_ARROW(-1, ENTITY), // akw
|
|
||||||
ARROW(2, ABSTRACT_ARROW), // aky
|
|
||||||
SPECTRAL_ARROW(68, ABSTRACT_ARROW), // alk
|
|
||||||
TRIDENT(94, ABSTRACT_ARROW), // alq
|
|
||||||
|
|
||||||
// Fireballs
|
|
||||||
ABSTRACT_FIREBALL(-1, ENTITY), // akx
|
|
||||||
DRAGON_FIREBALL(13, ABSTRACT_FIREBALL), // akz
|
|
||||||
FIREBALL(34, ABSTRACT_FIREBALL), // ald
|
|
||||||
SMALL_FIREBALL(65, ABSTRACT_FIREBALL), // ali
|
|
||||||
WITHER_SKULL(85, ABSTRACT_FIREBALL), // alr
|
|
||||||
|
|
||||||
// Projectiles
|
|
||||||
PROJECTILE_ABSTRACT(-1, ENTITY), // all
|
|
||||||
SNOWBALL(67, PROJECTILE_ABSTRACT), // alj
|
|
||||||
ENDER_PEARL(75, PROJECTILE_ABSTRACT), // aln
|
|
||||||
EGG(74, PROJECTILE_ABSTRACT), // alm
|
|
||||||
POTION(77, PROJECTILE_ABSTRACT), // alp
|
|
||||||
XP_BOTTLE(76, PROJECTILE_ABSTRACT), // alo
|
|
||||||
|
|
||||||
// Vehicles
|
|
||||||
MINECART_ABSTRACT(-1, ENTITY), // alt
|
|
||||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT), // alu
|
|
||||||
CHEST_MINECART(40, CHESTED_MINECART_ABSTRACT), // alx
|
|
||||||
HOPPER_MINECART(43, CHESTED_MINECART_ABSTRACT), // ama
|
|
||||||
MINECART(39, MINECART_ABSTRACT), // alw
|
|
||||||
FURNACE_MINECART(42, MINECART_ABSTRACT), // alz
|
|
||||||
COMMANDBLOCK_MINECART(41, MINECART_ABSTRACT), // aly
|
|
||||||
TNT_MINECART(45, MINECART_ABSTRACT), // amc
|
|
||||||
SPAWNER_MINECART(44, MINECART_ABSTRACT), // amb
|
|
||||||
BOAT(5, ENTITY); // alv
|
|
||||||
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final EntityType parent;
|
|
||||||
|
|
||||||
EntityType(int id) {
|
|
||||||
this.id = id;
|
|
||||||
this.parent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<EntityType> findById(int id) {
|
|
||||||
if (id == -1) // Check if this is called
|
|
||||||
return Optional.empty();
|
|
||||||
|
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean is(AbstractEntityType... types) {
|
|
||||||
for (AbstractEntityType type : types)
|
|
||||||
if (is(type))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean is(AbstractEntityType type) {
|
|
||||||
return this == type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOrHasParent(AbstractEntityType type) {
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (parent == type)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractEntityType> getParents() {
|
|
||||||
List<AbstractEntityType> types = new ArrayList<>();
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
types.add(parent);
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum ObjectType implements AbstractObjectType {
|
|
||||||
BOAT(1, EntityType.BOAT),
|
|
||||||
ITEM(2, EntityType.ITEM),
|
|
||||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
|
||||||
MINECART(10, EntityType.MINECART_ABSTRACT),
|
|
||||||
TNT_PRIMED(50, EntityType.TNT),
|
|
||||||
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
|
|
||||||
TIPPED_ARROW(60, EntityType.ARROW),
|
|
||||||
SNOWBALL(61, EntityType.SNOWBALL),
|
|
||||||
EGG(62, EntityType.EGG),
|
|
||||||
FIREBALL(63, EntityType.FIREBALL),
|
|
||||||
SMALL_FIREBALL(64, EntityType.SMALL_FIREBALL),
|
|
||||||
ENDER_PEARL(65, EntityType.ENDER_PEARL),
|
|
||||||
WITHER_SKULL(66, EntityType.WITHER_SKULL),
|
|
||||||
SHULKER_BULLET(67, EntityType.SHULKER_BULLET),
|
|
||||||
LIAMA_SPIT(68, EntityType.LLAMA_SPIT),
|
|
||||||
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
|
||||||
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
|
||||||
ENDER_SIGNAL(72, EntityType.EYE_OF_ENDER_SIGNAL),
|
|
||||||
POTION(73, EntityType.POTION),
|
|
||||||
THROWN_EXP_BOTTLE(75, EntityType.XP_BOTTLE),
|
|
||||||
FIREWORK(76, EntityType.FIREWORKS_ROCKET),
|
|
||||||
LEASH(77, EntityType.LEASH_KNOT),
|
|
||||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
|
||||||
EVOCATION_FANGS(79, EntityType.EVOCATION_FANGS),
|
|
||||||
FISHIHNG_HOOK(90, EntityType.FISHING_BOBBER),
|
|
||||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
|
||||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL),
|
|
||||||
TRIDENT(94, EntityType.TRIDENT);
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final EntityType type;
|
|
||||||
|
|
||||||
public static Optional<ObjectType> findById(int id) {
|
|
||||||
if (id == -1)
|
|
||||||
return Optional.empty();
|
|
||||||
|
|
||||||
for (ObjectType ent : ObjectType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return Optional.of(ent);
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<EntityType> getPCEntity(int id) {
|
|
||||||
Optional<ObjectType> output = findById(id);
|
|
||||||
|
|
||||||
return output.map(ObjectType::getType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Optional<ObjectType> fromEntityType(EntityType type) {
|
|
||||||
for (ObjectType ent : ObjectType.values())
|
|
||||||
if (ent.getType() == type)
|
|
||||||
return Optional.of(ent);
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,258 +0,0 @@
|
|||||||
package nl.matsv.viabackwards.api.entities.types;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class EntityType1_14 {
|
|
||||||
public static EntityType1_14.EntityType getTypeFromId(int typeID) {
|
|
||||||
Optional<EntityType> type = EntityType.findById(typeID);
|
|
||||||
|
|
||||||
if (!type.isPresent()) {
|
|
||||||
ViaBackwards.getPlatform().getLogger().severe("Could not find type id " + typeID);
|
|
||||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
|
||||||
}
|
|
||||||
|
|
||||||
return type.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum EntityType implements AbstractEntityType {
|
|
||||||
// Auto generated
|
|
||||||
|
|
||||||
ENTITY(-1),
|
|
||||||
|
|
||||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
|
||||||
ENDER_CRYSTAL(17, ENTITY),
|
|
||||||
EVOCATION_FANGS(21, ENTITY),
|
|
||||||
XP_ORB(23, ENTITY),
|
|
||||||
EYE_OF_ENDER_SIGNAL(24, ENTITY),
|
|
||||||
FALLING_BLOCK(25, ENTITY),
|
|
||||||
FIREWORKS_ROCKET(26, ENTITY),
|
|
||||||
ITEM(34, ENTITY),
|
|
||||||
LLAMA_SPIT(39, ENTITY),
|
|
||||||
TNT(58, ENTITY),
|
|
||||||
SHULKER_BULLET(63, ENTITY),
|
|
||||||
FISHING_BOBBER(101, ENTITY),
|
|
||||||
|
|
||||||
LIVINGENTITY(-1, ENTITY),
|
|
||||||
ARMOR_STAND(1, LIVINGENTITY),
|
|
||||||
PLAYER(100, LIVINGENTITY),
|
|
||||||
|
|
||||||
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
|
|
||||||
ENDER_DRAGON(18, ABSTRACT_INSENTIENT),
|
|
||||||
|
|
||||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
|
|
||||||
|
|
||||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
|
|
||||||
VILLAGER(84, ABSTRACT_AGEABLE),
|
|
||||||
WANDERING_TRADER(88, ABSTRACT_AGEABLE),
|
|
||||||
|
|
||||||
// Animals
|
|
||||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
|
|
||||||
DOLPHIN(13, ABSTRACT_INSENTIENT),
|
|
||||||
CHICKEN(8, ABSTRACT_ANIMAL),
|
|
||||||
COW(10, ABSTRACT_ANIMAL),
|
|
||||||
MOOSHROOM(49, COW),
|
|
||||||
PANDA(52, ABSTRACT_INSENTIENT),
|
|
||||||
PIG(54, ABSTRACT_ANIMAL),
|
|
||||||
POLAR_BEAR(57, ABSTRACT_ANIMAL),
|
|
||||||
RABBIT(59, ABSTRACT_ANIMAL),
|
|
||||||
SHEEP(61, ABSTRACT_ANIMAL),
|
|
||||||
TURTLE(77, ABSTRACT_ANIMAL),
|
|
||||||
FOX(27, ABSTRACT_ANIMAL),
|
|
||||||
|
|
||||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
|
|
||||||
CAT(6, ABSTRACT_TAMEABLE_ANIMAL),
|
|
||||||
OCELOT(50, ABSTRACT_TAMEABLE_ANIMAL),
|
|
||||||
WOLF(93, ABSTRACT_TAMEABLE_ANIMAL),
|
|
||||||
|
|
||||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
|
|
||||||
PARROT(53, ABSTRACT_PARROT),
|
|
||||||
|
|
||||||
// Horses
|
|
||||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
|
|
||||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
|
||||||
DONKEY(12, CHESTED_HORSE),
|
|
||||||
MULE(48, CHESTED_HORSE),
|
|
||||||
LLAMA(38, CHESTED_HORSE),
|
|
||||||
TRADER_LLAMA(75, CHESTED_HORSE),
|
|
||||||
HORSE(31, ABSTRACT_HORSE),
|
|
||||||
SKELETON_HORSE(66, ABSTRACT_HORSE),
|
|
||||||
ZOMBIE_HORSE(95, ABSTRACT_HORSE),
|
|
||||||
|
|
||||||
// Golem
|
|
||||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
|
||||||
SNOWMAN(69, ABSTRACT_GOLEM),
|
|
||||||
VILLAGER_GOLEM(85, ABSTRACT_GOLEM),
|
|
||||||
SHULKER(62, ABSTRACT_GOLEM),
|
|
||||||
|
|
||||||
// Fish
|
|
||||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
|
||||||
COD(9, ABSTRACT_FISHES),
|
|
||||||
PUFFER_FISH(55, ABSTRACT_FISHES),
|
|
||||||
SALMON_MOB(60, ABSTRACT_FISHES),
|
|
||||||
TROPICAL_FISH(76, ABSTRACT_FISHES),
|
|
||||||
|
|
||||||
// Monsters
|
|
||||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
|
|
||||||
BLAZE(4, ABSTRACT_MONSTER),
|
|
||||||
CREEPER(11, ABSTRACT_MONSTER),
|
|
||||||
ENDERMITE(20, ABSTRACT_MONSTER),
|
|
||||||
ENDERMAN(19, ABSTRACT_MONSTER),
|
|
||||||
GIANT(29, ABSTRACT_MONSTER),
|
|
||||||
SILVERFISH(64, ABSTRACT_MONSTER),
|
|
||||||
VEX(83, ABSTRACT_MONSTER),
|
|
||||||
WITCH(89, ABSTRACT_MONSTER),
|
|
||||||
WITHER(90, ABSTRACT_MONSTER),
|
|
||||||
RAVAGER(98, ABSTRACT_MONSTER),
|
|
||||||
|
|
||||||
// Illagers
|
|
||||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
|
||||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
|
||||||
EVOCATION_ILLAGER(22, ABSTRACT_EVO_ILLU_ILLAGER),
|
|
||||||
ILLUSION_ILLAGER(33, ABSTRACT_EVO_ILLU_ILLAGER),
|
|
||||||
VINDICATION_ILLAGER(86, ABSTRACT_ILLAGER_BASE),
|
|
||||||
PILLAGER(87, ABSTRACT_ILLAGER_BASE),
|
|
||||||
|
|
||||||
// Skeletons
|
|
||||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
|
|
||||||
SKELETON(65, ABSTRACT_SKELETON),
|
|
||||||
STRAY(74, ABSTRACT_SKELETON),
|
|
||||||
WITHER_SKELETON(91, ABSTRACT_SKELETON),
|
|
||||||
|
|
||||||
// Guardians
|
|
||||||
GUARDIAN(30, ABSTRACT_MONSTER),
|
|
||||||
ELDER_GUARDIAN(16, GUARDIAN),
|
|
||||||
|
|
||||||
// Spiders
|
|
||||||
SPIDER(72, ABSTRACT_MONSTER),
|
|
||||||
CAVE_SPIDER(7, SPIDER),
|
|
||||||
|
|
||||||
// Zombies - META CHECKED
|
|
||||||
ZOMBIE(94, ABSTRACT_MONSTER),
|
|
||||||
DROWNED(15, ZOMBIE),
|
|
||||||
HUSK(32, ZOMBIE),
|
|
||||||
ZOMBIE_PIGMAN(56, ZOMBIE),
|
|
||||||
ZOMBIE_VILLAGER(96, ZOMBIE),
|
|
||||||
|
|
||||||
// Flying entities
|
|
||||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
|
|
||||||
GHAST(28, ABSTRACT_FLYING),
|
|
||||||
PHANTOM(97, ABSTRACT_FLYING),
|
|
||||||
|
|
||||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
|
|
||||||
BAT(3, ABSTRACT_AMBIENT),
|
|
||||||
|
|
||||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
|
|
||||||
SQUID(73, ABSTRACT_WATERMOB),
|
|
||||||
|
|
||||||
// Slimes
|
|
||||||
SLIME(67, ABSTRACT_INSENTIENT),
|
|
||||||
MAGMA_CUBE(40, SLIME),
|
|
||||||
|
|
||||||
// Hangable objects
|
|
||||||
ABSTRACT_HANGING(-1, ENTITY),
|
|
||||||
LEASH_KNOT(37, ABSTRACT_HANGING),
|
|
||||||
ITEM_FRAME(35, ABSTRACT_HANGING),
|
|
||||||
PAINTING(51, ABSTRACT_HANGING),
|
|
||||||
|
|
||||||
ABSTRACT_LIGHTNING(-1, ENTITY),
|
|
||||||
LIGHTNING_BOLT(99, ABSTRACT_LIGHTNING),
|
|
||||||
|
|
||||||
// Arrows
|
|
||||||
ABSTRACT_ARROW(-1, ENTITY),
|
|
||||||
ARROW(2, ABSTRACT_ARROW),
|
|
||||||
SPECTRAL_ARROW(71, ABSTRACT_ARROW),
|
|
||||||
TRIDENT(82, ABSTRACT_ARROW),
|
|
||||||
|
|
||||||
// Fireballs
|
|
||||||
ABSTRACT_FIREBALL(-1, ENTITY),
|
|
||||||
DRAGON_FIREBALL(14, ABSTRACT_FIREBALL),
|
|
||||||
FIREBALL(36, ABSTRACT_FIREBALL),
|
|
||||||
SMALL_FIREBALL(68, ABSTRACT_FIREBALL),
|
|
||||||
WITHER_SKULL(92, ABSTRACT_FIREBALL),
|
|
||||||
|
|
||||||
// Projectiles
|
|
||||||
PROJECTILE_ABSTRACT(-1, ENTITY),
|
|
||||||
SNOWBALL(70, PROJECTILE_ABSTRACT),
|
|
||||||
ENDER_PEARL(79, PROJECTILE_ABSTRACT),
|
|
||||||
EGG(78, PROJECTILE_ABSTRACT),
|
|
||||||
POTION(81, PROJECTILE_ABSTRACT),
|
|
||||||
XP_BOTTLE(80, PROJECTILE_ABSTRACT),
|
|
||||||
|
|
||||||
// Vehicles
|
|
||||||
MINECART_ABSTRACT(-1, ENTITY),
|
|
||||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
|
|
||||||
CHEST_MINECART(42, CHESTED_MINECART_ABSTRACT),
|
|
||||||
HOPPER_MINECART(45, CHESTED_MINECART_ABSTRACT),
|
|
||||||
MINECART(41, MINECART_ABSTRACT),
|
|
||||||
FURNACE_MINECART(44, MINECART_ABSTRACT),
|
|
||||||
COMMANDBLOCK_MINECART(43, MINECART_ABSTRACT),
|
|
||||||
TNT_MINECART(47, MINECART_ABSTRACT),
|
|
||||||
SPAWNER_MINECART(46, MINECART_ABSTRACT),
|
|
||||||
BOAT(5, ENTITY),
|
|
||||||
;
|
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final EntityType parent;
|
|
||||||
|
|
||||||
EntityType(int id) {
|
|
||||||
this.id = id;
|
|
||||||
this.parent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static java.util.Optional<EntityType> findById(int id) {
|
|
||||||
if (id == -1) // Check if this is called
|
|
||||||
return java.util.Optional.empty();
|
|
||||||
|
|
||||||
for (EntityType ent : EntityType.values())
|
|
||||||
if (ent.getId() == id)
|
|
||||||
return java.util.Optional.of(ent);
|
|
||||||
|
|
||||||
return java.util.Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean is(AbstractEntityType... types) {
|
|
||||||
for (AbstractEntityType type : types)
|
|
||||||
if (is(type))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean is(AbstractEntityType type) {
|
|
||||||
return this == type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOrHasParent(AbstractEntityType type) {
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (parent == type)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractEntityType> getParents() {
|
|
||||||
List<AbstractEntityType> types = new ArrayList<>();
|
|
||||||
EntityType parent = this;
|
|
||||||
|
|
||||||
do {
|
|
||||||
types.add(parent);
|
|
||||||
parent = parent.getParent();
|
|
||||||
} while (parent != null);
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,4 +13,9 @@ package nl.matsv.viabackwards.api.exceptions;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class RemovedValueException extends IOException {
|
public class RemovedValueException extends IOException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* May be cached since it is never actually printed, only checked.
|
||||||
|
*/
|
||||||
|
public static final RemovedValueException EX = new RemovedValueException();
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,7 @@
|
|||||||
|
|
||||||
package nl.matsv.viabackwards.api.rewriters;
|
package nl.matsv.viabackwards.api.rewriters;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.Setter;
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
import nl.matsv.viabackwards.api.entities.meta.MetaHandlerEvent;
|
import nl.matsv.viabackwards.api.entities.meta.MetaHandlerEvent;
|
||||||
@ -21,11 +18,11 @@ import nl.matsv.viabackwards.api.entities.meta.MetaHandlerSettings;
|
|||||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractObjectType;
|
|
||||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
|
import us.myles.ViaVersion.api.entities.ObjectType;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
|
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
||||||
@ -37,64 +34,57 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewriter<T> {
|
public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewriter<T> {
|
||||||
private final Map<AbstractEntityType, EntityData> entityTypes = new ConcurrentHashMap<>();
|
private final Map<EntityType, EntityData> entityTypes = new ConcurrentHashMap<>();
|
||||||
private final Map<AbstractObjectType, EntityData> objectTypes = new ConcurrentHashMap<>();
|
private final Map<ObjectType, EntityData> objectTypes = new ConcurrentHashMap<>();
|
||||||
private final List<MetaHandlerSettings> metaHandlers = new ArrayList<>();
|
private final List<MetaHandlerSettings> metaHandlers = new ArrayList<>();
|
||||||
|
|
||||||
@Getter(AccessLevel.PROTECTED)
|
|
||||||
@Setter(AccessLevel.PROTECTED)
|
|
||||||
private MetaType displayNameMetaType = MetaType1_9.String;
|
private MetaType displayNameMetaType = MetaType1_9.String;
|
||||||
@Getter(AccessLevel.PROTECTED)
|
|
||||||
@Setter(AccessLevel.PROTECTED)
|
|
||||||
private int displayNameIndex = 2;
|
private int displayNameIndex = 2;
|
||||||
@Getter(AccessLevel.PROTECTED)
|
private boolean isDisplayNameJson;
|
||||||
@Setter(AccessLevel.PROTECTED)
|
|
||||||
private boolean isDisplayNameJson = false;
|
|
||||||
|
|
||||||
protected AbstractEntityType getEntityType(UserConnection connection, int id) {
|
protected EntityType getEntityType(UserConnection connection, int id) {
|
||||||
return getEntityTracker(connection).getEntityType(id);
|
return getEntityTracker(connection).getEntityType(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addTrackedEntity(UserConnection connection, int entityId, AbstractEntityType type) {
|
protected void addTrackedEntity(UserConnection connection, int entityId, EntityType type) {
|
||||||
getEntityTracker(connection).trackEntityType(entityId, type);
|
getEntityTracker(connection).trackEntityType(entityId, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean hasData(AbstractEntityType type) {
|
protected boolean hasData(EntityType type) {
|
||||||
return entityTypes.containsKey(type);
|
return entityTypes.containsKey(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Optional<EntityData> getEntityData(AbstractEntityType type) {
|
protected Optional<EntityData> getEntityData(EntityType type) {
|
||||||
if (!entityTypes.containsKey(type))
|
if (!entityTypes.containsKey(type))
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
return Optional.of(entityTypes.get(type));
|
return Optional.of(entityTypes.get(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Optional<EntityData> getObjectData(AbstractObjectType type) {
|
protected Optional<EntityData> getObjectData(ObjectType type) {
|
||||||
if (!objectTypes.containsKey(type))
|
if (!objectTypes.containsKey(type))
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
return Optional.of(objectTypes.get(type));
|
return Optional.of(objectTypes.get(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EntityData regEntType(AbstractEntityType oldEnt, AbstractEntityType replacement) {
|
protected EntityData regEntType(EntityType oldEnt, EntityType replacement) {
|
||||||
return regEntType(oldEnt, (short) replacement.getId());
|
return regEntType(oldEnt, (short) replacement.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntityData regEntType(AbstractEntityType oldEnt, short replacementId) {
|
private EntityData regEntType(EntityType oldEnt, short replacementId) {
|
||||||
EntityData data = new EntityData(oldEnt.getId(), false, replacementId, -1);
|
EntityData data = new EntityData(oldEnt.getId(), false, replacementId, -1);
|
||||||
entityTypes.put(oldEnt, data);
|
entityTypes.put(oldEnt, data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EntityData regObjType(AbstractObjectType oldObj, AbstractObjectType replacement, int data) {
|
protected EntityData regObjType(ObjectType oldObj, ObjectType replacement, int data) {
|
||||||
return regObjType(oldObj, (short) replacement.getId(), data);
|
return regObjType(oldObj, (short) replacement.getId(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntityData regObjType(AbstractObjectType oldObj, short replacementId, int data) {
|
private EntityData regObjType(ObjectType oldObj, short replacementId, int data) {
|
||||||
EntityData entData = new EntityData(oldObj.getId(), true, replacementId, data);
|
EntityData entData = new EntityData(oldObj.getId(), true, replacementId, data);
|
||||||
objectTypes.put(oldObj, entData);
|
objectTypes.put(oldObj, entData);
|
||||||
return entData;
|
return entData;
|
||||||
@ -115,9 +105,9 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
|
|||||||
}
|
}
|
||||||
|
|
||||||
EntityTracker.StoredEntity entity = optEntity.get();
|
EntityTracker.StoredEntity entity = optEntity.get();
|
||||||
AbstractEntityType type = entity.getType();
|
EntityType type = entity.getType();
|
||||||
|
|
||||||
List<Metadata> newList = new CopyOnWriteArrayList<>();
|
List<Metadata> newList = new ArrayList<>();
|
||||||
|
|
||||||
for (MetaHandlerSettings settings : metaHandlers) {
|
for (MetaHandlerSettings settings : metaHandlers) {
|
||||||
List<Metadata> extraData = null;
|
List<Metadata> extraData = null;
|
||||||
@ -136,7 +126,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nmd == null) {
|
if (nmd == null) {
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
}
|
}
|
||||||
|
|
||||||
newList.add(nmd);
|
newList.add(nmd);
|
||||||
@ -146,12 +136,10 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
|
|||||||
(extraData != null ? extraData : (extraData = new ArrayList<>())).addAll(event.getExtraData());
|
(extraData != null ? extraData : (extraData = new ArrayList<>())).addAll(event.getExtraData());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (Via.getManager().isDebug()) {
|
Logger log = ViaBackwards.getPlatform().getLogger();
|
||||||
Logger log = ViaBackwards.getPlatform().getLogger();
|
log.warning("Unable to handle metadata " + nmd);
|
||||||
log.warning("Unable to handle metadata " + nmd);
|
log.warning("Full metadata list " + storage);
|
||||||
log.warning("Full metadata list " + storage);
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,4 +178,28 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
|
|||||||
protected EntityTracker.ProtocolEntityTracker getEntityTracker(UserConnection user) {
|
protected EntityTracker.ProtocolEntityTracker getEntityTracker(UserConnection user) {
|
||||||
return user.get(EntityTracker.class).get(getProtocol());
|
return user.get(EntityTracker.class).get(getProtocol());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected MetaType getDisplayNameMetaType() {
|
||||||
|
return displayNameMetaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDisplayNameMetaType(MetaType displayNameMetaType) {
|
||||||
|
this.displayNameMetaType = displayNameMetaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getDisplayNameIndex() {
|
||||||
|
return displayNameIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDisplayNameIndex(int displayNameIndex) {
|
||||||
|
this.displayNameIndex = displayNameIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isDisplayNameJson() {
|
||||||
|
return isDisplayNameJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDisplayNameJson(boolean displayNameJson) {
|
||||||
|
isDisplayNameJson = displayNameJson;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ package nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets;
|
|||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_11;
|
|
||||||
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.EntityTypeNames;
|
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.EntityTypeNames;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||||
@ -22,6 +21,7 @@ import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
|
|||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_11Types;
|
||||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
@ -424,8 +424,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
|
|||||||
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
|
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
|
||||||
EntityTracker.ProtocolEntityTracker entTracker = user.get(EntityTracker.class).get(getProtocol());
|
EntityTracker.ProtocolEntityTracker entTracker = user.get(EntityTracker.class).get(getProtocol());
|
||||||
Optional<EntityTracker.StoredEntity> optEntity = entTracker.getEntity(tracker.getEntityId());
|
Optional<EntityTracker.StoredEntity> optEntity = entTracker.getEntity(tracker.getEntityId());
|
||||||
if (optEntity.isPresent() && optEntity.get().getType().is(EntityType1_11.EntityType.LIAMA))
|
return optEntity.isPresent() && optEntity.get().getType().is(Entity1_11Types.EntityType.LIAMA);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,6 @@ package nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets;
|
|||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
|
||||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||||
@ -22,6 +20,9 @@ import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseSto
|
|||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_11Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_12Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
@ -33,9 +34,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static nl.matsv.viabackwards.api.entities.types.EntityType1_11.*;
|
|
||||||
|
|
||||||
|
|
||||||
public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,7 +59,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
getTypeFromId(wrapper.get(Type.BYTE, 0), true)
|
Entity1_11Types.getTypeFromId(wrapper.get(Type.BYTE, 0), true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -69,7 +67,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Optional<ObjectType> type = ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
Optional<Entity1_11Types.ObjectType> type = Entity1_11Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
|
|
||||||
if (type.isPresent()) {
|
if (type.isPresent()) {
|
||||||
Optional<EntityData> optEntDat = getObjectData(type.get());
|
Optional<EntityData> optEntDat = getObjectData(type.get());
|
||||||
@ -91,8 +89,8 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Optional<EntityType1_12.ObjectType> type = EntityType1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
if (type.isPresent() && type.get().equals(EntityType1_12.ObjectType.FALLING_BLOCK)) {
|
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||||
int objectData = wrapper.get(Type.INT, 0);
|
int objectData = wrapper.get(Type.INT, 0);
|
||||||
int objType = objectData & 4095;
|
int objType = objectData & 4095;
|
||||||
int data = objectData >> 12 & 15;
|
int data = objectData >> 12 & 15;
|
||||||
@ -121,7 +119,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
ObjectType.THROWN_EXP_BOTTLE.getType()
|
Entity1_11Types.ObjectType.THROWN_EXP_BOTTLE.getType()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -142,7 +140,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.WEATHER // Always thunder according to wiki.vg
|
Entity1_11Types.EntityType.WEATHER // Always thunder according to wiki.vg
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -174,7 +172,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
getTypeFromId(wrapper.get(Type.UNSIGNED_BYTE, 0), false)
|
Entity1_11Types.getTypeFromId(wrapper.get(Type.UNSIGNED_BYTE, 0), false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -184,7 +182,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
AbstractEntityType type = getEntityType(wrapper.user(), entityId);
|
EntityType type = getEntityType(wrapper.user(), entityId);
|
||||||
|
|
||||||
MetaStorage storage = new MetaStorage(wrapper.get(Types1_9.METADATA_LIST, 0));
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_9.METADATA_LIST, 0));
|
||||||
handleMeta(
|
handleMeta(
|
||||||
@ -225,7 +223,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PAINTING
|
Entity1_11Types.EntityType.PAINTING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -246,7 +244,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.INT, 0),
|
wrapper.get(Type.INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_11Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -298,7 +296,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_11Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -389,39 +387,39 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
// Guardian
|
// Guardian
|
||||||
regEntType(EntityType.ELDER_GUARDIAN, EntityType.GUARDIAN);
|
regEntType(Entity1_11Types.EntityType.ELDER_GUARDIAN, Entity1_11Types.EntityType.GUARDIAN);
|
||||||
// Skeletons
|
// Skeletons
|
||||||
regEntType(EntityType.WITHER_SKELETON, EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
|
regEntType(Entity1_11Types.EntityType.WITHER_SKELETON, Entity1_11Types.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
|
||||||
regEntType(EntityType.STRAY, EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
|
regEntType(Entity1_11Types.EntityType.STRAY, Entity1_11Types.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
|
||||||
// Zombies
|
// Zombies
|
||||||
regEntType(EntityType.HUSK, EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 6));
|
regEntType(Entity1_11Types.EntityType.HUSK, Entity1_11Types.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 6));
|
||||||
regEntType(EntityType.ZOMBIE_VILLAGER, EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1));
|
regEntType(Entity1_11Types.EntityType.ZOMBIE_VILLAGER, Entity1_11Types.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1));
|
||||||
// Horses
|
// Horses
|
||||||
regEntType(EntityType.HORSE, EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent.
|
regEntType(Entity1_11Types.EntityType.HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent.
|
||||||
regEntType(EntityType.DONKEY, EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
regEntType(Entity1_11Types.EntityType.DONKEY, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||||
regEntType(EntityType.MULE, EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2)));
|
regEntType(Entity1_11Types.EntityType.MULE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2)));
|
||||||
regEntType(EntityType.SKELETON_HORSE, EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
|
regEntType(Entity1_11Types.EntityType.SKELETON_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
|
||||||
regEntType(EntityType.ZOMBIE_HORSE, EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
|
regEntType(Entity1_11Types.EntityType.ZOMBIE_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
|
||||||
// New mobs
|
// New mobs
|
||||||
regEntType(EntityType.EVOCATION_FANGS, EntityType.SHULKER);
|
regEntType(Entity1_11Types.EntityType.EVOCATION_FANGS, Entity1_11Types.EntityType.SHULKER);
|
||||||
regEntType(EntityType.EVOCATION_ILLAGER, EntityType.VILLAGER).mobName("Evoker");
|
regEntType(Entity1_11Types.EntityType.EVOCATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).mobName("Evoker");
|
||||||
regEntType(EntityType.VEX, EntityType.BAT).mobName("Vex");
|
regEntType(Entity1_11Types.EntityType.VEX, Entity1_11Types.EntityType.BAT).mobName("Vex");
|
||||||
regEntType(EntityType.VINDICATION_ILLAGER, EntityType.VILLAGER).mobName("Vindicator").spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession
|
regEntType(Entity1_11Types.EntityType.VINDICATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).mobName("Vindicator").spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession
|
||||||
regEntType(EntityType.LIAMA, EntityType.HORSE).mobName("Llama").spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
regEntType(Entity1_11Types.EntityType.LIAMA, Entity1_11Types.EntityType.HORSE).mobName("Llama").spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||||
regEntType(EntityType.LIAMA_SPIT, EntityType.SNOWBALL);
|
regEntType(Entity1_11Types.EntityType.LIAMA_SPIT, Entity1_11Types.EntityType.SNOWBALL);
|
||||||
|
|
||||||
regObjType(ObjectType.LIAMA_SPIT, ObjectType.SNOWBALL, -1);
|
regObjType(Entity1_11Types.ObjectType.LIAMA_SPIT, Entity1_11Types.ObjectType.SNOWBALL, -1);
|
||||||
// Replace with endertorchthingies
|
// Replace with endertorchthingies
|
||||||
regObjType(ObjectType.EVOCATION_FANGS, ObjectType.FALLING_BLOCK, 198 | 1 << 12);
|
regObjType(Entity1_11Types.ObjectType.EVOCATION_FANGS, Entity1_11Types.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
|
||||||
|
|
||||||
// Handle ElderGuardian & target metadata
|
// Handle ElderGuardian & target metadata
|
||||||
registerMetaHandler().filter(EntityType.GUARDIAN, true, 12).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.GUARDIAN, true, 12).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
|
|
||||||
boolean b = (boolean) data.getValue();
|
boolean b = (boolean) data.getValue();
|
||||||
int bitmask = b ? 0x02 : 0;
|
int bitmask = b ? 0x02 : 0;
|
||||||
|
|
||||||
if (e.getEntity().getType().is(EntityType.ELDER_GUARDIAN))
|
if (e.getEntity().getType().is(Entity1_11Types.EntityType.ELDER_GUARDIAN))
|
||||||
bitmask |= 0x04;
|
bitmask |= 0x04;
|
||||||
|
|
||||||
data.setMetaType(MetaType1_9.Byte);
|
data.setMetaType(MetaType1_9.Byte);
|
||||||
@ -431,17 +429,17 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Handle skeleton swing
|
// Handle skeleton swing
|
||||||
registerMetaHandler().filter(EntityType.ABSTRACT_SKELETON, true, 12).handleIndexChange(13);
|
registerMetaHandler().filter(Entity1_11Types.EntityType.ABSTRACT_SKELETON, true, 12).handleIndexChange(13);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ZOMBIE CHANGES
|
ZOMBIE CHANGES
|
||||||
*/
|
*/
|
||||||
registerMetaHandler().filter(EntityType.ZOMBIE, true).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.ZOMBIE, true).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
|
|
||||||
switch (data.getId()) {
|
switch (data.getId()) {
|
||||||
case 13:
|
case 13:
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
case 14:
|
case 14:
|
||||||
data.setId(15);
|
data.setId(15);
|
||||||
break;
|
break;
|
||||||
@ -459,7 +457,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Handle Evocation Illager
|
// Handle Evocation Illager
|
||||||
registerMetaHandler().filter(EntityType.EVOCATION_ILLAGER, 12).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.EVOCATION_ILLAGER, 12).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
data.setId(13);
|
data.setId(13);
|
||||||
data.setMetaType(MetaType1_9.VarInt);
|
data.setMetaType(MetaType1_9.VarInt);
|
||||||
@ -469,14 +467,14 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ):
|
// Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ):
|
||||||
registerMetaHandler().filter(EntityType.VEX, 12).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.VEX, 12).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
data.setValue((byte) 0x00);
|
data.setValue((byte) 0x00);
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle VindicationIllager
|
// Handle VindicationIllager
|
||||||
registerMetaHandler().filter(EntityType.VINDICATION_ILLAGER, 12).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.VINDICATION_ILLAGER, 12).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
data.setId(13);
|
data.setId(13);
|
||||||
data.setMetaType(MetaType1_9.VarInt);
|
data.setMetaType(MetaType1_9.VarInt);
|
||||||
@ -491,7 +489,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Handle horse flags
|
// Handle horse flags
|
||||||
registerMetaHandler().filter(EntityType.ABSTRACT_HORSE, true, 13).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.ABSTRACT_HORSE, true, 13).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
byte b = (byte) data.getValue();
|
byte b = (byte) data.getValue();
|
||||||
if (e.getEntity().has(ChestedHorseStorage.class) &&
|
if (e.getEntity().has(ChestedHorseStorage.class) &&
|
||||||
@ -503,26 +501,26 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Create chested horse storage TODO create on mob spawn?
|
// Create chested horse storage TODO create on mob spawn?
|
||||||
registerMetaHandler().filter(EntityType.CHESTED_HORSE, true).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.CHESTED_HORSE, true).handle(e -> {
|
||||||
if (!e.getEntity().has(ChestedHorseStorage.class))
|
if (!e.getEntity().has(ChestedHorseStorage.class))
|
||||||
e.getEntity().put(new ChestedHorseStorage());
|
e.getEntity().put(new ChestedHorseStorage());
|
||||||
return e.getData();
|
return e.getData();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle horse armor
|
// Handle horse armor
|
||||||
registerMetaHandler().filter(EntityType.HORSE, 16).handleIndexChange(17);
|
registerMetaHandler().filter(Entity1_11Types.EntityType.HORSE, 16).handleIndexChange(17);
|
||||||
|
|
||||||
// Handle chested horse
|
// Handle chested horse
|
||||||
registerMetaHandler().filter(EntityType.CHESTED_HORSE, true, 15).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.CHESTED_HORSE, true, 15).handle(e -> {
|
||||||
ChestedHorseStorage storage = e.getEntity().get(ChestedHorseStorage.class);
|
ChestedHorseStorage storage = e.getEntity().get(ChestedHorseStorage.class);
|
||||||
boolean b = (boolean) e.getData().getValue();
|
boolean b = (boolean) e.getData().getValue();
|
||||||
storage.setChested(b);
|
storage.setChested(b);
|
||||||
|
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get rid of Liama metadata
|
// Get rid of Liama metadata
|
||||||
registerMetaHandler().filter(EntityType.LIAMA).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.LIAMA).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
ChestedHorseStorage storage = e.getEntity().get(ChestedHorseStorage.class);
|
ChestedHorseStorage storage = e.getEntity().get(ChestedHorseStorage.class);
|
||||||
|
|
||||||
@ -531,22 +529,22 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
switch (index) {
|
switch (index) {
|
||||||
case 16:
|
case 16:
|
||||||
storage.setLiamaStrength((int) data.getValue());
|
storage.setLiamaStrength((int) data.getValue());
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
case 17:
|
case 17:
|
||||||
storage.setLiamaCarpetColor((int) data.getValue());
|
storage.setLiamaCarpetColor((int) data.getValue());
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
case 18:
|
case 18:
|
||||||
storage.setLiamaVariant((int) data.getValue());
|
storage.setLiamaVariant((int) data.getValue());
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
}
|
}
|
||||||
return e.getData();
|
return e.getData();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle Horse (Correct owner)
|
// Handle Horse (Correct owner)
|
||||||
registerMetaHandler().filter(EntityType.ABSTRACT_HORSE, true, 14).handleIndexChange(16);
|
registerMetaHandler().filter(Entity1_11Types.EntityType.ABSTRACT_HORSE, true, 14).handleIndexChange(16);
|
||||||
|
|
||||||
// Handle villager - Change non-existing profession
|
// Handle villager - Change non-existing profession
|
||||||
registerMetaHandler().filter(EntityType.VILLAGER, 13).handle(e -> {
|
registerMetaHandler().filter(Entity1_11Types.EntityType.VILLAGER, 13).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
if ((int) data.getValue() == 5)
|
if ((int) data.getValue() == 5)
|
||||||
data.setValue(0);
|
data.setValue(0);
|
||||||
@ -555,7 +553,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// handle new Shulker color meta
|
// handle new Shulker color meta
|
||||||
registerMetaHandler().filter(EntityType.SHULKER, 15).removed();
|
registerMetaHandler().filter(Entity1_11Types.EntityType.SHULKER, 15).removed();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@ package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
|||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
|
||||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||||
@ -23,6 +21,8 @@ import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
|||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_12Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12;
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
@ -35,8 +35,6 @@ import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static nl.matsv.viabackwards.api.entities.types.EntityType1_12.*;
|
|
||||||
|
|
||||||
public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
|
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
|
||||||
@ -61,7 +59,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
getTypeFromId(wrapper.get(Type.BYTE, 0), true)
|
Entity1_12Types.getTypeFromId(wrapper.get(Type.BYTE, 0), true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -69,7 +67,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Optional<EntityType1_12.ObjectType> type = ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
|
|
||||||
if (type.isPresent()) {
|
if (type.isPresent()) {
|
||||||
Optional<EntityData> optEntDat = getObjectData(type.get());
|
Optional<EntityData> optEntDat = getObjectData(type.get());
|
||||||
@ -91,8 +89,8 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Optional<EntityType1_12.ObjectType> type = ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
if (type.isPresent() && type.get().equals(ObjectType.FALLING_BLOCK)) {
|
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||||
int objectData = wrapper.get(Type.INT, 0);
|
int objectData = wrapper.get(Type.INT, 0);
|
||||||
int objType = objectData & 4095;
|
int objType = objectData & 4095;
|
||||||
int data = objectData >> 12 & 15;
|
int data = objectData >> 12 & 15;
|
||||||
@ -121,7 +119,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
ObjectType.THROWN_EXP_BOTTLE.getType()
|
Entity1_12Types.ObjectType.THROWN_EXP_BOTTLE.getType()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -142,7 +140,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.WEATHER // Always thunder according to wiki.vg
|
Entity1_12Types.EntityType.WEATHER // Always thunder according to wiki.vg
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -174,7 +172,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
getTypeFromId(wrapper.get(Type.VAR_INT, 1), false)
|
Entity1_12Types.getTypeFromId(wrapper.get(Type.VAR_INT, 1), false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -185,7 +183,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
AbstractEntityType type = getEntityType(wrapper.user(), entityId);
|
EntityType type = getEntityType(wrapper.user(), entityId);
|
||||||
|
|
||||||
MetaStorage storage = new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0));
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0));
|
||||||
handleMeta(
|
handleMeta(
|
||||||
@ -226,7 +224,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PAINTING
|
Entity1_12Types.EntityType.PAINTING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -253,7 +251,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_12Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -290,7 +288,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.INT, 0),
|
wrapper.get(Type.INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_12Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -387,14 +385,14 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
regEntType(EntityType.PARROT, EntityType.BAT).mobName("Parrot").spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
|
regEntType(Entity1_12Types.EntityType.PARROT, Entity1_12Types.EntityType.BAT).mobName("Parrot").spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
|
||||||
regEntType(EntityType.ILLUSION_ILLAGER, EntityType.EVOCATION_ILLAGER).mobName("Illusioner");
|
regEntType(Entity1_12Types.EntityType.ILLUSION_ILLAGER, Entity1_12Types.EntityType.EVOCATION_ILLAGER).mobName("Illusioner");
|
||||||
|
|
||||||
// Handle Illager
|
// Handle Illager
|
||||||
registerMetaHandler().filter(EntityType.EVOCATION_ILLAGER, true, 12).removed();
|
registerMetaHandler().filter(Entity1_12Types.EntityType.EVOCATION_ILLAGER, true, 12).removed();
|
||||||
registerMetaHandler().filter(EntityType.EVOCATION_ILLAGER, true, 13).handleIndexChange(12);
|
registerMetaHandler().filter(Entity1_12Types.EntityType.EVOCATION_ILLAGER, true, 13).handleIndexChange(12);
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType.ILLUSION_ILLAGER, 0).handle(e -> {
|
registerMetaHandler().filter(Entity1_12Types.EntityType.ILLUSION_ILLAGER, 0).handle(e -> {
|
||||||
byte mask = (byte) e.getData().getValue();
|
byte mask = (byte) e.getData().getValue();
|
||||||
|
|
||||||
if ((mask & 0x20) == 0x20)
|
if ((mask & 0x20) == 0x20)
|
||||||
@ -405,14 +403,14 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Create Parrot storage
|
// Create Parrot storage
|
||||||
registerMetaHandler().filter(EntityType.PARROT, true).handle(e -> {
|
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, true).handle(e -> {
|
||||||
if (!e.getEntity().has(ParrotStorage.class))
|
if (!e.getEntity().has(ParrotStorage.class))
|
||||||
e.getEntity().put(new ParrotStorage());
|
e.getEntity().put(new ParrotStorage());
|
||||||
return e.getData();
|
return e.getData();
|
||||||
});
|
});
|
||||||
// Parrot remove animal metadata
|
// Parrot remove animal metadata
|
||||||
registerMetaHandler().filter(EntityType.PARROT, 12).removed(); // Is baby
|
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, 12).removed(); // Is baby
|
||||||
registerMetaHandler().filter(EntityType.PARROT, 13).handle(e -> {
|
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, 13).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
ParrotStorage storage = e.getEntity().get(ParrotStorage.class);
|
ParrotStorage storage = e.getEntity().get(ParrotStorage.class);
|
||||||
boolean isSitting = (((byte) data.getValue()) & 0x01) == 0x01;
|
boolean isSitting = (((byte) data.getValue()) & 0x01) == 0x01;
|
||||||
@ -433,15 +431,15 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
data.setValue((byte) 0x00);
|
data.setValue((byte) 0x00);
|
||||||
storage.setSitting(false);
|
storage.setSitting(false);
|
||||||
} else
|
} else
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}); // Flags (Is sitting etc, might be useful in the future
|
}); // Flags (Is sitting etc, might be useful in the future
|
||||||
registerMetaHandler().filter(EntityType.PARROT, 14).removed(); // Owner
|
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, 14).removed(); // Owner
|
||||||
registerMetaHandler().filter(EntityType.PARROT, 15).removed(); // Variant
|
registerMetaHandler().filter(Entity1_12Types.EntityType.PARROT, 15).removed(); // Variant
|
||||||
|
|
||||||
// Left shoulder entity data
|
// Left shoulder entity data
|
||||||
registerMetaHandler().filter(EntityType.PLAYER, 15).handle(e -> {
|
registerMetaHandler().filter(Entity1_12Types.EntityType.PLAYER, 15).handle(e -> {
|
||||||
CompoundTag tag = (CompoundTag) e.getData().getValue();
|
CompoundTag tag = (CompoundTag) e.getData().getValue();
|
||||||
ShoulderTracker tracker = e.getUser().get(ShoulderTracker.class);
|
ShoulderTracker tracker = e.getUser().get(ShoulderTracker.class);
|
||||||
|
|
||||||
@ -456,11 +454,11 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Right shoulder entity data
|
// Right shoulder entity data
|
||||||
registerMetaHandler().filter(EntityType.PLAYER, 16).handle(e -> {
|
registerMetaHandler().filter(Entity1_12Types.EntityType.PLAYER, 16).handle(e -> {
|
||||||
CompoundTag tag = (CompoundTag) e.getData().getValue();
|
CompoundTag tag = (CompoundTag) e.getData().getValue();
|
||||||
ShoulderTracker tracker = e.getUser().get(ShoulderTracker.class);
|
ShoulderTracker tracker = e.getUser().get(ShoulderTracker.class);
|
||||||
|
|
||||||
@ -475,7 +473,7 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,12 @@ package nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets;
|
|||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_11Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
@ -27,8 +28,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static nl.matsv.viabackwards.api.entities.types.EntityType1_11.*;
|
|
||||||
|
|
||||||
public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,7 +53,7 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
getTypeFromId(wrapper.get(Type.BYTE, 0), true)
|
Entity1_11Types.getTypeFromId(wrapper.get(Type.BYTE, 0), true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -62,7 +61,7 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Optional<ObjectType> type = ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
Optional<Entity1_11Types.ObjectType> type = Entity1_11Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
|
|
||||||
if (type.isPresent()) {
|
if (type.isPresent()) {
|
||||||
Optional<EntityData> optEntDat = getObjectData(type.get());
|
Optional<EntityData> optEntDat = getObjectData(type.get());
|
||||||
@ -95,7 +94,7 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
ObjectType.THROWN_EXP_BOTTLE.getType()
|
Entity1_11Types.ObjectType.THROWN_EXP_BOTTLE.getType()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -116,7 +115,7 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.WEATHER // Always thunder according to wiki.vg
|
Entity1_11Types.EntityType.WEATHER // Always thunder according to wiki.vg
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -148,7 +147,7 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
getTypeFromId(wrapper.get(Type.VAR_INT, 1), false)
|
Entity1_11Types.getTypeFromId(wrapper.get(Type.VAR_INT, 1), false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -159,7 +158,7 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
AbstractEntityType type = getEntityType(wrapper.user(), entityId);
|
EntityType type = getEntityType(wrapper.user(), entityId);
|
||||||
|
|
||||||
MetaStorage storage = new MetaStorage(wrapper.get(Types1_9.METADATA_LIST, 0));
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_9.METADATA_LIST, 0));
|
||||||
handleMeta(
|
handleMeta(
|
||||||
@ -200,7 +199,7 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PAINTING
|
Entity1_11Types.EntityType.PAINTING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -221,7 +220,7 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.INT, 0),
|
wrapper.get(Type.INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_11Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -273,7 +272,7 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_11Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -340,9 +339,9 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
|
|||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
// Handle non-existing firework metadata (index 7 entity id for boosting)
|
// Handle non-existing firework metadata (index 7 entity id for boosting)
|
||||||
registerMetaHandler().filter(EntityType.FIREWORK, 7).removed();
|
registerMetaHandler().filter(Entity1_11Types.EntityType.FIREWORK, 7).removed();
|
||||||
|
|
||||||
// Handle non-existing pig metadata (index 14 - boost time)
|
// Handle non-existing pig metadata (index 14 - boost time)
|
||||||
registerMetaHandler().filter(EntityType.PIG, 14).removed();
|
registerMetaHandler().filter(Entity1_11Types.EntityType.PIG, 14).removed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import nl.matsv.viabackwards.ViaBackwards;
|
|||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
|
||||||
import us.myles.viaversion.libs.gson.JsonElement;
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
import us.myles.viaversion.libs.gson.JsonObject;
|
import us.myles.viaversion.libs.gson.JsonObject;
|
||||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
@ -41,7 +41,7 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
|||||||
addEntries(entry.getKey(), entry.getValue());
|
addEntries(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
JsonObject mappings = MappingData.loadData("mapping-1.13.json").getAsJsonObject("blocks");
|
JsonObject mappings = MappingDataLoader.loadData("mapping-1.13.json").getAsJsonObject("blocks");
|
||||||
for (Map.Entry<String, JsonElement> blockState : mappings.entrySet()) {
|
for (Map.Entry<String, JsonElement> blockState : mappings.entrySet()) {
|
||||||
String key = blockState.getValue().getAsString();
|
String key = blockState.getValue().getAsString();
|
||||||
if (!key.contains("piston")) continue;
|
if (!key.contains("piston")) continue;
|
||||||
|
@ -12,7 +12,7 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
|||||||
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||||
import us.myles.ViaVersion.util.GsonUtil;
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
import us.myles.viaversion.libs.gson.JsonElement;
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
import us.myles.viaversion.libs.gson.JsonObject;
|
import us.myles.viaversion.libs.gson.JsonObject;
|
||||||
@ -27,9 +27,9 @@ public class BackwardsMappings {
|
|||||||
public static BlockMappings blockMappings;
|
public static BlockMappings blockMappings;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
us.myles.viaversion.libs.gson.JsonObject mapping1_12 = MappingData.loadData("mapping-1.12.json");
|
JsonObject mapping1_12 = MappingDataLoader.loadData("mapping-1.12.json");
|
||||||
us.myles.viaversion.libs.gson.JsonObject mapping1_13 = MappingData.loadData("mapping-1.13.json");
|
JsonObject mapping1_13 = MappingDataLoader.loadData("mapping-1.13.json");
|
||||||
us.myles.viaversion.libs.gson.JsonObject mapping1_12_2to1_13 = loadData("mapping-1.12.2to1.13.json");
|
JsonObject mapping1_12_2to1_13 = loadData("mapping-1.12.2to1.13.json");
|
||||||
|
|
||||||
ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 block mapping...");
|
ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 block mapping...");
|
||||||
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates"));
|
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates"));
|
||||||
|
@ -6,7 +6,7 @@ import us.myles.viaversion.libs.gson.JsonObject;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.loadData;
|
import static us.myles.ViaVersion.api.data.MappingDataLoader.loadData;
|
||||||
|
|
||||||
public class SoundMapping {
|
public class SoundMapping {
|
||||||
private static short[] sounds = new short[662];
|
private static short[] sounds = new short[662];
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||||
@ -45,7 +44,7 @@ import java.util.*;
|
|||||||
public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13> {
|
public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13> {
|
||||||
|
|
||||||
private static String NBT_TAG_NAME;
|
private static String NBT_TAG_NAME;
|
||||||
private static Map<String, String> enchantmentMappings = new HashMap<>();
|
private static final Map<String, String> enchantmentMappings = new HashMap<>();
|
||||||
|
|
||||||
public static int toOldId(int oldId) {
|
public static int toOldId(int oldId) {
|
||||||
if (oldId < 0) {
|
if (oldId < 0) {
|
||||||
|
@ -3,10 +3,6 @@ package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
|||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_13;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_13.EntityType;
|
|
||||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||||
@ -14,6 +10,9 @@ import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.EntityTypeMappin
|
|||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_12Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12;
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12;
|
||||||
@ -52,7 +51,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
byte type = wrapper.get(Type.BYTE, 0);
|
byte type = wrapper.get(Type.BYTE, 0);
|
||||||
EntityType entityType = EntityType1_13.getTypeFromId(type, true);
|
EntityType entityType = Entity1_13Types.getTypeFromId(type, true);
|
||||||
if (entityType == null) {
|
if (entityType == null) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
|
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
|
||||||
return;
|
return;
|
||||||
@ -67,16 +66,16 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Optional<EntityType1_13.ObjectType> optionalType = EntityType1_13.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
Optional<Entity1_13Types.ObjectType> optionalType = Entity1_13Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
if (!optionalType.isPresent()) return;
|
if (!optionalType.isPresent()) return;
|
||||||
|
|
||||||
final EntityType1_13.ObjectType type = optionalType.get();
|
final Entity1_13Types.ObjectType type = optionalType.get();
|
||||||
if (type == EntityType1_13.ObjectType.FALLING_BLOCK) {
|
if (type == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
||||||
int blockState = wrapper.get(Type.INT, 0);
|
int blockState = wrapper.get(Type.INT, 0);
|
||||||
int combined = BlockItemPackets1_13.toOldId(blockState);
|
int combined = BlockItemPackets1_13.toOldId(blockState);
|
||||||
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
||||||
wrapper.set(Type.INT, 0, combined);
|
wrapper.set(Type.INT, 0, combined);
|
||||||
} else if (type == EntityType1_13.ObjectType.ITEM_FRAME) {
|
} else if (type == Entity1_13Types.ObjectType.ITEM_FRAME) {
|
||||||
int data = wrapper.get(Type.INT, 0);
|
int data = wrapper.get(Type.INT, 0);
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case 3:
|
case 3:
|
||||||
@ -90,8 +89,8 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wrapper.set(Type.INT, 0, data);
|
wrapper.set(Type.INT, 0, data);
|
||||||
} else if (type == EntityType1_13.ObjectType.TRIDENT) {
|
} else if (type == Entity1_13Types.ObjectType.TRIDENT) {
|
||||||
wrapper.set(Type.BYTE, 0, (byte) EntityType1_13.ObjectType.TIPPED_ARROW.getId());
|
wrapper.set(Type.BYTE, 0, (byte) Entity1_13Types.ObjectType.TIPPED_ARROW.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -109,7 +108,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.XP_ORB
|
Entity1_13Types.EntityType.XP_ORB
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -128,7 +127,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.LIGHTNING_BOLT
|
Entity1_13Types.EntityType.LIGHTNING_BOLT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -157,7 +156,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int type = wrapper.get(Type.VAR_INT, 1);
|
int type = wrapper.get(Type.VAR_INT, 1);
|
||||||
EntityType entityType = EntityType1_13.getTypeFromId(type, false);
|
EntityType entityType = Entity1_13Types.getTypeFromId(type, false);
|
||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
@ -178,7 +177,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
AbstractEntityType type = getEntityType(wrapper.user(), entityId);
|
EntityType type = getEntityType(wrapper.user(), entityId);
|
||||||
|
|
||||||
MetaStorage storage = new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0));
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0));
|
||||||
handleMeta(
|
handleMeta(
|
||||||
@ -192,7 +191,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
EntityData data = optEntDat.get();
|
EntityData data = optEntDat.get();
|
||||||
|
|
||||||
Optional<Integer> replacementId = EntityTypeMapping.getOldId(data.getReplacementId());
|
Optional<Integer> replacementId = EntityTypeMapping.getOldId(data.getReplacementId());
|
||||||
wrapper.set(Type.VAR_INT, 1, replacementId.orElse(EntityType1_12.EntityType.ZOMBIE.getId()));
|
wrapper.set(Type.VAR_INT, 1, replacementId.orElse(Entity1_12Types.EntityType.ZOMBIE.getId()));
|
||||||
if (data.hasBaseMeta())
|
if (data.hasBaseMeta())
|
||||||
data.getDefaultMeta().handle(storage);
|
data.getDefaultMeta().handle(storage);
|
||||||
}
|
}
|
||||||
@ -228,7 +227,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_13Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -263,7 +262,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PAINTING
|
Entity1_13Types.EntityType.PAINTING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -293,7 +292,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.INT, 0),
|
wrapper.get(Type.INT, 0),
|
||||||
EntityType1_12.EntityType.PLAYER
|
Entity1_12Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -369,25 +368,25 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
// Rewrite new Entity 'drowned'
|
// Rewrite new Entity 'drowned'
|
||||||
regEntType(EntityType.DROWNED, EntityType.ZOMBIE_VILLAGER).mobName("Drowned");
|
regEntType(Entity1_13Types.EntityType.DROWNED, Entity1_13Types.EntityType.ZOMBIE_VILLAGER).mobName("Drowned");
|
||||||
|
|
||||||
// Fishy
|
// Fishy
|
||||||
regEntType(EntityType.COD_MOB, EntityType.SQUID).mobName("Cod");
|
regEntType(Entity1_13Types.EntityType.COD_MOB, Entity1_13Types.EntityType.SQUID).mobName("Cod");
|
||||||
regEntType(EntityType.SALMON_MOB, EntityType.SQUID).mobName("Salmon");
|
regEntType(Entity1_13Types.EntityType.SALMON_MOB, Entity1_13Types.EntityType.SQUID).mobName("Salmon");
|
||||||
regEntType(EntityType.PUFFER_FISH, EntityType.SQUID).mobName("Puffer Fish");
|
regEntType(Entity1_13Types.EntityType.PUFFER_FISH, Entity1_13Types.EntityType.SQUID).mobName("Puffer Fish");
|
||||||
regEntType(EntityType.TROPICAL_FISH, EntityType.SQUID).mobName("Tropical Fish");
|
regEntType(Entity1_13Types.EntityType.TROPICAL_FISH, Entity1_13Types.EntityType.SQUID).mobName("Tropical Fish");
|
||||||
|
|
||||||
// Phantom
|
// Phantom
|
||||||
regEntType(EntityType.PHANTOM, EntityType.PARROT).mobName("Phantom").spawnMetadata(storage -> {
|
regEntType(Entity1_13Types.EntityType.PHANTOM, Entity1_13Types.EntityType.PARROT).mobName("Phantom").spawnMetadata(storage -> {
|
||||||
// The phantom is grey/blue so let's do yellow/blue
|
// The phantom is grey/blue so let's do yellow/blue
|
||||||
storage.add(new Metadata(15, MetaType1_12.VarInt, 3));
|
storage.add(new Metadata(15, MetaType1_12.VarInt, 3));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Dolphin
|
// Dolphin
|
||||||
regEntType(EntityType.DOLPHIN, EntityType.SQUID).mobName("Dolphin");
|
regEntType(Entity1_13Types.EntityType.DOLPHIN, Entity1_13Types.EntityType.SQUID).mobName("Dolphin");
|
||||||
|
|
||||||
// Turtle
|
// Turtle
|
||||||
regEntType(EntityType.TURTLE, EntityType.OCELOT).mobName("Turtle");
|
regEntType(Entity1_13Types.EntityType.TURTLE, Entity1_13Types.EntityType.OCELOT).mobName("Turtle");
|
||||||
|
|
||||||
// Rewrite Meta types
|
// Rewrite Meta types
|
||||||
registerMetaHandler().handle(e -> {
|
registerMetaHandler().handle(e -> {
|
||||||
@ -426,21 +425,17 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Rewrite Custom Name from Chat to String
|
// Rewrite Custom Name from Chat to String
|
||||||
registerMetaHandler().filter(EntityType.ENTITY, true, 2).handle(e -> {
|
registerMetaHandler().filter(Entity1_13Types.EntityType.ENTITY, true, 2).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
|
String value = (String) meta.getValue();
|
||||||
meta.setValue(
|
if (value.isEmpty()) return meta;
|
||||||
ChatRewriter.jsonTextToLegacy(
|
meta.setValue(ChatRewriter.jsonTextToLegacy(value));
|
||||||
(String) meta.getValue()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return meta;
|
return meta;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle zombie metadata
|
// Handle zombie metadata
|
||||||
registerMetaHandler().filter(EntityType.ZOMBIE, true, 15).removed();
|
registerMetaHandler().filter(Entity1_13Types.EntityType.ZOMBIE, true, 15).removed();
|
||||||
registerMetaHandler().filter(EntityType.ZOMBIE, true).handle(e -> {
|
registerMetaHandler().filter(Entity1_13Types.EntityType.ZOMBIE, true).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
|
|
||||||
if (meta.getId() > 15) {
|
if (meta.getId() > 15) {
|
||||||
@ -451,28 +446,28 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Handle turtle metadata (Remove them all for now)
|
// Handle turtle metadata (Remove them all for now)
|
||||||
registerMetaHandler().filter(EntityType.TURTLE, 13).removed(); // Home pos
|
registerMetaHandler().filter(Entity1_13Types.EntityType.TURTLE, 13).removed(); // Home pos
|
||||||
registerMetaHandler().filter(EntityType.TURTLE, 14).removed(); // Has egg
|
registerMetaHandler().filter(Entity1_13Types.EntityType.TURTLE, 14).removed(); // Has egg
|
||||||
registerMetaHandler().filter(EntityType.TURTLE, 15).removed(); // Laying egg
|
registerMetaHandler().filter(Entity1_13Types.EntityType.TURTLE, 15).removed(); // Laying egg
|
||||||
registerMetaHandler().filter(EntityType.TURTLE, 16).removed(); // Travel pos
|
registerMetaHandler().filter(Entity1_13Types.EntityType.TURTLE, 16).removed(); // Travel pos
|
||||||
registerMetaHandler().filter(EntityType.TURTLE, 17).removed(); // Going home
|
registerMetaHandler().filter(Entity1_13Types.EntityType.TURTLE, 17).removed(); // Going home
|
||||||
registerMetaHandler().filter(EntityType.TURTLE, 18).removed(); // Traveling
|
registerMetaHandler().filter(Entity1_13Types.EntityType.TURTLE, 18).removed(); // Traveling
|
||||||
|
|
||||||
// Remove additional fish meta
|
// Remove additional fish meta
|
||||||
registerMetaHandler().filter(EntityType.ABSTRACT_FISHES, true, 12).removed();
|
registerMetaHandler().filter(Entity1_13Types.EntityType.ABSTRACT_FISHES, true, 12).removed();
|
||||||
registerMetaHandler().filter(EntityType.ABSTRACT_FISHES, true, 13).removed();
|
registerMetaHandler().filter(Entity1_13Types.EntityType.ABSTRACT_FISHES, true, 13).removed();
|
||||||
|
|
||||||
// Remove phantom size
|
// Remove phantom size
|
||||||
registerMetaHandler().filter(EntityType.PHANTOM, 12).removed();
|
registerMetaHandler().filter(Entity1_13Types.EntityType.PHANTOM, 12).removed();
|
||||||
|
|
||||||
// Remove boat splash timer
|
// Remove boat splash timer
|
||||||
registerMetaHandler().filter(EntityType.BOAT, 12).removed();
|
registerMetaHandler().filter(Entity1_13Types.EntityType.BOAT, 12).removed();
|
||||||
|
|
||||||
// Remove Trident special loyalty level
|
// Remove Trident special loyalty level
|
||||||
registerMetaHandler().filter(EntityType.TRIDENT, 7).removed();
|
registerMetaHandler().filter(Entity1_13Types.EntityType.TRIDENT, 7).removed();
|
||||||
|
|
||||||
// Handle new wolf colors
|
// Handle new wolf colors
|
||||||
registerMetaHandler().filter(EntityType.WOLF, 17).handle(e -> {
|
registerMetaHandler().filter(Entity1_13Types.EntityType.WOLF, 17).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
|
|
||||||
meta.setValue(15 - (int) meta.getValue());
|
meta.setValue(15 - (int) meta.getValue());
|
||||||
@ -481,7 +476,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Rewrite AreaEffectCloud
|
// Rewrite AreaEffectCloud
|
||||||
registerMetaHandler().filter(EntityType.AREA_EFFECT_CLOUD, 9).handle(e -> {
|
registerMetaHandler().filter(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD, 9).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
Particle particle = (Particle) meta.getValue();
|
Particle particle = (Particle) meta.getValue();
|
||||||
|
|
||||||
@ -490,7 +485,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
|||||||
e.createMeta(new Metadata(10, MetaType1_12.VarInt, 0)); //TODO particle data
|
e.createMeta(new Metadata(10, MetaType1_12.VarInt, 0)); //TODO particle data
|
||||||
e.createMeta(new Metadata(11, MetaType1_12.VarInt, 0)); //TODO particle data
|
e.createMeta(new Metadata(11, MetaType1_12.VarInt, 0)); //TODO particle data
|
||||||
|
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO REWRITE BLOCKS IN MINECART
|
// TODO REWRITE BLOCKS IN MINECART
|
||||||
|
@ -2,7 +2,7 @@ package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
|
|||||||
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||||
import us.myles.ViaVersion.util.GsonUtil;
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
import us.myles.viaversion.libs.gson.JsonElement;
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
import us.myles.viaversion.libs.gson.JsonObject;
|
import us.myles.viaversion.libs.gson.JsonObject;
|
||||||
@ -18,8 +18,8 @@ public class BackwardsMappings {
|
|||||||
public static BlockMappings blockMappings;
|
public static BlockMappings blockMappings;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
JsonObject mapping1_13_2 = MappingData.loadData("mapping-1.13.2.json");
|
JsonObject mapping1_13_2 = MappingDataLoader.loadData("mapping-1.13.2.json");
|
||||||
JsonObject mapping1_14 = MappingData.loadData("mapping-1.14.json");
|
JsonObject mapping1_14 = MappingDataLoader.loadData("mapping-1.14.json");
|
||||||
JsonObject mapping1_13_2to1_14 = loadData("mapping-1.13.2to1.14.json");
|
JsonObject mapping1_13_2to1_14 = loadData("mapping-1.13.2to1.14.json");
|
||||||
|
|
||||||
ViaBackwards.getPlatform().getLogger().info("Loading 1.14 -> 1.13.2 block mapping...");
|
ViaBackwards.getPlatform().getLogger().info("Loading 1.14 -> 1.13.2 block mapping...");
|
||||||
|
@ -9,8 +9,8 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class EntityTypeMapping {
|
public class EntityTypeMapping {
|
||||||
private static Map<Integer, Integer> entityTypes = new HashMap<>();
|
private static final Map<Integer, Integer> entityTypes = new HashMap<>();
|
||||||
private static Map<Integer, Integer> oldEntityToOldObject = new HashMap<>();
|
private static final Map<Integer, Integer> oldEntityToOldObject = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
@ -23,8 +23,8 @@ public class EntityTypeMapping {
|
|||||||
}
|
}
|
||||||
for (Map.Entry<Integer, Integer> newToOld : entityTypes.entrySet()) {
|
for (Map.Entry<Integer, Integer> newToOld : entityTypes.entrySet()) {
|
||||||
Entity1_13Types.EntityType type1_13 = Entity1_13Types.getTypeFromId(newToOld.getValue(), false);
|
Entity1_13Types.EntityType type1_13 = Entity1_13Types.getTypeFromId(newToOld.getValue(), false);
|
||||||
Entity1_13Types.ObjectTypes object1_13 = null;
|
Entity1_13Types.ObjectType object1_13 = null;
|
||||||
for (Entity1_13Types.ObjectTypes objectType : Entity1_13Types.ObjectTypes.values()) {
|
for (Entity1_13Types.ObjectType objectType : Entity1_13Types.ObjectType.values()) {
|
||||||
if (objectType.getType() == type1_13) {
|
if (objectType.getType() == type1_13) {
|
||||||
object1_13 = objectType;
|
object1_13 = objectType;
|
||||||
break;
|
break;
|
||||||
@ -34,8 +34,8 @@ public class EntityTypeMapping {
|
|||||||
oldEntityToOldObject.put(type1_13.getId(), object1_13.getId());
|
oldEntityToOldObject.put(type1_13.getId(), object1_13.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(Entity1_13Types.EntityType type : Entity1_13Types.EntityType.values()){
|
for (Entity1_13Types.EntityType type : Entity1_13Types.EntityType.values()) {
|
||||||
if(!entityTypes.containsValue(type.getId())){
|
if (!entityTypes.containsValue(type.getId())) {
|
||||||
entityTypes.put(type.getId(), type.getId());
|
entityTypes.put(type.getId(), type.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@ import us.myles.viaversion.libs.gson.JsonObject;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.loadData;
|
import static us.myles.ViaVersion.api.data.MappingDataLoader.loadData;
|
||||||
|
|
||||||
public class SoundMapping {
|
public class SoundMapping {
|
||||||
private static short[] sounds = new short[795];
|
private static final short[] sounds = new short[795];
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
JsonObject mapping1_13_2 = loadData("mapping-1.13.2.json");
|
JsonObject mapping1_13_2 = loadData("mapping-1.13.2.json");
|
||||||
|
@ -3,14 +3,14 @@ package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_14;
|
|
||||||
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_14Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||||
import us.myles.ViaVersion.api.minecraft.Environment;
|
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||||
@ -261,10 +261,10 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
AbstractEntityType entityType = wrapper.user().get(EntityTracker.class).get(getProtocol()).getEntityType(entityId);
|
EntityType entityType = wrapper.user().get(EntityTracker.class).get(getProtocol()).getEntityType(entityId);
|
||||||
if (entityType == null) return; // TODO: Check why there might (?) be an untracked entity
|
if (entityType == null) return; // TODO: Check why there might (?) be an untracked entity
|
||||||
|
|
||||||
if (entityType.isOrHasParent(EntityType1_14.EntityType.ABSTRACT_HORSE)) {
|
if (entityType.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_HORSE)) {
|
||||||
wrapper.setId(0x3F);
|
wrapper.setId(0x3F);
|
||||||
wrapper.resetReader();
|
wrapper.resetReader();
|
||||||
wrapper.passthrough(Type.VAR_INT);
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
|
@ -4,15 +4,15 @@ import nl.matsv.viabackwards.ViaBackwards;
|
|||||||
import nl.matsv.viabackwards.api.entities.meta.MetaHandler;
|
import nl.matsv.viabackwards.api.entities.meta.MetaHandler;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_13;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_14;
|
|
||||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.EntityTypeMapping;
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.EntityTypeMapping;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
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.Position;
|
||||||
import us.myles.ViaVersion.api.minecraft.VillagerData;
|
import us.myles.ViaVersion.api.minecraft.VillagerData;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
@ -51,7 +51,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
byte type = wrapper.get(Type.BYTE, 0);
|
byte type = wrapper.get(Type.BYTE, 0);
|
||||||
EntityType1_14.EntityType entityType = EntityType1_14.getTypeFromId(type);
|
Entity1_14Types.EntityType entityType = Entity1_14Types.getTypeFromId(type);
|
||||||
if (entityType == null) {
|
if (entityType == null) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.14 entity type " + type);
|
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.14 entity type " + type);
|
||||||
return;
|
return;
|
||||||
@ -67,10 +67,10 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int id = wrapper.get(Type.BYTE, 0);
|
int id = wrapper.get(Type.BYTE, 0);
|
||||||
EntityType1_13.EntityType entityType = EntityType1_13.getTypeFromId(EntityTypeMapping.getOldId(id).orElse(id), false);
|
Entity1_13Types.EntityType entityType = Entity1_13Types.getTypeFromId(EntityTypeMapping.getOldId(id).orElse(id), false);
|
||||||
Optional<EntityType1_13.ObjectType> type;
|
Optional<Entity1_13Types.ObjectType> type;
|
||||||
if (entityType.isOrHasParent(EntityType1_13.EntityType.MINECART_ABSTRACT)) {
|
if (entityType.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT)) {
|
||||||
type = Optional.of(EntityType1_13.ObjectType.MINECART);
|
type = Optional.of(Entity1_13Types.ObjectType.MINECART);
|
||||||
int data = 0;
|
int data = 0;
|
||||||
switch (entityType) {
|
switch (entityType) {
|
||||||
case CHEST_MINECART:
|
case CHEST_MINECART:
|
||||||
@ -95,18 +95,18 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
if (data != 0)
|
if (data != 0)
|
||||||
wrapper.set(Type.INT, 0, data);
|
wrapper.set(Type.INT, 0, data);
|
||||||
} else {
|
} else {
|
||||||
type = EntityType1_13.ObjectType.fromEntityType(entityType);
|
type = Entity1_13Types.ObjectType.fromEntityType(entityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.isPresent()) {
|
if (type.isPresent()) {
|
||||||
wrapper.set(Type.BYTE, 0, (byte) type.get().getId());
|
wrapper.set(Type.BYTE, 0, (byte) type.get().getId());
|
||||||
}
|
}
|
||||||
if (type.isPresent() && type.get() == EntityType1_13.ObjectType.FALLING_BLOCK) {
|
if (type.isPresent() && type.get() == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
||||||
int blockState = wrapper.get(Type.INT, 0);
|
int blockState = wrapper.get(Type.INT, 0);
|
||||||
int combined = BlockItemPackets1_13.toOldId(blockState);
|
int combined = BlockItemPackets1_13.toOldId(blockState);
|
||||||
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
||||||
wrapper.set(Type.INT, 0, combined);
|
wrapper.set(Type.INT, 0, combined);
|
||||||
} else if (type.isPresent() && type.get() == EntityType1_13.ObjectType.ITEM_FRAME) {
|
} else if (type.isPresent() && type.get() == Entity1_13Types.ObjectType.ITEM_FRAME) {
|
||||||
int data = wrapper.get(Type.INT, 0);
|
int data = wrapper.get(Type.INT, 0);
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case 3:
|
case 3:
|
||||||
@ -148,7 +148,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int type = wrapper.get(Type.VAR_INT, 1);
|
int type = wrapper.get(Type.VAR_INT, 1);
|
||||||
EntityType1_14.EntityType entityType = EntityType1_14.getTypeFromId(type);
|
Entity1_14Types.EntityType entityType = Entity1_14Types.getTypeFromId(type);
|
||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
@ -174,12 +174,12 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
AbstractEntityType type = getEntityType(wrapper.user(), entityId);
|
EntityType type = getEntityType(wrapper.user(), entityId);
|
||||||
|
|
||||||
MetaStorage storage = new MetaStorage(wrapper.get(Types1_13_2.METADATA_LIST, 0));
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_13_2.METADATA_LIST, 0));
|
||||||
handleMeta(
|
handleMeta(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
entityId,
|
||||||
storage
|
storage
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
EntityData data = optEntDat.get();
|
EntityData data = optEntDat.get();
|
||||||
|
|
||||||
Optional<Integer> replacementId = EntityTypeMapping.getOldId(data.getReplacementId());
|
Optional<Integer> replacementId = EntityTypeMapping.getOldId(data.getReplacementId());
|
||||||
wrapper.set(Type.VAR_INT, 1, replacementId.orElse(EntityType1_13.EntityType.ZOMBIE.getId()));
|
wrapper.set(Type.VAR_INT, 1, replacementId.orElse(Entity1_13Types.EntityType.ZOMBIE.getId()));
|
||||||
if (data.hasBaseMeta())
|
if (data.hasBaseMeta())
|
||||||
data.getDefaultMeta().handle(storage);
|
data.getDefaultMeta().handle(storage);
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType1_14.EntityType.XP_ORB
|
Entity1_14Types.EntityType.XP_ORB
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -241,7 +241,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType1_14.EntityType.PAINTING
|
Entity1_14Types.EntityType.PAINTING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -266,7 +266,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
|
||||||
EntityType1_14.EntityType entType = EntityType1_14.EntityType.PLAYER;
|
Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER;
|
||||||
// Register Type ID
|
// Register Type ID
|
||||||
addTrackedEntity(wrapper.user(), entityId, entType);
|
addTrackedEntity(wrapper.user(), entityId, entType);
|
||||||
wrapper.set(Types1_13_2.METADATA_LIST, 0,
|
wrapper.set(Types1_13_2.METADATA_LIST, 0,
|
||||||
@ -339,7 +339,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
int entityId = wrapper.get(Type.INT, 0);
|
int entityId = wrapper.get(Type.INT, 0);
|
||||||
|
|
||||||
// Register Type ID
|
// Register Type ID
|
||||||
addTrackedEntity(wrapper.user(), entityId, EntityType1_14.EntityType.PLAYER);
|
addTrackedEntity(wrapper.user(), entityId, Entity1_14Types.EntityType.PLAYER);
|
||||||
|
|
||||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
|
wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||||
|
|
||||||
@ -357,13 +357,13 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
setDisplayNameJson(true);
|
setDisplayNameJson(true);
|
||||||
setDisplayNameMetaType(MetaType1_13_2.OptChat);
|
setDisplayNameMetaType(MetaType1_13_2.OptChat);
|
||||||
|
|
||||||
regEntType(EntityType1_14.EntityType.CAT, EntityType1_14.EntityType.OCELOT).mobName("Cat");
|
regEntType(Entity1_14Types.EntityType.CAT, Entity1_14Types.EntityType.OCELOT).mobName("Cat");
|
||||||
regEntType(EntityType1_14.EntityType.TRADER_LLAMA, EntityType1_14.EntityType.LLAMA).mobName("Trader Llama");
|
regEntType(Entity1_14Types.EntityType.TRADER_LLAMA, Entity1_14Types.EntityType.LLAMA).mobName("Trader Llama");
|
||||||
regEntType(EntityType1_14.EntityType.FOX, EntityType1_14.EntityType.WOLF).mobName("Fox");
|
regEntType(Entity1_14Types.EntityType.FOX, Entity1_14Types.EntityType.WOLF).mobName("Fox");
|
||||||
regEntType(EntityType1_14.EntityType.PANDA, EntityType1_14.EntityType.POLAR_BEAR).mobName("Panda");
|
regEntType(Entity1_14Types.EntityType.PANDA, Entity1_14Types.EntityType.POLAR_BEAR).mobName("Panda");
|
||||||
regEntType(EntityType1_14.EntityType.PILLAGER, EntityType1_14.EntityType.VILLAGER).mobName("Pillager");
|
regEntType(Entity1_14Types.EntityType.PILLAGER, Entity1_14Types.EntityType.VILLAGER).mobName("Pillager");
|
||||||
regEntType(EntityType1_14.EntityType.WANDERING_TRADER, EntityType1_14.EntityType.VILLAGER).mobName("Wandering Trader");
|
regEntType(Entity1_14Types.EntityType.WANDERING_TRADER, Entity1_14Types.EntityType.VILLAGER).mobName("Wandering Trader");
|
||||||
regEntType(EntityType1_14.EntityType.RAVAGER, EntityType1_14.EntityType.COW).mobName("Ravager");
|
regEntType(Entity1_14Types.EntityType.RAVAGER, Entity1_14Types.EntityType.COW).mobName("Ravager");
|
||||||
|
|
||||||
registerMetaHandler().handle(e -> {
|
registerMetaHandler().handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
@ -385,32 +385,32 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
return meta;
|
return meta;
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.PILLAGER, 15).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.PILLAGER, 15).removed();
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 15).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.FOX, 15).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 16).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.FOX, 16).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 17).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.FOX, 17).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 18).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.FOX, 18).removed();
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 15).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.PANDA, 15).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 16).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.PANDA, 16).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 17).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.PANDA, 17).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 18).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.PANDA, 18).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 19).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.PANDA, 19).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 20).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.PANDA, 20).removed();
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 18).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.CAT, 18).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 19).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.CAT, 19).removed();
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 20).removed();
|
registerMetaHandler().filter(Entity1_14Types.EntityType.CAT, 20).removed();
|
||||||
|
|
||||||
registerMetaHandler().handle(e -> {
|
registerMetaHandler().handle(e -> {
|
||||||
AbstractEntityType type = e.getEntity().getType();
|
EntityType type = e.getEntity().getType();
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
if (type.isOrHasParent(EntityType1_14.EntityType.ABSTRACT_ILLAGER_BASE) || type == EntityType1_14.EntityType.RAVAGER || type == EntityType1_14.EntityType.WITCH) {
|
if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_ILLAGER_BASE) || type == Entity1_14Types.EntityType.RAVAGER || type == Entity1_14Types.EntityType.WITCH) {
|
||||||
int index = e.getIndex();
|
int index = e.getIndex();
|
||||||
if (index == 14) {
|
if (index == 14) {
|
||||||
//TODO handle
|
//TODO handle
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
} else if (index > 14) {
|
} else if (index > 14) {
|
||||||
meta.setId(index - 1);
|
meta.setId(index - 1);
|
||||||
}
|
}
|
||||||
@ -418,14 +418,14 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
return meta;
|
return meta;
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.AREA_EFFECT_CLOUD, 10).handle(e -> {
|
registerMetaHandler().filter(Entity1_14Types.EntityType.AREA_EFFECT_CLOUD, 10).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
Particle particle = (Particle) meta.getValue();
|
Particle particle = (Particle) meta.getValue();
|
||||||
particle.setId(getOldParticleId(particle.getId()));
|
particle.setId(getOldParticleId(particle.getId()));
|
||||||
return meta;
|
return meta;
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.FIREWORKS_ROCKET, 8).handle(e -> {
|
registerMetaHandler().filter(Entity1_14Types.EntityType.FIREWORKS_ROCKET, 8).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
meta.setMetaType(MetaType1_13_2.VarInt);
|
meta.setMetaType(MetaType1_13_2.VarInt);
|
||||||
Integer value = (Integer) meta.getValue();
|
Integer value = (Integer) meta.getValue();
|
||||||
@ -433,18 +433,18 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
return meta;
|
return meta;
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.ABSTRACT_ARROW, true).handle(e -> {
|
registerMetaHandler().filter(Entity1_14Types.EntityType.ABSTRACT_ARROW, true).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
int index = e.getIndex();
|
int index = e.getIndex();
|
||||||
if (index == 9) {
|
if (index == 9) {
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
} else if (index > 9) {
|
} else if (index > 9) {
|
||||||
meta.setId(index - 1);
|
meta.setId(index - 1);
|
||||||
}
|
}
|
||||||
return meta;
|
return meta;
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.VILLAGER, 15).removed(); // Head shake timer
|
registerMetaHandler().filter(Entity1_14Types.EntityType.VILLAGER, 15).removed(); // Head shake timer
|
||||||
|
|
||||||
MetaHandler villagerDataHandler = e -> {
|
MetaHandler villagerDataHandler = e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
@ -457,10 +457,10 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
return meta;
|
return meta;
|
||||||
};
|
};
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.ZOMBIE_VILLAGER, 18).handle(villagerDataHandler);
|
registerMetaHandler().filter(Entity1_14Types.EntityType.ZOMBIE_VILLAGER, 18).handle(villagerDataHandler);
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.VILLAGER, 16).handle(villagerDataHandler);
|
registerMetaHandler().filter(Entity1_14Types.EntityType.VILLAGER, 16).handle(villagerDataHandler);
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.ZOMBIE, true).handle(e -> {
|
registerMetaHandler().filter(Entity1_14Types.EntityType.ZOMBIE, true).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
int index = e.getIndex();
|
int index = e.getIndex();
|
||||||
if (index >= 16) {
|
if (index >= 16) {
|
||||||
@ -470,7 +470,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Remove bed location
|
// Remove bed location
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.LIVINGENTITY, true).handle(e -> {
|
registerMetaHandler().filter(Entity1_14Types.EntityType.LIVINGENTITY, true).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
int index = e.getIndex();
|
int index = e.getIndex();
|
||||||
if (index == 12) {
|
if (index == 12) {
|
||||||
@ -496,7 +496,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
} else if (index > 12) {
|
} else if (index > 12) {
|
||||||
meta.setId(index - 1);
|
meta.setId(index - 1);
|
||||||
}
|
}
|
||||||
@ -507,7 +507,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
int index = e.getIndex();
|
int index = e.getIndex();
|
||||||
if (index == 6) {
|
if (index == 6) {
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
} else if (index > 6) {
|
} else if (index > 6) {
|
||||||
meta.setId(index - 1);
|
meta.setId(index - 1);
|
||||||
}
|
}
|
||||||
@ -524,7 +524,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
return meta;
|
return meta;
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.OCELOT, 13).handle(e -> {
|
registerMetaHandler().filter(Entity1_14Types.EntityType.OCELOT, 13).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
meta.setId(15);
|
meta.setId(15);
|
||||||
meta.setMetaType(MetaType1_13_2.VarInt);
|
meta.setMetaType(MetaType1_13_2.VarInt);
|
||||||
@ -532,7 +532,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
|||||||
return meta;
|
return meta;
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMetaHandler().filter(EntityType1_14.EntityType.CAT).handle(e -> {
|
registerMetaHandler().filter(Entity1_14Types.EntityType.CAT).handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
if (meta.getId() == 15) {
|
if (meta.getId() == 15) {
|
||||||
meta.setValue(1);
|
meta.setValue(1);
|
||||||
|
@ -2,12 +2,11 @@ package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
|||||||
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_13;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_13.EntityType;
|
|
||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_12Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||||
@ -42,14 +41,14 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
|||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
byte type = wrapper.get(Type.BYTE, 0);
|
byte type = wrapper.get(Type.BYTE, 0);
|
||||||
EntityType entType = EntityType1_13.getTypeFromId(type, true);
|
Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true);
|
||||||
if (entType == null) {
|
if (entType == null) {
|
||||||
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
|
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rewrite falling block
|
// Rewrite falling block
|
||||||
if (entType.is(EntityType.FALLING_BLOCK)) {
|
if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) {
|
||||||
int data = wrapper.get(Type.INT, 0);
|
int data = wrapper.get(Type.INT, 0);
|
||||||
wrapper.set(Type.INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
wrapper.set(Type.INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||||
}
|
}
|
||||||
@ -76,7 +75,7 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.XP_ORB
|
Entity1_13Types.EntityType.XP_ORB
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -96,7 +95,7 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.LIGHTNING_BOLT
|
Entity1_13Types.EntityType.LIGHTNING_BOLT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -127,7 +126,7 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
|||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int type = wrapper.get(Type.VAR_INT, 1);
|
int type = wrapper.get(Type.VAR_INT, 1);
|
||||||
|
|
||||||
EntityType entityType = EntityType1_13.getTypeFromId(type, false);
|
Entity1_13Types.EntityType entityType = Entity1_13Types.getTypeFromId(type, false);
|
||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
@ -180,7 +179,7 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_13Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -215,7 +214,7 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PAINTING
|
Entity1_13Types.EntityType.PAINTING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -237,7 +236,7 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.INT, 0),
|
wrapper.get(Type.INT, 0),
|
||||||
EntityType1_12.EntityType.PLAYER
|
Entity1_12Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -334,20 +333,20 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
|||||||
|
|
||||||
// Remove shooter UUID
|
// Remove shooter UUID
|
||||||
registerMetaHandler().
|
registerMetaHandler().
|
||||||
filter(EntityType.ABSTRACT_ARROW, true, 7)
|
filter(Entity1_13Types.EntityType.ABSTRACT_ARROW, true, 7)
|
||||||
.removed();
|
.removed();
|
||||||
|
|
||||||
// Move colors to old position
|
// Move colors to old position
|
||||||
registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8)
|
registerMetaHandler().filter(Entity1_13Types.EntityType.SPECTRAL_ARROW, 8)
|
||||||
.handleIndexChange(7);
|
.handleIndexChange(7);
|
||||||
|
|
||||||
// Move loyalty level to old position
|
// Move loyalty level to old position
|
||||||
registerMetaHandler().filter(EntityType.TRIDENT, 8)
|
registerMetaHandler().filter(Entity1_13Types.EntityType.TRIDENT, 8)
|
||||||
.handleIndexChange(7);
|
.handleIndexChange(7);
|
||||||
|
|
||||||
// Rewrite Minecart blocks
|
// Rewrite Minecart blocks
|
||||||
registerMetaHandler()
|
registerMetaHandler()
|
||||||
.filter(EntityType.MINECART_ABSTRACT, true, 9)
|
.filter(Entity1_13Types.EntityType.MINECART_ABSTRACT, true, 9)
|
||||||
.handle(e -> {
|
.handle(e -> {
|
||||||
Metadata meta = e.getData();
|
Metadata meta = e.getData();
|
||||||
|
|
||||||
|
@ -13,16 +13,16 @@ package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets;
|
|||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_10;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_11;
|
|
||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
|
||||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_10Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_11Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_12Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.EntityType;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
@ -34,8 +34,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static nl.matsv.viabackwards.api.entities.types.EntityType1_10.EntityType;
|
import static us.myles.ViaVersion.api.entities.Entity1_11Types.getTypeFromId;
|
||||||
import static nl.matsv.viabackwards.api.entities.types.EntityType1_11.getTypeFromId;
|
|
||||||
|
|
||||||
public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
||||||
|
|
||||||
@ -71,7 +70,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Optional<EntityType1_11.ObjectType> type = EntityType1_11.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
Optional<Entity1_11Types.ObjectType> type = Entity1_11Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
|
|
||||||
if (type.isPresent()) {
|
if (type.isPresent()) {
|
||||||
Optional<EntityData> optEntDat = getObjectData(type.get());
|
Optional<EntityData> optEntDat = getObjectData(type.get());
|
||||||
@ -93,8 +92,8 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
Optional<EntityType1_12.ObjectType> type = EntityType1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
if (type.isPresent() && type.get().equals(EntityType1_12.ObjectType.FALLING_BLOCK)) {
|
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||||
int objectData = wrapper.get(Type.INT, 0);
|
int objectData = wrapper.get(Type.INT, 0);
|
||||||
int objType = objectData & 4095;
|
int objType = objectData & 4095;
|
||||||
int data = objectData >> 12 & 15;
|
int data = objectData >> 12 & 15;
|
||||||
@ -102,7 +101,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
Block block = getProtocol().getBlockItemPackets().handleBlock(objType, data);
|
Block block = getProtocol().getBlockItemPackets().handleBlock(objType, data);
|
||||||
if (block == null)
|
if (block == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +122,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType1_10.ObjectType.THROWN_EXP_BOTTLE.getType()
|
Entity1_10Types.ObjectType.THROWN_EXP_BOTTLE.getType()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -144,7 +143,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.WEATHER // Always thunder according to wiki.vg
|
Entity1_10Types.EntityType.WEATHER // Always thunder according to wiki.vg
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -176,7 +175,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType1_10.getTypeFromId(wrapper.get(Type.UNSIGNED_BYTE, 0), false)
|
Entity1_10Types.getTypeFromId(wrapper.get(Type.UNSIGNED_BYTE, 0), false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -186,7 +185,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
AbstractEntityType type = getEntityType(wrapper.user(), entityId);
|
EntityType type = getEntityType(wrapper.user(), entityId);
|
||||||
|
|
||||||
MetaStorage storage = new MetaStorage(wrapper.get(Types1_9.METADATA_LIST, 0));
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_9.METADATA_LIST, 0));
|
||||||
handleMeta(
|
handleMeta(
|
||||||
@ -228,7 +227,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PAINTING
|
Entity1_10Types.EntityType.PAINTING
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -249,7 +248,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.INT, 0),
|
wrapper.get(Type.INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_10Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -301,7 +300,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
addTrackedEntity(
|
addTrackedEntity(
|
||||||
wrapper.user(),
|
wrapper.user(),
|
||||||
wrapper.get(Type.VAR_INT, 0),
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
EntityType.PLAYER
|
Entity1_10Types.EntityType.PLAYER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -367,10 +366,10 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
regEntType(EntityType.POLAR_BEAR, EntityType.SHEEP).mobName("Polar Bear");
|
regEntType(Entity1_10Types.EntityType.POLAR_BEAR, Entity1_10Types.EntityType.SHEEP).mobName("Polar Bear");
|
||||||
|
|
||||||
// Change the sheep color when the polar bear is standing up (index 13 -> Standing up)
|
// Change the sheep color when the polar bear is standing up (index 13 -> Standing up)
|
||||||
registerMetaHandler().filter(EntityType.POLAR_BEAR, 13).handle((e -> {
|
registerMetaHandler().filter(Entity1_10Types.EntityType.POLAR_BEAR, 13).handle((e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
boolean b = (boolean) data.getValue();
|
boolean b = (boolean) data.getValue();
|
||||||
|
|
||||||
@ -382,7 +381,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
|
|
||||||
|
|
||||||
// Handle husk (index 13 -> Zombie Type)
|
// Handle husk (index 13 -> Zombie Type)
|
||||||
registerMetaHandler().filter(EntityType.ZOMBIE, 13).handle(e -> {
|
registerMetaHandler().filter(Entity1_10Types.EntityType.ZOMBIE, 13).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
|
|
||||||
if ((int) data.getValue() == 6) // Is type Husk
|
if ((int) data.getValue() == 6) // Is type Husk
|
||||||
@ -392,7 +391,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Handle Stray (index 12 -> Skeleton Type)
|
// Handle Stray (index 12 -> Skeleton Type)
|
||||||
registerMetaHandler().filter(EntityType.SKELETON, 12).handle(e -> {
|
registerMetaHandler().filter(Entity1_10Types.EntityType.SKELETON, 12).handle(e -> {
|
||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
|
|
||||||
if ((int) data.getValue() == 2)
|
if ((int) data.getValue() == 2)
|
||||||
@ -406,7 +405,7 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
|
|||||||
Metadata data = e.getData();
|
Metadata data = e.getData();
|
||||||
|
|
||||||
if (data.getId() == 5)
|
if (data.getId() == 5)
|
||||||
throw new RemovedValueException();
|
throw RemovedValueException.EX;
|
||||||
else if (data.getId() >= 5)
|
else if (data.getId() >= 5)
|
||||||
data.setId(data.getId() - 1);
|
data.setId(data.getId() - 1);
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -61,7 +61,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.myles</groupId>
|
<groupId>us.myles</groupId>
|
||||||
<artifactId>viaversion</artifactId>
|
<artifactId>viaversion</artifactId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.4-19w38b</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren