public static int getProgressScaled(int scale, @Nonnull IProgressTile tile) { return (int) (tile.getProgress() * scale); }
private final void sendProgressIf() { // this is only used for players that do not have the GUI open. They do not need a very fine resolution, as they only see the the machine being on or // off and get the sound restarted on progress==0 if (isProgressTile && !world.isRemote) { float progress = ((IProgressTile) this).getProgress(); boolean send = // progress < lastProgressSent // always send progress if it goes down, e.g. machine goes inactive or new task starts || (lastProgressSent <= 0 && progress > 0) // always send progress if machine goes active || (lastUpdate - lastProgressUpdate) > 60 * 20; // also update every 60 seconds to avoid stale client status if (send) { EnderPacketHandler.INSTANCE.sendToAllAround(((IProgressTile) this).getProgressPacket(), this); lastProgressSent = progress; lastProgressUpdate = lastUpdate; } } }
public static int getProgressScaled(int scale, @Nonnull IProgressTile tile) { return (int) (tile.getProgress() * scale); }
@Override public byte getProgress(TileEntity tile) { return (byte) Math.max(0, Math.min(((IProgressTile)tile).getProgress() * 100, 100)); } }
public PacketProgress(@Nonnull IProgressTile tile) { super(tile.getTileEntity()); progress = tile.getProgress(); }
/** * Called when the chunk data is sent (client receiving chunks from server). Must have x/y/z tags. */ @Override public final @Nonnull NBTTagCompound getUpdateTag() { NBTTagCompound tag = super.getUpdateTag(); 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 tag; }
protected boolean shouldRenderProgress() { if (tileEntity instanceof IProgressTile) { float progress = ((IProgressTile) tileEntity).getProgress(); if (progress >= 0 && progress <= 1) { updateProgressTooltips(scaleProgressForTooltip(progress), progress); return true; } else { updateProgressTooltips(-1, -1); return false; } } return false; }
protected boolean shouldRenderProgress() { if (tileEntity instanceof IProgressTile) { float progress = ((IProgressTile) tileEntity).getProgress(); if (progress >= 0 && progress < 1) { updateProgressTooltips(scaleProgressForTooltip(progress), progress); return true; } else { updateProgressTooltips(-1, -1); return false; } } return false; }
/** * 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); }
progress = progressTile.getProgress(); hasProgress = true; if (tileEntity instanceof AbstractPoweredTaskEntity) {