Java Code Examples for net.minecraft.init.Blocks#WATER

The following examples show how to use net.minecraft.init.Blocks#WATER . 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 CommunityMod with GNU Lesser General Public License v2.1 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: 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 3
Source File: BiomeGenDeepSwamp.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
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, Blocks.WATERLILY.getDefaultState());
                       }
                   }

                   break;
               }
           }
       }

       this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);

       
	//Decoration time takes too long due to block relights, so run at terrain gen time
	///swampTree.func_151539_a(null, world, x, z, block); //Arg 1 never actually used so fake it
	//Yes this is hacky
	if(x % 16 == 0 && z % 16 == 0 )
		swampTree.generate(worldIn, x/16, z/16, chunkPrimerIn);
}
 
Example 4
Source File: CollectorHelper.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public static boolean isFloatingInWater(World world, BlockPos pos) {

        IBlockState aboveBlock = world.getBlockState(pos.add(0, 1, 0));

        // If underwater, is invalid
        if (aboveBlock.getBlock() == Blocks.WATER) {
            return false;
        }

        BlockPos startPos = pos.add(-2, 0, -2);

        int waterBlockCount = 0;

        for (int x = 0; x < 5; x++) {
            for (int z = 0; z < 5; z++) {
                boolean isValidNeighbour = isValidNeighbour(world.getBlockState(startPos.add(x, 0, z)));
                if (isValidNeighbour) {
                    waterBlockCount++;
                    if (waterBlockCount >= EmergingTechnologyConfig.POLYMERS_MODULE.COLLECTOR.minimumWaterBlocks) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
 
Example 5
Source File: ItemUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static ItemStack getStateToItemOverride(IBlockState state)
{
    if (state.getBlock() == Blocks.LAVA || state.getBlock() == Blocks.FLOWING_LAVA)
    {
        return new ItemStack(Items.LAVA_BUCKET);
    }
    else if (state.getBlock() == Blocks.WATER || state.getBlock() == Blocks.FLOWING_WATER)
    {
        return new ItemStack(Items.WATER_BUCKET);
    }

    return ItemStack.EMPTY;
}
 
Example 6
Source File: DrinkWaterHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickBlock event)
{
	if(event.getSide() == Side.CLIENT)
	{
		/*if(event.getHitVec() == null || event.getItemStack() != null)
		{
			return;
		}
		BlockPos blockpos = event.getPos().offset(event.getFace());
		IBlockState state = event.getWorld().getBlockState(blockpos);
		if(state.getBlock() == Blocks.WATER && Core.isFreshWater(event.getWorld(), blockpos))
		{
			Minecraft.getMinecraft().playerController.processRightClickBlock((EntityPlayerSP)event.getEntityPlayer(), 
					(WorldClient)event.getWorld(), event.getItemStack(), blockpos, event.getFace(), event.getHitVec(), event.getHand());
		}*/
	}
	else
	{
		BlockPos blockpos = event.getPos().offset(event.getFace());
		IBlockState state = event.getWorld().getBlockState(blockpos);
		if((state.getBlock() == Blocks.WATER || state.getBlock() == Blocks.FLOWING_WATER) && Core.isFreshWater(event.getWorld(), blockpos))
		{
			if(event.getEntityPlayer().getHeldItem(event.getHand()) == ItemStack.EMPTY)
			{
				IFoodStatsTFC food = (IFoodStatsTFC)event.getEntityPlayer().getFoodStats();
				food.setWaterLevel((Math.min(food.getWaterLevel()+0.1f, 20)));
				TFC.network.sendTo(new CFoodPacket(food), (EntityPlayerMP) event.getEntityPlayer());
			}
			else if(ItemPotteryJug.IsCeramicJug(event.getEntityPlayer().getHeldItem(event.getHand())))
			{
				event.getEntityPlayer().getHeldItem(event.getHand()).setItemDamage(2);
			}
		}
	}
}
 
Example 7
Source File: BlockWaterHyacinth.java    From Production-Line with MIT License 4 votes vote down vote up
@Override
protected boolean canSustainBush(IBlockState state) {
    return state.getBlock() == Blocks.WATER || state.getMaterial() == Material.ICE;
}
 
Example 8
Source File: PLItems.java    From Production-Line with MIT License 4 votes vote down vote up
public static void init() {
        diamondApple = new ItemDiamondApple();


        record_MusicSpring = new ItemPLRecord("record_musicspring", PLSounds.recordMusicSpring);
        salt = new ItemPLFood("salt", 0, 10F, true);
        gravityRay = new ItemGravityRay();

        //MultiMetaItem registry
        itemOre = new ItemOre();
        itemCrafting = new ItemCrafting();


        // special registry TODO: Better registry system

        packagedSalt = new ItemPL("packaged_salt") {
            /**
             * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
             */
            @Override
            public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) {
                if (PLConfig.instance.throwablePackagedSalt) {
                    if (!player.capabilities.isCreativeMode) {
                        --itemStack.stackSize;
                    }
                    world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
                    if (!world.isRemote) {
                        world.spawnEntity(new EntityThrownItem(world, player, itemStack));
                    }
                }

                return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
            }

        };

        saltWaterBucket = new ItemBucket(Blocks.WATER);
        saltWaterBucket.setCreativeTab(ProductionLine.creativeTabPL)
                .setUnlocalizedName(MOD_ID + ".saltwater_bucket");

//        iridiumPickaxe = ToolPL.registerPickaxe(PLToolMaterial.iridium, "iridium_pickaxe");
//        iridiumAxe = ToolPL.registerAxe(PLToolMaterial.iridium, "iridium_axe");
//        iridiumSpade = ToolPL.registerSpade(PLToolMaterial.iridium, "iridium_spade");
//        iridiumSword = ToolPL.registerSword(PLToolMaterial.iridium, "iridium_sword");

        // TODO: Better registry system
        GameRegistry.<Item>register(saltWaterBucket, new ResourceLocation(MOD_ID, "saltwater_bucket"));
        GameRegistry.registerFuelHandler(new PLItems());
    }
 
Example 9
Source File: QuestBase.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
protected static boolean isLiquid(IBlockState blockState) {
	return blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.LAVA;
}
 
Example 10
Source File: TileEntityToroSpawner.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean isLiquid(IBlockState blockState) {
	return blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.LAVA;
}
 
Example 11
Source File: ItemEnderBucket.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *  Attempts to place one fluid block in the world, identified by the given FluidStack
 */
public boolean tryPlaceFluidBlock(World world, BlockPos pos, FluidStack fluidStack)
{
    if (fluidStack == null || fluidStack.getFluid() == null || fluidStack.getFluid().canBePlacedInWorld() == false)
    {
        return false;
    }

    Block block = fluidStack.getFluid().getBlock();

    // We need to convert water and lava to the flowing variant, otherwise we get non-flowing source blocks
    if (block == Blocks.WATER)
    {
        block = Blocks.FLOWING_WATER;
    }
    else if (block == Blocks.LAVA)
    {
        block = Blocks.FLOWING_LAVA;
    }

    IBlockState state = world.getBlockState(pos);
    Material material = state.getMaterial();

    if (world.isAirBlock(pos) == false && material.isSolid())
    {
        return false;
    }

    if (world.provider.doesWaterVaporize() && block == Blocks.FLOWING_WATER)
    {
        float x = pos.getX();
        float y = pos.getY();
        float z = pos.getZ();

        world.playSound(null, x + 0.5F, y + 0.5F, z + 0.5F, SoundEvents.BLOCK_FIRE_EXTINGUISH,
                SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

        for (int l = 0; l < 8; ++l)
        {
            world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, x + Math.random(), y + Math.random(), z + Math.random(), 0.0D, 0.0D, 0.0D);
        }
    }
    else
    {
        if (world.isRemote == false && material.isSolid() == false && material.isLiquid() == false)
        {
            // Set a replaceable block to air, and drop the items
            world.destroyBlock(pos, true);
        }

        world.setBlockState(pos, block.getDefaultState(), 3);
        SoundEvent soundevent = block == Blocks.FLOWING_LAVA ? SoundEvents.ITEM_BUCKET_EMPTY_LAVA : SoundEvents.ITEM_BUCKET_EMPTY;
        world.playSound(null, pos, soundevent, SoundCategory.BLOCKS, 1.0f, 1.0f);
    }

    return true;
}
 
Example 12
Source File: BastionsLairGenerator.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean isLiquid(IBlockState blockState) {
	return blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.LAVA;
}
 
Example 13
Source File: BastionsLairEntranceGenerator.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean isLiquid(IBlockState blockState) {
	return blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.LAVA;
}
 
Example 14
Source File: MonolithGenerator.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean isLiquid(IBlockState blockState) {
	return blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.LAVA;
}
 
Example 15
Source File: GraveyardGenerator.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean isLiquid(IBlockState blockState) {
	return blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.LAVA;
}
 
Example 16
Source File: ModuleEffectFrost.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Entity targetEntity = spell.getVictim(world);
	BlockPos targetPos = spell.getTargetPos();
	Entity caster = spell.getCaster(world);

	double range = spellRing.getAttributeValue(world, AttributeRegistry.AREA, spell) / 2;
	double time = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 10;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (targetEntity != null) {
		world.playSound(null, targetEntity.getPosition(), ModSounds.FROST_FORM, SoundCategory.NEUTRAL, 1, 1);
		targetEntity.extinguish();
		if (targetEntity instanceof EntityLivingBase) {
			((EntityLivingBase) targetEntity).addPotionEffect(new PotionEffect(ModPotions.SLIPPERY, (int) time, 0, true, false));
		}
	}

	if (targetPos != null) {
		world.playSound(null, targetPos, ModSounds.FROST_FORM, SoundCategory.NEUTRAL, 1, 1);
		for (BlockPos pos : BlockPos.getAllInBox(targetPos.add(-range, -range, -range), targetPos.add(range + 1, range + 1, range + 1))) {
			double dist = pos.distanceSq(targetPos);
			if (dist > range) continue;

			for (EnumFacing facing : EnumFacing.VALUES) {
				IBlockState state = world.getBlockState(pos.offset(facing));
				if (state.getBlock() == Blocks.FIRE) {
					BlockUtils.breakBlock(world, pos.offset(facing), state, BlockUtils.makeBreaker(world, pos, caster));
				}
			}

			BlockPos up = pos.offset(EnumFacing.UP);
			if (world.getBlockState(pos).isSideSolid(world, pos, EnumFacing.UP) && world.isAirBlock(up)) {
				int layerSize = (int) (Math.max(1, Math.min(8, Math.max(1, (dist / range) * 6.0))));
				layerSize = Math.max(1, Math.min(layerSize + RandUtil.nextInt(-1, 1), 8));
				BlockUtils.placeBlock(world, up, Blocks.SNOW_LAYER.getDefaultState().withProperty(BlockSnow.LAYERS, layerSize), BlockUtils.makePlacer(world, up, caster));
			}

			if (world.getBlockState(pos).getBlock() == Blocks.WATER) {
				BlockUtils.placeBlock(world, pos, Blocks.ICE.getDefaultState(), BlockUtils.makePlacer(world, pos, caster));
			}
		}
	}
	return true;
}
 
Example 17
Source File: MaterialCache.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Nullable
protected ItemStack getStateToItemOverride(IBlockState state)
{
    Block block = state.getBlock();

    if (block == Blocks.PISTON_HEAD ||
        block == Blocks.PISTON_EXTENSION ||
        block == Blocks.PORTAL ||
        block == Blocks.END_PORTAL ||
        block == Blocks.END_GATEWAY)
    {
        return ItemStack.EMPTY;
    }
    else if (block == Blocks.FARMLAND)
    {
        return new ItemStack(Blocks.DIRT);
    }
    else if (block == Blocks.GRASS_PATH)
    {
        return new ItemStack(Blocks.GRASS);
    }
    else if (block == Blocks.BROWN_MUSHROOM_BLOCK)
    {
        return new ItemStack(Blocks.BROWN_MUSHROOM_BLOCK);
    }
    else if (block == Blocks.RED_MUSHROOM_BLOCK)
    {
        return new ItemStack(Blocks.RED_MUSHROOM_BLOCK);
    }
    else if (block == Blocks.LAVA)
    {
        if (state.getValue(BlockLiquid.LEVEL) == 0)
        {
            return new ItemStack(Items.LAVA_BUCKET);
        }
        else
        {
            return ItemStack.EMPTY;
        }
    }
    else if (block == Blocks.WATER)
    {
        if (state.getValue(BlockLiquid.LEVEL) == 0)
        {
            return new ItemStack(Items.WATER_BUCKET);
        }
        else
        {
            return ItemStack.EMPTY;
        }
    }
    else if (block instanceof BlockDoor && state.getValue(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.UPPER)
    {
        return ItemStack.EMPTY;
    }
    else if (block instanceof BlockBed && state.getValue(BlockBed.PART) == BlockBed.EnumPartType.HEAD)
    {
        return ItemStack.EMPTY;
    }
    else if (block instanceof BlockDoublePlant && state.getValue(BlockDoublePlant.HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
    {
        return ItemStack.EMPTY;
    }

    return null;
}
 
Example 18
Source File: PlanetEventHandler.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void fogColor(RenderFogEvent event) {

	if(false || event.getFogMode() == -1) {
		return;
	}
	DimensionProperties properties = DimensionManager.getInstance().getDimensionProperties(event.getEntity().dimension);
	if(properties != null && event.getState().getBlock() != Blocks.WATER && event.getState().getBlock() != Blocks.LAVA) {//& properties.atmosphereDensity > 125) {
		float fog = properties.getAtmosphereDensityAtHeight(event.getEntity().posY);
		//GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP);
		GlStateManager.setFog(GlStateManager.FogMode.LINEAR);



		float f1 = event.getFarPlaneDistance();
		float near;
		float far;

		int atmosphere = properties.getAtmosphereDensity();
		ItemStack armor = Minecraft.getMinecraft().player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);

		if(armor != null && armor.getItem() instanceof IModularArmor) {
			for(ItemStack i : ((IModularArmor)armor.getItem()).getComponents(armor)) {
				if(i.isItemEqual(component)) {
					atmosphere = Math.min(atmosphere, 100);
					break;
				}
			}
		}

		//Check environment
		if(AtmosphereHandler.currentPressure != -1) {
			atmosphere = AtmosphereHandler.currentPressure;
		}

		if(atmosphere > 100) {
			near = 0.75f*f1*(2.00f - atmosphere*atmosphere/10000f);
			far = f1;
		}
		else {
			near = 0.75f*f1*(2.00f -atmosphere/100f);
			far = f1*(2.002f - atmosphere/100f);
		}

		GlStateManager.setFogStart(near);
		GlStateManager.setFogEnd(far);
		GlStateManager.setFogDensity(0);


		//event.setCanceled(false);
	}
		
}
 
Example 19
Source File: TidalHelper.java    From EmergingTechnology with MIT License 3 votes vote down vote up
private static boolean isValidNeighbour(World world, BlockPos pos) {

        IBlockState state = world.getBlockState(pos);

        Block block = state.getBlock();

        return (block == Blocks.WATER || block.getMaterial(state).isLiquid());
    }
 
Example 20
Source File: CollectorHelper.java    From EmergingTechnology with MIT License 2 votes vote down vote up
private static boolean isValidNeighbour(IBlockState state) {

        Block block = state.getBlock();

        return (block == Blocks.WATER);
    }