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

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

本文整理了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

  1. public boolean notLoaded()
  2. {
  3. return !this.world.isBlockLoaded( this.pos );
  4. }

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

  1. @Override
  2. public Boolean call( final World world ) throws Exception
  3. {
  4. if( world.isBlockLoaded( this.pos ) )
  5. {
  6. world.notifyNeighborsOfStateChange( this.pos, Platform.AIR_BLOCK, true );
  7. }
  8. return true;
  9. }
  10. }

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

  1. public boolean contentsEqual(World world) {
  2. if(!world.isBlockLoaded(coords)) {
  3. invalid = true;
  4. return false;
  5. }
  6. return world.getBlockState(coords) == state;
  7. }

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

  1. @Override
  2. public void notifyNeighbors()
  3. {
  4. if( this.world != null && this.world.isBlockLoaded( this.pos ) && !CableBusContainer.isLoading() )
  5. {
  6. Platform.notifyBlocksOfNeighbors( this.world, this.pos );
  7. }
  8. }

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

  1. private IGridHost findGridHost( final World world, final int x, final int y, final int z )
  2. {
  3. final BlockPos pos = new BlockPos( x, y, z );
  4. if( world.isBlockLoaded( pos ) )
  5. {
  6. final TileEntity te = world.getTileEntity( pos );
  7. if( te instanceof IGridHost )
  8. {
  9. return (IGridHost) te;
  10. }
  11. }
  12. return null;
  13. }

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

  1. @Override
  2. public void update() {
  3. if (world.isRemote)
  4. return;
  5. validPools.clear();
  6. for(EnumFacing dir : EnumFacing.HORIZONTALS) {
  7. BlockPos pos = this.pos.offset(dir);
  8. if(world.isBlockLoaded(pos)) {
  9. TileEntity tileAt = world.getTileEntity(pos);
  10. if(tileAt instanceof IManaPool && !tileAt.isInvalid()) {
  11. IManaReceiver receiver = (IManaReceiver) tileAt;
  12. if(!receiver.isFull())
  13. validPools.add(receiver);
  14. }
  15. }
  16. }
  17. }

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

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

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

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

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

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if(getWorld().isRemote) {
  5. if(state != NONE && Math.random() > 0.6)
  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);
  7. } else {
  8. int mana = 0;
  9. for(EnumFacing dir : EnumFacing.HORIZONTALS) {
  10. BlockPos pos = supertile.getPos().offset(dir);
  11. if(getWorld().isBlockLoaded(pos)) {
  12. TileEntity tile = supertile.getWorld().getTileEntity(pos);
  13. if(tile instanceof IManaPool)
  14. mana += ((IManaPool) tile).getCurrentMana();
  15. }
  16. }
  17. int newState = mana > lastMana ? INCREASING : mana < lastMana ? DECREASING : NONE;
  18. if(newState != state)
  19. getWorld().addBlockEvent(getPos(), supertile.getBlockType(), SET_STATE_EVENT, newState);
  20. if(ticksExisted % 60 == 0)
  21. lastMana = mana;
  22. }
  23. }

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

  1. @Override
  2. public void render(@Nullable TileBellows bellows, double d0, double d1, double d2, float f, int digProgress, float unused) {
  3. if (bellows != null)
  4. if (!bellows.getWorld().isBlockLoaded(bellows.getPos(), false)
  5. || bellows.getWorld().getBlockState(bellows.getPos()).getBlock() != ModBlocks.bellows)
  6. return;
  7. GlStateManager.pushMatrix();
  8. GlStateManager.enableRescaleNormal();
  9. GlStateManager.color(1F, 1F, 1F, 1F);
  10. GlStateManager.translate(d0, d1, d2);
  11. Minecraft.getMinecraft().renderEngine.bindTexture(texture);
  12. int meta = bellows != null && bellows.getWorld() != null ? bellows.getBlockMetadata() : 0;
  13. GlStateManager.translate(0.5F, 1.5F, 0.5F);
  14. GlStateManager.scale(1F, -1F, -1F);
  15. GlStateManager.rotate(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F);
  16. model.render(Math.max(0.1F, 1F - (bellows == null ? 0 : bellows.movePos + bellows.moving * f + 0.1F)));
  17. GlStateManager.color(1F, 1F, 1F);
  18. GlStateManager.scale(1F, -1F, -1F);
  19. GlStateManager.enableRescaleNormal();
  20. GlStateManager.popMatrix();
  21. }

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

  1. public void checkForReceiver() {
  2. ItemStack stack = itemHandler.getStackInSlot(0);
  3. ILensControl control = getLensController(stack);
  4. if(control != null && !control.allowBurstShooting(stack, this, false))
  5. return;
  6. EntityManaBurst fakeBurst = getBurst(true);
  7. fakeBurst.setScanBeam();
  8. TileEntity receiver = fakeBurst.getCollidedTile(true);
  9. if(receiver != null
  10. && receiver instanceof IManaReceiver
  11. && receiver.hasWorld()
  12. && receiver.getWorld().isBlockLoaded(receiver.getPos(), !receiver.getWorld().isRemote))
  13. this.receiver = (IManaReceiver) receiver;
  14. else this.receiver = null;
  15. lastTentativeBurst = fakeBurst.propsList;
  16. }

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

  1. @Override
  2. public void render(@Nonnull TileEntity tile, double d0, double d1, double d2, float t, int digProgress, float unused) {
  3. if(ConfigHandler.staticFloaters)
  4. return;
  5. if (tile != null)
  6. if (!tile.getWorld().isBlockLoaded(tile.getPos(), false))
  7. return;
  8. BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher();
  9. GlStateManager.pushMatrix();
  10. GlStateManager.color(1F, 1F, 1F, 1F);
  11. GlStateManager.translate(d0, d1, d2);
  12. double worldTime = ClientTickHandler.ticksInGame + t;
  13. if(tile.getWorld() != null)
  14. worldTime += new Random(tile.getPos().hashCode()).nextInt(1000);
  15. GlStateManager.translate(0.5F, 0, 0.5F);
  16. GlStateManager.rotate(-((float) worldTime * 0.5F), 0F, 1F, 0F);
  17. GlStateManager.translate(-0.5, (float) Math.sin(worldTime * 0.05F) * 0.1F, 0.5);
  18. GlStateManager.rotate(4F * (float) Math.sin(worldTime * 0.04F), 1F, 0F, 0F);
  19. Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  20. IBlockState state = tile.getWorld().getBlockState(tile.getPos());
  21. state = state.getBlock().getExtendedState(state, tile.getWorld(), tile.getPos());
  22. IBakedModel model = brd.getBlockModelShapes().getModelManager().getModel(new ModelResourceLocation("botania:floatingSpecialFlower", "inventory"));
  23. brd.getBlockModelRenderer().renderModelBrightness(model, state, 1.0F, true);
  24. GlStateManager.popMatrix();
  25. }

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

  1. private int transmitEnergy(int energy) {
  2. for(EnumFacing e : EnumFacing.VALUES) {
  3. BlockPos neighbor = getPos().offset(e);
  4. if(!world.isBlockLoaded(neighbor))
  5. continue;
  6. TileEntity te = world.getTileEntity(neighbor);
  7. if(te == null)
  8. continue;
  9. IEnergyStorage storage = null;
  10. if(te.hasCapability(CapabilityEnergy.ENERGY, e.getOpposite())) {
  11. storage = te.getCapability(CapabilityEnergy.ENERGY, e.getOpposite());
  12. } else if(te.hasCapability(CapabilityEnergy.ENERGY, null)) {
  13. storage = te.getCapability(CapabilityEnergy.ENERGY, null);
  14. }
  15. if(storage != null) {
  16. energy -= storage.receiveEnergy(energy, false);
  17. if (energy <= 0)
  18. return 0;
  19. }
  20. }
  21. return energy;
  22. }

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

  1. public void linkPool() {
  2. boolean needsNew = false;
  3. if(linkedPool == null) {
  4. needsNew = true;
  5. if(cachedPoolCoordinates != null) {
  6. needsNew = false;
  7. if(supertile.getWorld().isBlockLoaded(cachedPoolCoordinates)) {
  8. needsNew = true;
  9. TileEntity tileAt = supertile.getWorld().getTileEntity(cachedPoolCoordinates);
  10. if(tileAt != null && tileAt instanceof IManaPool && !tileAt.isInvalid()) {
  11. linkedPool = tileAt;
  12. needsNew = false;
  13. }
  14. cachedPoolCoordinates = null;
  15. }
  16. }
  17. } else {
  18. TileEntity tileAt = supertile.getWorld().getTileEntity(linkedPool.getPos());
  19. if(tileAt != null && tileAt instanceof IManaPool)
  20. linkedPool = tileAt;
  21. }
  22. if(needsNew && ticksExisted == 1) { // Only for new flowers
  23. IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
  24. int size = network.getAllPoolsInWorld(supertile.getWorld()).size();
  25. if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) {
  26. linkedPool = network.getClosestPool(supertile.getPos(), supertile.getWorld(), LINK_RANGE);
  27. sizeLastCheck = size;
  28. }
  29. }
  30. }

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

  1. public void linkCollector() {
  2. boolean needsNew = false;
  3. if(linkedCollector == null) {
  4. needsNew = true;
  5. if(cachedCollectorCoordinates != null) {
  6. needsNew = false;
  7. if(supertile.getWorld().isBlockLoaded(cachedCollectorCoordinates)) {
  8. needsNew = true;
  9. TileEntity tileAt = supertile.getWorld().getTileEntity(cachedCollectorCoordinates);
  10. if(tileAt != null && tileAt instanceof IManaCollector && !tileAt.isInvalid()) {
  11. linkedCollector = tileAt;
  12. needsNew = false;
  13. }
  14. cachedCollectorCoordinates = null;
  15. }
  16. }
  17. } else {
  18. TileEntity tileAt = supertile.getWorld().getTileEntity(linkedCollector.getPos());
  19. if(tileAt != null && tileAt instanceof IManaCollector)
  20. linkedCollector = tileAt;
  21. }
  22. if(needsNew && ticksExisted == 1) { // New flowers only
  23. IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
  24. int size = network.getAllCollectorsInWorld(supertile.getWorld()).size();
  25. if(BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) {
  26. linkedCollector = network.getClosestCollector(supertile.getPos(), supertile.getWorld(), LINK_RANGE);
  27. sizeLastCheck = size;
  28. }
  29. }
  30. }

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

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

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

  1. public static void removeBlockWithDrops(EntityPlayer player, ItemStack stack, World world, BlockPos pos,
  2. Predicate<IBlockState> filter,
  3. boolean dispose, boolean particles) {
  4. if(!world.isBlockLoaded(pos))
  5. return;
  6. IBlockState state = world.getBlockState(pos);
  7. Block block = state.getBlock();
  8. if(!world.isRemote && filter.test(state)
  9. && !block.isAir(state, world, pos) && state.getPlayerRelativeBlockHardness(player, world, pos) > 0
  10. && block.canHarvestBlock(player.world, pos, player)) {
  11. int exp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos);
  12. if(exp == -1)
  13. return;
  14. if(!player.capabilities.isCreativeMode) {
  15. TileEntity tile = world.getTileEntity(pos);
  16. if(block.removedByPlayer(state, world, pos, player, true)) {
  17. block.onPlayerDestroy(world, pos, state);
  18. if(!dispose || !ItemElementiumPick.isDisposable(block)) {
  19. block.harvestBlock(world, player, pos, state, tile, stack);
  20. block.dropXpOnBlockBreak(world, pos, exp);
  21. }
  22. }
  23. damageItem(stack, 1, player, 80);
  24. } else world.setBlockToAir(pos);
  25. if(particles && ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool)
  26. world.playEvent(2001, pos, Block.getStateId(state));
  27. }
  28. }

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

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

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

  1. @SuppressWarnings("deprecation")
  2. @Override
  3. public void render(@Nonnull TileIncensePlate plate, double d0, double d1, double d2, float ticks, int digProgress, float unused) {
  4. if(!plate.getWorld().isBlockLoaded(plate.getPos(), false)
  5. || plate.getWorld().getBlockState(plate.getPos()).getBlock() != ModBlocks.incensePlate)
  6. return;
  7. ItemStack stack = plate.getItemHandler().getStackInSlot(0);
  8. if(stack.isEmpty())
  9. return;
  10. EnumFacing facing = plate.getWorld().getBlockState(plate.getPos()).getValue(BotaniaStateProps.CARDINALS);
  11. GlStateManager.pushMatrix();
  12. GlStateManager.enableRescaleNormal();
  13. GlStateManager.translate(d0, d1, d2);
  14. GlStateManager.translate(0.5F, 1.5F, 0.5F);
  15. GlStateManager.rotate(ROTATIONS.get(facing), 0F, 1F, 0F);
  16. Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  17. float s = 0.6F;
  18. GlStateManager.translate(-0.11F, -1.35F, 0F);
  19. GlStateManager.scale(s, s, s);
  20. Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
  21. GlStateManager.color(1F, 1F, 1F);
  22. GlStateManager.enableRescaleNormal();
  23. GlStateManager.popMatrix();
  24. }

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

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

相关文章

World类方法