net.minecraft.block.Block.createTileEntity()方法的使用及代码示例

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

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

Block.createTileEntity介绍

暂无

代码示例

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

public default IMultipartTile createMultipartTile(World world, IPartSlot slot, IBlockState state) {
  TileEntity tileEntity = state.getBlock().createTileEntity(world, state);
  return tileEntity != null ? convertToMultipartTile(tileEntity) : null;
}

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

@SuppressWarnings("null")
private TileEntity createTileEntity(IBlockState state, @Nonnull BlockPos pos) {
 Block block = state.getBlock();
 if (!block.hasTileEntity(state) || teBlackList.containsKey(block)) {
  return null;
 }
 if (teCache.containsKey(block)) {
  try {
   TileEntity tileEntity = teCache.get(block);
   tileEntity.setPos(pos);
   return tileEntity;
  } catch (Throwable t) {
   teCache.remove(block);
  }
 }
 try {
  TileEntity tileEntity = block.createTileEntity(null, state);
  tileEntity.setPos(pos);
  teCache.put(block, tileEntity);
  return tileEntity;
 } catch (Throwable t) {
  teBlackList.put(block, true);
 }
 return null;
}

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

@Override
@Nullable
public TileEntity getTileEntity(BlockPos pos) {
  IBlockState state = getBlockState(pos);
  if (state.getBlock().hasTileEntity(state)) {
    return teCache.computeIfAbsent(pos.toImmutable(), p -> state.getBlock().createTileEntity(world, state));
  }
  return null;
}

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

TileEntity newTile = block.createTileEntity(world, state);
world.setTileEntity(pos_, newTile);

代码示例来源:origin: WayofTime/BloodMagic

IBlockState state = replacementState;
if (block.hasTileEntity(state)) {
  TileEntity tile = block.createTileEntity(world, state);

代码示例来源:origin: thraaawn/CompactMachines

@Nullable
@Override
public TileEntity getTileEntity(BlockPos pos) {
  IBlockState state = getBlockState(pos);
  if(state.getBlock().hasTileEntity(state)) {
    TileEntity tileentity = state.getBlock().createTileEntity(proxyWorld, state);
    tileentity.setWorld(proxyWorld);
    if (tileentity != null) {
      NBTTagCompound nbt = getVariantAtBlockPos(pos);
      if(nbt != null) {
        tileentity.readFromNBT(nbt);
        for (AbstractExtraTileDataProvider provider : ExtraTileDataProviderRegistry.getDataProviders(tileentity)) {
          String tagName = String.format("cm3_extra:%s", provider.getName());
          if (nbt.hasKey(tagName)) {
            provider.readExtraData(tileentity, (NBTTagCompound) nbt.getTag(tagName));
          }
        }
      }
    }
    return tileentity;
  }
  return null;
}

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

final TileEntity nte = blk.createTileEntity( world, state );
final NBTTagCompound data = new NBTTagCompound();
ote.writeToNBT( data );

代码示例来源:origin: thraaawn/CompactMachines

TileEntity restoredTe = machineWorld.getTileEntity(absolutePos);
if (restoredTe == null) {
  restoredTe = bi.block.createTileEntity(machineWorld, state);

相关文章

Block类方法