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:
Brock
2018-06-12 03:55:33 +10:00
committed by yueh
parent 89bebc4385
commit d16677224a
126 changed files with 8031 additions and 778 deletions
+56 -7
View File
@@ -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