mirror of https://github.com/Minestom/Minestom.git
Block collision improvement
This commit is contained in:
parent
51308ce920
commit
69e46274da
|
@ -1,7 +1,7 @@
|
|||
package fr.themode.minestom.collision;
|
||||
|
||||
import fr.themode.minestom.instance.Instance;
|
||||
import fr.themode.minestom.item.Material;
|
||||
import fr.themode.minestom.instance.block.Block;
|
||||
import fr.themode.minestom.utils.BlockPosition;
|
||||
import fr.themode.minestom.utils.Position;
|
||||
|
||||
|
@ -22,9 +22,9 @@ public class CollisionUtils {
|
|||
BlockPosition yBlock = new BlockPosition(currentX, targetY, currentZ);
|
||||
BlockPosition zBlock = new BlockPosition(currentX, currentY, targetZ);
|
||||
|
||||
boolean xAir = instance.getBlockId(xBlock) == Material.AIR.getId();
|
||||
boolean yAir = instance.getBlockId(yBlock) == Material.AIR.getId();
|
||||
boolean zAir = instance.getBlockId(zBlock) == Material.AIR.getId();
|
||||
boolean xAir = !Block.getFromId(instance.getBlockId(xBlock)).isSolid();
|
||||
boolean yAir = !Block.getFromId(instance.getBlockId(yBlock)).isSolid();
|
||||
boolean zAir = !Block.getFromId(instance.getBlockId(zBlock)).isSolid();
|
||||
|
||||
boolean xIntersect = boundingBox.intersect(xBlock);
|
||||
boolean yIntersect = boundingBox.intersect(yBlock);
|
||||
|
|
|
@ -692,7 +692,7 @@ public enum Block {
|
|||
|
||||
private static Short2ObjectOpenHashMap<Block> blocksMap = new Short2ObjectOpenHashMap<>();
|
||||
|
||||
public static Block getBlockFromId(short blockId) {
|
||||
public static Block getFromId(short blockId) {
|
||||
return blocksMap.getOrDefault(blockId, AIR);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class BlockManager {
|
|||
}
|
||||
|
||||
public BlockPlacementRule getBlockPlacementRule(short blockId) {
|
||||
Block block = Block.getBlockFromId(blockId); // Convert block alternative
|
||||
Block block = Block.getFromId(blockId); // Convert block alternative
|
||||
blockId = block.getBlockId();
|
||||
return this.placementRules.get(blockId);
|
||||
}
|
||||
|
|
|
@ -74,12 +74,12 @@ public class RedstonePlacementRule extends BlockPlacementRule {
|
|||
|
||||
private boolean isRedstone(Instance instance, int x, int y, int z) {
|
||||
short blockId = instance.getBlockId(x, y, z);
|
||||
return Block.getBlockFromId(blockId) == Block.REDSTONE_WIRE;
|
||||
return Block.getFromId(blockId) == Block.REDSTONE_WIRE;
|
||||
}
|
||||
|
||||
private boolean isAir(Instance instance, int x, int y, int z) {
|
||||
short blockId = instance.getBlockId(x, y, z);
|
||||
return Block.getBlockFromId(blockId) == Block.AIR;
|
||||
return Block.getFromId(blockId) == Block.AIR;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue