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


Java TileEntity.markDirty方法代码示例

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


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

示例1: pushEnergy

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
protected boolean pushEnergy() {
    boolean pushed = false;
    for(AccumulatorInfo info : accumulatorInfos) {
        if(info.getIoInfo() == AccumulatorInfo.AccumulatorIOInfo.OUTPUT) {
            EnumFacing dir = info.getFacing();
            TileEntity tile = world.getTileEntity(getPos().offset(dir));
            if(tile != null)
                if(tile.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, dir.getOpposite())) {
                    BaseTeslaContainer cont = (BaseTeslaContainer) tile.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, dir.getOpposite());
                    container.takePower(cont.givePower(container.takePower(container.getOutputRate(), true), false), false);
                    if(!world.isRemote) {
                        tile.markDirty();
                        markDirty();
                        pushed = true;
                    }
                }
        }
    }
    return pushed;
}
 
开发者ID:jaredlll08,项目名称:Machines-and-Stuff,代码行数:21,代码来源:TileEntityAccumulator.java

示例2: neighborChanged

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
    TileEntity t = world.getTileEntity(pos);
    if (t instanceof TileEntityEmberBurst) {
        ((TileEntityEmberBurst) t).updateNeighbors(world);
        t.markDirty();
    }
    if (world.isAirBlock(pos.offset(state.getValue(facing), -1))) {
        world.setBlockToAir(pos);
        this.dropBlockAsItem(world, pos, state, 0);
    }
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:13,代码来源:BlockEmberBurst.java

示例3: execute

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
@Override
public void execute(Side side, EntityPlayer player)
{
    TileEntity te = player.getEntityWorld().getTileEntity(pos);
    if(te instanceof TileEntityGlassMaster && !((TileEntityGlassMaster)te).active)
    {
        ((TileEntityGlassMaster)te).wirelessPos = channel;
        te.markDirty();

        IBlockState state = player.getEntityWorld().getBlockState(pos);
        player.getEntityWorld().notifyBlockUpdate(pos, state, state, 3);
    }
}
 
开发者ID:iChun,项目名称:GeneralLaymansAestheticSpyingScreen,代码行数:14,代码来源:PacketWirelessOrder.java

示例4: execute

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
@Override
public void execute(Side side, EntityPlayer player)
{
    TileEntity te = player.getEntityWorld().getTileEntity(masterPos);
    if(player.getEntityWorld().getTileEntity(wirelessPos) instanceof TileEntityGlassWireless && te instanceof TileEntityGlassMaster)
    {
        ((TileEntityGlassMaster)te).wirelessPos.add(wirelessPos);
        te.markDirty();

        IBlockState state = player.getEntityWorld().getBlockState(masterPos);
        player.getEntityWorld().notifyBlockUpdate(masterPos, state, state, 3);
    }
}
 
开发者ID:iChun,项目名称:GeneralLaymansAestheticSpyingScreen,代码行数:14,代码来源:PacketSetProjector.java

示例5: placeDownBlock

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
public void placeDownBlock(BlockPos pos) {
    // @todo what if this fails?
    IBlockState state = getHeldBlockState();
    if (state == null) {
        return;
    }
    if (state.getBlock() == ModBlocks.heldCubeBlock) {
        return;
    }

    world.setBlockState(pos, state, 3);
    NBTTagCompound tc = getCarriedNBT();
    if (tc != null) {
        tc.setInteger("x", pos.getX());
        tc.setInteger("y", pos.getY());
        tc.setInteger("z", pos.getZ());
        TileEntity tileEntity = TileEntity.create(world, tc);
        if (tileEntity != null) {
            world.getChunkFromBlockCoords(pos).addTileEntity(tileEntity);
            tileEntity.markDirty();
            world.notifyBlockUpdate(pos, state, state, 3);
        }
    }

    carriedNBT = null;
    setHeldBlockState(null);
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:28,代码来源:EntityMeeCreeps.java

示例6: pushEnergy

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
protected boolean pushEnergy() {
    boolean pushed = false;
    TileEntity tile = world.getTileEntity(getPos().offset(EnumFacing.DOWN));
    if(tile != null)
        if(tile.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, EnumFacing.UP) || tile.hasCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.UP)) {
            BaseTeslaContainer cont = (BaseTeslaContainer) tile.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.UP);
            container.takePower(cont.givePower(container.takePower(container.getOutputRate(), true), false), false);
            if(!world.isRemote) {
                tile.markDirty();
                markDirty();
                pushed = true;
            }
        }
    return pushed;
}
 
开发者ID:jaredlll08,项目名称:Machines-and-Stuff,代码行数:16,代码来源:TileEntityCrank.java

示例7: restore

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
public boolean restore(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)
        {
            getWorld().setBlockState(getPos(), replaced, applyPhysics ? 3 : 2);
        }
        else
        {
            return false;
        }
    }

    getWorld().setBlockState(getPos(), replaced, applyPhysics ? 3 : 2);
    getWorld().notifyBlockUpdate(getPos(), current, replaced, applyPhysics ? 3 : 2);
    TileEntity te = null;
    if (getNbt() != null)
    {
        te = getWorld().getTileEntity(getPos());
        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]", getWorld().getWorldInfo().getWorldName(), getPos().getX(), getPos().getY(), getPos().getZ(), replaced.getBlock().getMetaFromState(replaced), replaced.getBlock().delegate.name(), te, force, applyPhysics);
    }
    return true;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:36,代码来源:BlockSnapshot.java

示例8: execute

import net.minecraft.tileentity.TileEntity; //导入方法依赖的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:F1r3w477,项目名称:CustomWorldGen,代码行数:65,代码来源:CommandBlockData.java

示例9: onBlockActivated

import net.minecraft.tileentity.TileEntity; //导入方法依赖的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;
	}
	TileEntity te = world.getTileEntity(pos);
	if (!(te instanceof TileEntityWritingDesk))
	{
		return false;
	}

	ItemStack stack = player.getHeldItem(hand);

	int slot = 0;
	IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

	if (stack != null && !stack.isEmpty() && !player.isSneaking())
	{
		ItemStack insertStack = stack.copy();
		ItemStack remain = cap.insertItem(slot, insertStack, false);
		if (remain.getCount() != insertStack.getCount())
		{
			if (!world.isRemote)
			{
				player.setHeldItem(hand, remain);
				te.markDirty();
			} else
			{
				world.playSound(player, pos, SoundEvents.ENTITY_ITEMFRAME_ADD_ITEM, SoundCategory.BLOCKS, 1, 1);
			}
		}

	} else if (player.isSneaking())
	{
		ItemStack toExtract = cap.getStackInSlot(slot);
		if (toExtract != null && !toExtract.isEmpty())
		{
			if (!world.isRemote)
			{
				if (player.addItemStackToInventory(toExtract.copy()))
				{
					cap.getStackInSlot(slot).setCount(0);
					te.markDirty();
				}
			} else
			{
				world.playSound(player, pos, SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, SoundCategory.BLOCKS, 1, 1);
			}
		}
	}

	return true;
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:57,代码来源:BlockWritingDesk.java

示例10: processCommand

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(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
        {
            TileEntity tileentity = world.getTileEntity(blockpos);

            if (tileentity == null)
            {
                throw new CommandException("commands.blockdata.notValid", new Object[0]);
            }
            else
            {
                NBTTagCompound nbttagcompound = new NBTTagCompound();
                tileentity.writeToNBT(nbttagcompound);
                NBTTagCompound nbttagcompound1 = (NBTTagCompound)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.markBlockForUpdate(blockpos);
                    sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 1);
                    notifyOperators(sender, this, "commands.blockdata.success", new Object[] {nbttagcompound.toString()});
                }
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:65,代码来源:CommandBlockData.java

示例11: setTileEntityNBT

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
public static boolean setTileEntityNBT(World worldIn, EntityPlayer pos, BlockPos stack, ItemStack p_179224_3_)
{
    MinecraftServer minecraftserver = MinecraftServer.getServer();

    if (minecraftserver == null)
    {
        return false;
    }
    else
    {
        if (p_179224_3_.hasTagCompound() && p_179224_3_.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            TileEntity tileentity = worldIn.getTileEntity(stack);

            if (tileentity != null)
            {
                if (!worldIn.isRemote && tileentity.func_183000_F() && !minecraftserver.getConfigurationManager().canSendCommands(pos.getGameProfile()))
                {
                    return false;
                }

                NBTTagCompound nbttagcompound = new NBTTagCompound();
                NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttagcompound.copy();
                tileentity.writeToNBT(nbttagcompound);
                NBTTagCompound nbttagcompound2 = (NBTTagCompound)p_179224_3_.getTagCompound().getTag("BlockEntityTag");
                nbttagcompound.merge(nbttagcompound2);
                nbttagcompound.setInteger("x", stack.getX());
                nbttagcompound.setInteger("y", stack.getY());
                nbttagcompound.setInteger("z", stack.getZ());

                if (!nbttagcompound.equals(nbttagcompound1))
                {
                    tileentity.readFromNBT(nbttagcompound);
                    tileentity.markDirty();
                    return true;
                }
            }
        }

        return false;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:43,代码来源:ItemBlock.java

示例12: onItemUse

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    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(EntityList.getStringFromID(stack.getMetadata()));
                tileentity.markDirty();
                worldIn.markBlockForUpdate(pos);

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

                return true;
            }
        }

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

        if (side == EnumFacing.UP && iblockstate instanceof BlockFence)
        {
            d0 = 0.5D;
        }

        Entity entity = spawnCreature(worldIn, stack.getMetadata(), (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());
            }

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

        return true;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:64,代码来源:ItemMonsterPlacer.java

示例13: setTileEntityNBT

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
public static boolean setTileEntityNBT(World worldIn, @Nullable EntityPlayer player, BlockPos pos, ItemStack stackIn)
{
    MinecraftServer minecraftserver = worldIn.getMinecraftServer();

    if (minecraftserver == null)
    {
        return false;
    }
    else
    {
        NBTTagCompound nbttagcompound = stackIn.getSubCompound("BlockEntityTag");

        if (nbttagcompound != null)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity != null)
            {
                if (!worldIn.isRemote && tileentity.onlyOpsCanSetNbt() && (player == null || !player.canUseCommandBlock()))
                {
                    return false;
                }

                NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
                NBTTagCompound nbttagcompound2 = nbttagcompound1.copy();
                nbttagcompound1.merge(nbttagcompound);
                nbttagcompound1.setInteger("x", pos.getX());
                nbttagcompound1.setInteger("y", pos.getY());
                nbttagcompound1.setInteger("z", pos.getZ());

                if (!nbttagcompound1.equals(nbttagcompound2))
                {
                    tileentity.readFromNBT(nbttagcompound1);
                    tileentity.markDirty();
                    return true;
                }
            }
        }

        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:43,代码来源:ItemBlock.java

示例14: placeBlock

import net.minecraft.tileentity.TileEntity; //导入方法依赖的package包/类
public boolean placeBlock(BlockPos blockpos) {
	Block block = this.block.getBlock();
	IBlockState prevstate=this.world.getBlockState(blockpos);
	if (!this.isBreakingAnvil
			&& this.world.mayPlace(block, blockpos, true, EnumFacing.UP, (Entity) null)
			&& (!BlockFalling.canFallThrough(this.world.getBlockState(blockpos.offset(EnumFacing.DOWN)))
					|| (this.sticky == 1 && this.canBuildAt(blockpos)) || this.nogravity)
			&& this.world.setBlockState(blockpos, this.block, 3)) {
		if (this.isFired)
			for (int a = 0; a < 6; a++) {
				EnumFacing facing = EnumFacing.VALUES[a];
				BlockPos firepos = new BlockPos(blockpos.getX() + facing.getFrontOffsetX(),
						blockpos.getY() + facing.getFrontOffsetY(), blockpos.getZ() + facing.getFrontOffsetZ());
				if (this.world.getBlockState(firepos).getBlock().isReplaceable(world, firepos))
					this.world.setBlockState(firepos, this.fireBlock.getDefaultState());
			}
		if (block instanceof BlockFalling)
			((BlockFalling) block).onEndFalling(this.world, blockpos, this.block, prevstate);

		if (this.dataTag != null && block instanceof ITileEntityProvider) {
			TileEntity tileentity = this.world.getTileEntity(blockpos);

			if (tileentity != null) {
				NBTTagCompound nbttagcompound = new NBTTagCompound();
				tileentity.writeToNBT(nbttagcompound);
				Iterator iterator = this.dataTag.getKeySet().iterator();

				while (iterator.hasNext()) {
					String s = (String) iterator.next();
					NBTBase nbtbase = this.dataTag.getTag(s);

					if (!s.equals("x") && !s.equals("y") && !s.equals("z"))
						nbttagcompound.setTag(s, nbtbase.copy());
				}

				tileentity.readFromNBT(nbttagcompound);
				tileentity.markDirty();
			}
		}
		return true;
	}
	return false;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:44,代码来源:EntityFallingEnchantedBlock.java


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