Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 08:30:10 +01:00
Bump viaversion & handle metadata changes
Dieser Commit ist enthalten in:
Ursprung
cb93950785
Commit
d98a511757
@ -15,11 +15,9 @@ import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
|||||||
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 nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
||||||
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 us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ -47,13 +45,14 @@ public interface ViaBackwardsPlatform {
|
|||||||
|
|
||||||
// TODO remove or better implement on full release
|
// TODO remove or better implement on full release
|
||||||
default boolean isOutdated() {
|
default boolean isOutdated() {
|
||||||
Method m = null;
|
Class<?> clazz = null;
|
||||||
try {
|
try {
|
||||||
m = ChunkSection.class.getMethod("getBlock", int.class, int.class, int.class);
|
clazz = Class.forName("us.myles.ViaVersion.api.type.types.version.Types1_12");
|
||||||
} catch (NoSuchMethodException ignored) {
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m == null) {
|
if (clazz == null) {
|
||||||
getLogger().severe("================================");
|
getLogger().severe("================================");
|
||||||
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
||||||
getLogger().severe("PLEASE USE THE LATEST DEVBUILD");
|
getLogger().severe("PLEASE USE THE LATEST DEVBUILD");
|
||||||
|
@ -0,0 +1,271 @@
|
|||||||
|
/*
|
||||||
|
* 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 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()) {
|
||||||
|
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),
|
||||||
|
EVOCATION_ILLAGER(34, ENTITY_INSENTIENT),
|
||||||
|
VEX(35, ENTITY_INSENTIENT),
|
||||||
|
VINDICATION_ILLAGER(36, ENTITY_INSENTIENT),
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,16 +10,22 @@
|
|||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1;
|
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets.ChangedPacketIds;
|
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets.ChangedPacketIds;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets.EntityPackets1_12;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class Protocol1_11_1To1_12 extends BackwardsProtocol {
|
public class Protocol1_11_1To1_12 extends BackwardsProtocol {
|
||||||
|
private EntityPackets1_12 entityPackets;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
new ChangedPacketIds().register(this);
|
new ChangedPacketIds().register(this);
|
||||||
|
(entityPackets = new EntityPackets1_12()).register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,10 +35,10 @@ public class ChangedPacketIds extends Rewriter<Protocol1_11_1To1_12> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}); // Unlock Recipes TODO does ViaVersion cancel the packet if the new id is -1?
|
}); // Unlock Recipes TODO does ViaVersion cancel the packet if the new id is -1?
|
||||||
p.registerOutgoing(State.PLAY, 0x31, 0x30); // Destroy Entities
|
// 0x31 -> 0x30 Destroy Entities handled in EntityPackets1_12.java
|
||||||
p.registerOutgoing(State.PLAY, 0x32, 0x31); // Remove Entity Effect
|
p.registerOutgoing(State.PLAY, 0x32, 0x31); // Remove Entity Effect
|
||||||
p.registerOutgoing(State.PLAY, 0x33, 0x32); // Resource Pack Send
|
p.registerOutgoing(State.PLAY, 0x33, 0x32); // Resource Pack Send
|
||||||
p.registerOutgoing(State.PLAY, 0x34, 0x33); // Respawn
|
// 0x34 -> 0x33 Respawn handled in EntityPackets1_12.java
|
||||||
p.registerOutgoing(State.PLAY, 0x35, 0x34); // Entity Head Look
|
p.registerOutgoing(State.PLAY, 0x35, 0x34); // Entity Head Look
|
||||||
p.registerOutgoing(State.PLAY, 0x36, -1, new PacketRemapper() {
|
p.registerOutgoing(State.PLAY, 0x36, -1, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
@ -55,7 +55,7 @@ public class ChangedPacketIds extends Rewriter<Protocol1_11_1To1_12> {
|
|||||||
p.registerOutgoing(State.PLAY, 0x38, 0x36); //Camera
|
p.registerOutgoing(State.PLAY, 0x38, 0x36); //Camera
|
||||||
p.registerOutgoing(State.PLAY, 0x39, 0x37); // Held Item Change (ClientBound)
|
p.registerOutgoing(State.PLAY, 0x39, 0x37); // Held Item Change (ClientBound)
|
||||||
p.registerOutgoing(State.PLAY, 0x3A, 0x38); // Display Scoreboard
|
p.registerOutgoing(State.PLAY, 0x3A, 0x38); // Display Scoreboard
|
||||||
p.registerOutgoing(State.PLAY, 0x3B, 0x39); // Entity Metadata
|
// 0x3B -> 0x39 Entity Metadata handled in EntityPackets1_12.java
|
||||||
p.registerOutgoing(State.PLAY, 0x3C, 0x3A); // Attach Entity
|
p.registerOutgoing(State.PLAY, 0x3C, 0x3A); // Attach Entity
|
||||||
p.registerOutgoing(State.PLAY, 0x3D, 0x3B); // Entity Velocity
|
p.registerOutgoing(State.PLAY, 0x3D, 0x3B); // Entity Velocity
|
||||||
p.registerOutgoing(State.PLAY, 0x3E, 0x3C); // Entity Equipment
|
p.registerOutgoing(State.PLAY, 0x3E, 0x3C); // Entity Equipment
|
||||||
|
@ -0,0 +1,354 @@
|
|||||||
|
/*
|
||||||
|
* 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.protocol.protocol1_12to1_11_1.packets;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
|
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.rewriters.EntityRewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
import us.myles.ViaVersion.api.type.types.version.Types1_12;
|
||||||
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static nl.matsv.viabackwards.api.entities.types.EntityType1_11.getTypeFromId;
|
||||||
|
|
||||||
|
public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
|
||||||
|
@Override
|
||||||
|
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
|
||||||
|
// Spawn Object
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
|
map(Type.UUID); // 1 - UUID
|
||||||
|
map(Type.BYTE); // 2 - Type
|
||||||
|
map(Type.DOUBLE); // 3 - x
|
||||||
|
map(Type.DOUBLE); // 4 - y
|
||||||
|
map(Type.DOUBLE); // 5 - z
|
||||||
|
map(Type.BYTE); // 6 - Pitch
|
||||||
|
map(Type.BYTE); // 7 - Yaw
|
||||||
|
map(Type.INT); // 8 - data
|
||||||
|
|
||||||
|
// Track Entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
getTypeFromId(wrapper.get(Type.BYTE, 0), true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
Optional<EntityType1_12.ObjectType> type = EntityType1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
|
|
||||||
|
if (type.isPresent()) {
|
||||||
|
Optional<EntityData> optEntDat = getObjectData(type.get());
|
||||||
|
if (optEntDat.isPresent()) {
|
||||||
|
EntityData data = optEntDat.get();
|
||||||
|
wrapper.set(Type.BYTE, 0, ((Integer) data.getReplacementId()).byteValue());
|
||||||
|
if (data.getObjectData() != -1)
|
||||||
|
wrapper.set(Type.INT, 0, data.getObjectData());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Via.getManager().isDebug()) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Could not find Entity Type" + wrapper.get(Type.BYTE, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Experience Orb
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
|
|
||||||
|
// Track entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType1_12.ObjectType.THROWN_EXP_BOTTLE.getType()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Global Entity
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x02, 0x02, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.BYTE); // 1 - Type
|
||||||
|
|
||||||
|
// Track entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType1_12.EntityType.WEATHER // Always thunder according to wiki.vg
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Mob
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
|
map(Type.UUID); // 1 - UUID
|
||||||
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
|
map(Type.DOUBLE); // 3 - X
|
||||||
|
map(Type.DOUBLE); // 4 - Y
|
||||||
|
map(Type.DOUBLE); // 5 - Z
|
||||||
|
map(Type.BYTE); // 6 - Yaw
|
||||||
|
map(Type.BYTE); // 7 - Pitch
|
||||||
|
map(Type.BYTE); // 8 - Head Pitch
|
||||||
|
map(Type.SHORT); // 9 - Velocity X
|
||||||
|
map(Type.SHORT); // 10 - Velocity Y
|
||||||
|
map(Type.SHORT); // 11 - Velocity Z
|
||||||
|
map(Types1_12.METADATA_LIST); // 12 - Metadata
|
||||||
|
|
||||||
|
// Track entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
getTypeFromId(wrapper.get(Type.VAR_INT, 1), false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Rewrite entity type / metadata
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
AbstractEntityType type = getEntityType(wrapper.user(), entityId);
|
||||||
|
|
||||||
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0));
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
storage
|
||||||
|
);
|
||||||
|
|
||||||
|
Optional<EntityData> optEntDat = getEntityData(type);
|
||||||
|
if (optEntDat.isPresent()) {
|
||||||
|
EntityData data = optEntDat.get();
|
||||||
|
wrapper.set(Type.UNSIGNED_BYTE, 0, ((Integer) data.getReplacementId()).shortValue());
|
||||||
|
if (data.hasBaseMeta())
|
||||||
|
data.getDefaultMeta().handle(storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite Metadata
|
||||||
|
wrapper.set(
|
||||||
|
Types1_12.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
storage.getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Painting
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
|
||||||
|
// Track entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType1_12.EntityType.PAINTING
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Player
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.UUID); // 1 - Player UUID
|
||||||
|
map(Type.DOUBLE); // 2 - X
|
||||||
|
map(Type.DOUBLE); // 3 - Y
|
||||||
|
map(Type.DOUBLE); // 4 - Z
|
||||||
|
map(Type.BYTE); // 5 - Yaw
|
||||||
|
map(Type.BYTE); // 6 - Pitch
|
||||||
|
map(Types1_12.METADATA_LIST); // 7 - Metadata list
|
||||||
|
|
||||||
|
// Track Entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType1_12.EntityType.PLAYER
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Rewrite Metadata
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.set(
|
||||||
|
Types1_12.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0))
|
||||||
|
).getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Join game
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT); // 0 - Entity ID
|
||||||
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
|
map(Type.INT); // 2 - Dimension
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.INT, 0),
|
||||||
|
EntityType1_12.EntityType.PLAYER
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
|
int dimensionId = wrapper.get(Type.INT, 1);
|
||||||
|
clientWorld.setEnvironment(dimensionId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Respawn Packet (save dimension id)
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x34, 0x33, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT); // 0 - Dimension ID
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
|
int dimensionId = wrapper.get(Type.INT, 0);
|
||||||
|
clientWorld.setEnvironment(dimensionId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Destroy entities
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x31, 0x30, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
||||||
|
getEntityTracker(wrapper.user()).removeEntity(entity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Metadata packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x3B, 0x39, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Types1_12.METADATA_LIST); // 1 - Metadata list
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.set(
|
||||||
|
Types1_12.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0))
|
||||||
|
).getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
// Todo handle IllusionIllager and do research what it is
|
||||||
|
// Todo handle Parrot and do research what it is
|
||||||
|
|
||||||
|
// Parrot Variant TODO
|
||||||
|
registerMetaHandler().filter(EntityType1_12.EntityType.PARROT, 15).removed();
|
||||||
|
|
||||||
|
// Left shoulder entity data
|
||||||
|
registerMetaHandler().filter(EntityType1_12.EntityType.PLAYER, 15).removed();
|
||||||
|
// Right shoulder entity data
|
||||||
|
registerMetaHandler().filter(EntityType1_12.EntityType.PLAYER, 16).removed();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
2
pom.xml
2
pom.xml
@ -65,7 +65,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.myles</groupId>
|
<groupId>us.myles</groupId>
|
||||||
<artifactId>viaversion</artifactId>
|
<artifactId>viaversion</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren