Skip to content

Commit fbf087c

Browse files
committed
Prevent weird GUI behaviour at small X coordinates
GTNewHorizons/GT-New-Horizons-Modpack#7377
1 parent 11f1d36 commit fbf087c

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
aeversion=rv3
22
aechannel=beta
3-
aebuild=40-GTNH
3+
aebuild=41-GTNH
44
#KEEP V6 FOR MOD SUPPORT
55
aegroup=appeng
66
aebasename=appliedenergistics2

src/main/java/appeng/core/sync/GuiBridge.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,17 @@ private void getGui()
215215
public Object getServerGuiElement( final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z )
216216
{
217217
final ForgeDirection side = ForgeDirection.getOrientation( ordinal & 0x07 );
218-
final GuiBridge ID = values()[ordinal >> 4];
218+
final GuiBridge ID = values()[ordinal >> 5];
219219
final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1;
220+
final boolean xIsSlotIndex = ( ( ordinal >> 4 ) & 1 ) == 1;
220221
if( ID.type.isItem() )
221222
{
222223
ItemStack it = null;
223224
if( stem )
224225
{
225226
it = player.inventory.getCurrentItem();
226227
}
227-
else if( x >= 0 && x < player.inventory.mainInventory.length )
228+
else if( xIsSlotIndex && x >= 0 && x < player.inventory.mainInventory.length )
228229
{
229230
it = player.inventory.getStackInSlot( x );
230231
}
@@ -397,16 +398,17 @@ private void addPressAchievementToPlayer( final ItemStack newItem, final IMateri
397398
public Object getClientGuiElement( final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z )
398399
{
399400
final ForgeDirection side = ForgeDirection.getOrientation( ordinal & 0x07 );
400-
final GuiBridge ID = values()[ordinal >> 4];
401+
final GuiBridge ID = values()[ordinal >> 5];
401402
final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1;
403+
final boolean xIsSlotIndex = ( ( ordinal >> 4 ) & 1 ) == 1;
402404
if( ID.type.isItem() )
403405
{
404406
ItemStack it = null;
405407
if( stem )
406408
{
407409
it = player.inventory.getCurrentItem();
408410
}
409-
else if( x >= 0 && x < player.inventory.mainInventory.length )
411+
else if (xIsSlotIndex && x >= 0 && x < player.inventory.mainInventory.length )
410412
{
411413
it = player.inventory.getStackInSlot( x );
412414
}

src/main/java/appeng/util/Platform.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,15 @@ public static void openGUI( @Nonnull final EntityPlayer p, @Nullable final TileE
338338
{
339339
if( tile == null && type.getType() == GuiHostType.ITEM )
340340
{
341-
p.openGui( AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), p.inventory.currentItem, 0, 0 );
341+
p.openGui( AppEng.instance(), type.ordinal() << 5 | (1 << 4), p.getEntityWorld(), p.inventory.currentItem, 0, 0 );
342342
}
343343
else if( tile == null || type.getType() == GuiHostType.ITEM )
344344
{
345-
p.openGui( AppEng.instance(), type.ordinal() << 4 | ( 1 << 3 ), p.getEntityWorld(), x, y, z );
345+
p.openGui( AppEng.instance(), type.ordinal() << 5 | ( 1 << 3 ), p.getEntityWorld(), x, y, z );
346346
}
347347
else
348348
{
349-
p.openGui( AppEng.instance(), type.ordinal() << 4 | ( side.ordinal() ), tile.getWorldObj(), x, y, z );
349+
p.openGui( AppEng.instance(), type.ordinal() << 5 | ( side.ordinal() ), tile.getWorldObj(), x, y, z );
350350
}
351351
}
352352
}

0 commit comments

Comments
 (0)