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


Java World.getTileEntity方法代码示例

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


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

示例1: 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;
	}
	TileEntity te = world.getTileEntity(pos);
	if (!(te instanceof TileEntityAnimusMaterializer))
	{
		return false;
	}
	player.openGui(ArcaneMagic.instance, GUI_ID, world, pos.getX(), pos.getY(), pos.getZ());
	return true;
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:17,代码来源:BlockAnimusMaterializer.java

示例2: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
	if (worldIn.isRemote) {
		return false;
	}
	if (this.hasTileEntity(this.getDefaultState())) {
		ItemStack stack = playerIn.getHeldItem(hand);
		if (!stack.isEmpty()) {
			System.out.println("yep");
			if (stack.getItem() == Items.BUCKET && !stack.isEmpty()) {
				stack.shrink(1);
				TileEntity te = worldIn.getTileEntity(pos);
				if (te instanceof TileEntityTreeTap) {
					((TileEntityTreeTap) te).hasBucket = true;
					worldIn.setBlockState(pos, worldIn.getBlockState(pos).withProperty(HASBUCKET, true), 3);
					return true;
				}
			}
		}

	}
	return false;
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:Got-Wood,代码行数:25,代码来源:BlockTreeTap.java

示例3: onBlockPlacedBy

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

    if (stack.hasDisplayName())
    {
        TileEntity teBase = world.getTileEntity(pos);
        if (teBase instanceof TileEntitySpecializedFurnace)
        {
            TileEntitySpecializedFurnace tileEntity = (TileEntitySpecializedFurnace)teBase;
            tileEntity.setBlockName(stack.getDisplayName());
        }
    }
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:17,代码来源:BlockSpecializedFurnace.java

示例4: 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)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityFurnace)
        {
            playerIn.displayGUIChest((TileEntityFurnace)tileentity);
            playerIn.addStat(StatList.FURNACE_INTERACTION);
        }

        return true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:BlockFurnace.java

示例5: randomDisplayTick

import net.minecraft.world.World; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
	double d0 = (double)pos.getX() + 0.5D;
	double d1 = (double)pos.getY() + 0.75D;
	double d2 = (double)pos.getZ() + 0.5D;
	double d3 = 0.22D;
	double d4 = 0.27D;

	if(worldIn.getTileEntity(pos) instanceof TileEntitySmelter)
	{
		if(((TileEntitySmelter)worldIn.getTileEntity(pos)).isCooking() && !((TileEntitySmelter)worldIn.getTileEntity(pos)).getInventory().getStackInSlot(0).isEmpty())
		{
			for(int i = 0; i < 25; i++)
			{
				worldIn.spawnParticle(EnumParticleTypes.FLAME, d0+(RANDOM.nextDouble()/5 - 0.1), d1, d2+(RANDOM.nextDouble()/5 - 0.1), 0.0D, 0.0D, 0.0D, new int[0]);
				worldIn.spawnParticle(EnumParticleTypes.FLAME, d0+(RANDOM.nextDouble()/5 - 0.1), d1, d2+(RANDOM.nextDouble()/5 - 0.1), 0.0D, 0.02D, 0.0D, new int[0]);

				worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0+(RANDOM.nextDouble()/5 - 0.1), d1, d2+(RANDOM.nextDouble()/5 - 0.1), 0.0D, 0.0D, 0.0D, new int[0]);
			}
			worldIn.spawnParticle(EnumParticleTypes.FLAME, d0+(RANDOM.nextDouble()/5 - 0.1), d1, d2+(RANDOM.nextDouble()/5 - 0.1), 0.0D, 0.05D, 0.0D, new int[0]);
		}
	}
}
 
开发者ID:ArtixAllMighty,项目名称:ExSartagine,代码行数:25,代码来源:BlockSmelter.java

示例6: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9) {
    if (player.isSneaking()) return false;
    else {
        if (!world.isRemote) {
            TileEntitySecurityStation te = (TileEntitySecurityStation) world.getTileEntity(pos);
            if (te != null) {
                if (te.isPlayerOnWhiteList(player)) {
                    player.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.SECURITY_STATION_INVENTORY.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
                } else if (!te.hasValidNetwork()) {
                    player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "This Security Station is out of order: Its network hasn't been properly configured."), false);
                } else if (te.hasPlayerHacked(player)) {
                    player.sendStatusMessage(new TextComponentString(TextFormatting.GREEN + "You've already hacked this Security Station!"), false);
                } else if (getPlayerHackLevel(player) < te.getSecurityLevel()) {
                    player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "You can't access or hack this Security Station. To hack it you need at least a Pneumatic Helmet upgraded with " + te.getSecurityLevel() + " Security upgrade(s)."), false);
                } else {
                    player.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.HACKING.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
                }
            }
        }
        return true;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:24,代码来源:BlockSecurityStation.java

示例7: breakBlock

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
	// System.out.println("123");
	if (!worldIn.isRemote) {
		TileEntityPictureFrame te = (TileEntityPictureFrame) worldIn.getTileEntity(pos);
		if (!te.imagename.equals("")) {
			ItemStack picture = new ItemStack(ItemLoader.itemPicture);
			NBTTagCompound nbt = new NBTTagCompound();
			nbt.setString("pid", te.imagename);
			picture.setTagCompound(nbt);
			// worldIn.spawnEntityInWorld(new EntityItem(worldIn,
			// pos.getX(), pos.getY(), pos.getZ(), picture));
			Block.spawnAsEntity(worldIn, pos, picture);
		}
	}
	super.breakBlock(worldIn, pos, state);

}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:19,代码来源:BlockPictureFrame.java

示例8: fromBytes

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void fromBytes(ByteBuf buf) {
	int dim = buf.readInt();
	BlockPos pos = BlockPos.fromLong(buf.readLong());

	World world = SimpleTubes.proxy.getWorld(dim);
	this.tile = world.getTileEntity(pos);

	this.id = buf.readInt();
	this.stack = ByteBufUtils.readItemStack(buf);
	this.progress = buf.readFloat();
	this.direction = buf.readByte();
	this.color = buf.readInt();
}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:15,代码来源:PacketItemAdd.java

示例9: dispenseStack

import net.minecraft.world.World; //导入方法依赖的package包/类
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    Block block = Block.getBlockFromItem(stack.getItem());
    World world = source.getWorld();
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    this.field_190911_b = world.func_190527_a(block, blockpos, false, EnumFacing.DOWN, (Entity)null);

    if (this.field_190911_b)
    {
        EnumFacing enumfacing1 = world.isAirBlock(blockpos.down()) ? enumfacing : EnumFacing.UP;
        IBlockState iblockstate = block.getDefaultState().withProperty(BlockShulkerBox.field_190957_a, enumfacing1);
        world.setBlockState(blockpos, iblockstate);
        TileEntity tileentity = world.getTileEntity(blockpos);
        ItemStack itemstack = stack.splitStack(1);

        if (itemstack.hasTagCompound())
        {
            ((TileEntityShulkerBox)tileentity).func_190586_e(itemstack.getTagCompound().getCompoundTag("BlockEntityTag"));
        }

        if (itemstack.hasDisplayName())
        {
            ((TileEntityShulkerBox)tileentity).func_190575_a(itemstack.getDisplayName());
        }

        world.updateComparatorOutputLevel(blockpos, iblockstate.getBlock());
    }

    return stack;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:32,代码来源:Bootstrap.java

示例10: neighborChanged

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    super.neighborChanged(state, worldIn, pos, blockIn);
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof TileEntityChest)
    {
        tileentity.updateContainingBlockInfo();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:16,代码来源:BlockChest.java

示例11: insertRecord

import net.minecraft.world.World; //导入方法依赖的package包/类
public void insertRecord(World worldIn, BlockPos pos, IBlockState state, ItemStack recordStack)
{
    if (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof BlockJukebox.TileEntityJukebox)
        {
            ((BlockJukebox.TileEntityJukebox)tileentity).setRecord(recordStack.copy());
            worldIn.setBlockState(pos, state.withProperty(HAS_RECORD, Boolean.valueOf(true)), 2);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:14,代码来源:BlockJukebox.java

示例12: updateTick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
	super.updateTick(worldIn, pos, state, rand);
	if (worldIn.getTileEntity(pos) != null && worldIn.getTileEntity(pos).hasCapability(ExPFarmlandCapability.farmlandCap, EnumFacing.UP))
	{
		IFarmland.of(worldIn.getTileEntity(pos)).onWorldTick();
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:10,代码来源:BlockFarmland.java

示例13: breakBlock

import net.minecraft.world.World; //导入方法依赖的package包/类
public void breakBlock(World world, BlockPos pos, IBlockState state) {
	if (!world.isRemote) {
		TileEntity atPos = world.getTileEntity(pos);
		if (atPos != null && atPos instanceof IInventory) {
			InventoryHelper.dropInventoryItems(world, pos, (IInventory) atPos);
		}
	}
}
 
开发者ID:cjburkey01,项目名称:MiningWells,代码行数:9,代码来源:BlockBase.java

示例14: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (worldIn.isRemote) {
        return true;
    }
    TileEntity te = worldIn.getTileEntity(pos);

    if (!(te instanceof TilePersonalCharger)) {
        return false;
    }
    playerIn.openGui(Main.instance, GUI_ID, worldIn, pos.getX(), pos.getY(), pos.getZ());
    return true;
}
 
开发者ID:CreeperShift,项目名称:WirelessCharger,代码行数:14,代码来源:BlockPersonalCharger.java

示例15: onBlockPlacedBy

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);

    if (stack.hasDisplayName())
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityBeacon)
        {
            ((TileEntityBeacon)tileentity).setName(stack.getDisplayName());
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:BlockBeacon.java


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