@Override public boolean fuzzyComparison( final IAEFluidStack other, final FuzzyMode mode ) { return this.fluid == other.getFluid(); }
@Override public String getMessage() { final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot ); if( fluid != null && fluid.getStackSize() > 0 ) { String desc = fluid.getFluid().getLocalizedName( fluid.getFluidStack() ); String amountToText = fluid.getStackSize() + "mB"; return desc + "\n" + amountToText; } return null; }
currentToolTip.add( WailaText.Showing.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) );
@Override public void drawButton( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks ) { if( this.visible ) { GlStateManager.disableBlend(); GlStateManager.disableLighting(); drawRect( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 ); final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot ); if( fluid != null && fluid.getStackSize() > 0 ) { mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE ); float red = ( fluid.getFluid().getColor() >> 16 & 255 ) / 255.0F; float green = ( fluid.getFluid().getColor() >> 8 & 255 ) / 255.0F; float blue = ( fluid.getFluid().getColor() & 255 ) / 255.0F; GlStateManager.color( red, green, blue ); TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getFluid().getStill().toString() ); final int scaledHeight = (int) ( this.height * ( (float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity() ) ); int iconHeightRemainder = scaledHeight % 16; if( iconHeightRemainder > 0 ) { this.drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder, sprite, 16, iconHeightRemainder ); } for( int i = 0; i < scaledHeight / 16; i++ ) { this.drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder - ( i + 1 ) * 16, sprite, 16, 16 ); } } } }
@Override public void addProbeInfo( IPart part, ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data ) { if( part instanceof IPartStorageMonitor ) { final IPartStorageMonitor monitor = (IPartStorageMonitor) part; final IAEStack<?> displayed = monitor.getDisplayed(); final boolean isLocked = monitor.isLocked(); // TODO: generalize if( displayed instanceof IAEItemStack ) { final IAEItemStack ais = (IAEItemStack) displayed; probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.asItemStackRepresentation().getDisplayName() ); } else if( displayed instanceof IAEFluidStack ) { final IAEFluidStack ais = (IAEFluidStack) displayed; probeInfo.text( TheOneProbeText.SHOWING.getLocal() + ": " + ais.getFluid().getLocalizedName( ais.getFluidStack() ) ); } probeInfo.text( isLocked ? TheOneProbeText.LOCKED.getLocal() : TheOneProbeText.UNLOCKED.getLocal() ); } }
@Override public boolean isPrioritized(IAEFluidStack input) { if (input == null) { return false; } for (Fluid fluid : this.prioritizedFluids) { if (fluid == input.getFluid()) { return true; } } return false; }
public void updateFluids() { this.fluidWidgets = new ArrayList<AbstractFluidWidget>(); for (IAEFluidStack fluidStack : this.container.getFluidStackList()) { if (fluidStack.getFluid().getLocalizedName(fluidStack.getFluidStack()).toLowerCase().contains(this.searchbar.getText().toLowerCase()) && storageType.canSee(fluidStack.getFluidStack())) { this.fluidWidgets.add(new WidgetFluidSelector(this, fluidStack)); } } updateSelectedFluid(); }
public FluidStack drain( final int slot, final int maxDrain, boolean doDrain ) { final IAEFluidStack fluid = this.fluids[slot]; if( fluid == null || maxDrain <= 0 ) { return null; } int drained = maxDrain; if( fluid.getStackSize() < drained ) { drained = (int) fluid.getStackSize(); } FluidStack stack = new FluidStack( fluid.getFluid(), drained ); if( doDrain ) { fluid.setStackSize( fluid.getStackSize() - drained ); if( fluid.getStackSize() <= 0 ) { this.fluids[slot] = null; } this.onContentChanged( slot ); } return stack; }
@Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRenderer.drawString(I18n.translateToLocal("extracells.part." + type.getName() + ".terminal.name").replace("ME ", ""), 9, 6, 0x000000); drawWidgets(mouseX, mouseY); if (this.currentFluid != null) { long currentFluidAmount = this.currentFluid.getStackSize(); String amountToText = Long.toString(currentFluidAmount) + "mB"; if (ECConfigHandler.shortenedBuckets) { if (currentFluidAmount > 1000000000L) { amountToText = Long.toString(currentFluidAmount / 1000000000L) + type.getMega(); } else if (currentFluidAmount > 1000000L) { amountToText = Long.toString(currentFluidAmount / 1000000L) + type.getKilo(); } else if (currentFluidAmount > 9999L) { amountToText = Long.toString(currentFluidAmount / 1000L) + type.getBuckets(); } } this.fontRenderer.drawString(I18n.translateToLocal("extracells.tooltip.amount") + ": " + amountToText, 45, 91, 0x000000); this.fontRenderer.drawString(I18n.translateToLocal("extracells.tooltip.fluid") + ": " + this.currentFluid.getFluid().getLocalizedName(this.currentFluid.getFluidStack()), 45, 101, 0x000000); } }
@Override public void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks ) { final IAEFluidStack fs = this.getFluidStack(); if( fs != null ) { GlStateManager.disableLighting(); GlStateManager.disableBlend(); final Fluid fluid = fs.getFluid(); mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE ); final TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getStill().toString() ); // Set color for dynamic fluids // Convert int color to RGB final float red = ( fluid.getColor() >> 16 & 255 ) / 255.0F; final float green = ( fluid.getColor() >> 8 & 255 ) / 255.0F; final float blue = ( fluid.getColor() & 255 ) / 255.0F; GlStateManager.color( red, green, blue ); this.drawTexturedModalRect( this.xPos(), this.yPos(), sprite, this.getWidth(), this.getHeight() ); } }
@Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.fontRenderer.drawString(I18n.translateToLocal(this.guiName).replace("ME ", ""), 5, 6, 0x000000); drawWidgets(mouseX, mouseY); if (this.currentFluid != null) { long currentFluidAmount = this.currentFluid.getStackSize(); String amountToText = Long.toString(currentFluidAmount) + "mB"; if (ECConfigHandler.shortenedBuckets) { if (currentFluidAmount > 1000000000L) { amountToText = Long.toString(currentFluidAmount / 1000000000L) + storageType.getMega(); } else if (currentFluidAmount > 1000000L) { amountToText = Long.toString(currentFluidAmount / 1000000L) + storageType.getKilo(); } else if (currentFluidAmount > 9999L) { amountToText = Long.toString(currentFluidAmount / 1000L) + storageType.getBuckets(); } } this.fontRenderer.drawString( I18n.translateToLocal("extracells.tooltip.amount") + ": " + amountToText, 45, 91, 0x000000); this.fontRenderer.drawString( I18n.translateToLocal("extracells.tooltip.fluid") + ": " + this.currentFluid.getFluid().getLocalizedName( this.currentFluid.getFluidStack()), 45, 101, 0x000000); } }
public void receiveSelectedFluid(Fluid _selectedFluid) { this.selectedFluid = _selectedFluid; if (this.selectedFluid != null) { for (IAEFluidStack stack : this.fluidStackList) { if (stack != null && stack.getFluid() == this.selectedFluid) { this.selectedFluidStack = stack; break; } } } else { this.selectedFluidStack = null; } if (player.world.isRemote) updateGui(); }
public void updateSelectedFluid() { this.currentFluid = null; for (IAEFluidStack stack : this.container.getFluidStackList()) { if (stack.getFluid() == this.container.getSelectedFluid()) { this.currentFluid = stack; } } } }
public void updateSelectedFluid() { this.currentFluid = null; for (IAEFluidStack stack : this.containerTerminal.getFluidStackList()) { if (stack.getFluid() == this.containerTerminal.getSelectedFluid()) { this.currentFluid = stack; } } } }
public static GasStack getGasStack(IAEFluidStack fluidStack) { if (fluidStack == null) { return null; } Fluid fluid = fluidStack.getFluid(); if (fluid instanceof MekanismGas.GasFluid) { return new GasStack(((MekanismGas.GasFluid) fluid).getGas(), (int) fluidStack.getStackSize()); } return null; }
@Override public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, IActionSource actionSource) { List<Fluid> oldFluids = new ArrayList<Fluid>(this.fluids); boolean mustUpdate = false; this.fluids.clear(); for (IAEFluidStack fluid : ((IMEMonitor<IAEFluidStack>) monitor) .getStorageList()) { if (!oldFluids.contains(fluid.getFluid())) { mustUpdate = true; } else { oldFluids.remove(fluid.getFluid()); } this.fluids.add(fluid.getFluid()); } if (!(oldFluids.isEmpty() && !mustUpdate)) { if (getGridNode(AEPartLocation.INTERNAL) != null && getGridNode(AEPartLocation.INTERNAL).getGrid() != null) { getGridNode(AEPartLocation.INTERNAL).getGrid().postEvent( new MENetworkCraftingPatternChange(this, getGridNode(AEPartLocation.INTERNAL))); } } }
final Fluid fluid = fs.getFluid(); Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE ); final TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( fluid.getStill().toString() );
@Override public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, IStorageChannel chan) { if (isGas && chan == StorageChannels.GAS()) onStackChangeGas((IAEGasStack) fullStack, (IAEGasStack) diffStack); else if (chan == StorageChannels.FLUID() && diffStack != null && ((IAEFluidStack) diffStack).getFluid() == this.selectedFluid) { this.currentAmount = fullStack != null ? fullStack.getStackSize() : 0; IGridNode node = getGridNode(); if (node != null) { setActive(node.isActive()); getHost().markForUpdate(); notifyTargetBlock(getHostTile(), getFacing()); } } }
@Override public void drawWidget(int posX, int posY) { Minecraft.getMinecraft().renderEngine .bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor3f(1, 1, 1); IAEFluidStack terminalFluid = ((IFluidSelectorGui) this.guiFluidTerminal) .getCurrentFluid(); Fluid currentFluid = terminalFluid != null ? terminalFluid.getFluid() : null; if (this.fluid != null) { TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks(); TextureAtlasSprite sprite = map.getAtlasSprite(fluid.getStill().toString()); drawTexturedModalRect(posX + 1, posY + 1, sprite, this.height - 2, this.width - 2); } if (this.fluid == currentFluid) { drawHollowRectWithCorners(posX, posY, this.height, this.width, this.color, this.borderThickness); } GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); }