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

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

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

World.setTileEntity介绍

暂无

代码示例

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

/**
 * Set a tile entity at the given location.
 *
 * @param world the world
 * @param position the position
 * @param clazz the tile entity class
 * @param tag the tag for the tile entity (may be null to not set NBT data)
 */
static void setTileEntity(World world, BlockVector3 position, Class<? extends TileEntity> clazz, @Nullable NBTTagCompound tag) {
  checkNotNull(world);
  checkNotNull(position);
  checkNotNull(clazz);
  TileEntity tileEntity = constructTileEntity(world, position, clazz);
  if (tileEntity == null) {
    return;
  }
  if (tag != null) {
    // Set X, Y, Z
    updateForSet(tag, position);
    tileEntity.readFromNBT(tag);
  }
  world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
}

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

/**
 * Set a tile entity at the given location using the tile entity ID from
 * the tag.
 *
 * @param world the world
 * @param position the position
 * @param tag the tag for the tile entity (may be null to do nothing)
 */
static void setTileEntity(World world, BlockVector3 position, @Nullable NBTTagCompound tag) {
  if (tag != null) {
    updateForSet(tag, position);
    TileEntity tileEntity = TileEntity.create(world, tag);
    if (tileEntity != null) {
      world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
    }
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

/**
 * Changes this tile to the TESR version if any of the parts require dynamic rendering.
 */
protected void updateTileSetting()
{
  if( this.getCableBus().isRequiresDynamicRender() )
  {
    try
    {
      final TileCableBus tcb = (TileCableBus) BlockCableBus.getTesrTile().newInstance();
      tcb.copyFrom( this );
      this.getWorld().setTileEntity( this.pos, tcb );
    }
    catch( final Throwable ignored )
    {
    }
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

/**
   * Changes this tile to the non-TESR version, if none of the parts require dynamic rendering.
   */
  @Override
  protected void updateTileSetting()
  {
    if( !this.getCableBus().isRequiresDynamicRender() )
    {
      try
      {
        final TileCableBus tcb = (TileCableBus) BlockCableBus.getNoTesrTile().newInstance();
        tcb.copyFrom( this );
        this.getWorld().setTileEntity( this.pos, tcb );
      }
      catch( final Throwable ignored )
      {

      }
    }
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public void setTileEntity(@Nonnull BlockPos pos, @Nullable TileEntity tileEntityIn) {
 wrapped.setTileEntity(pos, tileEntityIn);
}

代码示例来源:origin: GregTechCE/GregTech

public void apply(World world, BlockPos pos) {
    world.setBlockState(pos, blockState);
    if(tileEntity != null) {
      world.setTileEntity(pos, tileEntity);
    }
  }
}

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

@SubscribeEvent
public void onWorldTick(WorldTickEvent event) {
  if(!delayedUpdates.containsKey(event.world) || event.phase == Phase.START)
    return;
  
  List<Pair<BlockPos, TileEntity>> delays = delayedUpdates.get(event.world);
  if(delays.isEmpty())
    return;
  
  for(Pair<BlockPos, TileEntity> delay : delays) {
    event.world.setTileEntity(delay.getLeft(), delay.getRight());
    delay.getRight().updateContainingBlockInfo();
  }
  
  delays.clear();
}

代码示例来源:origin: TheGreyGhost/MinecraftByExample

@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
 super.onBlockAdded(worldIn, pos, state);
 worldIn.setTileEntity(pos, this.createTileEntity(worldIn, state));
}

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

public void setState(World worldIn, BlockPos pos, IBlockState state, int flag) {
  TileEntity te = worldIn.getTileEntity(pos);
  worldIn.setBlockState(pos, state, flag);
  if(te != null) {
    te.validate();
    worldIn.setTileEntity(pos, te);
    
    if(te instanceof TileCustomChest)
      ((TileCustomChest) te).adjacentChestChecked = false;
  }
}

代码示例来源:origin: amadornes/MCMultiPart

@Override
public void setTileEntity(BlockPos pos, TileEntity tile) {
  if (part.getPartPos().equals(pos)) {
    if (tile.hasCapability(MCMPCapabilities.MULTIPART_TILE, null)) {
      part.setTile(tile.getCapability(MCMPCapabilities.MULTIPART_TILE, null));
    } else {
      throw new IllegalArgumentException("The specified TileEntity is not a multipart!");
    }
  } else {
    getActualWorld().setTileEntity(pos, tile);
  }
}

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

if(tile != null) {
  tile.setPos(pos);
  entity.world.setTileEntity(pos, tile);

代码示例来源:origin: GregTechCE/GregTech

@Override
protected void onActiveModeChange(World world, BlockPos pos, boolean isActiveNow, boolean isInitialChange) {
  TileEntityFluidPipe oldTileEntity = (TileEntityFluidPipe) world.getTileEntity(pos);
  if (!(oldTileEntity instanceof TileEntityFluidPipeActive) && isActiveNow) {
    TileEntityFluidPipeActive newTileEntity = new TileEntityFluidPipeActive();
    newTileEntity.transferDataFrom(oldTileEntity);
    newTileEntity.setActive(true);
    world.setTileEntity(pos, newTileEntity);
  } else if (oldTileEntity instanceof TileEntityFluidPipeActive) {
    ((TileEntityFluidPipeActive) oldTileEntity).setActive(isActiveNow);
  }
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

@Override
public boolean generate(World world, Random random, BlockPos pos) {
  if (isWorldValid(world) && random.nextFloat() < chance && world.setBlockState(pos, MatterOverdrive.BLOCKS.gravitational_anomaly.getDefaultState())) {
    TileEntityGravitationalAnomaly anomaly = new TileEntityGravitationalAnomaly(minMatter + random.nextInt(maxMatter - minMatter));
    world.setTileEntity(pos, anomaly);
    GenPositionWorldData data = MOWorldGen.getWorldPositionData(world);
    data.addPosition(name, new WorldPosition2D(pos.getX(), pos.getZ()));
  }
  return false;
}

代码示例来源:origin: vadis365/TheErebus

public static void setState(World world, BlockPos pos, IBlockState state, boolean powered) {
  if (!world.isRemote) {
    TileEntityLiquifier tile = (TileEntityLiquifier) world.getTileEntity(pos);
    state = state.withProperty(POWERED, powered);
    world.setBlockState(pos, state, 3);
    tile.setActive(powered);
    if (tile != null) {
      tile.validate();
      world.setTileEntity(pos, tile);
    }
  }
}

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

world.setTileEntity(pos_, newTile);

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

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  if(worldIn.getTileEntity(pos) instanceof TileEntityEnchantmentTable)
    worldIn.setTileEntity(pos, createNewTileEntity(worldIn, 0));
  
  playerIn.openGui(Quark.instance, LibGuiIDs.MATRIX_ENCHANTING, worldIn, pos.getX(), pos.getY(), pos.getZ());
  return true;
}

代码示例来源:origin: GregTechCE/GregTech

@Override
public IPipeTile<PipeType, NodeDataType> setSupportsTicking() {
  if(supportsTicking()) {
    return this;
  }
  //create new tickable tile entity, transfer data, and replace it
  IPipeTile<PipeType, NodeDataType> newTile = getPipeBlock().createNewTileEntity(true);
  newTile.transferDataFrom(this);
  getWorld().setTileEntity(getPos(), (TileEntity) newTile);
  return newTile;
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  ItemStack heldItem = playerIn.getHeldItem(hand);
  if (BlockCandle.lightingItems.contains(heldItem.getItem())) {
    IBlockState activatedState = ModuleApiculture.getBlocks().candle.getDefaultState().withProperty(BlockCandle.STATE, BlockCandle.State.ON);
    worldIn.setBlockState(pos, activatedState, Constants.FLAG_BLOCK_SYNC);
    TileCandle tc = new TileCandle();
    tc.setColour(16777215); // default to white
    tc.setLit(true);
    worldIn.setTileEntity(pos, tc);
    return true;
  }
  return false;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

ote.writeToNBT( data );
nte.readFromNBT( data.copy() );
world.setTileEntity( d, nte );

代码示例来源:origin: vadis365/TheErebus

public static void setState(boolean active, World world, BlockPos pos) {
  IBlockState iblockstate = world.getBlockState(pos);
  TileEntity tileentity = world.getTileEntity(pos);
  keepInventory = true;
  if (active)
    world.setBlockState(pos, ModBlocks.UMBER_FURNACE_ACTIVE.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
  else
    world.setBlockState(pos, ModBlocks.UMBER_FURNACE.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
  keepInventory = false;
  if (tileentity != null) {
    tileentity.validate();
    world.setTileEntity(pos, tileentity);
  }
}

相关文章

微信公众号

最新文章

更多

World类方法