npcs + miners 1.19.3

This commit is contained in:
NK 2022-12-22 23:46:07 +00:00
parent 42fbf357c7
commit 69c965d807
2 changed files with 17 additions and 16 deletions

View file

@ -6,18 +6,19 @@ import com.mojang.authlib.properties.Property;
import me.night.nullvalkyrie.enums.MinerType; import me.night.nullvalkyrie.enums.MinerType;
import me.night.nullvalkyrie.util.Skin; import me.night.nullvalkyrie.util.Skin;
import me.night.nullvalkyrie.util.Util; 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.MinecraftServer;
import net.minecraft.server.level.EntityPlayer; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.WorldServer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.PlayerConnection; import net.minecraft.server.network.ServerGamePacketListenerImpl;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer; import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; 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.ArmorStand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -137,11 +138,11 @@ public class CryptoMiner {
String[] skin = Skin.getSkin("Shiba_"); String[] skin = Skin.getSkin("Shiba_");
gameProfile.getProperties().put("textures", new Property("textures", skin[0], skin[1])); gameProfile.getProperties().put("textures", new Property("textures", skin[0], skin[1]));
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer(); MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer w = ((CraftWorld) player.getLocation().getWorld()).getHandle(); ServerLevel w = ((CraftWorld) player.getLocation().getWorld()).getHandle();
EntityPlayer miner = new EntityPlayer(server, w, gameProfile, null); ServerPlayer miner = new ServerPlayer(server, w, gameProfile);
// TODO: how to make a armor stand turn // TODO: fixing could not add to tab list
PlayerConnection pc = ((org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer) player).getHandle().b; ServerGamePacketListenerImpl pc = ((CraftPlayer) player).getHandle().connection;
pc.a(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a, miner)); pc.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, miner));
World world = miner.getBukkitEntity().getWorld(); World world = miner.getBukkitEntity().getWorld();
List<Location> locs = new ArrayList<>(); List<Location> locs = new ArrayList<>();
for (int x = (int) stand.getLocation().getX() - 3; x <= stand.getLocation().getX() + 2; x++) { for (int x = (int) stand.getLocation().getX() - 3; x <= stand.getLocation().getX() + 2; x++) {

View file

@ -1,6 +1,6 @@
package me.night.nullvalkyrie.events.custom; 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.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
@ -9,17 +9,17 @@ import org.jetbrains.annotations.NotNull;
public class RightClickNPCEvent extends Event implements Cancellable { public class RightClickNPCEvent extends Event implements Cancellable {
private final Player player; private final Player player;
private final EntityPlayer npc; private final ServerPlayer npc;
private boolean isCancelled; private boolean isCancelled;
private static final HandlerList HANDLERS = new HandlerList(); private static final HandlerList HANDLERS = new HandlerList();
public RightClickNPCEvent(Player player, EntityPlayer npc) { public RightClickNPCEvent(Player player, ServerPlayer npc) {
this.player = player; this.player = player;
this.npc = npc; this.npc = npc;
} }
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
public EntityPlayer getNPC() { public ServerPlayer getNPC() {
return npc; return npc;
} }
@Override @Override
@ -37,6 +37,6 @@ public class RightClickNPCEvent extends Event implements Cancellable {
public HandlerList getHandlers() { public HandlerList getHandlers() {
return HANDLERS; return HANDLERS;
} }
@SuppressWarnings("unused")
public static HandlerList getHandlerList() { return HANDLERS; } public static HandlerList getHandlerList() { return HANDLERS; }
} }