Skip to content

Commit

Permalink
Prevent weird GUI behaviour at small X coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
repo-alt committed Jan 31, 2021
1 parent 11f1d36 commit fbf087c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aeversion=rv3
aechannel=beta
aebuild=40-GTNH
aebuild=41-GTNH
#KEEP V6 FOR MOD SUPPORT
aegroup=appeng
aebasename=appliedenergistics2
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/appeng/core/sync/GuiBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,17 @@ private void getGui()
public Object getServerGuiElement( final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z )
{
final ForgeDirection side = ForgeDirection.getOrientation( ordinal & 0x07 );
final GuiBridge ID = values()[ordinal >> 4];
final GuiBridge ID = values()[ordinal >> 5];
final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1;
final boolean xIsSlotIndex = ( ( ordinal >> 4 ) & 1 ) == 1;
if( ID.type.isItem() )
{
ItemStack it = null;
if( stem )
{
it = player.inventory.getCurrentItem();
}
else if( x >= 0 && x < player.inventory.mainInventory.length )
else if( xIsSlotIndex && x >= 0 && x < player.inventory.mainInventory.length )
{
it = player.inventory.getStackInSlot( x );
}
Expand Down Expand Up @@ -397,16 +398,17 @@ private void addPressAchievementToPlayer( final ItemStack newItem, final IMateri
public Object getClientGuiElement( final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z )
{
final ForgeDirection side = ForgeDirection.getOrientation( ordinal & 0x07 );
final GuiBridge ID = values()[ordinal >> 4];
final GuiBridge ID = values()[ordinal >> 5];
final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1;
final boolean xIsSlotIndex = ( ( ordinal >> 4 ) & 1 ) == 1;
if( ID.type.isItem() )
{
ItemStack it = null;
if( stem )
{
it = player.inventory.getCurrentItem();
}
else if( x >= 0 && x < player.inventory.mainInventory.length )
else if (xIsSlotIndex && x >= 0 && x < player.inventory.mainInventory.length )
{
it = player.inventory.getStackInSlot( x );
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/appeng/util/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@ public static void openGUI( @Nonnull final EntityPlayer p, @Nullable final TileE
{
if( tile == null && type.getType() == GuiHostType.ITEM )
{
p.openGui( AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), p.inventory.currentItem, 0, 0 );
p.openGui( AppEng.instance(), type.ordinal() << 5 | (1 << 4), p.getEntityWorld(), p.inventory.currentItem, 0, 0 );
}
else if( tile == null || type.getType() == GuiHostType.ITEM )
{
p.openGui( AppEng.instance(), type.ordinal() << 4 | ( 1 << 3 ), p.getEntityWorld(), x, y, z );
p.openGui( AppEng.instance(), type.ordinal() << 5 | ( 1 << 3 ), p.getEntityWorld(), x, y, z );
}
else
{
p.openGui( AppEng.instance(), type.ordinal() << 4 | ( side.ordinal() ), tile.getWorldObj(), x, y, z );
p.openGui( AppEng.instance(), type.ordinal() << 5 | ( side.ordinal() ), tile.getWorldObj(), x, y, z );
}
}
}
Expand Down

0 comments on commit fbf087c

Please sign in to comment.