Initial Fluid Integration (#3510)
* Added Fluid Storage Cells * Added Fluid Import Bus * Added Fluid Export Bus * Added Fluid Storage Bus * Added Fluid Terminal. While holding a item with the FLUID_HANDLER_ITEM_CAPABILITY, such as a tank Left click on a fluid to extract the fluid Right click to insert the fluid
This commit is contained in:
@@ -46,6 +46,8 @@ import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
@@ -54,6 +56,8 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
@@ -66,7 +70,8 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.AppEngCraftingSlot;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.AppEngSlot.hasCalculatedValidness;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.IOptionalSlot;
|
||||
import appeng.container.slot.ISlotFluid;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
import appeng.container.slot.SlotDisabled;
|
||||
import appeng.container.slot.SlotFake;
|
||||
@@ -208,6 +213,23 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
this.drawHoveringText( lines, x, y, this.fontRenderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderHoveredToolTip( int mouseX, int mouseY )
|
||||
{
|
||||
Slot slot = this.getSlot( mouseX, mouseY );
|
||||
if( slot != null && slot.isEnabled() && slot instanceof ISlotFluid )
|
||||
{
|
||||
ISlotFluid fluidSlot = (ISlotFluid) slot;
|
||||
if( fluidSlot.getFluidInSlot() != null && fluidSlot.shouldRenderAsFluid() )
|
||||
{
|
||||
FluidStack fluidStack = fluidSlot.getFluidInSlot();
|
||||
this.drawHoveringText( fluidStack.getLocalizedName(), mouseX, mouseY );
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.renderHoveredToolTip( mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void drawGuiContainerForegroundLayer( final int x, final int y )
|
||||
{
|
||||
@@ -236,21 +258,22 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
final List<Slot> slots = this.getInventorySlots();
|
||||
for( final Slot slot : slots )
|
||||
{
|
||||
if( slot instanceof OptionalSlotFake )
|
||||
if( slot instanceof IOptionalSlot )
|
||||
{
|
||||
final OptionalSlotFake fs = (OptionalSlotFake) slot;
|
||||
if( fs.renderDisabled() )
|
||||
final IOptionalSlot optionalSlot = (IOptionalSlot) slot;
|
||||
if( optionalSlot.isRenderDisabled() )
|
||||
{
|
||||
if( fs.isSlotEnabled() )
|
||||
final AppEngSlot aeSlot = (AppEngSlot) slot;
|
||||
if( aeSlot.isSlotEnabled() )
|
||||
{
|
||||
this.drawTexturedModalRect( ox + fs.xPos - 1, oy + fs.yPos - 1, fs.getSourceX() - 1, fs.getSourceY() - 1, 18,
|
||||
this.drawTexturedModalRect( ox + aeSlot.xPos - 1, oy + aeSlot.yPos - 1, optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, 18,
|
||||
18 );
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 0.4F );
|
||||
GlStateManager.enableBlend();
|
||||
this.drawTexturedModalRect( ox + fs.xPos - 1, oy + fs.yPos - 1, fs.getSourceX() - 1, fs.getSourceY() - 1, 18,
|
||||
this.drawTexturedModalRect( ox + aeSlot.xPos - 1, oy + aeSlot.yPos - 1, optionalSlot.getSourceX() - 1, optionalSlot.getSourceY() - 1, 18,
|
||||
18 );
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
@@ -715,6 +738,32 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
|
||||
return;
|
||||
}
|
||||
else if( s instanceof ISlotFluid && ( (ISlotFluid) s ).shouldRenderAsFluid() )
|
||||
{
|
||||
FluidStack fs = ( (ISlotFluid) s ).getFluidInSlot();
|
||||
if( fs != null )
|
||||
{
|
||||
GlStateManager.disableLighting();
|
||||
Fluid fluid = fs.getFluid();
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
|
||||
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( fluid.getStill().toString() );
|
||||
|
||||
// Set color for dynamic fluids
|
||||
// Convert int color to RGB
|
||||
float red = ( fluid.getColor() >> 16 & 255 ) / 255.0F;
|
||||
float green = ( fluid.getColor() >> 8 & 255 ) / 255.0F;
|
||||
float blue = ( fluid.getColor() & 255 ) / 255.0F;
|
||||
GlStateManager.color( red, green, blue );
|
||||
|
||||
this.drawTexturedModalRect( s.xPos, s.yPos, sprite, 16, 16 );
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
if( !this.isPowered() )
|
||||
{
|
||||
drawRect( s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111 );
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.container.implementations.ContainerFluidIO;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.fluids.parts.PartFluidImportBus;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv5 - 1/05/2018
|
||||
* @since rv5 1/05/2018
|
||||
*/
|
||||
public class GuiFluidIO extends GuiUpgradeable
|
||||
{
|
||||
|
||||
public GuiFluidIO( InventoryPlayer inventoryPlayer, IUpgradeableHost te )
|
||||
{
|
||||
super( new ContainerFluidIO( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return this.bc instanceof PartFluidImportBus ? GuiText.ImportBusFluids : GuiText.ExportBusFluids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerFluidStorageBus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.parts.PartFluidStorageBus;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class GuiFluidStorageBus extends GuiUpgradeable
|
||||
{
|
||||
private GuiImgButton rwMode;
|
||||
private GuiImgButton storageFilter;
|
||||
private GuiTabButton priority;
|
||||
private GuiImgButton partition;
|
||||
private GuiImgButton clear;
|
||||
|
||||
public GuiFluidStorageBus( InventoryPlayer inventoryPlayer, PartFluidStorageBus te )
|
||||
{
|
||||
super( new ContainerFluidStorageBus( inventoryPlayer, te ) );
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.clear = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
this.partition = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
|
||||
this.rwMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||
this.storageFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
|
||||
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
|
||||
this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
|
||||
|
||||
this.buttonList.add( this.storageFilter );
|
||||
this.buttonList.add( this.fuzzyMode );
|
||||
this.buttonList.add( this.rwMode );
|
||||
this.buttonList.add( this.partition );
|
||||
this.buttonList.add( this.clear );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.fontRenderer.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 );
|
||||
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
|
||||
if( this.fuzzyMode != null )
|
||||
{
|
||||
this.fuzzyMode.set( this.cvb.getFuzzyMode() );
|
||||
}
|
||||
|
||||
if( this.storageFilter != null )
|
||||
{
|
||||
this.storageFilter.set( ( (ContainerFluidStorageBus) this.cvb ).getStorageFilter() );
|
||||
}
|
||||
|
||||
if( this.rwMode != null )
|
||||
{
|
||||
this.rwMode.set( ( (ContainerFluidStorageBus) this.cvb ).getReadWriteMode() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if( btn == this.partition )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
|
||||
}
|
||||
else if( btn == this.clear )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
|
||||
}
|
||||
else if( btn == this.priority )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
else if( btn == this.rwMode )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
|
||||
}
|
||||
else if( btn == this.storageFilter )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
|
||||
}
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.StorageBusFluids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.FluidRepo;
|
||||
import appeng.client.me.SlotFluidME;
|
||||
import appeng.client.me.InternalFluidSlotME;
|
||||
import appeng.container.implementations.ContainerFluidTerminal;
|
||||
import appeng.container.slot.ISlotFluid;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.parts.reporting.PartFluidTerminal;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 12/05/2018
|
||||
* @since rv6 12/05/2018
|
||||
*/
|
||||
public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfigManagerHost
|
||||
{
|
||||
private final List<SlotFluidME> meFluidSlots = new LinkedList<>();
|
||||
private final FluidRepo repo;
|
||||
private final IConfigManager configSrc;
|
||||
private final ContainerFluidTerminal container;
|
||||
private final int offsetX = 9;
|
||||
private int rows = 6;
|
||||
private int maxRows = Integer.MAX_VALUE;
|
||||
private int perRow = 9;
|
||||
|
||||
protected PartFluidTerminal terminal;
|
||||
|
||||
private MEGuiTextField searchField;
|
||||
private GuiImgButton sortByBox;
|
||||
private GuiImgButton sortDirBox;
|
||||
|
||||
public GuiFluidTerminal( InventoryPlayer inventoryPlayer, PartFluidTerminal terminal )
|
||||
{
|
||||
super( new ContainerFluidTerminal( inventoryPlayer, terminal ) );
|
||||
this.terminal = terminal;
|
||||
this.xSize = 185;
|
||||
this.ySize = 222;
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar( scrollbar );
|
||||
this.repo = new FluidRepo( scrollbar, this );
|
||||
this.configSrc = ( (IConfigurableObject) this.inventorySlots ).getConfigManager();
|
||||
( this.container = (ContainerFluidTerminal) this.inventorySlots ).setGui( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
this.mc.player.openContainer = this.inventorySlots;
|
||||
this.guiLeft = ( this.width - this.xSize ) / 2;
|
||||
this.guiTop = ( this.height - this.ySize ) / 2;
|
||||
|
||||
this.searchField = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
|
||||
this.searchField.setEnableBackgroundDrawing( false );
|
||||
this.searchField.setMaxStringLength( 25 );
|
||||
this.searchField.setTextColor( 0xFFFFFF );
|
||||
this.searchField.setSelectionColor( 0xFF99FF99 );
|
||||
this.searchField.setVisible( true );
|
||||
|
||||
int offset = this.guiTop;
|
||||
|
||||
this.buttonList.add( this.sortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ) ) );
|
||||
offset += 20;
|
||||
|
||||
this.buttonList.add( this.sortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc.getSetting( Settings.SORT_DIRECTION ) ) );
|
||||
|
||||
for( int y = 0; y < this.rows; y++ )
|
||||
{
|
||||
for( int x = 0; x < this.perRow; x++ )
|
||||
{
|
||||
SlotFluidME slot = new SlotFluidME( new InternalFluidSlotME( this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18 ) );
|
||||
this.getMeFluidSlots().add( slot );
|
||||
this.inventorySlots.inventorySlots.add( slot );
|
||||
}
|
||||
}
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
|
||||
{
|
||||
this.fontRenderer.drawString( this.getGuiDisplayName( "Fluid Terminal" ), 8, 6, 4210752 );
|
||||
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
|
||||
{
|
||||
this.bindTexture( this.getBackground() );
|
||||
final int x_width = 197;
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
|
||||
|
||||
for( int x = 0; x < 6; x++ )
|
||||
{
|
||||
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect( offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77 );
|
||||
|
||||
if( this.searchField != null )
|
||||
{
|
||||
this.searchField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
this.repo.setPower( this.container.isPowered() );
|
||||
super.updateScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderHoveredToolTip( int mouseX, int mouseY )
|
||||
{
|
||||
Slot slot = this.getSlot( mouseX, mouseY );
|
||||
if( slot != null && slot.isEnabled() && slot instanceof ISlotFluid )
|
||||
{
|
||||
ISlotFluid fluidSlot = (ISlotFluid) slot;
|
||||
if( fluidSlot.getFluidInSlot() != null && fluidSlot.shouldRenderAsFluid() )
|
||||
{
|
||||
FluidStack fluidStack = fluidSlot.getFluidInSlot();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add( fluidStack.getLocalizedName() );
|
||||
int amount = fluidStack.amount;
|
||||
DecimalFormat formatter = new DecimalFormat( "#,###.##" );
|
||||
String amountStr = formatter.format( amount ) + "mb";
|
||||
if( amount >= 10000 )
|
||||
{
|
||||
amountStr += " ( ";
|
||||
amountStr += formatter.format( amount / 1000 ) + "B";
|
||||
amountStr += " )";
|
||||
}
|
||||
list.add( amountStr );
|
||||
String modName = "";
|
||||
modName += TextFormatting.BLUE;
|
||||
modName += TextFormatting.ITALIC;
|
||||
modName += Loader.instance().getIndexedModList().get( Platform.getModId( AEFluidStack.fromFluidStack( fluidStack ) ) ).getName();
|
||||
list.add( modName );
|
||||
this.drawHoveringText( list, mouseX, mouseY );
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.renderHoveredToolTip( mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( GuiButton btn ) throws IOException
|
||||
{
|
||||
if( btn instanceof GuiImgButton )
|
||||
{
|
||||
final boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
final GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
if( iBtn.getSetting() != Settings.ACTIONS )
|
||||
{
|
||||
final Enum cv = iBtn.getCurrentValue();
|
||||
final Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
|
||||
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
|
||||
iBtn.set( next );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick( Slot slot, int slotIdx, int mouseButton, ClickType clickType )
|
||||
{
|
||||
if( slot instanceof SlotFluidME )
|
||||
{
|
||||
SlotFluidME meSlot = (SlotFluidME) slot;
|
||||
if( clickType == ClickType.PICKUP )
|
||||
{
|
||||
// TODO: Allow more options
|
||||
if( mouseButton == 0 && meSlot.getHasStack() )
|
||||
{
|
||||
this.container.setTargetStack( meSlot.getAEStack() );
|
||||
AELog.info( "mouse0 GUI STACK SIZE %s", meSlot.getAEStack().getStackSize() );
|
||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.FILL_ITEM, slot.slotNumber, 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.container.setTargetStack( meSlot.getAEStack() );
|
||||
if( meSlot.getAEStack() != null )
|
||||
{
|
||||
AELog.info( "mouse1 GUI STACK SIZE %s", meSlot.getAEStack().getStackSize() );
|
||||
}
|
||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.EMPTY_ITEM, slot.slotNumber, 0 ) );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.handleMouseClick( slot, slotIdx, mouseButton, clickType );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if( character == ' ' && this.searchField.getText().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.searchField.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
this.repo.setSearchString( this.searchField.getText() );
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
|
||||
{
|
||||
this.searchField.mouseClicked( xCoord, yCoord, btn );
|
||||
|
||||
if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
|
||||
{
|
||||
this.searchField.setText( "" );
|
||||
this.repo.setSearchString( "" );
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
|
||||
public void postUpdate( final List<IAEFluidStack> list )
|
||||
{
|
||||
for( final IAEFluidStack is : list )
|
||||
{
|
||||
this.repo.postUpdate( is );
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
this.getScrollBar().setTop( 18 ).setLeft( 175 ).setHeight( this.rows * 18 - 2 );
|
||||
this.getScrollBar().setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return this.configSrc.getSetting( Settings.SORT_BY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDir()
|
||||
{
|
||||
return this.configSrc.getSetting( Settings.SORT_DIRECTION );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDisplay()
|
||||
{
|
||||
return this.configSrc.getSetting( Settings.VIEW_MODE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
if( this.sortByBox != null )
|
||||
{
|
||||
this.sortByBox.set( this.configSrc.getSetting( Settings.SORT_BY ) );
|
||||
}
|
||||
|
||||
if( this.sortDirBox != null )
|
||||
{
|
||||
this.sortDirBox.set( this.configSrc.getSetting( Settings.SORT_DIRECTION ) );
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
}
|
||||
|
||||
protected List<SlotFluidME> getMeFluidSlots()
|
||||
{
|
||||
return this.meFluidSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPowered()
|
||||
{
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/terminal.png";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.me;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.util.FluidSorters;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.prioritylist.IPartitionList;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class FluidRepo
|
||||
{
|
||||
private final IItemList<IAEFluidStack> list = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
private final ArrayList<IAEFluidStack> view = new ArrayList<>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
private int rowSize = 9;
|
||||
|
||||
private String searchString = "";
|
||||
private IPartitionList<IAEFluidStack> myPartitionList;
|
||||
private boolean hasPower;
|
||||
|
||||
public FluidRepo( final IScrollSource src, final ISortSource sortSrc )
|
||||
{
|
||||
this.src = src;
|
||||
this.sortSrc = sortSrc;
|
||||
}
|
||||
|
||||
public void updateView()
|
||||
{
|
||||
this.view.clear();
|
||||
|
||||
this.view.ensureCapacity( this.list.size() );
|
||||
|
||||
String innerSearch = this.searchString;
|
||||
|
||||
boolean searchMod = false;
|
||||
if( innerSearch.startsWith( "@" ) )
|
||||
{
|
||||
searchMod = true;
|
||||
innerSearch = innerSearch.substring( 1 );
|
||||
}
|
||||
|
||||
Pattern m;
|
||||
try
|
||||
{
|
||||
m = Pattern.compile( innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE );
|
||||
}
|
||||
catch( final Exception ignore1 )
|
||||
{
|
||||
try
|
||||
{
|
||||
m = Pattern.compile( Pattern.quote( innerSearch.toLowerCase() ), Pattern.CASE_INSENSITIVE );
|
||||
}
|
||||
catch( final Exception ignore2 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE;
|
||||
final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO;
|
||||
|
||||
boolean notDone = false;
|
||||
for( IAEFluidStack fs : this.list )
|
||||
{
|
||||
if( this.myPartitionList != null && !this.myPartitionList.isListed( fs ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( viewMode == ViewItems.CRAFTABLE && !fs.isCraftable() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( viewMode == ViewItems.STORED && fs.getStackSize() == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String dspName = searchMod ? Platform.getModId( fs ) : Platform.getFluidDisplayName( fs );
|
||||
boolean foundMatchingFluidStack = false;
|
||||
notDone = true;
|
||||
|
||||
if( m.matcher( dspName.toLowerCase() ).find() )
|
||||
{
|
||||
notDone = false;
|
||||
foundMatchingFluidStack = true;
|
||||
}
|
||||
|
||||
if( terminalSearchToolTips && notDone && !searchMod )
|
||||
{
|
||||
final List<String> tooltip = Platform.getTooltip( fs );
|
||||
|
||||
for( final String line : tooltip )
|
||||
{
|
||||
if( m.matcher( line ).find() )
|
||||
{
|
||||
foundMatchingFluidStack = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( foundMatchingFluidStack )
|
||||
{
|
||||
if( needsZeroCopy )
|
||||
{
|
||||
fs = fs.copy();
|
||||
fs.setStackSize( 0 );
|
||||
}
|
||||
|
||||
this.view.add( fs );
|
||||
}
|
||||
}
|
||||
|
||||
final Enum sortBy = this.sortSrc.getSortBy();
|
||||
final Enum sortDir = this.sortSrc.getSortDir();
|
||||
|
||||
FluidSorters.setDirection( (appeng.api.config.SortDir) sortDir );
|
||||
|
||||
if( sortBy == SortOrder.MOD )
|
||||
{
|
||||
Collections.sort( this.view, FluidSorters.CONFIG_BASED_SORT_BY_MOD );
|
||||
}
|
||||
else if( sortBy == SortOrder.AMOUNT )
|
||||
{
|
||||
Collections.sort( this.view, FluidSorters.CONFIG_BASED_SORT_BY_SIZE );
|
||||
}
|
||||
else
|
||||
{
|
||||
Collections.sort( this.view, FluidSorters.CONFIG_BASED_SORT_BY_NAME );
|
||||
}
|
||||
}
|
||||
|
||||
public void postUpdate( final IAEFluidStack is )
|
||||
{
|
||||
final IAEFluidStack st = this.list.findPrecise( is );
|
||||
|
||||
if( st != null )
|
||||
{
|
||||
st.reset();
|
||||
st.add( is );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.list.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
public IAEFluidStack getReferenceFluid( int idx )
|
||||
{
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
if( idx >= this.view.size() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.view.get( idx );
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return this.view.size();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
this.list.resetStatus();
|
||||
}
|
||||
|
||||
public boolean hasPower()
|
||||
{
|
||||
return this.hasPower;
|
||||
}
|
||||
|
||||
public void setPower( final boolean hasPower )
|
||||
{
|
||||
this.hasPower = hasPower;
|
||||
}
|
||||
|
||||
public int getRowSize()
|
||||
{
|
||||
return this.rowSize;
|
||||
}
|
||||
|
||||
public void setRowSize( final int rowSize )
|
||||
{
|
||||
this.rowSize = rowSize;
|
||||
}
|
||||
|
||||
public String getSearchString()
|
||||
{
|
||||
return this.searchString;
|
||||
}
|
||||
|
||||
public void setSearchString( @Nonnull final String searchString )
|
||||
{
|
||||
this.searchString = searchString;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.me;
|
||||
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class InternalFluidSlotME
|
||||
{
|
||||
|
||||
private final int offset;
|
||||
private final int xPos;
|
||||
private final int yPos;
|
||||
private final FluidRepo repo;
|
||||
|
||||
public InternalFluidSlotME( final FluidRepo def, final int offset, final int displayX, final int displayY )
|
||||
{
|
||||
this.repo = def;
|
||||
this.offset = offset;
|
||||
this.xPos = displayX;
|
||||
this.yPos = displayY;
|
||||
}
|
||||
|
||||
FluidStack getStack()
|
||||
{
|
||||
return this.getAEStack() == null ? null : this.getAEStack().getFluidStack();
|
||||
}
|
||||
|
||||
IAEFluidStack getAEStack()
|
||||
{
|
||||
return this.repo.getReferenceFluid( this.offset );
|
||||
}
|
||||
|
||||
boolean hasPower()
|
||||
{
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
int getxPosition()
|
||||
{
|
||||
return this.xPos;
|
||||
}
|
||||
|
||||
int getyPosition()
|
||||
{
|
||||
return this.yPos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.me;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.container.slot.ISlotFluid;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class SlotFluidME extends SlotItemHandler implements ISlotFluid
|
||||
{
|
||||
private InternalFluidSlotME slot;
|
||||
|
||||
public SlotFluidME( InternalFluidSlotME slot )
|
||||
{
|
||||
super( null, 0, slot.getxPosition(), slot.getyPosition() );
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public IAEFluidStack getAEStack()
|
||||
{
|
||||
if( this.slot.hasPower() )
|
||||
{
|
||||
return this.slot.getAEStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( final ItemStack par1ItemStack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluidInSlot()
|
||||
{
|
||||
return this.slot.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack()
|
||||
{
|
||||
if( this.slot.hasPower() )
|
||||
{
|
||||
return this.getAEStack() != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( final ItemStack par1ItemStack )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int par1 )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHere( final IInventory inv, final int slotIn )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack( final EntityPlayer par1EntityPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
|
||||
/**
|
||||
* @author DrummerMC
|
||||
* @version rv6 - 2018-01-22
|
||||
* @since rv6 2018-01-22
|
||||
*/
|
||||
public class DummyFluidBakedModel implements IBakedModel
|
||||
{
|
||||
private final ImmutableList<BakedQuad> quads;
|
||||
public DummyFluidBakedModel( ImmutableList<BakedQuad> quads )
|
||||
{
|
||||
this.quads = quads;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand )
|
||||
{
|
||||
return quads;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ItemLayerModel;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import appeng.fluids.items.FluidDummyItem;
|
||||
|
||||
|
||||
/**
|
||||
* This baked model class is used as a dispatcher to redirect the renderer to the *real* model that should be used based
|
||||
* on the item stack.
|
||||
* A custom Item Override List is used to accomplish this.
|
||||
*/
|
||||
public class DummyFluidDispatcherBakedModel extends DelegateBakedModel
|
||||
{
|
||||
private final VertexFormat format;
|
||||
private final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter;
|
||||
|
||||
public DummyFluidDispatcherBakedModel( IBakedModel baseModel, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
super( baseModel );
|
||||
this.format = format;
|
||||
this.bakedTextureGetter = bakedTextureGetter;
|
||||
}
|
||||
|
||||
// This is never used. See the item override list below.
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return this.getBaseModel().isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return new ItemOverrideList( Collections.emptyList() )
|
||||
{
|
||||
@Override
|
||||
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity )
|
||||
{
|
||||
if( !( stack.getItem() instanceof FluidDummyItem ) )
|
||||
{
|
||||
return originalModel;
|
||||
}
|
||||
|
||||
FluidDummyItem itemFacade = (FluidDummyItem) stack.getItem();
|
||||
|
||||
FluidStack fluidStack = itemFacade.getFluidStack( stack );
|
||||
if( fluidStack == null )
|
||||
{
|
||||
fluidStack = new FluidStack( FluidRegistry.WATER, Fluid.BUCKET_VOLUME );
|
||||
}
|
||||
|
||||
TextureAtlasSprite sprite = bakedTextureGetter.apply( fluidStack.getFluid().getStill( fluidStack ) );
|
||||
if( sprite == null )
|
||||
{
|
||||
return new DummyFluidBakedModel( ImmutableList.of() );
|
||||
}
|
||||
|
||||
return new DummyFluidBakedModel( ItemLayerModel.getQuadsForSprite( 0, sprite, format, Optional.empty() ) );
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
/**
|
||||
* The model class for facades. Since facades wrap existing models, they don't declare any dependencies here other
|
||||
* than the cable anchor.
|
||||
*/
|
||||
public class DummyFluidItemModel implements IModel
|
||||
{
|
||||
// We use this to get the default item transforms and make our lives easier
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/dummy_fluid_item_base" );
|
||||
|
||||
private IModel baseModel = null;
|
||||
|
||||
private IModel getBaseModel()
|
||||
{
|
||||
if( this.baseModel == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
baseModel = ModelLoaderRegistry.getModel( MODEL_BASE );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
return this.baseModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
IBakedModel bakedBaseModel = this.getBaseModel().bake( state, format, bakedTextureGetter );
|
||||
|
||||
return new DummyFluidDispatcherBakedModel( bakedBaseModel, format, bakedTextureGetter );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return getBaseModel().getDefaultState();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user