Skip to content

Commit

Permalink
Merge pull request #448 from ViaVersion/master
Browse files Browse the repository at this point in the history
Upstream master changes into dev
  • Loading branch information
FlorianMichael authored Aug 14, 2023
2 parents 197f7b2 + cd8306a commit 8856ed4
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 136 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 11
- name: Build with Maven
run: mvn install
- uses: actions/upload-artifact@v3
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: artifact
path: all/target

2 changes: 1 addition & 1 deletion all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.viaversion</groupId>
<artifactId>viarewind-parent</artifactId>
<version>2.0.3</version>
<version>2.0.4-SNAPSHOT</version>
</parent>

<artifactId>viarewind-all</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.viaversion</groupId>
<artifactId>viarewind-parent</artifactId>
<version>2.0.3</version>
<version>2.0.4-SNAPSHOT</version>
</parent>

<artifactId>viarewind-bukkit</artifactId>
Expand Down
1 change: 1 addition & 0 deletions bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: ViaRewind
version: ${project.version}
main: de.gerrygames.viarewind.BukkitPlugin
api-version: 1.13
folia-supported: true

authors: [Gerrygames]
website: https://viaversion.com/rewind
Expand Down
2 changes: 1 addition & 1 deletion bungee/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.viaversion</groupId>
<artifactId>viarewind-parent</artifactId>
<version>2.0.3</version>
<version>2.0.4-SNAPSHOT</version>
</parent>

<artifactId>viarewind-bungee</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.viaversion</groupId>
<artifactId>viarewind-parent</artifactId>
<version>2.0.3</version>
<version>2.0.4-SNAPSHOT</version>
</parent>

<artifactId>viarewind-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import de.gerrygames.viarewind.ViaRewind;
import de.gerrygames.viarewind.protocol.protocol1_7_0_5to1_7_6_10.Protocol1_7_0_5to1_7_6_10;
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8;
import de.gerrygames.viarewind.protocol.protocol1_7_6to1_7_2.Protocol1_7_6to1_7_2;
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9;

import java.util.logging.Logger;
Expand All @@ -20,8 +19,6 @@ default void init(ViaRewindConfig config) {
Via.getManager().getProtocolManager().registerProtocol(new Protocol1_8TO1_9(), ProtocolVersion.v1_8, ProtocolVersion.v1_9);
Via.getManager().getProtocolManager().registerProtocol(new Protocol1_7_6_10TO1_8(), ProtocolVersion.v1_7_6, ProtocolVersion.v1_8);
Via.getManager().getProtocolManager().registerProtocol(new Protocol1_7_0_5to1_7_6_10(), ProtocolVersion.v1_7_1, ProtocolVersion.v1_7_6);

Via.getManager().getProtocolManager().registerProtocol(new Protocol1_7_6to1_7_2(), ProtocolVersion.v1_7_6, ProtocolVersion.v1_7_1);
}

Logger getLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setLocation(double x, double y, double z) {
this.locX = x;
this.locY = y;
this.locZ = z;
updateLocation();
updateLocation(false);
}
}

Expand All @@ -59,22 +59,22 @@ public void relMove(double x, double y, double z) {
this.locX += x;
this.locY += y;
this.locZ += z;
updateLocation();
updateLocation(false);
}

public void setYawPitch(float yaw, float pitch) {
if (this.yaw != yaw && this.pitch != pitch || this.headYaw != yaw) {
this.yaw = yaw;
this.headYaw = yaw;
this.pitch = pitch;
updateLocation();
updateLocation(false);
}
}

public void setHeadYaw(float yaw) {
if (this.headYaw != yaw) {
this.headYaw = yaw;
updateLocation();
updateLocation(false);
}
}

Expand Down Expand Up @@ -106,7 +106,7 @@ public void updateState() {
marker = (armorStandFlags & 0x10) != 0;

State prevState = currentState;
if (invisible && name != null) {
if (invisible && marker) {
currentState = State.HOLOGRAM;
} else {
currentState = State.ZOMBIE;
Expand All @@ -117,40 +117,45 @@ public void updateState() {
spawn();
} else {
updateMetadata();
updateLocation();
updateLocation(false);
}
}

public void updateLocation() {
public void updateLocation(boolean remount) {
if (entityIds == null) return;

if (currentState == State.ZOMBIE) {
updateZombieLocation();
} else if (currentState == State.HOLOGRAM) {
updateHologramLocation();
updateHologramLocation(remount);
}
}

private void updateZombieLocation() {
sendTeleportWithHead(entityId, locX, locY, locZ, yaw, pitch, headYaw);
}

private void updateHologramLocation() {
PacketWrapper detach = PacketWrapper.create(ClientboundPackets1_7.ATTACH_ENTITY, null, user);
detach.write(Type.INT, entityIds[1]);
detach.write(Type.INT, -1);
detach.write(Type.BOOLEAN, false);
PacketUtil.sendPacket(detach, Protocol1_7_6_10TO1_8.class, true, true);
private void updateHologramLocation(boolean remount) {
if(remount) {
PacketWrapper detach = PacketWrapper.create(ClientboundPackets1_7.ATTACH_ENTITY, null, user);
detach.write(Type.INT, entityIds[1]);
detach.write(Type.INT, -1);
detach.write(Type.BOOLEAN, false);
PacketUtil.sendPacket(detach, Protocol1_7_6_10TO1_8.class, true, true);
}

// 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
sendTeleport(entityIds[1], locX, locY + 56.75, locZ, 0, 0); // Horse

PacketWrapper attach = PacketWrapper.create(ClientboundPackets1_7.ATTACH_ENTITY, null, user);
attach.write(Type.INT, entityIds[1]);
attach.write(Type.INT, entityIds[0]);
attach.write(Type.BOOLEAN, false);
PacketUtil.sendPacket(attach, Protocol1_7_6_10TO1_8.class, true, true);
if(remount) {
sendTeleport(entityIds[1], locX, locY + 56.75, locZ, 0, 0); // Horse

PacketWrapper attach = PacketWrapper.create(ClientboundPackets1_7.ATTACH_ENTITY, null, user);
attach.write(Type.INT, entityIds[1]);
attach.write(Type.INT, entityIds[0]);
attach.write(Type.BOOLEAN, false);
PacketUtil.sendPacket(attach, Protocol1_7_6_10TO1_8.class, true, true);
}
}

public void updateMetadata() {
Expand Down Expand Up @@ -204,7 +209,7 @@ public void spawn() {
}

updateMetadata();
updateLocation();
updateLocation(true);
}

private void spawnZombie() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,6 @@ public void register() {
}
});

protocol.registerServerbound(ServerboundPackets1_7.WINDOW_CONFIRMATION, new PacketHandlers() {
@Override
public void register() {
map(Type.UNSIGNED_BYTE);
map(Type.SHORT);
map(Type.BOOLEAN);
handler(packetWrapper -> {
int action = packetWrapper.get(Type.SHORT, 0);
if (action == -89) packetWrapper.cancel();
});
}
});

//Creative Inventory Action
protocol.registerServerbound(ServerboundPackets1_7.CREATIVE_INVENTORY_ACTION, new PacketHandlers() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,6 @@ public void register() {

PlayerPosition playerPosition = packetWrapper.user().get(PlayerPosition.class);

if (playerPosition.isPositionPacketReceived()) {
playerPosition.setPositionPacketReceived(false);
feetY -= 0.01;
packetWrapper.set(Type.DOUBLE, 1, feetY);
}

playerPosition.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
playerPosition.setPos(x, feetY, z);
});
Expand Down Expand Up @@ -666,12 +660,6 @@ public void register() {

PlayerPosition playerPosition = packetWrapper.user().get(PlayerPosition.class);

if (playerPosition.isPositionPacketReceived()) {
playerPosition.setPositionPacketReceived(false);
feetY = playerPosition.getReceivedPosY();
packetWrapper.set(Type.DOUBLE, 1, feetY);
}

playerPosition.setOnGround(packetWrapper.get(Type.BOOLEAN, 0));
playerPosition.setPos(x, feetY, z);
playerPosition.setYaw(yaw);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.*;
import de.gerrygames.viarewind.utils.Ticker;

import java.util.HashSet;
import java.util.Set;
import java.util.Timer;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;

public class Protocol1_8TO1_9 extends AbstractProtocol<ClientboundPackets1_9, ClientboundPackets1_8,
ServerboundPackets1_9, ServerboundPackets1_8> {
public static final Timer TIMER = new Timer("ViaRewind-1_8TO1_9", true);

public Queue<PacketWrapper> animationsToSend = new ConcurrentLinkedQueue<>();

public static final Set<String> VALID_ATTRIBUTES = new HashSet<>();
public static final ValueTransformer<Double, Integer> TO_OLD_INT = new ValueTransformer<Double, Integer>(Type.INT) {
public Integer transform(PacketWrapper wrapper, Double inputValue) {
Expand Down
Loading

0 comments on commit 8856ed4

Please sign in to comment.