@author Gregorius Techneticies Contains simple Utility Functions based on the In-World-Coordinates
| 40 | * Contains simple Utility Functions based on the In-World-Coordinates |
| 41 | */ |
| 42 | public class WorldAndCoords implements IHasWorldAndCoords, Comparable<WorldAndCoords> { |
| 43 | public final int mX, mY, mZ; |
| 44 | public final World mWorld; |
| 45 | |
| 46 | public WorldAndCoords(World aWorld, int aX, int aY, int aZ) {mWorld = aWorld; mX = aX; mY = aY; mZ = aZ;} |
| 47 | public WorldAndCoords(World aWorld, ChunkCoordinates aCoords) {mWorld = aWorld; mX = aCoords.posX; mY = aCoords.posY; mZ = aCoords.posZ;} |
| 48 | public WorldAndCoords(TileEntity aTileEntity) {mWorld = aTileEntity.getWorldObj(); mX = aTileEntity.xCoord; mY = aTileEntity.yCoord; mZ = aTileEntity.zCoord;} |
| 49 | |
| 50 | @Override public World getWorld() {return mWorld;} |
| 51 | @Override public int getX() {return mX;} |
| 52 | @Override public int getY() {return mY;} |
| 53 | @Override public int getZ() {return mZ;} |
| 54 | @Override public int getOffsetX (byte aSide) {return mX + OFFX[aSide];} |
| 55 | @Override public int getOffsetY (byte aSide) {return mY + OFFY[aSide];} |
| 56 | @Override public int getOffsetZ (byte aSide) {return mZ + OFFZ[aSide];} |
| 57 | @Override public int getOffsetX (byte aSide, int aMultiplier) {return mX + OFFX[aSide] * aMultiplier;} |
| 58 | @Override public int getOffsetY (byte aSide, int aMultiplier) {return mY + OFFY[aSide] * aMultiplier;} |
| 59 | @Override public int getOffsetZ (byte aSide, int aMultiplier) {return mZ + OFFZ[aSide] * aMultiplier;} |
| 60 | @Override public int getOffsetXN(byte aSide) {return mX - OFFX[aSide];} |
| 61 | @Override public int getOffsetYN(byte aSide) {return mY - OFFY[aSide];} |
| 62 | @Override public int getOffsetZN(byte aSide) {return mZ - OFFZ[aSide];} |
| 63 | @Override public int getOffsetXN(byte aSide, int aMultiplier) {return mX - OFFX[aSide] * aMultiplier;} |
| 64 | @Override public int getOffsetYN(byte aSide, int aMultiplier) {return mY - OFFY[aSide] * aMultiplier;} |
| 65 | @Override public int getOffsetZN(byte aSide, int aMultiplier) {return mZ - OFFZ[aSide] * aMultiplier;} |
| 66 | @Override public ChunkCoordinates getCoords() {return new ChunkCoordinates(mX, mY, mZ);} |
| 67 | @Override public ChunkCoordinates getOffset (byte aSide, int aMultiplier) {return new ChunkCoordinates(getOffsetX (aSide, aMultiplier), getOffsetY (aSide, aMultiplier), getOffsetZ (aSide, aMultiplier));} |
| 68 | @Override public ChunkCoordinates getOffsetN(byte aSide, int aMultiplier) {return new ChunkCoordinates(getOffsetXN(aSide, aMultiplier), getOffsetYN(aSide, aMultiplier), getOffsetZN(aSide, aMultiplier));} |
| 69 | @Override public boolean isServerSide() {return mWorld == null ? cpw.mods.fml.common.FMLCommonHandler.instance().getEffectiveSide().isServer() : !mWorld.isRemote;} |
| 70 | @Override public boolean isClientSide() {return mWorld == null ? cpw.mods.fml.common.FMLCommonHandler.instance().getEffectiveSide().isClient() : mWorld.isRemote;} |
| 71 | @Override public int rng(int aRange) {return RNGSUS.nextInt(aRange);} |
| 72 | @Override public int getRandomNumber(int aRange) {return RNGSUS.nextInt(aRange);} |
| 73 | @Override public TileEntity getTileEntity (int aX, int aY, int aZ) {return mWorld==null?null:mWorld.getTileEntity(aX, aY, aZ);} |
| 74 | @Override public Block getBlock (int aX, int aY, int aZ) {return mWorld==null?NB:mWorld.getBlock(aX, aY, aZ);} |
| 75 | @Override public byte getMetaData (int aX, int aY, int aZ) {return mWorld==null?0:UT.Code.bind4(mWorld.getBlockMetadata(aX, aY, aZ));} |
| 76 | @Override public byte getLightLevel (int aX, int aY, int aZ) {return mWorld==null?0:UT.Code.bind4((long)mWorld.getLightBrightness(aX, aY, aZ)*15);} |
| 77 | @Override public boolean getOpacity (int aX, int aY, int aZ) {return mWorld!=null&&mWorld.getBlock(aX, aY, aZ).isOpaqueCube();} |
| 78 | @Override public boolean getSky (int aX, int aY, int aZ) {return mWorld==null||mWorld.canBlockSeeTheSky(aX, aY, aZ);} |
| 79 | @Override public boolean getRain (int aX, int aY, int aZ) {return mWorld==null||mWorld.getPrecipitationHeight(aX, aZ) <= aY;} |
| 80 | @Override public boolean getAir (int aX, int aY, int aZ) {return mWorld==null||mWorld.getBlock(aX, aY, aZ).isAir(mWorld, aX, aY, aZ);} |
| 81 | @Override public BiomeGenBase getBiome() {return getBiome(mX, mZ);} |
| 82 | @Override public BiomeGenBase getBiome (int aX, int aZ) {return mWorld==null?null:mWorld.getBiomeGenForCoords(aX, aZ);} |
| 83 | @Override public BiomeGenBase getBiome (ChunkCoordinates aCoords) {return mWorld==null?null:mWorld.getBiomeGenForCoords(aCoords.posX, aCoords.posZ);} |
| 84 | @Override public TileEntity getTileEntity (ChunkCoordinates aCoords) {return mWorld==null?null:mWorld.getTileEntity(aCoords.posX, aCoords.posY, aCoords.posZ);} |
| 85 | @Override public Block getBlock (ChunkCoordinates aCoords) {return mWorld==null?NB:mWorld.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ);} |
| 86 | @Override public byte getMetaData (ChunkCoordinates aCoords) {return mWorld==null?0:UT.Code.bind4(mWorld.getBlockMetadata(aCoords.posX, aCoords.posY, aCoords.posZ));} |
| 87 | @Override public byte getLightLevel (ChunkCoordinates aCoords) {return mWorld==null?0:UT.Code.bind4((long)mWorld.getLightBrightness(aCoords.posX, aCoords.posY, aCoords.posZ)*15);} |
| 88 | @Override public boolean getOpacity (ChunkCoordinates aCoords) {return mWorld!=null&&mWorld.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ).isOpaqueCube();} |
| 89 | @Override public boolean getSky (ChunkCoordinates aCoords) {return mWorld==null||mWorld.canBlockSeeTheSky(aCoords.posX, aCoords.posY, aCoords.posZ);} |
| 90 | @Override public boolean getRain (ChunkCoordinates aCoords) {return mWorld==null||mWorld.getPrecipitationHeight(aCoords.posX, aCoords.posZ) <= aCoords.posY;} |
| 91 | @Override public boolean getAir (ChunkCoordinates aCoords) {return mWorld==null||mWorld.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ).isAir(mWorld, aCoords.posX, aCoords.posY, aCoords.posZ);} |
| 92 | @Override public Block getBlockOffset(int aX, int aY, int aZ) {return getBlock(mX+aX, mY+aY, mZ+aZ);} |
| 93 | @Override public Block getBlockAtSide(byte aSide) {return getBlockAtSideAndDistance(aSide, 1);} |
| 94 | @Override public Block getBlockAtSideAndDistance(byte aSide, int aDistance) {return getBlock(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance));} |
| 95 | @Override public byte getMetaDataOffset(int aX, int aY, int aZ) {return getMetaData(mX+aX, mY+aY, mZ+aZ);} |
| 96 | @Override public byte getMetaDataAtSide(byte aSide) {return getMetaDataAtSideAndDistance(aSide, 1);} |
| 97 | @Override public byte getMetaDataAtSideAndDistance(byte aSide, int aDistance) {return getMetaData(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance));} |
| 98 | @Override public byte getLightLevelOffset(int aX, int aY, int aZ) {return getLightLevel(mX+aX, mY+aY, mZ+aZ);} |
| 99 | @Override public byte getLightLevelAtSide(byte aSide) {return getLightLevelAtSideAndDistance(aSide, 1);} |
nothing calls this directly
no outgoing calls
no test coverage detected