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 PacketProgress(@Nonnull IProgressTile tile) { super(tile.getTileEntity()); progress = tile.getProgress(); }
@Override public IMessage onMessage(PacketProgress message, MessageContext ctx) { TileEntity tile = message.getTileEntity(EnderCore.proxy.getClientWorld()); if (tile instanceof IProgressTile) { ((IProgressTile) tile).setProgress(message.progress); } return null; } }
public static @Nullable Packet<?> getProgressPacket(Object o) { if (o instanceof IProgressTile) { return EnderPacketHandler.INSTANCE.getPacketFrom(((IProgressTile) o).getProgressPacket()); } return null; }
/** * CLIENT: Called when chunk data is received (client receiving chunks from server). */ @Override public final void handleUpdateTag(@Nonnull NBTTagCompound tag) { super.handleUpdateTag(tag); readCustomNBT(NBTAction.CLIENT, tag); if (isProgressTile) { // TODO: nicer way to do this? This is needed so players who enter a chunk get a correct progress. ((IProgressTile) this).setProgress(tag.getFloat("tileprogress")); } }
public static int getProgressScaled(int scale, @Nonnull IProgressTile tile) { return (int) (tile.getProgress() * scale); }
/** * CLIENT: Called when block data is received (client receiving blocks from server, via notifyBlockUpdate). */ @Override public final void onDataPacket(@Nonnull NetworkManager net, @Nonnull SPacketUpdateTileEntity pkt) { readCustomNBT(NBTAction.CLIENT, pkt.getNbtCompound()); if (isProgressTile) { // TODO: nicer way to do this? This is needed so players who enter a chunk get a correct progress. ((IProgressTile) this).setProgress(pkt.getNbtCompound().getFloat("tileprogress")); } }
@Override public byte getProgress(TileEntity tile) { return (byte) Math.max(0, Math.min(((IProgressTile)tile).getProgress() * 100, 100)); } }
/** * 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) {