mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-28 07:07:39 +02: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.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -242,6 +244,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
return skinTracker;
|
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) {
|
private void initialise(MinecraftServer minecraftServer) {
|
||||||
Socket socket = new EmptySocket();
|
Socket socket = new EmptySocket();
|
||||||
NetworkManager conn = null;
|
NetworkManager conn = null;
|
||||||
|
@ -7,6 +7,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -273,6 +275,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
return skinTracker;
|
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) {
|
private void initialise(MinecraftServer minecraftServer) {
|
||||||
Socket socket = new EmptySocket();
|
Socket socket = new EmptySocket();
|
||||||
NetworkManager conn = null;
|
NetworkManager conn = null;
|
||||||
|
@ -8,6 +8,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -293,6 +295,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
return skinTracker;
|
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) {
|
private void initialise(MinecraftServer minecraftServer) {
|
||||||
Socket socket = new EmptySocket();
|
Socket socket = new EmptySocket();
|
||||||
NetworkManager conn = null;
|
NetworkManager conn = null;
|
||||||
|
@ -8,6 +8,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -272,6 +274,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
return skinTracker;
|
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) {
|
private void initialise(MinecraftServer minecraftServer) {
|
||||||
Socket socket = new EmptySocket();
|
Socket socket = new EmptySocket();
|
||||||
NetworkManager conn = null;
|
NetworkManager conn = null;
|
||||||
|
@ -7,6 +7,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -263,6 +265,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
return skinTracker;
|
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) {
|
private void initialise(MinecraftServer minecraftServer) {
|
||||||
Socket socket = new EmptySocket();
|
Socket socket = new EmptySocket();
|
||||||
NetworkManager conn = null;
|
NetworkManager conn = null;
|
||||||
|
@ -7,6 +7,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -264,6 +266,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
// cancelled.
|
// 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) {
|
private void initialise(MinecraftServer minecraftServer) {
|
||||||
Socket socket = new EmptySocket();
|
Socket socket = new EmptySocket();
|
||||||
NetworkManager conn = null;
|
NetworkManager conn = null;
|
||||||
|
@ -9,6 +9,8 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -278,6 +280,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
// cancelled.
|
// 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) {
|
private void initialise(MinecraftServer minecraftServer) {
|
||||||
Socket socket = new EmptySocket();
|
Socket socket = new EmptySocket();
|
||||||
NetworkManager conn = null;
|
NetworkManager conn = null;
|
||||||
@ -376,7 +391,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super.playerTick();
|
super.playerTick();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
noclip = true;
|
||||||
entityBaseTick();
|
entityBaseTick();
|
||||||
|
noclip = false;
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
if (!navigating && getBukkitEntity() != null
|
if (!navigating && getBukkitEntity() != null
|
||||||
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -243,6 +244,19 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
return skinTracker;
|
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) {
|
private void initialise(MinecraftServer minecraftServer) {
|
||||||
Socket socket = new EmptySocket();
|
Socket socket = new EmptySocket();
|
||||||
NetworkManager conn = null;
|
NetworkManager conn = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user