From b27197fc92929532f191b185489175e0f2d5610f Mon Sep 17 00:00:00 2001 From: Dawson Hessler Date: Fri, 18 Oct 2019 15:36:09 -0400 Subject: [PATCH] Fixed bugs with boxes and added code improvements - Removed useless instances of some utils in which are static but I made an instance for a long time ago because I sucked at java. - Added Block.collisionBoxes to boundingBox checks because of problems with certain block boundingboxes getting called but theyre always the same boundingBox type no matter orientation. --- AtlasParent/Atlas/buildNumber.properties | 4 +- .../main/java/cc/funkemunky/api/Atlas.java | 4 - .../cc/funkemunky/api/utils/BlockUtils.java | 14 +-- .../java/cc/funkemunky/api/utils/Color.java | 7 +- .../cc/funkemunky/api/utils/MiscUtils.java | 56 ++++----- .../funkemunky/api/utils/ReflectionsUtil.java | 16 +-- .../utils/blockbox/boxes/BlockBox1_10_R1.java | 69 ++++++----- .../utils/blockbox/boxes/BlockBox1_11_R1.java | 113 +++++++++-------- .../utils/blockbox/boxes/BlockBox1_12_R1.java | 115 +++++++++--------- .../utils/blockbox/boxes/BlockBox1_7_R4.java | 57 +++++---- .../utils/blockbox/boxes/BlockBox1_8_R1.java | 77 ++++++------ .../utils/blockbox/boxes/BlockBox1_8_R2.java | 74 +++++------ .../utils/blockbox/boxes/BlockBox1_8_R3.java | 79 ++++++------ .../utils/blockbox/boxes/BlockBox1_9_R1.java | 69 ++++++----- .../utils/blockbox/boxes/BlockBox1_9_R2.java | 69 ++++++----- .../AtlasBungee/buildNumber.properties | 4 +- 16 files changed, 427 insertions(+), 400 deletions(-) diff --git a/AtlasParent/Atlas/buildNumber.properties b/AtlasParent/Atlas/buildNumber.properties index ddf1ee30..44ed8efc 100644 --- a/AtlasParent/Atlas/buildNumber.properties +++ b/AtlasParent/Atlas/buildNumber.properties @@ -1,3 +1,3 @@ #maven.buildNumber.plugin properties file -#Wed Oct 16 12:09:32 EDT 2019 -buildNumber=427 +#Fri Oct 18 15:34:54 EDT 2019 +buildNumber=432 diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/Atlas.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/Atlas.java index 9c7e879a..fa7eb22a 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/Atlas.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/Atlas.java @@ -96,10 +96,6 @@ public void onEnable() { blockBoxManager = new BlockBoxManager(); commandManager = new CommandManager(this); funkeCommandManager = new FunkeCommandManager(); - new BlockUtils(); - new ReflectionsUtil(); - new Color(); - new MiscUtils(); updater = new Updater(); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/BlockUtils.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/BlockUtils.java index 6655a5aa..c3dfa271 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/BlockUtils.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/BlockUtils.java @@ -15,15 +15,9 @@ public class BlockUtils { - public static Map collisionBoundingBoxes; + public static Map collisionBoundingBoxes = new HashMap<>();; public static Map blockBounds = new HashMap<>(); - public BlockUtils() { - collisionBoundingBoxes = new HashMap<>(); - - setupCollisionBB(); - } - public static Block getBlock(Location location) { if (Atlas.getInstance().getBlockBoxManager().getBlockBox().isChunkLoaded(location)) { return location.getBlock(); @@ -344,7 +338,7 @@ public static Location findGround(World world, Location point) { return point; } - private void setupCollisionBB() { + private static void setupCollisionBB() { if(ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.V1_13)) { collisionBoundingBoxes.put(Material.getMaterial("FIRE"), new BoundingBox((float) 0.0, (float) 0.0, (float) 0.0, (float) 1.0, (float) 1.0, (float) 1.0)); collisionBoundingBoxes.put(Material.getMaterial("STONE_PLATE"), new BoundingBox((float) 0.0625, (float) 0.0, (float) 0.0625, (float) 0.9375, (float) 0.0625, (float) 0.9375)); @@ -441,5 +435,9 @@ private void setupCollisionBB() { collisionBoundingBoxes.put(Material.getMaterial("STATIONARY_LAVA"), new BoundingBox(0, 0, 0, 0.9f, 0.9f, 0.9f)); } } + + static { + setupCollisionBB(); + } } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/Color.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/Color.java index fae321c5..12c0c1d3 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/Color.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/Color.java @@ -26,11 +26,6 @@ public class Color { public static final String Purple = ChatColor.DARK_PURPLE.toString(); public static final String Black = ChatColor.BLACK.toString(); public static final String Underline = ChatColor.UNDERLINE.toString(); - private static Color instance; - - public Color() { - instance = this; - } public static String translate(String string) { return ChatColor.translateAlternateColorCodes('&', string); @@ -44,7 +39,7 @@ public static String getColorFromString(String string) { if (string.contains("&")) { return ChatColor.translateAlternateColorCodes('&', string); } else { - String color = (String) ReflectionsUtil.getFieldValue(ReflectionsUtil.getFieldByName(instance.getClass(), string), instance); + String color = (String) ReflectionsUtil.getFieldValue(ReflectionsUtil.getFieldByName(null, string), null); if (color == null) { Bukkit.getLogger().log(Level.WARNING, "The color '" + string + "' does not exist."); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/MiscUtils.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/MiscUtils.java index 664ba9a1..f0c54f07 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/MiscUtils.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/MiscUtils.java @@ -22,35 +22,7 @@ public class MiscUtils { - public static Map entityDimensions; - - public MiscUtils() { - entityDimensions = new HashMap<>(); - - entityDimensions.put(EntityType.WOLF, new Vector(0.31, 0.8, 0.31)); - entityDimensions.put(EntityType.SHEEP, new Vector(0.45, 1.3, 0.45)); - entityDimensions.put(EntityType.COW, new Vector(0.45, 1.3, 0.45)); - entityDimensions.put(EntityType.PIG, new Vector(0.45, 0.9, 0.45)); - entityDimensions.put(EntityType.MUSHROOM_COW, new Vector(0.45, 1.3, 0.45)); - entityDimensions.put(EntityType.WITCH, new Vector(0.31, 1.95, 0.31)); - entityDimensions.put(EntityType.BLAZE, new Vector(0.31, 1.8, 0.31)); - entityDimensions.put(EntityType.PLAYER, new Vector(0.3, 1.8, 0.3)); - entityDimensions.put(EntityType.VILLAGER, new Vector(0.31, 1.8, 0.31)); - entityDimensions.put(EntityType.CREEPER, new Vector(0.31, 1.8, 0.31)); - entityDimensions.put(EntityType.GIANT, new Vector(1.8, 10.8, 1.8)); - entityDimensions.put(EntityType.SKELETON, new Vector(0.31, 1.8, 0.31)); - entityDimensions.put(EntityType.ZOMBIE, new Vector(0.31, 1.8, 0.31)); - entityDimensions.put(EntityType.SNOWMAN, new Vector(0.35, 1.9, 0.35)); - entityDimensions.put(EntityType.HORSE, new Vector(0.7, 1.6, 0.7)); - entityDimensions.put(EntityType.ENDER_DRAGON, new Vector(1.5, 1.5, 1.5)); - entityDimensions.put(EntityType.ENDERMAN, new Vector(0.31, 2.9, 0.31)); - entityDimensions.put(EntityType.CHICKEN, new Vector(0.2, 0.7, 0.2)); - entityDimensions.put(EntityType.OCELOT, new Vector(0.31, 0.7, 0.31)); - entityDimensions.put(EntityType.SPIDER, new Vector(0.7, 0.9, 0.7)); - entityDimensions.put(EntityType.WITHER, new Vector(0.45, 3.5, 0.45)); - entityDimensions.put(EntityType.IRON_GOLEM, new Vector(0.7, 2.9, 0.7)); - entityDimensions.put(EntityType.GHAST, new Vector(2, 4, 2)); - } + public static Map entityDimensions = new HashMap<>();; public static boolean containsIgnoreCase(String toCheck, String contains) { return toCheck.toLowerCase().contains(contains.toLowerCase()); @@ -306,5 +278,31 @@ private static Plugin getPlugin(final String p) { public static void printToConsole(String string) { Atlas.getInstance().getConsoleSender().sendMessage(Color.translate(string)); } + + static { + entityDimensions.put(EntityType.WOLF, new Vector(0.31, 0.8, 0.31)); + entityDimensions.put(EntityType.SHEEP, new Vector(0.45, 1.3, 0.45)); + entityDimensions.put(EntityType.COW, new Vector(0.45, 1.3, 0.45)); + entityDimensions.put(EntityType.PIG, new Vector(0.45, 0.9, 0.45)); + entityDimensions.put(EntityType.MUSHROOM_COW, new Vector(0.45, 1.3, 0.45)); + entityDimensions.put(EntityType.WITCH, new Vector(0.31, 1.95, 0.31)); + entityDimensions.put(EntityType.BLAZE, new Vector(0.31, 1.8, 0.31)); + entityDimensions.put(EntityType.PLAYER, new Vector(0.3, 1.8, 0.3)); + entityDimensions.put(EntityType.VILLAGER, new Vector(0.31, 1.8, 0.31)); + entityDimensions.put(EntityType.CREEPER, new Vector(0.31, 1.8, 0.31)); + entityDimensions.put(EntityType.GIANT, new Vector(1.8, 10.8, 1.8)); + entityDimensions.put(EntityType.SKELETON, new Vector(0.31, 1.8, 0.31)); + entityDimensions.put(EntityType.ZOMBIE, new Vector(0.31, 1.8, 0.31)); + entityDimensions.put(EntityType.SNOWMAN, new Vector(0.35, 1.9, 0.35)); + entityDimensions.put(EntityType.HORSE, new Vector(0.7, 1.6, 0.7)); + entityDimensions.put(EntityType.ENDER_DRAGON, new Vector(1.5, 1.5, 1.5)); + entityDimensions.put(EntityType.ENDERMAN, new Vector(0.31, 2.9, 0.31)); + entityDimensions.put(EntityType.CHICKEN, new Vector(0.2, 0.7, 0.2)); + entityDimensions.put(EntityType.OCELOT, new Vector(0.31, 0.7, 0.31)); + entityDimensions.put(EntityType.SPIDER, new Vector(0.7, 0.9, 0.7)); + entityDimensions.put(EntityType.WITHER, new Vector(0.45, 3.5, 0.45)); + entityDimensions.put(EntityType.IRON_GOLEM, new Vector(0.7, 2.9, 0.7)); + entityDimensions.put(EntityType.GHAST, new Vector(2, 4, 2)); + } } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/ReflectionsUtil.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/ReflectionsUtil.java index df5675d9..d1e8a362 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/ReflectionsUtil.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/ReflectionsUtil.java @@ -44,14 +44,6 @@ public class ReflectionsUtil { private static Method getCubes = getMethod(World, "a", getNMSClass("AxisAlignedBB")); private static Method getCubes1_12 = getMethod(World, "getCubes", getNMSClass("Entity"), getNMSClass("AxisAlignedBB")); - public ReflectionsUtil() { - if (ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_8)) { - iBlockData = getNMSClass("IBlockData"); - blockPosition = getNMSClass("BlockPosition"); - iBlockAccess = getNMSClass("IBlockAccess"); - } - } - public static Object getEntityPlayer(Player player) { return getMethodValue(getMethod(CraftPlayer, "getHandle"), player); } @@ -579,4 +571,12 @@ public static Object newInstance(Class objectClass, Object... args) { public static Class getNMSClass(String string) { return getClass("net.minecraft.server." + version + "." + string); } + + static { + if (ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_8)) { + iBlockData = getNMSClass("IBlockData"); + blockPosition = getNMSClass("BlockPosition"); + iBlockAccess = getNMSClass("IBlockAccess"); + } + } } \ No newline at end of file diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_10_R1.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_10_R1.java index d1e3dbe7..834ad8d6 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_10_R1.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_10_R1.java @@ -50,43 +50,48 @@ public List getCollidingBoxes(org.bukkit.World world, BoundingBox b locs.parallelStream().forEach(loc -> { org.bukkit.block.Block block = loc.getBlock(); if (block != null && !block.getType().equals(Material.AIR)) { - int x = block.getX(), y = block.getY(), z = block.getZ(); - - BlockPosition pos = new BlockPosition(x, y, z); - World nmsWorld = ((CraftWorld) world).getHandle(); - IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); - Block nmsBlock = nmsiBlockData.getBlock(); - List preBoxes = new ArrayList<>(); - - nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); - nmsBlock.a(nmsiBlockData, - nmsWorld, - pos, - (AxisAlignedBB) box.toAxisAlignedBB(), - preBoxes, - null); - - if (preBoxes.size() > 0) { - for (AxisAlignedBB aabb : preBoxes) { - BoundingBox bb = new BoundingBox( - (float)aabb.a, - (float)aabb.b, - (float)aabb.c, - (float)aabb.d, - (float)aabb.e, - (float)aabb.f); + if(BlockUtils.collisionBoundingBoxes.containsKey(block.getType())) { + BoundingBox box2 = BlockUtils.collisionBoundingBoxes.get(block.getType()).add(block.getLocation().toVector()); + boxes.add(box2); + } else { + int x = block.getX(), y = block.getY(), z = block.getZ(); + + BlockPosition pos = new BlockPosition(x, y, z); + World nmsWorld = ((CraftWorld) world).getHandle(); + IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); + Block nmsBlock = nmsiBlockData.getBlock(); + List preBoxes = new ArrayList<>(); + + nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); + nmsBlock.a(nmsiBlockData, + nmsWorld, + pos, + (AxisAlignedBB) box.toAxisAlignedBB(), + preBoxes, + null); + + if (preBoxes.size() > 0) { + for (AxisAlignedBB aabb : preBoxes) { + BoundingBox bb = new BoundingBox( + (float)aabb.a, + (float)aabb.b, + (float)aabb.c, + (float)aabb.d, + (float)aabb.e, + (float)aabb.f); + + if(bb.collides(box)) { + boxes.add(bb); + } + } + } else { + BoundingBox bb = ReflectionsUtil.toBoundingBox(nmsBlock.a(nmsiBlockData, nmsWorld, pos)) + .add(x, y, z, x, y, z); if(bb.collides(box)) { boxes.add(bb); } } - } else { - BoundingBox bb = ReflectionsUtil.toBoundingBox(nmsBlock.a(nmsiBlockData, nmsWorld, pos)) - .add(x, y, z, x, y, z); - - if(bb.collides(box)) { - boxes.add(bb); - } } } }); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_11_R1.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_11_R1.java index 18231a2e..e80163d3 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_11_R1.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_11_R1.java @@ -51,65 +51,70 @@ public List getCollidingBoxes(org.bukkit.World world, BoundingBox b locs.parallelStream().forEach(loc -> { org.bukkit.block.Block block = loc.getBlock(); if (block != null && !block.getType().equals(Material.AIR)) { - int x = block.getX(), y = block.getY(), z = block.getZ(); - - BlockPosition pos = new BlockPosition(x, y, z); - World nmsWorld = ((CraftWorld) world).getHandle(); - IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); - Block nmsBlock = nmsiBlockData.getBlock(); - List preBoxes = new ArrayList<>(); - - nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); - nmsBlock.a(nmsiBlockData, - nmsWorld, - pos, - (AxisAlignedBB) box.toAxisAlignedBB(), - preBoxes, - null, - true); - - if (preBoxes.size() > 0) { - for (AxisAlignedBB aabb : preBoxes) { - BoundingBox bb = new BoundingBox( - (float)aabb.a, - (float)aabb.b, - (float)aabb.c, - (float)aabb.d, - (float)aabb.e, - (float)aabb.f); - - if(bb.collides(box)) { - boxes.add(bb); + if(BlockUtils.collisionBoundingBoxes.containsKey(block.getType())) { + BoundingBox box2 = BlockUtils.collisionBoundingBoxes.get(block.getType()).add(block.getLocation().toVector()); + boxes.add(box2); + } else { + int x = block.getX(), y = block.getY(), z = block.getZ(); + + BlockPosition pos = new BlockPosition(x, y, z); + World nmsWorld = ((CraftWorld) world).getHandle(); + IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); + Block nmsBlock = nmsiBlockData.getBlock(); + List preBoxes = new ArrayList<>(); + + nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); + nmsBlock.a(nmsiBlockData, + nmsWorld, + pos, + (AxisAlignedBB) box.toAxisAlignedBB(), + preBoxes, + null, + false); + + if (preBoxes.size() > 0) { + for (AxisAlignedBB aabb : preBoxes) { + BoundingBox bb = new BoundingBox( + (float)aabb.a, + (float)aabb.b, + (float)aabb.c, + (float)aabb.d, + (float)aabb.e, + (float)aabb.f); + + if(bb.collides(box)) { + boxes.add(bb); + } } - } - if (nmsBlock instanceof BlockShulkerBox) { - TileEntity tileentity = nmsWorld.getTileEntity(pos); - BlockShulkerBox shulker = (BlockShulkerBox) nmsBlock; - - if (tileentity instanceof TileEntityShulkerBox) { - TileEntityShulkerBox entity = (TileEntityShulkerBox) tileentity; - //Bukkit.broadcastMessage("entity"); - boxes.add(ReflectionsUtil.toBoundingBox(entity.a(nmsiBlockData))); - - if (entity.p().toString().contains("OPEN") - || entity.p().toString().contains("CLOSING")) { - boxes.add(new BoundingBox( - block.getX(), - block.getY(), - block.getZ(), - block.getX() + 1, - block.getY() + 1.5f, - block.getZ() + 1)); + if (nmsBlock instanceof BlockShulkerBox) { + TileEntity tileentity = nmsWorld.getTileEntity(pos); + BlockShulkerBox shulker = (BlockShulkerBox) nmsBlock; + + if (tileentity instanceof TileEntityShulkerBox) { + TileEntityShulkerBox entity = (TileEntityShulkerBox) tileentity; + //Bukkit.broadcastMessage("entity"); + boxes.add(ReflectionsUtil.toBoundingBox(entity.a(nmsiBlockData))); + + if (entity.p().toString().contains("OPEN") + || entity.p().toString().contains("CLOSING")) { + boxes.add(new BoundingBox( + block.getX(), + block.getY(), + block.getZ(), + block.getX() + 1, + block.getY() + 1.5f, + block.getZ() + 1)); + } } } - } - } else { - BoundingBox bb = ReflectionsUtil.toBoundingBox(nmsBlock.a(nmsiBlockData, nmsWorld, pos)) - .add(x, y, z, x, y, z); + } else { + BoundingBox bb = ReflectionsUtil.toBoundingBox(nmsBlock.a(nmsiBlockData, nmsWorld, pos)) + .add(x, y, z, x, y, z); - if(bb.collides(box)) { - boxes.add(bb); + if(bb.collides(box)) { + boxes.add(bb); + } } } } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_12_R1.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_12_R1.java index e86075f7..247bdaff 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_12_R1.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_12_R1.java @@ -50,67 +50,72 @@ public List getCollidingBoxes(org.bukkit.World world, BoundingBox b locs.parallelStream().forEach(loc -> { org.bukkit.block.Block block = loc.getBlock(); if (block != null && !block.getType().equals(Material.AIR)) { - int x = block.getX(), y = block.getY(), z = block.getZ(); - - BlockPosition pos = new BlockPosition(x, y, z); - World nmsWorld = ((CraftWorld) world).getHandle(); - IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); - Block nmsBlock = nmsiBlockData.getBlock(); - List preBoxes = new ArrayList<>(); - - nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); - nmsBlock.a(nmsiBlockData, - nmsWorld, - pos, - (AxisAlignedBB) box.toAxisAlignedBB(), - preBoxes, - null, - true); - - if (preBoxes.size() > 0) { - for (AxisAlignedBB aabb : preBoxes) { - BoundingBox bb = new BoundingBox( - (float)aabb.a, - (float)aabb.b, - (float)aabb.c, - (float)aabb.d, - (float)aabb.e, - (float)aabb.f); - - if(bb.collides(box)) { - boxes.add(bb); + if(BlockUtils.collisionBoundingBoxes.containsKey(block.getType())) { + BoundingBox box2 = BlockUtils.collisionBoundingBoxes.get(block.getType()).add(block.getLocation().toVector()); + boxes.add(box2); + } else { + int x = block.getX(), y = block.getY(), z = block.getZ(); + + BlockPosition pos = new BlockPosition(x, y, z); + World nmsWorld = ((CraftWorld) world).getHandle(); + IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); + Block nmsBlock = nmsiBlockData.getBlock(); + List preBoxes = new ArrayList<>(); + + nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); + nmsBlock.a(nmsiBlockData, + nmsWorld, + pos, + (AxisAlignedBB) box.toAxisAlignedBB(), + preBoxes, + null, + false); + + if (preBoxes.size() > 0) { + for (AxisAlignedBB aabb : preBoxes) { + BoundingBox bb = new BoundingBox( + (float)aabb.a, + (float)aabb.b, + (float)aabb.c, + (float)aabb.d, + (float)aabb.e, + (float)aabb.f); + + if(bb.collides(box)) { + boxes.add(bb); + } } - } - if (nmsBlock instanceof BlockShulkerBox) { - TileEntity tileentity = nmsWorld.getTileEntity(pos); - BlockShulkerBox shulker = (BlockShulkerBox) nmsBlock; - - if (tileentity instanceof TileEntityShulkerBox) { - TileEntityShulkerBox entity = (TileEntityShulkerBox) tileentity; - //Bukkit.broadcastMessage("entity"); - boxes.add(ReflectionsUtil.toBoundingBox(entity.a(nmsiBlockData))); - - if (entity.p().toString().contains("OPEN") - || entity.p().toString().contains("CLOSING")) { - boxes.add(new BoundingBox( - block.getX(), - block.getY(), - block.getZ(), - block.getX() + 1, - block.getY() + 1.5f, - block.getZ() + 1)); + if (nmsBlock instanceof BlockShulkerBox) { + TileEntity tileentity = nmsWorld.getTileEntity(pos); + BlockShulkerBox shulker = (BlockShulkerBox) nmsBlock; + + if (tileentity instanceof TileEntityShulkerBox) { + TileEntityShulkerBox entity = (TileEntityShulkerBox) tileentity; + //Bukkit.broadcastMessage("entity"); + boxes.add(ReflectionsUtil.toBoundingBox(entity.a(nmsiBlockData))); + + if (entity.p().toString().contains("OPEN") + || entity.p().toString().contains("CLOSING")) { + boxes.add(new BoundingBox( + block.getX(), + block.getY(), + block.getZ(), + block.getX() + 1, + block.getY() + 1.5f, + block.getZ() + 1)); + } } } - } - } else { - AxisAlignedBB aabb = nmsiBlockData.d(nmsWorld, pos); + } else { + AxisAlignedBB aabb = nmsiBlockData.d(nmsWorld, pos); - if(aabb != null) { - BoundingBox bb = ReflectionsUtil.toBoundingBox(aabb).add(x, y, z, x, y, z); + if(aabb != null) { + BoundingBox bb = ReflectionsUtil.toBoundingBox(aabb).add(x, y, z, x, y, z); - if(bb.collides(box)) { - boxes.add(bb); + if(bb.collides(box)) { + boxes.add(bb); + } } } } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_7_R4.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_7_R4.java index 524472c6..978db340 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_7_R4.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_7_R4.java @@ -49,41 +49,46 @@ public List getCollidingBoxes(org.bukkit.World world, BoundingBox b locs.parallelStream().forEach(loc -> { org.bukkit.block.Block block = loc.getBlock(); if (block != null && !block.getType().equals(Material.AIR)) { - int x = block.getX(), y = block.getY(), z = block.getZ(); + if(BlockUtils.collisionBoundingBoxes.containsKey(block.getType())) { + BoundingBox box2 = BlockUtils.collisionBoundingBoxes.get(block.getType()).add(block.getLocation().toVector()); + boxes.add(box2); + } else { + int x = block.getX(), y = block.getY(), z = block.getZ(); - net.minecraft.server.v1_7_R4.World nmsWorld = ((CraftWorld) world).getHandle(); - net.minecraft.server.v1_7_R4.Block nmsBlock = nmsWorld.getType(x, y, z); - List preBoxes = new ArrayList<>(); + net.minecraft.server.v1_7_R4.World nmsWorld = ((CraftWorld) world).getHandle(); + net.minecraft.server.v1_7_R4.Block nmsBlock = nmsWorld.getType(x, y, z); + List preBoxes = new ArrayList<>(); - nmsBlock.updateShape(nmsWorld, x, y, z); - nmsBlock.a(nmsWorld, x, y, z, (AxisAlignedBB) box.toAxisAlignedBB(), preBoxes, null); + nmsBlock.updateShape(nmsWorld, x, y, z); + nmsBlock.a(nmsWorld, x, y, z, (AxisAlignedBB) box.toAxisAlignedBB(), preBoxes, null); - if (preBoxes.size() > 0) { - for (AxisAlignedBB aabb : preBoxes) { - BoundingBox bb = new BoundingBox( - (float)aabb.a, - (float)aabb.b, - (float)aabb.c, - (float)aabb.d, - (float)aabb.e,( - float)aabb.f); + if (preBoxes.size() > 0) { + for (AxisAlignedBB aabb : preBoxes) { + BoundingBox bb = new BoundingBox( + (float)aabb.a, + (float)aabb.b, + (float)aabb.c, + (float)aabb.d, + (float)aabb.e,( + float)aabb.f); + if(bb.collides(box)) { + boxes.add(bb); + } + } + } else { + BoundingBox bb = new BoundingBox( + (float)nmsBlock.x(), + (float)nmsBlock.z(), + (float)nmsBlock.B(), + (float)nmsBlock.y(), + (float)nmsBlock.A(), + (float)nmsBlock.C()).add(x, y, z, x, y, z); if(bb.collides(box)) { boxes.add(bb); } } - } else { - BoundingBox bb = new BoundingBox( - (float)nmsBlock.x(), - (float)nmsBlock.z(), - (float)nmsBlock.B(), - (float)nmsBlock.y(), - (float)nmsBlock.A(), - (float)nmsBlock.C()).add(x, y, z, x, y, z); - if(bb.collides(box)) { - boxes.add(bb); - } } } }); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R1.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R1.java index 1b302aae..d000396d 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R1.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R1.java @@ -49,47 +49,52 @@ public List getCollidingBoxes(org.bukkit.World world, BoundingBox b locs.parallelStream().forEach(loc -> { org.bukkit.block.Block block = loc.getBlock(); if (block != null && !block.getType().equals(Material.AIR)) { - int x = block.getX(), y = block.getY(), z = block.getZ(); - - BlockPosition pos = new BlockPosition(x, y, z); - World nmsWorld = ((CraftWorld) world).getHandle(); - IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); - Block nmsBlock = nmsiBlockData.getBlock(); - List preBoxes = new ArrayList<>(); - - nmsBlock.updateShape(nmsWorld, pos); - nmsBlock.a(nmsWorld, - pos, - nmsiBlockData, - (AxisAlignedBB) box.toAxisAlignedBB(), - preBoxes, - null); - - if (preBoxes.size() > 0) { - for (AxisAlignedBB aabb : preBoxes) { + if(BlockUtils.collisionBoundingBoxes.containsKey(block.getType())) { + BoundingBox box2 = BlockUtils.collisionBoundingBoxes.get(block.getType()).add(block.getLocation().toVector()); + boxes.add(box2); + } else { + int x = block.getX(), y = block.getY(), z = block.getZ(); + + BlockPosition pos = new BlockPosition(x, y, z); + World nmsWorld = ((CraftWorld) world).getHandle(); + IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); + Block nmsBlock = nmsiBlockData.getBlock(); + List preBoxes = new ArrayList<>(); + + nmsBlock.updateShape(nmsWorld, pos); + nmsBlock.a(nmsWorld, + pos, + nmsiBlockData, + (AxisAlignedBB) box.toAxisAlignedBB(), + preBoxes, + null); + + if (preBoxes.size() > 0) { + for (AxisAlignedBB aabb : preBoxes) { + BoundingBox bb = new BoundingBox( + (float)aabb.a, + (float)aabb.b, + (float)aabb.c, + (float)aabb.d, + (float)aabb.e, + (float)aabb.f); + + if(bb.collides(box)) { + boxes.add(bb); + } + } + } else { BoundingBox bb = new BoundingBox( - (float)aabb.a, - (float)aabb.b, - (float)aabb.c, - (float)aabb.d, - (float)aabb.e, - (float)aabb.f); - + (float)nmsBlock.z(), + (float)nmsBlock.B(), + (float)nmsBlock.D(), + (float)nmsBlock.A(), + (float)nmsBlock.C(), + (float)nmsBlock.E()).add(x, y, z, x, y, z); if(bb.collides(box)) { boxes.add(bb); } } - } else { - BoundingBox bb = new BoundingBox( - (float)nmsBlock.z(), - (float)nmsBlock.B(), - (float)nmsBlock.D(), - (float)nmsBlock.A(), - (float)nmsBlock.C(), - (float)nmsBlock.E()).add(x, y, z, x, y, z); - if(bb.collides(box)) { - boxes.add(bb); - } } } }); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R2.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R2.java index f66c989d..5fe68c0d 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R2.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R2.java @@ -49,46 +49,46 @@ public List getCollidingBoxes(org.bukkit.World world, BoundingBox b locs.parallelStream().forEach(loc -> { org.bukkit.block.Block block = loc.getBlock(); if (block != null && !block.getType().equals(Material.AIR)) { - int x = block.getX(), y = block.getY(), z = block.getZ(); - - BlockPosition pos = new BlockPosition(x, y, z); - World nmsWorld = ((CraftWorld) world).getHandle(); - IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); - Block nmsBlock = nmsiBlockData.getBlock(); - List preBoxes = new ArrayList<>(); - - nmsBlock.updateShape(nmsWorld, pos); - nmsBlock.a(nmsWorld, - pos, - nmsiBlockData, - (AxisAlignedBB) box.toAxisAlignedBB(), - preBoxes, - null); - - if (preBoxes.size() > 0) { - for (AxisAlignedBB aabb : preBoxes) { + if(BlockUtils.collisionBoundingBoxes.containsKey(block.getType())) { + BoundingBox box2 = BlockUtils.collisionBoundingBoxes.get(block.getType()).add(block.getLocation().toVector()); + boxes.add(box2); + } else { + int x = block.getX(), y = block.getY(), z = block.getZ(); + + BlockPosition pos = new BlockPosition(x, y, z); + World nmsWorld = ((CraftWorld) world).getHandle(); + IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); + Block nmsBlock = nmsiBlockData.getBlock(); + List preBoxes = new ArrayList<>(); + + nmsBlock.updateShape(nmsWorld, pos); + nmsBlock.a(nmsWorld, + pos, + nmsiBlockData, + (AxisAlignedBB) box.toAxisAlignedBB(), + preBoxes, + null); + + if (preBoxes.size() > 0) { + for (AxisAlignedBB aabb : preBoxes) { + boxes.add(new BoundingBox( + (float)aabb.a, + (float)aabb.b, + (float)aabb.c, + (float)aabb.d, + (float)aabb.e, + (float)aabb.f)); + } + } else { boxes.add(new BoundingBox( - (float)aabb.a, - (float)aabb.b, - (float)aabb.c, - (float)aabb.d, - (float)aabb.e, - (float)aabb.f)); + (float)nmsBlock.B(), + (float)nmsBlock.D(), + (float)nmsBlock.F(), + (float)nmsBlock.C(), + (float)nmsBlock.E(), + (float)nmsBlock.G()).add(x, y, z, x, y, z)); } - } else { - boxes.add(new BoundingBox( - (float)nmsBlock.B(), - (float)nmsBlock.D(), - (float)nmsBlock.F(), - (float)nmsBlock.C(), - (float)nmsBlock.E(), - (float)nmsBlock.G()).add(x, y, z, x, y, z)); } - /* - else { - BoundingBox blockBox = new BoundingBox((float) nmsBlock.B(), (float) nmsBlock.D(), (float) nmsBlock.F(), (float) nmsBlock.C(), (float) nmsBlock.E(), (float) nmsBlock.G()); - }*/ - } }); } diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R3.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R3.java index 32948dcf..6f0f0c0c 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R3.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_8_R3.java @@ -48,49 +48,54 @@ public List getCollidingBoxes(org.bukkit.World world, BoundingBox b locs.parallelStream().forEach(loc -> { org.bukkit.block.Block block = loc.getBlock(); if (block != null && !block.getType().equals(Material.AIR)) { - int x = block.getX(), y = block.getY(), z = block.getZ(); - - BlockPosition pos = new BlockPosition(x, y, z); - World nmsWorld = ((CraftWorld) world).getHandle(); - IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); - Block nmsBlock = nmsiBlockData.getBlock(); - List preBoxes = new ArrayList<>(); - - nmsBlock.updateShape(nmsWorld, pos); - nmsBlock.a(nmsWorld, - pos, - nmsiBlockData, - (AxisAlignedBB) box.toAxisAlignedBB(), - preBoxes, - null); - - if (preBoxes.size() > 0) { - for (AxisAlignedBB aabb : preBoxes) { + if(BlockUtils.collisionBoundingBoxes.containsKey(block.getType())) { + BoundingBox box2 = BlockUtils.collisionBoundingBoxes.get(block.getType()).add(block.getLocation().toVector()); + boxes.add(box2); + } else { + int x = block.getX(), y = block.getY(), z = block.getZ(); + + BlockPosition pos = new BlockPosition(x, y, z); + World nmsWorld = ((CraftWorld) world).getHandle(); + IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); + Block nmsBlock = nmsiBlockData.getBlock(); + List preBoxes = new ArrayList<>(); + + nmsBlock.updateShape(nmsWorld, pos); + nmsBlock.a(nmsWorld, + pos, + nmsiBlockData, + (AxisAlignedBB) box.toAxisAlignedBB(), + preBoxes, + null); + + if (preBoxes.size() > 0) { + for (AxisAlignedBB aabb : preBoxes) { + BoundingBox bb = new BoundingBox( + (float)aabb.a, + (float)aabb.b, + (float)aabb.c, + (float)aabb.d, + (float)aabb.e, + (float)aabb.f); + + if(bb.collides(box)) { + boxes.add(bb); + } + } + } else { BoundingBox bb = new BoundingBox( - (float)aabb.a, - (float)aabb.b, - (float)aabb.c, - (float)aabb.d, - (float)aabb.e, - (float)aabb.f); + (float)nmsBlock.B(), + (float)nmsBlock.D(), + (float)nmsBlock.F(), + (float)nmsBlock.C(), + (float)nmsBlock.E(), + (float)nmsBlock.G()) + .add(x, y, z, x, y, z); if(bb.collides(box)) { boxes.add(bb); } } - } else { - BoundingBox bb = new BoundingBox( - (float)nmsBlock.B(), - (float)nmsBlock.D(), - (float)nmsBlock.F(), - (float)nmsBlock.C(), - (float)nmsBlock.E(), - (float)nmsBlock.G()) - .add(x, y, z, x, y, z); - - if(bb.collides(box)) { - boxes.add(bb); - } } } }); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_9_R1.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_9_R1.java index 15862812..2d8d4796 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_9_R1.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_9_R1.java @@ -50,43 +50,48 @@ public List getCollidingBoxes(org.bukkit.World world, BoundingBox b locs.parallelStream().forEach(loc -> { org.bukkit.block.Block block = loc.getBlock(); if (block != null && !block.getType().equals(Material.AIR)) { - int x = block.getX(), y = block.getY(), z = block.getZ(); - - BlockPosition pos = new BlockPosition(x, y, z); - World nmsWorld = ((CraftWorld) world).getHandle(); - IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); - Block nmsBlock = nmsiBlockData.getBlock(); - List preBoxes = new ArrayList<>(); - - nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); - nmsBlock.a(nmsiBlockData, - nmsWorld, - pos, - (AxisAlignedBB) box.toAxisAlignedBB(), - preBoxes, - null); - - if (preBoxes.size() > 0) { - for (AxisAlignedBB aabb : preBoxes) { - BoundingBox bb = new BoundingBox( - (float)aabb.a, - (float)aabb.b, - (float)aabb.c, - (float)aabb.d, - (float)aabb.e, - (float)aabb.f); + if(BlockUtils.collisionBoundingBoxes.containsKey(block.getType())) { + BoundingBox box2 = BlockUtils.collisionBoundingBoxes.get(block.getType()).add(block.getLocation().toVector()); + boxes.add(box2); + } else { + int x = block.getX(), y = block.getY(), z = block.getZ(); + + BlockPosition pos = new BlockPosition(x, y, z); + World nmsWorld = ((CraftWorld) world).getHandle(); + IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); + Block nmsBlock = nmsiBlockData.getBlock(); + List preBoxes = new ArrayList<>(); + + nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); + nmsBlock.a(nmsiBlockData, + nmsWorld, + pos, + (AxisAlignedBB) box.toAxisAlignedBB(), + preBoxes, + null); + + if (preBoxes.size() > 0) { + for (AxisAlignedBB aabb : preBoxes) { + BoundingBox bb = new BoundingBox( + (float)aabb.a, + (float)aabb.b, + (float)aabb.c, + (float)aabb.d, + (float)aabb.e, + (float)aabb.f); + + if(bb.collides(box)) { + boxes.add(bb); + } + } + } else { + BoundingBox bb = ReflectionsUtil.toBoundingBox(nmsBlock.a(nmsiBlockData, nmsWorld, pos)) + .add(x, y, z, x, y, z); if(bb.collides(box)) { boxes.add(bb); } } - } else { - BoundingBox bb = ReflectionsUtil.toBoundingBox(nmsBlock.a(nmsiBlockData, nmsWorld, pos)) - .add(x, y, z, x, y, z); - - if(bb.collides(box)) { - boxes.add(bb); - } } } }); diff --git a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_9_R2.java b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_9_R2.java index aba25338..3170808d 100644 --- a/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_9_R2.java +++ b/AtlasParent/Atlas/src/main/java/cc/funkemunky/api/utils/blockbox/boxes/BlockBox1_9_R2.java @@ -50,43 +50,48 @@ public List getCollidingBoxes(org.bukkit.World world, BoundingBox b locs.parallelStream().forEach(loc -> { org.bukkit.block.Block block = loc.getBlock(); if (block != null && !block.getType().equals(Material.AIR)) { - int x = block.getX(), y = block.getY(), z = block.getZ(); - - BlockPosition pos = new BlockPosition(x, y, z); - World nmsWorld = ((CraftWorld) world).getHandle(); - IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); - Block nmsBlock = nmsiBlockData.getBlock(); - List preBoxes = new ArrayList<>(); - - nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); - nmsBlock.a(nmsiBlockData, - nmsWorld, - pos, - (AxisAlignedBB) box.toAxisAlignedBB(), - preBoxes, - null); - - if (preBoxes.size() > 0) { - for (AxisAlignedBB aabb : preBoxes) { - BoundingBox bb = new BoundingBox( - (float)aabb.a, - (float)aabb.b, - (float)aabb.c, - (float)aabb.d, - (float)aabb.e, - (float)aabb.f); + if(BlockUtils.collisionBoundingBoxes.containsKey(block.getType())) { + BoundingBox box2 = BlockUtils.collisionBoundingBoxes.get(block.getType()).add(block.getLocation().toVector()); + boxes.add(box2); + } else { + int x = block.getX(), y = block.getY(), z = block.getZ(); + + BlockPosition pos = new BlockPosition(x, y, z); + World nmsWorld = ((CraftWorld) world).getHandle(); + IBlockData nmsiBlockData = ((CraftWorld) world).getHandle().getType(pos); + Block nmsBlock = nmsiBlockData.getBlock(); + List preBoxes = new ArrayList<>(); + + nmsBlock.updateState(nmsiBlockData, nmsWorld, pos); + nmsBlock.a(nmsiBlockData, + nmsWorld, + pos, + (AxisAlignedBB) box.toAxisAlignedBB(), + preBoxes, + null); + + if (preBoxes.size() > 0) { + for (AxisAlignedBB aabb : preBoxes) { + BoundingBox bb = new BoundingBox( + (float)aabb.a, + (float)aabb.b, + (float)aabb.c, + (float)aabb.d, + (float)aabb.e, + (float)aabb.f); + + if(bb.collides(box)) { + boxes.add(bb); + } + } + } else { + BoundingBox bb = ReflectionsUtil.toBoundingBox(nmsBlock.a(nmsiBlockData, nmsWorld, pos)) + .add(x, y, z, x, y, z); if(bb.collides(box)) { boxes.add(bb); } } - } else { - BoundingBox bb = ReflectionsUtil.toBoundingBox(nmsBlock.a(nmsiBlockData, nmsWorld, pos)) - .add(x, y, z, x, y, z); - - if(bb.collides(box)) { - boxes.add(bb); - } } } }); diff --git a/AtlasParent/AtlasBungee/buildNumber.properties b/AtlasParent/AtlasBungee/buildNumber.properties index 3612d99f..4c76704a 100644 --- a/AtlasParent/AtlasBungee/buildNumber.properties +++ b/AtlasParent/AtlasBungee/buildNumber.properties @@ -1,3 +1,3 @@ #maven.buildNumber.plugin properties file -#Wed Oct 16 12:05:48 EDT 2019 -buildNumber=243 +#Fri Oct 18 15:10:53 EDT 2019 +buildNumber=244