mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-21 11:46:46 +01:00
Removed support for 1.15
This commit is contained in:
parent
2fd477d47e
commit
e5a233b980
@ -7,7 +7,6 @@ mavenPassword=''
|
||||
nms.compile_v1_7=true
|
||||
nms.compile_v1_8=true
|
||||
nms.compile_v1_12=true
|
||||
nms.compile_v1_15=true
|
||||
nms.compile_v1_16=true
|
||||
nms.compile_v1_17=true
|
||||
nms.compile_v1_18=true
|
||||
|
@ -9,7 +9,6 @@ include 'Hook_SuperiorSkyblock'
|
||||
include 'v1_7_R4'
|
||||
include 'v1_8_R3'
|
||||
include 'v1_12_R1'
|
||||
include 'v1_15_R1'
|
||||
include 'v1_16_R3'
|
||||
include 'v1_17_R1'
|
||||
include 'v1_18_R1'
|
||||
|
@ -1,11 +0,0 @@
|
||||
group 'v1_15_R1'
|
||||
|
||||
dependencies {
|
||||
compileOnly "org.spigotmc:v1_15_R1-Paper:latest"
|
||||
compileOnly project(":API")
|
||||
compileOnly parent
|
||||
}
|
||||
|
||||
if (project.hasProperty('nms.compile_v1_15') && !Boolean.valueOf(project.findProperty("nms.compile_v1_15").toString())) {
|
||||
project.tasks.all { task -> task.enabled = false }
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_15_R1.EnumGamemode;
|
||||
import net.minecraft.server.v1_15_R1.EnumProtocolDirection;
|
||||
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
||||
import net.minecraft.server.v1_15_R1.NetworkManager;
|
||||
import net.minecraft.server.v1_15_R1.Packet;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInBlockDig;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInBlockPlace;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInChat;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInFlying;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInHeldItemSlot;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInTransaction;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInUpdateSign;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInWindowClick;
|
||||
import net.minecraft.server.v1_15_R1.PlayerConnection;
|
||||
import net.minecraft.server.v1_15_R1.PlayerInteractManager;
|
||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC_v1_15_R1 extends EntityPlayer implements ChunkLoaderNPC {
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
public ChunkLoaderNPC_v1_15_R1(Location location, UUID uuid){
|
||||
super(((CraftServer) Bukkit.getServer()).getServer(),
|
||||
((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
|
||||
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
|
||||
|
||||
playerConnection = new DummyPlayerConnection(server, this);
|
||||
|
||||
this.playerInteractManager.setGameMode(EnumGamemode.CREATIVE);
|
||||
clientViewDistance = 1;
|
||||
|
||||
fauxSleeping = true;
|
||||
|
||||
spawnIn(world);
|
||||
setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
((WorldServer) world).addPlayerJoin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return super.getUniqueID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
if(!dieCall) {
|
||||
dieCall = true;
|
||||
getWorldServer().removePlayer(this);
|
||||
dieCall = false;
|
||||
}
|
||||
else {
|
||||
super.die();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager{
|
||||
|
||||
private static Field channelField;
|
||||
private static Field socketAddressField;
|
||||
|
||||
static {
|
||||
try {
|
||||
channelField = NetworkManager.class.getDeclaredField("channel");
|
||||
channelField.setAccessible(true);
|
||||
socketAddressField = NetworkManager.class.getDeclaredField("socketAddress");
|
||||
socketAddressField.setAccessible(true);
|
||||
} catch (Exception error) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
DummyNetworkManager(){
|
||||
super(EnumProtocolDirection.SERVERBOUND);
|
||||
updateFields();
|
||||
}
|
||||
|
||||
private void updateFields() {
|
||||
try {
|
||||
if (channelField != null) {
|
||||
channelField.set(this, new DummyChannel());
|
||||
}
|
||||
|
||||
if (socketAddressField != null) {
|
||||
socketAddressField.set(this, null);
|
||||
}
|
||||
} catch (Exception error) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DummyPlayerConnection extends PlayerConnection {
|
||||
|
||||
DummyPlayerConnection(MinecraftServer minecraftServer, EntityPlayer entityPlayer) {
|
||||
super(minecraftServer, new DummyNetworkManager(), entityPlayer);
|
||||
}
|
||||
|
||||
public void a(PacketPlayInWindowClick packetPlayInWindowClick) {
|
||||
|
||||
}
|
||||
|
||||
public void a(PacketPlayInTransaction packetPlayInTransaction) {
|
||||
|
||||
}
|
||||
|
||||
public void a(PacketPlayInFlying packetPlayInFlying) {
|
||||
|
||||
}
|
||||
|
||||
public void a(PacketPlayInUpdateSign packetPlayInUpdateSign) {
|
||||
|
||||
}
|
||||
|
||||
public void a(PacketPlayInBlockDig packetPlayInBlockDig) {
|
||||
|
||||
}
|
||||
|
||||
public void a(PacketPlayInBlockPlace packetPlayInBlockPlace) {
|
||||
|
||||
}
|
||||
|
||||
public void disconnect(String s) {
|
||||
|
||||
}
|
||||
|
||||
public void a(PacketPlayInHeldItemSlot packetPlayInHeldItemSlot) {
|
||||
|
||||
}
|
||||
|
||||
public void a(PacketPlayInChat packetPlayInChat) {
|
||||
|
||||
}
|
||||
|
||||
public void sendPacket(Packet packet) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,179 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import net.minecraft.server.v1_15_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_15_R1.DamageSource;
|
||||
import net.minecraft.server.v1_15_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_15_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_15_R1.EnumHand;
|
||||
import net.minecraft.server.v1_15_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_15_R1.EnumItemSlot;
|
||||
import net.minecraft.server.v1_15_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_15_R1.ItemStack;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_15_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_15_R1.Vec3D;
|
||||
import net.minecraft.server.v1_15_R1.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.util.CraftChatMessage;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class EntityHolograms_v1_15_R1 extends EntityArmorStand implements Hologram {
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
EntityHolograms_v1_15_R1(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
setInvisible(true);
|
||||
setSmall(true);
|
||||
setArms(false);
|
||||
setNoGravity(true);
|
||||
setBasePlate(true);
|
||||
setMarker(true);
|
||||
super.collides = false;
|
||||
super.setCustomNameVisible(true);
|
||||
super.a(new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHologramName(String name) {
|
||||
super.setCustomName(CraftChatMessage.fromString(name)[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
super.die();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(@Nullable IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean flag) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a_(int i, ItemStack item) {
|
||||
// Prevent stand being equipped
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AxisAlignedBB boundingBox) {
|
||||
// Do not change it!
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = new CraftArmorStand(super.world.getServer(), this);
|
||||
}
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
}
|
@ -1,303 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms;
|
||||
|
||||
import com.bgsoftware.wildloaders.WildLoadersPlugin;
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.WChunkLoader;
|
||||
import net.minecraft.server.v1_15_R1.Block;
|
||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_15_R1.Chunk;
|
||||
import net.minecraft.server.v1_15_R1.ChunkCoordIntPair;
|
||||
import net.minecraft.server.v1_15_R1.ITickable;
|
||||
import net.minecraft.server.v1_15_R1.ItemStack;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagLong;
|
||||
import net.minecraft.server.v1_15_R1.NBTTagString;
|
||||
import net.minecraft.server.v1_15_R1.TileEntity;
|
||||
import net.minecraft.server.v1_15_R1.TileEntityMobSpawner;
|
||||
import net.minecraft.server.v1_15_R1.TileEntityTypes;
|
||||
import net.minecraft.server.v1_15_R1.World;
|
||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class NMSAdapter_v1_15_R1 implements NMSAdapter {
|
||||
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
if(!tagCompound.hasKeyOfType(key, 8))
|
||||
return def;
|
||||
|
||||
return tagCompound.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
tagCompound.set(key, NBTTagString.a(value));
|
||||
|
||||
nmsItem.setTag(tagCompound);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack itemStack, String key, long def) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
if(!tagCompound.hasKeyOfType(key, 4))
|
||||
return def;
|
||||
|
||||
return tagCompound.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, long value) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
tagCompound.set(key, NBTTagLong.a(value));
|
||||
|
||||
nmsItem.setTag(tagCompound);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack itemStack, String texture) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
|
||||
NBTTagCompound nbtTagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
NBTTagCompound skullOwner = nbtTagCompound.hasKey("SkullOwner") ? nbtTagCompound.getCompound("SkullOwner") : new NBTTagCompound();
|
||||
|
||||
NBTTagCompound properties = new NBTTagCompound();
|
||||
|
||||
NBTTagList textures = new NBTTagList();
|
||||
NBTTagCompound signature = new NBTTagCompound();
|
||||
signature.setString("Value", texture);
|
||||
textures.add(signature);
|
||||
|
||||
properties.set("textures", textures);
|
||||
|
||||
skullOwner.set("Properties", properties);
|
||||
skullOwner.setString("Id", UUID.randomUUID().toString());
|
||||
|
||||
nbtTagCompound.set("SkullOwner", skullOwner);
|
||||
|
||||
nmsItem.setTag(nbtTagCompound);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkLoaderNPC createNPC(Location location, UUID uuid) {
|
||||
return new ChunkLoaderNPC_v1_15_R1(location, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
assert loaderLoc.getWorld() != null;
|
||||
WorldServer world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
|
||||
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
|
||||
world.tileEntityListTick.add(tileEntityChunkLoader);
|
||||
|
||||
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
|
||||
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = -1);
|
||||
|
||||
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, true);
|
||||
}
|
||||
|
||||
return tileEntityChunkLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
assert loaderLoc.getWorld() != null;
|
||||
WorldServer world = ((CraftWorld) loaderLoc.getWorld()).getHandle();
|
||||
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
long tileEntityLong = ChunkCoordIntPair.pair(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
|
||||
TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
|
||||
if(tileEntityChunkLoader != null) {
|
||||
tileEntityChunkLoader.holograms.forEach(EntityHolograms_v1_15_R1::removeHologram);
|
||||
tileEntityChunkLoader.removed = true;
|
||||
world.tileEntityListTick.remove(tileEntityChunkLoader);
|
||||
}
|
||||
|
||||
if(spawnParticle)
|
||||
world.a(null, 2001, blockPosition, Block.getCombinedId(world.getType(blockPosition)));
|
||||
|
||||
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
chunk.tileEntities.values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
|
||||
.forEach(tileEntity -> ((TileEntityMobSpawner) tileEntity).getSpawner().requiredPlayerRange = 16);
|
||||
|
||||
world.setForceLoaded(chunk.getPos().x, chunk.getPos().z, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSpawner(Location location, boolean reset) {
|
||||
assert location.getWorld() != null;
|
||||
World world = ((CraftWorld) location.getWorld()).getHandle();
|
||||
|
||||
BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
|
||||
TileEntityMobSpawner mobSpawner = (TileEntityMobSpawner) world.getTileEntity(blockPosition);
|
||||
|
||||
if(mobSpawner == null)
|
||||
return;
|
||||
|
||||
mobSpawner.getSpawner().requiredPlayerRange = reset ? 16 : -1;
|
||||
}
|
||||
|
||||
private static final class TileEntityChunkLoader extends TileEntity implements ITickable, ITileEntityChunkLoader {
|
||||
|
||||
private static final Map<Long, TileEntityChunkLoader> tileEntityChunkLoaderMap = new HashMap<>();
|
||||
|
||||
private final List<EntityHolograms_v1_15_R1> holograms = new ArrayList<>();
|
||||
private final WChunkLoader chunkLoader;
|
||||
private final Block loaderBlock;
|
||||
|
||||
private short currentTick = 20;
|
||||
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
|
||||
private boolean removed = false;
|
||||
|
||||
TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){
|
||||
super(TileEntityTypes.COMMAND_BLOCK);
|
||||
|
||||
this.chunkLoader = (WChunkLoader) chunkLoader;
|
||||
|
||||
setLocation(world, blockPosition);
|
||||
|
||||
loaderBlock = world.getType(blockPosition).getBlock();
|
||||
|
||||
try {
|
||||
// Not a method of Spigot - fixes https://github.com/OmerBenGera/WildLoaders/issues/2
|
||||
setCurrentChunk(world.getChunkAtWorldCoords(blockPosition));
|
||||
}catch (Throwable ignored){}
|
||||
|
||||
if(!this.chunkLoader.isInfinite()) {
|
||||
long timeLeft = chunkLoader.getTimeLeft();
|
||||
|
||||
daysAmount = (short) (timeLeft / 86400);
|
||||
timeLeft = timeLeft % 86400;
|
||||
|
||||
hoursAmount = (short) (timeLeft / 3600);
|
||||
timeLeft = timeLeft % 3600;
|
||||
|
||||
minutesAmount = (short) (timeLeft / 60);
|
||||
timeLeft = timeLeft % 60;
|
||||
|
||||
secondsAmount = (short) timeLeft;
|
||||
}
|
||||
|
||||
tileEntityChunkLoaderMap.put(ChunkCoordIntPair.pair(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this);
|
||||
|
||||
List<String> hologramLines = this.chunkLoader.getHologramLines();
|
||||
|
||||
double currentY = position.getY() + 1;
|
||||
for(int i = hologramLines.size(); i > 0; i--){
|
||||
EntityHolograms_v1_15_R1 hologram = new EntityHolograms_v1_15_R1(world, position.getX() + 0.5, currentY, position.getZ() + 0.5);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
world.addEntity(hologram);
|
||||
currentY += 0.23;
|
||||
holograms.add(hologram);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void v() {
|
||||
tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if(removed || ++currentTick <= 20)
|
||||
return;
|
||||
|
||||
currentTick = 0;
|
||||
|
||||
assert world != null;
|
||||
if(chunkLoader.isNotActive() || world.getType(position).getBlock() != loaderBlock){
|
||||
chunkLoader.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if(chunkLoader.isInfinite())
|
||||
return;
|
||||
|
||||
List<String> hologramLines = chunkLoader.getHologramLines();
|
||||
|
||||
int hologramsAmount = holograms.size();
|
||||
for (int i = hologramsAmount; i > 0; i--) {
|
||||
EntityHolograms_v1_15_R1 hologram = holograms.get(hologramsAmount - i);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
}
|
||||
|
||||
chunkLoader.tick();
|
||||
|
||||
if(!removed) {
|
||||
secondsAmount--;
|
||||
if (secondsAmount < 0) {
|
||||
secondsAmount = 59;
|
||||
minutesAmount--;
|
||||
if (minutesAmount < 0) {
|
||||
minutesAmount = 59;
|
||||
hoursAmount--;
|
||||
if (hoursAmount < 0) {
|
||||
hoursAmount = 23;
|
||||
daysAmount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Hologram> getHolograms() {
|
||||
return Collections.unmodifiableList(holograms);
|
||||
}
|
||||
|
||||
private void updateName(EntityHolograms_v1_15_R1 hologram, String line){
|
||||
assert chunkLoader.getWhoPlaced().getName() != null;
|
||||
hologram.setHologramName(line
|
||||
.replace("{0}", chunkLoader.getWhoPlaced().getName())
|
||||
.replace("{1}", daysAmount + "")
|
||||
.replace("{2}", hoursAmount + "")
|
||||
.replace("{3}", minutesAmount + "")
|
||||
.replace("{4}", secondsAmount + "")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user