public boolean canPlayerAccess(EntityPlayer player) { return hasWorld() && !isInvalid() && player.getDistanceSqToCenter(getPos()) <= 64D; }
@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(); } }
/** * SERVER: Called when block data is sent (client receiving blocks from server, via notifyBlockUpdate). No need for x/y/z tags. */ @Override public final SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound tag = new NBTTagCompound(); writeCustomNBT(NBTAction.CLIENT, tag); if (isProgressTile) { // TODO: nicer way to do this? This is needed so players who enter a chunk get a correct progress. tag.setFloat("tileprogress", ((IProgressTile) this).getProgress()); } return new SPacketUpdateTileEntity(getPos(), 1, tag); }
@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()); } } }
protected void renderItemStack(T te, @Nonnull World world, double x, double y, double z, float tick) { EntityItem ei = this.enityItem; if (ei == null) { this.enityItem = ei = new EntityItem(world, 0, 0, 0, getFloatingItem(te)); } ei.setItem(getFloatingItem(te)); ei.hoverStart = (float) ((EnderIO.proxy.getTickCount() * 0.05f + (tick * 0.05f)) % (Math.PI * 2)); RenderUtil.bindBlockTexture(); GlStateManager.pushMatrix(); glTranslated(x + 0.5, y + 0.7, z + 0.5); glScalef(1.1f, 1.1f, 1.1f); BlockPos p; if (te != null) { p = te.getPos(); } else { p = new BlockPos(0, 0, 0); } rand.setSeed(p.getX() + p.getY() + p.getZ()); rand.nextBoolean(); if (Minecraft.getMinecraft().gameSettings.fancyGraphics) { GlStateManager.rotate(rand.nextFloat() * 360f, 0, 1, 0); } ei.hoverStart += rand.nextFloat(); GlStateManager.translate(0, -0.15f, 0); if (rei == null) { rei = new InnerRenderEntityItem(Minecraft.getMinecraft().getRenderManager(), Minecraft.getMinecraft().getRenderItem()); } rei.doRender(ei, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); GlStateManager.popMatrix(); }
@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(); } }