fix dismantling storage blocks not checking stacksize (#2970)
This commit is contained in:
@@ -64,6 +64,7 @@ public class StorageBlockItem extends BaseBlockItem {
|
|||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||||
ItemStack storageStack = player.getHeldItem(hand);
|
ItemStack storageStack = player.getHeldItem(hand);
|
||||||
|
int count = storageStack.getCount();
|
||||||
|
|
||||||
if (!world.isRemote && player.isCrouching() && type != ItemStorageType.CREATIVE) {
|
if (!world.isRemote && player.isCrouching() && type != ItemStorageType.CREATIVE) {
|
||||||
UUID diskId = null;
|
UUID diskId = null;
|
||||||
@@ -77,6 +78,7 @@ public class StorageBlockItem extends BaseBlockItem {
|
|||||||
// Newly created storages won't have a tag yet, so allow invalid disks as well.
|
// Newly created storages won't have a tag yet, so allow invalid disks as well.
|
||||||
if (disk == null || disk.getStored() == 0) {
|
if (disk == null || disk.getStored() == 0) {
|
||||||
ItemStack storagePart = new ItemStack(StoragePartItem.getByType(type));
|
ItemStack storagePart = new ItemStack(StoragePartItem.getByType(type));
|
||||||
|
storagePart.setCount(count);
|
||||||
|
|
||||||
if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
|
if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
|
||||||
InventoryHelper.spawnItemStack(world, player.getPosX(), player.getPosY(), player.getPosZ(), storagePart);
|
InventoryHelper.spawnItemStack(world, player.getPosX(), player.getPosY(), player.getPosZ(), storagePart);
|
||||||
@@ -87,7 +89,9 @@ public class StorageBlockItem extends BaseBlockItem {
|
|||||||
API.instance().getStorageDiskManager((ServerWorld) world).markForSaving();
|
API.instance().getStorageDiskManager((ServerWorld) world).markForSaving();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ActionResult<>(ActionResultType.SUCCESS, new ItemStack(RSBlocks.MACHINE_CASING.get()));
|
ItemStack stack = new ItemStack(RSBlocks.MACHINE_CASING.get());
|
||||||
|
stack.setCount(count);
|
||||||
|
return new ActionResult<>(ActionResultType.SUCCESS, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user