Most of the work from yesterday was useless, as my Gradle cache was apparently out of sync and therefore registering imports as valid that turned out to be invalid, so, back to the drawing board. Down to 93 errors remaining.

This commit is contained in:
David Berdik 2021-06-30 22:25:16 -04:00
parent bb12e57257
commit 7da381ec6a
11 changed files with 64 additions and 64 deletions

View File

@ -13,9 +13,9 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo;
import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action;
import net.theprogrammersworld.herobrine.Herobrine;
import net.theprogrammersworld.herobrine.Utils;
import net.theprogrammersworld.herobrine.AI.Core.CoreType;
@ -678,15 +678,15 @@ public class AICore {
boolean playerCanSeeHerobrine = p.hasLineOfSight(Herobrine.getPluginCore().HerobrineNPC.getBukkitEntity());
if(playerCanSeeHerobrine && !visibilityList.contains(p)) {
// If player p can see Herobrine but visibilty is not already enabled, then enable it.
EntityPlayer pcon = ((CraftPlayer) p).getHandle();
pcon.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
ServerPlayer pcon = ((CraftPlayer) p).getHandle();
pcon.connection.send(new ClientboundPlayerInfoPacket(Action.ADD_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
visibilityList.add(p);
return true;
}
else if(!playerCanSeeHerobrine && visibilityList.contains(p)) {
// If player p cannot see Herobrine but visibility is still enabled, then disable it.
EntityPlayer pcon = ((CraftPlayer) p).getHandle();
pcon.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
ServerPlayer pcon = ((CraftPlayer) p).getHandle();
pcon.connection.send(new ClientboundPlayerInfoPacket(Action.REMOVE_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
visibilityList.remove(p);
}
return false;

View File

@ -23,7 +23,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EnumCreatureType;
import net.minecraft.core.IRegistry;
import net.theprogrammersworld.herobrine.AI.AICore;
@ -363,9 +363,9 @@ public class Herobrine extends JavaPlugin implements Listener {
}
}
private static <T extends Entity> void addCustomEntity(String customName, EntityTypes.b<T> _func, EnumCreatureType enumCreatureType) {
private static <T extends Entity> void addCustomEntity(String customName, EntityType.b<T> _func, EnumCreatureType enumCreatureType) {
// Registers a custom entity. Adapted from https://www.spigotmc.org/threads/handling-custom-entity-registry-on-spigot-1-13.353426/#post-3447111
EntityTypes.Builder<?> entity = EntityTypes.Builder.a(_func, enumCreatureType);
EntityType.Builder<?> entity = EntityType.Builder.a(_func, enumCreatureType);
entity.b();
IRegistry.a(IRegistry.ENTITY_TYPE, customName, entity.a(customName));
}

View File

@ -2,7 +2,7 @@ package net.theprogrammersworld.herobrine.NPC.Entity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.entity.EnumMoveType;
import net.minecraft.server.level.PlayerInteractManager;
@ -17,7 +17,7 @@ import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import com.mojang.authlib.GameProfile;
public class HumanEntity extends EntityPlayer {
public class HumanEntity extends Player {
private CraftPlayer cplayer = null;

View File

@ -1,7 +1,7 @@
package net.theprogrammersworld.herobrine.NPC.Entity;
import net.minecraft.server.level.ChunkProviderServer;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.EnumHand;
import net.minecraft.network.protocol.game.PacketPlayInArmAnimation;
import net.minecraft.server.level.PlayerChunkMap;
@ -17,7 +17,7 @@ import org.bukkit.inventory.PlayerInventory;
public class HumanNPC {
private EntityPlayer entity;
private ServerPlayer entity;
private final int id;
public HumanNPC(HumanEntity humanEntity, int id) {
@ -29,7 +29,7 @@ public class HumanNPC {
return this.id;
}
public EntityPlayer getEntity() {
public ServerPlayer getEntity() {
return this.entity;
}

View File

@ -1,6 +1,6 @@
package net.theprogrammersworld.herobrine.NPC.Network;
import net.minecraft.server.level.EntityPlayer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.network.protocol.Packet;
import net.minecraft.server.network.PlayerConnection;
import net.theprogrammersworld.herobrine.NPC.NPCCore;

View File

@ -20,7 +20,7 @@ public class NetworkUtils {
for (Player player : Bukkit.getOnlinePlayers()) {
if (world == player.getWorld()) {
if (location.distanceSquared(player.getLocation()) <= radius) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
((CraftPlayer) player).getHandle().connection.send(packet);
}
}
}

View File

@ -11,10 +11,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.network.chat.ChatMessageType;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.chat.IChatBaseComponent.ChatSerializer;
import net.minecraft.network.protocol.game.PacketPlayOutChat;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component.Serializer;
import net.minecraft.network.protocol.game.ClientboundChatPacket;
import net.theprogrammersworld.herobrine.Herobrine;
public class CmdExecutor implements CommandExecutor {
@ -71,9 +71,9 @@ public class CmdExecutor implements CommandExecutor {
player.sendMessage(ChatColor.RED + "[Herobrine] Command List (hover over commands for more info)");
for (String v : helpMessage) {
if(player.hasPermission("herobrine." + permissionNode.get(v))) {
IChatBaseComponent help = ChatSerializer.a("{\"text\":\"\",\"extra\":[{\"text\":\"" + v +
TextComponent help = (TextComponent) Serializer.fromJson("{\"text\":\"\",\"extra\":[{\"text\":\"" + v +
"\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"" + helpMessageDesc.get(v) + "\"}}]}");
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(help, ChatMessageType.CHAT, player.getUniqueId()));
((CraftPlayer) player).getHandle().connection.send(new ClientboundChatPacket(help, ChatType.CHAT, player.getUniqueId()));
}
}
}

View File

@ -9,24 +9,24 @@ import java.util.Random;
import org.bukkit.Color;
import net.minecraft.network.chat.ChatComponentText;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.ai.attributes.GenericAttributes;
import net.minecraft.world.level.World;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.level.Level;
import net.theprogrammersworld.herobrine.Herobrine;
import net.theprogrammersworld.herobrine.misc.ItemName;
public class CustomSkeleton extends net.minecraft.world.entity.monster.EntitySkeleton implements CustomEntity {
public class CustomSkeleton extends net.minecraft.world.entity.monster.Skeleton implements CustomEntity {
private MobType mobType = null;
public CustomSkeleton(EntityTypes<? extends Entity> entitytypes, World world) {
super(EntityTypes.SKELETON, world);
public CustomSkeleton(EntityType<? extends Entity> entitytypes, Level world) {
super(EntityType.SKELETON, world);
}
public CustomSkeleton(World world, Location loc, MobType mbt) {
super(EntityTypes.SKELETON, world);
public CustomSkeleton(Level world, Location loc, MobType mbt) {
super(EntityType.SKELETON, world);
this.mobType = mbt;
if (mbt == MobType.DEMON) {
spawnDemon(loc);
@ -35,10 +35,10 @@ public class CustomSkeleton extends net.minecraft.world.entity.monster.EntitySke
public void spawnDemon(Location loc) {
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Demon.Speed"));
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP"));
this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Demon.Speed"));
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP"));
this.setHealth(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Demon.HP"));
this.setCustomName(new ChatComponentText("Demon"));
this.setCustomName(new TextComponent("Demon"));
Skeleton entityCast = (Skeleton) this.getBukkitEntity();
@ -51,8 +51,8 @@ public class CustomSkeleton extends net.minecraft.world.entity.monster.EntitySke
}
public CustomSkeleton(World world) {
super(EntityTypes.SKELETON, world);
public CustomSkeleton(Level world) {
super(EntityType.SKELETON, world);
}
@Override

View File

@ -7,23 +7,23 @@ import org.bukkit.Material;
import org.bukkit.entity.Zombie;
import org.bukkit.inventory.ItemStack;
import net.minecraft.network.chat.ChatComponentText;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.ai.attributes.GenericAttributes;
import net.minecraft.world.level.World;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.level.Level;
import net.theprogrammersworld.herobrine.Herobrine;
public class CustomZombie extends net.minecraft.world.entity.monster.EntityZombie implements CustomEntity {
public class CustomZombie extends net.minecraft.world.entity.monster.Zombie implements CustomEntity {
private MobType mobType = null;
public CustomZombie(EntityTypes<? extends Entity> entitytypes, World world) {
super(EntityTypes.ZOMBIE, world);
public CustomZombie(EntityType<? extends Entity> entitytypes, Level world) {
super(EntityType.ZOMBIE, world);
}
public CustomZombie(World world, Location loc, MobType mbt) {
super(EntityTypes.ZOMBIE, world);
public CustomZombie(Level world, Location loc, MobType mbt) {
super(EntityType.ZOMBIE, world);
this.mobType = mbt;
if (mbt == MobType.ARTIFACT_GUARDIAN) {
spawnArtifactGuardian(loc);
@ -34,11 +34,11 @@ public class CustomZombie extends net.minecraft.world.entity.monster.EntityZombi
private void spawnArtifactGuardian(Location loc) {
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Guardian.Speed"));
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP"));
this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Guardian.Speed"));
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP"));
this.setHealth(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Guardian.HP"));
this.setCustomName(new ChatComponentText("Artifact Guardian"));
this.setCustomName(new TextComponent("Artifact Guardian"));
Zombie entityCast = (Zombie) this.getBukkitEntity();
@ -54,11 +54,11 @@ public class CustomZombie extends net.minecraft.world.entity.monster.EntityZombi
private void spawnHerobrineWarrior(Location loc) {
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Warrior.Speed"));
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP"));
this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getDouble("npc.Warrior.Speed"));
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP"));
this.setHealth(Herobrine.getPluginCore().getConfigDB().npc.getInt("npc.Warrior.HP"));
this.setCustomName(new ChatComponentText("Herobrine Warrior"));
this.setCustomName(new TextComponent("Herobrine Warrior"));
Zombie entityCast = (Zombie) this.getBukkitEntity();
@ -72,8 +72,8 @@ public class CustomZombie extends net.minecraft.world.entity.monster.EntityZombi
}
public CustomZombie(World world) {
super(EntityTypes.ZOMBIE, world);
public CustomZombie(Level world) {
super(EntityType.ZOMBIE, world);
mobType = null;
}

View File

@ -5,6 +5,7 @@ import java.util.Map;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
public class EntityManager {
@ -13,9 +14,9 @@ public class EntityManager {
public void spawnCustomZombie(Location loc,MobType mbt){
World world = loc.getWorld();
net.minecraft.world.level.World mcWorld = ((org.bukkit.craftbukkit.v1_17_R1.CraftWorld) world).getHandle();
net.minecraft.world.level.Level mcWorld = ((org.bukkit.craftbukkit.v1_17_R1.CraftWorld) world).getHandle();
CustomZombie zmb = new CustomZombie(mcWorld,loc,mbt);
mcWorld.addEntity(zmb);
mcWorld.addEntity(zmb, SpawnReason.CUSTOM);
mobList.put(Integer.valueOf(zmb.getBukkitEntity().getEntityId()),zmb);
}
@ -23,9 +24,9 @@ public class EntityManager {
public void spawnCustomSkeleton(Location loc,MobType mbt){
World world = loc.getWorld();
net.minecraft.world.level.World mcWorld = ((org.bukkit.craftbukkit.v1_17_R1.CraftWorld) world).getHandle();
net.minecraft.world.level.Level mcWorld = ((org.bukkit.craftbukkit.v1_17_R1.CraftWorld) world).getHandle();
CustomSkeleton zmb = new CustomSkeleton(mcWorld,loc,mbt);
mcWorld.addEntity(zmb);
mcWorld.addEntity(zmb, SpawnReason.CUSTOM);
mobList.put(Integer.valueOf(zmb.getBukkitEntity().getEntityId()), zmb);
}

View File

@ -1,7 +1,7 @@
package net.theprogrammersworld.herobrine.listeners;
import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo;
import net.minecraft.network.protocol.game.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket.Action;
import net.theprogrammersworld.herobrine.AI.AICore;
import net.theprogrammersworld.herobrine.AI.Core.CoreType;
import net.theprogrammersworld.herobrine.Herobrine;
@ -15,7 +15,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
@ -49,8 +48,8 @@ public class PlayerListener implements Listener {
public void onJoin(PlayerJoinEvent event) {
// If the persistent tab list entry for Herobrine is enabled, send an "add player" packet to the user on login.
if(Herobrine.getPluginCore().getConfigDB().ShowInTabList)
((CraftPlayer) event.getPlayer()).getHandle().playerConnection.sendPacket(
new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
((CraftPlayer) event.getPlayer()).getHandle().connection.send(
new ClientboundPlayerInfoPacket(Action.ADD_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
// Check if the user has a Graveyard cache. If they do, this means they are stuck in the Graveyard and
// need teleported out.
@ -87,7 +86,7 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (event.getAction() == org.bukkit.event.block.Action.LEFT_CLICK_BLOCK || event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) {
if (event.getClickedBlock() != null && event.getPlayer().getInventory().getItemInMainHand() != null) {
ItemStack itemInHand = event.getPlayer().getInventory().getItemInMainHand();