mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-19 03:49:33 +00:00
Prevent some crashes when grabbing items from drawers (#49)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
da11704f55
commit
464add34bf
2 files changed
+16
-8
No files matched your search
@@ -376,12 +376,14 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
if (locked) {
|
||||
int slot = getDrawerSlot(side, hitX, hitY, hitZ);
|
||||
IDrawer drawer = tileDrawers.getDrawer(slot);
|
||||
ItemStack stack = drawer.getStoredItemPrototype();
|
||||
int count = drawer.getStoredItemCount();
|
||||
if (drawer != null) {
|
||||
ItemStack stack = drawer.getStoredItemPrototype();
|
||||
int count = drawer.getStoredItemCount();
|
||||
|
||||
if (stack != null && count == 0) {
|
||||
drawer.setStoredItemRedir(null, 0);
|
||||
return true;
|
||||
if (stack != null && count == 0) {
|
||||
drawer.setStoredItemRedir(null, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
tileDrawers.setLocked(LockAttribute.LOCK_POPULATED, !locked);
|
||||
@@ -424,10 +426,12 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
|
||||
int slot = getDrawerSlot(side, hitX, hitY, hitZ);
|
||||
IDrawer drawer = tileDrawers.getDrawer(slot);
|
||||
ItemStack currentStack = drawer.getStoredItemPrototype();
|
||||
if (drawer != null) {
|
||||
ItemStack currentStack = drawer.getStoredItemPrototype();
|
||||
|
||||
int countAdded = tileDrawers.interactPutItemsIntoSlot(slot, player);
|
||||
if (countAdded > 0 && currentStack != null) world.markBlockForUpdate(x, y, z);
|
||||
int countAdded = tileDrawers.interactPutItemsIntoSlot(slot, player);
|
||||
if (countAdded > 0 && currentStack != null) world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -504,6 +508,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
|
||||
int slot = getDrawerSlot(side, hitX, hitY, hitZ);
|
||||
IDrawer drawer = tileDrawers.getDrawer(slot);
|
||||
if (drawer == null) return;
|
||||
|
||||
final ItemStack item;
|
||||
// if invertSHift is true this will happen when the player is not shifting
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.jaquadro.minecraft.storagedrawers.block.tile;
|
||||
import java.util.EnumSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -857,6 +859,7 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IDrawer getDrawer(int slot) {
|
||||
if (slot < 0 || slot >= drawers.length) return null;
|
||||
|
||||
|
||||
Reference in new issue
Block a user