Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d5372a5ff6 | |||
| c8eb792d38 | |||
| f4ef7edf86 | |||
| 67c733b418 | |||
| fe4db2eb98 | |||
| 2891014cf6 | |||
| e809c688df | |||
| 71a9bb2532 | |||
| 3363acb7db | |||
| 8f6f35b9cf | |||
| ff75f34333 | |||
| e2c0129037 | |||
| 7fe7f4b1c2 | |||
| 693487504c | |||
| 883d9ba49b | |||
| fe8d824526 | |||
| d2250b115f | |||
| e5ab9df086 | |||
| 96af371882 | |||
| bde76d1fb1 | |||
| eb4caaa688 | |||
| 3ba04b3831 | |||
| 7cd8b72bb7 | |||
| 2182b6e37c | |||
| 5d26b98ab8 | |||
| 979531afb7 |
@@ -27,7 +27,7 @@ A Mod about Matter, Energy and using them to conquer the world..
|
||||
* [Website](http://ae-mod.info/)
|
||||
* [IRC #appliedenergistics on esper.net](http://webchat.esper.net/?channels=appliedenergistics&prompt=1)
|
||||
* [GitHub](https://github.com/AppliedEnergistics/Applied-Energistics-2)
|
||||
* [Discord](https://discord.gg/DJ9hVAN)
|
||||
* [Discord](https://discord.gg/GygKjjm)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ ic2_version=2.8.73-ex112
|
||||
top_version=1.12-1.4.23-16
|
||||
cofhcore_version=1.12.2-4.5.2.19
|
||||
crafttweaker_version=4.1.8.9
|
||||
inventorytweaks_version=1.63
|
||||
|
||||
#########################################################
|
||||
# Deployment #
|
||||
|
||||
@@ -68,6 +68,11 @@ repositories {
|
||||
name 'modmaven'
|
||||
url "https://modmaven.k-4u.nl/"
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@@ -88,7 +93,8 @@ dependencies {
|
||||
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
|
||||
compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf"
|
||||
compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}"
|
||||
|
||||
compileOnly "inventory-tweaks:InventoryTweaks:${inventorytweaks_version}:api"
|
||||
|
||||
// at runtime, use the full JEI jar
|
||||
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
|
||||
|
||||
|
||||
@@ -117,4 +117,10 @@ public interface IParts
|
||||
IItemDefinition fluidExportBus();
|
||||
|
||||
IItemDefinition fluidStorageBus();
|
||||
|
||||
IItemDefinition fluidLevelEmitter();
|
||||
|
||||
IItemDefinition fluidAnnihilationPlane();
|
||||
|
||||
IItemDefinition fluidFormationnPlane();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
|
||||
/**
|
||||
* Memory Card API
|
||||
@@ -41,13 +43,18 @@ public interface IMemoryCard
|
||||
* Configures the data stored on the memory card, the SettingsName, will be
|
||||
* localized when displayed.
|
||||
*
|
||||
* The data can contain an optional string with the key "tooltip", which will be used as
|
||||
* unlocalized string to display it after the settings name.
|
||||
*
|
||||
* The data can contain an optional intArray using "colorCode" to be displayed on the model itself.
|
||||
* It needs to have exactly 8 elements representing the ordinal of the matching {@link AEColor}.
|
||||
* The first 4 values represent the top row, left to right. The second 4 the bottom row.
|
||||
*
|
||||
* @param is item
|
||||
* @param SettingsName unlocalized string that represents the tile entity.
|
||||
* @param data may contain a String called "tooltip" which is is a
|
||||
* unlocalized string displayed after the settings name, optional
|
||||
* but can be used to add details to the card for later.
|
||||
* @param settingsName unlocalized string that represents the tile entity.
|
||||
* @param data the NBT tag, refer to the normal comment for special keys.
|
||||
*/
|
||||
void setMemoryCardContents( ItemStack is, String SettingsName, NBTTagCompound data );
|
||||
void setMemoryCardContents( ItemStack is, String settingsName, NBTTagCompound data );
|
||||
|
||||
/**
|
||||
* returns the settings name provided by a previous call to
|
||||
@@ -68,6 +75,17 @@ public interface IMemoryCard
|
||||
*/
|
||||
NBTTagCompound getData( ItemStack is );
|
||||
|
||||
/**
|
||||
* This represent as 4x2 grid of {@link AEColor} without transparent/fluix color.
|
||||
*
|
||||
* First 4 colors are used for the top row, second for the bottom one.
|
||||
*
|
||||
* @param is item
|
||||
*
|
||||
* @return a hash representation of the memory card content
|
||||
*/
|
||||
AEColor[] getColorCode( ItemStack is );
|
||||
|
||||
/**
|
||||
* notify the user of a outcome related to the memory card.
|
||||
*
|
||||
|
||||
@@ -209,6 +209,7 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
|
||||
* Called when you right click the part, very similar to Block.onActivateBlock
|
||||
*
|
||||
* @param player right clicking player
|
||||
* @param hand hand used
|
||||
* @param pos position of block
|
||||
*
|
||||
* @return if your activate method performed something.
|
||||
@@ -219,12 +220,41 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
|
||||
* Called when you right click the part, very similar to Block.onActivateBlock
|
||||
*
|
||||
* @param player shift right clicking player
|
||||
* @param hand hand used
|
||||
* @param pos position of block
|
||||
*
|
||||
* @return if your activate method performed something, you should use false unless you really need it.
|
||||
*/
|
||||
boolean onShiftActivate( EntityPlayer player, EnumHand hand, Vec3d pos );
|
||||
|
||||
/**
|
||||
* Called when you left click the part, very similar to Block.onBlockClicked
|
||||
*
|
||||
* @param player left clicking player
|
||||
* @param hand hand used
|
||||
* @param pos position of block
|
||||
*
|
||||
* @return if your activate method performed something, you should use false unless you really need it.
|
||||
*/
|
||||
default boolean onClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when you shift-left click the part, very similar to Block.onBlockClicked
|
||||
*
|
||||
* @param player shift-left clicking player
|
||||
* @param hand hand used
|
||||
* @param pos position of block
|
||||
*
|
||||
* @return if your activate method performed something, you should use false unless you really need it.
|
||||
*/
|
||||
default boolean onShiftClicked( EntityPlayer player, EnumHand hand, Vec3d pos )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add drops to the items being dropped into the world, if your item stores its contents when wrenched use the
|
||||
* wrenched boolean to control what data is saved vs dropped when it is broken.
|
||||
@@ -325,4 +355,14 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag to be passed to the renderer.
|
||||
*
|
||||
* @return flag or null
|
||||
*/
|
||||
default Long getRenderFlag()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
package appeng.api.parts;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
|
||||
|
||||
public interface IPartBakedModel
|
||||
{
|
||||
List<BakedQuad> getPartQuads( @Nullable Long partFlags, long rand );
|
||||
}
|
||||
@@ -52,12 +52,12 @@ public interface ICellHandler
|
||||
*
|
||||
* @param is a storage cell item.
|
||||
* @param host anytime the contents of your storage cell changes it should use this to request a save, please
|
||||
* note, this value can be null.
|
||||
* note, this value can be null. If provided, the host is responsible for persisting the cell content.
|
||||
* @param channel the storage channel requested.
|
||||
*
|
||||
* @return a new IMEHandler for the provided item
|
||||
*/
|
||||
<T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> channel );
|
||||
<T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> channel );
|
||||
|
||||
/**
|
||||
* Called when the storage cell is planed in an ME Chest and the user tries to open the terminal side, if your item
|
||||
|
||||
@@ -118,4 +118,9 @@ public interface ICellInventory<T extends IAEStack<T>> extends IMEInventory<T>
|
||||
* @return the status number for this drive.
|
||||
*/
|
||||
int getStatusForCell();
|
||||
|
||||
/**
|
||||
* Tells the cell to persist to NBT
|
||||
*/
|
||||
void persist();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface ICellInventoryHandler<T extends IAEStack<T>> extends IMEInvento
|
||||
/**
|
||||
* @return get access to the Cell Inventory.
|
||||
*/
|
||||
ICellInventory getCellInv();
|
||||
ICellInventory<T> getCellInv();
|
||||
|
||||
boolean isPreformatted();
|
||||
|
||||
|
||||
@@ -77,11 +77,11 @@ public interface ICellRegistry
|
||||
* returns an IMEInventoryHandler for the provided item.
|
||||
*
|
||||
* @param is item with inventory handler
|
||||
* @param host can be null, or the hosting tile / part.
|
||||
* @param host can be null. If provided, the host is responsible for persisting the cell content.
|
||||
* @param chan the storage channel to request the handler for.
|
||||
*
|
||||
* @return new IMEInventoryHandler, or null if there isn't one.
|
||||
*/
|
||||
@Nullable
|
||||
<T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> chan );
|
||||
<T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> chan );
|
||||
}
|
||||
@@ -24,8 +24,11 @@
|
||||
package appeng.api.storage;
|
||||
|
||||
|
||||
/**
|
||||
* Tells the cell provider that changes have been made an the cell must be persisted
|
||||
*
|
||||
*/
|
||||
public interface ISaveProvider
|
||||
{
|
||||
|
||||
void saveChanges( IMEInventory<?> cellInventory );
|
||||
void saveChanges( ICellInventory<?> cellInventory );
|
||||
}
|
||||
|
||||
@@ -37,17 +37,13 @@ import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.entity.EntityIds;
|
||||
import appeng.entity.EntityTinyTNTPrimed;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
|
||||
@@ -67,9 +63,6 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
|
||||
|
||||
this.setSoundType( SoundType.GROUND );
|
||||
this.setHardness( 0F );
|
||||
|
||||
EntityRegistry.registerModEntity( new ResourceLocation( AppEng.MOD_ID, EntityTinyTNTPrimed.class.getName() ), EntityTinyTNTPrimed.class,
|
||||
"EntityTinyTNTPrimed", EntityIds.get( EntityTinyTNTPrimed.class ), AppEng.instance(), 16, 4, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult.Type;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -70,6 +71,8 @@ import appeng.client.render.cablebus.CableBusBakedModel;
|
||||
import appeng.client.render.cablebus.CableBusRenderState;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.parts.ICableBusContainer;
|
||||
import appeng.parts.NullCableBusContainer;
|
||||
@@ -353,6 +356,31 @@ public class BlockCableBus extends AEBaseTileBlock
|
||||
return out == null ? NULL_CABLE_BUS : out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked( World worldIn, BlockPos pos, EntityPlayer playerIn )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
final RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver;
|
||||
if( rtr != null && rtr.typeOfHit == Type.BLOCK && pos.equals( rtr.getBlockPos() ) )
|
||||
{
|
||||
final Vec3d hitVec = rtr.hitVec.subtract( new Vec3d( pos ) );
|
||||
|
||||
if( this.cb( worldIn, pos ).clicked( playerIn, EnumHand.MAIN_HAND, hitVec ) )
|
||||
{
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(
|
||||
new PacketClick( pos, rtr.sideHit, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, EnumHand.MAIN_HAND, true ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockClickPacket( World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, Vec3d hitVec )
|
||||
{
|
||||
this.cb( worldIn, pos ).clicked( playerIn, hand, hitVec );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
|
||||
@@ -144,7 +144,7 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||
item.setCreativeTab( this.creativeTab );
|
||||
|
||||
// Register all extra handlers
|
||||
this.boostrapComponents.forEach( component -> component.apply( item ) );
|
||||
this.boostrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( item ) ) );
|
||||
|
||||
// Register custom dispenser behavior if requested
|
||||
if( this.dispenserBehaviorSupplier != null )
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package appeng.bootstrap.components;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import appeng.bootstrap.IBootstrapComponent;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IEntityRegistrationComponent extends IBootstrapComponent
|
||||
{
|
||||
void entityRegistration( IForgeRegistry<EntityEntry> entityRegistry );
|
||||
}
|
||||
@@ -26,10 +26,8 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -42,6 +40,7 @@ import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
@@ -85,30 +84,14 @@ public class ClientHelper extends ServerHelper
|
||||
{
|
||||
ModelLoaderRegistry.registerLoader( UVLModelLoader.INSTANCE );
|
||||
}
|
||||
|
||||
RenderingRegistry.registerEntityRenderingHandler( EntityTinyTNTPrimed.class, manager -> new RenderTinyTNTPrimed( manager ) );
|
||||
RenderingRegistry.registerEntityRenderingHandler( EntityFloatingItem.class, manager -> new RenderFloatingItem( manager ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
// final Block fluixBlock = GameRegistry.findBlock( "appliedenergistics2", "fluix" );
|
||||
// Item fluixItem = Item.getItemFromBlock( fluixBlock );
|
||||
// ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation( "appliedenergistics2:fluix",
|
||||
// "inventory" );
|
||||
// final int DEFAULT_ITEM_SUBTYPE = 0;
|
||||
// final ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
|
||||
// // mesher.register( fluixItem, DEFAULT_ITEM_SUBTYPE, itemModelResourceLocation );
|
||||
//
|
||||
// final ResourceLocation resource = new ResourceLocation( "appliedenergistics2", "stair.fluix" );
|
||||
// final ModelResourceLocation fluixStairModel = new ModelResourceLocation( resource, "inventory" );
|
||||
// AELog.info( "FluixStairModel: " + fluixStairModel );
|
||||
//
|
||||
// final Set<Item> items = AEApi.instance().definitions().blocks().fluixStairs().maybeItem().asSet();
|
||||
// for( Item item : items )
|
||||
// {
|
||||
// AELog.info( "Registering with %s with unlocalized %s", item, item.getUnlocalizedName() );
|
||||
// mesher.register( item, DEFAULT_ITEM_SUBTYPE, fluixStairModel );
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,11 +182,6 @@ public class ClientHelper extends ServerHelper
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
// RenderingRegistry.registerBlockHandler( WorldRender.INSTANCE );
|
||||
final RenderManager inst = Minecraft.getMinecraft().getRenderManager();
|
||||
|
||||
inst.entityRenderMap.put( EntityTinyTNTPrimed.class, new RenderTinyTNTPrimed( inst ) );
|
||||
inst.entityRenderMap.put( EntityFloatingItem.class, new RenderFloatingItem( inst ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -330,29 +308,20 @@ public class ClientHelper extends ServerHelper
|
||||
final EntityPlayer player = mc.player;
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
final EnumHand hand;
|
||||
if( !player.getHeldItem( EnumHand.MAIN_HAND ).isEmpty() && player.getHeldItem( EnumHand.MAIN_HAND ).getItem() instanceof IMouseWheelItem )
|
||||
{
|
||||
hand = EnumHand.MAIN_HAND;
|
||||
}
|
||||
else if( !player.getHeldItem( EnumHand.OFF_HAND ).isEmpty() && player.getHeldItem( EnumHand.OFF_HAND ).getItem() instanceof IMouseWheelItem )
|
||||
{
|
||||
hand = EnumHand.OFF_HAND;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
final boolean mainHand = player.getHeldItem( EnumHand.MAIN_HAND ).getItem() instanceof IMouseWheelItem;
|
||||
final boolean offHand = player.getHeldItem( EnumHand.OFF_HAND ).getItem() instanceof IMouseWheelItem;
|
||||
|
||||
final ItemStack is = player.getHeldItem( hand );
|
||||
try
|
||||
if( mainHand || offHand )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Item", me.getDwheel() > 0 ? "WheelUp" : "WheelDown" ) );
|
||||
me.setCanceled( true );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "Item", me.getDwheel() > 0 ? "WheelUp" : "WheelDown" ) );
|
||||
me.setCanceled( true );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,10 @@ 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.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.widgets.GuiCustomSlot;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
@@ -84,7 +85,6 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.fluids.client.render.FluidStackSizeRenderer;
|
||||
import appeng.fluids.container.slots.IFluidSlot;
|
||||
import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.helpers.InventoryAction;
|
||||
|
||||
@@ -101,6 +101,7 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
private Stopwatch dbl_clickTimer = Stopwatch.createStarted();
|
||||
private ItemStack dbl_whichItem = ItemStack.EMPTY;
|
||||
private Slot bl_clicked;
|
||||
protected final List<GuiCustomSlot> guiSlots = new ArrayList<>();
|
||||
|
||||
public AEBaseGui( final Container container )
|
||||
{
|
||||
@@ -154,35 +155,76 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen( final int mouseX, final int mouseY, final float btn )
|
||||
public void drawScreen( final int mouseX, final int mouseY, final float partialTicks )
|
||||
{
|
||||
super.drawDefaultBackground();
|
||||
super.drawScreen( mouseX, mouseY, btn );
|
||||
super.drawScreen( mouseX, mouseY, partialTicks );
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate( (float) this.guiLeft, (float) this.guiTop, 0.0F );
|
||||
GlStateManager.enableDepth();
|
||||
for( final GuiCustomSlot c : this.guiSlots )
|
||||
{
|
||||
drawGuiSlot( c, mouseX, mouseY, partialTicks );
|
||||
}
|
||||
GlStateManager.disableDepth();
|
||||
for( final GuiCustomSlot c : this.guiSlots )
|
||||
{
|
||||
drawTooltip( c, mouseX - this.guiLeft, mouseY - this.guiTop );
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
this.renderHoveredToolTip( mouseX, mouseY );
|
||||
|
||||
for( final Object c : this.buttonList )
|
||||
{
|
||||
if( c instanceof ITooltip )
|
||||
{
|
||||
final ITooltip tooltip = (ITooltip) c;
|
||||
final int x = tooltip.xPos(); // ((GuiImgButton) c).x;
|
||||
int y = tooltip.yPos(); // ((GuiImgButton) c).y;
|
||||
drawTooltip( (ITooltip) c, mouseX, mouseY );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible() )
|
||||
protected void drawGuiSlot( GuiCustomSlot slot, int mouseX, int mouseY, float partialTicks )
|
||||
{
|
||||
if( slot.isSlotEnabled() )
|
||||
{
|
||||
final int left = slot.xPos();
|
||||
final int top = slot.yPos();
|
||||
final int right = left + slot.getWidth();
|
||||
final int bottom = top + slot.getHeight();
|
||||
|
||||
slot.drawContent( this.mc, mouseX, mouseY, partialTicks );
|
||||
|
||||
if( this.isPointInRegion( left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY ) && slot.canClick( this.mc.player ) )
|
||||
{
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.colorMask( true, true, true, false );
|
||||
this.drawGradientRect( left, top, right, bottom, -2130706433, -2130706433 );
|
||||
GlStateManager.colorMask( true, true, true, true );
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawTooltip( ITooltip tooltip, int mouseX, int mouseY )
|
||||
{
|
||||
final int x = tooltip.xPos(); // ((GuiImgButton) c).x;
|
||||
int y = tooltip.yPos(); // ((GuiImgButton) c).y;
|
||||
|
||||
if( x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible() )
|
||||
{
|
||||
if( y < mouseY && y + tooltip.getHeight() > mouseY )
|
||||
{
|
||||
if( y < 15 )
|
||||
{
|
||||
if( y < mouseY && y + tooltip.getHeight() > mouseY )
|
||||
{
|
||||
if( y < 15 )
|
||||
{
|
||||
y = 15;
|
||||
}
|
||||
y = 15;
|
||||
}
|
||||
|
||||
final String msg = tooltip.getMessage();
|
||||
if( msg != null )
|
||||
{
|
||||
this.drawTooltip( x + 11, y + 4, msg );
|
||||
}
|
||||
}
|
||||
final String msg = tooltip.getMessage();
|
||||
if( msg != null )
|
||||
{
|
||||
this.drawTooltip( x + 11, y + 4, msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,23 +258,6 @@ 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 IFluidSlot )
|
||||
{
|
||||
IFluidSlot fluidSlot = (IFluidSlot) slot;
|
||||
if( fluidSlot.getFluidStack() != null && fluidSlot.shouldRenderAsFluid() )
|
||||
{
|
||||
FluidStack fluidStack = fluidSlot.getFluidStack();
|
||||
this.drawHoveringText( fluidStack.getLocalizedName(), mouseX, mouseY );
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.renderHoveredToolTip( mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void drawGuiContainerForegroundLayer( final int x, final int y )
|
||||
{
|
||||
@@ -285,6 +310,12 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( final GuiCustomSlot slot : this.guiSlots )
|
||||
{
|
||||
slot.drawBackground( ox, oy );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -305,6 +336,14 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
}
|
||||
}
|
||||
|
||||
for( GuiCustomSlot slot : this.guiSlots )
|
||||
{
|
||||
if( this.isPointInRegion( slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord ) && slot.canClick( this.mc.player ) )
|
||||
{
|
||||
slot.slotClicked( this.mc.player.inventory.getItemStack(), btn );
|
||||
}
|
||||
}
|
||||
|
||||
if( this.getScrollBar() != null )
|
||||
{
|
||||
this.getScrollBar().click( this, xCoord - this.guiLeft, yCoord - this.guiTop );
|
||||
@@ -516,11 +555,11 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
return;
|
||||
}
|
||||
|
||||
if( !this.disableShiftClick && isShiftKeyDown() )
|
||||
if( !this.disableShiftClick && isShiftKeyDown() && mouseButton == 0 )
|
||||
{
|
||||
this.disableShiftClick = true;
|
||||
|
||||
if( this.dbl_whichItem.isEmpty() || this.bl_clicked != slot || this.dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 150 )
|
||||
if( this.dbl_whichItem.isEmpty() || this.bl_clicked != slot || this.dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 250 )
|
||||
{
|
||||
// some simple double click logic.
|
||||
this.bl_clicked = slot;
|
||||
@@ -542,12 +581,13 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
for( final Slot inventorySlot : slots )
|
||||
{
|
||||
if( inventorySlot != null && inventorySlot.canTakeStack(
|
||||
this.mc.player ) && inventorySlot.getHasStack() && inventorySlot.inventory == slot.inventory && Container.canAddItemToSlot(
|
||||
this.mc.player ) && inventorySlot.getHasStack() && inventorySlot.isSameInventory( slot ) && Container.canAddItemToSlot(
|
||||
inventorySlot, this.dbl_whichItem, true ) )
|
||||
{
|
||||
this.handleMouseClick( inventorySlot, inventorySlot.slotNumber, 1, clickType );
|
||||
this.handleMouseClick( inventorySlot, inventorySlot.slotNumber, 0, ClickType.QUICK_MOVE );
|
||||
}
|
||||
}
|
||||
this.dbl_whichItem = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
this.disableShiftClick = false;
|
||||
@@ -743,18 +783,18 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
|
||||
return;
|
||||
}
|
||||
else if( s instanceof IFluidSlot && ( (IFluidSlot) s ).shouldRenderAsFluid() )
|
||||
else if( s instanceof IMEFluidSlot && ( (IMEFluidSlot) s ).shouldRenderAsFluid() )
|
||||
{
|
||||
final IFluidSlot slot = (IFluidSlot) s;
|
||||
final FluidStack fs = slot.getFluidStack();
|
||||
final IMEFluidSlot slot = (IMEFluidSlot) s;
|
||||
final IAEFluidStack fs = slot.getAEFluidStack();
|
||||
|
||||
if( fs != null && this.isPowered() )
|
||||
{
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.disableBlend();
|
||||
Fluid fluid = fs.getFluid();
|
||||
final Fluid fluid = fs.getFluid();
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
|
||||
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( fluid.getStill().toString() );
|
||||
final TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( fluid.getStill().toString() );
|
||||
|
||||
// Set color for dynamic fluids
|
||||
// Convert int color to RGB
|
||||
@@ -767,11 +807,7 @@ public abstract class AEBaseGui extends GuiContainer
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
if( s instanceof IMEFluidSlot )
|
||||
{
|
||||
final IMEFluidSlot meFluidSlot = (IMEFluidSlot) s;
|
||||
this.fluidStackSizeRenderer.renderStackSize( this.fontRenderer, meFluidSlot.getAEFluidStack(), s.xPos, s.yPos );
|
||||
}
|
||||
this.fluidStackSizeRenderer.renderStackSize( this.fontRenderer, fs, s.xPos, s.yPos );
|
||||
}
|
||||
else if( !this.isPowered() )
|
||||
{
|
||||
|
||||
@@ -95,6 +95,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
private GuiImgButton SortDirBox;
|
||||
private GuiImgButton searchBoxSettings;
|
||||
private GuiImgButton terminalStyleBox;
|
||||
private boolean isAutoFocus = false;
|
||||
private int currentMouseX = 0;
|
||||
private int currentMouseY = 0;
|
||||
|
||||
public GuiMEMonitorable( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
|
||||
{
|
||||
@@ -224,8 +227,10 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
Keyboard.enableRepeatEvents( true );
|
||||
|
||||
this.maxRows = this.getMaxRows();
|
||||
this.perRow = AEConfig.instance().getConfigManager().getSetting(
|
||||
Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ( ( this.width - this.standardSize ) / 18 );
|
||||
this.perRow = AEConfig.instance()
|
||||
.getConfigManager()
|
||||
.getSetting(
|
||||
Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ( ( this.width - this.standardSize ) / 18 );
|
||||
|
||||
final int magicNumber = 114 + 1;
|
||||
final int extraSpace = this.height - magicNumber - this.reservedSpace;
|
||||
@@ -290,8 +295,10 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
offset += 20;
|
||||
|
||||
this.buttonList.add(
|
||||
this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance().getConfigManager().getSetting(
|
||||
Settings.SEARCH_MODE ) ) );
|
||||
this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance()
|
||||
.getConfigManager()
|
||||
.getSetting(
|
||||
Settings.SEARCH_MODE ) ) );
|
||||
|
||||
offset += 20;
|
||||
|
||||
@@ -306,7 +313,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.searchField.setEnableBackgroundDrawing( false );
|
||||
this.searchField.setMaxStringLength( 25 );
|
||||
this.searchField.setTextColor( 0xFFFFFF );
|
||||
this.searchField.setSelectionColor( 0xFF99FF99 );
|
||||
this.searchField.setSelectionColor( 0xFF008000 );
|
||||
this.searchField.setVisible( true );
|
||||
|
||||
if( this.viewCell || this instanceof GuiWirelessTerm )
|
||||
@@ -318,13 +325,11 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
|
||||
final Enum searchModeSetting = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE );
|
||||
|
||||
final boolean isAutoFocus = SearchBoxMode.AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting;
|
||||
final boolean isManualFocus = SearchBoxMode.MANUAL_SEARCH == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH == searchModeSetting || SearchBoxMode.MANUAL_SEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchModeSetting;
|
||||
this.isAutoFocus = SearchBoxMode.AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting;
|
||||
final boolean isKeepFilter = SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.MANUAL_SEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchModeSetting;
|
||||
final boolean isJEIEnabled = SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH == searchModeSetting;
|
||||
|
||||
this.searchField.setFocused( isAutoFocus );
|
||||
this.searchField.setCanLoseFocus( isManualFocus );
|
||||
this.searchField.setFocused( this.isAutoFocus );
|
||||
|
||||
if( isJEIEnabled )
|
||||
{
|
||||
@@ -374,6 +379,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
{
|
||||
this.fontRenderer.drawString( this.getGuiDisplayName( this.myName.getLocal() ), 8, 6, 4210752 );
|
||||
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
||||
|
||||
this.currentMouseX = mouseX;
|
||||
this.currentMouseY = mouseY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -470,18 +478,40 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
{
|
||||
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if( key == Keyboard.KEY_TAB )
|
||||
{
|
||||
this.searchField.setFocused( !this.searchField.isFocused() );
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.searchField.isFocused() && key == Keyboard.KEY_RETURN )
|
||||
{
|
||||
this.searchField.setFocused( false );
|
||||
return;
|
||||
}
|
||||
|
||||
if( character == ' ' && this.searchField.getText().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean mouseInGui = this.isPointInRegion( 0, 0, this.xSize, this.ySize, this.currentMouseX, this.currentMouseY );
|
||||
|
||||
if( this.isAutoFocus && !this.searchField.isFocused() && mouseInGui )
|
||||
{
|
||||
this.searchField.setFocused( true );
|
||||
}
|
||||
|
||||
if( this.searchField.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
this.repo.setSearchString( this.searchField.getText() );
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
// tell forge the key event is handled and should not be sent out
|
||||
this.keyHandled = mouseInGui;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -25,14 +25,9 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
@@ -42,12 +37,6 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
|
||||
|
||||
public class GuiPriority extends AEBaseGui
|
||||
@@ -92,49 +81,11 @@ public class GuiPriority extends AEBaseGui
|
||||
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
|
||||
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
|
||||
|
||||
ItemStack myIcon = null;
|
||||
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
final ContainerPriority con = ( (ContainerPriority) this.inventorySlots );
|
||||
final ItemStack myIcon = con.getPriorityHost().getItemStackRepresentation();
|
||||
this.OriginalGui = con.getPriorityHost().getGuiBridge();
|
||||
|
||||
if( target instanceof PartStorageBus )
|
||||
{
|
||||
myIcon = parts.storageBus().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_STORAGEBUS;
|
||||
}
|
||||
|
||||
if( target instanceof PartFormationPlane )
|
||||
{
|
||||
myIcon = parts.formationPlane().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_FORMATION_PLANE;
|
||||
}
|
||||
|
||||
if( target instanceof TileDrive )
|
||||
{
|
||||
myIcon = blocks.drive().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_DRIVE;
|
||||
}
|
||||
|
||||
if( target instanceof TileChest )
|
||||
{
|
||||
myIcon = blocks.chest().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_CHEST;
|
||||
}
|
||||
|
||||
if( target instanceof TileInterface )
|
||||
{
|
||||
myIcon = blocks.iface().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
if( target instanceof PartInterface )
|
||||
{
|
||||
myIcon = parts.iface().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
if( this.OriginalGui != null && myIcon != null )
|
||||
if( this.OriginalGui != null && !myIcon.isEmpty() )
|
||||
{
|
||||
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender ) );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public abstract class GuiCustomSlot extends Gui implements ITooltip
|
||||
{
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int id;
|
||||
|
||||
public GuiCustomSlot( final int id, final int x, final int y )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean canClick( final EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void slotClicked( final ItemStack clickStack, final int mouseButton )
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks );
|
||||
|
||||
public void drawBackground( int guileft, int guitop )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,6 +43,7 @@ public class MEGuiTextField extends GuiTextField
|
||||
private final int _yPos;
|
||||
private final int _width;
|
||||
private final int _height;
|
||||
private final int _fontPad;
|
||||
private int selectionColor = 0xFF00FF00;
|
||||
|
||||
/**
|
||||
@@ -59,6 +60,7 @@ public class MEGuiTextField extends GuiTextField
|
||||
{
|
||||
super( 0, fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth( '_' ), height - 2 * PADDING );
|
||||
|
||||
this._fontPad = fontRenderer.getCharWidth( '_' );
|
||||
this._xPos = xPos;
|
||||
this._yPos = yPos;
|
||||
this._width = width;
|
||||
@@ -106,9 +108,31 @@ public class MEGuiTextField extends GuiTextField
|
||||
this.selectionColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextBox()
|
||||
{
|
||||
if( this.getVisible() )
|
||||
{
|
||||
if( this.isFocused() )
|
||||
{
|
||||
drawRect( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
|
||||
0xFF606060 );
|
||||
}
|
||||
else
|
||||
{
|
||||
drawRect( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
|
||||
0xFFA8A8A8 );
|
||||
}
|
||||
super.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelectionBox( int startX, int startY, int endX, int endY )
|
||||
{
|
||||
if( !this.isFocused() )
|
||||
return;
|
||||
|
||||
if( startX < endX )
|
||||
{
|
||||
int i = startX;
|
||||
@@ -159,4 +183,5 @@ public class MEGuiTextField extends GuiTextField
|
||||
GlStateManager.disableColorLogic();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
package appeng.client.me;
|
||||
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
|
||||
|
||||
@@ -45,11 +43,6 @@ public class InternalFluidSlotME
|
||||
this.yPos = displayY;
|
||||
}
|
||||
|
||||
FluidStack getStack()
|
||||
{
|
||||
return this.getAEStack() == null ? null : this.getAEStack().getFluidStack();
|
||||
}
|
||||
|
||||
IAEFluidStack getAEStack()
|
||||
{
|
||||
return this.repo.getReferenceFluid( this.offset );
|
||||
|
||||
@@ -24,7 +24,6 @@ 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;
|
||||
@@ -70,12 +69,6 @@ public class SlotFluidME extends SlotItemHandler implements IMEFluidSlot
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluidStack()
|
||||
{
|
||||
return this.slot.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack()
|
||||
{
|
||||
|
||||
@@ -44,6 +44,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.api.parts.IPartBakedModel;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
@@ -119,7 +120,15 @@ public class CableBusBakedModel implements IBakedModel
|
||||
throw new IllegalStateException( "Trying to use an unregistered part model: " + model );
|
||||
}
|
||||
|
||||
List<BakedQuad> partQuads = bakedModel.getQuads( state, null, rand );
|
||||
List<BakedQuad> partQuads;
|
||||
if( bakedModel instanceof IPartBakedModel )
|
||||
{
|
||||
partQuads = ( (IPartBakedModel) bakedModel ).getPartQuads( renderState.getPartFlags().get( facing ), rand );
|
||||
}
|
||||
else
|
||||
{
|
||||
partQuads = bakedModel.getQuads( state, null, rand );
|
||||
}
|
||||
|
||||
// Rotate quads accordingly
|
||||
QuadRotator rotator = new QuadRotator();
|
||||
|
||||
@@ -74,6 +74,8 @@ public class CableBusRenderState
|
||||
// facades on this cable bus
|
||||
private List<AxisAlignedBB> boundingBoxes = new ArrayList<>();
|
||||
|
||||
private EnumMap<EnumFacing, Long> partFlags = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
public CableCoreType getCoreType()
|
||||
{
|
||||
return this.coreType;
|
||||
@@ -154,6 +156,11 @@ public class CableBusRenderState
|
||||
return this.boundingBoxes;
|
||||
}
|
||||
|
||||
public EnumMap<EnumFacing, Long> getPartFlags()
|
||||
{
|
||||
return this.partFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
@@ -166,6 +173,7 @@ public class CableBusRenderState
|
||||
result = prime * result + ( ( this.channelsOnSide == null ) ? 0 : this.channelsOnSide.hashCode() );
|
||||
result = prime * result + ( ( this.connectionTypes == null ) ? 0 : this.connectionTypes.hashCode() );
|
||||
result = prime * result + ( ( this.coreType == null ) ? 0 : this.coreType.hashCode() );
|
||||
result = prime * result + ( ( this.partFlags == null ) ? 0 : this.partFlags.hashCode() );
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -190,7 +198,7 @@ public class CableBusRenderState
|
||||
return this.cableColor == other.cableColor && this.cableType == other.cableType && this.coreType == other.coreType && Objects
|
||||
.equals( this.attachmentConnections, other.attachmentConnections ) && Objects.equals( this.cableBusAdjacent,
|
||||
other.cableBusAdjacent ) && Objects.equals( this.channelsOnSide, other.channelsOnSide ) && Objects.equals( this.connectionTypes,
|
||||
other.connectionTypes );
|
||||
other.connectionTypes ) && Objects.equals( this.partFlags, other.partFlags );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
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.util.EnumFacing;
|
||||
|
||||
import appeng.api.parts.IPartBakedModel;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedModel
|
||||
{
|
||||
private final VertexFormat format;
|
||||
private final TextureAtlasSprite texture;
|
||||
|
||||
private final static Cache<Long, List<BakedQuad>> modelCache = CacheBuilder.newBuilder().maximumSize( 100 ).build();
|
||||
|
||||
private static final int[][] QUAD_OFFSETS = new int[][] {
|
||||
{ 4, 10, 2 },
|
||||
{ 10, 10, 2 },
|
||||
{ 4, 4, 2 },
|
||||
{ 10, 4, 2 }
|
||||
};
|
||||
|
||||
public P2PTunnelFrequencyBakedModel( final VertexFormat format, final TextureAtlasSprite texture )
|
||||
{
|
||||
this.format = format;
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getPartQuads( Long partFlags, long rand )
|
||||
{
|
||||
try
|
||||
{
|
||||
return modelCache.get( partFlags, () ->
|
||||
{
|
||||
short frequency = 0;
|
||||
boolean active = false;
|
||||
if( partFlags != null )
|
||||
{
|
||||
frequency = (short) ( partFlags.longValue() & 0xffffL );
|
||||
active = ( partFlags.longValue() & 0x10000L ) != 0;
|
||||
}
|
||||
return getQuadsForFrequency( frequency, active );
|
||||
} );
|
||||
}
|
||||
catch( ExecutionException e )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( IBlockState state, EnumFacing side, long rand )
|
||||
{
|
||||
if( side != null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getPartQuads( null, rand );
|
||||
}
|
||||
|
||||
private List<BakedQuad> getQuadsForFrequency( final short frequency, final boolean active )
|
||||
{
|
||||
final AEColor[] colors = Platform.p2p().toColors( frequency );
|
||||
final CubeBuilder cb = new CubeBuilder( this.format );
|
||||
|
||||
cb.setTexture( this.texture );
|
||||
cb.useStandardUV();
|
||||
cb.setRenderFullBright( active );
|
||||
|
||||
for( int i = 0; i < 4; ++i )
|
||||
{
|
||||
final int[] offs = QUAD_OFFSETS[i];
|
||||
for( int j = 0; j < 4; ++j )
|
||||
{
|
||||
final AEColor c = colors[j];
|
||||
if( active )
|
||||
{
|
||||
cb.setColorRGB( c.dye.getColorValue() );
|
||||
}
|
||||
else
|
||||
{
|
||||
final float cv[] = c.dye.getColorComponentValues();
|
||||
cb.setColorRGB( cv[0] * 0.5f, cv[1] * 0.5f, cv[2] * 0.5f );
|
||||
}
|
||||
|
||||
final int startx = j % 2;
|
||||
final int starty = 1 - j / 2;
|
||||
|
||||
cb.addCube( offs[0] + startx, offs[1] + starty, offs[2], offs[0] + startx + 1, offs[1] + starty + 1, offs[2] + 1 );
|
||||
}
|
||||
|
||||
}
|
||||
return cb.getOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return ItemOverrideList.NONE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
|
||||
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.common.model.IModelState;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
public class P2PTunnelFrequencyModel implements IModel
|
||||
{
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "parts/p2p_tunnel_frequency" );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Collections.singletonList( TEXTURE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
try
|
||||
{
|
||||
final TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE );
|
||||
return new P2PTunnelFrequencyBakedModel( format, texture );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
@@ -216,9 +215,9 @@ class BiometricCardBakedModel implements IBakedModel
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type )
|
||||
{
|
||||
// Delegate to the base model if possible
|
||||
if( this.baseModel instanceof IModel )
|
||||
if( this.baseModel instanceof IBakedModel )
|
||||
{
|
||||
IBakedModel pam = (IBakedModel) this.baseModel;
|
||||
IBakedModel pam = this.baseModel;
|
||||
Pair<? extends IBakedModel, Matrix4f> pair = pam.handlePerspective( type );
|
||||
return Pair.of( this, pair.getValue() );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
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.ItemCameraTransforms;
|
||||
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.world.World;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
||||
class MemoryCardBakedModel implements IBakedModel
|
||||
{
|
||||
private static final AEColor[] DEFAULT_COLOR_CODE = new AEColor[] {
|
||||
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
|
||||
AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT, AEColor.TRANSPARENT,
|
||||
};
|
||||
|
||||
private final VertexFormat format;
|
||||
|
||||
private final IBakedModel baseModel;
|
||||
|
||||
private final TextureAtlasSprite texture;
|
||||
|
||||
private final AEColor[] colorCode;
|
||||
|
||||
private final Cache<CacheKey, MemoryCardBakedModel> modelCache;
|
||||
|
||||
private final ImmutableList<BakedQuad> generalQuads;
|
||||
|
||||
MemoryCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture )
|
||||
{
|
||||
this( format, baseModel, texture, DEFAULT_COLOR_CODE, createCache() );
|
||||
}
|
||||
|
||||
private MemoryCardBakedModel( VertexFormat format, IBakedModel baseModel, TextureAtlasSprite texture, AEColor[] hash, Cache<CacheKey, MemoryCardBakedModel> modelCache )
|
||||
{
|
||||
this.format = format;
|
||||
this.baseModel = baseModel;
|
||||
this.texture = texture;
|
||||
this.colorCode = hash;
|
||||
this.generalQuads = ImmutableList.copyOf( this.buildGeneralQuads() );
|
||||
this.modelCache = modelCache;
|
||||
}
|
||||
|
||||
private static Cache<CacheKey, MemoryCardBakedModel> createCache()
|
||||
{
|
||||
return CacheBuilder.newBuilder()
|
||||
.maximumSize( 100 )
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand )
|
||||
{
|
||||
|
||||
List<BakedQuad> quads = this.baseModel.getQuads( state, side, rand );
|
||||
|
||||
if( side != null )
|
||||
{
|
||||
return quads;
|
||||
}
|
||||
|
||||
List<BakedQuad> result = new ArrayList<>( quads.size() + this.generalQuads.size() );
|
||||
result.addAll( quads );
|
||||
result.addAll( this.generalQuads );
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<BakedQuad> buildGeneralQuads()
|
||||
{
|
||||
CubeBuilder builder = new CubeBuilder( this.format );
|
||||
|
||||
builder.setTexture( this.texture );
|
||||
|
||||
for( int x = 0; x < 4; x++ )
|
||||
{
|
||||
for( int y = 0; y < 2; y++ )
|
||||
{
|
||||
final AEColor color = this.colorCode[x + y * 4];
|
||||
|
||||
builder.setColorRGB( color.mediumVariant );
|
||||
builder.addCube( 7 + x, 8 + ( 1 - y ), 7.5f, 7 + x + 1, 8 + ( 1 - y ) + 1, 8.5f );
|
||||
}
|
||||
}
|
||||
|
||||
return builder.getOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
return this.baseModel.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
return this.baseModel.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
return this.baseModel.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return this.baseModel.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return this.baseModel.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
return new ItemOverrideList( Collections.emptyList() )
|
||||
{
|
||||
@Override
|
||||
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( stack.getItem() instanceof IMemoryCard )
|
||||
{
|
||||
final IMemoryCard memoryCard = (IMemoryCard) stack.getItem();
|
||||
final AEColor[] colors = memoryCard.getColorCode( stack );
|
||||
|
||||
return MemoryCardBakedModel.this.modelCache.get( new CacheKey( colors ),
|
||||
() -> new MemoryCardBakedModel( MemoryCardBakedModel.this.format, MemoryCardBakedModel.this.baseModel, MemoryCardBakedModel.this.texture, colors, MemoryCardBakedModel.this.modelCache ) );
|
||||
}
|
||||
}
|
||||
catch( ExecutionException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
return MemoryCardBakedModel.this;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType type )
|
||||
{
|
||||
// Delegate to the base model if possible
|
||||
if( this.baseModel instanceof IBakedModel )
|
||||
{
|
||||
IBakedModel pam = this.baseModel;
|
||||
Pair<? extends IBakedModel, Matrix4f> pair = pam.handlePerspective( type );
|
||||
return Pair.of( this, pair.getValue() );
|
||||
}
|
||||
return Pair.of( this, TRSRTransformation.identity().getMatrix() );
|
||||
}
|
||||
|
||||
private static class CacheKey
|
||||
{
|
||||
private final AEColor[] key;
|
||||
|
||||
CacheKey( AEColor[] key )
|
||||
{
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + Arrays.hashCode( this.key );
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if( this == obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( obj == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( this.getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CacheKey other = (CacheKey) obj;
|
||||
return Arrays.equals( this.key, other.key );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
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 net.minecraftforge.common.model.TRSRTransformation;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
/**
|
||||
* Model wrapper for the memory card item model, which combines a base card layer with a "visual hash" of the part/tile.
|
||||
*/
|
||||
public class MemoryCardModel implements IModel
|
||||
{
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/memory_card" );
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation( AppEng.MOD_ID, "items/memory_card_hash" );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.singletonList( MODEL_BASE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Collections.singletonList( TEXTURE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
TextureAtlasSprite texture = bakedTextureGetter.apply( TEXTURE );
|
||||
|
||||
IBakedModel baseModel = this.getBaseModel( state, format, bakedTextureGetter );
|
||||
|
||||
return new MemoryCardBakedModel( format, baseModel, texture );
|
||||
}
|
||||
|
||||
private IBakedModel getBaseModel( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
|
||||
{
|
||||
// Load the base model
|
||||
try
|
||||
{
|
||||
return ModelLoaderRegistry.getModel( MODEL_BASE ).bake( state, format, bakedTextureGetter );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return TRSRTransformation.identity().toItemTransform();
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ package appeng.client.render.tesr;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
@@ -15,7 +14,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
@@ -23,7 +22,6 @@ import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
@@ -32,7 +30,7 @@ import appeng.tile.misc.TileInscriber;
|
||||
/**
|
||||
* Renders the dynamic parts of an inscriber (the presses, the animation and the item being smashed)
|
||||
*/
|
||||
public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
public final class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
{
|
||||
|
||||
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
|
||||
@@ -42,7 +40,7 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
private static TextureAtlasSprite textureInside;
|
||||
|
||||
@Override
|
||||
public void render( TileInscriber tile, double x, double y, double z, float partialTicks, int destroyStage, float p_render_10_ )
|
||||
public void render( final TileInscriber tile, final double x, final double y, final double z, final float partialTicks, final int destroyStage, final float p_render_10_ )
|
||||
{
|
||||
// render inscriber
|
||||
|
||||
@@ -90,7 +88,7 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
float press = 0.2f;
|
||||
press -= progress / 5.0f;
|
||||
|
||||
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
|
||||
final BufferBuilder buffer = Tessellator.getInstance().getBuffer();
|
||||
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX );
|
||||
|
||||
float middle = 0.5f;
|
||||
@@ -129,8 +127,6 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
|
||||
Tessellator.getInstance().draw();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
// render items.
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
@@ -150,8 +146,6 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
items++;
|
||||
}
|
||||
|
||||
// buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.ITEM );
|
||||
|
||||
if( relativeProgress > 1.0f || items == 0 )
|
||||
{
|
||||
ItemStack is = tileInv.getStackInSlot( 3 );
|
||||
@@ -165,65 +159,40 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
||||
}
|
||||
}
|
||||
|
||||
this.renderItem( is, 0.0f, tile, buffer, x, y, z );
|
||||
this.renderItem( is, 0.0f, tile, x, y, z );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.renderItem( tileInv.getStackInSlot( 0 ), press, tile, buffer, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 1 ), -press, tile, buffer, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 2 ), 0.0f, tile, buffer, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 0 ), press, tile, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 1 ), -press, tile, x, y, z );
|
||||
this.renderItem( tileInv.getStackInSlot( 2 ), 0.0f, tile, x, y, z );
|
||||
}
|
||||
|
||||
// Tessellator.getInstance().draw();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableRescaleNormal();
|
||||
}
|
||||
|
||||
private void renderItem( ItemStack sis, final float o, final AEBaseTile tile, final BufferBuilder tess, final double x, final double y, final double z )
|
||||
private void renderItem( final ItemStack stack, final float o, final AEBaseTile tile, final double x, final double y, final double z )
|
||||
{
|
||||
if( !sis.isEmpty() )
|
||||
if( !stack.isEmpty() )
|
||||
{
|
||||
sis = sis.copy();
|
||||
final ItemStack sis = stack.copy();
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
// move to center
|
||||
GlStateManager.translate( 0.5f, 0.5f + o, 0.5f );
|
||||
GlStateManager.rotate( 90, 1, 0, 0 );
|
||||
// set scale
|
||||
GlStateManager.scale( ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE );
|
||||
|
||||
GlStateManager.translate( x, y, z );
|
||||
GlStateManager.translate( 0.5F, 0.5F, 0.5F );
|
||||
FacingToRotation.get( tile.getForward(), tile.getUp() ).glRotateCurrentMat();
|
||||
GlStateManager.translate( -0.5F, -0.5F, -0.5F );
|
||||
|
||||
try
|
||||
// heuristic to scale items down much further than blocks
|
||||
if( !( sis.getItem() instanceof ItemBlock ) )
|
||||
{
|
||||
// move to center
|
||||
GlStateManager.translate( 0.5f, 0.5f + o, 0.5f );
|
||||
|
||||
GlStateManager.rotate( 90, 1, 0, 0 );
|
||||
|
||||
// set scale
|
||||
GlStateManager.scale( ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE );
|
||||
|
||||
// heuristic to scale items down much further than blocks
|
||||
final Block blk = Block.getBlockFromItem( sis.getItem() );
|
||||
if( blk == Blocks.AIR )
|
||||
{
|
||||
GlStateManager.scale( 0.5, 0.5, 0.5 );
|
||||
}
|
||||
|
||||
// << 20 | light << 4;
|
||||
final int br = tile.getWorld().getCombinedLight( tile.getPos(), 0 );
|
||||
final int var11 = br % 65536;
|
||||
final int var12 = br / 65536;
|
||||
|
||||
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11, var12 );
|
||||
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem( sis, ItemCameraTransforms.TransformType.FIXED );
|
||||
}
|
||||
catch( final Exception err )
|
||||
{
|
||||
AELog.debug( err );
|
||||
GlStateManager.scale( 0.5, 0.5, 0.5 );
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem( sis, ItemCameraTransforms.TransformType.FIXED );
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.guisync.SyncData;
|
||||
@@ -381,21 +380,6 @@ public abstract class AEBaseContainer extends Container
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
boolean hasMETiles = false;
|
||||
for( final Object is : this.inventorySlots )
|
||||
{
|
||||
if( is instanceof InternalSlotME )
|
||||
{
|
||||
hasMETiles = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( hasMETiles && Platform.isClient() )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get( idx ); // require AE SLots!
|
||||
|
||||
if( clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessible )
|
||||
@@ -418,18 +402,21 @@ public abstract class AEBaseContainer extends Container
|
||||
*/
|
||||
if( clickSlot.isPlayerSide() )
|
||||
{
|
||||
tis = this.shiftStoreItem( tis );
|
||||
tis = this.transferStackToContainer( tis );
|
||||
|
||||
// target slots in the container...
|
||||
for( final Object inventorySlot : this.inventorySlots )
|
||||
if( !tis.isEmpty() )
|
||||
{
|
||||
final AppEngSlot cs = (AppEngSlot) inventorySlot;
|
||||
|
||||
if( !( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) && !( cs instanceof SlotCraftingMatrix ) )
|
||||
// target slots in the container...
|
||||
for( final Object inventorySlot : this.inventorySlots )
|
||||
{
|
||||
if( cs.isItemValid( tis ) )
|
||||
final AppEngSlot cs = (AppEngSlot) inventorySlot;
|
||||
|
||||
if( !( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) && !( cs instanceof SlotCraftingMatrix ) )
|
||||
{
|
||||
selectedSlots.add( cs );
|
||||
if( cs.isItemValid( tis ) )
|
||||
{
|
||||
selectedSlots.add( cs );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1032,9 +1019,10 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendTo(
|
||||
new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.fromItemStack( p.inventory.getItemStack() ) ),
|
||||
p );
|
||||
NetworkHandler.instance()
|
||||
.sendTo(
|
||||
new PacketInventoryAction( InventoryAction.UPDATE_HAND, 0, AEItemStack.fromItemStack( p.inventory.getItemStack() ) ),
|
||||
p );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
@@ -1043,6 +1031,11 @@ public abstract class AEBaseContainer extends Container
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack transferStackToContainer( final ItemStack input )
|
||||
{
|
||||
return shiftStoreItem( input );
|
||||
}
|
||||
|
||||
private ItemStack shiftStoreItem( final ItemStack input )
|
||||
{
|
||||
if( this.getPowerSource() == null || this.getCellInventory() == null )
|
||||
@@ -1105,8 +1098,9 @@ public abstract class AEBaseContainer extends Container
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketValueConfig( "CustomName", this.getCustomName() ),
|
||||
(EntityPlayerMP) this.getInventoryPlayer().player );
|
||||
NetworkHandler.instance()
|
||||
.sendTo( new PacketValueConfig( "CustomName", this.getCustomName() ),
|
||||
(EntityPlayerMP) this.getInventoryPlayer().player );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
|
||||
@@ -88,4 +88,9 @@ public class ContainerPriority extends AEBaseContainer
|
||||
|
||||
super.onUpdate( field, oldValue, newValue );
|
||||
}
|
||||
|
||||
public IPriorityHost getPriorityHost()
|
||||
{
|
||||
return this.priHost;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,15 +156,22 @@ public class ContainerQuartzKnife extends AEBaseContainer
|
||||
|
||||
private void makePlate()
|
||||
{
|
||||
if( !this.getItemHandler().extractItem( 0, 1, false ).isEmpty() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack();
|
||||
item.damageItem( 1, ContainerQuartzKnife.this.getPlayerInv().player );
|
||||
|
||||
if( item.getCount() == 0 )
|
||||
if( !this.getItemHandler().extractItem( 0, 1, false ).isEmpty() )
|
||||
{
|
||||
ContainerQuartzKnife.this.getPlayerInv().mainInventory.add( ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY );
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( ContainerQuartzKnife.this.getPlayerInv().player, item, null ) );
|
||||
final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack();
|
||||
final ItemStack before = item.copy();
|
||||
item.damageItem( 1, ContainerQuartzKnife.this.getPlayerInv().player );
|
||||
|
||||
if( item.getCount() == 0 )
|
||||
{
|
||||
ContainerQuartzKnife.this.getPlayerInv()
|
||||
.setInventorySlotContents( ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY );
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( ContainerQuartzKnife.this.getPlayerInv().player, before, null ) );
|
||||
}
|
||||
|
||||
ContainerQuartzKnife.this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
||||
}
|
||||
}
|
||||
|
||||
private void checkToolbox()
|
||||
protected void checkToolbox()
|
||||
{
|
||||
if( this.hasToolbox() )
|
||||
{
|
||||
@@ -289,7 +289,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
||||
return this.fzMode;
|
||||
}
|
||||
|
||||
protected void setFuzzyMode( final FuzzyMode fzMode )
|
||||
public void setFuzzyMode( final FuzzyMode fzMode )
|
||||
{
|
||||
this.fzMode = fzMode;
|
||||
}
|
||||
@@ -309,7 +309,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
||||
return this.rsMode;
|
||||
}
|
||||
|
||||
void setRedStoneMode( final RedstoneMode rsMode )
|
||||
public void setRedStoneMode( final RedstoneMode rsMode )
|
||||
{
|
||||
this.rsMode = rsMode;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
private final int[] craftByStacks = { 1, 10, 100, 1000 };
|
||||
private final int[] priorityByStacks = { 1, 10, 100, 1000 };
|
||||
private final int[] levelByStacks = { 1, 10, 100, 1000 };
|
||||
private final int[] levelByMillibuckets = { 10, 100, 1000, 10000 };
|
||||
|
||||
// Spatial IO/Dimension
|
||||
private int storageProviderID = -1;
|
||||
@@ -172,12 +173,14 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
this.settings.registerSetting( Settings.TERMINAL_STYLE, TerminalStyle.TALL );
|
||||
this.settings.registerSetting( Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH );
|
||||
|
||||
this.spawnChargedChance = (float) ( 1.0 - this.get( "worldGen", "spawnChargedChance", 1.0 - this.spawnChargedChance ).getDouble(
|
||||
1.0 - this.spawnChargedChance ) );
|
||||
this.spawnChargedChance = (float) ( 1.0 - this.get( "worldGen", "spawnChargedChance", 1.0 - this.spawnChargedChance )
|
||||
.getDouble(
|
||||
1.0 - this.spawnChargedChance ) );
|
||||
this.minMeteoriteDistance = this.get( "worldGen", "minMeteoriteDistance", this.minMeteoriteDistance ).getInt( this.minMeteoriteDistance );
|
||||
this.meteoriteClusterChance = this.get( "worldGen", "meteoriteClusterChance", this.meteoriteClusterChance ).getDouble( this.meteoriteClusterChance );
|
||||
this.meteoriteMaximumSpawnHeight = this.get( "worldGen", "meteoriteMaximumSpawnHeight", this.meteoriteMaximumSpawnHeight ).getInt(
|
||||
this.meteoriteMaximumSpawnHeight );
|
||||
this.meteoriteMaximumSpawnHeight = this.get( "worldGen", "meteoriteMaximumSpawnHeight", this.meteoriteMaximumSpawnHeight )
|
||||
.getInt(
|
||||
this.meteoriteMaximumSpawnHeight );
|
||||
this.meteoriteDimensionWhitelist = this.get( "worldGen", "meteoriteDimensionWhitelist", this.meteoriteDimensionWhitelist ).getIntList();
|
||||
|
||||
this.quartzOresPerCluster = this.get( "worldGen", "quartzOresPerCluster", this.quartzOresPerCluster ).getInt( this.quartzOresPerCluster );
|
||||
@@ -191,14 +194,17 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
this.wirelessBaseCost = this.get( "wireless", "wirelessBaseCost", this.wirelessBaseCost ).getDouble( this.wirelessBaseCost );
|
||||
this.wirelessCostMultiplier = this.get( "wireless", "wirelessCostMultiplier", this.wirelessCostMultiplier ).getDouble( this.wirelessCostMultiplier );
|
||||
this.wirelessBaseRange = this.get( "wireless", "wirelessBaseRange", this.wirelessBaseRange ).getDouble( this.wirelessBaseRange );
|
||||
this.wirelessBoosterRangeMultiplier = this.get( "wireless", "wirelessBoosterRangeMultiplier", this.wirelessBoosterRangeMultiplier ).getDouble(
|
||||
this.wirelessBoosterRangeMultiplier );
|
||||
this.wirelessBoosterRangeMultiplier = this.get( "wireless", "wirelessBoosterRangeMultiplier", this.wirelessBoosterRangeMultiplier )
|
||||
.getDouble(
|
||||
this.wirelessBoosterRangeMultiplier );
|
||||
this.wirelessBoosterExp = this.get( "wireless", "wirelessBoosterExp", this.wirelessBoosterExp ).getDouble( this.wirelessBoosterExp );
|
||||
this.wirelessTerminalDrainMultiplier = this.get( "wireless", "wirelessTerminalDrainMultiplier", this.wirelessTerminalDrainMultiplier ).getDouble(
|
||||
this.wirelessTerminalDrainMultiplier );
|
||||
this.wirelessTerminalDrainMultiplier = this.get( "wireless", "wirelessTerminalDrainMultiplier", this.wirelessTerminalDrainMultiplier )
|
||||
.getDouble(
|
||||
this.wirelessTerminalDrainMultiplier );
|
||||
|
||||
this.formationPlaneEntityLimit = this.get( "automation", "formationPlaneEntityLimit", this.formationPlaneEntityLimit ).getInt(
|
||||
this.formationPlaneEntityLimit );
|
||||
this.formationPlaneEntityLimit = this.get( "automation", "formationPlaneEntityLimit", this.formationPlaneEntityLimit )
|
||||
.getInt(
|
||||
this.formationPlaneEntityLimit );
|
||||
|
||||
this.wirelessTerminalBattery = this.get( "battery", "wirelessTerminal", this.wirelessTerminalBattery ).getInt( this.wirelessTerminalBattery );
|
||||
this.chargedStaffBattery = this.get( "battery", "chargedStaff", this.chargedStaffBattery ).getInt( this.chargedStaffBattery );
|
||||
@@ -209,6 +215,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
|
||||
this.clientSync();
|
||||
|
||||
this.addCustomCategoryComment( "features", "Warning: Disabling a feature may disable other features depending on it." );
|
||||
for( final AEFeature feature : AEFeature.values() )
|
||||
{
|
||||
if( feature.isVisible() )
|
||||
@@ -255,15 +262,17 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
{
|
||||
this.storageProviderID = this.get( "spatialio", "storageProviderID", this.storageProviderID ).getInt( this.storageProviderID );
|
||||
this.storageDimensionID = this.get( "spatialio", "storageDimensionID", this.storageDimensionID ).getInt( this.storageDimensionID );
|
||||
this.spatialPowerMultiplier = this.get( "spatialio", "spatialPowerMultiplier", this.spatialPowerMultiplier ).getDouble(
|
||||
this.spatialPowerMultiplier );
|
||||
this.spatialPowerMultiplier = this.get( "spatialio", "spatialPowerMultiplier", this.spatialPowerMultiplier )
|
||||
.getDouble(
|
||||
this.spatialPowerMultiplier );
|
||||
this.spatialPowerExponent = this.get( "spatialio", "spatialPowerExponent", this.spatialPowerExponent ).getDouble( this.spatialPowerExponent );
|
||||
}
|
||||
|
||||
if( this.isFeatureEnabled( AEFeature.CRAFTING_CPU ) )
|
||||
{
|
||||
this.craftingCalculationTimePerTick = this.get( "craftingCPU", "craftingCalculationTimePerTick", this.craftingCalculationTimePerTick ).getInt(
|
||||
this.craftingCalculationTimePerTick );
|
||||
this.craftingCalculationTimePerTick = this.get( "craftingCPU", "craftingCalculationTimePerTick", this.craftingCalculationTimePerTick )
|
||||
.getInt(
|
||||
this.craftingCalculationTimePerTick );
|
||||
}
|
||||
|
||||
this.updatable = true;
|
||||
@@ -530,6 +539,11 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
return this.levelByStacks[i];
|
||||
}
|
||||
|
||||
public int levelByMillyBuckets( final int i )
|
||||
{
|
||||
return this.levelByMillibuckets[i];
|
||||
}
|
||||
|
||||
public Enum getSetting( final String category, final Class<? extends Enum> class1, final Enum myDefault )
|
||||
{
|
||||
final String name = class1.getSimpleName();
|
||||
|
||||
@@ -67,7 +67,7 @@ import appeng.services.version.VersionCheckerConfig;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@Mod( modid = AppEng.MOD_ID, acceptedMinecraftVersions = "[1.12.2]", name = AppEng.MOD_NAME, version = AEConfig.VERSION, dependencies = AppEng.MOD_DEPENDENCIES, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory" )
|
||||
@Mod( modid = AppEng.MOD_ID, acceptedMinecraftVersions = "[1.12.2]", name = AppEng.MOD_NAME, version = AEConfig.VERSION, dependencies = AppEng.MOD_DEPENDENCIES, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory", certificateFingerprint = "dfa4d3ac143316c6f32aa1a1beda1e34d42132e5" )
|
||||
public final class AppEng
|
||||
{
|
||||
@SidedProxy( clientSide = "appeng.client.ClientHelper", serverSide = "appeng.server.ServerHelper", modId = AppEng.MOD_ID )
|
||||
@@ -78,17 +78,7 @@ public final class AppEng
|
||||
|
||||
public static final String ASSETS = "appliedenergistics2:";
|
||||
|
||||
public static final String MOD_DEPENDENCIES =
|
||||
// a few mods, AE should load after, probably.
|
||||
// required-after:AppliedEnergistics2API|all;
|
||||
// "after:gregtech_addon;after:Mekanism;after:IC2;after:ThermalExpansion;after:BuildCraft|Core;" +
|
||||
|
||||
// depend on version of forge used for build.
|
||||
"after:appliedenergistics2-core;";// + "required-after:Forge@[" // require forge.
|
||||
// + net.minecraftforge.common.ForgeVersion.majorVersion + '.' // majorVersion
|
||||
// + net.minecraftforge.common.ForgeVersion.minorVersion + '.' // minorVersion
|
||||
// + net.minecraftforge.common.ForgeVersion.revisionVersion + '.' // revisionVersion
|
||||
// + net.minecraftforge.common.ForgeVersion.buildVersion + ",)"; // buildVersion
|
||||
public static final String MOD_DEPENDENCIES = "";
|
||||
|
||||
@Nonnull
|
||||
private static final AppEng INSTANCE = new AppEng();
|
||||
|
||||
@@ -53,6 +53,7 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -76,10 +77,10 @@ import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.spatial.ISpatialCache;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.bootstrap.ICriterionTriggerRegistry;
|
||||
import appeng.bootstrap.IModelRegistry;
|
||||
import appeng.bootstrap.components.IBlockRegistrationComponent;
|
||||
import appeng.bootstrap.components.IEntityRegistrationComponent;
|
||||
import appeng.bootstrap.components.IInitComponent;
|
||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||
import appeng.bootstrap.components.IModelRegistrationComponent;
|
||||
@@ -211,11 +212,9 @@ final class Registration
|
||||
Preconditions.checkArgument( !recipeDirectory.isFile() );
|
||||
|
||||
final Api api = Api.INSTANCE;
|
||||
final IPartHelper partHelper = api.partHelper();
|
||||
final IRegistryContainer registries = api.registries();
|
||||
|
||||
ApiDefinitions definitions = api.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents( IOreDictComponent.class ).forEachRemaining( b -> b.oreRegistration( event.getSide() ) );
|
||||
definitions.getRegistry().getBootstrapComponents( IInitComponent.class ).forEachRemaining( b -> b.initialize( event.getSide() ) );
|
||||
|
||||
MinecraftForge.EVENT_BUS.register( TickHandler.INSTANCE );
|
||||
@@ -286,6 +285,10 @@ final class Registration
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
final Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
definitions.getRegistry().getBootstrapComponents( IItemRegistrationComponent.class ).forEachRemaining( b -> b.itemRegistration( side, registry ) );
|
||||
// register oredicts
|
||||
definitions.getRegistry().getBootstrapComponents( IOreDictComponent.class ).forEachRemaining( b -> b.oreRegistration( side ) );
|
||||
ItemMaterial.instance.registerOredicts();
|
||||
ItemPart.instance.registerOreDicts();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -297,10 +300,6 @@ final class Registration
|
||||
final ApiDefinitions definitions = api.definitions();
|
||||
final Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
// Perform ore camouflage!
|
||||
ItemMaterial.instance.makeUnique();
|
||||
ItemPart.instance.registerOreDicts();
|
||||
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_DISASSEMBLY_CRAFTING ) )
|
||||
{
|
||||
DisassembleRecipe r = new DisassembleRecipe();
|
||||
@@ -321,7 +320,15 @@ final class Registration
|
||||
final AERecipeLoader ldr = new AERecipeLoader();
|
||||
ldr.loadProcessingRecipes();
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerEntities( RegistryEvent.Register<EntityEntry> event)
|
||||
{
|
||||
final IForgeRegistry<EntityEntry> registry = event.getRegistry();
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents( IEntityRegistrationComponent.class ).forEachRemaining( b -> b.entityRegistration( registry ) );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void attachSpatialDimensionManager( AttachCapabilitiesEvent<World> event )
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemSlab;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -93,6 +94,7 @@ import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.FeatureFactory;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.components.IEntityRegistrationComponent;
|
||||
import appeng.bootstrap.components.IOreDictComponent;
|
||||
import appeng.bootstrap.components.IPostInitComponent;
|
||||
import appeng.bootstrap.components.IPreInitComponent;
|
||||
@@ -126,6 +128,8 @@ import appeng.decorative.solid.BlockQuartzPillar;
|
||||
import appeng.decorative.solid.BlockSkyStone;
|
||||
import appeng.decorative.solid.BlockSkyStone.SkystoneType;
|
||||
import appeng.decorative.stair.BlockStairCommon;
|
||||
import appeng.entity.EntityIds;
|
||||
import appeng.entity.EntityTinyTNTPrimed;
|
||||
import appeng.fluids.block.BlockFluidInterface;
|
||||
import appeng.fluids.tile.TileFluidInterface;
|
||||
import appeng.hooks.DispenserBehaviorTinyTNT;
|
||||
@@ -261,11 +265,13 @@ public final class ApiBlocks implements IBlocks
|
||||
.build();
|
||||
this.matrixFrame = registry.block( "matrix_frame", BlockMatrixFrame::new ).features( AEFeature.SPATIAL_IO ).build();
|
||||
|
||||
FeatureFactory deco = registry.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS );
|
||||
FeatureFactory deco = registry.features( AEFeature.DECORATIVE_BLOCKS );
|
||||
this.quartzBlock = deco.block( "quartz_block", BlockQuartz::new ).build();
|
||||
this.quartzPillar = deco.block( "quartz_pillar", BlockQuartzPillar::new ).build();
|
||||
this.chiseledQuartzBlock = deco.block( "chiseled_quartz_block", BlockChiseledQuartz::new ).build();
|
||||
this.quartzGlass = deco.block( "quartz_glass", BlockQuartzGlass::new )
|
||||
|
||||
this.quartzGlass = registry.features( AEFeature.QUARTZ_GLASS )
|
||||
.block( "quartz_glass", BlockQuartzGlass::new )
|
||||
.useCustomItemModel()
|
||||
.rendering( new BlockRenderingCustomizer()
|
||||
{
|
||||
@@ -278,7 +284,7 @@ public final class ApiBlocks implements IBlocks
|
||||
} )
|
||||
.build();
|
||||
this.quartzVibrantGlass = deco.block( "quartz_vibrant_glass", BlockQuartzLamp::new )
|
||||
.addFeatures( AEFeature.DECORATIVE_LIGHTS )
|
||||
.addFeatures( AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS )
|
||||
.useCustomItemModel()
|
||||
.build();
|
||||
this.quartzFixture = registry.block( "quartz_fixture", BlockQuartzFixture::new )
|
||||
@@ -286,19 +292,28 @@ public final class ApiBlocks implements IBlocks
|
||||
.useCustomItemModel()
|
||||
.build();
|
||||
|
||||
this.fluixBlock = deco.block( "fluix_block", BlockFluix::new ).build();
|
||||
this.skyStoneBlock = deco.block( "sky_stone_block", () -> new BlockSkyStone( SkystoneType.STONE ) ).build();
|
||||
this.smoothSkyStoneBlock = deco.block( "smooth_sky_stone_block", () -> new BlockSkyStone( SkystoneType.BLOCK ) ).build();
|
||||
this.skyStoneBrick = deco.block( "sky_stone_brick", () -> new BlockSkyStone( SkystoneType.BRICK ) ).build();
|
||||
this.skyStoneSmallBrick = deco.block( "sky_stone_small_brick", () -> new BlockSkyStone( SkystoneType.SMALL_BRICK ) ).build();
|
||||
this.fluixBlock = registry.features( AEFeature.FLUIX ).block( "fluix_block", BlockFluix::new ).build();
|
||||
|
||||
this.skyStoneBlock = registry.features( AEFeature.SKY_STONE )
|
||||
.block( "sky_stone_block", () -> new BlockSkyStone( SkystoneType.STONE ) )
|
||||
.build();
|
||||
this.smoothSkyStoneBlock = registry.features( AEFeature.SKY_STONE )
|
||||
.block( "smooth_sky_stone_block", () -> new BlockSkyStone( SkystoneType.BLOCK ) )
|
||||
.build();
|
||||
this.skyStoneBrick = deco.block( "sky_stone_brick", () -> new BlockSkyStone( SkystoneType.BRICK ) )
|
||||
.addFeatures( AEFeature.SKY_STONE )
|
||||
.build();
|
||||
this.skyStoneSmallBrick = deco.block( "sky_stone_small_brick", () -> new BlockSkyStone( SkystoneType.SMALL_BRICK ) )
|
||||
.addFeatures( AEFeature.SKY_STONE )
|
||||
.build();
|
||||
|
||||
this.skyStoneChest = registry.block( "sky_stone_chest", () -> new BlockSkyChest( SkyChestType.STONE ) )
|
||||
.features( AEFeature.SKY_STONE_CHESTS )
|
||||
.features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS )
|
||||
.tileEntity( new TileEntityDefinition( TileSkyChest.class, "sky_stone_chest" ) )
|
||||
.rendering( new SkyChestRenderingCustomizer( SkyChestType.STONE ) )
|
||||
.build();
|
||||
this.smoothSkyStoneChest = registry.block( "smooth_sky_stone_chest", () -> new BlockSkyChest( SkyChestType.BLOCK ) )
|
||||
.features( AEFeature.SKY_STONE_CHESTS )
|
||||
.features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS )
|
||||
.tileEntity( new TileEntityDefinition( TileSkyChest.class, "sky_stone_chest" ) )
|
||||
.rendering( new SkyChestRenderingCustomizer( SkyChestType.BLOCK ) )
|
||||
.build();
|
||||
@@ -345,6 +360,16 @@ public final class ApiBlocks implements IBlocks
|
||||
.features( AEFeature.TINY_TNT )
|
||||
.bootstrap( ( block, item ) -> (IPreInitComponent) side -> BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item,
|
||||
new DispenserBehaviorTinyTNT() ) )
|
||||
.bootstrap( ( block, item ) -> (IEntityRegistrationComponent) r ->
|
||||
{
|
||||
r.register( EntityEntryBuilder.create()
|
||||
.entity( EntityTinyTNTPrimed.class )
|
||||
.id( new ResourceLocation( "appliedenergistics2", EntityTinyTNTPrimed.class.getName() ),
|
||||
EntityIds.get( EntityTinyTNTPrimed.class ) )
|
||||
.name( "EntityTinyTNTPrimed" )
|
||||
.tracker( 16, 4, true )
|
||||
.build() );
|
||||
} )
|
||||
.build();
|
||||
this.securityStation = registry.block( "security_station", BlockSecurityStation::new )
|
||||
.features( AEFeature.SECURITY )
|
||||
@@ -557,7 +582,7 @@ public final class ApiBlocks implements IBlocks
|
||||
Block block = blockDef.maybeBlock().get();
|
||||
|
||||
IBlockDefinition slabDef = registry.block( slabId, () -> new BlockSlabCommon.Half( block ) )
|
||||
.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS )
|
||||
.features( AEFeature.DECORATIVE_BLOCKS )
|
||||
.disableItem()
|
||||
.build();
|
||||
|
||||
@@ -570,7 +595,7 @@ public final class ApiBlocks implements IBlocks
|
||||
|
||||
// Reigster the double slab variant as well
|
||||
IBlockDefinition doubleSlabDef = registry.block( doubleSlabId, () -> new BlockSlabCommon.Double( slabBlock, block ) )
|
||||
.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS )
|
||||
.features( AEFeature.DECORATIVE_BLOCKS )
|
||||
.disableItem()
|
||||
.build();
|
||||
|
||||
@@ -580,7 +605,7 @@ public final class ApiBlocks implements IBlocks
|
||||
|
||||
// Make the slab item
|
||||
IItemDefinition itemDef = registry.item( slabId, () -> new ItemSlab( slabBlock, slabBlock, doubleSlabBlock ) )
|
||||
.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS )
|
||||
.features( AEFeature.DECORATIVE_BLOCKS )
|
||||
.build();
|
||||
|
||||
Verify.verify( itemDef.maybeItem().isPresent() );
|
||||
@@ -592,7 +617,7 @@ public final class ApiBlocks implements IBlocks
|
||||
private static IBlockDefinition makeStairs( String registryName, FeatureFactory registry, IBlockDefinition block )
|
||||
{
|
||||
return registry.block( registryName, () -> new BlockStairCommon( block.maybeBlock().get(), block.identifier() ) )
|
||||
.features( AEFeature.DECORATIVE_QUARTZ_BLOCKS )
|
||||
.features( AEFeature.DECORATIVE_BLOCKS )
|
||||
.rendering( new BlockRenderingCustomizer()
|
||||
{
|
||||
@Override
|
||||
|
||||
@@ -19,10 +19,14 @@
|
||||
package appeng.core.api.definitions;
|
||||
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.bootstrap.FeatureFactory;
|
||||
import appeng.bootstrap.components.IEntityRegistrationComponent;
|
||||
import appeng.client.render.crafting.ItemEncodedPatternRendering;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.core.features.AEFeature;
|
||||
@@ -30,6 +34,8 @@ import appeng.debug.ToolDebugCard;
|
||||
import appeng.debug.ToolEraser;
|
||||
import appeng.debug.ToolMeteoritePlacer;
|
||||
import appeng.debug.ToolReplicatorCard;
|
||||
import appeng.entity.EntityGrowingCrystal;
|
||||
import appeng.entity.EntityIds;
|
||||
import appeng.fluids.items.BasicFluidStorageCell;
|
||||
import appeng.fluids.items.FluidDummyItem;
|
||||
import appeng.fluids.items.FluidDummyItemRendering;
|
||||
@@ -50,6 +56,7 @@ import appeng.items.storage.ItemViewCell;
|
||||
import appeng.items.tools.ToolBiometricCard;
|
||||
import appeng.items.tools.ToolBiometricCardRendering;
|
||||
import appeng.items.tools.ToolMemoryCard;
|
||||
import appeng.items.tools.ToolMemoryCardRendering;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.items.tools.powered.ToolChargedStaff;
|
||||
import appeng.items.tools.powered.ToolColorApplicator;
|
||||
@@ -199,7 +206,10 @@ public final class ApiItems implements IItems
|
||||
.rendering( new ToolBiometricCardRendering() )
|
||||
.features( AEFeature.SECURITY )
|
||||
.build();
|
||||
this.memoryCard = registry.item( "memory_card", ToolMemoryCard::new ).features( AEFeature.MEMORY_CARD ).build();
|
||||
this.memoryCard = registry.item( "memory_card", ToolMemoryCard::new )
|
||||
.rendering( new ToolMemoryCardRendering() )
|
||||
.features( AEFeature.MEMORY_CARD )
|
||||
.build();
|
||||
this.networkTool = registry.item( "network_tool", ToolNetworkTool::new ).features( AEFeature.NETWORK_TOOL ).build();
|
||||
|
||||
this.cellCreative = registry.item( "creative_storage_cell", ItemCreativeStorageCell::new )
|
||||
@@ -231,6 +241,16 @@ public final class ApiItems implements IItems
|
||||
this.crystalSeed = registry.item( "crystal_seed", ItemCrystalSeed::new )
|
||||
.features( AEFeature.CRYSTAL_SEEDS )
|
||||
.rendering( new ItemCrystalSeedRendering() )
|
||||
.bootstrap( item -> (IEntityRegistrationComponent) r ->
|
||||
{
|
||||
r.register( EntityEntryBuilder.create()
|
||||
.entity( EntityGrowingCrystal.class )
|
||||
.id( new ResourceLocation( "appliedenergistics2", EntityGrowingCrystal.class.getName() ),
|
||||
EntityIds.get( EntityGrowingCrystal.class ) )
|
||||
.name( EntityGrowingCrystal.class.getSimpleName() )
|
||||
.tracker( 16, 4, true )
|
||||
.build() );
|
||||
} )
|
||||
.build();
|
||||
|
||||
// rv1
|
||||
|
||||
@@ -22,6 +22,8 @@ package appeng.core.api.definitions;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -30,7 +32,11 @@ import appeng.api.definitions.IMaterials;
|
||||
import appeng.bootstrap.FeatureFactory;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.bootstrap.ItemRenderingCustomizer;
|
||||
import appeng.bootstrap.components.IEntityRegistrationComponent;
|
||||
import appeng.core.features.DamagedItemDefinition;
|
||||
import appeng.entity.EntityChargedQuartz;
|
||||
import appeng.entity.EntityIds;
|
||||
import appeng.entity.EntitySingularity;
|
||||
import appeng.items.materials.ItemMaterial;
|
||||
import appeng.items.materials.MaterialType;
|
||||
|
||||
@@ -133,6 +139,22 @@ public final class ApiMaterials implements IMaterials
|
||||
.collect( Collectors.toList() ) );
|
||||
}
|
||||
} )
|
||||
.bootstrap( item -> (IEntityRegistrationComponent) r ->
|
||||
{
|
||||
r.register( EntityEntryBuilder.create()
|
||||
.entity( EntitySingularity.class )
|
||||
.id( new ResourceLocation( "appliedenergistics2", EntitySingularity.class.getName() ), EntityIds.get( EntitySingularity.class ) )
|
||||
.name( EntitySingularity.class.getSimpleName() )
|
||||
.tracker( 16, 4, true )
|
||||
.build() );
|
||||
r.register( EntityEntryBuilder.create()
|
||||
.entity( EntityChargedQuartz.class )
|
||||
.id( new ResourceLocation( "appliedenergistics2", EntityChargedQuartz.class.getName() ),
|
||||
EntityIds.get( EntityChargedQuartz.class ) )
|
||||
.name( EntityChargedQuartz.class.getSimpleName() )
|
||||
.tracker( 16, 4, true )
|
||||
.build() );
|
||||
} )
|
||||
.build();
|
||||
|
||||
this.cell2SpatialPart = new DamagedItemDefinition( "material.cell.spatial.2", materials.createMaterial( MaterialType.CELL2_SPATIAL_PART ) );
|
||||
|
||||
@@ -57,9 +57,12 @@ public final class ApiParts implements IParts
|
||||
private final IItemDefinition iface;
|
||||
private final IItemDefinition fluidIface;
|
||||
private final IItemDefinition levelEmitter;
|
||||
private final IItemDefinition fluidLevelEmitter;
|
||||
private final IItemDefinition annihilationPlane;
|
||||
private final IItemDefinition identityAnnihilationPlane;
|
||||
private final IItemDefinition fluidAnnihilationPlane;
|
||||
private final IItemDefinition formationPlane;
|
||||
private final IItemDefinition fluidFormationPlane;
|
||||
private final IItemDefinition p2PTunnelME;
|
||||
private final IItemDefinition p2PTunnelRedstone;
|
||||
private final IItemDefinition p2PTunnelItems;
|
||||
@@ -114,10 +117,13 @@ public final class ApiParts implements IParts
|
||||
this.iface = new DamagedItemDefinition( "part.interface", itemPart.createPart( PartType.INTERFACE ) );
|
||||
this.fluidIface = new DamagedItemDefinition( "part.fluid_interface", itemPart.createPart( PartType.FLUID_INTERFACE ) );
|
||||
this.levelEmitter = new DamagedItemDefinition( "part.level_emitter", itemPart.createPart( PartType.LEVEL_EMITTER ) );
|
||||
this.fluidLevelEmitter = new DamagedItemDefinition( "part.fluid_level_emitter", itemPart.createPart( PartType.FLUID_LEVEL_EMITTER ) );
|
||||
this.annihilationPlane = new DamagedItemDefinition( "part.plane.annihilation", itemPart.createPart( PartType.ANNIHILATION_PLANE ) );
|
||||
this.identityAnnihilationPlane = new DamagedItemDefinition( "part.plane.annihiliation.identity", itemPart
|
||||
.createPart( PartType.IDENTITY_ANNIHILATION_PLANE ) );
|
||||
this.fluidAnnihilationPlane = new DamagedItemDefinition( "part.plane.fluid_annihilation", itemPart.createPart( PartType.FLUID_ANNIHILATION_PLANE ) );
|
||||
this.formationPlane = new DamagedItemDefinition( "part.plane.formation", itemPart.createPart( PartType.FORMATION_PLANE ) );
|
||||
this.fluidFormationPlane = new DamagedItemDefinition( "part.plane.fluid_formation", itemPart.createPart( PartType.FLUID_FORMATION_PLANE ) );
|
||||
this.p2PTunnelME = new DamagedItemDefinition( "part.tunnel.me", itemPart.createPart( PartType.P2P_TUNNEL_ME ) );
|
||||
this.p2PTunnelRedstone = new DamagedItemDefinition( "part.tunnel.redstone", itemPart.createPart( PartType.P2P_TUNNEL_REDSTONE ) );
|
||||
this.p2PTunnelItems = new DamagedItemDefinition( "part.tunnel.item", itemPart.createPart( PartType.P2P_TUNNEL_ITEMS ) );
|
||||
@@ -420,4 +426,22 @@ public final class ApiParts implements IParts
|
||||
{
|
||||
return this.fluidStorageBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidLevelEmitter()
|
||||
{
|
||||
return this.fluidLevelEmitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidAnnihilationPlane()
|
||||
{
|
||||
return this.fluidAnnihilationPlane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition fluidFormationnPlane()
|
||||
{
|
||||
return this.fluidFormationPlane;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,20 +36,22 @@ public enum AEFeature
|
||||
CERTUS_QUARTZ_WORLD_GEN( "CertusQuartzWorldGen", Constants.CATEGORY_WORLD ),
|
||||
METEORITE_WORLD_GEN( "MeteoriteWorldGen", Constants.CATEGORY_WORLD ),
|
||||
DECORATIVE_LIGHTS( "DecorativeLights", Constants.CATEGORY_WORLD ),
|
||||
DECORATIVE_QUARTZ_BLOCKS( "DecorativeQuartzBlocks", Constants.CATEGORY_WORLD ),
|
||||
DECORATIVE_BLOCKS( "DecorativeBlocks", Constants.CATEGORY_WORLD, "Blocks that are not used in any essential recipes, also slabs and stairs." ),
|
||||
SKY_STONE_CHESTS( "SkyStoneChests", Constants.CATEGORY_WORLD ),
|
||||
SPAWN_PRESSES_IN_METEORITES( "SpawnPressesInMeteorites", Constants.CATEGORY_WORLD ),
|
||||
GRIND_STONE( "GrindStone", Constants.CATEGORY_WORLD ),
|
||||
FLOUR( "Flour", Constants.CATEGORY_WORLD ),
|
||||
INSCRIBER( "Inscriber", Constants.CATEGORY_WORLD ),
|
||||
CHARGER( "Charger", Constants.CATEGORY_WORLD ),
|
||||
CRYSTAL_GROWTH_ACCELERATOR( "CrystalGrowthAccelerator", Constants.CATEGORY_WORLD ),
|
||||
CHEST_LOOT( "ChestLoot", Constants.CATEGORY_WORLD ),
|
||||
VILLAGER_TRADING( "VillagerTrading", Constants.CATEGORY_WORLD ),
|
||||
TINY_TNT( "TinyTNT", Constants.CATEGORY_WORLD ),
|
||||
CERTUS_ORE( "CertusOre", Constants.CATEGORY_WORLD ),
|
||||
CHARGED_CERTUS_ORE( "ChargedCertusOre", Constants.CATEGORY_WORLD ),
|
||||
|
||||
GRIND_STONE( "GrindStone", Constants.CATEGORY_MACHINES ),
|
||||
INSCRIBER( "Inscriber", Constants.CATEGORY_MACHINES ),
|
||||
CHARGER( "Charger", Constants.CATEGORY_MACHINES ),
|
||||
CRYSTAL_GROWTH_ACCELERATOR( "CrystalGrowthAccelerator", Constants.CATEGORY_MACHINES ),
|
||||
POWER_GEN( "VibrationChamber", Constants.CATEGORY_MACHINES ),
|
||||
|
||||
POWERED_TOOLS( "PoweredTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ),
|
||||
CERTUS_QUARTZ_TOOLS( "CertusQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ),
|
||||
NETHER_QUARTZ_TOOLS( "NetherQuartzTools", Constants.CATEGORY_TOOLS_CLASSIFICATIONS ),
|
||||
@@ -68,7 +70,6 @@ public enum AEFeature
|
||||
COLOR_APPLICATOR( "ColorApplicator", Constants.CATEGORY_TOOLS ),
|
||||
METEORITE_COMPASS( "MeteoriteCompass", Constants.CATEGORY_TOOLS ),
|
||||
|
||||
POWER_GEN( "PowerGen", Constants.CATEGORY_NETWORK_FEATURES ),
|
||||
SECURITY( "Security", Constants.CATEGORY_NETWORK_FEATURES ),
|
||||
SPATIAL_IO( "SpatialIO", Constants.CATEGORY_NETWORK_FEATURES ),
|
||||
QUANTUM_NETWORK_BRIDGE( "QuantumNetworkBridge", Constants.CATEGORY_NETWORK_FEATURES ),
|
||||
@@ -77,14 +78,17 @@ public enum AEFeature
|
||||
INTERFACE( "Interface", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
FLUID_INTERFACE( "FluidInterface", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
LEVEL_EMITTER( "LevelEmitter", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
FLUID_LEVEL_EMITTER( "FluidLevelEmitter", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
FLUID_TERMINAL( "FluidTerminal", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
CRAFTING_TERMINAL( "CraftingTerminal", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
TERMINAL( "Terminal", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
STORAGE_MONITOR( "StorageMonitor", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
P2P_TUNNEL( "P2PTunnel", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
FORMATION_PLANE( "FormationPlane", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
FLUID_FORMATION_PLANE( "FluidFormationPlane", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
ANNIHILATION_PLANE( "AnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
IDENTITY_ANNIHILATION_PLANE( "IdentityAnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
FLUID_ANNIHILATION_PLANE( "FluidAnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
IMPORT_BUS( "ImportBus", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
FLUID_IMPORT_BUS( "FluidImportBus", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
EXPORT_BUS( "ExportBus", Constants.CATEGORY_NETWORK_BUSES ),
|
||||
@@ -111,12 +115,11 @@ public enum AEFeature
|
||||
GLASS_CABLES( "GlassCables", Constants.CATEGORY_CABLES ),
|
||||
COVERED_CABLES( "CoveredCables", Constants.CATEGORY_CABLES ),
|
||||
SMART_CABLES( "SmartCables", Constants.CATEGORY_CABLES ),
|
||||
DENSE_CABLES( "DenseCables", Constants.CATEGORY_CABLES ),
|
||||
|
||||
ENERGY_CELLS( "EnergyCells", Constants.CATEGORY_ENERGY ),
|
||||
ENERGY_ACCEPTOR( "EnergyAcceptor", Constants.CATEGORY_ENERGY ),
|
||||
|
||||
DENSE_ENERGY_CELLS( "DenseEnergyCells", Constants.CATEGORY_HIGHER_CAPACITY ),
|
||||
DENSE_CABLES( "DenseCables", Constants.CATEGORY_HIGHER_CAPACITY ),
|
||||
DENSE_ENERGY_CELLS( "DenseEnergyCells", Constants.CATEGORY_ENERGY ),
|
||||
|
||||
P2P_TUNNEL_ME( "P2PTunnelME", Constants.CATEGORY_P2P_TUNNELS ),
|
||||
P2P_TUNNEL_ITEMS( "P2PTunnelItems", Constants.CATEGORY_P2P_TUNNELS ),
|
||||
@@ -166,9 +169,6 @@ public enum AEFeature
|
||||
ADVANCED_CARDS( "AdvancedCards", Constants.CATEGORY_UPGRADES ),
|
||||
VIEW_CELL( "ViewCell", Constants.CATEGORY_UPGRADES ),
|
||||
|
||||
PROCESSORS( "Processors", Constants.CATEGORY_MATERIALS ),
|
||||
PRINTED_CIRCUITS( "PrintedCircuits", Constants.CATEGORY_MATERIALS ),
|
||||
PRESSES( "Presses", Constants.CATEGORY_MATERIALS ),
|
||||
CRYSTAL_SEEDS( "CrystalSeeds", Constants.CATEGORY_MATERIALS ),
|
||||
PURE_CRYSTALS( "PureCrystals", Constants.CATEGORY_MATERIALS ),
|
||||
CERTUS( "Certus", Constants.CATEGORY_MATERIALS ),
|
||||
@@ -176,8 +176,14 @@ public enum AEFeature
|
||||
SILICON( "Silicon", Constants.CATEGORY_MATERIALS ),
|
||||
DUSTS( "Dusts", Constants.CATEGORY_MATERIALS ),
|
||||
NUGGETS( "Nuggets", Constants.CATEGORY_MATERIALS ),
|
||||
MATTER_BALL( "MatterBall", Constants.CATEGORY_MATERIALS ),
|
||||
CORES( "Cores", Constants.CATEGORY_MATERIALS ),
|
||||
QUARTZ_GLASS( "QuartzGlass", Constants.CATEGORY_MATERIALS ),
|
||||
SKY_STONE( "SkyStone", Constants.CATEGORY_MATERIALS ),
|
||||
|
||||
PROCESSORS( "Processors", Constants.CATEGORY_COMPONENTS ),
|
||||
PRINTED_CIRCUITS( "PrintedCircuits", Constants.CATEGORY_COMPONENTS ),
|
||||
PRESSES( "Presses", Constants.CATEGORY_COMPONENTS ),
|
||||
MATTER_BALL( "MatterBall", Constants.CATEGORY_COMPONENTS ),
|
||||
CORES( "Cores", Constants.CATEGORY_COMPONENTS ),
|
||||
|
||||
CHUNK_LOGGER_TRACE( "ChunkLoggerTrace", Constants.CATEGORY_COMMANDS, false );
|
||||
|
||||
@@ -246,6 +252,7 @@ public enum AEFeature
|
||||
private static final String CATEGORY_MISC = "Misc";
|
||||
private static final String CATEGORY_CRAFTING = "Crafting";
|
||||
private static final String CATEGORY_WORLD = "World";
|
||||
private static final String CATEGORY_MACHINES = "Machines";
|
||||
private static final String CATEGORY_TOOLS = "Tools";
|
||||
private static final String CATEGORY_TOOLS_CLASSIFICATIONS = "ToolsClassifications";
|
||||
private static final String CATEGORY_NETWORK_BUSES = "NetworkBuses";
|
||||
@@ -254,7 +261,6 @@ public enum AEFeature
|
||||
private static final String CATEGORY_CRAFTING_FEATURES = "CraftingFeatures";
|
||||
private static final String CATEGORY_STORAGE = "Storage";
|
||||
private static final String CATEGORY_CABLES = "Cables";
|
||||
private static final String CATEGORY_HIGHER_CAPACITY = "HigherCapacity";
|
||||
private static final String CATEGORY_NETWORK_FEATURES = "NetworkFeatures";
|
||||
private static final String CATEGORY_COMMANDS = "Commands";
|
||||
private static final String CATEGORY_RENDERING = "Rendering";
|
||||
@@ -264,5 +270,6 @@ public enum AEFeature
|
||||
private static final String CATEGORY_ENERGY = "Energy";
|
||||
private static final String CATEGORY_UPGRADES = "Upgrades";
|
||||
private static final String CATEGORY_MATERIALS = "Materials";
|
||||
private static final String CATEGORY_COMPONENTS = "CraftingComponents";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ public class BasicItemCellHandler implements ICellHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
|
||||
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
{
|
||||
return ItemCellInventory.getCell( is, container );
|
||||
return (ICellInventoryHandler<T>) ItemCellInventory.getCell( is, container );
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -28,8 +28,8 @@ import com.google.common.base.Verify;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.ICellRegistry;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
@@ -92,7 +92,7 @@ public class CellRegistry implements ICellRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> chan )
|
||||
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> chan )
|
||||
{
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
@@ -48,7 +49,7 @@ public final class CreativeCellHandler implements ICellHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel )
|
||||
public ICellInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel )
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && !is.isEmpty() && is
|
||||
.getItem() instanceof ItemCreativeStorageCell )
|
||||
|
||||
@@ -37,6 +37,7 @@ public enum GuiText
|
||||
VibrationChamber,
|
||||
SpatialIOPort,
|
||||
LevelEmitter,
|
||||
FluidLevelEmitter,
|
||||
Terminal,
|
||||
|
||||
Interface,
|
||||
@@ -84,6 +85,7 @@ public enum GuiText
|
||||
|
||||
CraftingTerminal,
|
||||
FormationPlane,
|
||||
FluidFormationPlane,
|
||||
Inscriber,
|
||||
QuartzCuttingKnife,
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import appeng.core.sync.packets.PacketCompassResponse;
|
||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import appeng.core.sync.packets.PacketFluidTank;
|
||||
import appeng.core.sync.packets.PacketFluidSlot;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketJEIRecipe;
|
||||
import appeng.core.sync.packets.PacketLightning;
|
||||
@@ -107,7 +107,7 @@ public class AppEngPacketHandlerBase
|
||||
|
||||
PACKET_PAINTED_ENTITY( PacketPaintedEntity.class ),
|
||||
|
||||
PACKET_FLUID_TANK( PacketFluidTank.class );
|
||||
PACKET_FLUID_TANK( PacketFluidSlot.class );
|
||||
|
||||
private final Class<? extends AppEngPacket> packetClass;
|
||||
private final Constructor<? extends AppEngPacket> packetConstructor;
|
||||
|
||||
@@ -86,13 +86,16 @@ import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.container.implementations.ContainerWirelessTerm;
|
||||
import appeng.fluids.container.ContainerFluidFormationPlane;
|
||||
import appeng.fluids.container.ContainerFluidIO;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import appeng.fluids.container.ContainerFluidStorageBus;
|
||||
import appeng.fluids.container.ContainerFluidTerminal;
|
||||
import appeng.fluids.helper.IFluidInterfaceHost;
|
||||
import appeng.fluids.parts.PartFluidFormationPlane;
|
||||
import appeng.fluids.parts.PartFluidLevelEmitter;
|
||||
import appeng.fluids.parts.PartFluidStorageBus;
|
||||
import appeng.fluids.parts.PartFluidTerminal;
|
||||
import appeng.fluids.parts.PartSharedFluidBus;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
@@ -172,6 +175,8 @@ public enum GuiBridge implements IGuiHandler
|
||||
|
||||
GUI_FORMATION_PLANE( ContainerFormationPlane.class, PartFormationPlane.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_FLUID_FORMATION_PLANE( ContainerFluidFormationPlane.class, PartFluidFormationPlane.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_PRIORITY( ContainerPriority.class, IPriorityHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_SECURITY( ContainerSecurityStation.class, TileSecurityStation.class, GuiHostType.WORLD, SecurityPermissions.SECURITY ),
|
||||
@@ -180,11 +185,13 @@ public enum GuiBridge implements IGuiHandler
|
||||
|
||||
GUI_PATTERN_TERMINAL( ContainerPatternTerm.class, PartPatternTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ),
|
||||
|
||||
GUI_FLUID_TERMINAL( ContainerFluidTerminal.class, PartFluidTerminal.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
GUI_FLUID_TERMINAL( ContainerFluidTerminal.class, ITerminalHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
// extends (Container/Gui) + Bus
|
||||
GUI_LEVEL_EMITTER( ContainerLevelEmitter.class, PartLevelEmitter.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_FLUID_LEVEL_EMITTER( ContainerFluidLevelEmitter.class, PartFluidLevelEmitter.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_SPATIAL_IO_PORT( ContainerSpatialIOPort.class, TileSpatialIOPort.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_INSCRIBER( ContainerInscriber.class, TileInscriber.class, GuiHostType.WORLD, null ),
|
||||
|
||||
@@ -22,17 +22,20 @@ package appeng.core.sync.packets;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IComparableDefinition;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
@@ -50,6 +53,7 @@ public class PacketClick extends AppEngPacket
|
||||
private final float hitY;
|
||||
private final float hitZ;
|
||||
private EnumHand hand;
|
||||
private final boolean leftClick;
|
||||
|
||||
// automatic.
|
||||
public PacketClick( final ByteBuf stream )
|
||||
@@ -70,10 +74,16 @@ public class PacketClick extends AppEngPacket
|
||||
this.hitY = stream.readFloat();
|
||||
this.hitZ = stream.readFloat();
|
||||
this.hand = EnumHand.values()[stream.readByte()];
|
||||
this.leftClick = stream.readBoolean();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketClick( final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
this( pos, side, hitX, hitY, hitZ, hand, false );
|
||||
}
|
||||
|
||||
public PacketClick( final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand, boolean leftClick )
|
||||
{
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
@@ -94,6 +104,7 @@ public class PacketClick extends AppEngPacket
|
||||
data.writeFloat( this.hitY = hitY );
|
||||
data.writeFloat( this.hitZ = hitZ );
|
||||
data.writeByte( hand.ordinal() );
|
||||
data.writeBoolean( this.leftClick = leftClick );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@@ -105,27 +116,38 @@ public class PacketClick extends AppEngPacket
|
||||
final IItems items = AEApi.instance().definitions().items();
|
||||
final IComparableDefinition maybeMemoryCard = items.memoryCard();
|
||||
final IComparableDefinition maybeColorApplicator = items.colorApplicator();
|
||||
|
||||
if( !is.isEmpty() )
|
||||
final BlockPos pos = new BlockPos( this.x, this.y, this.z );
|
||||
if( this.leftClick )
|
||||
{
|
||||
if( is.getItem() instanceof ToolNetworkTool )
|
||||
final Block block = player.world.getBlockState( pos ).getBlock();
|
||||
if( block instanceof BlockCableBus )
|
||||
{
|
||||
final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
tnt.serverSideToolLogic( is, player, this.hand, player.world, new BlockPos( this.x, this.y, this.z ), this.side, this.hitX, this.hitY,
|
||||
this.hitZ );
|
||||
( (BlockCableBus) block ).onBlockClickPacket( player.world, pos, player, this.hand, new Vec3d( this.hitX, this.hitY, this.hitZ ) );
|
||||
}
|
||||
|
||||
else if( maybeMemoryCard.isSameAs( is ) )
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
}
|
||||
if( is.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
final ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
tnt.serverSideToolLogic( is, player, this.hand, player.world, pos, this.side, this.hitX, this.hitY,
|
||||
this.hitZ );
|
||||
}
|
||||
|
||||
else if( maybeColorApplicator.isSameAs( is ) )
|
||||
{
|
||||
final ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors( is, mem.getColor( is ), 1 );
|
||||
else if( maybeMemoryCard.isSameAs( is ) )
|
||||
{
|
||||
final IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
}
|
||||
|
||||
else if( maybeColorApplicator.isSameAs( is ) )
|
||||
{
|
||||
final ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors( is, mem.getColor( is ), 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+34
-22
@@ -30,54 +30,66 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.fluids.container.IFluidSyncContainer;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
|
||||
|
||||
public class PacketFluidTank extends AppEngPacket
|
||||
public class PacketFluidSlot extends AppEngPacket
|
||||
{
|
||||
private final Map<Integer, NBTTagCompound> updateMap;
|
||||
private final Map<Integer, IAEFluidStack> list;
|
||||
|
||||
public PacketFluidTank( final ByteBuf stream )
|
||||
public PacketFluidSlot( final ByteBuf stream )
|
||||
{
|
||||
this.updateMap = new HashMap<>();
|
||||
NBTTagCompound tags = ByteBufUtils.readTag( stream );
|
||||
this.list = new HashMap<>();
|
||||
NBTTagCompound tag = ByteBufUtils.readTag( stream );
|
||||
|
||||
for( final String key : tags.getKeySet() )
|
||||
for( final String key : tag.getKeySet() )
|
||||
{
|
||||
updateMap.put( Integer.parseInt( key ), tags.getCompoundTag( key ) );
|
||||
this.list.put( Integer.parseInt( key ), AEFluidStack.fromNBT( tag.getCompoundTag( key ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketFluidTank( final Map<Integer, NBTTagCompound> updateMap )
|
||||
public PacketFluidSlot( final Map<Integer, IAEFluidStack> list )
|
||||
{
|
||||
this.updateMap = updateMap;
|
||||
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
for( Map.Entry<Integer, NBTTagCompound> e : updateMap.entrySet() )
|
||||
this.list = list;
|
||||
final NBTTagCompound sendTag = new NBTTagCompound();
|
||||
for( Map.Entry<Integer, IAEFluidStack> fs : list.entrySet() )
|
||||
{
|
||||
tag.setTag( e.getKey().toString(), e.getValue() );
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
if( fs.getValue() != null )
|
||||
{
|
||||
fs.getValue().writeToNBT( tag );
|
||||
}
|
||||
sendTag.setTag( fs.getKey().toString(), tag );
|
||||
}
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
data.writeInt( this.getPacketID() );
|
||||
ByteBufUtils.writeTag( data, tag );
|
||||
ByteBufUtils.writeTag( data, sendTag );
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
public Map<Integer, NBTTagCompound> getUpdateMap()
|
||||
{
|
||||
return this.updateMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo manager, final AppEngPacket packet, final EntityPlayer player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof ContainerFluidInterface )
|
||||
if( c instanceof IFluidSyncContainer )
|
||||
{
|
||||
( (ContainerFluidInterface) c ).receiveTankInfo( this.updateMap );
|
||||
( (IFluidSyncContainer) c ).receiveFluidSlots( this.list );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
if( c instanceof IFluidSyncContainer )
|
||||
{
|
||||
( (IFluidSyncContainer) c ).receiveFluidSlots( this.list );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ import appeng.container.implementations.ContainerSecurityStation;
|
||||
import appeng.container.implementations.ContainerStorageBus;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import appeng.fluids.container.ContainerFluidStorageBus;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
|
||||
@@ -160,6 +161,11 @@ public class PacketValueConfig extends AppEngPacket
|
||||
final ContainerLevelEmitter lvc = (ContainerLevelEmitter) c;
|
||||
lvc.setLevel( Long.parseLong( this.Value ), player );
|
||||
}
|
||||
else if( this.Name.equals( "FluidLevelEmitter.Value" ) && c instanceof ContainerFluidLevelEmitter )
|
||||
{
|
||||
final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c;
|
||||
lvc.setLevel( Long.parseLong( this.Value ), player );
|
||||
}
|
||||
else if( this.Name.startsWith( "PatternTerminal." ) && c instanceof ContainerPatternTerm )
|
||||
{
|
||||
final ContainerPatternTerm cpt = (ContainerPatternTerm) c;
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -33,7 +32,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public class RenderTinyTNTPrimed extends Render
|
||||
public class RenderTinyTNTPrimed extends Render<EntityTinyTNTPrimed>
|
||||
{
|
||||
|
||||
public RenderTinyTNTPrimed( final RenderManager p_i46134_1_ )
|
||||
@@ -43,12 +42,7 @@ public class RenderTinyTNTPrimed extends Render
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender( final Entity tnt, final double x, final double y, final double z, final float unused, final float life )
|
||||
{
|
||||
this.renderPrimedTNT( (EntityTinyTNTPrimed) tnt, x, y, z, unused, life );
|
||||
}
|
||||
|
||||
private void renderPrimedTNT( final EntityTinyTNTPrimed tnt, final double x, final double y, final double z, final float unused, final float life )
|
||||
public void doRender( final EntityTinyTNTPrimed tnt, final double x, final double y, final double z, final float unused, final float life )
|
||||
{
|
||||
final BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
|
||||
GlStateManager.pushMatrix();
|
||||
@@ -105,7 +99,7 @@ public class RenderTinyTNTPrimed extends Render
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture( final Entity entity )
|
||||
protected ResourceLocation getEntityTexture( final EntityTinyTNTPrimed entity )
|
||||
{
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
|
||||
import appeng.fluids.container.ContainerFluidFormationPlane;
|
||||
import appeng.fluids.parts.PartFluidFormationPlane;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
public class GuiFluidFormationPlane extends GuiUpgradeable
|
||||
{
|
||||
private final PartFluidFormationPlane plane;
|
||||
private GuiTabButton priority;
|
||||
|
||||
public GuiFluidFormationPlane( InventoryPlayer inventoryPlayer, PartFluidFormationPlane te )
|
||||
{
|
||||
super( new ContainerFluidFormationPlane( inventoryPlayer, te ) );
|
||||
this.ySize = 251;
|
||||
this.plane = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
final IAEFluidTank config = this.plane.getConfig();
|
||||
final ContainerFluidFormationPlane container = (ContainerFluidFormationPlane) this.inventorySlots;
|
||||
|
||||
for( int y = 0; y < 7; y++ )
|
||||
{
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
final int idx = y * 9 + x;
|
||||
if( y < 2 )
|
||||
{
|
||||
this.guiSlots.add( new GuiFluidSlot( config, idx, idx, xo + x * 18, yo + y * 18 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( config, container, idx, idx, y - 2, xo, yo, x, y ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
if( btn == this.priority )
|
||||
{
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.FluidFormationPlane;
|
||||
}
|
||||
}
|
||||
@@ -21,11 +21,14 @@ package appeng.fluids.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
|
||||
import appeng.fluids.container.ContainerFluidIO;
|
||||
import appeng.fluids.parts.PartFluidImportBus;
|
||||
import appeng.fluids.parts.PartSharedFluidBus;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
/**
|
||||
@@ -35,10 +38,34 @@ import appeng.fluids.parts.PartFluidImportBus;
|
||||
*/
|
||||
public class GuiFluidIO extends GuiUpgradeable
|
||||
{
|
||||
private final PartSharedFluidBus bus;
|
||||
|
||||
public GuiFluidIO( InventoryPlayer inventoryPlayer, IUpgradeableHost te )
|
||||
public GuiFluidIO( InventoryPlayer inventoryPlayer, PartSharedFluidBus te )
|
||||
{
|
||||
super( new ContainerFluidIO( inventoryPlayer, te ) );
|
||||
this.bus = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
final ContainerFluidIO container = (ContainerFluidIO) this.inventorySlots;
|
||||
final IAEFluidTank inv = this.bus.getConfig();
|
||||
final int y = 40;
|
||||
final int x = 80;
|
||||
|
||||
this.guiSlots.add( new GuiFluidSlot( inv, 0, 0, x, y ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 1, 1, 1, x, y, -1, 0 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 2, 2, 1, x, y, 1, 0 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 3, 3, 1, x, y, 0, -1 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 4, 4, 1, x, y, 0, 1 ) );
|
||||
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 5, 5, 2, x, y, -1, -1 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 6, 6, 2, x, y, 1, -1 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 7, 7, 2, x, y, -1, 1 ) );
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 8, 8, 2, x, y, 1, 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,20 +24,21 @@ import java.io.IOException;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiFluidTank;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidTank;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.fluids.helper.AEFluidTank;
|
||||
import appeng.fluids.helper.DualityFluidInterface;
|
||||
import appeng.fluids.helper.IFluidInterfaceHost;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
public class GuiFluidInterface extends AEBaseGui
|
||||
public class GuiFluidInterface extends GuiUpgradeable
|
||||
{
|
||||
public final static int ID_BUTTON_TANK = 222;
|
||||
|
||||
@@ -56,17 +57,26 @@ public class GuiFluidInterface extends AEBaseGui
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
final IAEFluidTank configFluids = this.host.getDualityFluidInterface().getConfig();
|
||||
final IAEFluidTank fluidTank = this.host.getDualityFluidInterface().getTanks();
|
||||
|
||||
for( int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i )
|
||||
{
|
||||
final AEFluidTank fluidTank = this.host.getDualityFluidInterface().getTank( i );
|
||||
final GuiFluidTank guiTank = new GuiFluidTank( ID_BUTTON_TANK + i, fluidTank, this.getGuiLeft() + 35 + 18 * i, this.getGuiTop() + 53, 16, 68 );
|
||||
final GuiFluidTank guiTank = new GuiFluidTank( fluidTank, i, DualityFluidInterface.NUMBER_OF_TANKS + i, this.getGuiLeft() + 35 + 18 * i, this
|
||||
.getGuiTop() + 53, 16, 68 );
|
||||
this.buttonList.add( guiTank );
|
||||
this.guiSlots.add( new GuiFluidSlot( configFluids, i, i, 35 + 18 * i, 35 ) );
|
||||
}
|
||||
|
||||
this.priority = new GuiTabButton( this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender );
|
||||
this.buttonList.add( this.priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
|
||||
{
|
||||
@@ -93,4 +103,10 @@ public class GuiFluidInterface extends AEBaseGui
|
||||
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
|
||||
package appeng.fluids.client.gui;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.fluids.container.ContainerFluidLevelEmitter;
|
||||
import appeng.fluids.parts.PartFluidLevelEmitter;
|
||||
|
||||
|
||||
public class GuiFluidLevelEmitter extends GuiUpgradeable
|
||||
{
|
||||
private final PartFluidLevelEmitter levelEmitter;
|
||||
private GuiNumberBox level;
|
||||
|
||||
private GuiButton plus1;
|
||||
private GuiButton plus10;
|
||||
private GuiButton plus100;
|
||||
private GuiButton plus1000;
|
||||
private GuiButton minus1;
|
||||
private GuiButton minus10;
|
||||
private GuiButton minus100;
|
||||
private GuiButton minus1000;
|
||||
|
||||
public GuiFluidLevelEmitter( final InventoryPlayer inventoryPlayer, final PartFluidLevelEmitter te )
|
||||
{
|
||||
super( new ContainerFluidLevelEmitter( inventoryPlayer, te ) );
|
||||
this.levelEmitter = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
this.level = new GuiNumberBox( this.fontRenderer, this.guiLeft + 24, this.guiTop + 43, 79, this.fontRenderer.FONT_HEIGHT, Long.class );
|
||||
this.level.setEnableBackgroundDrawing( false );
|
||||
this.level.setMaxStringLength( 16 );
|
||||
this.level.setTextColor( 0xFFFFFF );
|
||||
this.level.setVisible( true );
|
||||
this.level.setFocused( true );
|
||||
( (ContainerFluidLevelEmitter) this.inventorySlots ).setTextField( this.level );
|
||||
|
||||
final int y = 40;
|
||||
final int x = 80 + 44;
|
||||
this.guiSlots.add( new GuiFluidSlot( this.levelEmitter.getConfig(), 0, 0, x, y ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
|
||||
|
||||
final int a = AEConfig.instance().levelByMillyBuckets( 0 );
|
||||
final int b = AEConfig.instance().levelByMillyBuckets( 1 );
|
||||
final int c = AEConfig.instance().levelByMillyBuckets( 2 );
|
||||
final int d = AEConfig.instance().levelByMillyBuckets( 3 );
|
||||
|
||||
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a ) );
|
||||
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b ) );
|
||||
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c ) );
|
||||
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d ) );
|
||||
|
||||
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a ) );
|
||||
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b ) );
|
||||
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c ) );
|
||||
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d ) );
|
||||
|
||||
this.buttonList.add( this.redstoneMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.level.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/lvlemitter.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.FluidLevelEmitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn ) throws IOException
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
|
||||
|
||||
if( isPlus || isMinus )
|
||||
{
|
||||
this.addQty( this.getQty( btn ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void addQty( final long i )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while( Out.startsWith( "0" ) && Out.length() > 1 )
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if( Fixed )
|
||||
{
|
||||
this.level.setText( Out );
|
||||
}
|
||||
|
||||
if( Out.isEmpty() )
|
||||
{
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
result += i;
|
||||
if( result < 0 )
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
|
||||
this.level.setText( Out = Long.toString( result ) );
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
// nope..
|
||||
this.level.setText( "0" );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key ) throws IOException
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if( ( key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit( character ) ) && this.level.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while( Out.startsWith( "0" ) && Out.length() > 1 )
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if( Fixed )
|
||||
{
|
||||
this.level.setText( Out );
|
||||
}
|
||||
|
||||
if( Out.isEmpty() )
|
||||
{
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
|
||||
}
|
||||
catch( final IOException e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,11 @@ 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.client.gui.widgets.GuiFluidSlot;
|
||||
import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
|
||||
import appeng.fluids.container.ContainerFluidStorageBus;
|
||||
import appeng.fluids.parts.PartFluidStorageBus;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
/**
|
||||
@@ -57,11 +60,41 @@ public class GuiFluidStorageBus extends GuiUpgradeable
|
||||
private GuiTabButton priority;
|
||||
private GuiImgButton partition;
|
||||
private GuiImgButton clear;
|
||||
private final PartFluidStorageBus bus;
|
||||
|
||||
public GuiFluidStorageBus( InventoryPlayer inventoryPlayer, PartFluidStorageBus te )
|
||||
{
|
||||
super( new ContainerFluidStorageBus( inventoryPlayer, te ) );
|
||||
this.ySize = 251;
|
||||
this.bus = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
final IAEFluidTank config = this.bus.getConfig();
|
||||
final ContainerFluidStorageBus container = (ContainerFluidStorageBus) this.inventorySlots;
|
||||
|
||||
for( int y = 0; y < 7; y++ )
|
||||
{
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
final int idx = y * 9 + x;
|
||||
if( y < 2 )
|
||||
{
|
||||
this.guiSlots.add( new GuiFluidSlot( config, idx, idx, xo + x * 18, yo + y * 18 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.guiSlots.add( new GuiOptionalFluidSlot( config, container, idx, idx, y - 2, xo, yo, x, y ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,6 +36,7 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
@@ -54,7 +55,6 @@ import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.container.ContainerFluidTerminal;
|
||||
import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.fluids.parts.PartFluidTerminal;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
@@ -73,19 +73,23 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
||||
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;
|
||||
protected ITerminalHost terminal;
|
||||
|
||||
private MEGuiTextField searchField;
|
||||
private GuiImgButton sortByBox;
|
||||
private GuiImgButton sortDirBox;
|
||||
|
||||
public GuiFluidTerminal( InventoryPlayer inventoryPlayer, PartFluidTerminal terminal )
|
||||
public GuiFluidTerminal( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
|
||||
{
|
||||
super( new ContainerFluidTerminal( inventoryPlayer, terminal ) );
|
||||
this.terminal = terminal;
|
||||
this( inventoryPlayer, te, new ContainerFluidTerminal( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
public GuiFluidTerminal( InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerFluidTerminal c )
|
||||
{
|
||||
super( c );
|
||||
this.terminal = te;
|
||||
this.xSize = 185;
|
||||
this.ySize = 222;
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
@@ -172,10 +176,10 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
||||
{
|
||||
final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot;
|
||||
|
||||
if( fluidSlot.getFluidStack() != null && fluidSlot.shouldRenderAsFluid() )
|
||||
if( fluidSlot.getAEFluidStack() != null && fluidSlot.shouldRenderAsFluid() )
|
||||
{
|
||||
final IAEFluidStack fluidStack = fluidSlot.getAEFluidStack();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( fluidStack.getStackSize() ) + " mB";
|
||||
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( fluidStack.getStackSize() / 1000.0 ) + " B";
|
||||
|
||||
final String modName = "" + TextFormatting.BLUE + TextFormatting.ITALIC + Loader.instance()
|
||||
.getIndexedModList()
|
||||
@@ -236,7 +240,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
||||
if( mouseButton == 0 && meSlot.getHasStack() )
|
||||
{
|
||||
this.container.setTargetStack( meSlot.getAEFluidStack() );
|
||||
AELog.info( "mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
AELog.debug( "mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.FILL_ITEM, slot.slotNumber, 0 ) );
|
||||
}
|
||||
else
|
||||
@@ -244,7 +248,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.container.setTargetStack( meSlot.getAEFluidStack() );
|
||||
if( meSlot.getAEFluidStack() != null )
|
||||
{
|
||||
AELog.info( "mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
AELog.debug( "mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
}
|
||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.EMPTY_ITEM, slot.slotNumber, 0 ) );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
|
||||
package appeng.fluids.client.gui.widgets;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.gui.widgets.GuiCustomSlot;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketFluidSlot;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
public class GuiFluidSlot extends GuiCustomSlot
|
||||
{
|
||||
private final IAEFluidTank fluids;
|
||||
private final int slot;
|
||||
|
||||
public GuiFluidSlot( final IAEFluidTank fluids, final int slot, final int id, final int x, final int y )
|
||||
{
|
||||
super( id, x, y );
|
||||
this.fluids = fluids;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@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
|
||||
public boolean canClick( final EntityPlayer player )
|
||||
{
|
||||
final ItemStack mouseStack = player.inventory.getItemStack();
|
||||
return mouseStack.isEmpty() || mouseStack.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slotClicked( final ItemStack clickStack, int mouseButton )
|
||||
{
|
||||
if( clickStack.isEmpty() || mouseButton == 1 )
|
||||
{
|
||||
this.setFluidStack( null );
|
||||
}
|
||||
else if( mouseButton == 0 )
|
||||
{
|
||||
final FluidStack fluid = FluidUtil.getFluidContained( clickStack );
|
||||
if( fluid != null )
|
||||
{
|
||||
this.setFluidStack( AEFluidStack.fromFluidStack( fluid ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
final IAEFluidStack fluid = getFluidStack();
|
||||
if( fluid != null )
|
||||
{
|
||||
return fluid.getFluidStack().getLocalizedName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public IAEFluidStack getFluidStack()
|
||||
{
|
||||
return this.fluids.getFluidInSlot( this.slot );
|
||||
}
|
||||
|
||||
public void setFluidStack( final IAEFluidStack stack )
|
||||
{
|
||||
this.fluids.setFluidInSlot( this.slot, stack );
|
||||
NetworkHandler.instance().sendToServer( new PacketFluidSlot( Collections.singletonMap( this.getId(), this.getFluidStack() ) ) );
|
||||
}
|
||||
}
|
||||
+33
-31
@@ -16,7 +16,7 @@
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
package appeng.fluids.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -24,23 +24,26 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public class GuiFluidTank extends GuiButton implements ITooltip
|
||||
{
|
||||
private final IFluidTank tank;
|
||||
private final IAEFluidTank tank;
|
||||
private final int slot;
|
||||
|
||||
public GuiFluidTank( int buttonId, IFluidTank tank, int x, int y, int w, int h )
|
||||
public GuiFluidTank( IAEFluidTank tank, int slot, int id, int x, int y, int w, int h )
|
||||
{
|
||||
super( buttonId, x, y, w, h, "" );
|
||||
super( id, x, y, w, h, "" );
|
||||
this.tank = tank;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,42 +56,41 @@ public class GuiFluidTank extends GuiButton implements ITooltip
|
||||
|
||||
drawRect( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 );
|
||||
|
||||
if( this.tank != null )
|
||||
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
|
||||
if( fluid != null && fluid.getStackSize() > 0 )
|
||||
{
|
||||
final FluidStack fluid = this.tank.getFluid();
|
||||
if( fluid != null && fluid.amount > 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 )
|
||||
{
|
||||
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.amount / this.tank.getCapacity() ) );
|
||||
|
||||
int iconHeightRemainder = scaledHeight % 16;
|
||||
if( iconHeightRemainder > 0 )
|
||||
{
|
||||
drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder, sprite, 16, iconHeightRemainder );
|
||||
}
|
||||
for( int i = 0; i < scaledHeight / 16; i++ )
|
||||
{
|
||||
drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder - ( i + 1 ) * 16, sprite, 16, 16 );
|
||||
}
|
||||
drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder, sprite, 16, iconHeightRemainder );
|
||||
}
|
||||
for( int i = 0; i < scaledHeight / 16; i++ )
|
||||
{
|
||||
drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder - ( i + 1 ) * 16, sprite, 16, 16 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
if( this.tank != null && this.tank.getFluid() != null && this.tank.getFluid().amount > 0 )
|
||||
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
|
||||
if( fluid != null && fluid.getStackSize() > 0 )
|
||||
{
|
||||
String desc = this.tank.getFluid().getFluid().getLocalizedName( this.tank.getFluid() );
|
||||
String amountToText = this.tank.getFluid().amount + "mB";
|
||||
String desc = fluid.getFluid().getLocalizedName( fluid.getFluidStack() );
|
||||
String amountToText = fluid.getStackSize() + "mB";
|
||||
|
||||
return desc + "\n" + amountToText;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
package appeng.fluids.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
public class GuiOptionalFluidSlot extends GuiFluidSlot
|
||||
{
|
||||
private final IOptionalSlotHost containerBus;
|
||||
private final int groupNum;
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
|
||||
public GuiOptionalFluidSlot( IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id, int groupNum, int x, int y, int xoffs, int yoffs )
|
||||
{
|
||||
super( fluids, slot, id, x + xoffs * 18, y + yoffs * 18 );
|
||||
this.containerBus = containerBus;
|
||||
this.groupNum = groupNum;
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.containerBus == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.containerBus.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getFluidStack()
|
||||
{
|
||||
if( !this.isSlotEnabled() && super.getFluidStack() != null )
|
||||
{
|
||||
this.setFluidStack( null );
|
||||
}
|
||||
return super.getFluidStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground( int guileft, int guitop )
|
||||
{
|
||||
GlStateManager.enableBlend();
|
||||
if( this.isSlotEnabled() )
|
||||
{
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
}
|
||||
else
|
||||
{
|
||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 0.4F );
|
||||
}
|
||||
this.drawTexturedModalRect( guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1, this.srcY - 1, this.getWidth() + 2,
|
||||
this.getHeight() + 2 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
|
||||
package appeng.fluids.container;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.fluids.helper.FluidSyncHelper;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public abstract class ContainerFluidConfigurable extends ContainerUpgradeable implements IFluidSyncContainer
|
||||
{
|
||||
private FluidSyncHelper sync = null;
|
||||
|
||||
public ContainerFluidConfigurable( InventoryPlayer ip, IUpgradeableHost te )
|
||||
{
|
||||
super( ip, te );
|
||||
}
|
||||
|
||||
public abstract IAEFluidTank getFluidConfigInventory();
|
||||
|
||||
private FluidSyncHelper getSynchHelper()
|
||||
{
|
||||
if( this.sync == null )
|
||||
{
|
||||
this.sync = new FluidSyncHelper( getFluidConfigInventory(), 0 );
|
||||
}
|
||||
return this.sync;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack transferStackToContainer( ItemStack input )
|
||||
{
|
||||
FluidStack fs = FluidUtil.getFluidContained( input );
|
||||
if( fs != null )
|
||||
{
|
||||
final IAEFluidTank t = getFluidConfigInventory();
|
||||
final IAEFluidStack stack = AEFluidStack.fromFluidStack( fs );
|
||||
for( int i = 0; i < t.getSlots(); ++i )
|
||||
{
|
||||
if( t.getFluidInSlot( i ) == null && this.isValidForConfig( i, stack ) )
|
||||
{
|
||||
t.setFluidInSlot( i, stack );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
protected boolean isValidForConfig( int slot, IAEFluidStack fs )
|
||||
{
|
||||
if( this.supportCapacity() )
|
||||
{
|
||||
// assumes 4 slots per upgrade
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
|
||||
if( slot > 0 && upgrades < 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( slot > 4 && upgrades < 2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void standardDetectAndSendChanges()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.getSynchHelper().sendDiff( this.listeners );
|
||||
|
||||
// clear out config items that are no longer valid (eg capacity upgrade removed)
|
||||
final IAEFluidTank t = getFluidConfigInventory();
|
||||
for( int i = 0; i < t.getSlots(); ++i )
|
||||
{
|
||||
if( t.getFluidInSlot( i ) != null && !this.isValidForConfig( i, t.getFluidInSlot( i ) ) )
|
||||
{
|
||||
t.setFluidInSlot( i, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
super.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( IContainerListener listener )
|
||||
{
|
||||
super.addListener( listener );
|
||||
this.getSynchHelper().sendFull( Collections.singleton( listener ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveFluidSlots( Map<Integer, IAEFluidStack> fluids )
|
||||
{
|
||||
this.getSynchHelper().readPacket( fluids );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
|
||||
package appeng.fluids.container;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.fluids.parts.PartFluidFormationPlane;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
public class ContainerFluidFormationPlane extends ContainerFluidConfigurable
|
||||
{
|
||||
private final PartFluidFormationPlane plane;
|
||||
|
||||
public ContainerFluidFormationPlane( final InventoryPlayer ip, final PartFluidFormationPlane te )
|
||||
{
|
||||
super( ip, te );
|
||||
this.plane = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidTank getFluidConfigInventory()
|
||||
{
|
||||
return plane.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
|
||||
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlotToContainer(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlotToContainer(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlotToContainer(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlotToContainer(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
this.checkToolbox();
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidForConfig( int slot, IAEFluidStack fs )
|
||||
{
|
||||
if( this.supportCapacity() )
|
||||
{
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
|
||||
final int y = slot / 9;
|
||||
|
||||
if( y >= upgrades + 2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled( final int idx )
|
||||
{
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
|
||||
return upgrades > idx;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
@@ -20,15 +20,9 @@ package appeng.fluids.container;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.fluids.container.slots.OptionalSlotFakeFluid;
|
||||
import appeng.fluids.container.slots.SlotFakeFluid;
|
||||
import appeng.fluids.parts.PartSharedFluidBus;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,40 +30,25 @@ import appeng.fluids.container.slots.SlotFakeFluid;
|
||||
* @version rv5 - 1/05/2018
|
||||
* @since rv5 1/05/2018
|
||||
*/
|
||||
public class ContainerFluidIO extends ContainerUpgradeable
|
||||
public class ContainerFluidIO extends ContainerFluidConfigurable
|
||||
{
|
||||
public ContainerFluidIO( InventoryPlayer ip, IUpgradeableHost te )
|
||||
private final PartSharedFluidBus bus;
|
||||
|
||||
public ContainerFluidIO( InventoryPlayer ip, PartSharedFluidBus te )
|
||||
{
|
||||
super( ip, te );
|
||||
this.bus = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidTank getFluidConfigInventory()
|
||||
{
|
||||
return bus.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
this.setupUpgrades();
|
||||
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
|
||||
final int y = 40;
|
||||
final int x = 80;
|
||||
this.addSlotToContainer( new SlotFakeFluid( inv, 0, x, y ) );
|
||||
|
||||
if( this.supportCapacity() )
|
||||
{
|
||||
this.addSlotToContainer( new OptionalSlotFakeFluid( inv, this, 1, x, y, -1, 0, 1 ) );
|
||||
this.addSlotToContainer( new OptionalSlotFakeFluid( inv, this, 2, x, y, 1, 0, 1 ) );
|
||||
this.addSlotToContainer( new OptionalSlotFakeFluid( inv, this, 3, x, y, 0, -1, 1 ) );
|
||||
this.addSlotToContainer( new OptionalSlotFakeFluid( inv, this, 4, x, y, 0, 1, 1 ) );
|
||||
|
||||
this.addSlotToContainer( new OptionalSlotFakeFluid( inv, this, 5, x, y, -1, -1, 2 ) );
|
||||
this.addSlotToContainer( new OptionalSlotFakeFluid( inv, this, 6, x, y, 1, -1, 2 ) );
|
||||
this.addSlotToContainer( new OptionalSlotFakeFluid( inv, this, 7, x, y, -1, 1, 2 ) );
|
||||
this.addSlotToContainer( new OptionalSlotFakeFluid( inv, this, 8, x, y, 1, 1, 2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidForSlot( Slot s, ItemStack i )
|
||||
{
|
||||
return s instanceof SlotFakeFluid ? i.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null ) : super.isValidForSlot( s, i );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,45 +19,45 @@
|
||||
package appeng.fluids.container;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketFluidTank;
|
||||
import appeng.fluids.container.slots.SlotFakeFluid;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.fluids.helper.DualityFluidInterface;
|
||||
import appeng.fluids.helper.FluidSyncHelper;
|
||||
import appeng.fluids.helper.IFluidInterfaceHost;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ContainerFluidInterface extends AEBaseContainer
|
||||
public class ContainerFluidInterface extends ContainerFluidConfigurable
|
||||
{
|
||||
private final DualityFluidInterface myDuality;
|
||||
private final FluidSyncHelper tankSync;
|
||||
|
||||
public ContainerFluidInterface( final InventoryPlayer ip, final IFluidInterfaceHost te )
|
||||
{
|
||||
super( ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) );
|
||||
super( ip, te.getDualityFluidInterface().getHost() );
|
||||
|
||||
this.myDuality = te.getDualityFluidInterface();
|
||||
this.tankSync = new FluidSyncHelper( this.myDuality.getTanks(), DualityFluidInterface.NUMBER_OF_TANKS );
|
||||
}
|
||||
|
||||
for( int x = 0; x < DualityFluidInterface.NUMBER_OF_TANKS; x++ )
|
||||
{
|
||||
this.addSlotToContainer( new SlotFakeFluid( this.myDuality.getConfig(), x, 35 + 18 * x, 35 ) );
|
||||
}
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 231;
|
||||
}
|
||||
|
||||
this.bindPlayerInventory( ip, 0, 231 - /* height of player inventory */82 );
|
||||
@Override
|
||||
public IAEFluidTank getFluidConfigInventory()
|
||||
{
|
||||
return this.myDuality.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,56 +67,49 @@ public class ContainerFluidInterface extends AEBaseContainer
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.sendTankUpdate();
|
||||
this.tankSync.sendDiff( this.listeners );
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( IContainerListener listener )
|
||||
protected void setupConfig()
|
||||
{
|
||||
super.addListener( listener );
|
||||
this.sendTankInfo( listener );
|
||||
}
|
||||
|
||||
private void sendTankUpdate( final IContainerListener l, final HashMap<Integer, NBTTagCompound> updateMap )
|
||||
{
|
||||
if( l instanceof EntityPlayerMP )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketFluidTank( updateMap ), (EntityPlayerMP) l );
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTankUpdate()
|
||||
{
|
||||
final HashMap<Integer, NBTTagCompound> updateMap = new HashMap<>();
|
||||
if( this.myDuality.writeTankInfo( updateMap, false ) )
|
||||
{
|
||||
for( final IContainerListener listener : this.listeners )
|
||||
{
|
||||
this.sendTankUpdate( listener, updateMap );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTankInfo( final IContainerListener l )
|
||||
{
|
||||
final HashMap<Integer, NBTTagCompound> updateMap = new HashMap<>();
|
||||
if( this.myDuality.writeTankInfo( updateMap, true ) )
|
||||
{
|
||||
this.sendTankUpdate( l, updateMap );
|
||||
}
|
||||
}
|
||||
|
||||
public void receiveTankInfo( final Map<Integer, NBTTagCompound> tankTags )
|
||||
{
|
||||
this.myDuality.readTankInfo( tankTags );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidForSlot( Slot s, ItemStack i )
|
||||
protected void loadSettingsFromHost( final IConfigManager cm )
|
||||
{
|
||||
return s instanceof SlotFakeFluid ? i.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null ) : super.isValidForSlot( s, i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( IContainerListener listener )
|
||||
{
|
||||
super.addListener( listener );
|
||||
this.tankSync.sendFull( Collections.singleton( listener ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveFluidSlots( Map<Integer, IAEFluidStack> fluids )
|
||||
{
|
||||
super.receiveFluidSlots( fluids );
|
||||
this.tankSync.readPacket( fluids );
|
||||
}
|
||||
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasToolbox()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
|
||||
package appeng.fluids.container;
|
||||
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.fluids.parts.PartFluidLevelEmitter;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ContainerFluidLevelEmitter extends ContainerFluidConfigurable
|
||||
{
|
||||
private final PartFluidLevelEmitter lvlEmitter;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private GuiTextField textField;
|
||||
@GuiSync( 3 )
|
||||
public long EmitterValue = -1;
|
||||
|
||||
public ContainerFluidLevelEmitter( final InventoryPlayer ip, final PartFluidLevelEmitter te )
|
||||
{
|
||||
super( ip, te );
|
||||
this.lvlEmitter = te;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void setTextField( final GuiTextField level )
|
||||
{
|
||||
this.textField = level;
|
||||
this.textField.setText( String.valueOf( this.EmitterValue ) );
|
||||
}
|
||||
|
||||
public void setLevel( final long l, final EntityPlayer player )
|
||||
{
|
||||
this.lvlEmitter.setReportingValue( l );
|
||||
this.EmitterValue = l;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
this.verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.EmitterValue = this.lvlEmitter.getReportingValue();
|
||||
this.setRedStoneMode( (RedstoneMode) this.getUpgradeable().getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) );
|
||||
}
|
||||
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate( final String field, final Object oldValue, final Object newValue )
|
||||
{
|
||||
if( field.equals( "EmitterValue" ) )
|
||||
{
|
||||
if( this.textField != null )
|
||||
{
|
||||
this.textField.setText( String.valueOf( this.EmitterValue ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidTank getFluidConfigInventory()
|
||||
{
|
||||
return this.lvlEmitter.getConfig();
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ package appeng.fluids.container;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -37,13 +36,10 @@ import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.fluids.container.slots.OptionalSlotFakeFluid;
|
||||
import appeng.fluids.container.slots.SlotFakeFluid;
|
||||
import appeng.fluids.parts.PartFluidStorageBus;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.iterators.NullIterator;
|
||||
|
||||
|
||||
@@ -52,7 +48,7 @@ import appeng.util.iterators.NullIterator;
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class ContainerFluidStorageBus extends ContainerUpgradeable
|
||||
public class ContainerFluidStorageBus extends ContainerFluidConfigurable
|
||||
{
|
||||
|
||||
private final PartFluidStorageBus storageBus;
|
||||
@@ -78,31 +74,39 @@ public class ContainerFluidStorageBus extends ContainerUpgradeable
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
|
||||
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlotToContainer(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlotToContainer(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlotToContainer(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
this.addSlotToContainer(
|
||||
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getInventoryPlayer() ) )
|
||||
.setNotDraggable() );
|
||||
}
|
||||
|
||||
final IItemHandler config = this.getUpgradeable().getInventoryByName( "config" );
|
||||
for( int y = 0; y < 7; y++ )
|
||||
@Override
|
||||
protected boolean isValidForConfig( int slot, IAEFluidStack fs )
|
||||
{
|
||||
if( this.supportCapacity() )
|
||||
{
|
||||
for( int x = 0; x < 9; x++ )
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
|
||||
final int y = slot / 9;
|
||||
|
||||
if( y >= upgrades + 2 )
|
||||
{
|
||||
if( y < 2 )
|
||||
{
|
||||
this.addSlotToContainer( new SlotFakeFluid( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.addSlotToContainer( new OptionalSlotFakeFluid( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
|
||||
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer() ) ).setNotDraggable() );
|
||||
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.getInventoryPlayer() ) ).setNotDraggable() );
|
||||
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.getInventoryPlayer() ) ).setNotDraggable() );
|
||||
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.getInventoryPlayer() ) ).setNotDraggable() );
|
||||
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.getInventoryPlayer() ) ).setNotDraggable() );
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,36 +146,39 @@ public class ContainerFluidStorageBus extends ContainerUpgradeable
|
||||
|
||||
public void clear()
|
||||
{
|
||||
ItemHandlerUtil.clear( this.getUpgradeable().getInventoryByName( "config" ) );
|
||||
IAEFluidTank h = this.storageBus.getConfig();
|
||||
for( int i = 0; i < h.getSlots(); ++i )
|
||||
{
|
||||
h.setFluidInSlot( i, null );
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public void partition()
|
||||
{
|
||||
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
|
||||
IAEFluidTank h = this.storageBus.getConfig();
|
||||
|
||||
final IMEInventory<IAEFluidStack> cellInv = this.storageBus.getInternalHandler();
|
||||
|
||||
Iterator<IAEFluidStack> i = new NullIterator<>();
|
||||
if( cellInv != null )
|
||||
{
|
||||
final IItemList<IAEFluidStack> list = cellInv.getAvailableItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList() );
|
||||
final IItemList<IAEFluidStack> list = cellInv
|
||||
.getAvailableItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList() );
|
||||
i = list.iterator();
|
||||
}
|
||||
|
||||
for( int x = 0; x < inv.getSlots(); x++ )
|
||||
for( int x = 0; x < h.getSlots(); x++ )
|
||||
{
|
||||
if( i.hasNext() && this.isSlotEnabled( ( x / 9 ) - 2 ) )
|
||||
{
|
||||
final ItemStack g = i.next().asItemStackRepresentation();
|
||||
ItemHandlerUtil.setStackInSlot( inv, x, g );
|
||||
h.setFluidInSlot( x, i.next() );
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.EMPTY );
|
||||
h.setFluidInSlot( x, null );
|
||||
}
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@@ -194,4 +201,10 @@ public class ContainerFluidStorageBus extends ContainerUpgradeable
|
||||
{
|
||||
this.storageFilter = storageFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidTank getFluidConfigInventory()
|
||||
{
|
||||
return this.storageBus.getConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -44,12 +44,16 @@ import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
@@ -63,7 +67,6 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEFluidInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketTargetFluidStack;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.parts.PartFluidTerminal;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.me.helpers.ChannelPowerSrc;
|
||||
@@ -84,14 +87,14 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
@GuiSync( 99 )
|
||||
public boolean hasPower = false;
|
||||
private PartFluidTerminal terminal;
|
||||
private ITerminalHost terminal;
|
||||
private IConfigManager serverCM;
|
||||
private IConfigManagerHost gui;
|
||||
private IGridNode networkNode;
|
||||
// Holds the fluid the client wishes to extract, or null for insert
|
||||
private IAEFluidStack clientRequestedTargetFluid = null;
|
||||
|
||||
public ContainerFluidTerminal( InventoryPlayer ip, PartFluidTerminal terminal )
|
||||
public ContainerFluidTerminal( InventoryPlayer ip, ITerminalHost terminal )
|
||||
{
|
||||
super( ip, terminal );
|
||||
this.terminal = terminal;
|
||||
@@ -104,17 +107,39 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
{
|
||||
this.serverCM = terminal.getConfigManager();
|
||||
this.monitor = terminal.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||
|
||||
if( this.monitor != null )
|
||||
{
|
||||
this.monitor.addListener( this, null );
|
||||
final IGridNode node = terminal.getGridNode( AEPartLocation.INTERNAL );
|
||||
if( node != null )
|
||||
|
||||
if( terminal instanceof IEnergySource )
|
||||
{
|
||||
this.networkNode = node;
|
||||
final IGrid g = node.getGrid();
|
||||
if( g != null )
|
||||
this.setPowerSource( (IEnergySource) terminal );
|
||||
}
|
||||
else if( terminal instanceof IGridHost || terminal instanceof IActionHost )
|
||||
{
|
||||
final IGridNode node;
|
||||
if( terminal instanceof IGridHost )
|
||||
{
|
||||
this.setPowerSource( new ChannelPowerSrc( this.networkNode, g.getCache( IEnergyGrid.class ) ) );
|
||||
node = ( (IGridHost) terminal ).getGridNode( AEPartLocation.INTERNAL );
|
||||
}
|
||||
else if( terminal instanceof IActionHost )
|
||||
{
|
||||
node = ( (IActionHost) terminal ).getActionableNode();
|
||||
}
|
||||
else
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
|
||||
if( node != null )
|
||||
{
|
||||
this.networkNode = node;
|
||||
final IGrid g = node.getGrid();
|
||||
if( g != null )
|
||||
{
|
||||
this.setPowerSource( new ChannelPowerSrc( this.networkNode, (IEnergySource) g.getCache( IEnergyGrid.class ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,29 +354,28 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
return;
|
||||
}
|
||||
ItemStack held = player.inventory.getItemStack();
|
||||
if( !held.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null ) )
|
||||
{ // For now only do simple i/o with held tanks
|
||||
if( held.getCount() != 1 )
|
||||
{
|
||||
// only support stacksize 1 for now
|
||||
return;
|
||||
}
|
||||
IFluidHandlerItem fh = FluidUtil.getFluidHandler( held );
|
||||
if( fh == null )
|
||||
{
|
||||
throw new NullPointerException( held.getDisplayName() + " did not give FLUID_HANDLER_ITEM_CAPABILITY" );
|
||||
// only fluid handlers items
|
||||
return;
|
||||
}
|
||||
boolean isBucket = held.getItem() == Items.BUCKET ||
|
||||
held.getItem() == Items.WATER_BUCKET ||
|
||||
held.getItem() == Items.LAVA_BUCKET ||
|
||||
held.getItem() == Items.MILK_BUCKET ||
|
||||
held.getItem() == ForgeModContainer.getInstance().universalBucket;
|
||||
boolean isBucket = held.getItem() == Items.BUCKET || held.getItem() == Items.WATER_BUCKET || held.getItem() == Items.LAVA_BUCKET || held
|
||||
.getItem() == Items.MILK_BUCKET || held.getItem() == ForgeModContainer.getInstance().universalBucket;
|
||||
|
||||
if( action == InventoryAction.FILL_ITEM && this.clientRequestedTargetFluid != null )
|
||||
{
|
||||
AEFluidStack stack = (AEFluidStack) this.clientRequestedTargetFluid.copy();
|
||||
|
||||
AELog.info( "Filling %s with %s, %s mb", held.getDisplayName(), this.clientRequestedTargetFluid.getFluidStack().getLocalizedName(),
|
||||
AELog.debug( "Filling %s with %s, %s mb", held.getDisplayName(), this.clientRequestedTargetFluid.getFluidStack().getLocalizedName(),
|
||||
stack.getStackSize() );
|
||||
|
||||
if( isBucket && stack.getStackSize() < 1000 )
|
||||
if( isBucket && stack.getStackSize() < Fluid.BUCKET_VOLUME )
|
||||
{ // Although buckets support less than a buckets worth of fluid, it does not display how much it holds
|
||||
return;
|
||||
}
|
||||
@@ -362,8 +386,8 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
stack.setStackSize( amountAllowed );
|
||||
|
||||
// Check if we can pull out of the system
|
||||
IAEFluidStack canPull = this.monitor.extractItems( stack, Actionable.SIMULATE, this.getActionSource() );
|
||||
if( canPull == null || canPull.getStackSize() < 1 || ( isBucket && canPull.getStackSize() < 1000 ) )
|
||||
IAEFluidStack canPull = Platform.poweredExtraction( this.getPowerSource(), this.monitor, stack, this.getActionSource(), Actionable.SIMULATE );
|
||||
if( canPull == null || canPull.getStackSize() < 1 || ( isBucket && canPull.getStackSize() != Fluid.BUCKET_VOLUME ) )
|
||||
{
|
||||
// Either we couldn't pull out of the system,
|
||||
// or we are using a bucket and can only pull out less than a buckets worth of fluid
|
||||
@@ -379,22 +403,16 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
return;
|
||||
}
|
||||
|
||||
if( isBucket )
|
||||
{
|
||||
// We need to handle buckets separately
|
||||
ItemStack filledBucket = FluidUtil.getFilledBucket( pulled.getFluidStack() );
|
||||
player.inventory.setItemStack( filledBucket );
|
||||
}
|
||||
else
|
||||
{
|
||||
fh.fill( pulled.getFluidStack(), true );
|
||||
}
|
||||
// Actually fill
|
||||
fh.fill( pulled.getFluidStack(), true );
|
||||
|
||||
player.inventory.setItemStack( fh.getContainer() );
|
||||
this.updateHeld( player );
|
||||
}
|
||||
else if( action == InventoryAction.EMPTY_ITEM )
|
||||
{
|
||||
// Empty held item
|
||||
AELog.info( "Emptying %s", held.getDisplayName() );
|
||||
AELog.debug( "Emptying %s", held.getDisplayName() );
|
||||
|
||||
// See how much we can drain from the item
|
||||
FluidStack extract = fh.drain( Integer.MAX_VALUE, false );
|
||||
@@ -404,31 +422,26 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
}
|
||||
|
||||
// Check if we can push into the system
|
||||
IAEFluidStack canPush = this.monitor.injectItems( AEFluidStack.fromFluidStack( extract ), Actionable.SIMULATE, this.getActionSource() );
|
||||
if( isBucket && canPush != null && canPush.getStackSize() > 0 )
|
||||
IAEFluidStack notPushed = Platform.poweredInsert( this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack( extract ),
|
||||
this.getActionSource(), Actionable.SIMULATE );
|
||||
if( isBucket && notPushed != null && notPushed.getStackSize() > 0 )
|
||||
{
|
||||
// We can't push enough for the bucket
|
||||
return;
|
||||
}
|
||||
|
||||
IAEFluidStack inserted = Platform.poweredInsert( this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack( extract ),
|
||||
IAEFluidStack notInserted = Platform.poweredInsert( this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack( extract ),
|
||||
this.getActionSource() );
|
||||
if( inserted != null && inserted.getStackSize() > 0 )
|
||||
if( notInserted != null && notInserted.getStackSize() > 0 )
|
||||
{
|
||||
// Only try to extract the amount we DID insert
|
||||
extract.amount -= Math.toIntExact( inserted.getStackSize() );
|
||||
extract.amount -= Math.toIntExact( notInserted.getStackSize() );
|
||||
}
|
||||
|
||||
if( isBucket )
|
||||
{
|
||||
// Remove bucket and replace with EmptyBucket
|
||||
player.inventory.setItemStack( new ItemStack( Items.BUCKET, 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Actually drain
|
||||
fh.drain( extract, true );
|
||||
}
|
||||
// Actually drain
|
||||
fh.drain( extract, true );
|
||||
|
||||
player.inventory.setItemStack( fh.getContainer() );
|
||||
this.updateHeld( player );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
package appeng.fluids.container;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
|
||||
|
||||
public interface IFluidSyncContainer
|
||||
{
|
||||
void receiveFluidSlots( final Map<Integer, IAEFluidStack> fluids );
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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.fluids.container.slots;
|
||||
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 3/05/2018
|
||||
* @since rv6 3/05/2018
|
||||
*/
|
||||
public interface IFluidSlot
|
||||
{
|
||||
FluidStack getFluidStack();
|
||||
|
||||
default boolean shouldRenderAsFluid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,12 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
* @version rv6
|
||||
* @since rv6
|
||||
*/
|
||||
public interface IMEFluidSlot extends IFluidSlot
|
||||
public interface IMEFluidSlot
|
||||
{
|
||||
IAEFluidStack getAEFluidStack();
|
||||
|
||||
default boolean shouldRenderAsFluid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* 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.fluids.container.slots;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.container.slot.IOptionalSlot;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 1/05/2018
|
||||
* @since rv6 1/05/2018
|
||||
*/
|
||||
public class OptionalSlotFakeFluid extends SlotFakeFluid implements IOptionalSlot
|
||||
{
|
||||
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
private boolean renderDisabled = true;
|
||||
|
||||
public OptionalSlotFakeFluid( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
|
||||
{
|
||||
super( inv, idx, x + offX * 18, y + offY * 18 );
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack()
|
||||
{
|
||||
if( !this.isSlotEnabled() )
|
||||
{
|
||||
if( !this.getDisplayStack().isEmpty() )
|
||||
{
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled()
|
||||
{
|
||||
if( this.host == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled( this.groupNum );
|
||||
}
|
||||
|
||||
public boolean isRenderDisabled()
|
||||
{
|
||||
return this.renderDisabled;
|
||||
}
|
||||
|
||||
public void setRenderDisabled( final boolean renderDisabled )
|
||||
{
|
||||
this.renderDisabled = renderDisabled;
|
||||
}
|
||||
|
||||
public int getSourceX()
|
||||
{
|
||||
return this.srcX;
|
||||
}
|
||||
|
||||
public int getSourceY()
|
||||
{
|
||||
return this.srcY;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* 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.fluids.container.slots;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.container.slot.SlotFake;
|
||||
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 1/05/2018
|
||||
* @since rv6 1/05/2018
|
||||
*/
|
||||
public class SlotFakeFluid extends SlotFake implements IFluidSlot
|
||||
{
|
||||
public SlotFakeFluid( IItemHandler inv, int idx, int x, int y )
|
||||
{
|
||||
super( inv, idx, x, y );
|
||||
this.setIIcon( 12 * 16 + 15 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
if( this.isItemValid( is ) || is.isEmpty() )
|
||||
{
|
||||
super.putStack( is );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid( ItemStack stack )
|
||||
{
|
||||
return stack.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null ) && this.getContainer().isValidForSlot( this, stack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderIconWithItem()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluidStack()
|
||||
{
|
||||
if( !this.getStack().isEmpty() )
|
||||
{
|
||||
IFluidHandlerItem fh = this.getStack().getCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null );
|
||||
if( fh == null )
|
||||
{
|
||||
throw new NullPointerException( "Item did not give IFluidHandlerItem: " + this.getStack().getDisplayName() );
|
||||
}
|
||||
return fh.drain( Integer.MAX_VALUE, false );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -19,25 +19,21 @@
|
||||
package appeng.fluids.helper;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidHandlerConcatenate;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
@@ -59,38 +55,38 @@ import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.fluids.util.AEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.me.storage.MEMonitorIFluidHandler;
|
||||
import appeng.me.storage.MEMonitorPassThrough;
|
||||
import appeng.me.storage.NullInventory;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
|
||||
public class DualityFluidInterface implements IGridTickable, IStorageMonitorable, IAEFluidInventory, IAEAppEngInventory, IPriorityHost
|
||||
public class DualityFluidInterface implements IGridTickable, IStorageMonitorable, IAEFluidInventory, IUpgradeableHost, IConfigManagerHost
|
||||
{
|
||||
public static final int NUMBER_OF_TANKS = 6;
|
||||
public static final int TANK_CAPACITY = Fluid.BUCKET_VOLUME * 4;
|
||||
|
||||
private final ConfigManager cm = new ConfigManager( this );
|
||||
private final AENetworkProxy gridProxy;
|
||||
private final IFluidInterfaceHost iHost;
|
||||
private final IActionSource mySource;
|
||||
private final IActionSource interfaceRequestSource;
|
||||
private boolean hasConfig = false;
|
||||
private final IStorageMonitorableAccessor accessor = this::getMonitorable;
|
||||
private final AEFluidTank[] tanks;
|
||||
private final IFluidHandler storage;
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, NUMBER_OF_TANKS );
|
||||
private final IAEFluidStack[] configStacks;
|
||||
private final AEFluidInventory tanks = new AEFluidInventory( this, NUMBER_OF_TANKS, TANK_CAPACITY );
|
||||
private final AEFluidInventory config = new AEFluidInventory( this, NUMBER_OF_TANKS );
|
||||
private final IAEFluidStack[] requireWork;
|
||||
private final boolean[] tankChanged;
|
||||
private int isWorking = -1;
|
||||
private int priority;
|
||||
|
||||
@@ -113,18 +109,24 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
this.fluids.setChangeSource( this.mySource );
|
||||
this.items.setChangeSource( this.mySource );
|
||||
|
||||
this.tanks = new AEFluidTank[NUMBER_OF_TANKS];
|
||||
this.requireWork = new IAEFluidStack[NUMBER_OF_TANKS];
|
||||
this.configStacks = new IAEFluidStack[NUMBER_OF_TANKS];
|
||||
this.tankChanged = new boolean[NUMBER_OF_TANKS];
|
||||
for( int i = 0; i < NUMBER_OF_TANKS; ++i )
|
||||
{
|
||||
this.tanks[i] = new AEFluidTank( this, TANK_CAPACITY );
|
||||
this.requireWork[i] = null;
|
||||
this.configStacks[i] = null;
|
||||
this.tankChanged[i] = false;
|
||||
}
|
||||
this.storage = new FluidHandlerConcatenate( this.tanks );
|
||||
}
|
||||
|
||||
public IUpgradeableHost getHost()
|
||||
{
|
||||
if( this.iHost instanceof IUpgradeableHost )
|
||||
{
|
||||
return (IUpgradeableHost) this.iHost;
|
||||
}
|
||||
if( this.iHost instanceof IUpgradeableHost )
|
||||
{
|
||||
return (IUpgradeableHost) this.iHost;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,7 +239,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
{
|
||||
if( capabilityClass == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY )
|
||||
{
|
||||
return (T) this.storage;
|
||||
return (T) this.tanks;
|
||||
}
|
||||
else if( capabilityClass == Capabilities.STORAGE_MONITORABLE_ACCESSOR )
|
||||
{
|
||||
@@ -257,20 +259,6 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
for( int x = 0; x < NUMBER_OF_TANKS; x++ )
|
||||
{
|
||||
this.configStacks[x] = null;
|
||||
ItemStack is = this.config.getStackInSlot( x );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
IFluidHandlerItem fh = is.getCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null );
|
||||
if( fh != null )
|
||||
{
|
||||
FluidStack fs = fh.drain( Fluid.BUCKET_VOLUME, false );
|
||||
if( fs != null && fs.amount > 0 )
|
||||
{
|
||||
this.configStacks[x] = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createStack( fs );
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updatePlan( x );
|
||||
}
|
||||
|
||||
@@ -324,49 +312,38 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
return false;
|
||||
}
|
||||
|
||||
private int getTankSlot( final IFluidHandler inventory )
|
||||
{
|
||||
for( int i = 0; i < NUMBER_OF_TANKS; ++i )
|
||||
{
|
||||
if( this.tanks[i] == inventory )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
private void updatePlan( final int slot )
|
||||
{
|
||||
final IAEFluidStack req = this.configStacks[slot];
|
||||
final FluidStack stored = this.tanks[slot].drain( TANK_CAPACITY, false );
|
||||
final IAEFluidStack req = this.config.getFluidInSlot( slot );
|
||||
final IAEFluidStack stored = this.tanks.getFluidInSlot( slot );
|
||||
|
||||
if( req == null && ( stored != null && stored.amount > 0 ) )
|
||||
if( req == null && ( stored != null && stored.getStackSize() > 0 ) )
|
||||
{
|
||||
final IAEFluidStack work = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createStack( stored );
|
||||
final IAEFluidStack work = stored.copy();
|
||||
this.requireWork[slot] = work.setStackSize( -work.getStackSize() );
|
||||
return;
|
||||
}
|
||||
else if( req != null )
|
||||
{
|
||||
if( stored == null || stored.amount == 0 ) // need to add stuff!
|
||||
if( stored == null || stored.getStackSize() == 0 ) // need to add stuff!
|
||||
{
|
||||
this.requireWork[slot] = req.copy();
|
||||
this.requireWork[slot].setStackSize( TANK_CAPACITY );
|
||||
return;
|
||||
}
|
||||
else if( req.getFluid().equals( stored.getFluid() ) ) // same type ( qty different? )!
|
||||
else if( req.equals( stored ) ) // same type ( qty different? )!
|
||||
{
|
||||
if( stored.amount < TANK_CAPACITY )
|
||||
if( stored.getStackSize() < TANK_CAPACITY )
|
||||
{
|
||||
this.requireWork[slot] = req.copy();
|
||||
this.requireWork[slot].setStackSize( TANK_CAPACITY - stored.amount );
|
||||
this.requireWork[slot].setStackSize( TANK_CAPACITY - stored.getStackSize() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
// Stored != null; dispose!
|
||||
{
|
||||
final IAEFluidStack work = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createStack( stored );
|
||||
final IAEFluidStack work = stored.copy();
|
||||
this.requireWork[slot] = work.setStackSize( -work.getStackSize() );
|
||||
return;
|
||||
}
|
||||
@@ -377,7 +354,6 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
private boolean usePlan( final int slot )
|
||||
{
|
||||
IFluidHandler tank = this.tanks[slot];
|
||||
IAEFluidStack work = this.requireWork[slot];
|
||||
this.isWorking = slot;
|
||||
|
||||
@@ -391,7 +367,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
if( work.getStackSize() > 0 )
|
||||
{
|
||||
// make sure strange things didn't happen...
|
||||
if( tank.fill( work.getFluidStack(), false ) != work.getStackSize() )
|
||||
if( this.tanks.fill( slot, work.getFluidStack(), false ) != work.getStackSize() )
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
@@ -401,7 +377,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
if( acquired != null )
|
||||
{
|
||||
changed = true;
|
||||
final int filled = tank.fill( acquired.getFluidStack(), true );
|
||||
final int filled = this.tanks.fill( slot, acquired.getFluidStack(), true );
|
||||
if( filled != acquired.getStackSize() )
|
||||
{
|
||||
throw new IllegalStateException( "bad attempt at managing tanks. ( fill )" );
|
||||
@@ -415,7 +391,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
toStore.setStackSize( -toStore.getStackSize() );
|
||||
|
||||
// make sure strange things didn't happen...
|
||||
final FluidStack canExtract = tank.drain( toStore.getFluidStack(), false );
|
||||
final FluidStack canExtract = this.tanks.drain( slot, toStore.getFluidStack(), false );
|
||||
if( canExtract == null || canExtract.amount != toStore.getStackSize() )
|
||||
{
|
||||
changed = true;
|
||||
@@ -429,7 +405,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
{
|
||||
// extract items!
|
||||
changed = true;
|
||||
final FluidStack removed = tank.drain( toStore.getFluidStack(), true );
|
||||
final FluidStack removed = this.tanks.drain( slot, toStore.getFluidStack(), true );
|
||||
if( removed == null || toStore.getStackSize() != removed.amount )
|
||||
{
|
||||
throw new IllegalStateException( "bad attempt at managing tanks. ( drain )" );
|
||||
@@ -453,65 +429,53 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged( final IFluidHandler inventory )
|
||||
{
|
||||
final int slot = this.getTankSlot( inventory );
|
||||
|
||||
this.tankChanged[slot] = true;
|
||||
this.saveChanges();
|
||||
|
||||
if( this.isWorking == slot )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean had = this.hasWorkToDo();
|
||||
|
||||
this.updatePlan( slot );
|
||||
|
||||
final boolean now = this.hasWorkToDo();
|
||||
|
||||
if( had != now )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( now )
|
||||
{
|
||||
this.gridProxy.getTick().alertDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
||||
public void onFluidInventoryChanged( final IAEFluidTank inventory, final int slot )
|
||||
{
|
||||
if( this.isWorking == slot )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( inv == this.config )
|
||||
if( inventory == this.config )
|
||||
{
|
||||
this.readConfig();
|
||||
}
|
||||
else if( inventory == this.tanks )
|
||||
{
|
||||
this.saveChanges();
|
||||
|
||||
final boolean had = this.hasWorkToDo();
|
||||
|
||||
this.updatePlan( slot );
|
||||
|
||||
final boolean now = this.hasWorkToDo();
|
||||
|
||||
if( had != now )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( now )
|
||||
{
|
||||
this.gridProxy.getTick().alertDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority( final int newValue )
|
||||
{
|
||||
this.priority = newValue;
|
||||
@@ -519,69 +483,27 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
public void writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
final NBTTagList tankContents = new NBTTagList();
|
||||
for( int i = 0; i < NUMBER_OF_TANKS; ++i )
|
||||
{
|
||||
tankContents.appendTag( this.tanks[i].writeToNBT( new NBTTagCompound() ) );
|
||||
}
|
||||
|
||||
data.setInteger( "priority", this.priority );
|
||||
data.setTag( "storage", tankContents );
|
||||
this.tanks.writeToNBT( data, "storage" );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
}
|
||||
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
this.config.readFromNBT( data, "config" );
|
||||
final NBTTagList tankContents = data.getTagList( "storage", 10 );
|
||||
if( tankContents != null )
|
||||
{
|
||||
for( int i = 0; i < Math.min( NUMBER_OF_TANKS, tankContents.tagCount() ); ++i )
|
||||
{
|
||||
this.tanks[i].readFromNBT( tankContents.getCompoundTagAt( i ) );
|
||||
}
|
||||
}
|
||||
this.tanks.readFromNBT( data, "storage" );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
this.readConfig();
|
||||
}
|
||||
|
||||
public IItemHandler getConfig()
|
||||
public IAEFluidTank getConfig()
|
||||
{
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public AEFluidTank getTank( final int i )
|
||||
public IAEFluidTank getTanks()
|
||||
{
|
||||
return this.tanks[i];
|
||||
}
|
||||
|
||||
public boolean writeTankInfo( final Map<Integer, NBTTagCompound> tagMap, boolean all )
|
||||
{
|
||||
boolean empty = true;
|
||||
for( int i = 0; i < NUMBER_OF_TANKS; ++i )
|
||||
{
|
||||
if( all || this.tankChanged[i] )
|
||||
{
|
||||
tagMap.put( i, this.tanks[i].writeToNBT( new NBTTagCompound() ) );
|
||||
this.tankChanged[i] = !all;
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
return !empty;
|
||||
}
|
||||
|
||||
public boolean readTankInfo( final Map<Integer, NBTTagCompound> tagMap )
|
||||
{
|
||||
boolean changed = false;
|
||||
for( int i = 0; i < NUMBER_OF_TANKS; ++i )
|
||||
{
|
||||
if( tagMap.containsKey( i ) )
|
||||
{
|
||||
this.tanks[i].readFromNBT( tagMap.get( i ) );
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
return this.tanks;
|
||||
}
|
||||
|
||||
private class InterfaceRequestSource extends MachineSource
|
||||
@@ -620,7 +542,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
InterfaceInventory( final DualityFluidInterface tileInterface )
|
||||
{
|
||||
super( tileInterface.storage );
|
||||
super( tileInterface.tanks );
|
||||
this.setActionSource( new MachineSource( tileInterface.iHost ) );
|
||||
}
|
||||
|
||||
@@ -653,10 +575,37 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
this.iHost.getTileEntity().markDirty();
|
||||
this.iHost.saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( String name )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTile()
|
||||
{
|
||||
return (TileEntity) ( this.iHost instanceof TileEntity ? this.iHost : null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.contents;
|
||||
package appeng.fluids.helper;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -0,0 +1,98 @@
|
||||
|
||||
package appeng.fluids.helper;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketFluidSlot;
|
||||
import appeng.fluids.util.AEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
|
||||
public class FluidSyncHelper
|
||||
{
|
||||
private final IAEFluidTank inv;
|
||||
private final IAEFluidTank cache;
|
||||
private final int idOffset;
|
||||
|
||||
public FluidSyncHelper( final IAEFluidTank inv, final int idOffset )
|
||||
{
|
||||
this.inv = inv;
|
||||
this.cache = new AEFluidInventory( null, inv.getSlots() );
|
||||
this.idOffset = idOffset;
|
||||
}
|
||||
|
||||
public void sendFull( final Iterable<IContainerListener> listeners )
|
||||
{
|
||||
this.sendDiffMap( this.createDiffMap( true ), listeners );
|
||||
}
|
||||
|
||||
public void sendDiff( final Iterable<IContainerListener> listeners )
|
||||
{
|
||||
this.sendDiffMap( this.createDiffMap( false ), listeners );
|
||||
}
|
||||
|
||||
public void readPacket( final Map<Integer, IAEFluidStack> data )
|
||||
{
|
||||
for( int i = 0; i < this.inv.getSlots(); ++i )
|
||||
{
|
||||
if( data.containsKey( i + this.idOffset ) )
|
||||
{
|
||||
this.inv.setFluidInSlot( i, data.get( i + this.idOffset ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendDiffMap( final Map<Integer, IAEFluidStack> data, final Iterable<IContainerListener> listeners )
|
||||
{
|
||||
if( data.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for( final IContainerListener l : listeners )
|
||||
{
|
||||
if( l instanceof EntityPlayerMP )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketFluidSlot( data ), (EntityPlayerMP) l );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<Integer, IAEFluidStack> createDiffMap( final boolean full )
|
||||
{
|
||||
final Map<Integer, IAEFluidStack> ret = new HashMap<>();
|
||||
for( int i = 0; i < this.inv.getSlots(); ++i )
|
||||
{
|
||||
if( full || !this.equalsSlot( i ) )
|
||||
{
|
||||
ret.put( i + this.idOffset, this.inv.getFluidInSlot( i ) );
|
||||
}
|
||||
if( !full )
|
||||
{
|
||||
this.cache.setFluidInSlot( i, this.inv.getFluidInSlot( i ) );
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private final boolean equalsSlot( int slot )
|
||||
{
|
||||
final IAEFluidStack stackA = this.inv.getFluidInSlot( slot );
|
||||
final IAEFluidStack stackB = this.cache.getFluidInSlot( slot );
|
||||
|
||||
if( !Objects.equals( stackA, stackB ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return stackA == null || stackA.getStackSize() == stackB.getStackSize();
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,18 @@ import java.util.EnumSet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
|
||||
|
||||
public interface IFluidInterfaceHost extends IActionHost, IGridProxyable
|
||||
public interface IFluidInterfaceHost extends IActionHost, IGridProxyable, IUpgradeableHost
|
||||
{
|
||||
DualityFluidInterface getDualityFluidInterface();
|
||||
|
||||
EnumSet<EnumFacing> getTargets();
|
||||
|
||||
TileEntity getTileEntity();
|
||||
|
||||
void saveChanges();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import appeng.api.AEApi;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.fluids.contents.FluidCellConfig;
|
||||
import appeng.fluids.helper.FluidCellConfig;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import appeng.items.storage.AbstractStorageCell;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
@@ -78,6 +78,6 @@ public class FluidDummyItem extends AEBaseItem
|
||||
@Override
|
||||
protected void getCheckedSubItems( final CreativeTabs creativeTab, final NonNullList<ItemStack> itemStacks )
|
||||
{
|
||||
//Don't show this item in CreativeTabs
|
||||
// Don't show this item in CreativeTabs
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,322 @@
|
||||
|
||||
package appeng.fluids.parts;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.core.sync.packets.PacketTransitionEffect;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.parts.automation.PlaneConnections;
|
||||
import appeng.parts.automation.PlaneModels;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PartFluidAnnihilationPlane extends PartBasicState implements IGridTickable
|
||||
{
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/fluid_annihilation_plane_", "part/fluid_annihilation_plane_on_" );
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
{
|
||||
return MODELS.getModels();
|
||||
}
|
||||
|
||||
private final IActionSource mySrc = new MachineSource( this );
|
||||
|
||||
public PartFluidAnnihilationPlane( final ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( final IPartCollisionHelper bch )
|
||||
{
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if( host != null )
|
||||
{
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final BlockPos pos = te.getPos();
|
||||
|
||||
final EnumFacing e = bch.getWorldX();
|
||||
final EnumFacing u = bch.getWorldY();
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( e.getOpposite() ) ), this.getSide() ) )
|
||||
{
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( e ) ), this.getSide() ) )
|
||||
{
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( u.getOpposite() ) ), this.getSide() ) )
|
||||
{
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( e ) ), this.getSide() ) )
|
||||
{
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( minX, minY, 15, maxX, maxY, 16 );
|
||||
}
|
||||
|
||||
public PlaneConnections getConnections()
|
||||
{
|
||||
|
||||
final EnumFacing facingRight, facingUp;
|
||||
AEPartLocation location = this.getSide();
|
||||
switch( location )
|
||||
{
|
||||
case UP:
|
||||
facingRight = EnumFacing.EAST;
|
||||
facingUp = EnumFacing.NORTH;
|
||||
break;
|
||||
case DOWN:
|
||||
facingRight = EnumFacing.WEST;
|
||||
facingUp = EnumFacing.NORTH;
|
||||
break;
|
||||
case NORTH:
|
||||
facingRight = EnumFacing.WEST;
|
||||
facingUp = EnumFacing.UP;
|
||||
break;
|
||||
case SOUTH:
|
||||
facingRight = EnumFacing.EAST;
|
||||
facingUp = EnumFacing.UP;
|
||||
break;
|
||||
case WEST:
|
||||
facingRight = EnumFacing.SOUTH;
|
||||
facingUp = EnumFacing.UP;
|
||||
break;
|
||||
case EAST:
|
||||
facingRight = EnumFacing.NORTH;
|
||||
facingUp = EnumFacing.UP;
|
||||
break;
|
||||
default:
|
||||
case INTERNAL:
|
||||
return PlaneConnections.of( false, false, false, false );
|
||||
}
|
||||
|
||||
boolean left = false, right = false, down = false, up = false;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if( host != null )
|
||||
{
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final BlockPos pos = te.getPos();
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingRight.getOpposite() ) ), this.getSide() ) )
|
||||
{
|
||||
left = true;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingRight ) ), this.getSide() ) )
|
||||
{
|
||||
right = true;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingUp.getOpposite() ) ), this.getSide() ) )
|
||||
{
|
||||
down = true;
|
||||
}
|
||||
|
||||
if( this.isAnnihilationPlane( te.getWorld().getTileEntity( pos.offset( facingUp ) ), this.getSide() ) )
|
||||
{
|
||||
up = true;
|
||||
}
|
||||
}
|
||||
|
||||
return PlaneConnections.of( up, right, down, left );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||
{
|
||||
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
|
||||
{
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCableConnectionLength( AECableType cable )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
private boolean isAnnihilationPlane( final TileEntity blockTileEntity, final AEPartLocation side )
|
||||
{
|
||||
if( blockTileEntity instanceof IPartHost )
|
||||
{
|
||||
final IPart p = ( (IPartHost) blockTileEntity ).getPart( side );
|
||||
return p != null && p.getClass() == this.getClass();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void refresh()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.getProxy().getTick().alertDevice( this.getProxy().getNode() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender( final MENetworkChannelsChanged c )
|
||||
{
|
||||
this.refresh();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.refresh();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
private TickRateModulation pickupFluid()
|
||||
{
|
||||
if( !this.getProxy().isActive() )
|
||||
{
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
final TileEntity te = this.getTile();
|
||||
final World w = te.getWorld();
|
||||
final BlockPos pos = te.getPos().offset( this.getSide().getFacing() );
|
||||
final IBlockState state = w.getBlockState( pos );
|
||||
final Block block = state.getBlock();
|
||||
|
||||
if( block instanceof IFluidBlock || block instanceof BlockLiquid )
|
||||
{
|
||||
final IFluidHandler fh = FluidUtil.getFluidHandler( w, pos, null );
|
||||
final IAEFluidStack blockFluid = AEFluidStack.fromFluidStack( fh.drain( Integer.MAX_VALUE, false ) );
|
||||
|
||||
if( blockFluid != null )
|
||||
{
|
||||
if( this.storeFluid( blockFluid, false ) )
|
||||
{
|
||||
this.storeFluid( AEFluidStack.fromFluidStack( fh.drain( Integer.MAX_VALUE, true ) ), true );
|
||||
|
||||
AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, w,
|
||||
new PacketTransitionEffect( pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true ) );
|
||||
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
// nothing to do here :)
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( final IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.AnnihilationPlane.getMin(), TickRates.AnnihilationPlane.getMax(), false, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
|
||||
{
|
||||
return this.pickupFluid();
|
||||
}
|
||||
|
||||
private boolean storeFluid( IAEFluidStack stack, boolean modulate )
|
||||
{
|
||||
try
|
||||
{
|
||||
final IStorageGrid storage = this.getProxy().getStorage();
|
||||
final IMEInventory<IAEFluidStack> inv = storage.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||
|
||||
if( modulate )
|
||||
{
|
||||
final IEnergyGrid energy = this.getProxy().getEnergy();
|
||||
return Platform.poweredInsert( energy, inv, stack, this.mySrc ) == null;
|
||||
}
|
||||
else
|
||||
{
|
||||
final float requiredPower = (float) stack.getStackSize() / Math.min( 1.0f, stack.getChannel().transferFactor() );
|
||||
final IEnergyGrid energy = this.getProxy().getEnergy();
|
||||
|
||||
if( energy.extractAEPower( requiredPower, Actionable.SIMULATE, PowerMultiplier.CONFIG ) < requiredPower )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return inv.injectItems( stack, Actionable.SIMULATE, this.mySrc ) == null;
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.getConnections(), this.isPowered(), this.isActive() );
|
||||
}
|
||||
}
|
||||
@@ -21,14 +21,11 @@ package appeng.fluids.parts;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Verify;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -44,10 +41,8 @@ import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
@@ -120,15 +115,10 @@ public class PartFluidExportBus extends PartSharedFluidBus
|
||||
{
|
||||
for( int i = 0; i < this.getConfig().getSlots(); i++ )
|
||||
{
|
||||
final IAEItemStack stack = this.getConfig().getAEStackInSlot( i );
|
||||
|
||||
if( stack != null && stack.getDefinition() != null )
|
||||
IAEFluidStack fluid = this.getConfig().getFluidInSlot( i );
|
||||
if( fluid != null )
|
||||
{
|
||||
final IFluidHandlerItem ifh = stack.getDefinition().getCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null );
|
||||
|
||||
Verify.verifyNotNull( ifh, "IFluidHandlerItem is null" );
|
||||
|
||||
final AEFluidStack toExtract = AEFluidStack.fromFluidStack( ifh.drain( Integer.MAX_VALUE, false ) );
|
||||
final IAEFluidStack toExtract = fluid.copy();
|
||||
|
||||
toExtract.setStackSize( this.calculateAmountToSend() );
|
||||
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
|
||||
package appeng.fluids.parts;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.fluids.util.AEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.parts.automation.PartAbstractFormationPlane;
|
||||
import appeng.parts.automation.PlaneModels;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
|
||||
|
||||
public class PartFluidFormationPlane extends PartAbstractFormationPlane<IAEFluidStack> implements IAEFluidInventory
|
||||
{
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/fluid_formation_plane_", "part/fluid_formation_plane_on_" );
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
{
|
||||
return MODELS.getModels();
|
||||
}
|
||||
|
||||
private final MEInventoryHandler<IAEFluidStack> myHandler = new MEInventoryHandler<>( this, AEApi.instance()
|
||||
.storage()
|
||||
.getStorageChannel( IFluidStorageChannel.class ) );
|
||||
private final AEFluidInventory config = new AEFluidInventory( this, 63 );
|
||||
|
||||
public PartFluidFormationPlane( final ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateHandler()
|
||||
{
|
||||
this.myHandler.setBaseAccess( AccessRestriction.WRITE );
|
||||
this.myHandler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
|
||||
this.myHandler.setPriority( this.getPriority() );
|
||||
|
||||
final IItemList<IAEFluidStack> priorityList = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
|
||||
final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
||||
for( int x = 0; x < this.config.getSlots() && x < slotsToUse; x++ )
|
||||
{
|
||||
final IAEFluidStack is = this.config.getFluidInSlot( x );
|
||||
if( is != null )
|
||||
{
|
||||
priorityList.add( is );
|
||||
}
|
||||
}
|
||||
this.myHandler.setPartitionList( new PrecisePriorityList<IAEFluidStack>( priorityList ) );
|
||||
|
||||
try
|
||||
{
|
||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack injectItems( IAEFluidStack input, Actionable type, IActionSource src )
|
||||
{
|
||||
if( this.blocked || input == null || input.getStackSize() < Fluid.BUCKET_VOLUME )
|
||||
{
|
||||
// need a full bucket
|
||||
return input;
|
||||
}
|
||||
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
final World w = te.getWorld();
|
||||
final AEPartLocation side = this.getSide();
|
||||
final BlockPos pos = te.getPos().offset( side.getFacing() );
|
||||
final IBlockState state = w.getBlockState( pos );
|
||||
|
||||
if( this.canReplace( w, state, state.getBlock(), pos ) )
|
||||
{
|
||||
if( type == Actionable.MODULATE )
|
||||
{
|
||||
final FluidStack fs = input.getFluidStack();
|
||||
fs.amount = Fluid.BUCKET_VOLUME;
|
||||
|
||||
final FluidTank tank = new FluidTank( fs, Fluid.BUCKET_VOLUME );
|
||||
if( !FluidUtil.tryPlaceFluid( null, w, pos, tank, fs ) )
|
||||
{
|
||||
return input;
|
||||
}
|
||||
}
|
||||
final IAEFluidStack ret = input.copy();
|
||||
ret.setStackSize( input.getStackSize() - Fluid.BUCKET_VOLUME );
|
||||
return ret.getStackSize() == 0 ? null : ret;
|
||||
}
|
||||
this.blocked = true;
|
||||
return input;
|
||||
}
|
||||
|
||||
private boolean canReplace( World w, IBlockState state, Block block, BlockPos pos )
|
||||
{
|
||||
return block.isReplaceable( w, pos ) && !( block instanceof IFluidBlock ) && !( block instanceof BlockLiquid ) && !state.getMaterial().isLiquid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged( IAEFluidTank inv, int slot )
|
||||
{
|
||||
if( inv == this.config )
|
||||
{
|
||||
this.updateHandler();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.stateChanged();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( final MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
this.stateChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FLUID_FORMATION_PLANE );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEFluidStack> getChannel()
|
||||
{
|
||||
return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( final IStorageChannel channel )
|
||||
{
|
||||
if( this.getProxy().isActive() && channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
final List<IMEInventoryHandler> handler = new ArrayList<>( 1 );
|
||||
handler.add( this.myHandler );
|
||||
return handler;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.getConnections(), this.isPowered(), this.isActive() );
|
||||
}
|
||||
|
||||
public IAEFluidTank getConfig()
|
||||
{
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
return AEApi.instance().definitions().parts().fluidFormationnPlane().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_FLUID_FORMATION_PLANE;
|
||||
}
|
||||
}
|
||||
@@ -21,15 +21,12 @@ package appeng.fluids.parts;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Verify;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -44,7 +41,6 @@ import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
@@ -157,20 +153,10 @@ public class PartFluidImportBus extends PartSharedFluidBus
|
||||
{
|
||||
for( int i = 0; i < this.getConfig().getSlots(); i++ )
|
||||
{
|
||||
final IAEItemStack stack = this.getConfig().getAEStackInSlot( i );
|
||||
|
||||
if( stack != null && stack.getDefinition() != null )
|
||||
final IAEFluidStack stack = this.getConfig().getFluidInSlot( i );
|
||||
if( stack != null && stack.equals( fluid ) )
|
||||
{
|
||||
final IFluidHandlerItem fh = stack.getDefinition().getCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null );
|
||||
|
||||
Verify.verifyNotNull( fh, "IFluidHandlerItem is null" );
|
||||
|
||||
final FluidStack filtered = fh.drain( Integer.MAX_VALUE, false );
|
||||
|
||||
if( filtered != null && filtered.isFluidEqual( fluid ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -180,8 +166,7 @@ public class PartFluidImportBus extends PartSharedFluidBus
|
||||
{
|
||||
for( int i = 0; i < this.getConfig().getSlots(); i++ )
|
||||
{
|
||||
final IAEItemStack stack = this.getConfig().getAEStackInSlot( i );
|
||||
|
||||
final IAEFluidStack stack = this.getConfig().getFluidInSlot( i );
|
||||
if( stack != null )
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -30,7 +30,10 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
@@ -45,6 +48,7 @@ import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.fluids.helper.DualityFluidInterface;
|
||||
@@ -132,11 +136,6 @@ public class PartFluidInterface extends PartBasicState implements IGridTickable,
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer p, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( p.isSneaking() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( p, this.getTileEntity(), this.getSide(), GuiBridge.GUI_FLUID_INTERFACE );
|
||||
@@ -216,4 +215,33 @@ public class PartFluidInterface extends PartBasicState implements IGridTickable,
|
||||
return this.duality.getCapability( capabilityClass, this.getSide().getFacing() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.duality.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.duality.getConfigManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( String name )
|
||||
{
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
return AEApi.instance().definitions().parts().fluidIface().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_FLUID_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,318 @@
|
||||
|
||||
package appeng.fluids.parts;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStackWatcher;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.fluids.util.AEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatcherHost, IConfigManagerHost, IAEFluidInventory
|
||||
{
|
||||
@PartModels
|
||||
public static final ResourceLocation MODEL_BASE_OFF = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_base_off" );
|
||||
@PartModels
|
||||
public static final ResourceLocation MODEL_BASE_ON = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_base_on" );
|
||||
@PartModels
|
||||
public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_off" );
|
||||
@PartModels
|
||||
public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_on" );
|
||||
@PartModels
|
||||
public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/level_emitter_status_has_channel" );
|
||||
|
||||
public static final PartModel MODEL_OFF_OFF = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_OFF );
|
||||
public static final PartModel MODEL_OFF_ON = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_ON );
|
||||
public static final PartModel MODEL_OFF_HAS_CHANNEL = new PartModel( MODEL_BASE_OFF, MODEL_STATUS_HAS_CHANNEL );
|
||||
public static final PartModel MODEL_ON_OFF = new PartModel( MODEL_BASE_ON, MODEL_STATUS_OFF );
|
||||
public static final PartModel MODEL_ON_ON = new PartModel( MODEL_BASE_ON, MODEL_STATUS_ON );
|
||||
public static final PartModel MODEL_ON_HAS_CHANNEL = new PartModel( MODEL_BASE_ON, MODEL_STATUS_HAS_CHANNEL );
|
||||
|
||||
private static final int FLAG_ON = 4;
|
||||
|
||||
private boolean prevState = false;
|
||||
private long lastReportedValue = 0;
|
||||
private long reportingValue = 0;
|
||||
private IStackWatcher stackWatcher = null;
|
||||
private final AEFluidInventory config = new AEFluidInventory( this, 1 );
|
||||
|
||||
public PartFluidLevelEmitter( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
|
||||
this.getConfigManager().registerSetting( Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL );
|
||||
}
|
||||
|
||||
public long getReportingValue()
|
||||
{
|
||||
return this.reportingValue;
|
||||
}
|
||||
|
||||
public void setReportingValue( final long v )
|
||||
{
|
||||
this.reportingValue = v;
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWatcher( IStackWatcher newWatcher )
|
||||
{
|
||||
this.stackWatcher = newWatcher;
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan )
|
||||
{
|
||||
if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) && fullStack.equals( this.config.getFluidInSlot( 0 ) ) )
|
||||
{
|
||||
this.lastReportedValue = fullStack.getStackSize();
|
||||
this.updateState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged( IAEFluidTank inv, int slot )
|
||||
{
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelChanged( final MENetworkChannelsChanged c )
|
||||
{
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerChanged( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower()
|
||||
{
|
||||
return this.prevState ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower()
|
||||
{
|
||||
return this.prevState ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int populateFlags( final int cf )
|
||||
{
|
||||
return cf | ( this.prevState ? FLAG_ON : 0 );
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
final boolean isOn = this.isLevelEmitterOn();
|
||||
if( this.prevState != isOn )
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
this.prevState = isOn;
|
||||
Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos() );
|
||||
Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos().offset( this.getSide().getFacing() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void configureWatchers()
|
||||
{
|
||||
if( this.stackWatcher != null )
|
||||
{
|
||||
this.stackWatcher.reset();
|
||||
|
||||
final IAEFluidStack myStack = this.config.getFluidInSlot( 0 );
|
||||
if( myStack != null )
|
||||
{
|
||||
this.stackWatcher.add( myStack );
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
this.updateReportingValue(
|
||||
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// x.x
|
||||
}
|
||||
}
|
||||
|
||||
private void updateReportingValue( final IMEMonitor<IAEFluidStack> monitor )
|
||||
{
|
||||
final IAEFluidStack myStack = this.config.getFluidInSlot( 0 );
|
||||
if( myStack != null )
|
||||
{
|
||||
final IAEFluidStack r = monitor.getStorageList().findPrecise( myStack );
|
||||
if( r == null )
|
||||
{
|
||||
this.lastReportedValue = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lastReportedValue = r.getStackSize();
|
||||
}
|
||||
}
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
private boolean isLevelEmitterOn()
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return ( this.getClientFlags() & FLAG_ON ) == FLAG_ON;
|
||||
}
|
||||
|
||||
if( !this.getProxy().isActive() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean flipState = this.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL;
|
||||
return flipState ? this.reportingValue > this.lastReportedValue : this.reportingValue <= this.lastReportedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.SMART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCableConnectionLength( AECableType cable )
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( final IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 7, 7, 11, 9, 9, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick( final World world, final BlockPos pos, final Random r )
|
||||
{
|
||||
if( this.isLevelEmitterOn() )
|
||||
{
|
||||
final AEPartLocation d = this.getSide();
|
||||
|
||||
final double d0 = d.xOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
||||
final double d1 = d.yOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
||||
final double d2 = d.zOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
||||
|
||||
world.spawnParticle( EnumParticleTypes.REDSTONE, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D,
|
||||
new int[0] );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FLUID_LEVEL_EMITTER );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
if( this.isActive() && this.isPowered() )
|
||||
{
|
||||
return this.isLevelEmitterOn() ? MODEL_ON_HAS_CHANNEL : MODEL_OFF_HAS_CHANNEL;
|
||||
}
|
||||
else if( this.isPowered() )
|
||||
{
|
||||
return this.isLevelEmitterOn() ? MODEL_ON_ON : MODEL_OFF_ON;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
public IAEFluidTank getConfig()
|
||||
{
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.lastReportedValue = data.getLong( "lastReportedValue" );
|
||||
this.reportingValue = data.getLong( "reportingValue" );
|
||||
this.prevState = data.getBoolean( "prevState" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setLong( "lastReportedValue", this.lastReportedValue );
|
||||
data.setLong( "reportingValue", this.reportingValue );
|
||||
data.setBoolean( "prevState", this.prevState );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,12 +33,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -64,14 +60,15 @@ import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.IStorageMonitorableAccessor;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.fluids.util.AEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -80,9 +77,7 @@ import appeng.me.storage.ITickingMonitor;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.parts.misc.PartSharedStorageBus;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.prioritylist.FuzzyPriorityList;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
|
||||
@@ -92,7 +87,7 @@ import appeng.util.prioritylist.PrecisePriorityList;
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMonitorHandlerReceiver<IAEFluidStack>
|
||||
public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMonitorHandlerReceiver<IAEFluidStack>, IAEFluidInventory
|
||||
{
|
||||
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_base" );
|
||||
@PartModels
|
||||
@@ -103,7 +98,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_has_channel" ) );
|
||||
|
||||
private final IActionSource source;
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 63 );
|
||||
private final AEFluidInventory config = new AEFluidInventory( this, 63 );
|
||||
private boolean cached = false;
|
||||
private ITickingMonitor monitor = null;
|
||||
private MEInventoryHandler<IAEFluidStack> handler = null;
|
||||
@@ -198,7 +193,9 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
|
||||
protected void resetCache( final boolean fullReset )
|
||||
{
|
||||
if( this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost().getTile().getWorld().isRemote )
|
||||
if( this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost()
|
||||
.getTile()
|
||||
.getWorld().isRemote )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -225,41 +222,22 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS_FLUID );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
public void onFluidInventoryChanged( IAEFluidTank inv, int slot )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
if( inv == this.config )
|
||||
{
|
||||
this.resetCache( true );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "config" ) )
|
||||
{
|
||||
return this.config;
|
||||
}
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
@@ -287,7 +265,9 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
{
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
||||
this.getProxy()
|
||||
.getStorage()
|
||||
.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
@@ -342,23 +322,17 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
||||
for( int x = 0; x < this.config.getSlots() && x < slotsToUse; x++ )
|
||||
{
|
||||
final IAEItemStack is = this.config.getAEStackInSlot( x );
|
||||
final IAEFluidStack is = this.config.getFluidInSlot( x );
|
||||
if( is != null )
|
||||
{
|
||||
// Because we store filtered fluid as buckets, we need to grab the fluid from the stack
|
||||
IFluidHandlerItem fh = FluidUtil.getFluidHandler( is.createItemStack() );
|
||||
if( fh == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
FluidStack fluid = fh.drain( Integer.MAX_VALUE, false );
|
||||
priorityList.add( AEFluidStack.fromFluidStack( fluid ) );
|
||||
priorityList.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
this.handler.setPartitionList( new FuzzyPriorityList<IAEFluidStack>( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
|
||||
this.handler.setPartitionList(
|
||||
new FuzzyPriorityList<IAEFluidStack>( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -488,6 +462,11 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class );
|
||||
}
|
||||
|
||||
public IAEFluidTank getConfig()
|
||||
{
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@SuppressWarnings( "Duplicates" )
|
||||
@Nonnull
|
||||
@Override
|
||||
@@ -506,4 +485,16 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
return MODELS_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
return AEApi.instance().definitions().parts().fluidStorageBus().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_STORAGEBUS_FLUID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
@@ -40,9 +39,10 @@ import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.fluids.util.AEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ import appeng.util.Platform;
|
||||
public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable
|
||||
{
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 );
|
||||
private final AEFluidInventory config = new AEFluidInventory( null, 9 );
|
||||
private boolean lastRedstone;
|
||||
|
||||
public PartSharedFluidBus( ItemStack is )
|
||||
@@ -104,18 +104,12 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( !player.isSneaking() )
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_BUS_FLUID );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,17 +138,6 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "config" ) )
|
||||
{
|
||||
return this.getConfig();
|
||||
}
|
||||
|
||||
return super.getInventoryByName( name );
|
||||
}
|
||||
|
||||
protected int calculateAmountToSend()
|
||||
{
|
||||
double amount = this.getChannel().transferFactor();
|
||||
@@ -178,22 +161,23 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
|
||||
public void readFromNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.getConfig().readFromNBT( extra, "config" );
|
||||
this.config.readFromNBT( extra, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.getConfig().writeToNBT( extra, "config" );
|
||||
this.config.writeToNBT( extra, "config" );
|
||||
}
|
||||
|
||||
public AppEngInternalAEInventory getConfig()
|
||||
public IAEFluidTank getConfig()
|
||||
{
|
||||
return this.config;
|
||||
}
|
||||
|
||||
protected IFluidStorageChannel getChannel(){
|
||||
protected IFluidStorageChannel getChannel()
|
||||
{
|
||||
return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class );
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.fluids.registries;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
@@ -33,8 +34,11 @@ import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.fluids.storage.FluidCellInventory;
|
||||
import appeng.fluids.storage.FluidCellInventoryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BasicFluidCellHandler implements ICellHandler
|
||||
@@ -47,11 +51,11 @@ public class BasicFluidCellHandler implements ICellHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
|
||||
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
return FluidCellInventory.getCell( is, container );
|
||||
return (ICellInventoryHandler<T>) FluidCellInventory.getCell( is, container );
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -62,8 +66,7 @@ public class BasicFluidCellHandler implements ICellHandler
|
||||
{
|
||||
if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
//TODO: Open Gui
|
||||
//Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_ME );
|
||||
Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_FLUID_TERMINAL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import appeng.api.config.Actionable;
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
@@ -47,17 +47,12 @@ import appeng.me.storage.AbstractCellInventory;
|
||||
*/
|
||||
public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
||||
{
|
||||
protected FluidCellInventory( final NBTTagCompound data, final ISaveProvider container )
|
||||
{
|
||||
super( data, container, 8000 );
|
||||
}
|
||||
|
||||
private FluidCellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException
|
||||
{
|
||||
super( o, container, 8000 );
|
||||
}
|
||||
|
||||
public static IMEInventoryHandler getCell( final ItemStack o, final ISaveProvider container2 )
|
||||
public static ICellInventoryHandler<IAEFluidStack> getCell( final ItemStack o, final ISaveProvider container2 )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -111,7 +106,7 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
||||
if( l != null )
|
||||
{
|
||||
final long remainingItemSlots = this.getRemainingItemCount();
|
||||
if( remainingItemSlots < 0 )
|
||||
if( remainingItemSlots <= 0 )
|
||||
{
|
||||
return input;
|
||||
}
|
||||
@@ -123,7 +118,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
l.setStackSize( l.getStackSize() + remainingItemSlots );
|
||||
this.updateItemCount( remainingItemSlots );
|
||||
this.saveChanges();
|
||||
}
|
||||
return r;
|
||||
@@ -133,7 +127,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
l.setStackSize( l.getStackSize() + input.getStackSize() );
|
||||
this.updateItemCount( input.getStackSize() );
|
||||
this.saveChanges();
|
||||
}
|
||||
return null;
|
||||
@@ -155,8 +148,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
||||
toWrite.amount = remainingItemCount;
|
||||
|
||||
this.cellItems.add( AEFluidStack.fromFluidStack( toWrite ) );
|
||||
this.updateItemCount( toWrite.amount );
|
||||
|
||||
this.saveChanges();
|
||||
}
|
||||
return AEFluidStack.fromFluidStack( toReturn );
|
||||
@@ -164,7 +155,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
||||
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
this.updateItemCount( input.getStackSize() );
|
||||
this.cellItems.add( input );
|
||||
this.saveChanges();
|
||||
}
|
||||
@@ -198,7 +188,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
||||
results.setStackSize( l.getStackSize() );
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
this.updateItemCount( -l.getStackSize() );
|
||||
l.setStackSize( 0 );
|
||||
this.saveChanges();
|
||||
}
|
||||
@@ -209,7 +198,6 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
l.setStackSize( l.getStackSize() - size );
|
||||
this.updateItemCount( -size );
|
||||
this.saveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,15 @@ import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
@@ -38,6 +42,8 @@ import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.fluids.helper.DualityFluidInterface;
|
||||
import appeng.fluids.helper.IFluidInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
@@ -151,4 +157,34 @@ public class TileFluidInterface extends AENetworkTile implements IGridTickable,
|
||||
}
|
||||
return super.getCapability( capability, facing );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInstalledUpgrades( Upgrades u )
|
||||
{
|
||||
return this.duality.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return this.duality.getConfigManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName( String name )
|
||||
{
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
return AEApi.instance().definitions().blocks().fluidIface().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
return GuiBridge.GUI_FLUID_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,377 @@
|
||||
|
||||
package appeng.fluids.util;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.AELog;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AEFluidInventory implements IAEFluidTank
|
||||
{
|
||||
private final IAEFluidStack[] fluids;
|
||||
private final IAEFluidInventory handler;
|
||||
private final long capacity;
|
||||
private IFluidTankProperties[] props = null;
|
||||
|
||||
public AEFluidInventory( final IAEFluidInventory handler, final int slots, final long capcity )
|
||||
{
|
||||
this.fluids = new IAEFluidStack[slots];
|
||||
this.handler = handler;
|
||||
this.capacity = capcity;
|
||||
}
|
||||
|
||||
public AEFluidInventory( final IAEFluidInventory handler, final int slots )
|
||||
{
|
||||
this( handler, slots, Long.MAX_VALUE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFluidInSlot( final int slot, final IAEFluidStack fluid )
|
||||
{
|
||||
if( slot >= 0 && slot < this.getSlots() )
|
||||
{
|
||||
if( Objects.equals( this.fluids[slot], fluid ) )
|
||||
{
|
||||
if( fluid != null && fluid.getStackSize() != this.fluids[slot].getStackSize() )
|
||||
{
|
||||
this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) );
|
||||
this.onContentChanged( slot );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fluid == null )
|
||||
{
|
||||
this.fluids[slot] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fluids[slot] = fluid.copy();
|
||||
this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) );
|
||||
}
|
||||
|
||||
this.onContentChanged( slot );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onContentChanged( final int slot )
|
||||
{
|
||||
if( this.handler != null && Platform.isServer() )
|
||||
{
|
||||
this.handler.onFluidInventoryChanged( this, slot );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getFluidInSlot( final int slot )
|
||||
{
|
||||
if( slot >= 0 && slot < this.getSlots() )
|
||||
{
|
||||
return this.fluids[slot];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
return fluids.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTankProperties[] getTankProperties()
|
||||
{
|
||||
if( this.props == null )
|
||||
{
|
||||
this.props = new IFluidTankProperties[this.getSlots()];
|
||||
for( int i = 0; i < this.getSlots(); ++i )
|
||||
{
|
||||
this.props[i] = new FluidTankPropertiesWrapper( i );
|
||||
}
|
||||
|
||||
}
|
||||
return this.props;
|
||||
}
|
||||
|
||||
public int fill( final int slot, final FluidStack resource, final boolean doFill )
|
||||
{
|
||||
if( resource == null || resource.amount <= 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final IAEFluidStack fluid = this.fluids[slot];
|
||||
|
||||
if( !doFill )
|
||||
{
|
||||
if( fluid == null )
|
||||
{
|
||||
return resource.amount;
|
||||
}
|
||||
|
||||
if( !fluid.equals( resource ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) Math.min( Math.min( this.capacity - fluid.getStackSize(), resource.amount ), Integer.MAX_VALUE );
|
||||
}
|
||||
|
||||
if( fluid == null )
|
||||
{
|
||||
this.setFluidInSlot( slot, AEFluidStack.fromFluidStack( resource ) );
|
||||
return resource.amount;
|
||||
}
|
||||
|
||||
if( !fluid.equals( resource ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
long filled = this.capacity - fluid.getStackSize();
|
||||
|
||||
if( resource.amount < filled )
|
||||
{
|
||||
fluid.setStackSize( fluid.getStackSize() + resource.amount );
|
||||
filled = resource.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
fluid.setStackSize( this.capacity );
|
||||
}
|
||||
|
||||
onContentChanged( slot );
|
||||
return (int) filled;
|
||||
}
|
||||
|
||||
public FluidStack drain( final int slot, final FluidStack resource, final boolean doDrain )
|
||||
{
|
||||
final IAEFluidStack fluid = this.fluids[slot];
|
||||
if( resource == null || fluid == null || !fluid.equals( resource ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return drain( slot, resource.amount, doDrain );
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
onContentChanged( slot );
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill( final FluidStack fluid, final boolean doFill )
|
||||
{
|
||||
if( fluid == null || fluid.amount <= 0 )
|
||||
return 0;
|
||||
|
||||
final FluidStack insert = fluid.copy();
|
||||
|
||||
int totalFillAmount = 0;
|
||||
for( int slot = 0; slot < this.getSlots(); ++slot )
|
||||
{
|
||||
int fillAmount = this.fill( slot, insert, doFill );
|
||||
totalFillAmount += fillAmount;
|
||||
insert.amount -= fillAmount;
|
||||
if( insert.amount <= 0 )
|
||||
break;
|
||||
}
|
||||
return totalFillAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain( final FluidStack fluid, final boolean doDrain )
|
||||
{
|
||||
if( fluid == null || fluid.amount <= 0 )
|
||||
return null;
|
||||
|
||||
final FluidStack resource = fluid.copy();
|
||||
|
||||
FluidStack totalDrained = null;
|
||||
for( int slot = 0; slot < this.getSlots(); ++slot )
|
||||
{
|
||||
FluidStack drain = this.drain( slot, resource, doDrain );
|
||||
if( drain != null )
|
||||
{
|
||||
if( totalDrained == null )
|
||||
totalDrained = drain;
|
||||
else
|
||||
totalDrained.amount += drain.amount;
|
||||
|
||||
resource.amount -= drain.amount;
|
||||
if( resource.amount <= 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
return totalDrained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain( final int maxDrain, final boolean doDrain )
|
||||
{
|
||||
if( maxDrain == 0 )
|
||||
return null;
|
||||
|
||||
FluidStack totalDrained = null;
|
||||
int toDrain = maxDrain;
|
||||
|
||||
for( int slot = 0; slot < this.getSlots(); ++slot )
|
||||
{
|
||||
if( totalDrained == null )
|
||||
{
|
||||
totalDrained = this.drain( slot, toDrain, doDrain );
|
||||
if( totalDrained != null )
|
||||
{
|
||||
toDrain -= totalDrained.amount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FluidStack copy = totalDrained.copy();
|
||||
copy.amount = toDrain;
|
||||
FluidStack drain = this.drain( slot, copy, doDrain );
|
||||
if( drain != null )
|
||||
{
|
||||
totalDrained.amount += drain.amount;
|
||||
toDrain -= drain.amount;
|
||||
}
|
||||
}
|
||||
|
||||
if( toDrain <= 0 )
|
||||
break;
|
||||
}
|
||||
return totalDrained;
|
||||
}
|
||||
|
||||
public void writeToNBT( final NBTTagCompound data, final String name )
|
||||
{
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
this.writeToNBT( c );
|
||||
data.setTag( name, c );
|
||||
}
|
||||
|
||||
private void writeToNBT( final NBTTagCompound target )
|
||||
{
|
||||
for( int x = 0; x < this.fluids.length; x++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if( this.fluids[x] != null )
|
||||
{
|
||||
this.fluids[x].writeToNBT( c );
|
||||
}
|
||||
|
||||
target.setTag( "#" + x, c );
|
||||
}
|
||||
catch( final Exception ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT( final NBTTagCompound data, final String name )
|
||||
{
|
||||
final NBTTagCompound c = data.getCompoundTag( name );
|
||||
if( c != null )
|
||||
{
|
||||
this.readFromNBT( c );
|
||||
}
|
||||
}
|
||||
|
||||
private void readFromNBT( final NBTTagCompound target )
|
||||
{
|
||||
for( int x = 0; x < this.fluids.length; x++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
final NBTTagCompound c = target.getCompoundTag( "#" + x );
|
||||
|
||||
if( c != null )
|
||||
{
|
||||
this.fluids[x] = AEFluidStack.fromNBT( c );
|
||||
}
|
||||
}
|
||||
catch( final Exception e )
|
||||
{
|
||||
AELog.debug( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class FluidTankPropertiesWrapper implements IFluidTankProperties
|
||||
{
|
||||
private final int slot;
|
||||
|
||||
public FluidTankPropertiesWrapper( final int slot )
|
||||
{
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getContents()
|
||||
{
|
||||
return AEFluidInventory.this.fluids[slot] == null ? null : AEFluidInventory.this.fluids[slot].getFluidStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
return (int) Math.min( AEFluidInventory.this.capacity, Integer.MAX_VALUE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFillFluidType( FluidStack fluidStack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrainFluidType( FluidStack fluidStack )
|
||||
{
|
||||
return fluidStack != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,13 +34,14 @@ import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.core.Api;
|
||||
import appeng.fluids.items.FluidDummyItem;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEStack;
|
||||
|
||||
@@ -271,34 +272,13 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
||||
{
|
||||
if( ia instanceof AEFluidStack )
|
||||
{
|
||||
return ( (AEFluidStack) ia ).fluid == this.fluid && this.tagCompound == ( (AEFluidStack) ia ).tagCompound;
|
||||
final AEFluidStack is = (AEFluidStack) ia;
|
||||
return is.fluid == this.fluid && Platform.itemComparisons().isNbtTagEqual( this.tagCompound, is.tagCompound );
|
||||
}
|
||||
else if( ia instanceof FluidStack )
|
||||
{
|
||||
final FluidStack is = (FluidStack) ia;
|
||||
|
||||
if( is.getFluid() == this.fluid )
|
||||
{
|
||||
final NBTTagCompound ta = this.tagCompound;
|
||||
final NBTTagCompound tb = is.tag;
|
||||
if( ta == tb )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( ( ta == null && tb == null ) || ( ta != null && ta.hasNoTags() && tb == null ) || ( tb != null && tb
|
||||
.hasNoTags() && ta == null ) || ( ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags() ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( ( ta == null && tb != null ) || ( ta != null && tb == null ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Platform.itemComparisons().isNbtTagEqual( ta, tb );
|
||||
}
|
||||
return is.getFluid() == this.fluid && Platform.itemComparisons().isNbtTagEqual( this.tagCompound, is.tag );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -336,8 +316,14 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
|
||||
@Override
|
||||
public ItemStack asItemStackRepresentation()
|
||||
{
|
||||
// TODO: fluids, how do they even work?
|
||||
return FluidUtil.getFilledBucket( this.getFluidStack() );
|
||||
ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
FluidDummyItem item = (FluidDummyItem) is.getItem();
|
||||
item.setFluidStack( is, this.getFluidStack() );
|
||||
return is;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+38
-4
@@ -16,13 +16,17 @@
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.helper;
|
||||
package appeng.fluids.util;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class AEFluidTank extends FluidTank
|
||||
|
||||
public class AEFluidTank extends FluidTank implements IAEFluidTank
|
||||
{
|
||||
private final IAEFluidInventory host;
|
||||
|
||||
@@ -30,16 +34,46 @@ public class AEFluidTank extends FluidTank
|
||||
{
|
||||
super( capacity );
|
||||
this.host = host;
|
||||
if (host instanceof TileEntity)
|
||||
{
|
||||
this.setTileEntity( (TileEntity) host );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onContentsChanged()
|
||||
{
|
||||
if( host != null )
|
||||
if( host != null && Platform.isServer() )
|
||||
{
|
||||
host.onFluidInventoryChanged( this );
|
||||
host.onFluidInventoryChanged( this, 0 );
|
||||
}
|
||||
super.onContentsChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFluidInSlot( int slot, IAEFluidStack fluid )
|
||||
{
|
||||
if( slot == 0 )
|
||||
{
|
||||
this.setFluid( fluid == null ? null : fluid.getFluidStack() );
|
||||
this.onContentsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getFluidInSlot( int slot )
|
||||
{
|
||||
if( slot == 0 )
|
||||
{
|
||||
return AEFluidStack.fromFluidStack( this.getFluid() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-5
@@ -16,14 +16,11 @@
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.helper;
|
||||
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
package appeng.fluids.util;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IAEFluidInventory
|
||||
{
|
||||
void onFluidInventoryChanged( IFluidHandler inventory );
|
||||
void onFluidInventoryChanged( final IAEFluidTank inv, final int slot );
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
package appeng.fluids.util;
|
||||
|
||||
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
|
||||
|
||||
public interface IAEFluidTank extends IFluidHandler
|
||||
{
|
||||
void setFluidInSlot( final int slot, final IAEFluidStack fluid );
|
||||
|
||||
IAEFluidStack getFluidInSlot( final int slot );
|
||||
|
||||
int getSlots();
|
||||
|
||||
}
|
||||
@@ -110,7 +110,7 @@ import appeng.util.inv.InvOperation;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost, IPriorityHost
|
||||
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
|
||||
{
|
||||
|
||||
public static final int NUMBER_OF_STORAGE_SLOTS = 9;
|
||||
@@ -561,14 +561,6 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
public void markDirty()
|
||||
{
|
||||
for( int slot = 0; slot < this.storage.getSlots(); slot++ )
|
||||
{
|
||||
this.storage.markDirty( slot );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( final IGridNode node )
|
||||
{
|
||||
@@ -869,8 +861,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
{
|
||||
this.cancelCrafting();
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
this.iHost.saveChanges();
|
||||
}
|
||||
|
||||
private void cancelCrafting()
|
||||
@@ -1243,18 +1234,16 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
this.updateCraftingList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority( final int newValue )
|
||||
{
|
||||
this.priority = newValue;
|
||||
this.markDirty();
|
||||
|
||||
this.iHost.saveChanges();
|
||||
|
||||
try
|
||||
{
|
||||
this.gridProxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.gridProxy.getNode() ) );
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
package appeng.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
public interface IPriorityHost
|
||||
{
|
||||
@@ -31,4 +34,8 @@ public interface IPriorityHost
|
||||
* set new priority
|
||||
*/
|
||||
void setPriority( int newValue );
|
||||
|
||||
ItemStack getItemStackRepresentation();
|
||||
|
||||
GuiBridge getGuiBridge();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.integration;
|
||||
|
||||
import appeng.integration.modules.crafttweaker.CTModule;
|
||||
import appeng.integration.modules.ic2.IC2Module;
|
||||
import appeng.integration.modules.inventorytweaks.InventoryTweaksModule;
|
||||
import appeng.integration.modules.jei.JEIModule;
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeModule;
|
||||
import appeng.integration.modules.waila.WailaModule;
|
||||
@@ -50,7 +51,14 @@ public enum IntegrationType
|
||||
}
|
||||
},
|
||||
|
||||
InvTweaks( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks" ),
|
||||
InvTweaks( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks" )
|
||||
{
|
||||
@Override
|
||||
public IIntegrationModule createInstance()
|
||||
{
|
||||
return Integrations.setInvTweaks( new InventoryTweaksModule() );
|
||||
}
|
||||
},
|
||||
|
||||
JEI( IntegrationSide.CLIENT, "Just Enough Items", "jei" )
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user