Java Code Examples for net.minecraft.init.Blocks

The following examples show how to use net.minecraft.init.Blocks. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	if (!worldIn.isRemote) {
		if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getLightOpacity(worldIn, pos.up()) > 2) {
			worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, DirtType.DIRT));
		} else {
			if (worldIn.getLightFromNeighbors(pos.up()) >= 9) {
				for (int i = 0; i < 4; ++i) {
					BlockPos posAt = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
					IBlockState stateAt = worldIn.getBlockState(posAt);
					IBlockState stateAbove = worldIn.getBlockState(posAt.up());
					if (Blocks.DIRT.equals(stateAt.getBlock()) && DirtType.DIRT.equals(stateAt.getValue(BlockDirt.VARIANT))
							&& worldIn.getLightFromNeighbors(posAt.up()) >= 4
							&& stateAbove.getLightOpacity(worldIn, posAt.up()) <= 2) {
						worldIn.setBlockState(posAt, this.getDefaultState());
					}
				}
			}
		}
	}
}
 
Example 2
Source Project: BigReactors   Source File: RadiationHelper.java    License: MIT License 6 votes vote down vote up
private void moderateByBlock(RadiationData data, RadiationPacket radiation, Block block, int metadata) {
	ReactorInteriorData moderatorData = null;

	if(block == Blocks.iron_block) {
		moderatorData = ReactorInterior.getBlockData("blockIron");
	}
	else if(block == Blocks.gold_block) {
		moderatorData = ReactorInterior.getBlockData("blockGold");
	}
	else if(block == Blocks.diamond_block) {
		moderatorData = ReactorInterior.getBlockData("blockDiamond");
	}
	else if(block == Blocks.emerald_block) {
		moderatorData = ReactorInterior.getBlockData("blockEmerald");
	}
	else {
		// Check the ore dictionary.
		moderatorData = ReactorInterior.getBlockData(ItemHelper.oreProxy.getOreName(new ItemStack(block, 1, metadata)));
	}
	
	if(moderatorData == null) {
		moderatorData = airData;
	}

	applyModerationFactors(data, radiation, moderatorData);
}
 
Example 3
Source Project: GardenCollection   Source File: BlockDecorativePot.java    License: MIT License 6 votes vote down vote up
@Override
protected boolean applyItemToGarden (World world, int x, int y, int z, EntityPlayer player, ItemStack itemStack, float hitX, float hitY, float hitZ, boolean hitValid) {
    ItemStack item = (itemStack == null) ? player.inventory.getCurrentItem() : itemStack;

    if (item != null && item.getItem() == Items.flint_and_steel) {
        ItemStack substrate = getGardenSubstrate(world, x, y, z, Slot2Profile.SLOT_CENTER);
        if (substrate != null && substrate.getItem() == Item.getItemFromBlock(Blocks.netherrack)) {
            if (world.isAirBlock(x, y + 1, z)) {
                world.playSoundEffect(x + .5, y + .5, z + .5, "fire.ignite", 1, world.rand.nextFloat() * .4f + .8f);
                world.setBlock(x, y + 1, z, ModBlocks.smallFire);

                world.notifyBlocksOfNeighborChange(x, y, z, this);
                world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
            }

            item.damageItem(1, player);
            return true;
        }
    }

    return super.applyItemToGarden(world, x, y, z, player, itemStack, hitX, hitY, hitZ, hitValid);
}
 
Example 4
public static void addDrillRecipe() {
    woodenDrill = toolRecipe(BaseItemStacks.woodenDrill, BaseItemStacks.woodenDrillTop, "plankWood", "stickWood");
    stoneDrill = toolRecipe(BaseItemStacks.stoneDrill, BaseItemStacks.stoneDrillTop, "stone", "cobblestone");
    ironDrill = toolRecipe(BaseItemStacks.ironDrill, BaseItemStacks.ironDrillTop, "ingotIron", new ItemStack(Items.leather));
    goldenDrill = toolRecipe(BaseItemStacks.goldenDrill, BaseItemStacks.goldenDrillTop, "ingotGold", new ItemStack(Blocks.obsidian));
    diamondDrill = toolRecipe(BaseItemStacks.diamondDrill, BaseItemStacks.diamondDrillTop, "gemDiamond", "ingotGold");

    if (isOreRegistered("ingotCopper") && isOreRegistered("ingotTin"))
        copperDrill = toolRecipe(BaseItemStacks.copperDrill, BaseItemStacks.copperDrillTop, "ingotCopper", "ingotTin");
    if (isOreRegistered("ingotTin"))
        tinDrill = toolRecipe(BaseItemStacks.tinDrill, BaseItemStacks.tinDrillTop, "ingotTin", "ingotGold");
    if (isOreRegistered("ingotLead"))
        leadDrill = toolRecipe(BaseItemStacks.leadDrill, BaseItemStacks.leadDrillTop, "ingotLead", "ingotIron");
    if (isOreRegistered("ingotBronze"))
        bronzeDrill = toolRecipe(BaseItemStacks.bronzeDrill, BaseItemStacks.bronzeDrillTop, "ingotBronze", new ItemStack(Blocks.obsidian));
}
 
Example 5
Source Project: Wizardry   Source File: BlockUtils.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Tries breaking a block safely and fires an event for it.
 *
 * @return Whether the block was successfully broken
 */
public static boolean breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nullable IBlockState oldState, @Nonnull EntityPlayerMP player) {
	if (!world.isBlockLoaded(pos)) return false;

	if (!(player instanceof FakePlayer) && !hasEditPermission(pos, player)) return false;

	if (oldState == null) oldState = world.getBlockState(pos);

	BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, oldState, player);
	MinecraftForge.EVENT_BUS.post(event);

	if (event.isCanceled()) return false;

	TileEntity tile = world.getTileEntity(pos);
	Block block = oldState.getBlock();
	if (block.removedByPlayer(oldState, world, pos, player, true)) {
		block.onPlayerDestroy(world, pos, oldState);
		block.harvestBlock(world, player, pos, oldState, tile, player.getHeldItemMainhand());
		world.notifyBlockUpdate(pos, oldState, Blocks.AIR.getDefaultState(), 3);
	} else return false;

	return true;
}
 
Example 6
Source Project: ehacks-pro   Source File: WaterWalk.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static boolean isOnLiquid(AxisAlignedBB boundingBox) {
    boundingBox = boundingBox.contract(0.01, 0.0, 0.01).offset(0.0, -0.01, 0.0);
    boolean onLiquid = false;
    int y = (int) boundingBox.minY;
    for (int x = MathHelper.floor_double(boundingBox.minX); x < MathHelper.floor_double((boundingBox.maxX + 1.0)); ++x) {
        for (int z = MathHelper.floor_double(boundingBox.minZ); z < MathHelper.floor_double((boundingBox.maxZ + 1.0)); ++z) {
            Block block = Wrapper.INSTANCE.world().getBlock(x, y, z);
            if (block == Blocks.air) {
                continue;
            }
            if (!(block instanceof BlockLiquid)) {
                return false;
            }
            onLiquid = true;
        }
    }
    return onLiquid;
}
 
Example 7
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
       float f = 0.1875F;
       renderer.setOverrideBlockTexture(renderer.getBlockIcon(Blocks.glass));
       renderer.renderStandardBlockWithAmbientOcclusion(block, x, y, z, 1, 1, 1);
       renderer.renderAllFaces = true;
       renderer.setOverrideBlockTexture(renderer.getBlockIcon(Blocks.obsidian));
       renderer.setRenderBounds(0.125D, 0.00625D, 0.125D, 0.875D, (double)f, 0.875D);
       renderer.renderStandardBlockWithAmbientOcclusion(block, x, y, z, 1, 1, 1);
       renderer.setOverrideBlockTexture(renderer.getBlockIcon(Blocks.beacon));
       renderer.setRenderBounds(0.1875D, (double)f, 0.1875D, 0.8125D, 0.875D, 0.8125D);
       renderer.renderStandardBlockWithAmbientOcclusion(block, x, y, z, 1, 1, 1);
       renderer.renderAllFaces = false;
       renderer.clearOverrideBlockTexture();
       return true;
}
 
Example 8
@Override
protected void countAtPosition(BlockPos pos)
{
    IBlockState stateSchematic = this.worldSchematic.getBlockState(pos).getActualState(this.worldSchematic, pos);

    if (stateSchematic.getBlock() != Blocks.AIR)
    {
        IBlockState stateClient = this.worldClient.getBlockState(pos).getActualState(this.worldClient, pos);

        this.countsTotal.addTo(stateSchematic, 1);

        if (stateClient.getBlock() == Blocks.AIR)
        {
            this.countsMissing.addTo(stateSchematic, 1);
        }
        else if (stateClient != stateSchematic)
        {
            this.countsMissing.addTo(stateSchematic, 1);
            this.countsMismatch.addTo(stateSchematic, 1);
        }
    }
}
 
Example 9
Source Project: GardenCollection   Source File: BlockGardenContainer.java    License: MIT License 6 votes vote down vote up
protected boolean isValidSubstrate (World world, int x, int y, int z, int slot, ItemStack itemStack) {
    if (itemStack == null || itemStack.getItem() == null)
        return false;

    Block block = Block.getBlockFromItem(itemStack.getItem());
    if (block == null)
        return false;

    return block == Blocks.dirt
        || block == Blocks.sand
        || block == Blocks.gravel
        || block == Blocks.soul_sand
        || block == Blocks.grass
        || block == Blocks.water
        || block == Blocks.farmland
        || block == Blocks.mycelium
        || block == ModBlocks.gardenSoil
        || block == ModBlocks.gardenFarmland;
}
 
Example 10
private static boolean breakSchematicBlocks(Minecraft mc)
{
    Entity entity = fi.dy.masa.malilib.util.EntityUtils.getCameraEntity();
    RayTraceWrapper wrapper = RayTraceUtils.getSchematicWorldTraceWrapperIfClosest(mc.world, entity, 20);

    if (wrapper != null)
    {
        RayTraceResult trace = wrapper.getRayTraceResult();
        BlockPos pos = trace.getBlockPos();
        EnumFacing playerFacingH = mc.player.getHorizontalFacing();
        EnumFacing direction = fi.dy.masa.malilib.util.PositionUtils.getTargetedDirection(trace.sideHit, playerFacingH, pos, trace.hitVec);

        // Center region
        if (direction == trace.sideHit)
        {
            direction = direction.getOpposite();
        }

        BlockPos posEnd = getReplacementBoxEndPos(pos, direction);

        return setSchematicBlockStates(pos, posEnd, Blocks.AIR.getDefaultState());
    }

    return false;
}
 
Example 11
Source Project: Artifacts   Source File: StructureApprenticeTowerAncient.java    License: MIT License 6 votes vote down vote up
private static void basement(World world, int i, int j, int k, Random rand) {
	boolean noair = false;
	int y = -1;
	do {
		noair = false;
		for(int x = 0; x <= 6; x++) {
			for(int z = 0; z <= 6; z++) {
				//5,y,4
				int d = (x-3)*(x-3)+(z-3)*(z-3);
				if(d <= 10) {
					if(!world.getBlock(i+x, j+y, z+k).isOpaqueCube() || world.getBlock(i+x, j+y, z+k) == Blocks.leaves) {
						noair=true;
						world.setBlock(i+x, j+y, z+k, StructureGenHelper.cobbleMossyOrAir(rand), 0, 2);
					}
				}
			}
		}
		y--;
	} while(noair && (j+y) >= 0);
}
 
Example 12
@Override
protected void setBits(int bitsIn)
{
    if (bitsIn != this.bits)
    {
        this.bits = bitsIn;

        if (this.bits <= MAX_BITS_LINEAR)
        {
            this.bits = Math.max(2, this.bits);
            this.palette = new LitematicaBlockStatePaletteLinear(this.bits, this);
        }
        else
        {
            this.palette = new LitematicaBlockStatePaletteHashMap(this.bits, this);
        }

        // Always reserve ID 0 for air, so that the container doesn't need to be filled with air separately
        this.palette.idFor(Blocks.AIR.getDefaultState());
    }
}
 
Example 13
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider){
    // TODO when adding worldgen, resolve the note at https://github.com/MineMaarten/Signals/pull/80 regarding the possibility of rails not being included in the network.
    if(chunkX == 0) {
        int x = chunkX * 16 + 8;
        int y = 4;
        int startZ = chunkZ * 16;
        for(int z = startZ; z < startZ + 16; z++) {
            world.setBlockState(new BlockPos(x, y, z), Blocks.STONE.getDefaultState(), 0);
            world.setBlockState(new BlockPos(x, y + 1, z), Blocks.RAIL.getDefaultState().withProperty(BlockRail.SHAPE, EnumRailDirection.NORTH_SOUTH), 0);
            if(z % 256 == 0) {
                world.setBlockState(new BlockPos(x + 1, y + 1, z), ModBlocks.BLOCK_SIGNAL.getDefaultState().withProperty(BlockSignalBase.FACING, EnumFacing.NORTH), 0);

            }
        }
    }
}
 
Example 14
Source Project: AdvancedRocketry   Source File: BiomeGenMarsh.java    License: MIT License 6 votes vote down vote up
@Override
public void genTerrainBlocks(World worldIn, Random rand,
		ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) {
	super.genTerrainBlocks(worldIn, rand, chunkPrimerIn, x, z, noiseVal);

	double d1 = GRASS_COLOR_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D);
	x = Math.abs(x % 16);
	z = Math.abs(z % 16);
	if (d1 > 0.2D)
	{
		chunkPrimerIn.setBlockState(x, 62, z, Blocks.GRASS.getDefaultState());
		for(int y = (int)(61); y > 1; y--) {
			
			if(!chunkPrimerIn.getBlockState(x, y, z).isOpaqueCube())
				chunkPrimerIn.setBlockState(x, y, z, Blocks.GRASS.getDefaultState());
			else
				break;
		}
	}
}
 
Example 15
private void doTest(boolean inOrder, boolean enoughDamage)
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {enoughDamage ? 5 : 5000, 0},
                                                                           new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD), new ItemStack(Items.APPLE));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(inOrder ? 3 : 4, new ItemStack(Items.WOODEN_SWORD));
    inv.setInventorySlotContents(inOrder ? 4 : 3, new ItemStack(Items.APPLE));

    assertSame(enoughDamage, recipe.matches(inv, null));

    if (enoughDamage)
    {
        NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
        assertSame(Items.WOODEN_SWORD, remaining.get(inOrder ? 3 : 4).getItem());
        assertEquals(5, remaining.get(inOrder ? 3 : 4).getItemDamage());
    }
}
 
Example 16
Source Project: Sakura_mod   Source File: BlockMapleLeaveOrange.java    License: MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
	Blocks.LEAVES.randomDisplayTick(stateIn, worldIn, pos, rand);
    if (rand.nextInt(40) == 0) {
        int j = rand.nextInt(2) * 2 - 1;
        int k = rand.nextInt(2) * 2 - 1;

        double d0 = pos.getX() + 0.5D + 0.25D * j;
        double d1 = pos.getY() - 0.15D;
        double d2 = pos.getZ() + 0.5D + 0.25D * k;
        double d3 = rand.nextFloat() * j * 0.1D;
        double d4 = ((rand.nextFloat()) * 0.055D) + 0.015D;
        double d5 = rand.nextFloat() * k * 0.1D;

        SakuraMain.proxy.spawnParticle(SakuraParticleType.MAPLEORANGE, d0, d1, d2, d3, -d4, d5);
    }
}
 
Example 17
Source Project: Et-Futurum   Source File: EntityNewSnowGolem.java    License: The Unlicense 5 votes vote down vote up
@Override
public ArrayList<ItemStack> onSheared(ItemStack stack, IBlockAccess world, int x, int y, int z, int fortune) {
	ArrayList<ItemStack> list = new ArrayList<ItemStack>();
	list.add(new ItemStack(Blocks.pumpkin));
	dataWatcher.updateObject(HAS_PUMPKIN, (byte) 0);
	return list;
}
 
Example 18
Source Project: TFC2   Source File: BlockVegDesert.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
{
	if (!canBlockStay(worldIn, pos, state))
	{
		dropBlockAsItem(worldIn, pos, state, 0);
		worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
	}
}
 
Example 19
Source Project: minecraft-roguelike   Source File: Repeater.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void generate(IWorldEditor editor, Random rand, Cardinal dir, int delay, boolean powered, Coord pos){
	
	MetaBlock repeater = powered ? new MetaBlock(Blocks.POWERED_REPEATER) : new MetaBlock(Blocks.UNPOWERED_REPEATER);
	repeater.withProperty(BlockRedstoneRepeater.FACING, Cardinal.facing(dir));
	if (delay > 0 && delay <= 4) repeater.withProperty(BlockRedstoneRepeater.DELAY, delay);
	repeater.set(editor, pos);
}
 
Example 20
Source Project: GT-Classic   Source File: GTUtility.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * A way to update surrounding blocks. this does not update the original block!
 * 
 * @param world     - The world to update in
 * @param pos       - the block pos the update should originate
 * @param blockType - block type which can be null
 * @param sides     - the list of sides to iterate an update
 */
public static void updateNeighbors(World world, BlockPos pos, @Nullable Block blockType, RotationList sides) {
	if (blockType == null) {
		blockType = Blocks.AIR;
	}
	for (EnumFacing side : sides) {
		BlockPos newPos = pos.offset(side);
		if (world.isBlockLoaded(newPos)) {
			world.neighborChanged(newPos, blockType, pos);
		}
	}
}
 
Example 21
@Override
public boolean execute()
{
    World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(this.dimension);
    if (world == null)
    {
        return true;
    }

    for (int i = 0; i < this.blocksPerTick; i++)
    {
        if (this.listIndex >= this.positions.size())
        {
            return true;
        }

        int meta = this.listIndex & 0xF;
        BlockPos pos = this.positions.get(this.listIndex++);

        if (this.placeBlocks)
        {
            IBlockState state = this.blockState != null ? this.blockState : Blocks.STAINED_GLASS.getStateFromMeta(meta);

            world.setBlockState(pos, state, 3);
            world.playSound(null, pos, state.getBlock().getSoundType(state, world, pos, null).getPlaceSound(), SoundCategory.BLOCKS, 1.0f, 1.0f);
        }

        if (this.useParticles)
        {
            Effects.spawnParticlesFromServer(this.dimension, pos, this.particle, 1);
        }

        this.count++;
    }

    return false;
}
 
Example 22
Source Project: TFC2   Source File: BlockVegetation.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
{
	if (!canBlockStay(worldIn, pos, state))
	{
		dropBlockAsItem(worldIn, pos, state, 0);
		worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
	}
}
 
Example 23
Source Project: seppuku   Source File: NoSlowDownModule.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDisable() {
    super.onDisable();
    Blocks.ICE.setDefaultSlipperiness(0.98f);
    Blocks.FROSTED_ICE.setDefaultSlipperiness(0.98f);
    Blocks.PACKED_ICE.setDefaultSlipperiness(0.98f);
}
 
Example 24
Source Project: NOVA-Core   Source File: BWBlock.java    License: 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();
}
 
Example 25
@Override
public void onDeath(DamageSource damage)
{
	if (this.getCarried().getBlock() == Blocks.CHEST)
	{
		this.dropChest();
	}
	if (this.gnode != null)
	{
		//this.gnode.denizen = null;
		this.gnode.onGnomeDeath();
		this.gnode.selfDestruct();
	}
}
 
Example 26
Source Project: GardenCollection   Source File: TileEntityBloomeryFurnace.java    License: MIT License 5 votes vote down vote up
public static boolean isItemSecondaryInput (ItemStack stack) {
    if (stack == null)
        return false;

    if (stack.getItem() == Item.getItemFromBlock(Blocks.sand))
        return true;

    return false;
}
 
Example 27
Source Project: AdvancedRocketry   Source File: StorageChunk.java    License: MIT License 5 votes vote down vote up
public static StorageChunk cutWorldBB(World worldObj, AxisAlignedBB bb) {
	StorageChunk chunk = StorageChunk.copyWorldBB(worldObj, bb);
	for(int x = (int)bb.minX; x <= bb.maxX; x++) {
		for(int z = (int)bb.minZ; z <= bb.maxZ; z++) {
			for(int y = (int)bb.minY; y<= bb.maxY; y++) {

				BlockPos pos = new BlockPos(x, y, z);
				//Workaround for dupe
				TileEntity tile = worldObj.getTileEntity(pos);
				if(tile instanceof IInventory) {
					IInventory inv = (IInventory) tile;
					for(int i = 0; i < inv.getSizeInventory(); i++) {
						inv.setInventorySlotContents(i, ItemStack.EMPTY);
					}
				}

				worldObj.setBlockState(pos, Blocks.AIR.getDefaultState(),2);
			}
		}
	}

	//Carpenter's block's dupe
	for(Object entity : worldObj.getEntitiesWithinAABB(EntityItem.class, bb.grow(5, 5, 5)) ) {
		((Entity)entity).setDead();
	}

	return chunk;
}
 
Example 28
public static void init(){
    registerAcquire(0, 0, Itemss.ingotIronCompressed, null);
    registerAcquire(2, 0, Blockss.airCompressor, getAchieve(Itemss.ingotIronCompressed));
    registerAcquire(4, 0, Fluids.getBucket(Fluids.oil), getAchieve(Itemss.ingotIronCompressed));
    registerAcquire(6, 0, Blockss.refinery, getAchieve(Fluids.getBucket(Fluids.oil)));
    registerAcquire(8, 0, Itemss.plastic, getAchieve(Blockss.refinery));
    registerAcquire(10, 0, Blockss.uvLightBox, getAchieve(Itemss.plastic));
    registerAcquire(12, 0, Fluids.getBucket(Fluids.etchingAcid), getAchieve(Blockss.uvLightBox));

    register("dw9x9", 0, 2, new ItemStack(Blocks.cobblestone), null).setSpecial();

    AchievementPage.registerAchievementPage(new AchievementPage("PneumaticCraft", achieveList.values().toArray(new Achievement[achieveList.size()])));
}
 
Example 29
Source Project: TFC2   Source File: DrinkWaterHandler.java    License: 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 30
public static Set<IBlockState> getMatchingBlockStatesForString(String blockStateString)
{
    Set<IBlockState> validStates = new HashSet<>();
    ResourceLocation air = new ResourceLocation("minecraft:air");
    int index = blockStateString.indexOf('[');
    String name = index > 0 ? blockStateString.substring(0, index) : blockStateString;
    ResourceLocation key = new ResourceLocation(name);
    Block block = ForgeRegistries.BLOCKS.getValue(key);

    if (block != null && (block != Blocks.AIR || key.equals(air)))
    {
        // First get all valid states for this block
        Collection<IBlockState> statesTmp = block.getBlockState().getValidStates();
        // Then get the list of properties and their values in the given name (if any)
        List<Pair<String, String>> props = getBlockStatePropertiesFromString(blockStateString);

        // ... and then filter the list of all valid states by the provided properties and their values
        if (props.isEmpty() == false)
        {
            for (Pair<String, String> pair : props)
            {
                statesTmp = getFilteredStates(statesTmp, pair.getLeft(), pair.getRight());
            }
        }

        validStates.addAll(statesTmp);
    }
    else
    {
        EnderUtilities.logger.warn("BlockUtils.getMatchingBlockStatesForString(): Invalid block state string '{}'", blockStateString);
    }

    return validStates;
}