update for Spigot 1.20.2 .
This commit is contained in:
parent
37d53da83c
commit
7f89be0354
@ -1,35 +0,0 @@
|
|||||||
package net.theprogrammersworld.herobrine.NPC.Network;
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class NetworkUtils {
|
|
||||||
public static void sendPacketNearby(Location location, Packet<?> packet) {
|
|
||||||
sendPacketNearby(location, packet, 64);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendPacketNearby(Location location, Packet<?> packet, double radius) {
|
|
||||||
radius *= radius;
|
|
||||||
final World world = location.getWorld();
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
if (world == player.getWorld()) {
|
|
||||||
if (location.distanceSquared(player.getLocation()) <= radius) {
|
|
||||||
((CraftPlayer) player).getHandle().connection.send(packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack[] combineItemStackArrays(Object[] a, Object[] b) {
|
|
||||||
ItemStack[] c = new ItemStack[a.length + b.length];
|
|
||||||
System.arraycopy(a, 0, c, 0, a.length);
|
|
||||||
System.arraycopy(b, 0, c, a.length, b.length);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package net.theprogrammersworld.herobrine.NPC.Network;
|
|
||||||
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.Socket;
|
|
||||||
|
|
||||||
public class NullSocket extends Socket {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream getInputStream() {
|
|
||||||
return new VoidInputStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OutputStream getOutputStream() {
|
|
||||||
return new VoidOutputStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class VoidInputStream extends InputStream {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read() throws IOException {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class VoidOutputStream extends OutputStream {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(int b) throws IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -4,17 +4,17 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
|
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
|
||||||
public class EntityManager {
|
public class EntityManager {
|
||||||
|
|
||||||
private HashMap<Integer,CustomEntity> mobList = new HashMap<Integer,CustomEntity>();
|
private HashMap<Integer,CustomEntity> mobList = new HashMap<Integer,CustomEntity>();
|
||||||
|
|
||||||
public void spawnCustomZombie(Location loc,MobType mbt){
|
public void spawnCustomZombie(Location loc,MobType mbt){
|
||||||
|
|
||||||
World world = loc.getWorld();
|
final ServerLevel mcWorld = ((org.bukkit.craftbukkit.v1_20_R2.CraftWorld) loc.getWorld()).getHandle();
|
||||||
net.minecraft.world.level.Level mcWorld = ((org.bukkit.craftbukkit.v1_20_R2.CraftWorld) world).getHandle();
|
|
||||||
CustomZombie zmb = new CustomZombie(mcWorld,loc,mbt);
|
CustomZombie zmb = new CustomZombie(mcWorld,loc,mbt);
|
||||||
mcWorld.addFreshEntity(zmb, SpawnReason.CUSTOM);
|
mcWorld.addFreshEntity(zmb, SpawnReason.CUSTOM);
|
||||||
mobList.put(Integer.valueOf(zmb.getBukkitEntity().getEntityId()),zmb);
|
mobList.put(Integer.valueOf(zmb.getBukkitEntity().getEntityId()),zmb);
|
||||||
@ -23,8 +23,7 @@ public class EntityManager {
|
|||||||
|
|
||||||
public void spawnCustomSkeleton(Location loc,MobType mbt){
|
public void spawnCustomSkeleton(Location loc,MobType mbt){
|
||||||
|
|
||||||
World world = loc.getWorld();
|
final ServerLevel mcWorld = ((org.bukkit.craftbukkit.v1_20_R2.CraftWorld) loc.getWorld()).getHandle();
|
||||||
net.minecraft.world.level.Level mcWorld = ((org.bukkit.craftbukkit.v1_20_R2.CraftWorld) world).getHandle();
|
|
||||||
CustomSkeleton zmb = new CustomSkeleton(mcWorld,loc,mbt);
|
CustomSkeleton zmb = new CustomSkeleton(mcWorld,loc,mbt);
|
||||||
mcWorld.addFreshEntity(zmb, SpawnReason.CUSTOM);
|
mcWorld.addFreshEntity(zmb, SpawnReason.CUSTOM);
|
||||||
mobList.put(Integer.valueOf(zmb.getBukkitEntity().getEntityId()), zmb);
|
mobList.put(Integer.valueOf(zmb.getBukkitEntity().getEntityId()), zmb);
|
||||||
|
Loading…
Reference in New Issue
Block a user