Fixed Crafting for real, attempt 2.
This commit is contained in:
parent
9ae5477b90
commit
843b2cd9c5
7 changed files with 24 additions and 13 deletions
|
@ -1,7 +1,9 @@
|
|||
package appeng.container;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.parts.IPart;
|
||||
|
||||
public class ContainerOpenContext
|
||||
{
|
||||
|
@ -9,5 +11,18 @@ public class ContainerOpenContext
|
|||
public World w;
|
||||
public int x, y, z;
|
||||
public ForgeDirection side;
|
||||
final public boolean isItem;
|
||||
|
||||
public ContainerOpenContext(Object myItem) {
|
||||
boolean isWorld = myItem instanceof IPart || myItem instanceof TileEntity;
|
||||
isItem = !isWorld;
|
||||
}
|
||||
|
||||
public TileEntity getTile()
|
||||
{
|
||||
if ( isItem )
|
||||
return null;
|
||||
return w.getTileEntity( x, y, z );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -336,7 +336,7 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
|||
// :(
|
||||
}
|
||||
|
||||
TileEntity te = openContext.w.getTileEntity( openContext.x, openContext.y, openContext.z );
|
||||
TileEntity te = openContext.getTile();
|
||||
Platform.openGUI( invPlayer.player, te, openContext.side, OriginalGui );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,12 +284,12 @@ public enum GuiBridge implements IGuiHandler
|
|||
return null;
|
||||
}
|
||||
|
||||
private Object updateGui(Object newContainer, World w, int x, int y, int z, ForgeDirection side)
|
||||
private Object updateGui(Object newContainer, World w, int x, int y, int z, ForgeDirection side, Object myItem)
|
||||
{
|
||||
if ( newContainer instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer bc = (AEBaseContainer) newContainer;
|
||||
bc.openContext = new ContainerOpenContext();
|
||||
bc.openContext = new ContainerOpenContext( myItem );
|
||||
bc.openContext.w = w;
|
||||
bc.openContext.x = x;
|
||||
bc.openContext.y = y;
|
||||
|
@ -311,7 +311,7 @@ public enum GuiBridge implements IGuiHandler
|
|||
ItemStack it = player.inventory.getCurrentItem();
|
||||
Object myItem = getGuiObject( it, player, w, x, y, z );
|
||||
if ( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||
return updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side );
|
||||
return updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side, myItem );
|
||||
}
|
||||
|
||||
if ( ID.type.isTile() )
|
||||
|
@ -322,12 +322,12 @@ public enum GuiBridge implements IGuiHandler
|
|||
((IPartHost) TE).getPart( side );
|
||||
IPart part = ((IPartHost) TE).getPart( side );
|
||||
if ( ID.CorrectTileOrPart( part ) )
|
||||
return updateGui( ID.ConstructContainer( player.inventory, side, part ), w, x, y, z, side );
|
||||
return updateGui( ID.ConstructContainer( player.inventory, side, part ), w, x, y, z, side, part );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ID.CorrectTileOrPart( TE ) )
|
||||
return updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side );
|
||||
return updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side, TE );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ public class PacketCraftRequest extends AppEngPacket
|
|||
ContainerOpenContext context = cca.openContext;
|
||||
if ( context != null )
|
||||
{
|
||||
TileEntity te = context.w.getTileEntity( context.x, context.y, context.z );
|
||||
TileEntity te = context.getTile();
|
||||
Platform.openGUI( player, te, cca.openContext.side, GuiBridge.GUI_CRAFTING_CONFIRM );
|
||||
|
||||
if ( player.openContainer instanceof ContainerCraftConfirm )
|
||||
|
|
|
@ -52,7 +52,7 @@ public class PacketInventoryAction extends AppEngPacket
|
|||
ContainerOpenContext context = aebc.openContext;
|
||||
if ( context != null )
|
||||
{
|
||||
TileEntity te = context.w.getTileEntity( context.x, context.y, context.z );
|
||||
TileEntity te = context.getTile();
|
||||
Platform.openGUI( sender, te, aebc.openContext.side, GuiBridge.GUI_CRAFTING_AMOUNT );
|
||||
|
||||
if ( sender.openContainer instanceof ContainerCraftAmount )
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PacketSwitchGuis extends AppEngPacket
|
|||
ContainerOpenContext context = bc.openContext;
|
||||
if ( context != null )
|
||||
{
|
||||
TileEntity te = context.w.getTileEntity( context.x, context.y, context.z );
|
||||
TileEntity te = context.getTile();
|
||||
Platform.openGUI( player, te, context.side, newGui );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,10 +299,6 @@ public class Platform
|
|||
z = tile.zCoord;
|
||||
}
|
||||
|
||||
// valid tile?
|
||||
if ( !type.CorrectTileOrPart( tile ) )
|
||||
tile = null;
|
||||
|
||||
if ( (type.getType().isItem() && tile == null) || type.hasPermissions( tile, x, y, z, side, p ) )
|
||||
{
|
||||
if ( tile == null )
|
||||
|
|
Loading…
Reference in a new issue