Java Code Examples for net.minecraft.util.Facing#offsetsZForSide()
The following examples show how to use
net.minecraft.util.Facing#offsetsZForSide() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TileEntityPressureChamberInterface.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
private void outputInChamber(){ TileEntityPressureChamberValve valve = getCore(); if(valve != null) { for(int i = 0; i < 6; i++) { int x = xCoord + Facing.offsetsXForSide[i]; int y = yCoord + Facing.offsetsYForSide[i]; int z = zCoord + Facing.offsetsZForSide[i]; if(valve.isCoordWithinChamber(worldObj, x, y, z)) { enoughAir = Math.abs(valve.currentAir) > inventory[0].stackSize * PneumaticValues.USAGE_CHAMBER_INTERFACE; if(enoughAir) { valve.addAir((valve.currentAir > 0 ? -1 : 1) * inventory[0].stackSize * PneumaticValues.USAGE_CHAMBER_INTERFACE, ForgeDirection.UNKNOWN); EntityItem item = new EntityItem(worldObj, x + 0.5D, y + 0.5D, z + 0.5D, inventory[0].copy()); worldObj.spawnEntityInWorld(item); setInventorySlotContents(0, null); break; } } } } }
Example 2
Source File: TileEntityQBlock.java From qcraft-mod with Apache License 2.0 | 5 votes |
private boolean isTouchingLiquid() { for( int i = 1; i < 6; ++i ) // ignore down { int x = xCoord + Facing.offsetsXForSide[ i ]; int y = yCoord + Facing.offsetsYForSide[ i ]; int z = zCoord + Facing.offsetsZForSide[ i ]; Block block = worldObj.getBlock( x, y, z ); if( block != null && block instanceof BlockLiquid ) { return true; } } return false; }
Example 3
Source File: TileEntityQuantumComputer.java From qcraft-mod with Apache License 2.0 | 5 votes |
private boolean checkCooling() { for( int i = 0; i < 6; ++i ) { int x = xCoord + Facing.offsetsXForSide[ i ]; int y = yCoord + Facing.offsetsYForSide[ i ]; int z = zCoord + Facing.offsetsZForSide[ i ]; Block block = worldObj.getBlock( x, y, z ); if( block != null && (block.getMaterial() == Material.ice || block.getMaterial() == Material.packedIce) ) { return true; } } return false; }
Example 4
Source File: BlockQuantumLogic.java From qcraft-mod with Apache License 2.0 | 5 votes |
private boolean getRedstoneSignal( World world, int i, int j, int k, int dir ) { i += Facing.offsetsXForSide[ dir ]; j += Facing.offsetsYForSide[ dir ]; k += Facing.offsetsZForSide[ dir ]; int side = Facing.oppositeSide[ dir ]; return QuantumUtil.getRedstoneSignal( world, i, j, k, side ); }
Example 5
Source File: ItemEntityEgg.java From Et-Futurum with The Unlicense | 5 votes |
@Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (world.isRemote) return true; else { Block block = world.getBlock(x, y, z); x += Facing.offsetsXForSide[side]; y += Facing.offsetsYForSide[side]; z += Facing.offsetsZForSide[side]; double d0 = 0.0D; if (side == 1 && block.getRenderType() == 11) d0 = 0.5D; Entity entity = spawnEntity(world, stack.getItemDamage(), x + 0.5D, y + d0, z + 0.5D); if (entity != null) { if (entity instanceof EntityLivingBase && stack.hasDisplayName()) ((EntityLiving) entity).setCustomNameTag(stack.getDisplayName()); if (!player.capabilities.isCreativeMode) stack.stackSize--; } return true; } }
Example 6
Source File: TileEntityQuantumComputer.java From qcraft-mod with Apache License 2.0 | 4 votes |
private ArrayList<PortalLocation> findRestOfPortal(int[] cornerPair) { ArrayList<PortalLocation> returnValue = new ArrayList(); int x1 = cornerPair[0]; //x = east/west = dir 4 5 int y1 = cornerPair[1]; //y = up/down = dir 0 1 int z1 = cornerPair[2]; //z = north/south = dir 2 3 int x2 = cornerPair[3]; int y2 = cornerPair[4]; int z2 = cornerPair[5]; int lookDir = cornerPair[6]; //direction the portal should be looking int searchDir = ((lookDir - (lookDir % 2)) % 4) + 2; //converts {2, 3, 4, 5} to {4, 4, 2, 2} if (Math.abs(y1 - y2) < 4 && (Math.abs(x1 - x2) < 3) && (Math.abs(z1 - z2) < 3)) { //if the portal would be too small if this pair of corners would make a portal return null; } else if (y1 == y2){ //both corners and the glass between them would form the upper OR lower portal border for (int dir = 0; dir < 2; dir++) { int tempY = y2; for (int i = 0; i < QCraft.maxPortalSize + 1; i++) { //check for maximal portal size tempY += Facing.offsetsYForSide[ dir ]; if (!isGlass(x1, tempY, z1) || !isGlass(x2, tempY,z2)) { //once connected glass stops break; } } if (isGlass(x1, tempY, z1) || isGlass(x2, tempY, z2) || Math.abs(y1 - tempY) < 4) { //if not both are non-glass OR the portal wouldn't be high enough continue; } if (isPortalCorner(x1, tempY, z1, lookDir) && isPortalCorner(x2, tempY, z2, lookDir)) { int c1; int c2; if (x1 == x2) { c1 = z1; c2 = z2; } else { c1 = x1; c2 = x2; } //check for completeness of last horizontal border. for(int i = Math.min(c1, c2) + 1; i < Math.max(c1, c2); i++ ) { if (!isGlass((x1 == x2) ? x1 : i, tempY, (z1 == z2) ? z1 : i )) { break; } if (i == Math.max(c1, c2) - 1) { returnValue.add(new PortalLocation(x1, y1, z1, x2, tempY, z2, worldObj.provider.dimensionId)); } } } } } else { //if the z and x coordinates of both corners are equal (corners are above eachother) for (int dir = searchDir; dir < searchDir+2 ; dir++) { int tempX = x2; int tempZ = z2; for (int i = 0; i < QCraft.maxPortalSize + 1; i++) { //check for maximal portal size tempX += Facing.offsetsXForSide[ dir ]; tempZ += Facing.offsetsZForSide[ dir ]; if (!isGlass(tempX, y1, tempZ) || !isGlass(tempX, y2,tempZ)) { //once connected glass stops break; } } if (isGlass(tempX, y1, tempZ) || isGlass(tempX, y2, tempZ) || (Math.abs(x1 - tempX) < 3 && Math.abs(z1 - tempZ) < 3) ) { //if not both are non-glass OR the portal wouldn't be high enough continue; } if (isPortalCorner(tempX, y1, tempZ, lookDir) && isPortalCorner(tempX, y2, tempZ, lookDir)) { //check for completeness of last vertical border. for(int i = Math.min(y1, y2) + 1; i < Math.max(y1, y2); i++ ) { if (!isGlass(tempX, i, tempZ )) { break; } if (i == Math.max(y1, y2) - 1) { returnValue.add(new PortalLocation(x1, y1, z1, tempX, y2, tempZ, worldObj.provider.dimensionId)); } } } } } return returnValue; //contains 0 up to 2 portal locations }
Example 7
Source File: TileEntityQuantumComputer.java From qcraft-mod with Apache License 2.0 | 4 votes |
private PortalLocation findPortal() { ArrayList<PortalLocation> portalLocations = new ArrayList(); tooManyPossiblePortals = false; for( int dir = 0; dir < 6; ++dir ) { // See if this adjoining block is part of a portal: int x = xCoord + Facing.offsetsXForSide[ dir ]; int y = yCoord + Facing.offsetsYForSide[ dir ]; int z = zCoord + Facing.offsetsZForSide[ dir ]; if( !isGlass( x, y, z ) && !isPortalCorner( x, y, z, 2 ) && !isPortalCorner( x, y, z, 4 ) ) { continue; } ArrayList<PortalLocation> tempLocations = findPortalsAt(x, y, z); if ( (tempLocations.size() == 2 && ! (isPortalCorner( x, y, z, 2 ) || isPortalCorner( x, y, z, 4 ) ) ) || tempLocations.size() > 2) { tooManyPossiblePortals = true; return null; } portalLocations.addAll(tempLocations); if (portalLocations.size() > 2) { tooManyPossiblePortals = true; return null; } } if (portalLocations.size() < 1) { return null; } else if (portalLocations.size() == 2) { PortalLocation portal1 = portalLocations.get(0); PortalLocation portal2 = portalLocations.get(1); if( Math.min(portal1.m_x1, portal1.m_x2) == Math.min(portal2.m_x1, portal2.m_x2) && Math.min(portal1.m_y1, portal1.m_y2) == Math.min(portal2.m_y1, portal2.m_y2) && Math.min(portal1.m_z1, portal1.m_z2) == Math.min(portal2.m_z1, portal2.m_z2)) { return portalLocations.get(0); } else { tooManyPossiblePortals = true; return null; } } else if (portalLocations.size() > 2) { tooManyPossiblePortals = true; return null; } else { return portalLocations.get(0); } }