public boolean canPlayerAccess(EntityPlayer player) { return hasWorld() && !isInvalid() && player.getDistanceSqToCenter(getPos()) <= 64D; }
protected boolean isPoweredRedstone() { return hasWorld() && world.isBlockLoaded(getPos()) ? world.isBlockIndirectlyGettingPowered(getPos()) > 0 : false; }
protected void updateBlock() { if (hasWorld() && world.isBlockLoaded(getPos())) { IBlockState bs = world.getBlockState(getPos()); world.notifyBlockUpdate(pos, bs, bs, 3); } }
@Override public void markDirty() { if (hasWorld() && world.isBlockLoaded(getPos())) { // we need the loaded check to make sure we don't trigger a chunk load while the chunk is loaded world.markChunkDirty(pos, this); IBlockState state = world.getBlockState(pos); if (state.hasComparatorInputOverride()) { world.updateComparatorOutputLevel(pos, state.getBlock()); } } }
@Override public final void update() { if (!hasWorld() || isInvalid() || !world.isBlockLoaded(getPos()) || world.getTileEntity(getPos()) != this) { // we can get ticked after being removed from the world, ignore this return; } if (ConfigHandler.allowExternalTickSpeedup || world.getTotalWorldTime() != lastUpdate) { lastUpdate = world.getTotalWorldTime(); doUpdate(); sendProgressIf(); } }
@SuppressWarnings({ "null", "unused" }) @Override public final void render(@Nonnull T te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { if (te != null && te.hasWorld() && !te.isInvalid()) { final IBlockState blockState = te.getWorld().getBlockState(te.getPos()); final int renderPass = MinecraftForgeClient.getRenderPass(); if ((block == null || block == blockState.getBlock()) && shouldRender(te, blockState, renderPass)) { GlStateManager.disableLighting(); if (renderPass == 0) { GlStateManager.disableBlend(); GlStateManager.depthMask(true); } else { GlStateManager.enableBlend(); GlStateManager.depthMask(false); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } RenderUtil.bindBlockTexture(); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); renderTileEntity(te, blockState, partialTicks, destroyStage); GlStateManager.popMatrix(); } } else if (te == null) { renderItem(); } }