/* * This file is a part of the SteamWar software. * * Copyright (C) 2021 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ package de.steamwar.bausystem.entities; import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.bausystem.shared.BaseArmorStand19; import net.minecraft.network.chat.IChatMutableComponent; import net.minecraft.network.chat.contents.LiteralContents; import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; import net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport; import net.minecraft.server.network.PlayerConnection; import org.bukkit.World; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.util.Vector; public class WarpEntity19 extends BaseArmorStand19 implements AbstractWarpEntity { public WarpEntity19(World world, Vector position, String name) { super(world, position); this.j(true); this.a(true); setName(name); this.e(true); this.S = -12000; } @Override public void display(Player player) { sendEntity(player); } @Override public void setName(String name) { this.n(true); this.b(IChatMutableComponent.a(new LiteralContents(name))); } @Override public boolean hide(Player player) { sendEntityDestroy(player); ag(); return true; } @Override public void sendMetaData(Player player) { PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; playerConnection.a(packetPlayOutEntityMetadata); } @Override public void teleport(Player player, Vector position) { setPosRaw(position.getX(), position.getY(), position.getZ(), false); PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this); ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityTeleport); } @Override public Vector getPosition() { return new Vector(df(), dh(), dj()); } }