From 69c965d80789013adef1215dc5c0befd664be5d0 Mon Sep 17 00:00:00 2001 From: NK Date: Thu, 22 Dec 2022 23:46:07 +0000 Subject: [PATCH] npcs + miners 1.19.3 --- .../entities/miners/CryptoMiner.java | 23 ++++++++++--------- .../events/custom/RightClickNPCEvent.java | 10 ++++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/me/night/nullvalkyrie/entities/miners/CryptoMiner.java b/src/main/java/me/night/nullvalkyrie/entities/miners/CryptoMiner.java index 34cf819..10befb8 100644 --- a/src/main/java/me/night/nullvalkyrie/entities/miners/CryptoMiner.java +++ b/src/main/java/me/night/nullvalkyrie/entities/miners/CryptoMiner.java @@ -6,18 +6,19 @@ import com.mojang.authlib.properties.Property; import me.night.nullvalkyrie.enums.MinerType; import me.night.nullvalkyrie.util.Skin; import me.night.nullvalkyrie.util.Util; -import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo; +import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.EntityPlayer; -import net.minecraft.server.level.WorldServer; -import net.minecraft.server.network.PlayerConnection; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.ServerGamePacketListenerImpl; import org.apache.commons.codec.binary.Base64; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_19_R1.CraftServer; -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R2.CraftServer; +import org.bukkit.craftbukkit.v1_19_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -137,11 +138,11 @@ public class CryptoMiner { String[] skin = Skin.getSkin("Shiba_"); gameProfile.getProperties().put("textures", new Property("textures", skin[0], skin[1])); MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer(); - WorldServer w = ((CraftWorld) player.getLocation().getWorld()).getHandle(); - EntityPlayer miner = new EntityPlayer(server, w, gameProfile, null); - // TODO: how to make a armor stand turn - PlayerConnection pc = ((org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer) player).getHandle().b; - pc.a(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a, miner)); + ServerLevel w = ((CraftWorld) player.getLocation().getWorld()).getHandle(); + ServerPlayer miner = new ServerPlayer(server, w, gameProfile); + // TODO: fixing could not add to tab list + ServerGamePacketListenerImpl pc = ((CraftPlayer) player).getHandle().connection; + pc.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, miner)); World world = miner.getBukkitEntity().getWorld(); List locs = new ArrayList<>(); for (int x = (int) stand.getLocation().getX() - 3; x <= stand.getLocation().getX() + 2; x++) { diff --git a/src/main/java/me/night/nullvalkyrie/events/custom/RightClickNPCEvent.java b/src/main/java/me/night/nullvalkyrie/events/custom/RightClickNPCEvent.java index 6d49942..56243fc 100644 --- a/src/main/java/me/night/nullvalkyrie/events/custom/RightClickNPCEvent.java +++ b/src/main/java/me/night/nullvalkyrie/events/custom/RightClickNPCEvent.java @@ -1,6 +1,6 @@ package me.night.nullvalkyrie.events.custom; -import net.minecraft.server.level.EntityPlayer; +import net.minecraft.server.level.ServerPlayer; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; @@ -9,17 +9,17 @@ import org.jetbrains.annotations.NotNull; public class RightClickNPCEvent extends Event implements Cancellable { private final Player player; - private final EntityPlayer npc; + private final ServerPlayer npc; private boolean isCancelled; private static final HandlerList HANDLERS = new HandlerList(); - public RightClickNPCEvent(Player player, EntityPlayer npc) { + public RightClickNPCEvent(Player player, ServerPlayer npc) { this.player = player; this.npc = npc; } public Player getPlayer() { return player; } - public EntityPlayer getNPC() { + public ServerPlayer getNPC() { return npc; } @Override @@ -37,6 +37,6 @@ public class RightClickNPCEvent extends Event implements Cancellable { public HandlerList getHandlers() { return HANDLERS; } - + @SuppressWarnings("unused") public static HandlerList getHandlerList() { return HANDLERS; } }