/* * Figure out if our position has put us into a new set of blocks and fire the appropriate events. */ private void checkBlockEntry( EntityRef entity, Vector3i oldPosition, Vector3i newPosition, float characterHeight) { // TODO: This will only work for tall mobs/players and single block mobs // is this a different position than previously if (!oldPosition.equals(newPosition)) { // get the old position's blocks Block[] oldBlocks = new Block[(int) Math.ceil(characterHeight)]; Vector3i currentPosition = new Vector3i(oldPosition); for (int currentHeight = 0; currentHeight < oldBlocks.length; currentHeight++) { oldBlocks[currentHeight] = worldProvider.getBlock(currentPosition); currentPosition.add(0, 1, 0); } // get the new position's blocks Block[] newBlocks = new Block[(int) Math.ceil(characterHeight)]; currentPosition = new Vector3i(newPosition); for (int currentHeight = 0; currentHeight < characterHeight; currentHeight++) { newBlocks[currentHeight] = worldProvider.getBlock(currentPosition); currentPosition.add(0, 1, 0); } for (int i = 0; i < characterHeight; i++) { // send a block enter/leave event for this character entity.send(new OnEnterBlockEvent(oldBlocks[i], newBlocks[i], new Vector3i(0, i, 0))); } } }
@Override public boolean isConnectingTo( Vector3i blockLocation, Side connectSide, WorldProvider worldProvider, BlockEntityRegistry blockEntityRegistry) { Vector3i neighborLocation = new Vector3i(blockLocation); neighborLocation.add(connectSide.getVector3i()); EntityRef neighborEntity = blockEntityRegistry.getBlockEntityAt(neighborLocation); return neighborEntity != null && connectsToNeighbor(neighborEntity); }