mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-10 10:09:55 +01:00
Fix removal of holograms not working properly (#103)
This commit is contained in:
parent
0cc90156a8
commit
c4c30c1265
@ -1,6 +1,7 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.wildloaders.scheduler.Scheduler;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@ -15,6 +16,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftEntity;
|
||||
@ -48,8 +50,15 @@ public final class EntityHologram extends ArmorStand implements Hologram {
|
||||
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
if (Scheduler.isRegionScheduler() || !Bukkit.isPrimaryThread()) {
|
||||
World world = level.getWorld();
|
||||
int chunkX = getBlockX() >> 4;
|
||||
int chunkZ = getBlockZ() >> 4;
|
||||
Scheduler.runTask(world, chunkX, chunkZ, () -> super.remove(RemovalReason.DISCARDED));
|
||||
} else {
|
||||
super.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
|
||||
@ -50,7 +51,10 @@ public final class EntityHologram extends ArmorStand implements Hologram {
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
if (Scheduler.isRegionScheduler() || !Bukkit.isPrimaryThread()) {
|
||||
Scheduler.runTask(getBukkitEntity(), () -> super.remove(RemovalReason.DISCARDED));
|
||||
World world = level().getWorld();
|
||||
int chunkX = getBlockX() >> 4;
|
||||
int chunkZ = getBlockZ() >> 4;
|
||||
Scheduler.runTask(world, chunkX, chunkZ, () -> super.remove(RemovalReason.DISCARDED));
|
||||
} else {
|
||||
super.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_20_4;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.wildloaders.scheduler.Scheduler;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@ -15,6 +16,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
@ -48,8 +50,15 @@ public final class EntityHologram extends ArmorStand implements Hologram {
|
||||
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
if (Scheduler.isRegionScheduler() || !Bukkit.isPrimaryThread()) {
|
||||
World world = level().getWorld();
|
||||
int chunkX = getBlockX() >> 4;
|
||||
int chunkZ = getBlockZ() >> 4;
|
||||
Scheduler.runTask(world, chunkX, chunkZ, () -> super.remove(RemovalReason.DISCARDED));
|
||||
} else {
|
||||
super.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_21;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.wildloaders.scheduler.Scheduler;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@ -15,6 +16,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
@ -48,8 +50,15 @@ public final class EntityHologram extends ArmorStand implements Hologram {
|
||||
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
if (Scheduler.isRegionScheduler() || !Bukkit.isPrimaryThread()) {
|
||||
World world = level().getWorld();
|
||||
int chunkX = getBlockX() >> 4;
|
||||
int chunkZ = getBlockZ() >> 4;
|
||||
Scheduler.runTask(world, chunkX, chunkZ, () -> super.remove(RemovalReason.DISCARDED));
|
||||
} else {
|
||||
super.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
|
@ -64,6 +64,10 @@ public class Scheduler {
|
||||
return runTask(location.getWorld(), location.getBlockX() >> 4, location.getBlockZ() >> 4, task, delay);
|
||||
}
|
||||
|
||||
public static ScheduledTask runTask(World world, int chunkX, int chunkZ, Runnable task) {
|
||||
return runTask(world, chunkX, chunkZ, task, 0L);
|
||||
}
|
||||
|
||||
public static ScheduledTask runTask(Entity entity, Runnable task) {
|
||||
return runTask(entity, task, 0L);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user