diff --git a/common/src/main/java/com/viaversion/viarewind/api/minecraft/EntityModel.java b/common/src/main/java/com/viaversion/viarewind/api/minecraft/EntityModel.java
new file mode 100644
index 000000000..a62490226
--- /dev/null
+++ b/common/src/main/java/com/viaversion/viarewind/api/minecraft/EntityModel.java
@@ -0,0 +1,102 @@
+/*
+ * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind
+ * Copyright (C) 2016-2023 ViaVersion and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.viaversion.viarewind.api.minecraft;
+
+import com.viaversion.viaversion.api.connection.UserConnection;
+import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
+import com.viaversion.viaversion.api.protocol.Protocol;
+
+import java.util.List;
+
+/**
+ * Represents a model that is replacing an entity on the client side (e.g. armor stand)
+ */
+public abstract class EntityModel> {
+
+ protected final UserConnection user;
+ protected final T protocol;
+
+ public EntityModel(final UserConnection user, final T protocol) {
+ this.user = user;
+ this.protocol = protocol;
+ }
+
+ /**
+ * @return The entity id of the entity this model is replacing
+ */
+ public abstract int getEntityId();
+
+ /**
+ * Updates the position of the entity this model is replacing
+ *
+ * @param x The new x position
+ * @param y The new y position
+ * @param z The new z position
+ */
+ public abstract void updateReplacementPosition(final double x, final double y, final double z);
+
+ /**
+ * Handles the original movement packet of the entity this model is replacing
+ *
+ * @param x The x position
+ * @param y The y position
+ * @param z The z position
+ */
+ public abstract void handleOriginalMovementPacket(final double x, final double y, final double z);
+
+ /**
+ * Sets the yaw and pitch of the entity this model is replacing
+ *
+ * @param yaw The new yaw
+ * @param pitch The new pitch
+ */
+ public abstract void setYawPitch(final float yaw, final float pitch);
+
+ /**
+ * Sets the head yaw of the entity this model is replacing
+ *
+ * @param yaw The new head yaw
+ */
+ public abstract void setHeadYaw(final float yaw);
+
+ /**
+ * Spawns the entity this model is replacing
+ */
+ public abstract void sendSpawnPacket();
+
+ /**
+ * Destroys the entity this model is replacing
+ */
+ public abstract void deleteEntity();
+
+ /**
+ * Updates the metadata of the entity this model is replacing
+ *
+ * @param metadataList The new metadata
+ */
+ public abstract void updateMetadata(final List metadataList);
+
+ public UserConnection getUser() {
+ return user;
+ }
+
+ public T getProtocol() {
+ return protocol;
+ }
+}
diff --git a/common/src/main/java/com/viaversion/viarewind/replacement/Replacement.java b/common/src/main/java/com/viaversion/viarewind/api/rewriter/Replacement.java
similarity index 59%
rename from common/src/main/java/com/viaversion/viarewind/replacement/Replacement.java
rename to common/src/main/java/com/viaversion/viarewind/api/rewriter/Replacement.java
index a7ccf3b4f..912649354 100644
--- a/common/src/main/java/com/viaversion/viarewind/replacement/Replacement.java
+++ b/common/src/main/java/com/viaversion/viarewind/api/rewriter/Replacement.java
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-package com.viaversion.viarewind.replacement;
+package com.viaversion.viarewind.api.rewriter;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
@@ -26,25 +26,27 @@ public class Replacement {
private final int id;
private final int data;
private final String name;
+
private String resetName;
private String bracketName;
- public Replacement(int id) {
+ public Replacement(final int id) {
this(id, -1);
}
- public Replacement(int id, int data) {
+ public Replacement(final int id, final int data) {
this(id, data, null);
}
- public Replacement(int id, String name) {
+ public Replacement(final int id, final String name) {
this(id, -1, name);
}
- public Replacement(int id, int data, String name) {
+ public Replacement(final int id, final int data, final String name) {
this.id = id;
this.data = data;
this.name = name;
+
if (name != null) {
this.resetName = "§r" + name;
this.bracketName = " §r§7(" + name + "§r§7)";
@@ -63,25 +65,38 @@ public String getName() {
return name;
}
+ /**
+ * @param item The item to replace
+ * @return The replacement for the item or the item if not found
+ */
public Item replace(Item item) {
- item.setIdentifier(id);
- if (data != -1) item.setData((short) data);
- if (name != null) {
- CompoundTag compoundTag = item.tag() == null ? new CompoundTag() : item.tag();
- if (!compoundTag.contains("display")) compoundTag.put("display", new CompoundTag());
- CompoundTag display = compoundTag.get("display");
+ item.setIdentifier(id); // Set the new id
+ if (data != -1) {
+ item.setData((short) data); // Set the new data
+ }
+ if (name != null) { // Set the new name
+ CompoundTag rootTag = item.tag() == null ? new CompoundTag() : item.tag(); // Get root tag or create new one if not exists
+
+ if (!rootTag.contains("display")) rootTag.put("display", new CompoundTag()); // Create display tag if not exists
+
+ final CompoundTag display = rootTag.get("display");
if (display.contains("Name")) {
- StringTag name = display.get("Name");
- if (!name.getValue().equals(resetName) && !name.getValue().endsWith(bracketName))
- name.setValue(name.getValue() + bracketName);
+ final StringTag name = display.get("Name");
+ if (!name.getValue().equals(resetName) && !name.getValue().endsWith(bracketName)) {
+ name.setValue(name.getValue() + bracketName); // Append the new name tag
+ }
} else {
- display.put("Name", new StringTag(resetName));
+ display.put("Name", new StringTag(resetName)); // Set the new name tag
}
- item.setTag(compoundTag);
+ item.setTag(rootTag);
}
return item;
}
+ /**
+ * @param data The data of the item/block
+ * @return The replacement data for the item/block
+ */
public int replaceData(int data) {
return this.data == -1 ? data : this.data;
}
diff --git a/common/src/main/java/com/viaversion/viarewind/api/rewriter/ReplacementItemRewriter.java b/common/src/main/java/com/viaversion/viarewind/api/rewriter/ReplacementItemRewriter.java
index 1d44b2ae1..2551e547b 100644
--- a/common/src/main/java/com/viaversion/viarewind/api/rewriter/ReplacementItemRewriter.java
+++ b/common/src/main/java/com/viaversion/viarewind/api/rewriter/ReplacementItemRewriter.java
@@ -19,7 +19,6 @@
package com.viaversion.viarewind.api.rewriter;
import com.viaversion.viarewind.api.minecraft.IdDataCombine;
-import com.viaversion.viarewind.replacement.Replacement;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10To1_8.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10To1_8.java
index 0c3c27d39..e2fda7144 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10To1_8.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10To1_8.java
@@ -119,12 +119,12 @@ public void init(UserConnection userConnection) {
userConnection.put(new Windows(userConnection));
userConnection.put(new EntityTracker(userConnection, this));
- userConnection.put(new PlayerPosition(userConnection));
+ userConnection.put(new PlayerPositionTracker(userConnection));
userConnection.put(new GameProfileStorage(userConnection));
userConnection.put(new Scoreboard(userConnection));
- userConnection.put(new CompressionSendStorage(userConnection));
+ userConnection.put(new CompressionStatusTracker(userConnection));
userConnection.put(new WorldBorder(userConnection));
- userConnection.put(new PlayerAbilities(userConnection));
+ userConnection.put(new PlayerAbilitiesTracker(userConnection));
userConnection.put(new ClientWorld(userConnection));
}
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/ArmorStandReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/ArmorStandModel.java
similarity index 89%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/ArmorStandReplacement.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/ArmorStandModel.java
index 2f6cdd5a6..28e62465d 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/ArmorStandReplacement.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/ArmorStandModel.java
@@ -16,11 +16,10 @@
* along with this program. If not, see .
*/
-package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements;
+package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator;
import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ClientboundPackets1_7_2_5;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.MetaType1_7_6_10;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
import com.viaversion.viarewind.utils.PacketUtil;
@@ -36,7 +35,7 @@
import java.util.ArrayList;
import java.util.List;
-public class ArmorStandReplacement extends EntityReplacement1_7to1_8 {
+public class ArmorStandModel extends EntityModel1_7_6_10 {
private final int entityId;
private final List datawatcher = new ArrayList<>();
private int[] entityIds = null;
@@ -49,8 +48,8 @@ public class ArmorStandReplacement extends EntityReplacement1_7to1_8 {
private boolean small = false;
private boolean marker = false;
- public ArmorStandReplacement(Protocol1_7_6_10To1_8 protocol, UserConnection user, int entityId) {
- super(protocol, user);
+ public ArmorStandModel(UserConnection user, Protocol1_7_6_10To1_8 protocol, int entityId) {
+ super(user, protocol);
this.entityId = entityId;
}
@@ -60,7 +59,7 @@ public int getEntityId() {
}
@Override
- public void setLocation(double x, double y, double z) {
+ public void updateReplacementPosition(double x, double y, double z) {
if (x != this.locX || y != this.locY || z != this.locZ) {
this.locX = x;
this.locY = y;
@@ -70,7 +69,7 @@ public void setLocation(double x, double y, double z) {
}
@Override
- public void relMove(double x, double y, double z) {
+ public void handleOriginalMovementPacket(double x, double y, double z) {
if (x == 0.0 && y == 0.0 && z == 0.0) return;
this.locX += x;
this.locY += y;
@@ -123,15 +122,15 @@ public void updateState() {
marker = (armorStandFlags & 0x10) != 0;
State prevState = currentState;
- if (invisible && (name != null || marker)) {
+ if (invisible && name != null) {
currentState = State.HOLOGRAM;
} else {
currentState = State.ZOMBIE;
}
if (currentState != prevState) {
- despawn();
- spawn();
+ deleteEntity();
+ sendSpawnPacket();
} else {
updateMetadata();
updateLocation(false);
@@ -149,7 +148,7 @@ public void updateLocation(boolean remount) {
}
private void updateZombieLocation() {
- sendTeleportWithHead(entityId, locX, locY, locZ, yaw, pitch, headYaw);
+ teleportAndUpdate(entityId, locX, locY, locZ, yaw, pitch, headYaw);
}
private void updateHologramLocation(boolean remount) {
@@ -162,10 +161,10 @@ private void updateHologramLocation(boolean remount) {
}
// Don't ask me where this offset is coming from
- sendTeleport(entityIds[0], locX, (locY + (marker ? 54.85 : small ? 56 : 57)), locZ, 0, 0); // Skull
+ teleportEntity(entityIds[0], locX, (locY + (marker ? 54.85 : small ? 56 : 57)), locZ, 0, 0); // Skull
if (remount) {
- sendTeleport(entityIds[1], locX, locY + 56.75, locZ, 0, 0); // Horse
+ teleportEntity(entityIds[1], locX, locY + 56.75, locZ, 0, 0); // Horse
PacketWrapper attach = PacketWrapper.create(ClientboundPackets1_7_2_5.ATTACH_ENTITY, null, user);
attach.write(Type.INT, entityIds[1]);
@@ -200,7 +199,7 @@ private void writeZombieMeta(PacketWrapper metadataPacket) {
metadataList.add(new Metadata(metadata.id(), metadata.metaType(), metadata.getValue()));
}
if (small) metadataList.add(new Metadata(12, MetaType1_8.Byte, (byte) 1));
- protocol.getMetadataRewriter().transform(Entity1_10Types.EntityType.ZOMBIE, metadataList);
+ getProtocol().getMetadataRewriter().transform(Entity1_10Types.EntityType.ZOMBIE, metadataList);
metadataPacket.write(Types1_7_6_10.METADATA_LIST, metadataList);
}
@@ -217,8 +216,8 @@ private void writeHologramMeta(PacketWrapper metadataPacket) {
}
@Override
- public void spawn() {
- if (entityIds != null) despawn();
+ public void sendSpawnPacket() {
+ if (entityIds != null) deleteEntity();
if (currentState == State.ZOMBIE) {
spawnZombie();
@@ -231,7 +230,7 @@ public void spawn() {
}
private void spawnZombie() {
- sendSpawn(entityId, 54, locX, locY, locZ);
+ spawnEntity(entityId, 54, locX, locY, locZ);
entityIds = new int[]{entityId};
}
@@ -250,7 +249,7 @@ private void spawnHologram() {
spawnSkull.write(Type.INT, 0);
PacketUtil.sendPacket(spawnSkull, Protocol1_7_6_10To1_8.class, true, true);
- sendSpawn(entityIds[1], 100, locX, locY, locZ); // Horse
+ spawnEntity(entityIds[1], 100, locX, locY, locZ); // Horse
this.entityIds = entityIds;
}
@@ -268,7 +267,7 @@ public AABB getBoundingBox() {
}
@Override
- public void despawn() {
+ public void deleteEntity() {
if (entityIds == null) return;
PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7_2_5.DESTROY_ENTITIES, null, user);
despawn.write(Type.BYTE, (byte) entityIds.length);
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EndermiteReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/EndermiteModel.java
similarity index 83%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EndermiteReplacement.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/EndermiteModel.java
index 8cd624be6..ba9a7c2ff 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EndermiteReplacement.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/EndermiteModel.java
@@ -16,11 +16,10 @@
* along with this program. If not, see .
*/
-package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements;
+package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator;
import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ClientboundPackets1_7_2_5;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.connection.UserConnection;
@@ -32,21 +31,21 @@
import java.util.ArrayList;
import java.util.List;
-public class EndermiteReplacement extends EntityReplacement1_7to1_8 {
+public class EndermiteModel extends EntityModel1_7_6_10 {
private final int entityId;
private final List datawatcher = new ArrayList<>();
private double locX, locY, locZ;
private float yaw, pitch;
private float headYaw;
- public EndermiteReplacement(Protocol1_7_6_10To1_8 protocol, UserConnection user, int entityId) {
- super(protocol, user);
+ public EndermiteModel(UserConnection user, Protocol1_7_6_10To1_8 protocol, int entityId) {
+ super(user, protocol);
this.entityId = entityId;
- spawn();
+ sendSpawnPacket();
}
@Override
- public void setLocation(double x, double y, double z) {
+ public void updateReplacementPosition(double x, double y, double z) {
this.locX = x;
this.locY = y;
this.locZ = z;
@@ -54,7 +53,7 @@ public void setLocation(double x, double y, double z) {
}
@Override
- public void relMove(double x, double y, double z) {
+ public void handleOriginalMovementPacket(double x, double y, double z) {
this.locX += x;
this.locY += y;
this.locZ += z;
@@ -88,7 +87,7 @@ public void updateMetadata(List metadataList) {
}
public void updateLocation() {
- sendTeleportWithHead(entityId, locX, locY, locZ, yaw, pitch, headYaw);
+ teleportAndUpdate(entityId, locX, locY, locZ, yaw, pitch, headYaw);
}
public void updateMetadata() {
@@ -100,7 +99,7 @@ public void updateMetadata() {
metadataList.add(new Metadata(metadata.id(), metadata.metaType(), metadata.getValue()));
}
- protocol.getMetadataRewriter().transform(Entity1_10Types.EntityType.SQUID, metadataList);
+ getProtocol().getMetadataRewriter().transform(Entity1_10Types.EntityType.SQUID, metadataList);
metadataPacket.write(Types1_7_6_10.METADATA_LIST, metadataList);
@@ -108,12 +107,12 @@ public void updateMetadata() {
}
@Override
- public void spawn() {
- sendSpawn(entityId, 60, locX, locY, locZ);
+ public void sendSpawnPacket() {
+ spawnEntity(entityId, 60, locX, locY, locZ);
}
@Override
- public void despawn() {
+ public void deleteEntity() {
PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7_2_5.DESTROY_ENTITIES, null, user);
despawn.write(Types1_7_6_10.INT_ARRAY, new int[]{entityId});
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/EntityModel1_7_6_10.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/EntityModel1_7_6_10.java
new file mode 100644
index 000000000..3eb4aba2c
--- /dev/null
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/EntityModel1_7_6_10.java
@@ -0,0 +1,83 @@
+/*
+ * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind
+ * Copyright (C) 2016-2023 ViaVersion and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator;
+
+import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ClientboundPackets1_7_2_5;
+import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
+import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
+import com.viaversion.viarewind.api.minecraft.EntityModel;
+import com.viaversion.viarewind.utils.PacketUtil;
+import com.viaversion.viaversion.api.connection.UserConnection;
+import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
+import com.viaversion.viaversion.api.type.Type;
+
+import java.util.ArrayList;
+
+public abstract class EntityModel1_7_6_10 extends EntityModel {
+
+ public EntityModel1_7_6_10(UserConnection user, Protocol1_7_6_10To1_8 protocol) {
+ super(user, protocol);
+ }
+
+ protected void teleportAndUpdate(final int entityId, final double x, final double y, final double z, final float yaw, final float pitch, final float headYaw) {
+ teleportEntity(entityId, x, y, z, yaw, pitch);
+ updateHeadYaw(entityId, headYaw);
+ }
+
+ protected void teleportEntity(final int entityId, final double x, final double y, final double z, final float yaw, final float pitch) {
+ final PacketWrapper entityTeleport = PacketWrapper.create(ClientboundPackets1_7_2_5.ENTITY_TELEPORT, user);
+
+ entityTeleport.write(Type.INT, entityId); // entity id
+ entityTeleport.write(Type.INT, (int) (x * 32.0)); // x
+ entityTeleport.write(Type.INT, (int) (y * 32.0)); // y
+ entityTeleport.write(Type.INT, (int) (z * 32.0)); // z
+ entityTeleport.write(Type.BYTE, (byte) ((yaw / 360f) * 256)); // yaw
+ entityTeleport.write(Type.BYTE, (byte) ((pitch / 360f) * 256)); // pitch
+
+ PacketUtil.sendPacket(entityTeleport, Protocol1_7_6_10To1_8.class, true, true);
+ }
+
+ protected void updateHeadYaw(final int entityId, final float headYaw) {
+ final PacketWrapper entityHeadLook = PacketWrapper.create(ClientboundPackets1_7_2_5.ENTITY_HEAD_LOOK, user);
+
+ entityHeadLook.write(Type.INT, entityId);
+ entityHeadLook.write(Type.BYTE, (byte) ((headYaw / 360f) * 256));
+
+ PacketUtil.sendPacket(entityHeadLook, Protocol1_7_6_10To1_8.class, true, true);
+ }
+
+ protected void spawnEntity(final int entityId, final int type, final double locX, final double locY, final double locZ) {
+ final PacketWrapper spawnMob = PacketWrapper.create(ClientboundPackets1_7_2_5.SPAWN_MOB, null, user);
+
+ spawnMob.write(Type.VAR_INT, entityId); // entity id
+ spawnMob.write(Type.UNSIGNED_BYTE, (short) type); // type
+ spawnMob.write(Type.INT, (int) (locX * 32.0)); // x
+ spawnMob.write(Type.INT, (int) (locY * 32.0)); // y
+ spawnMob.write(Type.INT, (int) (locZ * 32.0)); // z
+ spawnMob.write(Type.BYTE, (byte) 0); // yaw
+ spawnMob.write(Type.BYTE, (byte) 0); // pitch
+ spawnMob.write(Type.BYTE, (byte) 0); // head pitch
+ spawnMob.write(Type.SHORT, (short) 0); // velocity x
+ spawnMob.write(Type.SHORT, (short) 0); // velocity y
+ spawnMob.write(Type.SHORT, (short) 0); // velocity z
+ spawnMob.write(Types1_7_6_10.METADATA_LIST, new ArrayList<>()); // metadata
+
+ PacketUtil.sendPacket(spawnMob, Protocol1_7_6_10To1_8.class, true, true);
+ }
+}
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/GuardianReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/GuardianModel.java
similarity index 83%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/GuardianReplacement.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/GuardianModel.java
index a1f6e79ac..fab993236 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/GuardianReplacement.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/GuardianModel.java
@@ -16,11 +16,10 @@
* along with this program. If not, see .
*/
-package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements;
+package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator;
import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ClientboundPackets1_7_2_5;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.connection.UserConnection;
@@ -32,21 +31,21 @@
import java.util.ArrayList;
import java.util.List;
-public class GuardianReplacement extends EntityReplacement1_7to1_8 {
+public class GuardianModel extends EntityModel1_7_6_10 {
private final int entityId;
private final List datawatcher = new ArrayList<>();
private double locX, locY, locZ;
private float yaw, pitch;
private float headYaw;
- public GuardianReplacement(Protocol1_7_6_10To1_8 protocol, UserConnection user, int entityId) {
- super(protocol, user);
+ public GuardianModel(UserConnection user, Protocol1_7_6_10To1_8 protocol, int entityId) {
+ super(user, protocol);
this.entityId = entityId;
- spawn();
+ sendSpawnPacket();
}
@Override
- public void setLocation(double x, double y, double z) {
+ public void updateReplacementPosition(double x, double y, double z) {
this.locX = x;
this.locY = y;
this.locZ = z;
@@ -54,7 +53,7 @@ public void setLocation(double x, double y, double z) {
}
@Override
- public void relMove(double x, double y, double z) {
+ public void handleOriginalMovementPacket(double x, double y, double z) {
this.locX += x;
this.locY += y;
this.locZ += z;
@@ -88,7 +87,7 @@ public void updateMetadata(List metadataList) {
}
public void updateLocation() {
- sendTeleportWithHead(entityId, locX, locY, locZ, yaw, pitch, headYaw);
+ teleportAndUpdate(entityId, locX, locY, locZ, yaw, pitch, headYaw);
}
public void updateMetadata() {
@@ -101,7 +100,7 @@ public void updateMetadata() {
metadataList.add(new Metadata(metadata.id(), metadata.metaType(), metadata.getValue()));
}
- protocol.getMetadataRewriter().transform(Entity1_10Types.EntityType.SQUID, metadataList);
+ getProtocol().getMetadataRewriter().transform(Entity1_10Types.EntityType.SQUID, metadataList);
metadataPacket.write(Types1_7_6_10.METADATA_LIST, metadataList);
@@ -109,12 +108,12 @@ public void updateMetadata() {
}
@Override
- public void spawn() {
- sendSpawn(entityId, 94, locX, locY, locZ);
+ public void sendSpawnPacket() {
+ spawnEntity(entityId, 94, locX, locY, locZ);
}
@Override
- public void despawn() {
+ public void deleteEntity() {
PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7_2_5.DESTROY_ENTITIES, null, user);
despawn.write(Types1_7_6_10.INT_ARRAY, new int[]{entityId});
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/RabbitReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/RabbitModel.java
similarity index 83%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/RabbitReplacement.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/RabbitModel.java
index d7fa67b00..535824738 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/RabbitReplacement.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/emulator/RabbitModel.java
@@ -16,11 +16,10 @@
* along with this program. If not, see .
*/
-package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements;
+package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator;
import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ClientboundPackets1_7_2_5;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.connection.UserConnection;
@@ -32,21 +31,21 @@
import java.util.ArrayList;
import java.util.List;
-public class RabbitReplacement extends EntityReplacement1_7to1_8 {
+public class RabbitModel extends EntityModel1_7_6_10 {
private final int entityId;
private final List datawatcher = new ArrayList<>();
private double locX, locY, locZ;
private float yaw, pitch;
private float headYaw;
- public RabbitReplacement(Protocol1_7_6_10To1_8 protocol, UserConnection user, int entityId) {
- super(protocol, user);
+ public RabbitModel(UserConnection user, Protocol1_7_6_10To1_8 protocol, int entityId) {
+ super(user, protocol);
this.entityId = entityId;
- spawn();
+ sendSpawnPacket();
}
@Override
- public void setLocation(double x, double y, double z) {
+ public void updateReplacementPosition(double x, double y, double z) {
this.locX = x;
this.locY = y;
this.locZ = z;
@@ -54,7 +53,7 @@ public void setLocation(double x, double y, double z) {
}
@Override
- public void relMove(double x, double y, double z) {
+ public void handleOriginalMovementPacket(double x, double y, double z) {
this.locX += x;
this.locY += y;
this.locZ += z;
@@ -88,7 +87,7 @@ public void updateMetadata(List metadataList) {
}
public void updateLocation() {
- sendTeleportWithHead(entityId, locX, locY, locZ, yaw, pitch, headYaw);
+ teleportAndUpdate(entityId, locX, locY, locZ, yaw, pitch, headYaw);
}
public void updateMetadata() {
@@ -100,7 +99,7 @@ public void updateMetadata() {
metadataList.add(new Metadata(metadata.id(), metadata.metaType(), metadata.getValue()));
}
- protocol.getMetadataRewriter().transform(Entity1_10Types.EntityType.CHICKEN, metadataList);
+ getProtocol().getMetadataRewriter().transform(Entity1_10Types.EntityType.CHICKEN, metadataList);
metadataPacket.write(Types1_7_6_10.METADATA_LIST, metadataList);
@@ -108,12 +107,12 @@ public void updateMetadata() {
}
@Override
- public void spawn() {
- sendSpawn(entityId, 93, locX, locY, locZ); // Chicken
+ public void sendSpawnPacket() {
+ spawnEntity(entityId, 93, locX, locY, locZ); // Chicken
}
@Override
- public void despawn() {
+ public void deleteEntity() {
PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7_2_5.DESTROY_ENTITIES, null, user);
despawn.write(Types1_7_6_10.INT_ARRAY, new int[]{entityId});
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EntityReplacement1_7to1_8.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EntityReplacement1_7to1_8.java
deleted file mode 100644
index 0bc0449c7..000000000
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EntityReplacement1_7to1_8.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind
- * Copyright (C) 2016-2023 ViaVersion and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements;
-
-import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ClientboundPackets1_7_2_5;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
-import com.viaversion.viarewind.replacement.EntityReplacement;
-import com.viaversion.viarewind.utils.PacketUtil;
-import com.viaversion.viaversion.api.connection.UserConnection;
-import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
-import com.viaversion.viaversion.api.type.Type;
-
-import java.util.ArrayList;
-
-public abstract class EntityReplacement1_7to1_8 implements EntityReplacement {
- protected final Protocol1_7_6_10To1_8 protocol;
- protected final UserConnection user;
-
- public EntityReplacement1_7to1_8(Protocol1_7_6_10To1_8 protocol, UserConnection user) {
- this.protocol = protocol;
- this.user = user;
- }
-
- protected void sendTeleportWithHead(int entityId, double locX, double locY, double locZ, float yaw, float pitch, float headYaw) {
- sendTeleport(entityId, locX, locY, locZ, yaw, pitch);
- sendHeadYaw(entityId, headYaw);
- }
-
- protected void sendTeleport(int entityId, double locX, double locY, double locZ, float yaw, float pitch) {
- PacketWrapper teleport = PacketWrapper.create(ClientboundPackets1_7_2_5.ENTITY_TELEPORT, null, user);
- teleport.write(Type.INT, entityId);
- teleport.write(Type.INT, (int) (locX * 32.0));
- teleport.write(Type.INT, (int) (locY * 32.0));
- teleport.write(Type.INT, (int) (locZ * 32.0));
- teleport.write(Type.BYTE, (byte) ((yaw / 360f) * 256));
- teleport.write(Type.BYTE, (byte) ((pitch / 360f) * 256));
-
- PacketUtil.sendPacket(teleport, Protocol1_7_6_10To1_8.class, true, true);
- }
-
- protected void sendHeadYaw(int entityId, float headYaw) {
- PacketWrapper head = PacketWrapper.create(ClientboundPackets1_7_2_5.ENTITY_HEAD_LOOK, null, user);
- head.write(Type.INT, entityId);
- head.write(Type.BYTE, (byte) ((headYaw / 360f) * 256));
- PacketUtil.sendPacket(head, Protocol1_7_6_10To1_8.class, true, true);
- }
-
- protected void sendSpawn(int entityId, int type, double locX, double locY, double locZ) {
- PacketWrapper spawn = PacketWrapper.create(ClientboundPackets1_7_2_5.SPAWN_MOB, null, user);
- spawn.write(Type.VAR_INT, entityId);
- spawn.write(Type.UNSIGNED_BYTE, (short) type); // type
- spawn.write(Type.INT, (int) (locX * 32.0));
- spawn.write(Type.INT, (int) (locY * 32.0));
- spawn.write(Type.INT, (int) (locZ * 32.0));
- spawn.write(Type.BYTE, (byte) 0);
- spawn.write(Type.BYTE, (byte) 0);
- spawn.write(Type.BYTE, (byte) 0);
- spawn.write(Type.SHORT, (short) 0);
- spawn.write(Type.SHORT, (short) 0);
- spawn.write(Type.SHORT, (short) 0);
- spawn.write(Types1_7_6_10.METADATA_LIST, new ArrayList<>());
-
- PacketUtil.sendPacket(spawn, Protocol1_7_6_10To1_8.class, true, true);
- }
-}
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java
index 80c63a8dc..55587c9cb 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java
@@ -25,7 +25,7 @@
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.EntityTracker;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.GameProfileStorage;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
-import com.viaversion.viarewind.replacement.EntityReplacement;
+import com.viaversion.viarewind.api.minecraft.EntityModel;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types;
@@ -156,13 +156,13 @@ public void register() {
handler(packetWrapper -> {
int entityId = packetWrapper.get(Type.INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
int x = packetWrapper.get(Type.BYTE, 0);
int y = packetWrapper.get(Type.BYTE, 1);
int z = packetWrapper.get(Type.BYTE, 2);
- replacement.relMove(x / 32.0, y / 32.0, z / 32.0);
+ replacement.handleOriginalMovementPacket(x / 32.0, y / 32.0, z / 32.0);
}
});
}
@@ -178,7 +178,7 @@ public void register() {
handler(packetWrapper -> {
int entityId = packetWrapper.get(Type.INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
int yaw = packetWrapper.get(Type.BYTE, 0);
@@ -202,7 +202,7 @@ public void register() {
handler(packetWrapper -> {
int entityId = packetWrapper.get(Type.INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
int x = packetWrapper.get(Type.BYTE, 0);
@@ -210,7 +210,7 @@ public void register() {
int z = packetWrapper.get(Type.BYTE, 2);
int yaw = packetWrapper.get(Type.BYTE, 3);
int pitch = packetWrapper.get(Type.BYTE, 4);
- replacement.relMove(x / 32.0, y / 32.0, z / 32.0);
+ replacement.handleOriginalMovementPacket(x / 32.0, y / 32.0, z / 32.0);
replacement.setYawPitch(yaw * 360f / 256, pitch * 360f / 256);
}
});
@@ -240,7 +240,7 @@ public void register() {
handler(packetWrapper -> {
int entityId = packetWrapper.get(Type.INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
int x = packetWrapper.get(Type.INT, 1);
@@ -248,7 +248,7 @@ public void register() {
int z = packetWrapper.get(Type.INT, 3);
int yaw = packetWrapper.get(Type.BYTE, 0);
int pitch = packetWrapper.get(Type.BYTE, 1);
- replacement.setLocation(x / 32.0, y / 32.0, z / 32.0);
+ replacement.updateReplacementPosition(x / 32.0, y / 32.0, z / 32.0);
replacement.setYawPitch(yaw * 360f / 256, pitch * 360f / 256);
}
});
@@ -263,7 +263,7 @@ public void register() {
handler(packetWrapper -> {
int entityId = packetWrapper.get(Type.INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
int yaw = packetWrapper.get(Type.BYTE, 0);
@@ -300,7 +300,7 @@ public void register() {
int entityId = wrapper.get(Type.INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
if (tracker.getClientEntityTypes().containsKey(entityId)) {
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
wrapper.cancel();
replacement.updateMetadata(metadataList);
@@ -309,7 +309,6 @@ public void register() {
if (metadataList.isEmpty()) wrapper.cancel();
}
} else {
- tracker.addMetadataToBuffer(entityId, metadataList);
wrapper.cancel();
}
});
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java
index 5a8f12df3..98475fcf0 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java
@@ -22,11 +22,11 @@
import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ClientboundPackets1_7_2_5;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ServerboundPackets1_7_2_5;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.ArmorStandReplacement;
+import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator.ArmorStandModel;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.provider.TitleRenderProvider;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.*;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
-import com.viaversion.viarewind.replacement.EntityReplacement;
+import com.viaversion.viarewind.api.minecraft.EntityModel;
import com.viaversion.viarewind.utils.ChatUtil;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viarewind.utils.math.AABB;
@@ -166,41 +166,41 @@ public void register() {
map(Type.FLOAT); //yaw
map(Type.FLOAT); //pitch
handler(packetWrapper -> {
- PlayerPosition playerPosition = packetWrapper.user().get(PlayerPosition.class);
- playerPosition.setPositionPacketReceived(true);
+ PlayerPositionTracker playerPositionTracker = packetWrapper.user().get(PlayerPositionTracker.class);
+ playerPositionTracker.setPositionPacketReceived(true);
int flags = packetWrapper.read(Type.BYTE);
if ((flags & 0x01) == 0x01) {
double x = packetWrapper.get(Type.DOUBLE, 0);
- x += playerPosition.getPosX();
+ x += playerPositionTracker.getPosX();
packetWrapper.set(Type.DOUBLE, 0, x);
}
double y = packetWrapper.get(Type.DOUBLE, 1);
if ((flags & 0x02) == 0x02) {
- y += playerPosition.getPosY();
+ y += playerPositionTracker.getPosY();
}
- playerPosition.setReceivedPosY(y);
+ playerPositionTracker.setReceivedPosY(y);
y += 1.62F;
packetWrapper.set(Type.DOUBLE, 1, y);
if ((flags & 0x04) == 0x04) {
double z = packetWrapper.get(Type.DOUBLE, 2);
- z += playerPosition.getPosZ();
+ z += playerPositionTracker.getPosZ();
packetWrapper.set(Type.DOUBLE, 2, z);
}
if ((flags & 0x08) == 0x08) {
float yaw = packetWrapper.get(Type.FLOAT, 0);
- yaw += playerPosition.getYaw();
+ yaw += playerPositionTracker.getYaw();
packetWrapper.set(Type.FLOAT, 0, yaw);
}
if ((flags & 0x10) == 0x10) {
float pitch = packetWrapper.get(Type.FLOAT, 1);
- pitch += playerPosition.getPitch();
+ pitch += playerPositionTracker.getPitch();
packetWrapper.set(Type.FLOAT, 1, pitch);
}
});
handler(packetWrapper -> {
- PlayerPosition playerPosition = packetWrapper.user().get(PlayerPosition.class);
- packetWrapper.write(Type.BOOLEAN, playerPosition.isOnGround());
+ PlayerPositionTracker playerPositionTracker = packetWrapper.user().get(PlayerPositionTracker.class);
+ packetWrapper.write(Type.BOOLEAN, playerPositionTracker.isOnGround());
});
handler(packetWrapper -> {
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
@@ -413,7 +413,7 @@ public void register() {
byte flags = packetWrapper.get(Type.BYTE, 0);
float flySpeed = packetWrapper.get(Type.FLOAT, 0);
float walkSpeed = packetWrapper.get(Type.FLOAT, 1);
- PlayerAbilities abilities = packetWrapper.user().get(PlayerAbilities.class);
+ PlayerAbilitiesTracker abilities = packetWrapper.user().get(PlayerAbilitiesTracker.class);
abilities.setInvincible((flags & 8) == 8);
abilities.setAllowFly((flags & 4) == 4);
abilities.setFlying((flags & 2) == 2);
@@ -587,14 +587,14 @@ public void register() {
if (mode != 0) return;
int entityId = packetWrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
- if (!(replacement instanceof ArmorStandReplacement)) return;
- ArmorStandReplacement armorStand = (ArmorStandReplacement) replacement;
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
+ if (!(replacement instanceof ArmorStandModel)) return;
+ ArmorStandModel armorStand = (ArmorStandModel) replacement;
AABB boundingBox = armorStand.getBoundingBox();
- PlayerPosition playerPosition = packetWrapper.user().get(PlayerPosition.class);
- Vector3d pos = new Vector3d(playerPosition.getPosX(), playerPosition.getPosY() + 1.8, playerPosition.getPosZ());
- double yaw = Math.toRadians(playerPosition.getYaw());
- double pitch = Math.toRadians(playerPosition.getPitch());
+ PlayerPositionTracker playerPositionTracker = packetWrapper.user().get(PlayerPositionTracker.class);
+ Vector3d pos = new Vector3d(playerPositionTracker.getPosX(), playerPositionTracker.getPosY() + 1.8, playerPositionTracker.getPosZ());
+ double yaw = Math.toRadians(playerPositionTracker.getYaw());
+ double pitch = Math.toRadians(playerPositionTracker.getPitch());
Vector3d dir = new Vector3d(-Math.cos(pitch) * Math.sin(yaw), -Math.sin(pitch), Math.cos(pitch) * Math.cos(yaw));
Ray3d ray = new Ray3d(pos, dir);
Vector3d intersection = RayTracing.trace(ray, boundingBox, 5.0);
@@ -614,8 +614,8 @@ public void register() {
public void register() {
map(Type.BOOLEAN);
handler(packetWrapper -> {
- PlayerPosition playerPosition = packetWrapper.user().get(PlayerPosition.class);
- playerPosition.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
+ PlayerPositionTracker playerPositionTracker = packetWrapper.user().get(PlayerPositionTracker.class);
+ playerPositionTracker.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
});
}
});
@@ -633,10 +633,10 @@ public void register() {
double feetY = packetWrapper.get(Type.DOUBLE, 1);
double z = packetWrapper.get(Type.DOUBLE, 2);
- PlayerPosition playerPosition = packetWrapper.user().get(PlayerPosition.class);
+ PlayerPositionTracker playerPositionTracker = packetWrapper.user().get(PlayerPositionTracker.class);
- playerPosition.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
- playerPosition.setPos(x, feetY, z);
+ playerPositionTracker.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
+ playerPositionTracker.setPos(x, feetY, z);
});
}
});
@@ -648,10 +648,10 @@ public void register() {
map(Type.FLOAT);
map(Type.BOOLEAN);
handler(packetWrapper -> {
- PlayerPosition playerPosition = packetWrapper.user().get(PlayerPosition.class);
- playerPosition.setYaw(packetWrapper.get(Type.FLOAT, 0));
- playerPosition.setPitch(packetWrapper.get(Type.FLOAT, 1));
- playerPosition.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
+ PlayerPositionTracker playerPositionTracker = packetWrapper.user().get(PlayerPositionTracker.class);
+ playerPositionTracker.setYaw(packetWrapper.get(Type.FLOAT, 0));
+ playerPositionTracker.setPitch(packetWrapper.get(Type.FLOAT, 1));
+ playerPositionTracker.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
});
}
});
@@ -674,12 +674,12 @@ public void register() {
float yaw = packetWrapper.get(Type.FLOAT, 0);
float pitch = packetWrapper.get(Type.FLOAT, 1);
- PlayerPosition playerPosition = packetWrapper.user().get(PlayerPosition.class);
+ PlayerPositionTracker playerPositionTracker = packetWrapper.user().get(PlayerPositionTracker.class);
- playerPosition.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
- playerPosition.setPos(x, feetY, z);
- playerPosition.setYaw(yaw);
- playerPosition.setPitch(pitch);
+ playerPositionTracker.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
+ playerPositionTracker.setPos(x, feetY, z);
+ playerPositionTracker.setYaw(yaw);
+ playerPositionTracker.setPitch(pitch);
});
}
});
@@ -758,7 +758,7 @@ public void register() {
handler(packetWrapper -> {
int action = packetWrapper.get(Type.VAR_INT, 1);
if (action == 3 || action == 4) {
- PlayerAbilities abilities = packetWrapper.user().get(PlayerAbilities.class);
+ PlayerAbilitiesTracker abilities = packetWrapper.user().get(PlayerAbilitiesTracker.class);
abilities.setSprinting(action == 3);
PacketWrapper abilitiesPacket = PacketWrapper.create(0x39, null, packetWrapper.user());
abilitiesPacket.write(Type.BYTE, abilities.getFlags());
@@ -827,7 +827,7 @@ public void register() {
map(Type.FLOAT);
map(Type.FLOAT);
handler(packetWrapper -> {
- PlayerAbilities abilities = packetWrapper.user().get(PlayerAbilities.class);
+ PlayerAbilitiesTracker abilities = packetWrapper.user().get(PlayerAbilitiesTracker.class);
if (abilities.isAllowFly()) {
byte flags = packetWrapper.get(Type.BYTE, 0);
abilities.setFlying((flags & 2) == 2);
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java
index c9207eacf..c5b572a29 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java
@@ -20,17 +20,15 @@
import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ClientboundPackets1_7_2_5;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.ArmorStandReplacement;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.EndermiteReplacement;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.GuardianReplacement;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.RabbitReplacement;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.rewriter.ReplacementItemRewriter1_7_6_10;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter;
+import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator.ArmorStandModel;
+import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator.EndermiteModel;
+import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator.GuardianModel;
+import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.emulator.RabbitModel;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.EntityTracker;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.GameProfileStorage;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10;
-import com.viaversion.viarewind.replacement.EntityReplacement;
-import com.viaversion.viarewind.replacement.Replacement;
+import com.viaversion.viarewind.api.minecraft.EntityModel;
+import com.viaversion.viarewind.api.rewriter.Replacement;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types;
@@ -98,9 +96,9 @@ public void register() {
});
handler(packetWrapper -> {
int entityId = packetWrapper.get(Type.VAR_INT, 0);
+
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
tracker.getClientEntityTypes().put(entityId, Entity1_10Types.EntityType.PLAYER);
- tracker.sendMetadataBuffer(entityId);
});
}
});
@@ -148,8 +146,8 @@ public void register() {
} else if (typeId == 78) {
packetWrapper.cancel();
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- ArmorStandReplacement armorStand = new ArmorStandReplacement(protocol, packetWrapper.user(), entityId);
- armorStand.setLocation(x / 32.0, y / 32.0, z / 32.0);
+ ArmorStandModel armorStand = new ArmorStandModel(packetWrapper.user(), protocol, entityId);
+ armorStand.updateReplacementPosition(x / 32.0, y / 32.0, z / 32.0);
armorStand.setYawPitch(yaw * 360f / 256, pitch * 360f / 256);
armorStand.setHeadYaw(yaw * 360f / 256);
tracker.addEntityReplacement(armorStand);
@@ -167,7 +165,7 @@ public void register() {
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
Entity1_10Types.EntityType type = Entity1_10Types.getTypeFromId(typeId, true);
tracker.getClientEntityTypes().put(entityId, type);
- tracker.sendMetadataBuffer(entityId);
+// tracker.sendMetadataBuffer(entityId); TODO | ChecK?
int data = packetWrapper.get(Type.INT, 3);
@@ -220,17 +218,17 @@ public void register() {
packetWrapper.cancel();
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = null;
+ EntityModel replacement = null;
if (typeId == 30) {
- replacement = new ArmorStandReplacement(protocol, packetWrapper.user(), entityId);
+ replacement = new ArmorStandModel(packetWrapper.user(), protocol, entityId);
} else if (typeId == 68) {
- replacement = new GuardianReplacement(protocol, packetWrapper.user(), entityId);
+ replacement = new GuardianModel(packetWrapper.user(), protocol, entityId);
} else if (typeId == 67) {
- replacement = new EndermiteReplacement(protocol, packetWrapper.user(), entityId);
+ replacement = new EndermiteModel(packetWrapper.user(), protocol, entityId);
} else if (typeId == 101) {
- replacement = new RabbitReplacement(protocol, packetWrapper.user(), entityId);
+ replacement = new RabbitModel(packetWrapper.user(), protocol, entityId);
}
- replacement.setLocation(x / 32.0, y / 32.0, z / 32.0);
+ replacement.updateReplacementPosition(x / 32.0, y / 32.0, z / 32.0);
replacement.setYawPitch(yaw * 360f / 256, pitch * 360f / 256);
replacement.setHeadYaw(headYaw * 360f / 256);
tracker.addEntityReplacement(replacement);
@@ -243,7 +241,6 @@ public void register() {
int typeId = packetWrapper.get(Type.UNSIGNED_BYTE, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
tracker.getClientEntityTypes().put(entityId, Entity1_10Types.getTypeFromId(typeId, false));
- tracker.sendMetadataBuffer(entityId);
});
handler(wrapper -> {
List metadataList = wrapper.get(Types1_7_6_10.METADATA_LIST, 0);
@@ -273,10 +270,8 @@ public void register() {
});
map(Type.UNSIGNED_BYTE, Type.INT); //Rotation
handler(packetWrapper -> {
- int entityId = packetWrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- tracker.getClientEntityTypes().put(entityId, Entity1_10Types.EntityType.PAINTING);
- tracker.sendMetadataBuffer(entityId);
+ tracker.getClientEntityTypes().put(packetWrapper.get(Type.VAR_INT, 0), Entity1_10Types.EntityType.PAINTING);
});
}
});
@@ -290,10 +285,8 @@ public void register() {
map(Type.INT);
map(Type.SHORT);
handler(packetWrapper -> {
- int entityId = packetWrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- tracker.getClientEntityTypes().put(entityId, Entity1_10Types.EntityType.EXPERIENCE_ORB);
- tracker.sendMetadataBuffer(entityId);
+ tracker.getClientEntityTypes().put(packetWrapper.get(Type.VAR_INT, 0), Entity1_10Types.EntityType.EXPERIENCE_ORB);
});
}
});
@@ -307,10 +300,8 @@ public void register() {
map(Type.INT);
map(Type.INT);
handler(packetWrapper -> {
- int entityId = packetWrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- tracker.getClientEntityTypes().put(entityId, Entity1_10Types.EntityType.LIGHTNING);
- tracker.sendMetadataBuffer(entityId);
+ tracker.getClientEntityTypes().put(packetWrapper.get(Type.VAR_INT, 0), Entity1_10Types.EntityType.LIGHTNING);
});
}
});
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java
index b0bc873af..de8be462a 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java
@@ -18,7 +18,7 @@
package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.provider;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.CompressionSendStorage;
+import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.CompressionStatusTracker;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.platform.providers.Provider;
import io.netty.channel.ChannelHandler;
@@ -32,10 +32,10 @@ public abstract class CompressionHandlerProvider implements Provider {
public abstract ChannelHandler getDecoder(int threshold);
public boolean isCompressionEnabled(UserConnection user) {
- return user.get(CompressionSendStorage.class).removeCompression;
+ return user.get(CompressionStatusTracker.class).removeCompression;
}
public void setCompressionEnabled(UserConnection user, boolean enabled) {
- user.get(CompressionSendStorage.class).removeCompression = enabled;
+ user.get(CompressionStatusTracker.class).removeCompression = enabled;
}
}
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/rewriter/ReplacementItemRewriter1_7_6_10.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/rewriter/ReplacementItemRewriter1_7_6_10.java
index 44311607c..e1ead49c2 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/rewriter/ReplacementItemRewriter1_7_6_10.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/rewriter/ReplacementItemRewriter1_7_6_10.java
@@ -20,7 +20,7 @@
import com.viaversion.viarewind.api.rewriter.ReplacementItemRewriter;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
-import com.viaversion.viarewind.replacement.Replacement;
+import com.viaversion.viarewind.api.rewriter.Replacement;
import com.viaversion.viarewind.utils.ChatUtil;
import com.viaversion.viarewind.utils.Enchantments;
import com.viaversion.viaversion.api.minecraft.item.Item;
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionSendStorage.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionStatusTracker.java
similarity index 90%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionSendStorage.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionStatusTracker.java
index eb6e945e0..03ef8daf1 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionSendStorage.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionStatusTracker.java
@@ -24,10 +24,10 @@
/**
* @see com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.provider.CompressionHandlerProvider
*/
-public class CompressionSendStorage extends StoredObject {
+public class CompressionStatusTracker extends StoredObject {
public boolean removeCompression = false;
- public CompressionSendStorage(UserConnection user) {
+ public CompressionStatusTracker(UserConnection user) {
super(user);
}
}
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java
index 7d9aa7cc8..5930b2ce4 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java
@@ -19,8 +19,7 @@
package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage;
import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8;
-import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter;
-import com.viaversion.viarewind.replacement.EntityReplacement;
+import com.viaversion.viarewind.api.minecraft.EntityModel;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.connection.StoredObject;
import com.viaversion.viaversion.api.connection.UserConnection;
@@ -41,9 +40,8 @@
public class EntityTracker extends StoredObject implements ClientEntityIdChangeListener {
private final Protocol1_7_6_10To1_8 protocol;
private final Map clientEntityTypes = new ConcurrentHashMap<>();
- private final Map> metadataBuffer = new ConcurrentHashMap<>();
private final Map vehicles = new ConcurrentHashMap<>();
- private final Map entityReplacements = new ConcurrentHashMap<>();
+ private final Map entityReplacements = new ConcurrentHashMap<>();
private final Map playersByEntityId = new HashMap<>();
private final Map playersByUniqueId = new HashMap<>();
private final Map playerEquipment = new HashMap<>();
@@ -60,7 +58,7 @@ public EntityTracker(UserConnection user, Protocol1_7_6_10To1_8 protocol) {
public void removeEntity(int entityId) {
clientEntityTypes.remove(entityId);
if (entityReplacements.containsKey(entityId)) {
- entityReplacements.remove(entityId).despawn();
+ entityReplacements.remove(entityId).deleteEntity();
}
if (playersByEntityId.containsKey(entityId)) {
UUID playerId = playersByEntityId.remove(entityId);
@@ -99,44 +97,14 @@ public Map getClientEntityTypes() {
return this.clientEntityTypes;
}
- public void addMetadataToBuffer(int entityID, List metadataList) {
- if (this.metadataBuffer.containsKey(entityID)) {
- this.metadataBuffer.get(entityID).addAll(metadataList);
- } else if (!metadataList.isEmpty()) {
- this.metadataBuffer.put(entityID, metadataList);
- }
- }
-
- public void addEntityReplacement(EntityReplacement entityReplacement) {
- entityReplacements.put(entityReplacement.getEntityId(), entityReplacement);
+ public void addEntityReplacement(EntityModel entityModel) {
+ entityReplacements.put(entityModel.getEntityId(), entityModel);
}
- public EntityReplacement getEntityReplacement(int entityId) {
+ public EntityModel getEntityReplacement(int entityId) {
return entityReplacements.get(entityId);
}
- public List getBufferedMetadata(int entityId) {
- return metadataBuffer.get(entityId);
- }
-
- public void sendMetadataBuffer(int entityId) {
- if (!this.metadataBuffer.containsKey(entityId)) return;
- if (entityReplacements.containsKey(entityId)) {
- entityReplacements.get(entityId).updateMetadata(this.metadataBuffer.remove(entityId));
- } else {
- Entity1_10Types.EntityType type = this.getClientEntityTypes().get(entityId);
- PacketWrapper wrapper = PacketWrapper.create(0x1C, null, this.getUser());
- wrapper.write(Type.VAR_INT, entityId);
- wrapper.write(Types1_8.METADATA_LIST, this.metadataBuffer.get(entityId));
- protocol.getMetadataRewriter().transform(type, this.metadataBuffer.get(entityId));
- if (!this.metadataBuffer.get(entityId).isEmpty()) {
- PacketUtil.sendPacket(wrapper, Protocol1_7_6_10To1_8.class);
- }
-
- this.metadataBuffer.remove(entityId);
- }
- }
-
public int getVehicle(int passengerId) {
for (Map.Entry vehicle : vehicles.entrySet()) {
if (vehicle.getValue() == passengerId) return vehicle.getValue();
@@ -239,7 +207,6 @@ public void clearEntities() {
clientEntityTypes.clear();
entityReplacements.clear();
vehicles.clear();
- metadataBuffer.clear();
}
public int getDimension() {
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilities.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilitiesTracker.java
similarity index 93%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilities.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilitiesTracker.java
index 751dd0743..37e691206 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilities.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilitiesTracker.java
@@ -21,11 +21,11 @@
import com.viaversion.viaversion.api.connection.StoredObject;
import com.viaversion.viaversion.api.connection.UserConnection;
-public class PlayerAbilities extends StoredObject {
+public class PlayerAbilitiesTracker extends StoredObject {
private boolean sprinting, allowFly, flying, invincible, creative;
private float flySpeed, walkSpeed;
- public PlayerAbilities(UserConnection user) {
+ public PlayerAbilitiesTracker(UserConnection user) {
super(user);
}
@@ -96,9 +96,9 @@ public void setWalkSpeed(float walkSpeed) {
public boolean equals(final Object o) {
if (o == this) return true;
- if (!(o instanceof PlayerAbilities))
+ if (!(o instanceof PlayerAbilitiesTracker))
return false;
- final PlayerAbilities other = (PlayerAbilities) o;
+ final PlayerAbilitiesTracker other = (PlayerAbilitiesTracker) o;
if (!other.canEqual(this)) return false;
if (this.isSprinting() != other.isSprinting()) return false;
if (this.isAllowFly() != other.isAllowFly()) return false;
@@ -110,7 +110,7 @@ public boolean equals(final Object o) {
}
protected boolean canEqual(final Object other) {
- return other instanceof PlayerAbilities;
+ return other instanceof PlayerAbilitiesTracker;
}
public int hashCode() {
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPosition.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPositionTracker.java
similarity index 95%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPosition.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPositionTracker.java
index b33d0f7b3..8bd2a1158 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPosition.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPositionTracker.java
@@ -21,14 +21,14 @@
import com.viaversion.viaversion.api.connection.StoredObject;
import com.viaversion.viaversion.api.connection.UserConnection;
-public class PlayerPosition extends StoredObject {
+public class PlayerPositionTracker extends StoredObject {
private double posX, posY, posZ;
private float yaw, pitch;
private boolean onGround;
private boolean positionPacketReceived;
private double receivedPosY;
- public PlayerPosition(UserConnection user) {
+ public PlayerPositionTracker(UserConnection user) {
super(user);
}
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java
index 32ffd2680..1e2f158e9 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java
@@ -45,10 +45,9 @@ public void remove(short windowId) {
public static int getInventoryType(String name) {
switch (name) {
case "minecraft:container":
- return 0;
- case "minecraft:chest":
- return 0;
- case "minecraft:crafting_table":
+ case "minecraft:chest":
+ return 0;
+ case "minecraft:crafting_table":
return 1;
case "minecraft:furnace":
return 2;
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java
index 14ff9193a..59c5e4a29 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java
@@ -50,7 +50,7 @@ public void tick() {
}
private void sendPackets() {
- PlayerPosition position = getUser().get(PlayerPosition.class);
+ PlayerPositionTracker position = getUser().get(PlayerPositionTracker.class);
double radius = getSize() / 2.0;
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityReplacement1_8to1_9.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityModel1_8To1_9.java
similarity index 87%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityReplacement1_8to1_9.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityModel1_8To1_9.java
index 77c53cbc6..386cb14e0 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityReplacement1_8to1_9.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityModel1_8To1_9.java
@@ -19,10 +19,11 @@
package com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
-import com.viaversion.viarewind.replacement.EntityReplacement;
+import com.viaversion.viarewind.api.minecraft.EntityModel;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
+import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_8;
@@ -31,21 +32,18 @@
import java.util.ArrayList;
import java.util.List;
-public abstract class EntityReplacement1_8to1_9 implements EntityReplacement {
- protected final Protocol1_8To1_9 protocol;
- protected final UserConnection user;
+public abstract class EntityModel1_8To1_9 extends EntityModel {
- protected EntityReplacement1_8to1_9(Protocol1_8To1_9 protocol, UserConnection user) {
- this.protocol = protocol;
- this.user = user;
+ public EntityModel1_8To1_9(UserConnection user, Protocol1_8To1_9 protocol) {
+ super(user, protocol);
}
protected void sendTeleportWithHead(int entityId, double locX, double locY, double locZ, float yaw, float pitch, float headYaw) {
- sendTeleport(entityId, locX, locY, locZ, yaw, pitch);
+ teleportEntity(entityId, locX, locY, locZ, yaw, pitch);
sendHeadYaw(entityId, headYaw);
}
- protected void sendTeleport(int entityId, double locX, double locY, double locZ, float yaw, float pitch) {
+ protected void teleportEntity(int entityId, double locX, double locY, double locZ, float yaw, float pitch) {
PacketWrapper teleport = PacketWrapper.create(ClientboundPackets1_8.ENTITY_TELEPORT, null, user);
teleport.write(Type.VAR_INT, entityId);
teleport.write(Type.INT, (int) (locX * 32.0));
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletModel.java
similarity index 86%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletReplacement.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletModel.java
index 63df58af1..1fbcedd43 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletReplacement.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletModel.java
@@ -29,21 +29,21 @@
import java.util.ArrayList;
import java.util.List;
-public class ShulkerBulletReplacement extends EntityReplacement1_8to1_9 {
+public class ShulkerBulletModel extends EntityModel1_8To1_9 {
private final int entityId;
private final List datawatcher = new ArrayList<>();
private double locX, locY, locZ;
private float yaw, pitch;
private float headYaw;
- public ShulkerBulletReplacement(Protocol1_8To1_9 protocol, UserConnection user, int entityId) {
- super(protocol, user);
+ public ShulkerBulletModel(UserConnection user, Protocol1_8To1_9 protocol, int entityId) {
+ super(user, protocol);
this.entityId = entityId;
- spawn();
+ sendSpawnPacket();
}
@Override
- public void setLocation(double x, double y, double z) {
+ public void updateReplacementPosition(double x, double y, double z) {
if (x != this.locX || y != this.locY || z != this.locZ) {
this.locX = x;
this.locY = y;
@@ -53,7 +53,7 @@ public void setLocation(double x, double y, double z) {
}
@Override
- public void relMove(double x, double y, double z) {
+ public void handleOriginalMovementPacket(double x, double y, double z) {
if (x == 0.0 && y == 0.0 && z == 0.0) return;
this.locX += x;
this.locY += y;
@@ -84,12 +84,12 @@ public void updateLocation() {
}
@Override
- public void spawn() {
+ public void sendSpawnPacket() {
sendSpawnEntity(entityId, 66);
}
@Override
- public void despawn() {
+ public void deleteEntity() {
PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_8.DESTROY_ENTITIES, null, user);
despawn.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{entityId});
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerModel.java
similarity index 85%
rename from common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerReplacement.java
rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerModel.java
index 111047898..2368fe335 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerReplacement.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerModel.java
@@ -20,7 +20,6 @@
import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.ClientboundPackets1_7_2_5;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
-import com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types;
@@ -34,19 +33,19 @@
import java.util.ArrayList;
import java.util.List;
-public class ShulkerReplacement extends EntityReplacement1_8to1_9 {
+public class ShulkerModel extends EntityModel1_8To1_9 {
private final int entityId;
private final List datawatcher = new ArrayList<>();
private double locX, locY, locZ;
- public ShulkerReplacement(Protocol1_8To1_9 protocol, UserConnection user, int entityId) {
- super(protocol, user);
+ public ShulkerModel(UserConnection user, Protocol1_8To1_9 protocol, int entityId) {
+ super(user, protocol);
this.entityId = entityId;
- spawn();
+ sendSpawnPacket();
}
@Override
- public void setLocation(double x, double y, double z) {
+ public void updateReplacementPosition(double x, double y, double z) {
this.locX = x;
this.locY = y;
this.locZ = z;
@@ -54,7 +53,7 @@ public void setLocation(double x, double y, double z) {
}
@Override
- public void relMove(double x, double y, double z) {
+ public void handleOriginalMovementPacket(double x, double y, double z) {
this.locX += x;
this.locY += y;
this.locZ += z;
@@ -79,7 +78,7 @@ public void updateMetadata(List metadataList) {
}
public void updateLocation() {
- sendTeleport(entityId, locX, locY, locZ, 0, 0);
+ teleportEntity(entityId, locX, locY, locZ, 0, 0);
}
public void updateMetadata() {
@@ -93,7 +92,7 @@ public void updateMetadata() {
}
metadataList.add(new Metadata(11, MetaType1_9.VarInt, 2));
- protocol.getMetadataRewriter().transform(Entity1_10Types.EntityType.MAGMA_CUBE, metadataList);
+ getProtocol().getMetadataRewriter().transform(Entity1_10Types.EntityType.MAGMA_CUBE, metadataList);
metadataPacket.write(Types1_8.METADATA_LIST, metadataList);
@@ -101,13 +100,13 @@ public void updateMetadata() {
}
@Override
- public void spawn() {
+ public void sendSpawnPacket() {
sendSpawn(entityId, 62);
// Old clients don't like empty metadata
}
@Override
- public void despawn() {
+ public void deleteEntity() {
PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7_2_5.DESTROY_ENTITIES, null, user);
despawn.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{entityId});
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java
index 6ef7a7004..0faa81f54 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java
@@ -19,27 +19,23 @@
package com.viaversion.viarewind.protocol.protocol1_8to1_9.packets;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
-import com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.Cooldown;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.EntityTracker;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.Levitation;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.PlayerPosition;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.util.RelativeMoveUtil;
-import com.viaversion.viarewind.replacement.EntityReplacement;
+import com.viaversion.viarewind.api.minecraft.EntityModel;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.minecraft.Vector;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
-import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_8;
import com.viaversion.viaversion.api.type.types.version.Types1_9;
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
-import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
-import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
import com.viaversion.viaversion.util.Pair;
import java.util.ArrayList;
@@ -76,10 +72,10 @@ public void register() {
int relZ = packetWrapper.read(Type.SHORT);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
- replacement.relMove(relX / 4096.0, relY / 4096.0, relZ / 4096.0);
+ replacement.handleOriginalMovementPacket(relX / 4096.0, relY / 4096.0, relZ / 4096.0);
return;
}
@@ -117,10 +113,10 @@ public void register() {
int relZ = packetWrapper.read(Type.SHORT);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
- replacement.relMove(relX / 4096.0, relY / 4096.0, relZ / 4096.0);
+ replacement.handleOriginalMovementPacket(relX / 4096.0, relY / 4096.0, relZ / 4096.0);
replacement.setYawPitch(packetWrapper.read(Type.BYTE) * 360f / 256, packetWrapper.read(Type.BYTE) * 360f / 256);
return;
}
@@ -168,7 +164,7 @@ public void register() {
handler(packetWrapper -> {
int entityId = packetWrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
int yaw = packetWrapper.get(Type.BYTE, 0);
@@ -272,7 +268,7 @@ public void register() {
handler(packetWrapper -> {
int entityId = packetWrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
int yaw = packetWrapper.get(Type.BYTE, 0);
@@ -402,7 +398,7 @@ public void register() {
handler(packetWrapper -> {
int entityId = packetWrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- EntityReplacement replacement = tracker.getEntityReplacement(entityId);
+ EntityModel replacement = tracker.getEntityReplacement(entityId);
if (replacement != null) {
packetWrapper.cancel();
int x = packetWrapper.get(Type.INT, 0);
@@ -410,7 +406,7 @@ public void register() {
int z = packetWrapper.get(Type.INT, 2);
int yaw = packetWrapper.get(Type.BYTE, 0);
int pitch = packetWrapper.get(Type.BYTE, 1);
- replacement.setLocation(x / 32.0, y / 32.0, z / 32.0);
+ replacement.updateReplacementPosition(x / 32.0, y / 32.0, z / 32.0);
replacement.setYawPitch(yaw * 360f / 256, pitch * 360f / 256);
}
});
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java
index 771d835a2..8a59eda6a 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java
@@ -20,12 +20,11 @@
import com.viaversion.viarewind.ViaRewind;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
-import com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement.ShulkerBulletReplacement;
-import com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement.ShulkerReplacement;
-import com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter;
+import com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement.ShulkerBulletModel;
+import com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement.ShulkerModel;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.EntityTracker;
-import com.viaversion.viarewind.replacement.EntityReplacement;
-import com.viaversion.viarewind.replacement.Replacement;
+import com.viaversion.viarewind.api.minecraft.EntityModel;
+import com.viaversion.viarewind.api.rewriter.Replacement;
import com.viaversion.viarewind.utils.PacketUtil;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
@@ -84,8 +83,8 @@ public void register() {
packetWrapper.set(Type.INT, 1, y);
} else if (type.is(Entity1_10Types.EntityType.SHULKER_BULLET)) {
packetWrapper.cancel();
- ShulkerBulletReplacement shulkerBulletReplacement = new ShulkerBulletReplacement(protocol, packetWrapper.user(), entityId);
- shulkerBulletReplacement.setLocation(x / 32.0, y / 32.0, z / 32.0);
+ ShulkerBulletModel shulkerBulletReplacement = new ShulkerBulletModel(packetWrapper.user(), protocol, entityId);
+ shulkerBulletReplacement.updateReplacementPosition(x / 32.0, y / 32.0, z / 32.0);
tracker.addEntityReplacement(shulkerBulletReplacement);
return;
}
@@ -193,8 +192,8 @@ public void register() {
if (typeId == 69) {
packetWrapper.cancel();
EntityTracker tracker = packetWrapper.user().get(EntityTracker.class);
- ShulkerReplacement shulkerReplacement = new ShulkerReplacement(protocol, packetWrapper.user(), entityId);
- shulkerReplacement.setLocation(x / 32.0, y / 32.0, z / 32.0);
+ ShulkerModel shulkerReplacement = new ShulkerModel(packetWrapper.user(), protocol, entityId);
+ shulkerReplacement.updateReplacementPosition(x / 32.0, y / 32.0, z / 32.0);
shulkerReplacement.setYawPitch(yaw * 360f / 256, pitch * 360f / 256);
shulkerReplacement.setHeadYaw(headYaw * 360f / 256);
tracker.addEntityReplacement(shulkerReplacement);
@@ -213,7 +212,7 @@ public void register() {
List metadataList = wrapper.get(Types1_8.METADATA_LIST, 0);
int entityId = wrapper.get(Type.VAR_INT, 0);
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
- EntityReplacement replacement;
+ EntityModel replacement;
if ((replacement = tracker.getEntityReplacement(entityId)) != null) {
replacement.updateMetadata(metadataList);
} else if (tracker.getClientEntityTypes().containsKey(entityId)) {
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/rewriter/ReplacementItemRewriter1_8.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/rewriter/ReplacementItemRewriter1_8.java
index f2fd21171..aab55d53c 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/rewriter/ReplacementItemRewriter1_8.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/rewriter/ReplacementItemRewriter1_8.java
@@ -19,7 +19,7 @@
package com.viaversion.viarewind.protocol.protocol1_8to1_9.rewriter;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
-import com.viaversion.viarewind.replacement.Replacement;
+import com.viaversion.viarewind.api.rewriter.Replacement;
import com.viaversion.viarewind.api.rewriter.ReplacementItemRewriter;
import com.viaversion.viarewind.utils.Enchantments;
import com.viaversion.viaversion.api.minecraft.item.Item;
@@ -178,8 +178,8 @@ public Item handleItemToClient(Item item) {
CompoundTag entityTag = tag.get("EntityTag");
if (entityTag.contains("id")) {
StringTag id = entityTag.get("id");
- if (ItemRewriter.ENTTIY_NAME_TO_ID.containsKey(id.getValue())) {
- data = ItemRewriter.ENTTIY_NAME_TO_ID.get(id.getValue());
+ if (ItemRewriter.ENTITY_NAME_TO_ID.containsKey(id.getValue())) {
+ data = ItemRewriter.ENTITY_NAME_TO_ID.get(id.getValue());
} else if (display == null) {
tag.put("display", display = new CompoundTag());
viaVersionTag.put("noDisplay", new ByteTag());
@@ -248,9 +248,9 @@ public Item handleItemToServer(Item item) {
if (item.identifier() == 383 && item.data() != 0) {
if (tag == null) item.setTag(tag = new CompoundTag());
- if (!tag.contains("EntityTag") && ItemRewriter.ENTTIY_ID_TO_NAME.containsKey((int) item.data())) {
+ if (!tag.contains("EntityTag") && ItemRewriter.ENTITY_ID_TO_NAME.containsKey((int) item.data())) {
CompoundTag entityTag = new CompoundTag();
- entityTag.put("id", new StringTag(ItemRewriter.ENTTIY_ID_TO_NAME.get((int) item.data())));
+ entityTag.put("id", new StringTag(ItemRewriter.ENTITY_ID_TO_NAME.get((int) item.data())));
tag.put("EntityTag", entityTag);
}
diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java
index af6e56e77..06019a69e 100644
--- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java
+++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java
@@ -19,8 +19,7 @@
package com.viaversion.viarewind.protocol.protocol1_8to1_9.storage;
import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9;
-import com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter;
-import com.viaversion.viarewind.replacement.EntityReplacement;
+import com.viaversion.viarewind.api.minecraft.EntityModel;
import com.viaversion.viaversion.api.connection.StoredObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.entity.ClientEntityIdChangeListener;
@@ -42,7 +41,7 @@ public class EntityTracker extends StoredObject implements ClientEntityIdChangeL
private final Map> vehicleMap = new ConcurrentHashMap<>();
private final Map clientEntityTypes = new ConcurrentHashMap<>();
private final Map> metadataBuffer = new ConcurrentHashMap<>();
- private final Map entityReplacements = new ConcurrentHashMap<>();
+ private final Map entityReplacements = new ConcurrentHashMap<>();
private final Map entityOffsets = new ConcurrentHashMap<>();
private int playerId;
private int playerGamemode = 0;
@@ -76,7 +75,7 @@ public void removeEntity(int entityId) {
clientEntityTypes.remove(entityId);
entityOffsets.remove(entityId);
if (entityReplacements.containsKey(entityId)) {
- entityReplacements.remove(entityId).despawn();
+ entityReplacements.remove(entityId).deleteEntity();
}
}
@@ -114,11 +113,11 @@ public void setPassengers(int entityId, List passengers) {
vehicleMap.put(entityId, passengers);
}
- public void addEntityReplacement(EntityReplacement entityReplacement) {
- entityReplacements.put(entityReplacement.getEntityId(), entityReplacement);
+ public void addEntityReplacement(EntityModel entityModel) {
+ entityReplacements.put(entityModel.getEntityId(), entityModel);
}
- public EntityReplacement getEntityReplacement(int entityId) {
+ public EntityModel getEntityReplacement(int entityId) {
return entityReplacements.get(entityId);
}
diff --git a/common/src/main/java/com/viaversion/viarewind/replacement/EntityReplacement.java b/common/src/main/java/com/viaversion/viarewind/replacement/EntityReplacement.java
deleted file mode 100644
index 24abf0363..000000000
--- a/common/src/main/java/com/viaversion/viarewind/replacement/EntityReplacement.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind
- * Copyright (C) 2016-2023 ViaVersion and contributors
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.viaversion.viarewind.replacement;
-
-import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
-
-import java.util.List;
-
-public interface EntityReplacement {
-
- int getEntityId();
-
- void setLocation(double x, double y, double z);
-
- void relMove(double x, double y, double z);
-
- void setYawPitch(float yaw, float pitch);
-
- void setHeadYaw(float yaw);
-
- void spawn();
-
- void despawn();
-
- void updateMetadata(List metadataList);
-}