mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
native fluid io bus
This commit is contained in:
1 parent
a548d3094d
commit
a053b51b57
23 files changed
+1038
No files matched your search
@@ -52,12 +52,21 @@ public class FluidCraft {
|
||||
public static void postInit(FMLPostInitializationEvent event) {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(FluidCraft.INSTANCE, new InventoryHandler());
|
||||
(new RecipeLoader()).run();
|
||||
|
||||
if (ModAndClassUtil.isBigInterface) {
|
||||
Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 3 );
|
||||
Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 3 );
|
||||
}
|
||||
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1 );
|
||||
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1 );
|
||||
|
||||
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 2 );
|
||||
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 2 );
|
||||
Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1 );
|
||||
Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 1 );
|
||||
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 4 );
|
||||
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 4 );
|
||||
|
||||
proxy.postInit(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.core.localization.GuiText;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidIO;
|
||||
import com.glodblock.github.common.parts.PartFluidImportBus;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class GuiFluidIO extends GuiUpgradeable
|
||||
{
|
||||
private final PartSharedFluidBus bus;
|
||||
|
||||
public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te )
|
||||
{
|
||||
super( new ContainerFluidIO( inventoryPlayer, te ) );
|
||||
this.bus = te;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected GuiText getName()
|
||||
{
|
||||
return this.bus instanceof PartFluidImportBus ? GuiText.ImportBus : GuiText.ExportBus;
|
||||
}
|
||||
|
||||
public void update(int id, IAEFluidStack stack) {
|
||||
((ContainerFluidIO)this.cvb).getBus().setFluidInSlot(id, stack);
|
||||
}
|
||||
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
|
||||
|
||||
public ContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te)
|
||||
{
|
||||
super( ip, te );
|
||||
}
|
||||
|
||||
public abstract AppEngInternalAEInventory getFakeFluidInv();
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx )
|
||||
{
|
||||
AppEngSlot clickSlot = (AppEngSlot)this.inventorySlots.get(idx);
|
||||
if (clickSlot == null || !clickSlot.getHasStack()) return null;
|
||||
|
||||
ItemStack tis = clickSlot.getStack();
|
||||
FluidStack fs = Util.getFluidFromItem(tis);
|
||||
if( fs != null )
|
||||
{
|
||||
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
|
||||
final IAEFluidStack stack = AEFluidStack.create( fs );
|
||||
for( int i = 0; i < inv.getSizeInventory(); ++i )
|
||||
{
|
||||
if( inv.getStackInSlot(i) == null && this.isValidForConfig( i, stack ) )
|
||||
{
|
||||
ItemStack tmp = ItemFluidPacket.newStack(fs);
|
||||
if (tmp != null) {
|
||||
tmp.setStackDisplayName(fs.getLocalizedName());
|
||||
}
|
||||
inv.setInventorySlotContents( i, tmp );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.standardDetectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void setupConfig()
|
||||
{
|
||||
this.setupUpgrades();
|
||||
|
||||
final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName( "config" );
|
||||
final int y = 40;
|
||||
final int x = 80;
|
||||
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 0, x, y, 0, 0, 0 ) );
|
||||
if( this.supportCapacity() )
|
||||
{
|
||||
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
|
||||
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) );
|
||||
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 3, x, y, 0, -1, 1 ) );
|
||||
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 4, x, y, 0, 1, 1 ) );
|
||||
|
||||
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 5, x, y, -1, -1, 2 ) );
|
||||
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 6, x, y, 1, -1, 2 ) );
|
||||
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 7, x, y, -1, 1, 2 ) );
|
||||
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 8, x, y, 1, 1, 2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isValidForConfig( int slot, IAEFluidStack fs )
|
||||
{
|
||||
if( this.supportCapacity() )
|
||||
{
|
||||
// assumes 4 slots per upgrade
|
||||
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
|
||||
if( slot > 0 && upgrades < 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return slot <= 4 || upgrades >= 2;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void standardDetectAndSendChanges()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
// clear out config items that are no longer valid (eg capacity upgrade removed)
|
||||
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
|
||||
final Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
for( int i = 0; i < inv.getSizeInventory(); ++i )
|
||||
{
|
||||
if( inv.getStackInSlot( i ) != null && !this.isValidForConfig( i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot( i )))) )
|
||||
{
|
||||
inv.setInventorySlotContents( i, null );
|
||||
}
|
||||
tmp.put(i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot( i ))));
|
||||
}
|
||||
for( final Object g : this.crafters )
|
||||
{
|
||||
if( g instanceof EntityPlayer)
|
||||
{
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
public void setFluid(int id, IAEFluidStack fluidStack) {
|
||||
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
|
||||
if (inv != null && this.isValidForConfig(id, AEFluidStack.create(fluidStack))) {
|
||||
ItemStack tmp = ItemFluidPacket.newStack(fluidStack.getFluidStack());
|
||||
if (tmp != null) {
|
||||
tmp.setStackDisplayName(fluidStack.getFluidStack().getLocalizedName());
|
||||
}
|
||||
inv.setInventorySlotContents(id, tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class ContainerFluidIO extends ContainerFluidConfigurable
|
||||
{
|
||||
private final PartSharedFluidBus bus;
|
||||
|
||||
public ContainerFluidIO(InventoryPlayer ip, PartSharedFluidBus te )
|
||||
{
|
||||
super( ip, te );
|
||||
this.bus = te;
|
||||
}
|
||||
|
||||
public PartSharedFluidBus getBus() {
|
||||
return this.bus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngInternalAEInventory getFakeFluidInv() {
|
||||
return (AppEngInternalAEInventory) this.bus.getInventoryByName("config");
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public enum FCPartsTexture {
|
||||
|
||||
PartFluidPatternTerminal_Bright("pattern_terminal_bright"), PartFluidPatternTerminal_Dark("pattern_terminal_dark"),
|
||||
PartFluidPatternTerminal_Colored("pattern_terminal_medium"), PartTerminalBroad("terminal_broad"),
|
||||
PartFluidImportBus("fluid_import_face"), PartFluidExportBus("fluid_export_face"),
|
||||
BlockFluidInterfaceAlternate_Arrow("fluid_interface_arrow"), BlockInterfaceAlternate("fluid_interface_a"),
|
||||
BlockInterface_Face("fluid_interface");
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.parts.PartFluidExportBus;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemFluidExportBus extends Item implements IPartItem {
|
||||
|
||||
public ItemFluidExportBus() {
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_EXPORT);
|
||||
AEApi.instance().partHelper().setItemBusRenderer(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PartFluidExportBus createPartFromItemStack(ItemStack is) {
|
||||
return new PartFluidExportBus(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
public ItemFluidExportBus register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_EXPORT, FluidCraft.MODID);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister _iconRegister) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.parts.PartFluidImportBus;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemFluidImportBus extends Item implements IPartItem {
|
||||
|
||||
public ItemFluidImportBus() {
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_IMPORT);
|
||||
AEApi.instance().partHelper().setItemBusRenderer(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PartFluidImportBus createPartFromItemStack(ItemStack is) {
|
||||
return new PartFluidImportBus(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
public ItemFluidImportBus register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_IMPORT, FluidCraft.MODID);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister _iconRegister) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class PartFluidExportBus extends PartSharedFluidBus {
|
||||
|
||||
private final BaseActionSource source;
|
||||
|
||||
public PartFluidExportBus( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO );
|
||||
this.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
|
||||
this.source = new MachineSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getFaceIcon() {
|
||||
return FCPartsTexture.PartFluidExportBus.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( 5, 40, this.isSleeping(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall )
|
||||
{
|
||||
return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canDoBusWork()
|
||||
{
|
||||
return this.getProxy().isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TickRateModulation doBusWork()
|
||||
{
|
||||
if( !this.canDoBusWork() )
|
||||
{
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
final TileEntity te = this.getConnectedTE();
|
||||
|
||||
if(te instanceof IFluidHandler)
|
||||
{
|
||||
try
|
||||
{
|
||||
final IFluidHandler fh = (IFluidHandler) te;
|
||||
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
|
||||
|
||||
for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ )
|
||||
{
|
||||
IAEFluidStack fluid = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
|
||||
if( fluid != null )
|
||||
{
|
||||
final IAEFluidStack toExtract = fluid.copy();
|
||||
|
||||
toExtract.setStackSize( this.calculateAmountToSend() );
|
||||
|
||||
final IAEFluidStack out = inv.extractItems( toExtract, Actionable.SIMULATE, this.source );
|
||||
|
||||
if( out != null )
|
||||
{
|
||||
int wasInserted = fh.fill( this.getSide().getOpposite(), out.getFluidStack(), true );
|
||||
|
||||
if( wasInserted > 0 )
|
||||
{
|
||||
toExtract.setStackSize( wasInserted );
|
||||
inv.extractItems( toExtract, Actionable.MODULATE, this.source );
|
||||
|
||||
return TickRateModulation.FASTER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( final IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 4, 4, 12, 12, 12, 14 );
|
||||
bch.addBox( 5, 5, 14, 11, 11, 15 );
|
||||
bch.addBox( 6, 6, 15, 10, 10, 16 );
|
||||
bch.addBox( 6, 6, 11, 10, 10, 12 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 12, 12, 12, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 15, 10, 10, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer )
|
||||
{
|
||||
this.setRenderCache( rh.useSimplifiedRendering( x, y, z, this, this.getRenderCache() ) );
|
||||
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 12, 12, 12, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 14, 11, 11, 15 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 15, 10, 10, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 12 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class PartFluidImportBus extends PartSharedFluidBus {
|
||||
|
||||
private final BaseActionSource source;
|
||||
|
||||
public PartFluidImportBus( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO );
|
||||
this.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
|
||||
this.source = new MachineSource( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getFaceIcon() {
|
||||
return FCPartsTexture.PartFluidImportBus.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( 5, 40, this.isSleeping(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall )
|
||||
{
|
||||
return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TickRateModulation doBusWork()
|
||||
{
|
||||
if( !this.canDoBusWork() )
|
||||
{
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
|
||||
final TileEntity te = this.getConnectedTE();
|
||||
|
||||
if(te instanceof IFluidHandler)
|
||||
{
|
||||
try
|
||||
{
|
||||
final IFluidHandler fh = (IFluidHandler) te;
|
||||
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
|
||||
|
||||
final FluidStack fluidStack = fh.drain( this.getSide().getOpposite(), this.calculateAmountToSend(), false );
|
||||
|
||||
if( this.filterEnabled() && !this.isInFilter( fluidStack ) )
|
||||
{
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
final AEFluidStack aeFluidStack = AEFluidStack.create( fluidStack );
|
||||
|
||||
if( aeFluidStack != null )
|
||||
{
|
||||
final IAEFluidStack notInserted = inv.injectItems( aeFluidStack, Actionable.MODULATE, this.source );
|
||||
|
||||
if( notInserted != null && notInserted.getStackSize() > 0 )
|
||||
{
|
||||
aeFluidStack.decStackSize( notInserted.getStackSize() );
|
||||
}
|
||||
|
||||
fh.drain( this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true );
|
||||
|
||||
return TickRateModulation.FASTER;
|
||||
}
|
||||
|
||||
return TickRateModulation.IDLE;
|
||||
}
|
||||
catch(GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canDoBusWork()
|
||||
{
|
||||
return this.getProxy().isActive();
|
||||
}
|
||||
|
||||
private boolean isInFilter( FluidStack fluid )
|
||||
{
|
||||
for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ )
|
||||
{
|
||||
final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
|
||||
if( stack != null && stack.getFluidStack().equals( fluid ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean filterEnabled()
|
||||
{
|
||||
for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ )
|
||||
{
|
||||
final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
|
||||
if( stack != null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRSMode()
|
||||
{
|
||||
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( final IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 6, 6, 11, 10, 10, 13 );
|
||||
bch.addBox( 5, 5, 13, 11, 11, 14 );
|
||||
bch.addBox( 4, 4, 14, 12, 12, 16 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer )
|
||||
{
|
||||
rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 3, 3, 15, 13, 13, 16 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 4, 4, 14, 12, 12, 15 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderInventoryBox( renderer );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void renderStatic( final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer )
|
||||
{
|
||||
this.setRenderCache( rh.useSimplifiedRendering( x, y, z, this, this.getRenderCache() ) );
|
||||
rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
|
||||
|
||||
rh.setBounds( 4, 4, 14, 12, 12, 16 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 5, 5, 13, 11, 11, 14 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
rh.setBounds( 6, 6, 12, 10, 10, 13 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
|
||||
|
||||
rh.setBounds( 6, 6, 11, 10, 10, 12 );
|
||||
rh.renderBlock( x, y, z, renderer );
|
||||
|
||||
this.renderLights( x, y, z, rh, renderer );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable
|
||||
{
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 );
|
||||
private boolean lastRedstone;
|
||||
|
||||
public PartSharedFluidBus( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
}
|
||||
|
||||
public abstract IIcon getFaceIcon();
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
this.updateState();
|
||||
if( this.lastRedstone != this.getHost().hasRedstone( this.getSide() ) )
|
||||
{
|
||||
this.lastRedstone = !this.lastRedstone;
|
||||
if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE )
|
||||
{
|
||||
this.doBusWork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
try
|
||||
{
|
||||
if( !this.isSleeping() )
|
||||
{
|
||||
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getProxy().getTick().sleepDevice( this.getProxy().getNode() );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos)
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.FLUID_BUS_IO);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 6, 6, 11, 10, 10, 13 );
|
||||
bch.addBox( 5, 5, 13, 11, 11, 14 );
|
||||
bch.addBox( 4, 4, 14, 12, 12, 16 );
|
||||
}
|
||||
|
||||
protected TileEntity getConnectedTE()
|
||||
{
|
||||
TileEntity self = this.getHost().getTile();
|
||||
return this.getTileEntity( self, (new BlockPos(self)).getOffSet( this.getSide() ) );
|
||||
}
|
||||
|
||||
private TileEntity getTileEntity( final TileEntity self, final BlockPos pos )
|
||||
{
|
||||
final World w = self.getWorldObj();
|
||||
|
||||
if( w.getChunkProvider().chunkExists( pos.getX() >> 4, pos.getZ() >> 4 ) )
|
||||
{
|
||||
return w.getTileEntity( pos.getX(), pos.getY(), pos.getZ() );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int calculateAmountToSend()
|
||||
{
|
||||
double amount = 1000D;
|
||||
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
|
||||
{
|
||||
case 4:
|
||||
amount = amount * 1.5;
|
||||
case 3:
|
||||
amount = amount * 2;
|
||||
case 2:
|
||||
amount = amount * 4;
|
||||
case 1:
|
||||
amount = amount * 8;
|
||||
case 0:
|
||||
default:
|
||||
return (int) Math.floor( amount );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.readFromNBT( extra );
|
||||
this.config.readFromNBT( extra, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound extra )
|
||||
{
|
||||
super.writeToNBT( extra );
|
||||
this.config.writeToNBT( extra, "config" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name) {
|
||||
if (name.equals("config")) {
|
||||
return this.config;
|
||||
}
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
public void setFluidInSlot(int id, IAEFluidStack fluid) {
|
||||
ItemStack tmp = ItemFluidPacket.newStack(fluid == null ? null : fluid.getFluidStack());
|
||||
if (tmp != null) {
|
||||
tmp.setStackDisplayName(fluid.getFluidStack().getLocalizedName());
|
||||
}
|
||||
this.config.setInventorySlotContents(id, tmp);
|
||||
}
|
||||
|
||||
protected StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
protected abstract TickRateModulation doBusWork();
|
||||
|
||||
protected abstract boolean canDoBusWork();
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import appeng.core.AELog;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
@@ -6,6 +6,7 @@ import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.client.gui.container.*;
|
||||
import com.glodblock.github.common.parts.FCBasePart;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
|
||||
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
import com.glodblock.github.common.tile.TileIngredientBuffer;
|
||||
@@ -17,6 +18,18 @@ import java.util.List;
|
||||
|
||||
public enum GuiType {
|
||||
|
||||
FLUID_BUS_IO(new PartGuiFactory<PartSharedFluidBus>(PartSharedFluidBus.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartSharedFluidBus inv) {
|
||||
return new ContainerFluidIO(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, PartSharedFluidBus inv) {
|
||||
return new GuiFluidIO(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
INGREDIENT_BUFFER(new TileGuiFactory<TileIngredientBuffer>(TileIngredientBuffer.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, TileIngredientBuffer inv) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.glodblock.github.inventory.slot;
|
||||
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class OptionalFluidSlotFakeTypeOnly extends OptionalSlotFakeTypeOnly {
|
||||
|
||||
public OptionalFluidSlotFakeTypeOnly(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
FluidStack fluidStack = Util.getFluidFromItem(is);
|
||||
if (fluidStack != null) {
|
||||
ItemStack tmp = ItemFluidPacket.newStack(fluidStack);
|
||||
tmp.setStackDisplayName(fluidStack.getLocalizedName());
|
||||
super.putStack(tmp);
|
||||
}
|
||||
else {
|
||||
super.putStack(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ChannelLoader implements Runnable {
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void run() {
|
||||
int id = 0;
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id ++, Side.SERVER);
|
||||
@@ -19,5 +20,6 @@ public class ChannelLoader implements Runnable {
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketDumpTank.Handler(), CPacketDumpTank.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id ++, Side.CLIENT);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id ++, Side.SERVER);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ public class ItemAndBlockHolder {
|
||||
public static ItemPartFluidPatternTerminal FLUID_TERMINAL = new ItemPartFluidPatternTerminal().register();
|
||||
public static ItemPartFluidPatternTerminalEx FLUID_TERMINAL_EX = new ItemPartFluidPatternTerminalEx().register();
|
||||
public static ItemPartFluidInterface FLUID_INTERFACE = new ItemPartFluidInterface().register();
|
||||
public static ItemFluidImportBus FLUID_IMPORT_BUS = new ItemFluidImportBus().register();
|
||||
public static ItemFluidExportBus FLUID_EXPORT_BUS = new ItemFluidExportBus().register();
|
||||
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
|
||||
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
|
||||
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 4).register();
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidConfigurable;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CPacketFluidUpdate implements IMessage {
|
||||
|
||||
private Map<Integer, IAEFluidStack> list;
|
||||
|
||||
public CPacketFluidUpdate() {
|
||||
}
|
||||
|
||||
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data) {
|
||||
this.list = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int size = buf.readInt();
|
||||
this.list = new HashMap<>();
|
||||
try {
|
||||
for (int i = 0; i < size; i ++) {
|
||||
int id = buf.readInt();
|
||||
boolean isNull = buf.readBoolean();
|
||||
if (!isNull)
|
||||
list.put(id, null);
|
||||
else {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf);
|
||||
list.put(id, fluid);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(list.size());
|
||||
try {
|
||||
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
|
||||
buf.writeInt(fs.getKey());
|
||||
if (fs.getValue() == null)
|
||||
buf.writeBoolean(false);
|
||||
else {
|
||||
buf.writeBoolean(true);
|
||||
fs.getValue().writeToPacket(buf);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketFluidUpdate, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketFluidUpdate message, MessageContext ctx) {
|
||||
final Container c = ctx.getServerHandler().playerEntity.openContainer;
|
||||
if( c instanceof ContainerFluidConfigurable)
|
||||
{
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
|
||||
( (ContainerFluidConfigurable) c ).setFluid(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.gui.GuiFluidIO;
|
||||
import com.glodblock.github.client.gui.GuiIngredientBuffer;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -73,6 +74,11 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
|
||||
( (GuiIngredientBuffer) gs ).update(e.getKey(), e.getValue());
|
||||
}
|
||||
} else if( gs instanceof GuiFluidIO)
|
||||
{
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
|
||||
( (GuiFluidIO) gs ).update(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.implementations.GuiCraftingStatus;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.implementations.CraftingCPURecord;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.me.storage.MEPassThrough;
|
||||
@@ -29,6 +31,7 @@ import java.util.Set;
|
||||
public class Ae2Reflect {
|
||||
|
||||
private static final Field fInventory_container;
|
||||
private static final Field fInventory_containerUpgrade;
|
||||
private static final Field fInventory_width;
|
||||
private static final Field fAEPass_internal;
|
||||
private static final Field fAEInv_partitionList;
|
||||
@@ -41,6 +44,7 @@ public class Ae2Reflect {
|
||||
static {
|
||||
try {
|
||||
fInventory_container = reflectField(InventoryCrafting.class, "eventHandler", "field_70465_c", "c");
|
||||
fInventory_containerUpgrade = reflectField(ContainerUpgradeable.class, "upgradeable");
|
||||
fInventory_width = reflectField(InventoryCrafting.class, "inventoryWidth", "field_70464_b", "b");
|
||||
fAEPass_internal = reflectField(MEPassThrough.class, "internal");
|
||||
fAEInv_partitionList = reflectField(MEInventoryHandler.class, "myPartitionList");
|
||||
@@ -132,4 +136,8 @@ public class Ae2Reflect {
|
||||
return Ae2Reflect.readField(cpu, fCPU_size);
|
||||
}
|
||||
|
||||
public static IUpgradeableHost getUpgradeList(ContainerUpgradeable container) {
|
||||
return Ae2Reflect.readField(container, fInventory_containerUpgrade);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -22,6 +23,10 @@ public class BlockPos {
|
||||
this.z = te.zCoord;
|
||||
}
|
||||
|
||||
public BlockPos getOffSet(ForgeDirection face) {
|
||||
return new BlockPos(this.x + face.offsetX, this.y + face.offsetY, this.z + face.offsetZ);
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ public class NameConst {
|
||||
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL = "part_fluid_pattern_terminal";
|
||||
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL_EX = "part_fluid_pattern_terminal_ex";
|
||||
public static final String ITEM_PART_FLUID_INTERFACE = "part_fluid_interface";
|
||||
public static final String ITEM_PART_FLUID_IMPORT = "part_fluid_import";
|
||||
public static final String ITEM_PART_FLUID_EXPORT = "part_fluid_export";
|
||||
public static final String ITEM_FLUID_PACKET = "fluid_packet";
|
||||
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
|
||||
public static final String ITEM_FLUID_PART = "fluid_part";
|
||||
|
||||
Reference in new issue
Block a user