mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-23 08:31:37 +01:00
Simplify inBlock check to avoid chunk loading
This commit is contained in:
parent
d3002965fd
commit
dffbf60465
@ -7,6 +7,8 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -242,6 +244,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return skinTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBlock() {
|
||||
if (npc == null || noclip) {
|
||||
return super.inBlock();
|
||||
}
|
||||
Location loc = getBukkitEntity().getLocation(LOADED_LOCATION);
|
||||
if (!Util.isLoaded(loc)) {
|
||||
return false;
|
||||
}
|
||||
Block in = loc.getBlock();
|
||||
return in.getType().isSolid() && in.getRelative(BlockFace.UP).getType().isSolid();
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
|
@ -7,6 +7,8 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -273,6 +275,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return skinTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBlock() {
|
||||
if (npc == null || noclip) {
|
||||
return super.inBlock();
|
||||
}
|
||||
Location loc = getBukkitEntity().getLocation(LOADED_LOCATION);
|
||||
if (!Util.isLoaded(loc)) {
|
||||
return false;
|
||||
}
|
||||
Block in = loc.getBlock();
|
||||
return in.getType().isSolid() && in.getRelative(BlockFace.UP).getType().isSolid();
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
|
@ -8,6 +8,8 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -293,6 +295,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return skinTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBlock() {
|
||||
if (npc == null || noclip) {
|
||||
return super.inBlock();
|
||||
}
|
||||
Location loc = getBukkitEntity().getLocation(LOADED_LOCATION);
|
||||
if (!Util.isLoaded(loc)) {
|
||||
return false;
|
||||
}
|
||||
Block in = loc.getBlock();
|
||||
return in.getType().isSolid() && in.getRelative(BlockFace.UP).getType().isSolid();
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
|
@ -8,6 +8,8 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -272,6 +274,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return skinTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBlock() {
|
||||
if (npc == null || noclip) {
|
||||
return super.inBlock();
|
||||
}
|
||||
Location loc = getBukkitEntity().getLocation(LOADED_LOCATION);
|
||||
if (!Util.isLoaded(loc)) {
|
||||
return false;
|
||||
}
|
||||
Block in = loc.getBlock();
|
||||
return in.getType().isSolid() && in.getRelative(BlockFace.UP).getType().isSolid();
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
|
@ -7,6 +7,8 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -263,6 +265,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return skinTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBlock() {
|
||||
if (npc == null || noclip) {
|
||||
return super.inBlock();
|
||||
}
|
||||
Location loc = getBukkitEntity().getLocation(LOADED_LOCATION);
|
||||
if (!Util.isLoaded(loc)) {
|
||||
return false;
|
||||
}
|
||||
Block in = loc.getBlock();
|
||||
return in.getType().isSolid() && in.getRelative(BlockFace.UP).getType().isSolid();
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
|
@ -7,6 +7,8 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -264,6 +266,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBlock() {
|
||||
if (npc == null || noclip) {
|
||||
return super.inBlock();
|
||||
}
|
||||
Location loc = getBukkitEntity().getLocation(LOADED_LOCATION);
|
||||
if (!Util.isLoaded(loc)) {
|
||||
return false;
|
||||
}
|
||||
Block in = loc.getBlock();
|
||||
return in.getType().isSolid() && in.getRelative(BlockFace.UP).getType().isSolid();
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
|
@ -9,6 +9,8 @@ import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -278,6 +280,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBlock() {
|
||||
if (npc == null || noclip) {
|
||||
return super.inBlock();
|
||||
}
|
||||
Location loc = getBukkitEntity().getLocation(LOADED_LOCATION);
|
||||
if (!Util.isLoaded(loc)) {
|
||||
return false;
|
||||
}
|
||||
Block in = loc.getBlock();
|
||||
return in.getType().isSolid() && in.getRelative(BlockFace.UP).getType().isSolid();
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
@ -376,7 +391,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
super.playerTick();
|
||||
return;
|
||||
}
|
||||
noclip = true;
|
||||
entityBaseTick();
|
||||
noclip = false;
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
if (!navigating && getBukkitEntity() != null
|
||||
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -243,6 +244,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
return skinTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inBlock() {
|
||||
if (npc == null || noclip) {
|
||||
return super.inBlock();
|
||||
}
|
||||
Location loc = getBukkitEntity().getLocation(LOADED_LOCATION);
|
||||
if (!Util.isLoaded(loc)) {
|
||||
return false;
|
||||
}
|
||||
org.bukkit.block.Block in = loc.getBlock();
|
||||
return in.getType().isSolid() && in.getRelative(BlockFace.UP).getType().isSolid();
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
|
Loading…
Reference in New Issue
Block a user