Java Code Examples for net.minecraft.block.Block#isOpaqueCube()

The following examples show how to use net.minecraft.block.Block#isOpaqueCube() . 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: UndergroundTexture.java    From mapwriter with MIT License 5 votes vote down vote up
private void processBlock(int xi, int y, int zi) {
	int x = (this.updateX << 4) + xi;
	int z = (this.updateZ << 4) + zi;
	
	int xDist = this.px - x;
	int zDist = this.pz - z;
	
	if (((xDist * xDist) + (zDist * zDist)) <= 256) {
		if (this.isChunkInTexture(x >> 4, z >> 4)) {
			int chunkOffset = ((zi >> 4) * 3) + (xi >> 4);
			int columnXi = xi & 0xf;
			int columnZi = zi & 0xf;
			int columnOffset = (columnZi << 4) + columnXi;
			byte columnFlag = this.updateFlags[chunkOffset][columnOffset];
			
			if (columnFlag == ChunkRender.FLAG_UNPROCESSED) {
				// if column not yet processed
				WorldClient world = this.mw.mc.theWorld;
				Block block = world.getBlock(x, y, z);
				if ((block == null) || !block.isOpaqueCube()) {
					// if block is not opaque
					this.updateFlags[chunkOffset][columnOffset] = (byte) ChunkRender.FLAG_NON_OPAQUE;
					this.processBlock(xi + 1, y, zi);
					this.processBlock(xi - 1, y, zi);
					this.processBlock(xi, y, zi + 1);
					this.processBlock(xi, y, zi - 1);
				} else {
					// block is opaque
					this.updateFlags[chunkOffset][columnOffset] = (byte) ChunkRender.FLAG_OPAQUE;
				}
			}
		}
	}
}
 
Example 2
Source File: EntityShip.java    From archimedes-ships with MIT License 4 votes vote down vote up
public void updateRiderPosition(Entity entity, int seatx, int seaty, int seatz, int flags)
{
	if (entity != null)
	{
		float yaw = (float) Math.toRadians(rotationYaw);
		float pitch = (float) Math.toRadians(rotationPitch);
		
		int x1 = seatx, y1 = seaty, z1 = seatz;
		if ((flags & 1) == 1)
		{
			if (frontDirection == 0)
			{
				z1 -= 1;
			} else if (frontDirection == 1)
			{
				x1 += 1;
			} else if (frontDirection == 2)
			{
				z1 += 1;
			} else if (frontDirection == 3)
			{
				x1 -= 1;
			}
			
			Block block = shipChunk.getBlock(x1, MathHelper.floor_double(y1 + getMountedYOffset() + entity.getYOffset()), z1);
			if (block.isOpaqueCube())
			{
				x1 = seatx;
				y1 = seaty;
				z1 = seatz;
			}
		}
		
		double yoff = (flags & 2) == 2 ? 0d : getMountedYOffset();
		Vec3 vec = Vec3.createVectorHelper(x1 - shipChunk.getCenterX() + 0.5d, y1 - shipChunk.minY() + yoff, z1 - shipChunk.getCenterZ() + 0.5d);
		switch (frontDirection)
		{
		case 0:
			vec.rotateAroundZ(-pitch);
			break;
		case 1:
			vec.rotateAroundX(pitch);
			break;
		case 2:
			vec.rotateAroundZ(pitch);
			break;
		case 3:
			vec.rotateAroundX(-pitch);
			break;
		}
		vec.rotateAroundY(yaw);
		
		entity.setPosition(posX + vec.xCoord, posY + vec.yCoord + entity.getYOffset(), posZ + vec.zCoord);
	}
}
 
Example 3
Source File: BlockArtifactsPressurePlate.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
	if(this.camouflaged) {

		if(side != 1) {
			return this == camoStone ? Blocks.stone.getBlockTextureFromSide(0) : this == camoObsidian ? Blocks.obsidian.getBlockTextureFromSide(0) : Blocks.planks.getBlockTextureFromSide(0);
		}

		IIcon icon = this.blockIcon;
		Block block = world.getBlock(x, y-1, z);
		int meta = world.getBlockMetadata(x, y-1, z);

		if(block != null) {
			if(block == BlockTrap.instance) {
				int[] blockToCopyLocation = BlockTrap.getNeighbourBlockPosition(world, x, y-1, z, block, meta);
				Block blockToCopy = Blocks.stonebrick;
				int metaToCopy = 0;
				if(! (blockToCopyLocation[0] == x && blockToCopyLocation[1] == y && blockToCopyLocation[2] == z )) {
					blockToCopy = world.getBlock(blockToCopyLocation[0], blockToCopyLocation[1], blockToCopyLocation[2]);
					metaToCopy = world.getBlockMetadata(blockToCopyLocation[0], blockToCopyLocation[1], blockToCopyLocation[2]);
				}
				return blockToCopy.getIcon(side, metaToCopy);
			}
			else if(block != this && block.isOpaqueCube()) {
				icon = block.getIcon(side, meta);
				if(icon != null) {
					return icon;
				}
			}
			else if(block == BlockIllusionary.instance) {
				return block.getIcon(world, x, y-1, z, side);
				
			}
		}
	}

	//If it fails, return default icon.
			return super.getIcon(world, x, y, z, side);

}
 
Example 4
Source File: BlockTrap.java    From Artifacts with MIT License 4 votes vote down vote up
public static int[] getNeighbourBlockPosition(IBlockAccess world, int x, int y, int z, Block block, int blockMeta) {
  	
  	int xOffset = 0;
int zOffset = 0;
switch(blockMeta) {
	case 0: 
       case 2:
       case 3:
       	xOffset = 1;
       	break;
       case 1:
       case 4:
       case 5:
       	zOffset = 1;
       	break;
   }
int metaToCopy = 0;
Block adjacentBlock1 = world.getBlock(x + xOffset, y, z + zOffset);
Block adjacentBlock2 = world.getBlock(x - xOffset, y, z - zOffset);
Block blockToCopy = Blocks.stonebrick;
if(adjacentBlock1 != block && adjacentBlock1 != null && adjacentBlock1.isOpaqueCube()) {
	return new int[]{x + xOffset, y, z + zOffset};
}
else if(adjacentBlock2 != block && adjacentBlock2 != null && adjacentBlock2.isOpaqueCube()) {
	return new int[]{x - xOffset, y, z - zOffset};
}
else {
	if(blockMeta <= 1) {
		adjacentBlock1 = world.getBlock(x + zOffset, y, z + xOffset);
		adjacentBlock2 = world.getBlock(x - zOffset, y, z - xOffset);
		if(adjacentBlock1 != block && adjacentBlock1 != null && adjacentBlock1.isOpaqueCube()) {
			return new int[]{x + zOffset, y, z + xOffset};
		}
		else if(adjacentBlock2 != block && adjacentBlock2 != null && adjacentBlock2.isOpaqueCube()) {
			return new int[]{x - zOffset, y, z - xOffset};
		}
	}
	else {
		adjacentBlock1 = world.getBlock(x, y+1, z);
		adjacentBlock2 = world.getBlock(x, y-1, z);
		if(adjacentBlock1 != block && adjacentBlock1 != null && adjacentBlock1.isOpaqueCube()) {
			return new int[]{x, y+1, z};
		}
		else if(adjacentBlock2 != block && adjacentBlock2 != null && adjacentBlock2.isOpaqueCube()) {
			return new int[]{x, y-1, z};
		}
	}
}

return new int[]{x, y, z};
  }
 
Example 5
Source File: BlockWallPlate.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
	if(this.camouflage) {
		
		IIcon icon = this.blockIcon;
		Block block = Blocks.air;
		int bMeta = 0;
		int bx = x;
		int bz = z;
		int meta = world.getBlockMetadata(x, y, z) & 0x07;

		if (meta == 2 && side == 2)
		{
			block = world.getBlock(x, y, z+1);
			bMeta = world.getBlockMetadata(x, y, z+1);
			bz = z+1;
		}
		else if (meta == 3 && side == 3)
		{
			block = world.getBlock(x, y, z-1);
			bMeta = world.getBlockMetadata(x, y, z-1);
			bz = z-1;
		}
		else if (meta == 4 && side == 4)
		{
			block = world.getBlock(x+1, y, z);
			bMeta = world.getBlockMetadata(x+1, y, z);
			bx = x+1;
		}
		else if (meta == 5 && side == 5)
		{
			block = world.getBlock(x-1, y, z);
			bMeta = world.getBlockMetadata(x-1, y, z);
			bx = x-1;
		}
		else {
			block = this == camoStone ? Blocks.stone : this == camoObsidian ? Blocks.obsidian : Blocks.planks;
			bMeta = 0;
		}
		
		if(block != null) {
			if(block == BlockTrap.instance) {
				int[] blockToCopyLocation = BlockTrap.getNeighbourBlockPosition(world, bx, y, bz, block, bMeta);
				Block blockToCopy = Blocks.stonebrick;
				int metaToCopy = 0;
				if(! (blockToCopyLocation[0] == x && blockToCopyLocation[1] == y && blockToCopyLocation[2] == z )) {
					blockToCopy = world.getBlock(blockToCopyLocation[0], blockToCopyLocation[1], blockToCopyLocation[2]);
					metaToCopy = world.getBlockMetadata(blockToCopyLocation[0], blockToCopyLocation[1], blockToCopyLocation[2]);
				}
				return blockToCopy.getIcon(side, metaToCopy);
			}
			else if(block != this && block.isOpaqueCube()) {
				icon = block.getIcon(side, bMeta);
				if(icon != null) {
					return icon;
				}
			}
			else if(block == BlockIllusionary.instance) {
				return block.getIcon(world, bx, y, bz, side);
			}
		}
	}
	
	//If it fails, return default icon.
	return super.getIcon(world, x, y, z, side);

}
 
Example 6
Source File: CarvableHelper.java    From Chisel-2 with GNU General Public License v2.0 3 votes vote down vote up
public void registerVariation(String name, IVariationInfo info) {

		Block block = info.getVariation().getBlock();

		if (block.renderAsNormalBlock() || block.isOpaqueCube() || block.isNormalCube()) {
			FMPIMC.registerFMP(block, info.getVariation().getBlockMeta());
		}

		if (forbidChiseling)
			return;

		CarvingUtils.getChiselRegistry().addVariation(name, info.getVariation());
	}