当前位置: 首页>>代码示例>>Java>>正文


Java World.notifyBlockUpdate方法代码示例

本文整理汇总了Java中net.minecraft.world.World.notifyBlockUpdate方法的典型用法代码示例。如果您正苦于以下问题:Java World.notifyBlockUpdate方法的具体用法?Java World.notifyBlockUpdate怎么用?Java World.notifyBlockUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.world.World的用法示例。


在下文中一共展示了World.notifyBlockUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBlockAdded

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
	if(world.getBlockState(pos.down()).getBlock() == Blocks.LIT_FURNACE){
		((TileEntityPan)world.getTileEntity(pos)).setCooking();
		world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
	}
	if (world.getBlockState(pos.down()).getBlock() == ExSartagineBlock.range_extension){
		if(world.getTileEntity(pos.down()) instanceof TileEntityRangeExtension)
		{
			if(((TileEntityRangeExtension)world.getTileEntity(pos.down())).isCooking())
			{
				((TileEntityPan)world.getTileEntity(pos)).setCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}
		}
	}
}
 
开发者ID:ArtixAllMighty,项目名称:ExSartagine,代码行数:18,代码来源:BlockPan.java

示例2: onHackFinished

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void onHackFinished(World world, BlockPos pos, EntityPlayer player) {
    if (!world.isRemote) {
        NBTTagCompound tag = new NBTTagCompound();
        TileEntity te = world.getTileEntity(pos);
        if (te != null) {
            te.writeToNBT(tag);
            tag.setShort("RequiredPlayerRange", (short) 0);
            te.readFromNBT(tag);
            IBlockState state = world.getBlockState(pos);
            world.notifyBlockUpdate(pos, state, state, 3);
        }
    }

}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:16,代码来源:HackableMobSpawner.java

示例3: neighborChanged

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos)
{

	if(world.getTileEntity(pos) instanceof TileEntitySmelter){
		if(fromPos.up().equals(pos)){ //if the block is beneath us
			Block down = world.getBlockState(fromPos).getBlock();
			if(down == Blocks.AIR)
			{
				dropBlockAsItem(world, pos, getDefaultState(), 0);
				world.setBlockToAir(pos);
			}

			else if(down == Blocks.LIT_FURNACE)
			{
				((TileEntitySmelter)world.getTileEntity(pos)).setCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}

			else if(down == Blocks.FURNACE)
			{
				((TileEntitySmelter)world.getTileEntity(pos)).stopCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}
			else if (down == ExSartagineBlock.range_extension_lit)
			{
				((TileEntitySmelter)world.getTileEntity(pos)).setCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}
			else if (down == ExSartagineBlock.range_extension)
			{
				((TileEntitySmelter)world.getTileEntity(pos)).stopCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}
		}
	}
}
 
开发者ID:ArtixAllMighty,项目名称:ExSartagine,代码行数:38,代码来源:BlockSmelter.java

示例4: neighborChanged

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos)
{

	if(world.getTileEntity(pos) instanceof TileEntityPan){
		if(fromPos.up().equals(pos)){ //if the block is beneath us
			Block down = world.getBlockState(fromPos).getBlock();

			if(down == Blocks.AIR)
			{
				dropBlockAsItem(world, pos, getDefaultState(), 0);
				world.setBlockToAir(pos);
			}

			else if(down == Blocks.LIT_FURNACE)
			{
				((TileEntityPan)world.getTileEntity(pos)).setCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}

			else if(down == Blocks.FURNACE)
			{
				((TileEntityPan)world.getTileEntity(pos)).stopCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}
			else if (down == ExSartagineBlock.range_extension_lit)
			{
				((TileEntityPan)world.getTileEntity(pos)).setCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}
			else if (down == ExSartagineBlock.range_extension)
			{
				((TileEntityPan)world.getTileEntity(pos)).stopCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}
		}
	}
}
 
开发者ID:ArtixAllMighty,项目名称:ExSartagine,代码行数:39,代码来源:BlockPan.java

示例5: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (world.isRemote) return true;
	TileEntityBarrel barrel = (TileEntityBarrel) world.getTileEntity(pos);
	world.notifyBlockUpdate(pos, state, state, 3);
	ItemStack stack = player.getHeldItem(hand);
	if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
		IFluidHandlerItem itemHandler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
		IFluidHandler barrelHandler = barrel.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
		FluidStack fluidInItem = itemHandler.drain(Fluid.BUCKET_VOLUME, false);
		FluidStack fluidInBarrel = barrelHandler.drain(Fluid.BUCKET_VOLUME, false);
		if ((fluidInBarrel != null && fluidInBarrel.amount > 0) && (fluidInItem == null || fluidInItem.amount == 0 || (fluidInItem.isFluidEqual(fluidInBarrel) && fluidInItem.amount < Fluid.BUCKET_VOLUME))) {
			itemHandler.fill(barrelHandler.drain(Fluid.BUCKET_VOLUME, true), true);
			player.setHeldItem(hand, itemHandler.getContainer());
		} else if (fluidInItem != null && fluidInItem.amount > 0 && fluidInItem.getFluid() != null && (fluidInBarrel == null || fluidInBarrel.amount == 0 || (fluidInBarrel.amount < Fluid.BUCKET_VOLUME && fluidInBarrel.isFluidEqual(fluidInItem)))) {
			FluidStack fsin = itemHandler.drain(Fluid.BUCKET_VOLUME, true);
			if (fsin != null && fsin.amount > 0 && fsin.getFluid() != null) {
				barrelHandler.fill(fsin, true);
				player.setHeldItem(hand, itemHandler.getContainer());
				player.inventory.markDirty();
			}
		}
		return true;
	}

	player.openGui(Bewitchment.instance, LibGui.BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
	return true;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:29,代码来源:BlockBarrel.java

示例6: notifyAround

import net.minecraft.world.World; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void notifyAround(BlockPos pos, World world) {
	for (int dx = -1; dx <= 1; dx++)
		for (int dy = -1; dy <= 1; dy++) {
			BlockPos bp = pos.add(dx, 0, dy);
			if (world.getBlockState(bp).getBlock().equals(ModBlocks.witch_altar))
				world.notifyBlockUpdate(bp, world.getBlockState(bp), world.getBlockState(bp).getBlock().getActualState(world.getBlockState(bp), world, bp), 11);
		}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:10,代码来源:BlockWitchAltar.java

示例7: randomTick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
       if (state.getBlock() == this){
       	if (state.getValue(CLIPPED)){
       		worldIn.setBlockState(pos, state.withProperty(CLIPPED, false));
       		worldIn.notifyBlockUpdate(pos, state, state.withProperty(CLIPPED, false), 8);
       	}
       }
}
 
开发者ID:elucent,项目名称:SimplyTea,代码行数:11,代码来源:SimplyTea.java

示例8: onBlockPlacedBy

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase living, ItemStack stack)
{
    EnumFacing facing = living.getHorizontalFacing().getOpposite();

    TileEntity te = world.getTileEntity(pos);
    if (te != null && te instanceof TileEntityIronFurnace)
    {
        ((TileEntityIronFurnace) te).setFacing((byte) facing.ordinal());
        world.notifyBlockUpdate(pos, state, state, 3);
    }
}
 
开发者ID:cubex2,项目名称:morefurnaces,代码行数:13,代码来源:BlockMoreFurnaces.java

示例9: onItemUseFirst

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {

	if (!world.isRemote) {

		ItemStack held = player.getHeldItem(hand);

		if (player.isSneaking())
			return EnumActionResult.PASS;

		if (held != ItemStack.EMPTY && held.getItem() instanceof ItemUpgrade) {

			if (held.getMetadata() == 0) {

				IBlockState state = world.getBlockState(pos);
				if (state.getBlock() instanceof BlockDisplacer)
					if (!state.getValue(BlockDisplacer.FILTER)) {
						state = state.withProperty(BlockDisplacer.FILTER, true);

						if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileDisplacer) {
							if (!((TileDisplacer) world.getTileEntity(pos)).hasFilter()) {
								((TileDisplacer) world.getTileEntity(pos)).setHasFilter(true);
								((TileDisplacer) world.getTileEntity(pos)).markDirty();

								PacketHandler.sendToAll(new PacketDisplacerSync(((TileDisplacer) world.getTileEntity(pos)), true));
							}
						}
					}
				world.setBlockState(pos, state, 3);
				world.notifyBlockUpdate(pos, state, state, 3);

				if (!player.isCreative())
					player.getHeldItem(hand).splitStack(1);
			}
			return EnumActionResult.SUCCESS;
		}
	}

	return EnumActionResult.PASS;
}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:41,代码来源:ItemUpgrade.java

示例10: restoreToLocation

import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean restoreToLocation(World world, BlockPos pos, boolean force, boolean applyPhysics)
{
    IBlockState current = getCurrentBlock();
    IBlockState replaced = getReplacedBlock();
    if (current.getBlock() != replaced.getBlock() || current.getBlock().getMetaFromState(current) != replaced.getBlock().getMetaFromState(replaced))
    {
        if (force)
        {
            world.setBlockState(pos, replaced, applyPhysics ? 3 : 2);
        }
        else
        {
            return false;
        }
    }

    world.setBlockState(pos, replaced, applyPhysics ? 3 : 2);
    world.notifyBlockUpdate(pos, current, replaced, applyPhysics ? 3 : 2);
    TileEntity te = null;
    if (getNbt() != null)
    {
        te = world.getTileEntity(pos);
        if (te != null)
        {
            te.readFromNBT(getNbt());
            te.markDirty();
        }
    }

    if (DEBUG)
    {
        System.out.printf("Restored BlockSnapshot with data [World: %s ][Location: %d,%d,%d ][Meta: %d ][Block: %s ][TileEntity: %s ][force: %s ][applyPhysics: %s]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), replaced.getBlock().getMetaFromState(replaced), replaced.getBlock().delegate.name(), te, force, applyPhysics);
    }
    return true;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:36,代码来源:BlockSnapshot.java

示例11: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (heldItem != null && heldItem.getItem() instanceof ItemBlock)
    {
        TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);

        if (tileentityflowerpot == null)
        {
            return false;
        }
        else if (tileentityflowerpot.getFlowerPotItem() != null)
        {
            return false;
        }
        else
        {
            Block block = Block.getBlockFromItem(heldItem.getItem());

            if (!this.canContain(block, heldItem.getMetadata()))
            {
                return false;
            }
            else
            {
                tileentityflowerpot.setFlowerPotData(heldItem.getItem(), heldItem.getMetadata());
                tileentityflowerpot.markDirty();
                worldIn.notifyBlockUpdate(pos, state, state, 3);
                playerIn.addStat(StatList.FLOWER_POTTED);

                if (!playerIn.capabilities.isCreativeMode)
                {
                    --heldItem.stackSize;
                }

                return true;
            }
        }
    }
    else
    {
        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:44,代码来源:BlockFlowerPot.java

示例12: execute

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 4)
    {
        throw new WrongUsageException("commands.blockdata.usage", new Object[0]);
    }
    else
    {
        sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 0);
        BlockPos blockpos = parseBlockPos(sender, args, 0, false);
        World world = sender.getEntityWorld();

        if (!world.isBlockLoaded(blockpos))
        {
            throw new CommandException("commands.blockdata.outOfWorld", new Object[0]);
        }
        else
        {
            IBlockState iblockstate = world.getBlockState(blockpos);
            TileEntity tileentity = world.getTileEntity(blockpos);

            if (tileentity == null)
            {
                throw new CommandException("commands.blockdata.notValid", new Object[0]);
            }
            else
            {
                NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
                NBTTagCompound nbttagcompound1 = nbttagcompound.copy();
                NBTTagCompound nbttagcompound2;

                try
                {
                    nbttagcompound2 = JsonToNBT.getTagFromJson(getChatComponentFromNthArg(sender, args, 3).getUnformattedText());
                }
                catch (NBTException nbtexception)
                {
                    throw new CommandException("commands.blockdata.tagError", new Object[] {nbtexception.getMessage()});
                }

                nbttagcompound.merge(nbttagcompound2);
                nbttagcompound.setInteger("x", blockpos.getX());
                nbttagcompound.setInteger("y", blockpos.getY());
                nbttagcompound.setInteger("z", blockpos.getZ());

                if (nbttagcompound.equals(nbttagcompound1))
                {
                    throw new CommandException("commands.blockdata.failed", new Object[] {nbttagcompound.toString()});
                }
                else
                {
                    tileentity.readFromNBT(nbttagcompound);
                    tileentity.markDirty();
                    world.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 3);
                    sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 1);
                    notifyCommandListener(sender, this, "commands.blockdata.success", new Object[] {nbttagcompound.toString()});
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:65,代码来源:CommandBlockData.java

示例13: neighborChanged

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos)
{

	if(world.getTileEntity(pos) instanceof TileEntityPot){
		if(fromPos.up().equals(pos)){ //if the block is beneath us
			Block down = world.getBlockState(fromPos).getBlock();
			if(down == Blocks.AIR)
			{
				dropBlockAsItem(world, pos, getDefaultState(), 0);
				world.setBlockToAir(pos);
			}

			else if(down == Blocks.LIT_FURNACE)
			{
				if(((TileEntityPot)world.getTileEntity(pos)).getWaterLevel() > 0)
				{
					((TileEntityPot)world.getTileEntity(pos)).setCooking();
					world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
				}
			}

			else if(down == Blocks.FURNACE)
			{
				if(((TileEntityPot)world.getTileEntity(pos)).getWaterLevel() > 0)
				{
					((TileEntityPot)world.getTileEntity(pos)).stopCooking();
					world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
				}
			}
			else if (down == ExSartagineBlock.range_extension_lit)
			{
				((TileEntityPot)world.getTileEntity(pos)).setCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}
			else if (down == ExSartagineBlock.range_extension)
			{
				((TileEntityPot)world.getTileEntity(pos)).stopCooking();
				world.notifyBlockUpdate(pos, state, getDefaultState(), 3);
			}
		}
	}
}
 
开发者ID:ArtixAllMighty,项目名称:ExSartagine,代码行数:44,代码来源:BlockPot.java

示例14: onItemUse

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return EnumActionResult.SUCCESS;
    }
    else if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);

        if (iblockstate.getBlock() == Blocks.MOB_SPAWNER)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityMobSpawner)
            {
                MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
                mobspawnerbaselogic.setEntityName(getEntityIdFromItem(stack));
                tileentity.markDirty();
                worldIn.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);

                if (!playerIn.capabilities.isCreativeMode)
                {
                    --stack.stackSize;
                }

                return EnumActionResult.SUCCESS;
            }
        }

        pos = pos.offset(facing);
        double d0 = 0.0D;

        if (facing == EnumFacing.UP && iblockstate.getBlock() instanceof BlockFence) //Forge: Fix Vanilla bug comparing state instead of block
        {
            d0 = 0.5D;
        }

        Entity entity = spawnCreature(worldIn, getEntityIdFromItem(stack), (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);

        if (entity != null)
        {
            if (entity instanceof EntityLivingBase && stack.hasDisplayName())
            {
                entity.setCustomNameTag(stack.getDisplayName());
            }

            applyItemEntityDataToEntity(worldIn, playerIn, stack, entity);

            if (!playerIn.capabilities.isCreativeMode)
            {
                --stack.stackSize;
            }
        }

        return EnumActionResult.SUCCESS;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:66,代码来源:ItemMonsterPlacer.java

示例15: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    ItemStack itemstack = playerIn.getHeldItem(hand);
    TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);

    if (tileentityflowerpot == null)
    {
        return false;
    }
    else
    {
        ItemStack itemstack1 = tileentityflowerpot.getFlowerItemStack();

        if (itemstack1.func_190926_b())
        {
            if (!this.func_190951_a(itemstack))
            {
                return false;
            }

            tileentityflowerpot.func_190614_a(itemstack);
            playerIn.addStat(StatList.FLOWER_POTTED);

            if (!playerIn.capabilities.isCreativeMode)
            {
                itemstack.func_190918_g(1);
            }
        }
        else
        {
            if (itemstack.func_190926_b())
            {
                playerIn.setHeldItem(hand, itemstack1);
            }
            else if (!playerIn.func_191521_c(itemstack1))
            {
                playerIn.dropItem(itemstack1, false);
            }

            tileentityflowerpot.func_190614_a(ItemStack.field_190927_a);
        }

        tileentityflowerpot.markDirty();
        worldIn.notifyBlockUpdate(pos, state, state, 3);
        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:48,代码来源:BlockFlowerPot.java


注:本文中的net.minecraft.world.World.notifyBlockUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。