mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Fix #346. Legacy crash from old Apiarist chest
This commit is contained in:
1 parent
9d70a1b0ec
commit
8b37aa86ff
2 files changed
+31
-6
No files matched your search
@@ -10,6 +10,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.gui.slots.SlotForestry;
|
||||
import forestry.core.utils.EnumAccess;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -17,11 +22,6 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.gui.slots.SlotForestry;
|
||||
import forestry.core.utils.EnumAccess;
|
||||
import forestry.core.utils.StackUtils;
|
||||
|
||||
public class ContainerForestry extends Container {
|
||||
|
||||
protected IInventory inventory;
|
||||
@@ -44,9 +44,13 @@ public class ContainerForestry extends Container {
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotIndex, int button, int modifier, EntityPlayer player) {
|
||||
if (inventoryForestry != null && (inventoryForestry.getAccess() != EnumAccess.SHARED) && !inventoryForestry.owner.equals(player.getGameProfile()))
|
||||
if (player == null)
|
||||
return null;
|
||||
|
||||
if ((inventoryForestry != null) && (inventoryForestry.getAccess() != EnumAccess.SHARED))
|
||||
if ((inventoryForestry.owner != null) && !PlayerUtil.isSameGameProfile(inventoryForestry.owner, player.getGameProfile()))
|
||||
return null;
|
||||
|
||||
Slot slot = slotIndex < 0 ? null : (Slot) this.inventorySlots.get(slotIndex);
|
||||
if (slot instanceof SlotForestry) {
|
||||
((SlotForestry) slot).onSlotClick(slotIndex, button, modifier, player);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerUtil {
|
||||
|
||||
public static boolean isSameGameProfile(GameProfile player1, GameProfile player2) {
|
||||
if (player1 == null || player2 == null)
|
||||
return false;
|
||||
|
||||
UUID id1 = player1.getId();
|
||||
UUID id2 = player2.getId();
|
||||
if (id1 != null && id2 != null)
|
||||
return id1.equals(id2);
|
||||
|
||||
return player1.getName() != null && player1.getName().equals(player2.getName());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user