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

The following examples show how to use net.minecraft.init.Blocks#SNOW_LAYER . 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: MapGenTofuCaves.java    From TofuCraftReload with MIT License 6 votes vote down vote up
protected boolean canReplaceBlock(IBlockState p_175793_1_, IBlockState p_175793_2_) {
    if (p_175793_1_.getBlock() == Blocks.STONE) {
        return true;
    } else if (p_175793_1_.getBlock() == Blocks.DIRT) {
        return true;
    } else if (p_175793_1_.getBlock() == Blocks.GRASS) {
        return true;
    } else if (p_175793_1_.getBlock() == Blocks.HARDENED_CLAY) {
        return true;
    } else if (p_175793_1_.getBlock() == Blocks.STAINED_HARDENED_CLAY) {
        return true;
    } else if (p_175793_1_.getBlock() == Blocks.SANDSTONE) {
        return true;
    } else if (p_175793_1_.getBlock() == Blocks.RED_SANDSTONE) {
        return true;
    } else if (p_175793_1_.getBlock() == Blocks.MYCELIUM) {
        return true;
    } else if (p_175793_1_.getBlock() == Blocks.SNOW_LAYER) {
        return true;
    } else {
        return (/*p_175793_1_.getBlock() == TcBlocks.tofuMinced || */p_175793_1_.getBlock() == Blocks.GRAVEL)
                && p_175793_2_.getMaterial() != Material.WATER;

    }
}
 
Example 2
Source File: EntityDabSquirrel.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void playStepSound(BlockPos pos, Block blockIn) {
	if (!blockIn.getDefaultState().getMaterial().isLiquid()) {
		SoundType soundtype = blockIn.getSoundType(blockIn.getDefaultState(), this.world, pos, this);

		if (this.world.getBlockState(pos.up()).getBlock() == Blocks.SNOW_LAYER) {
			soundtype = Blocks.SNOW_LAYER.getSoundType(Blocks.SNOW_LAYER.getDefaultState(), this.world, pos, this);
		}

		if (this.isBeingRidden()) {
			++this.gallopTime;

			if (this.gallopTime > 5 && this.gallopTime % 3 == 0) {
				this.playGallopSound(soundtype);
			} else if (this.gallopTime <= 5) {
				this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
			}
		} else if (soundtype == SoundType.WOOD) {
			this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
		} else {
			this.playSound(SoundEvents.ENTITY_HORSE_STEP, soundtype.getVolume() * 0.15F, soundtype.getPitch());
		}
	}
}
 
Example 3
Source File: BlockUtils.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Check if the given block can be placed in the given position.
 * Note: This method is a functional copy of ItemBlock.func_150936_a() which is client side only.
 */
public static boolean checkCanPlaceBlockAt(World world, BlockPos pos, EnumFacing side, Block blockNew)
{
    Block blockExisting = world.getBlockState(pos).getBlock();

    if (blockExisting == Blocks.SNOW_LAYER && blockExisting.isReplaceable(world, pos))
    {
        side = EnumFacing.UP;
    }
    else if (blockExisting.isReplaceable(world, pos) == false)
    {
        pos = pos.offset(side);
    }

    return world.mayPlace(blockNew, pos, false, side, (Entity) null);
}
 
Example 4
Source File: MaterialCache.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void overrideStackSize(IBlockState state, ItemStack stack)
{
    if (state.getBlock() instanceof BlockSlab && ((BlockSlab) state.getBlock()).isDouble())
    {
        stack.setCount(2);
    }
    else if (state.getBlock() == Blocks.SNOW_LAYER)
    {
        stack.setCount(state.getValue(BlockSnow.LAYERS));
    }
}
 
Example 5
Source File: ModuleEffectBurn.java    From Wizardry with GNU Lesser General Public License v3.0 5 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);
	EnumFacing facing = spell.getData(FACE_HIT);

	double area = spellRing.getAttributeValue(world, AttributeRegistry.AREA, spell) / 2.0;
	double time = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell);

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

	if (targetEntity != null) {
		targetEntity.setFire((int) time);
		world.playSound(null, targetEntity.getPosition(), ModSounds.FIRE, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.35f, 0.75f), RandUtil.nextFloat(0.35f, 1.5f));
	}

	if (targetPos != null) {
		for (int x = (int) area; x >= -area; x--)
			for (int y = (int) area; y >= -area; y--)
				for (int z = (int) area; z >= -area; z--) {
					BlockPos pos = targetPos.add(x, y, z);
					double dist = pos.getDistance(targetPos.getX(), targetPos.getY(), targetPos.getZ());
					if (dist > area) continue;
					if (facing != null) {
						if (!world.isAirBlock(pos.offset(facing))) continue;
						BlockUtils.placeBlock(world, pos.offset(facing), Blocks.FIRE.getDefaultState(), BlockUtils.makePlacer(world, pos, caster));
					} else for (EnumFacing face : EnumFacing.VALUES) {
						if (world.isAirBlock(pos.offset(face)) || world.getBlockState(pos.offset(face)).getBlock() == Blocks.SNOW_LAYER) {
							BlockUtils.placeBlock(world, pos.offset(face), Blocks.AIR.getDefaultState(), BlockUtils.makePlacer(world, pos, caster));
						}
					}
				}
		world.playSound(null, targetPos, ModSounds.FIRE, SoundCategory.AMBIENT, 0.5f, RandUtil.nextFloat());
	}
	return true;
}
 
Example 6
Source File: BuildBattleDecoratorImplementation.java    From malmo with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event)
{
    // Disallow creating or destroying events in the player structure:
    if (event instanceof PlayerInteractEvent.LeftClickBlock)
    {
        // Destroy block
        if (blockInBounds(event.getPos(), this.sourceBounds))
            event.setCanceled(true);
    }
    else if (event instanceof PlayerInteractEvent.RightClickBlock)
    {
        // Place block - need to work out *where* the block would be placed.
        // This code was cribbed from ItemBlock.onItemUse()
        IBlockState iblockstate = event.getWorld().getBlockState(event.getPos());
        Block block = iblockstate.getBlock();
        EnumFacing side = event.getFace();
        BlockPos pos = event.getPos();
        if (block == Blocks.SNOW_LAYER && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
        {
            side = EnumFacing.UP;
        }
        else if (!block.isReplaceable(event.getWorld(), pos))
        {
            pos = pos.offset(side);
        }
        if (blockInBounds(pos, this.sourceBounds))
            event.setCanceled(true);
    }
}
 
Example 7
Source File: BWBlock.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean shouldDisplacePlacement() {
	if (block() == Blocks.SNOW_LAYER && (blockState().getValue(BlockSnow.LAYERS) < 1)) {
		return false;
	}

	if (block() == Blocks.VINE || block() == Blocks.TALLGRASS || block() == Blocks.DEADBUSH || block().isReplaceable(blockAccess(), blockPos())) {
		return false;
	}
	return super.shouldDisplacePlacement();
}