net.minecraft.util.MovingObjectPosition#net.minecraft.init.Blocks源码实例Demo

下面列出了net.minecraft.util.MovingObjectPosition#net.minecraft.init.Blocks 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Wizardry   文件: BlockTorikkiGrass.java
@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());
					}
				}
			}
		}
	}
}
 
源代码2 项目: BigReactors   文件: RadiationHelper.java
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);
}
 
源代码3 项目: GardenCollection   文件: BlockDecorativePot.java
@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);
}
 
源代码4 项目: Electro-Magic-Tools   文件: BaseRecipeRegistry.java
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));
}
 
源代码5 项目: Wizardry   文件: BlockUtils.java
/**
 * 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;
}
 
源代码6 项目: ehacks-pro   文件: WaterWalk.java
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;
}
 
源代码7 项目: Chisel-2   文件: RenderCarvableBeacon.java
@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;
}
 
源代码8 项目: litematica   文件: TaskCountBlocksPlacement.java
@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);
        }
    }
}
 
源代码9 项目: GardenCollection   文件: BlockGardenContainer.java
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;
}
 
源代码10 项目: litematica   文件: SchematicEditUtils.java
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;
}
 
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);
}
 
@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());
    }
}
 
源代码13 项目: Signals   文件: WorldGeneratorSignals.java
@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);

            }
        }
    }
}
 
源代码14 项目: AdvancedRocketry   文件: BiomeGenMarsh.java
@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;
		}
	}
}
 
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());
    }
}
 
源代码16 项目: Sakura_mod   文件: BlockMapleLeaveOrange.java
@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);
    }
}
 
源代码17 项目: Et-Futurum   文件: EntityNewSnowGolem.java
@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;
}
 
源代码18 项目: TFC2   文件: BlockVegDesert.java
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);
	}
}
 
源代码19 项目: minecraft-roguelike   文件: Repeater.java
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);
}
 
源代码20 项目: GT-Classic   文件: GTUtility.java
/**
 * 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);
		}
	}
}
 
源代码21 项目: enderutilities   文件: TaskPositionDebug.java
@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;
}
 
源代码22 项目: TFC2   文件: BlockVegetation.java
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);
	}
}
 
源代码23 项目: seppuku   文件: NoSlowDownModule.java
@Override
public void onDisable() {
    super.onDisable();
    Blocks.ICE.setDefaultSlipperiness(0.98f);
    Blocks.FROSTED_ICE.setDefaultSlipperiness(0.98f);
    Blocks.PACKED_ICE.setDefaultSlipperiness(0.98f);
}
 
源代码24 项目: NOVA-Core   文件: BWBlock.java
@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();
}
 
源代码25 项目: CommunityMod   文件: EntityGnomeWood.java
@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();
	}
}
 
public static boolean isItemSecondaryInput (ItemStack stack) {
    if (stack == null)
        return false;

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

    return false;
}
 
源代码27 项目: AdvancedRocketry   文件: StorageChunk.java
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;
}
 
源代码28 项目: PneumaticCraft   文件: AchievementHandler.java
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()])));
}
 
源代码29 项目: TFC2   文件: DrinkWaterHandler.java
@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);
			}
		}
	}
}
 
源代码30 项目: enderutilities   文件: BlockUtils.java
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;
}