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

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

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

World.isBlockLoaded介绍

暂无

代码示例

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

public boolean notLoaded()
{
  return !this.world.isBlockLoaded( this.pos );
}

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

@Override
  public Boolean call( final World world ) throws Exception
  {
    if( world.isBlockLoaded( this.pos ) )
    {
      world.notifyNeighborsOfStateChange( this.pos, Platform.AIR_BLOCK, true );
    }

    return true;
  }
}

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

public boolean contentsEqual(World world) {
  if(!world.isBlockLoaded(coords)) {
    invalid = true;
    return false;
  }
  return world.getBlockState(coords) == state;
}

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

@Override
public void notifyNeighbors()
{
  if( this.world != null && this.world.isBlockLoaded( this.pos ) && !CableBusContainer.isLoading() )
  {
    Platform.notifyBlocksOfNeighbors( this.world, this.pos );
  }
}

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

private IGridHost findGridHost( final World world, final int x, final int y, final int z )
{
  final BlockPos pos = new BlockPos( x, y, z );
  if( world.isBlockLoaded( pos ) )
  {
    final TileEntity te = world.getTileEntity( pos );
    if( te instanceof IGridHost )
    {
      return (IGridHost) te;
    }
  }
  return null;
}

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

@Override
public void update() {
  if (world.isRemote)
    return;
  validPools.clear();
  for(EnumFacing dir : EnumFacing.HORIZONTALS) {
    BlockPos pos = this.pos.offset(dir);
    if(world.isBlockLoaded(pos)) {
      TileEntity tileAt = world.getTileEntity(pos);
      if(tileAt instanceof IManaPool && !tileAt.isInvalid()) {
        IManaReceiver receiver = (IManaReceiver) tileAt;
        if(!receiver.isFull())
          validPools.add(receiver);
      }
    }
  }
}

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

@Override
public void render(@Nonnull TilePylon pylon, double d0, double d1, double d2, float pticks, int digProgress, float unused) {
  boolean renderingItem = pylon == ForwardingTEISR.DUMMY;
  if(!renderingItem && (!pylon.getWorld().isBlockLoaded(pylon.getPos(), false) || pylon.getWorld().getBlockState(pylon.getPos()).getBlock() != ModBlocks.pylon))
    return;
  renderPylon(pylon, d0, d1, d2, pticks, renderingItem);
}

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

public boolean isValidBinding() {
  return linkedPool != null && linkedPool.hasWorld() && !linkedPool.isInvalid() && supertile.getWorld().isBlockLoaded(linkedPool.getPos(), false) && supertile.getWorld().getTileEntity(linkedPool.getPos()) == linkedPool;
}

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

@Override
public void onUpdate() {
  super.onUpdate();
  if(getWorld().isRemote) {
    if(state != NONE && Math.random() > 0.6)
      Botania.proxy.wispFX(supertile.getPos().getX() + 0.55 + Math.random() * 0.2 - 0.1, supertile.getPos().getY() + 0.75 + Math.random() * 0.2 - 0.1, supertile.getPos().getZ() + 0.5, state == INCREASING ? 0.05F : 1F, 0.05F, state == INCREASING ? 1F : 0.05F, (float) Math.random() / 7, (float) -Math.random() / 50);
  } else {
    int mana = 0;
    for(EnumFacing dir : EnumFacing.HORIZONTALS) {
      BlockPos pos = supertile.getPos().offset(dir);
      if(getWorld().isBlockLoaded(pos)) {
        TileEntity tile = supertile.getWorld().getTileEntity(pos);
        if(tile instanceof IManaPool)
          mana += ((IManaPool) tile).getCurrentMana();
      }
    }
    int newState = mana > lastMana ? INCREASING : mana < lastMana ? DECREASING : NONE;
    if(newState != state)
      getWorld().addBlockEvent(getPos(), supertile.getBlockType(), SET_STATE_EVENT, newState);
    if(ticksExisted % 60 == 0)
      lastMana = mana;
  }
}

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

@Override
public void render(@Nullable TileBellows bellows, double d0, double d1, double d2, float f, int digProgress, float unused) {
  if (bellows != null)
    if (!bellows.getWorld().isBlockLoaded(bellows.getPos(), false)
        || bellows.getWorld().getBlockState(bellows.getPos()).getBlock() != ModBlocks.bellows)
      return;
  GlStateManager.pushMatrix();
  GlStateManager.enableRescaleNormal();
  GlStateManager.color(1F, 1F, 1F, 1F);
  GlStateManager.translate(d0, d1, d2);
  Minecraft.getMinecraft().renderEngine.bindTexture(texture);
  int meta = bellows != null && bellows.getWorld() != null ? bellows.getBlockMetadata() : 0;
  GlStateManager.translate(0.5F, 1.5F, 0.5F);
  GlStateManager.scale(1F, -1F, -1F);
  GlStateManager.rotate(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F);
  model.render(Math.max(0.1F, 1F - (bellows == null ? 0 : bellows.movePos + bellows.moving * f + 0.1F)));
  GlStateManager.color(1F, 1F, 1F);
  GlStateManager.scale(1F, -1F, -1F);
  GlStateManager.enableRescaleNormal();
  GlStateManager.popMatrix();
}

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

public void checkForReceiver() {
  ItemStack stack = itemHandler.getStackInSlot(0);
  ILensControl control = getLensController(stack);
  if(control != null && !control.allowBurstShooting(stack, this, false))
    return;
  EntityManaBurst fakeBurst = getBurst(true);
  fakeBurst.setScanBeam();
  TileEntity receiver = fakeBurst.getCollidedTile(true);
  if(receiver != null
      && receiver instanceof IManaReceiver
      && receiver.hasWorld()
      && receiver.getWorld().isBlockLoaded(receiver.getPos(), !receiver.getWorld().isRemote))
    this.receiver = (IManaReceiver) receiver;
  else this.receiver = null;
  lastTentativeBurst = fakeBurst.propsList;
}

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

@Override
public void render(@Nonnull TileEntity tile, double d0, double d1, double d2, float t, int digProgress, float unused) {
  if(ConfigHandler.staticFloaters)
    return;
  if (tile != null)
    if (!tile.getWorld().isBlockLoaded(tile.getPos(), false))
      return;
  BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher();
  GlStateManager.pushMatrix();
  GlStateManager.color(1F, 1F, 1F, 1F);
  GlStateManager.translate(d0, d1, d2);
  double worldTime = ClientTickHandler.ticksInGame + t;
  if(tile.getWorld() != null)
    worldTime += new Random(tile.getPos().hashCode()).nextInt(1000);
  GlStateManager.translate(0.5F, 0, 0.5F);
  GlStateManager.rotate(-((float) worldTime * 0.5F), 0F, 1F, 0F);
  GlStateManager.translate(-0.5, (float) Math.sin(worldTime * 0.05F) * 0.1F, 0.5);
  GlStateManager.rotate(4F * (float) Math.sin(worldTime * 0.04F), 1F, 0F, 0F);
  Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  IBlockState state = tile.getWorld().getBlockState(tile.getPos());
  state = state.getBlock().getExtendedState(state, tile.getWorld(), tile.getPos());
  IBakedModel model = brd.getBlockModelShapes().getModelManager().getModel(new ModelResourceLocation("botania:floatingSpecialFlower", "inventory"));
  brd.getBlockModelRenderer().renderModelBrightness(model, state, 1.0F, true);
  GlStateManager.popMatrix();
}

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

private int transmitEnergy(int energy) {
  for(EnumFacing e : EnumFacing.VALUES) {
    BlockPos neighbor = getPos().offset(e);
    if(!world.isBlockLoaded(neighbor))
      continue;
    TileEntity te = world.getTileEntity(neighbor);
    if(te == null)
      continue;
    IEnergyStorage storage = null;
    if(te.hasCapability(CapabilityEnergy.ENERGY, e.getOpposite())) {
      storage = te.getCapability(CapabilityEnergy.ENERGY, e.getOpposite());
    } else if(te.hasCapability(CapabilityEnergy.ENERGY, null)) {
      storage = te.getCapability(CapabilityEnergy.ENERGY, null);
    }
    if(storage != null) {
      energy -= storage.receiveEnergy(energy, false);
      if (energy <= 0)
        return 0;
    }
  }
  return energy;
}

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

public void linkPool() {
  boolean needsNew = false;
  if(linkedPool == null) {
    needsNew = true;
    if(cachedPoolCoordinates != null) {
      needsNew = false;
      if(supertile.getWorld().isBlockLoaded(cachedPoolCoordinates)) {
        needsNew = true;
        TileEntity tileAt = supertile.getWorld().getTileEntity(cachedPoolCoordinates);
        if(tileAt != null && tileAt instanceof IManaPool && !tileAt.isInvalid()) {
          linkedPool = tileAt;
          needsNew = false;
        }
        cachedPoolCoordinates = null;
      }
    }
  } else {
    TileEntity tileAt = supertile.getWorld().getTileEntity(linkedPool.getPos());
    if(tileAt != null && tileAt instanceof IManaPool)
      linkedPool = tileAt;
  }
  if(needsNew && ticksExisted == 1) { // Only for new flowers
    IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
    int size = network.getAllPoolsInWorld(supertile.getWorld()).size();
    if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) {
      linkedPool = network.getClosestPool(supertile.getPos(), supertile.getWorld(), LINK_RANGE);
      sizeLastCheck = size;
    }
  }
}

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

public void linkCollector() {
  boolean needsNew = false;
  if(linkedCollector == null) {
    needsNew = true;
    if(cachedCollectorCoordinates != null) {
      needsNew = false;
      if(supertile.getWorld().isBlockLoaded(cachedCollectorCoordinates)) {
        needsNew = true;
        TileEntity tileAt = supertile.getWorld().getTileEntity(cachedCollectorCoordinates);
        if(tileAt != null && tileAt instanceof IManaCollector && !tileAt.isInvalid()) {
          linkedCollector = tileAt;
          needsNew = false;
        }
        cachedCollectorCoordinates = null;
      }
    }
  } else {
    TileEntity tileAt = supertile.getWorld().getTileEntity(linkedCollector.getPos());
    if(tileAt != null && tileAt instanceof IManaCollector)
      linkedCollector = tileAt;
  }
  if(needsNew && ticksExisted == 1) { // New flowers only
    IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
    int size = network.getAllCollectorsInWorld(supertile.getWorld()).size();
    if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) {
      linkedCollector = network.getClosestCollector(supertile.getPos(), supertile.getWorld(), LINK_RANGE);
      sizeLastCheck = size;
    }
  }
}

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

@Override
public void render(@Nonnull TileLightRelay tile, double x, double y, double z, float pticks, int digProgress, float unused) {
  if(!tile.getWorld().isBlockLoaded(tile.getPos(), false) || tile.getWorld().getBlockState(tile.getPos()).getBlock() != ModBlocks.lightRelay)
    return;

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

public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, BlockPos pos,
                    Predicate<IBlockState> filter,
                    boolean dispose, boolean particles) {
  if(!world.isBlockLoaded(pos))
    return;
  IBlockState state = world.getBlockState(pos);
  Block block = state.getBlock();
  if(!world.isRemote && filter.test(state)
      && !block.isAir(state, world, pos) && state.getPlayerRelativeBlockHardness(player, world, pos) > 0
      && block.canHarvestBlock(player.world, pos, player)) {
    int exp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos);
    if(exp == -1)
      return;
    if(!player.capabilities.isCreativeMode) {
      TileEntity tile = world.getTileEntity(pos);
      if(block.removedByPlayer(state, world, pos, player, true)) {
        block.onPlayerDestroy(world, pos, state);
        if(!dispose || !ItemElementiumPick.isDisposable(block)) {
          block.harvestBlock(world, player, pos, state, tile, stack);
          block.dropXpOnBlockBreak(world, pos, exp);
        }
      }
      damageItem(stack, 1, player, 80);
    } else world.setBlockToAir(pos);
    if(particles && ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool)
      world.playEvent(2001, pos, Block.getStateId(state));
  }
}

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

@Override
public void render(@Nonnull TileAlfPortal portal, double d0, double d1, double d2, float f, int digProgress, float unused) {
  if (!portal.getWorld().isBlockLoaded(portal.getPos(), false)
      || portal.getWorld().getBlockState(portal.getPos()).getBlock() != ModBlocks.alfPortal)
    return;

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

@SuppressWarnings("deprecation")
@Override
public void render(@Nonnull TileIncensePlate plate, double d0, double d1, double d2, float ticks, int digProgress, float unused) {
  if(!plate.getWorld().isBlockLoaded(plate.getPos(), false)
      || plate.getWorld().getBlockState(plate.getPos()).getBlock() != ModBlocks.incensePlate)
    return;
  ItemStack stack = plate.getItemHandler().getStackInSlot(0);
  if(stack.isEmpty())
    return;
  EnumFacing facing = plate.getWorld().getBlockState(plate.getPos()).getValue(BotaniaStateProps.CARDINALS);
  GlStateManager.pushMatrix();
  GlStateManager.enableRescaleNormal();
  GlStateManager.translate(d0, d1, d2);
  GlStateManager.translate(0.5F, 1.5F, 0.5F);
  GlStateManager.rotate(ROTATIONS.get(facing), 0F, 1F, 0F);
  Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  float s = 0.6F;
  GlStateManager.translate(-0.11F, -1.35F, 0F);
  GlStateManager.scale(s, s, s);
  Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
  GlStateManager.color(1F, 1F, 1F);
  GlStateManager.enableRescaleNormal();
  GlStateManager.popMatrix();
}

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

super.onUpdate();
if(!supertile.getWorld().isRemote && redstoneSignal == 0 && supertile.getWorld().isBlockLoaded(bindPos)) {
  BlockPos pos = supertile.getPos();

相关文章

微信公众号

最新文章

更多

World类方法