net.minecraft.world.World.getTileEntity()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(275)

本文整理了Java中net.minecraft.world.World.getTileEntity()方法的一些代码示例,展示了World.getTileEntity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.getTileEntity()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:getTileEntity

World.getTileEntity介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

  1. @Override
  2. public boolean clearContainerBlockContents(BlockVector3 position) {
  3. checkNotNull(position);
  4. TileEntity tile = getWorld().getTileEntity(ForgeAdapter.toBlockPos(position));
  5. if ((tile instanceof IInventory)) {
  6. IInventory inv = (IInventory) tile;
  7. int size = inv.getSizeInventory();
  8. for (int i = 0; i < size; i++) {
  9. inv.setInventorySlotContents(i, ItemStack.EMPTY);
  10. }
  11. return true;
  12. }
  13. return false;
  14. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
  3. TileRuneAltar altar = (TileRuneAltar) world.getTileEntity(pos);
  4. return altar.signal;
  5. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, BlockPos pos, EnumFacing side) {
  3. TileHourglass tile = (TileHourglass) world.getTileEntity(pos);
  4. tile.lock = !tile.lock;
  5. return false;
  6. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
  3. TileBrewery brew = (TileBrewery) world.getTileEntity(pos);
  4. return brew.signal;
  5. }

代码示例来源:origin: EngineHub/WorldEdit

  1. @Override
  2. public BaseBlock getFullBlock(BlockVector3 position) {
  3. BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
  4. TileEntity tile = getWorld().getTileEntity(pos);
  5. if (tile != null) {
  6. return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile)));
  7. } else {
  8. return getBlock(position).toBaseBlock();
  9. }
  10. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) {
  3. TileEntity tile = world.getTileEntity(pos);
  4. if(tile != null && tile instanceof TilePrism)
  5. ((TilePrism) tile).onBurstCollision(burst);
  6. }

代码示例来源:origin: Vazkii/Botania

  1. @Nonnull
  2. @Override
  3. public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) {
  4. String name = ((TileSpecialFlower) world.getTileEntity(pos)).subTileName;
  5. return ItemBlockSpecialFlower.ofType(name);
  6. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) {
  3. TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos);
  4. InventoryHelper.dropInventory(inv, world, state, pos);
  5. super.breakBlock(world, pos, state);
  6. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) {
  3. TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos);
  4. InventoryHelper.dropInventory(inv, world, state, pos);
  5. super.breakBlock(world, pos, state);
  6. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void fillWithRain(World world, BlockPos pos) {
  3. if(world.rand.nextInt(20) == 1) {
  4. TileEntity tile = world.getTileEntity(pos);
  5. if(tile instanceof TileAltar) {
  6. TileAltar altar = (TileAltar) tile;
  7. if(!altar.hasLava && !altar.hasWater)
  8. altar.setWater(true);
  9. world.updateComparatorOutputLevel(pos, this);
  10. }
  11. }
  12. }

代码示例来源:origin: Vazkii/Botania

  1. @SideOnly(Side.CLIENT)
  2. @Override
  3. public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos) {
  4. ((TileBrewery) world.getTileEntity(pos)).renderHUD(mc, res);
  5. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) {
  3. if(!world.isRemote) {
  4. TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos);
  5. cube.doRequest(player.isSneaking());
  6. }
  7. }

代码示例来源:origin: Vazkii/Botania

  1. int getCellGeneration(BlockPos pos) {
  2. TileEntity tile = supertile.getWorld().getTileEntity(pos);
  3. if(tile instanceof TileCell)
  4. return ((TileCell) tile).isSameFlower(supertile) ? ((TileCell) tile).getGeneration() : 0;
  5. return -1;
  6. }

代码示例来源:origin: Vazkii/Botania

  1. public static boolean isValidBubbell(World world, BlockPos pos) {
  2. TileEntity tile = world.getTileEntity(pos);
  3. if(tile != null && tile instanceof ISubTileContainer) {
  4. ISubTileContainer container = (ISubTileContainer) tile;
  5. if(container.getSubTile() != null && container.getSubTile() instanceof SubTileBubbell) {
  6. SubTileBubbell bubbell = (SubTileBubbell) container.getSubTile();
  7. return bubbell.mana > COST_PER_TICK;
  8. }
  9. }
  10. return false;
  11. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public ISparkAttachable getAttachedTile() {
  3. int x = MathHelper.floor(posX);
  4. int y = MathHelper.floor(posY) - 1;
  5. int z = MathHelper.floor(posZ);
  6. TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
  7. if(tile != null && tile instanceof ISparkAttachable)
  8. return (ISparkAttachable) tile;
  9. return null;
  10. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) {
  3. TileEnchanter enchanter = (TileEnchanter) world.getTileEntity(pos);
  4. if(!enchanter.itemToEnchant.isEmpty()) {
  5. world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), enchanter.itemToEnchant));
  6. }
  7. world.updateComparatorOutputLevel(pos, state.getBlock());
  8. super.breakBlock(world, pos, state);
  9. }

代码示例来源:origin: Vazkii/Botania

  1. public void tickDispenser() {
  2. BlockPos bind = getBinding();
  3. if(bind != null) {
  4. TileEntity tile = world.getTileEntity(bind);
  5. if(tile instanceof TileEntityDispenser)
  6. world.scheduleUpdate(bind, tile.getBlockType(), tile.getBlockType().tickRate(world));
  7. }
  8. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) {
  3. world.setBlockState(pos, state.withProperty(BotaniaStateProps.CARDINALS, par5EntityLiving.getHorizontalFacing().getOpposite()));
  4. if (par6ItemStack.hasDisplayName())
  5. ((TileTinyPotato) world.getTileEntity(pos)).name = par6ItemStack.getDisplayName();
  6. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
  3. boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0;
  4. boolean powered = state.getValue(BotaniaStateProps.POWERED);
  5. if(power && !powered) {
  6. ((TileCorporeaRetainer) world.getTileEntity(pos)).fulfilRequest();
  7. world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, true), 4);
  8. } else if(!power && powered)
  9. world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 4);
  10. }

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
  3. boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0;
  4. boolean powered = state.getValue(BotaniaStateProps.POWERED);
  5. if(power && !powered) {
  6. TileEntity tile = world.getTileEntity(pos);
  7. if(tile != null && tile instanceof TileCacophonium)
  8. ((TileCacophonium) tile).annoyDirewolf();
  9. world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, true), 4);
  10. } else if(!power && powered)
  11. world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 4);
  12. }

相关文章

World类方法