Java Code Examples for net.minecraft.block.material.Material#AIR

The following examples show how to use net.minecraft.block.material.Material#AIR . 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: BiomeLushSwamp.java    From Traverse-Legacy-1-12-2 with MIT License 6 votes vote down vote up
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	double d0 = GRASS_COLOR_NOISE.getValue((double) x * 0.25D, (double) z * 0.25D);

	if (d0 > 0.0D) {
		int i = x & 15;
		int j = z & 15;

		for (int k = 255; k >= 0; --k) {
			if (chunkPrimerIn.getBlockState(j, k, i).getMaterial() != Material.AIR) {
				if (k == 62 && chunkPrimerIn.getBlockState(j, k, i).getBlock() != Blocks.WATER) {
					chunkPrimerIn.setBlockState(j, k, i, WATER);

					if (d0 < 0.12D) {
						chunkPrimerIn.setBlockState(j, k + 1, i, WATER_LILY);
					}
				}

				break;
			}
		}
	}

	this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
}
 
Example 2
Source File: FlyNodeProcessor.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
private boolean entityFits(Entity entityIn, int x, int y, int z) {

    BlockPos.MutableBlockPos mutableblockpos = new BlockPos.MutableBlockPos();
    for (int i = x; i < x + entitySizeX; ++i) {
      for (int j = y; j < y + entitySizeY; ++j) {
        for (int k = z; k < z + entitySizeZ; ++k) {
          IBlockState bs = blockaccess.getBlockState(mutableblockpos.setPos(i, j, k));
          if (bs.getMaterial() != Material.AIR) {
            AxisAlignedBB bb = bs.getCollisionBoundingBox(entityIn.world, mutableblockpos);
            if(bb != null) {
              return false;
            }
          }
        }
      }
    }

    return true;
  }
 
Example 3
Source File: EntityGnome.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void readEntityFromNBT(NBTTagCompound nbt)
{
	super.readEntityFromNBT(nbt);

	// Check NBT for block id+data for carried block
	
       IBlockState state;

       if (nbt.hasKey("carried", 8))
       {
           state = Block.getBlockFromName(nbt.getString("carried")).getStateFromMeta(nbt.getShort("carriedData") & 65535);
       }
       else
       {
           state = Block.getBlockById(nbt.getShort("carried")).getStateFromMeta(nbt.getShort("carriedData") & 65535);
       }

       if (state == null || state.getBlock() == null || state.getMaterial() == Material.AIR)
       {
           state = null;
       }

       this.setCarriedState(state);
}
 
Example 4
Source File: MixinRenderGlobal.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
private void drawSelectionBoxOriginal(EntityPlayer player,
    RayTraceResult movingObjectPositionIn,
    int execute, float partialTicks) {
    if (execute == 0 && movingObjectPositionIn.typeOfHit == RayTraceResult.Type.BLOCK) {
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA,
            GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE,
            GlStateManager.DestFactor.ZERO);
        GlStateManager.glLineWidth(2.0F);
        GlStateManager.disableTexture2D();
        GlStateManager.depthMask(false);
        BlockPos blockpos = movingObjectPositionIn.getBlockPos();
        IBlockState iblockstate = this.world.getBlockState(blockpos);

        if (iblockstate.getMaterial() != Material.AIR && this.world.getWorldBorder()
            .contains(blockpos)) {
            double d0 =
                player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
            double d1 =
                player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
            double d2 =
                player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
            drawSelectionBoundingBox(iblockstate.getSelectedBoundingBox(this.world, blockpos)
                .grow(0.0020000000949949026D).offset(-d0, -d1, -d2), 0.0F, 0.0F, 0.0F, 0.4F);
        }

        GlStateManager.depthMask(true);
        GlStateManager.enableTexture2D();
        GlStateManager.disableBlend();
    }
}
 
Example 5
Source File: BlockGravity.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean canFallInto(World worldIn, BlockPos pos)
{
	if (worldIn.isAirBlock(pos)) return true;
	Block block = worldIn.getBlockState(pos).getBlock();
	Material material = block.getMaterial(worldIn.getBlockState(pos));
	return (block == Blocks.FIRE) || (material == Material.AIR) || (material == Material.WATER) || (material == Material.LAVA) || block.isReplaceable(worldIn, pos);
}
 
Example 6
Source File: EntityFallingBlockTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public boolean canFallInto(World worldIn, BlockPos pos)
{
	if (worldIn.isAirBlock(pos)) return true;
	IBlockState state = worldIn.getBlockState(pos);
	Material material = state.getBlock().getMaterial(state);
	return (state.getBlock() == Blocks.FIRE) || (material == Material.AIR) || (material == Material.WATER) || (material == Material.LAVA) || state.getBlock().isReplaceable(worldIn, pos);
}
 
Example 7
Source File: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 5 votes vote down vote up
/**
 * Adds chest to the structure and sets its contents
 */
protected boolean generateChest(World worldIn, StructureBoundingBox structurebb, Random randomIn, int x, int y, int z, ResourceLocation loot) {
    BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));

    if (structurebb.isVecInside(blockpos) && worldIn.getBlockState(blockpos).getMaterial() == Material.AIR && worldIn.getBlockState(blockpos.down()).getMaterial() != Material.AIR) {
        IBlockState iblockstate = Blocks.RAIL.getDefaultState().withProperty(BlockRail.SHAPE, randomIn.nextBoolean() ? BlockRailBase.EnumRailDirection.NORTH_SOUTH : BlockRailBase.EnumRailDirection.EAST_WEST);
        this.setBlockState(worldIn, iblockstate, x, y, z, structurebb);
        EntityMinecartChest entityminecartchest = new EntityMinecartChest(worldIn, (double) ((float) blockpos.getX() + 0.5F), (double) ((float) blockpos.getY() + 0.5F), (double) ((float) blockpos.getZ() + 0.5F));
        entityminecartchest.setLootTable(loot, randomIn.nextLong());
        worldIn.spawnEntity(entityminecartchest);
        return true;
    } else {
        return false;
    }
}
 
Example 8
Source File: IStructure.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Will return a list of blocks that are incorrect. If this list is empty, the structure is complete.
 */
default Set<BlockPos> testStructure(World world, BlockPos pos) {
	Set<BlockPos> errors = new HashSet<>();

	for (Template.BlockInfo info : getStructure().blockInfos()) {
		if (info.blockState == null) continue;
		if (info.blockState.getMaterial() == Material.AIR || info.blockState.getBlock() == Blocks.STRUCTURE_VOID)
			continue;

		BlockPos realPos = info.pos.add(pos).subtract(getStructure().getOrigin());
		IBlockState state = world.getBlockState(realPos);
		if (state != info.blockState) {

			if (state.getBlock() == ModBlocks.CREATIVE_MANA_BATTERY && info.blockState.getBlock() == ModBlocks.MANA_BATTERY) {
				continue;
			}

			if (info.blockState.getBlock() instanceof BlockStairs && state.getBlock() instanceof BlockStairs
					&& info.blockState.getBlock() == state.getBlock()
					&& info.blockState.getValue(BlockStairs.HALF) == state.getValue(BlockStairs.HALF)
					&& info.blockState.getValue(BlockStairs.SHAPE) == state.getValue(BlockStairs.SHAPE)) {
				if (info.blockState.getValue(BlockStairs.FACING) != state.getValue(BlockStairs.FACING))
					world.setBlockState(realPos, info.blockState);
				continue;
			}
			errors.add(realPos);
		}
	}
	return errors;
}
 
Example 9
Source File: BlockValkyriumOre.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
public static boolean canFallThrough(IBlockState state) {
    Block block = state.getBlock();
    Material material = state.getMaterial();
    return block == Blocks.FIRE || material == Material.AIR || material == Material.WATER
        || material == Material.LAVA;
}
 
Example 10
Source File: BlockToroSpawner.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected BlockToroSpawner() {
	super(Material.AIR);
	setCreativeTab(CreativeTabs.MISC);
}
 
Example 11
Source File: Dummy.java    From Traverse-Legacy-1-12-2 with MIT License 4 votes vote down vote up
public Dummy() {
    super(Material.AIR);
}
 
Example 12
Source File: BiomeCanyon.java    From Traverse-Legacy-1-12-2 with MIT License 4 votes vote down vote up
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	int i = worldIn.getSeaLevel();
	IBlockState iblockstate = this.topBlock;
	IBlockState iblockstate1 = this.fillerBlock;
	int j = -1;
	int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
	int l = x & 15;
	int i1 = z & 15;
	BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

	for (int j1 = 255; j1 >= 0; --j1) {
		if (j1 <= rand.nextInt(5)) {
			chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK);
		} else {
			IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l);

			if (iblockstate2.getMaterial() == Material.AIR) {
				j = -1;
			} else if (iblockstate2.getBlock() == Blocks.STONE) {
				if (j == -1) {
					if (k <= 0) {
						iblockstate = AIR;
						iblockstate1 = STONE;
					} else if (j1 >= i - 4 && j1 <= i + 1) {
						iblockstate = this.topBlock;
						iblockstate1 = this.fillerBlock;
					}

					if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) {
						if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) {
							iblockstate = ICE;
						} else {
							iblockstate = WATER;
						}
					}

					j = k;

					if (j1 >= i - 1) {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate);
					} else if (j1 < i - 7 - k) {
						iblockstate = AIR;
						iblockstate1 = STONE;
						chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL);
					} else {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
					}
				} else if (j > 0) {
					--j;
					chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);

					if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE;
					}

					if (j == 0 && iblockstate == redRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate = redRock;
					}

					if (j == 0 && iblockstate1 == redRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = redRock;
					}
				}
			}
		}
	}
}
 
Example 13
Source File: ShipStorage.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public boolean isAirBlock(BlockPos pos) {
	return blockMap.get(pos).blockstate.getMaterial() == Material.AIR;
}
 
Example 14
Source File: EntityOwl.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
public void onLivingUpdate() {

  // setDead();
  super.onLivingUpdate();
  prevWingRotation = wingRotation;
  prevDestPos = destPos;
  destPos = (float) (destPos + (onGround ? -1 : 4) * 0.3D);
  destPos = MathHelper.clamp(destPos, 0.0F, 1.0F);
  if (!onGround && wingRotDelta < 1.0F) {
    wingRotDelta = 1.0F;
  }
  wingRotDelta = (float) (wingRotDelta * 0.9D);
  float flapSpeed = 2f;
  double yDelta = Math.abs(posY - prevPosY);
  if (yDelta != 0) {
    // normalise between 0 and 0.02
    yDelta = Math.min(1, yDelta / 0.02);
    yDelta = Math.max(yDelta, 0.75);
    flapSpeed *= yDelta;
  }
  wingRotation += wingRotDelta * flapSpeed;
   

  if (!world.isRemote && !isChild() && --timeUntilNextEgg <= 0) {
    if (isOnLeaves()) {
      playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
      dropItem(EnderZoo.itemOwlEgg, 1);        
    }
    timeUntilNextEgg = getNextLayingTime();
  }

  
  
  AxisAlignedBB movedBB = getEntityBoundingBox().offset(0, motionY, 0);
  BlockPos ep = getPosition();
  BlockPos pos = new BlockPos(ep.getX(), movedBB.maxY, ep.getZ());
  IBlockState bs = world.getBlockState(pos);
  if (bs.getMaterial() != Material.AIR) {
    AxisAlignedBB bb = bs.getCollisionBoundingBox(world, pos);
    if (bb != null) {
      double ouch = movedBB.maxY - bb.minY;
      if (ouch == 0) {
        motionY = -0.1;
      } else {
        motionY = 0;
      }
    }
  }
  

  if (onGround) {
    motionX *= groundSpeedRatio;
    motionZ *= groundSpeedRatio;
  }
}
 
Example 15
Source File: WeatherRenderer.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
public static void addRainParticles(Random random, int rendererUpdateCount)
{
	Minecraft mc = Minecraft.getMinecraft();
	WorldClient worldclient = mc.world;
	if(worldclient.provider.getDimension() != 0)
		return;
	float rainStrength = (float)WeatherManager.getInstance().getPrecipitation((int)mc.player.posX, (int)mc.player.posZ);
	double tempPlayer = WeatherManager.getInstance().getTemperature((int)mc.player.posX,(int)mc.player.posY, (int)mc.player.posZ);
	if(tempPlayer <= 0)
		return;

	if (!mc.gameSettings.fancyGraphics)
	{
		rainStrength /= 2.0F;
	}

	if (rainStrength > 0.0F)
	{
		worldclient.rand.setSeed((long)rendererUpdateCount * 312987231L);
		Entity entity = mc.getRenderViewEntity();
		BlockPos blockpos = new BlockPos(entity);
		byte b0 = 10;
		double d0 = 0.0D;
		double d1 = 0.0D;
		double d2 = 0.0D;
		int i = 0;
		int rainParticles = Math.max((int)(100.0F * rainStrength * rainStrength), 4);

		if (mc.gameSettings.particleSetting == 1)
		{
			rainParticles >>= 1;
		}
		else if (mc.gameSettings.particleSetting == 2)
		{
			rainParticles = 0;
		}

		for (int k = 0; k < rainParticles; ++k)
		{
			BlockPos blockPos1 = worldclient.getPrecipitationHeight(blockpos.add(worldclient.rand.nextInt(b0) - worldclient.rand.nextInt(b0), 0, worldclient.rand.nextInt(b0) - worldclient.rand.nextInt(b0)));
			double temp = WeatherManager.getInstance().getTemperature(blockPos1);
			BlockPos blockpos2 = blockPos1.down();
			IBlockState state = worldclient.getBlockState(blockpos2);
			Block block = worldclient.getBlockState(blockpos2).getBlock();

			if (blockPos1.getY() <= blockpos.getY() + b0 && blockPos1.getY() >= blockpos.getY() - b0 && temp > 0)
			{
				float f1 = worldclient.rand.nextFloat();
				float f2 = worldclient.rand.nextFloat();
				AxisAlignedBB axisalignedbb = state.getBoundingBox(worldclient, blockpos2);

				if (block.getMaterial(state) == Material.LAVA)
				{
					mc.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)((float)blockPos1.getX() + f1), (double)((float)blockPos1.getY() + 0.1F) - axisalignedbb.minY, (double)((float)blockPos1.getZ() + f2), 0.0D, 0.0D, 0.0D, new int[0]);
				}
				else if (block.getMaterial(state) != Material.AIR)
				{
					//block.setBlockBoundsBasedOnState(worldclient, blockpos2);
					++i;

					if (worldclient.rand.nextInt(i) == 0)
					{
						d0 = (double)((float)blockpos2.getX() + f1);
						d1 = (double)((float)blockpos2.getY() + 0.1F) + axisalignedbb.maxY - 1.0D;
						d2 = (double)((float)blockpos2.getZ() + f2);
					}

					mc.world.spawnParticle(EnumParticleTypes.WATER_DROP, (double)((float)blockpos2.getX() + f1), (double)((float)blockpos2.getY() + 0.1F) + axisalignedbb.maxY, (double)((float)blockpos2.getZ() + f2), 0.0D, 0.0D, 0.0D, new int[0]);
				}
			}
		}

		if (i > 0 && worldclient.rand.nextInt(3) < rainSoundCounter++)
		{
			rainSoundCounter = 0;

			if (d1 > (double)(blockpos.getY() + 1) && worldclient.getPrecipitationHeight(blockpos).getY() > MathHelper.floor((float)blockpos.getY()))
			{
				mc.world.playSound(d0, d1, d2, SoundEvents.WEATHER_RAIN_ABOVE, SoundCategory.WEATHER, 0.1F*rainStrength, 0.5F, false);
			}
			else
			{
				mc.world.playSound(d0, d1, d2, SoundEvents.WEATHER_RAIN, SoundCategory.WEATHER, 0.2F*rainStrength, 1.0F, false);
			}
		}
	}
}
 
Example 16
Source File: BiomeCragCliffs.java    From Traverse-Legacy-1-12-2 with MIT License 4 votes vote down vote up
@Override
public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	int i = worldIn.getSeaLevel();
	IBlockState iblockstate = this.topBlock;
	IBlockState iblockstate1 = this.fillerBlock;
	int j = -1;
	int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
	int l = x & 15;
	int i1 = z & 15;
	BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

	for (int j1 = 255; j1 >= 0; --j1) {
		if (j1 <= rand.nextInt(5)) {
			chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK);
		} else {
			IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l);

			if (iblockstate2.getMaterial() == Material.AIR) {
				j = -1;
			} else if (iblockstate2.getBlock() == Blocks.STONE) {
				if (j == -1) {
					if (k <= 0) {
						iblockstate = AIR;
						iblockstate1 = STONE;
					} else if (j1 >= i - 4 && j1 <= i + 1) {
						iblockstate = this.topBlock;
						iblockstate1 = this.fillerBlock;
					}

					if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) {
						if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) {
							iblockstate = ICE;
						} else {
							iblockstate = WATER;
						}
					}

					j = k;

					if (j1 >= i - 1) {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate);
					} else if (j1 < i - 7 - k) {
						iblockstate = AIR;
						iblockstate1 = STONE;
						chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL);
					} else {
						chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
					}
				} else if (j > 0) {
					--j;
					chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);

					if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE;
					}

					if (j == 0 && iblockstate == blueRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate = blueRock;
					}

					if (j == 0 && iblockstate1 == blueRock && k > 1) {
						j = rand.nextInt(4) + Math.max(0, j1 - 63);
						iblockstate1 = blueRock;
					}
				}
			}
		}
	}
}
 
Example 17
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
 * Mineshafts at the end, it adds Fences...
 */
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.averageGroundLvl < 0) {
        this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

        if (this.averageGroundLvl < 0) {
            return true;
        }

        this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 6 - 1, 0);
    }

    IBlockState iblockstate = this.getBiomeSpecificBlockState(BlockLoader.tofuTerrain.getDefaultState());
    IBlockState iblockstate1 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());
    IBlockState iblockstate2 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH));
    IBlockState iblockstate3 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());

    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 4, 0, 4, iblockstate, iblockstate, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 0, 4, 4, 4, iblockstate3, iblockstate3, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 4, 1, 3, 4, 3, iblockstate1, iblockstate1, false);
    this.setBlockState(worldIn, iblockstate, 0, 1, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 1, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 1, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 2, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 3, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 1, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 2, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 3, 4, structureBoundingBoxIn);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 1, 1, 0, 3, 3, iblockstate1, iblockstate1, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 4, 1, 1, 4, 3, 3, iblockstate1, iblockstate1, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 4, 3, 3, 4, iblockstate1, iblockstate1, false);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 2, 2, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 2, 2, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 4, 2, 2, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 1, 1, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 1, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 1, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 2, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 3, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 3, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 3, 1, 0, structureBoundingBoxIn);

    if (this.getBlockStateFromPos(worldIn, 2, 0, -1, structureBoundingBoxIn).getMaterial() == Material.AIR && this.getBlockStateFromPos(worldIn, 2, -1, -1, structureBoundingBoxIn).getMaterial() != Material.AIR)
    {
        this.setBlockState(worldIn, iblockstate2, 2, 0, -1, structureBoundingBoxIn);

    }

    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 1, 3, 3, 3, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);


    this.placeTorch(worldIn, EnumFacing.NORTH, 2, 3, 1, structureBoundingBoxIn);
    this.placeDoor(worldIn, structureBoundingBoxIn, randomIn, 2, 1, 0, EnumFacing.NORTH);

    for (int j = 0; j < 5; ++j)
    {
        for (int i = 0; i < 5; ++i)
        {
            this.clearCurrentPositionBlocksUpwards(worldIn, i, 6, j, structureBoundingBoxIn);
            this.replaceAirAndLiquidDownwards(worldIn, iblockstate, i, -1, j, structureBoundingBoxIn);
        }
    }

    this.spawnVillagers(worldIn, structureBoundingBoxIn, 1, 1, 2, 1);
    return true;
}
 
Example 18
Source File: EntityFallingBlockEU.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void readEntityFromNBT(NBTTagCompound nbt)
{
    Block block = null;
    int meta = nbt.getByte("Data") & 0xF;

    if (nbt.hasKey("Block", Constants.NBT.TAG_STRING))
    {
        block = Block.getBlockFromName(nbt.getString("Block"));
        this.setBlockState(block.getStateFromMeta(meta));
    }

    this.fallTime = nbt.getInteger("Time");

    if (nbt.hasKey("HurtEntities", Constants.NBT.TAG_BYTE))
    {
        this.hurtEntities = nbt.getBoolean("HurtEntities");
        this.fallHurtAmount = nbt.getFloat("FallHurtAmount");
        this.fallHurtMax = nbt.getInteger("FallHurtMax");
    }
    else if (block == Blocks.ANVIL)
    {
        this.hurtEntities = true;
    }

    if (nbt.hasKey("DropItem", 99))
    {
        this.shouldDropItem = nbt.getBoolean("DropItem");
    }

    if (nbt.hasKey("TileEntityData", 10))
    {
        this.tileEntityData = nbt.getCompoundTag("TileEntityData");
    }

    if (block == null || block.getDefaultState().getMaterial() == Material.AIR)
    {
        this.blockState = Blocks.SAND.getDefaultState();
    }
}
 
Example 19
Source File: TofuVillagerHouse.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
 * Mineshafts at the end, it adds Fences...
 */
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.averageGroundLvl < 0) {
        this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

        if (this.averageGroundLvl < 0) {
            return true;
        }

        this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 9 - 1, 0);
    }

    IBlockState iblockstate1 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());
    IBlockState iblockstate2 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH));
    IBlockState air = Blocks.AIR.getDefaultState();
    IBlockState iblockstate3 = BlockLoader.ISHITOFU.getDefaultState();

    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 6, 4, 6, iblockstate1, iblockstate1, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 1, 5, 3, 5, air, air, false);

    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 2, 3, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 3, 2, 6, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 6, 2, 3, structureBoundingBoxIn);

    this.setBlockState(worldIn, Blocks.BOOKSHELF.getDefaultState(), 1, 1, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.BOOKSHELF.getDefaultState(), 1, 2, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.BOOKSHELF.getDefaultState(), 1, 3, 5, structureBoundingBoxIn);

    this.setBlockState(worldIn, Blocks.CRAFTING_TABLE.getDefaultState(), 1, 1, 4, structureBoundingBoxIn);

    this.setBlockState(worldIn, BlockLoader.SALTFURNACE.getDefaultState(), 1, 5, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.CAULDRON.getDefaultState(), 1, 6, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.ISHITOFU.getDefaultState(), 5, 5, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.TOFUISHI_BRICK.getDefaultState(), 5, 6, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.ISHITOFU.getDefaultState(), 4, 5, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.TOFUISHI_BRICK.getDefaultState(), 5, 6, 1, structureBoundingBoxIn);

    IBlockState iblockstate5 = BlockLoader.TOFUISHI_BRICK_LADDER.getDefaultState().withProperty(BlockLadder.FACING, EnumFacing.SOUTH);
    this.setBlockState(worldIn, iblockstate5, 5, 1, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate5, 5, 2, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate5, 5, 3, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate5, 5, 4, 5, structureBoundingBoxIn);
    //2F
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5, 0, 6, 9, 6, iblockstate1, iblockstate1, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 5, 1, 5, 8, 5, air, air, false);

    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 0, 9, 0, iblockstate3, iblockstate3, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 0, 0, 6, 9, 0, iblockstate3, iblockstate3, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 6, 0, 9, 6, iblockstate3, iblockstate3, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 0, 6, 6, 9, 6, iblockstate3, iblockstate3, false);

    this.setBlockState(worldIn, BlockLoader.ISHITOFU.getDefaultState(), 1, 5, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.TOFU_LEAVE.getDefaultState(), 1, 6, 5, structureBoundingBoxIn);

    BlockPos blockpos = new BlockPos(this.getXWithOffset(2, 5), this.getYWithOffset(5), this.getZWithOffset(2, 5));

    this.generateChest(worldIn, structureBoundingBoxIn, randomIn, blockpos, TofuLootTables.tofuhouse, BlockLoader.TOFUCHEST.getDefaultState().withProperty(BlockTofuChest.FACING, EnumFacing.EAST));

    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 6, 3, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 3, 6, 6, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 6, 6, 3, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 3, 6, 0, structureBoundingBoxIn);


    if (this.getBlockStateFromPos(worldIn, 3, 0, -1, structureBoundingBoxIn).getMaterial() == Material.AIR && this.getBlockStateFromPos(worldIn, 3, -1, -1, structureBoundingBoxIn).getMaterial() != Material.AIR) {
        this.setBlockState(worldIn, iblockstate2, 3, 0, -1, structureBoundingBoxIn);

    }


    this.placeTorch(worldIn, EnumFacing.NORTH, 3, 3, 1, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.SOUTH, 3, 3, 5, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.SOUTH, 3, 7, 5, structureBoundingBoxIn);

    this.createVillageDoor(worldIn, structureBoundingBoxIn, randomIn, 3, 1, 0, EnumFacing.NORTH);


    this.spawnVillagers(worldIn, structureBoundingBoxIn, 4, 1, 4, 2);

    for (int l = 0; l < 6; ++l) {
        for (int k = 0; k < 6; ++k) {
            this.clearCurrentPositionBlocksUpwards(worldIn, k, 9, l, structureBoundingBoxIn);
            this.replaceAirAndLiquidDownwards(worldIn, iblockstate1, k, -1, l, structureBoundingBoxIn);
        }
    }

    return true;
}
 
Example 20
Source File: BlockTofuPortal.java    From TofuCraftReload with MIT License 3 votes vote down vote up
protected boolean isEmptyBlock(IBlockState state) {

            Block blockIn = state.getBlock();

            return state.getMaterial() == Material.AIR || blockIn == Blocks.FIRE ||

                    blockIn == BlockLoader.tofu_PORTAL;

        }