Add #setLocation implementation

This commit is contained in:
Flowsqy 2021-12-28 23:01:09 +01:00
parent 5123409626
commit d3079f6fd1
2 changed files with 19 additions and 7 deletions

View File

@ -9,10 +9,10 @@ public interface FakeArmorStand {
void sendData(String name, Iterable<Player> receivers); void sendData(String name, Iterable<Player> receivers);
void remove(); void remove(Iterable<Player> receivers);
void setLocation(Location location); void setLocation(Location location, Iterable<Player> receivers);
void spawn(); void spawn(Iterable<Player> receivers);
} }

View File

@ -1,11 +1,14 @@
package de.epiceric.shopchest.nms.v1_17_R1; package de.epiceric.shopchest.nms.v1_17_R1;
import de.epiceric.shopchest.nms.FakeArmorStand; import de.epiceric.shopchest.nms.FakeArmorStand;
import io.netty.buffer.Unpooled;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.chat.ComponentSerializer; import net.md_5.bungee.chat.ComponentSerializer;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; 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.EntityDataAccessor;
import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -103,17 +106,26 @@ public class FakeArmorStandImpl implements FakeArmorStand {
} }
@Override @Override
public void remove() { public void remove(Iterable<Player> receivers) {
} }
@Override @Override
public void setLocation(Location location) { public void setLocation(Location location, Iterable<Player> 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 @Override
public void spawn() { public void spawn(Iterable<Player> receivers) {
} }
} }