From d3079f6fd141a77bab6aa4e28102d9983abb6217 Mon Sep 17 00:00:00 2001 From: Flowsqy <47575244+Flowsqy@users.noreply.github.com> Date: Tue, 28 Dec 2021 23:01:09 +0100 Subject: [PATCH] Add #setLocation implementation --- .../shopchest/nms/FakeArmorStand.java | 6 +++--- .../nms/v1_17_R1/FakeArmorStandImpl.java | 20 +++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/nms/interface/src/main/java/de/epiceric/shopchest/nms/FakeArmorStand.java b/nms/interface/src/main/java/de/epiceric/shopchest/nms/FakeArmorStand.java index 2b242dd..4674d1d 100644 --- a/nms/interface/src/main/java/de/epiceric/shopchest/nms/FakeArmorStand.java +++ b/nms/interface/src/main/java/de/epiceric/shopchest/nms/FakeArmorStand.java @@ -9,10 +9,10 @@ public interface FakeArmorStand { void sendData(String name, Iterable receivers); - void remove(); + void remove(Iterable receivers); - void setLocation(Location location); + void setLocation(Location location, Iterable receivers); - void spawn(); + void spawn(Iterable receivers); } diff --git a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java index 333715f..55f0fe7 100644 --- a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java +++ b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java @@ -1,11 +1,14 @@ package de.epiceric.shopchest.nms.v1_17_R1; import de.epiceric.shopchest.nms.FakeArmorStand; +import io.netty.buffer.Unpooled; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.chat.ComponentSerializer; +import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; +import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.Entity; @@ -103,17 +106,26 @@ public class FakeArmorStandImpl implements FakeArmorStand { } @Override - public void remove() { + public void remove(Iterable receivers) { } @Override - public void setLocation(Location location) { - + public void setLocation(Location location, Iterable receivers) { + final FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer()); + buffer.writeVarInt(entityId); + buffer.writeDouble(location.getX()); + buffer.writeDouble(location.getY() + 1.975); + buffer.writeDouble(location.getZ()); + buffer.writeByte(0); + buffer.writeByte(0); + buffer.writeBoolean(false); + final ClientboundTeleportEntityPacket positionPacket = new ClientboundTeleportEntityPacket(buffer); + sendPacket(positionPacket, receivers); } @Override - public void spawn() { + public void spawn(Iterable receivers) { } }