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:
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class FluidSorters
|
||||
{
|
||||
private static SortDir Direction = SortDir.ASCENDING;
|
||||
|
||||
public static final Comparator<IAEFluidStack> CONFIG_BASED_SORT_BY_NAME = new Comparator<IAEFluidStack>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare( final IAEFluidStack o1, final IAEFluidStack o2 )
|
||||
{
|
||||
if( getDirection() == SortDir.ASCENDING )
|
||||
{
|
||||
return Platform.getFluidDisplayName( o1 ).compareToIgnoreCase( Platform.getFluidDisplayName( o2 ) );
|
||||
}
|
||||
return Platform.getFluidDisplayName( o2 ).compareToIgnoreCase( Platform.getFluidDisplayName( o1 ) );
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<IAEFluidStack> CONFIG_BASED_SORT_BY_MOD = new Comparator<IAEFluidStack>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare( final IAEFluidStack o1, final IAEFluidStack o2 )
|
||||
{
|
||||
final AEFluidStack op1 = (AEFluidStack) o1;
|
||||
final AEFluidStack op2 = (AEFluidStack) o2;
|
||||
|
||||
if( getDirection() == SortDir.ASCENDING )
|
||||
{
|
||||
return this.secondarySort( Platform.getModId( op1 ).compareToIgnoreCase( Platform.getModId( op2 ) ), o2, o1 );
|
||||
}
|
||||
return this.secondarySort( Platform.getModId( op2 ).compareToIgnoreCase( Platform.getModId( op1 ) ), o1, o2 );
|
||||
}
|
||||
|
||||
private int secondarySort( final int compareToIgnoreCase, final IAEFluidStack o1, final IAEFluidStack o2 )
|
||||
{
|
||||
if( compareToIgnoreCase == 0 )
|
||||
{
|
||||
return Platform.getFluidDisplayName( o2 ).compareToIgnoreCase( Platform.getFluidDisplayName( o1 ) );
|
||||
}
|
||||
|
||||
return compareToIgnoreCase;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<IAEFluidStack> CONFIG_BASED_SORT_BY_SIZE = new Comparator<IAEFluidStack>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare( final IAEFluidStack o1, final IAEFluidStack o2 )
|
||||
{
|
||||
if( getDirection() == SortDir.ASCENDING )
|
||||
{
|
||||
return Long.compare( o2.getStackSize(), o1.getStackSize() );
|
||||
}
|
||||
return Long.compare( o1.getStackSize(), o2.getStackSize() );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private static SortDir getDirection()
|
||||
{
|
||||
return Direction;
|
||||
}
|
||||
|
||||
public static void setDirection( final SortDir direction )
|
||||
{
|
||||
Direction = direction;
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,8 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
@@ -121,6 +123,7 @@ import appeng.me.GridNode;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.util.helpers.ItemComparisonHelper;
|
||||
import appeng.util.helpers.P2PHelper;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.prioritylist.IPartitionList;
|
||||
|
||||
@@ -610,6 +613,17 @@ public class Platform
|
||||
return n == null ? "** Null" : n;
|
||||
}
|
||||
|
||||
public static String getModId( final IAEFluidStack fs )
|
||||
{
|
||||
if( fs == null || fs.getFluidStack() == null )
|
||||
{
|
||||
return "** Null";
|
||||
}
|
||||
|
||||
final String n = FluidRegistry.getModId( fs.getFluidStack() );
|
||||
return n == null ? "** Null" : n;
|
||||
}
|
||||
|
||||
public static String getItemDisplayName( final Object o )
|
||||
{
|
||||
if( o == null )
|
||||
@@ -655,6 +669,33 @@ public class Platform
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFluidDisplayName( Object o )
|
||||
{
|
||||
if( o == null )
|
||||
{
|
||||
return "** Null";
|
||||
}
|
||||
FluidStack fluidStack = null;
|
||||
if( o instanceof AEFluidStack )
|
||||
{
|
||||
fluidStack = ( (AEFluidStack) o ).getFluidStack();
|
||||
}
|
||||
else if( o instanceof FluidStack )
|
||||
{
|
||||
fluidStack = (FluidStack) o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "**Invalid Object";
|
||||
}
|
||||
String n = fluidStack.getLocalizedName();
|
||||
if( n == null || "".equalsIgnoreCase( n ) )
|
||||
{
|
||||
n = fluidStack.getUnlocalizedName();
|
||||
}
|
||||
return n == null ? "** Null" : n;
|
||||
}
|
||||
|
||||
public static boolean isWrench( final EntityPlayer player, final ItemStack eq, final BlockPos pos )
|
||||
{
|
||||
if( !eq.isEmpty() )
|
||||
|
||||
Reference in New Issue
Block a user