mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 12:15:53 +01:00
Implement new bounding box checker for pathfinding
This commit is contained in:
parent
381f303023
commit
9d2cad098a
@ -113,7 +113,8 @@ public class Settings {
|
||||
MAX_TEXT_RANGE("npc.chat.options.max-text-range", 500),
|
||||
MAXIMUM_ASTAR_ITERATIONS("npc.pathfinding.maximum-new-pathfinder-iterations", 50000),
|
||||
MESSAGE_COLOUR("general.color-scheme.message", "<a>"),
|
||||
NEW_PATHFINDER_OPENS_DOORS("npc.pathfinding.new-finder-open-doors", false),
|
||||
NEW_PATHFINDER_CHECK_BOUNDING_BOXES("npc.pathfinding.new-finder.check-bounding-boxes", false),
|
||||
NEW_PATHFINDER_OPENS_DOORS("npc.pathfinding.new-finder.open-doors", false),
|
||||
NPC_ATTACK_DISTANCE("npc.pathfinding.attack-range", 1.75 * 1.75),
|
||||
NPC_COST("economy.npc.cost", 100D),
|
||||
NPC_SKIN_RETRY_DELAY("npc.skins.retry-delay", 120),
|
||||
|
@ -17,7 +17,6 @@ import net.citizensnpcs.api.ai.event.CancelReason;
|
||||
import net.citizensnpcs.api.astar.AStarMachine;
|
||||
import net.citizensnpcs.api.astar.pathfinder.BlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.BlockSource;
|
||||
import net.citizensnpcs.api.astar.pathfinder.ChunkBlockSource;
|
||||
import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.Path;
|
||||
import net.citizensnpcs.api.astar.pathfinder.PathPoint;
|
||||
@ -80,7 +79,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
Location location = npc.getEntity().getLocation();
|
||||
VectorGoal goal = new VectorGoal(destination, (float) params.pathDistanceMargin());
|
||||
state = ASTAR.getStateFor(goal,
|
||||
new VectorNode(goal, location, new ChunkBlockSource(location, params.range()), params.examiners()));
|
||||
new VectorNode(goal, location, new NMSChunkBlockSource(location, params.range()), params.examiners()));
|
||||
}
|
||||
|
||||
public void setPlan(Path path) {
|
||||
@ -134,7 +133,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
Location currLoc = npc.getEntity().getLocation(NPC_LOCATION);
|
||||
Vector destVector = new Vector(vector.getX() + 0.5, vector.getY(), vector.getZ() + 0.5);
|
||||
/* Proper door movement - gets stuck on corners at times
|
||||
|
||||
|
||||
Block block = currLoc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
if (MinecraftBlockExaminer.isDoor(block.getType())) {
|
||||
Door door = (Door) block.getState().getData();
|
||||
|
@ -0,0 +1,44 @@
|
||||
package net.citizensnpcs.npc.ai;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.astar.pathfinder.BlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.BlockSource;
|
||||
import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.PathPoint;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
|
||||
public class BoundingBoxExaminer implements BlockExaminer {
|
||||
private double height;
|
||||
private double width;
|
||||
|
||||
public BoundingBoxExaminer(Entity entity) {
|
||||
if (entity != null) {
|
||||
this.height = entity.getHeight();
|
||||
this.width = entity.getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCost(BlockSource source, PathPoint point) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PassableState isPassable(BlockSource source, PathPoint point) {
|
||||
Vector pos = point.getVector();
|
||||
Material up = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() + 2, pos.getBlockZ());
|
||||
Material down = source.getMaterialAt(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ());
|
||||
if (!MinecraftBlockExaminer.canStandIn(up) && MinecraftBlockExaminer.canStandOn(down)) {
|
||||
BoundingBox above = source.getCollisionBox(pos.getBlockX(), pos.getBlockY() + 2, pos.getBlockZ());
|
||||
BoundingBox below = source.getCollisionBox(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ());
|
||||
float height = (float) (above.minY - below.maxY);
|
||||
if (height < this.height) {
|
||||
return PassableState.UNPASSABLE;
|
||||
}
|
||||
}
|
||||
return PassableState.IGNORE;
|
||||
}
|
||||
}
|
@ -330,6 +330,9 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
: npc.data().<Boolean> get(NPC.PATHFINDER_OPEN_DOORS_METADATA)) {
|
||||
localParams.examiner(new DoorExaminer());
|
||||
}
|
||||
if (Setting.NEW_PATHFINDER_CHECK_BOUNDING_BOXES.asBoolean()) {
|
||||
localParams.examiner(new BoundingBoxExaminer(npc.getEntity()));
|
||||
}
|
||||
}
|
||||
|
||||
private void switchStrategyTo(PathStrategy newStrategy) {
|
||||
|
@ -20,7 +20,6 @@ import net.citizensnpcs.api.ai.TargetType;
|
||||
import net.citizensnpcs.api.ai.event.CancelReason;
|
||||
import net.citizensnpcs.api.astar.AStarMachine;
|
||||
import net.citizensnpcs.api.astar.pathfinder.BlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.ChunkBlockSource;
|
||||
import net.citizensnpcs.api.astar.pathfinder.FlyingBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.MinecraftBlockExaminer;
|
||||
import net.citizensnpcs.api.astar.pathfinder.Path;
|
||||
@ -101,7 +100,7 @@ public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
|
||||
parameters.examiner(new FlyingBlockExaminer());
|
||||
}
|
||||
setPlan(ASTAR.runFully(goal, new VectorNode(goal, location,
|
||||
new ChunkBlockSource(location, parameters.range()), parameters.examiners()),
|
||||
new NMSChunkBlockSource(location, parameters.range()), parameters.examiners()),
|
||||
Setting.MAXIMUM_ASTAR_ITERATIONS.asInt()));
|
||||
}
|
||||
if (getCancelReason() != null || plan == null || plan.isComplete()) {
|
||||
|
@ -12,7 +12,7 @@ import net.citizensnpcs.api.ai.PathStrategy;
|
||||
import net.citizensnpcs.api.ai.TargetType;
|
||||
import net.citizensnpcs.api.ai.event.CancelReason;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
|
||||
public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
|
@ -0,0 +1,19 @@
|
||||
package net.citizensnpcs.npc.ai;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import net.citizensnpcs.api.astar.pathfinder.ChunkBlockSource;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
|
||||
public class NMSChunkBlockSource extends ChunkBlockSource {
|
||||
public NMSChunkBlockSource(Location location, float radius) {
|
||||
super(location, radius);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BoundingBox getCollisionBox(Chunk chunk, int x, int y, int z) {
|
||||
return NMS.getCollisionBox(chunk.getBlock(x, y, z));
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package net.citizensnpcs.util;
|
||||
|
||||
public class BoundingBox {
|
||||
public final double maxX;
|
||||
public final double maxY;
|
||||
public final double maxZ;
|
||||
public final double minX;
|
||||
public final double minY;
|
||||
public final double minZ;
|
||||
|
||||
public BoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
@ -75,6 +76,10 @@ public class NMS {
|
||||
return BRIDGE.getBoundingBox(handle);
|
||||
}
|
||||
|
||||
public static BoundingBox getCollisionBox(Block block) {
|
||||
return BRIDGE.getCollisionBox(block).add(block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static Field getField(Class<?> clazz, String field) {
|
||||
return getField(clazz, field, true);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
@ -48,6 +49,8 @@ public interface NMSBridge {
|
||||
|
||||
public BoundingBox getBoundingBox(Entity handle);
|
||||
|
||||
public BoundingBox getCollisionBox(Block block);
|
||||
|
||||
public GameProfileRepository getGameProfileRepository();
|
||||
|
||||
public float getHeadYaw(Entity entity);
|
||||
|
@ -68,6 +68,7 @@ import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.TraitInfo;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.BatController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.BlazeController;
|
||||
@ -146,7 +147,6 @@ import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -336,6 +336,17 @@ public class NMSImpl implements NMSBridge {
|
||||
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
|
||||
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
|
||||
BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
|
||||
AxisAlignedBB aabb = world.getType(pos).c(world, pos);
|
||||
if (aabb == null) {
|
||||
aabb = world.getType(pos).d(world, pos);
|
||||
}
|
||||
return new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
|
@ -67,6 +67,7 @@ import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.TraitInfo;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.nms.v1_11_R1.entity.BatController;
|
||||
import net.citizensnpcs.nms.v1_11_R1.entity.BlazeController;
|
||||
@ -161,7 +162,6 @@ import net.citizensnpcs.trait.versioned.BossBarTrait;
|
||||
import net.citizensnpcs.trait.versioned.LlamaTrait;
|
||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -355,6 +355,17 @@ public class NMSImpl implements NMSBridge {
|
||||
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
|
||||
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
|
||||
BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
|
||||
AxisAlignedBB aabb = world.getType(pos).c(world, pos);
|
||||
if (aabb == null) {
|
||||
aabb = world.getType(pos).d(world, pos);
|
||||
}
|
||||
return new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
|
@ -67,6 +67,7 @@ import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.TraitInfo;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.nms.v1_12_R1.entity.BatController;
|
||||
import net.citizensnpcs.nms.v1_12_R1.entity.BlazeController;
|
||||
@ -164,7 +165,6 @@ import net.citizensnpcs.trait.versioned.LlamaTrait;
|
||||
import net.citizensnpcs.trait.versioned.ParrotTrait;
|
||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -359,6 +359,17 @@ public class NMSImpl implements NMSBridge {
|
||||
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
|
||||
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
|
||||
BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
|
||||
AxisAlignedBB aabb = world.getType(pos).d(world, pos);
|
||||
if (aabb == null) {
|
||||
aabb = world.getType(pos).e(world, pos);
|
||||
}
|
||||
return new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
|
@ -2,7 +2,7 @@ package net.citizensnpcs.nms.v1_13_R2.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.server.v1_13_R2.AxisAlignedBB;
|
||||
|
||||
|
@ -26,6 +26,7 @@ import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftSound;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.boss.CraftBossBar;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
|
||||
@ -68,6 +69,7 @@ import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.TraitInfo;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.BatController;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.BlazeController;
|
||||
@ -177,7 +179,6 @@ import net.citizensnpcs.trait.versioned.PufferFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -241,6 +242,7 @@ import net.minecraft.server.v1_13_R2.ScoreboardTeamBase.EnumNameTagVisibility;
|
||||
import net.minecraft.server.v1_13_R2.SoundEffect;
|
||||
import net.minecraft.server.v1_13_R2.SoundEffects;
|
||||
import net.minecraft.server.v1_13_R2.Vec3D;
|
||||
import net.minecraft.server.v1_13_R2.VoxelShape;
|
||||
import net.minecraft.server.v1_13_R2.WorldServer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -381,6 +383,16 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSBoundingBox.wrap(NMSImpl.getHandle(handle).getBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
|
||||
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
|
||||
VoxelShape shape = ((CraftBlock) block).getNMS().getCollisionShape(world, ((CraftBlock) block).getPosition());
|
||||
AxisAlignedBB aabb = shape.isEmpty()
|
||||
? ((CraftBlock) block).getNMS().getShape(world, ((CraftBlock) block).getPosition()).getBoundingBox()
|
||||
: shape.getBoundingBox();
|
||||
return aabb == null ? BoundingBox.convert(block.getBoundingBox()) : NMSBoundingBox.wrap(aabb);
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_13_R2.util;
|
||||
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.minecraft.server.v1_13_R2.Entity;
|
||||
import net.minecraft.server.v1_13_R2.EntityLiving;
|
||||
import net.minecraft.server.v1_13_R2.MathHelper;
|
||||
|
@ -2,8 +2,8 @@ package net.citizensnpcs.nms.v1_13_R2.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.server.v1_13_R2.AttributeInstance;
|
||||
import net.minecraft.server.v1_13_R2.ControllerMove;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.citizensnpcs.nms.v1_13_R2.util;
|
||||
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.server.v1_13_R2.*;
|
||||
|
||||
|
@ -4,8 +4,8 @@ import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.minecraft.server.v1_13_R2.BlockPosition;
|
||||
import net.minecraft.server.v1_13_R2.Entity;
|
||||
import net.minecraft.server.v1_13_R2.EntityInsentient;
|
||||
|
@ -7,8 +7,8 @@ import java.util.Iterator;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.server.v1_13_R2.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_13_R2.Block;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.citizensnpcs.nms.v1_14_R1.util;
|
||||
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.minecraft.server.v1_14_R1.AxisAlignedBB;
|
||||
|
||||
public class NMSBoundingBox {
|
||||
|
@ -27,6 +27,7 @@ import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftSound;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.boss.CraftBossBar;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||
@ -70,6 +71,7 @@ import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.TraitInfo;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.nms.v1_14_R1.entity.BatController;
|
||||
import net.citizensnpcs.nms.v1_14_R1.entity.BlazeController;
|
||||
@ -191,7 +193,6 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -261,6 +262,7 @@ import net.minecraft.server.v1_14_R1.ScoreboardTeam;
|
||||
import net.minecraft.server.v1_14_R1.ScoreboardTeamBase.EnumNameTagVisibility;
|
||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_14_R1.Vec3D;
|
||||
import net.minecraft.server.v1_14_R1.VoxelShape;
|
||||
import net.minecraft.server.v1_14_R1.WorldServer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -417,6 +419,16 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSBoundingBox.wrap(NMSImpl.getHandle(handle).getBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
|
||||
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
|
||||
VoxelShape shape = ((CraftBlock) block).getNMS().getCollisionShape(world, ((CraftBlock) block).getPosition());
|
||||
AxisAlignedBB aabb = shape.isEmpty()
|
||||
? ((CraftBlock) block).getNMS().getShape(world, ((CraftBlock) block).getPosition()).getBoundingBox()
|
||||
: shape.getBoundingBox();
|
||||
return aabb == null ? BoundingBox.convert(block.getBoundingBox()) : NMSBoundingBox.wrap(aabb);
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.citizensnpcs.nms.v1_15_R1.util;
|
||||
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.minecraft.server.v1_15_R1.AxisAlignedBB;
|
||||
|
||||
public class NMSBoundingBox {
|
||||
|
@ -27,6 +27,7 @@ import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftSound;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.boss.CraftBossBar;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
@ -70,6 +71,7 @@ import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.TraitInfo;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.nms.v1_15_R1.entity.BatController;
|
||||
import net.citizensnpcs.nms.v1_15_R1.entity.BeeController;
|
||||
@ -193,7 +195,6 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -263,6 +264,7 @@ import net.minecraft.server.v1_15_R1.ScoreboardTeam;
|
||||
import net.minecraft.server.v1_15_R1.ScoreboardTeamBase.EnumNameTagVisibility;
|
||||
import net.minecraft.server.v1_15_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_15_R1.Vec3D;
|
||||
import net.minecraft.server.v1_15_R1.VoxelShape;
|
||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -424,6 +426,16 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSBoundingBox.wrap(NMSImpl.getHandle(handle).getBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
|
||||
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
|
||||
VoxelShape shape = ((CraftBlock) block).getNMS().getCollisionShape(world, ((CraftBlock) block).getPosition());
|
||||
AxisAlignedBB aabb = shape.isEmpty()
|
||||
? ((CraftBlock) block).getNMS().getShape(world, ((CraftBlock) block).getPosition()).getBoundingBox()
|
||||
: shape.getBoundingBox();
|
||||
return aabb == null ? BoundingBox.convert(block.getBoundingBox()) : NMSBoundingBox.wrap(aabb);
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX() - tX) / (handle.locZ() - tZ))));
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.citizensnpcs.nms.v1_16_R1.util;
|
||||
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.minecraft.server.v1_16_R1.AxisAlignedBB;
|
||||
|
||||
public class NMSBoundingBox {
|
||||
|
@ -27,6 +27,7 @@ import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftSound;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.boss.CraftBossBar;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
|
||||
@ -70,6 +71,7 @@ import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.TraitInfo;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.nms.v1_16_R1.entity.BatController;
|
||||
import net.citizensnpcs.nms.v1_16_R1.entity.BeeController;
|
||||
@ -197,7 +199,6 @@ import net.citizensnpcs.trait.versioned.ShulkerTrait;
|
||||
import net.citizensnpcs.trait.versioned.SnowmanTrait;
|
||||
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
|
||||
import net.citizensnpcs.trait.versioned.VillagerTrait;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -269,6 +270,7 @@ import net.minecraft.server.v1_16_R1.ScoreboardTeamBase.EnumNameTagVisibility;
|
||||
import net.minecraft.server.v1_16_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_16_R1.TagsFluid;
|
||||
import net.minecraft.server.v1_16_R1.Vec3D;
|
||||
import net.minecraft.server.v1_16_R1.VoxelShape;
|
||||
import net.minecraft.server.v1_16_R1.WorldServer;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -430,6 +432,16 @@ public class NMSImpl implements NMSBridge {
|
||||
return NMSBoundingBox.wrap(NMSImpl.getHandle(handle).getBoundingBox());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
|
||||
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
|
||||
VoxelShape shape = ((CraftBlock) block).getNMS().getCollisionShape(world, ((CraftBlock) block).getPosition());
|
||||
AxisAlignedBB aabb = shape.isEmpty()
|
||||
? ((CraftBlock) block).getNMS().getShape(world, ((CraftBlock) block).getPosition()).getBoundingBox()
|
||||
: shape.getBoundingBox();
|
||||
return aabb == null ? BoundingBox.convert(block.getBoundingBox()) : NMSBoundingBox.wrap(aabb);
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ() > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX() - tX) / (handle.locZ() - tZ))));
|
||||
|
@ -26,6 +26,7 @@ import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWither;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -61,6 +62,7 @@ import net.citizensnpcs.api.npc.BlockBreaker;
|
||||
import net.citizensnpcs.api.npc.BlockBreaker.BlockBreakerConfiguration;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.util.BoundingBox;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.nms.v1_8_R3.entity.BatController;
|
||||
import net.citizensnpcs.nms.v1_8_R3.entity.BlazeController;
|
||||
@ -127,7 +129,6 @@ import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
||||
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.util.BoundingBox;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.NMSBridge;
|
||||
@ -288,6 +289,15 @@ public class NMSImpl implements NMSBridge {
|
||||
return new BoundingBox(bb.a, bb.b, bb.c, bb.d, bb.e, bb.f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundingBox getCollisionBox(org.bukkit.block.Block block) {
|
||||
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
|
||||
Block type = CraftMagicNumbers.getBlock(block);
|
||||
BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
|
||||
AxisAlignedBB aabb = type.a(world, pos, world.getType(pos));
|
||||
return new BoundingBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
|
||||
}
|
||||
|
||||
private float getDragonYaw(Entity handle, double tX, double tZ) {
|
||||
if (handle.locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((handle.locX - tX) / (handle.locZ - tZ))));
|
||||
|
Loading…
Reference in New Issue
Block a user