wip
This commit is contained in:
@@ -321,7 +321,7 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients
|
|||||||
final PacketInventoryAction p;
|
final PacketInventoryAction p;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (GuiFluidSlot) guiCustomSlot, AEFluidStack.fromFluidStack( finalFluidStack ) );
|
p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (GuiFluidSlot) guiCustomSlot, AEItemStack.fromItemStack(AEFluidStack.fromFluidStack( finalFluidStack ).asItemStackRepresentation() ));
|
||||||
NetworkHandler.instance().sendToServer( p );
|
NetworkHandler.instance().sendToServer( p );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package appeng.container.slot;
|
||||||
|
|
||||||
|
public interface IJEITargetSlot {
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
|
||||||
public class SlotFake extends AppEngSlot
|
public class SlotFake extends AppEngSlot implements IJEITargetSlot
|
||||||
{
|
{
|
||||||
|
|
||||||
public SlotFake( final IItemHandler inv, final int idx, final int x, final int y )
|
public SlotFake( final IItemHandler inv, final int idx, final int x, final int y )
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import java.io.IOException;
|
|||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||||
import appeng.client.gui.widgets.GuiCustomSlot;
|
import appeng.client.gui.widgets.GuiCustomSlot;
|
||||||
|
import appeng.container.slot.IJEITargetSlot;
|
||||||
import appeng.container.slot.SlotFake;
|
import appeng.container.slot.SlotFake;
|
||||||
import appeng.fluids.client.gui.GuiFluidInterface;
|
|
||||||
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
|
||||||
import appeng.fluids.util.AEFluidStack;
|
import appeng.fluids.util.AEFluidStack;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@@ -48,6 +48,7 @@ import appeng.core.sync.network.INetworkInfo;
|
|||||||
import appeng.helpers.InventoryAction;
|
import appeng.helpers.InventoryAction;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
|
||||||
public class PacketInventoryAction extends AppEngPacket
|
public class PacketInventoryAction extends AppEngPacket
|
||||||
@@ -57,7 +58,6 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
private final int slot;
|
private final int slot;
|
||||||
private final long id;
|
private final long id;
|
||||||
private final IAEItemStack slotItem;
|
private final IAEItemStack slotItem;
|
||||||
private final IAEFluidStack slotFluid;
|
|
||||||
|
|
||||||
// automatic.
|
// automatic.
|
||||||
public PacketInventoryAction( final ByteBuf stream ) throws IOException
|
public PacketInventoryAction( final ByteBuf stream ) throws IOException
|
||||||
@@ -66,7 +66,6 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
this.slot = stream.readInt();
|
this.slot = stream.readInt();
|
||||||
this.id = stream.readLong();
|
this.id = stream.readLong();
|
||||||
final boolean hasItem = stream.readBoolean();
|
final boolean hasItem = stream.readBoolean();
|
||||||
final boolean hasFluid = stream.readBoolean();
|
|
||||||
|
|
||||||
if( hasItem )
|
if( hasItem )
|
||||||
{
|
{
|
||||||
@@ -76,14 +75,6 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
{
|
{
|
||||||
this.slotItem = null;
|
this.slotItem = null;
|
||||||
}
|
}
|
||||||
if( hasFluid )
|
|
||||||
{
|
|
||||||
this.slotFluid = AEFluidStack.fromPacket( stream );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.slotFluid = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// api
|
// api
|
||||||
@@ -98,7 +89,6 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
this.id = 0;
|
this.id = 0;
|
||||||
this.slotItem = slotItem;
|
this.slotItem = slotItem;
|
||||||
this.slotFluid = null;
|
|
||||||
|
|
||||||
final ByteBuf data = Unpooled.buffer();
|
final ByteBuf data = Unpooled.buffer();
|
||||||
|
|
||||||
@@ -110,19 +100,17 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
if( slotItem == null )
|
if( slotItem == null )
|
||||||
{
|
{
|
||||||
data.writeBoolean( false );
|
data.writeBoolean( false );
|
||||||
data.writeBoolean( false );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data.writeBoolean( true );
|
data.writeBoolean( true );
|
||||||
data.writeBoolean( false );
|
|
||||||
slotItem.writeToPacket( data );
|
slotItem.writeToPacket( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.configureWrite( data );
|
this.configureWrite( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketInventoryAction( final InventoryAction action, final SlotFake slot, final IAEItemStack slotItem ) throws IOException
|
public PacketInventoryAction(final InventoryAction action, final IJEITargetSlot slot, final IAEItemStack slotItem ) throws IOException
|
||||||
{
|
{
|
||||||
if( action != InventoryAction.PLACE_JEI_GHOST_ITEM )
|
if( action != InventoryAction.PLACE_JEI_GHOST_ITEM )
|
||||||
{
|
{
|
||||||
@@ -130,65 +118,29 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.slot = slot.slotNumber;
|
if (slot instanceof SlotFake)
|
||||||
|
this.slot = ((SlotFake) slot).slotNumber;
|
||||||
|
else this.slot = ((GuiFluidSlot) slot).getId();
|
||||||
this.id = 0;
|
this.id = 0;
|
||||||
this.slotItem = slotItem;
|
this.slotItem = slotItem;
|
||||||
this.slotFluid = null;
|
|
||||||
|
|
||||||
final ByteBuf data = Unpooled.buffer();
|
final ByteBuf data = Unpooled.buffer();
|
||||||
|
|
||||||
data.writeInt( this.getPacketID() );
|
data.writeInt( this.getPacketID() );
|
||||||
data.writeInt( action.ordinal() );
|
data.writeInt( action.ordinal() );
|
||||||
data.writeInt( slot.slotNumber );
|
data.writeInt( this.slot );
|
||||||
data.writeLong( this.id );
|
data.writeLong( this.id );
|
||||||
|
|
||||||
if( slotItem == null )
|
if( slotItem == null )
|
||||||
{
|
{
|
||||||
data.writeBoolean( false );
|
data.writeBoolean( false );
|
||||||
data.writeBoolean( false );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data.writeBoolean( true );
|
data.writeBoolean( true );
|
||||||
data.writeBoolean( false );
|
|
||||||
slotItem.writeToPacket( data );
|
slotItem.writeToPacket( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.configureWrite( data );
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketInventoryAction( final InventoryAction action, final GuiFluidSlot slot, final IAEFluidStack slotFluid ) throws IOException
|
|
||||||
{
|
|
||||||
if( action != InventoryAction.PLACE_JEI_GHOST_ITEM )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." );
|
|
||||||
}
|
|
||||||
|
|
||||||
this.action = action;
|
|
||||||
this.slot = slot.getId();
|
|
||||||
this.id = 2;
|
|
||||||
this.slotFluid = slotFluid;
|
|
||||||
this.slotItem = null;
|
|
||||||
|
|
||||||
final ByteBuf data = Unpooled.buffer();
|
|
||||||
|
|
||||||
data.writeInt( this.getPacketID() );
|
|
||||||
data.writeInt( action.ordinal() );
|
|
||||||
data.writeInt( slot.getId() );
|
|
||||||
data.writeLong( this.id );
|
|
||||||
data.writeBoolean( false );
|
|
||||||
|
|
||||||
if( slotFluid == null )
|
|
||||||
{
|
|
||||||
data.writeBoolean( false );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data.writeBoolean( true );
|
|
||||||
slotFluid.writeToPacket( data );
|
|
||||||
}
|
|
||||||
|
|
||||||
this.configureWrite( data );
|
this.configureWrite( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +151,6 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.slotItem = null;
|
this.slotItem = null;
|
||||||
this.slotFluid = null;
|
|
||||||
|
|
||||||
final ByteBuf data = Unpooled.buffer();
|
final ByteBuf data = Unpooled.buffer();
|
||||||
|
|
||||||
@@ -208,7 +159,6 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
data.writeInt( slot );
|
data.writeInt( slot );
|
||||||
data.writeLong( id );
|
data.writeLong( id );
|
||||||
data.writeBoolean( false );
|
data.writeBoolean( false );
|
||||||
data.writeBoolean( false );
|
|
||||||
|
|
||||||
this.configureWrite( data );
|
this.configureWrite( data );
|
||||||
}
|
}
|
||||||
@@ -247,7 +197,7 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
{
|
{
|
||||||
if( sender.openContainer.inventorySlots.get( this.slot ) instanceof SlotFake )
|
if( sender.openContainer.inventorySlots.get( this.slot ) instanceof SlotFake )
|
||||||
{
|
{
|
||||||
if( this.slotItem != null ) sender.openContainer.inventorySlots.get( this.slot ).putStack( this.slotItem.createItemStack() );
|
if( this.slotItem != null ) sender.openContainer.inventorySlots.get( this.slot ).putStack( this.slotItem.asItemStackRepresentation() );
|
||||||
else sender.openContainer.inventorySlots.get( this.slot ).putStack( ItemStack.EMPTY );
|
else sender.openContainer.inventorySlots.get( this.slot ).putStack( ItemStack.EMPTY );
|
||||||
}
|
}
|
||||||
if( Minecraft.getMinecraft().currentScreen instanceof GuiUpgradeable )
|
if( Minecraft.getMinecraft().currentScreen instanceof GuiUpgradeable )
|
||||||
@@ -256,21 +206,19 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
if( cs.getGuiSlots().size() > 0 )
|
if( cs.getGuiSlots().size() > 0 )
|
||||||
{
|
{
|
||||||
GuiCustomSlot ct = cs.getGuiSlots().get( this.slot );
|
GuiCustomSlot ct = cs.getGuiSlots().get( this.slot );
|
||||||
if( this.slotFluid != null )
|
GuiFluidSlot gfs = (GuiFluidSlot) ct;
|
||||||
|
if( this.slotItem != null )
|
||||||
{
|
{
|
||||||
if( ct instanceof GuiFluidSlot )
|
IAEFluidStack aefs = AEFluidStack.fromNBT(this.slotItem.getDefinition().getTagCompound());
|
||||||
|
if (aefs != null)
|
||||||
{
|
{
|
||||||
GuiFluidSlot gfs = (GuiFluidSlot) ct;
|
FluidStack fluid = aefs.getFluidStack();
|
||||||
gfs.setFluidStack( this.slotFluid );
|
gfs.setFluidStack(AEFluidStack.fromFluidStack(fluid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( ct instanceof GuiFluidSlot )
|
gfs.setFluidStack( null );
|
||||||
{
|
|
||||||
GuiFluidSlot gfs = (GuiFluidSlot) ct;
|
|
||||||
gfs.setFluidStack( null );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package appeng.fluids.client.gui.widgets;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import appeng.container.slot.IJEITargetSlot;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
@@ -23,7 +24,7 @@ import appeng.fluids.util.AEFluidStack;
|
|||||||
import appeng.fluids.util.IAEFluidTank;
|
import appeng.fluids.util.IAEFluidTank;
|
||||||
|
|
||||||
|
|
||||||
public class GuiFluidSlot extends GuiCustomSlot
|
public class GuiFluidSlot extends GuiCustomSlot implements IJEITargetSlot
|
||||||
{
|
{
|
||||||
private final IAEFluidTank fluids;
|
private final IAEFluidTank fluids;
|
||||||
private final int slot;
|
private final int slot;
|
||||||
|
|||||||
Reference in New Issue
Block a user