mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
--------- Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com> Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
165 lines
10 KiB
Diff
165 lines
10 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Lumine1909 <133463833+lumine1909@users.noreply.github.com>
|
|
Date: Wed, 26 Jun 2024 17:59:56 +0800
|
|
Subject: [PATCH] Allow grindstone overstacking
|
|
|
|
|
|
diff --git a/net/minecraft/world/SimpleContainer.java b/net/minecraft/world/SimpleContainer.java
|
|
index 75170c8d3be477a6ea2a1d62018a6ab630b0e54e..e5f348daf1ae9e604ae12928e5c8618c4803bd70 100644
|
|
--- a/net/minecraft/world/SimpleContainer.java
|
|
+++ b/net/minecraft/world/SimpleContainer.java
|
|
@@ -211,6 +211,12 @@ public class SimpleContainer implements Container, StackedContentsCompatible {
|
|
@Override
|
|
public void setItem(int index, ItemStack stack) {
|
|
this.items.set(index, stack);
|
|
+ // Leaves end - grindstone overstacking
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(stack)) {
|
|
+ this.setChanged();
|
|
+ return;
|
|
+ }
|
|
+ // Leaves end - grindstone overstacking
|
|
stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util
|
|
this.setChanged();
|
|
}
|
|
diff --git a/net/minecraft/world/entity/vehicle/ContainerEntity.java b/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
|
index 358de981544b220bde770410c24e5f6b10520d91..d079513d0fcafc1f9d0b6384602d0d3f4093b9db 100644
|
|
--- a/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
|
+++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
|
@@ -163,6 +163,11 @@ public interface ContainerEntity extends Container, MenuProvider {
|
|
default void setChestVehicleItem(int slot, ItemStack stack) {
|
|
this.unpackChestVehicleLootTable(null);
|
|
this.getItemStacks().set(slot, stack);
|
|
+ // Leaves end - grindstone overstacking
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(stack)) {
|
|
+ return;
|
|
+ }
|
|
+ // Leaves end - grindstone overstacking
|
|
stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
index e78baa9433b6f5cb32142fe583fe95831b173d5a..509d368f7fa9e6330da02615d7bf78debb932623 100644
|
|
--- a/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
+++ b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
|
@@ -607,7 +607,7 @@ public abstract class AbstractContainerMenu {
|
|
} else if (carried.isEmpty()) {
|
|
if (slot.mayPlace(item)) {
|
|
int maxStackSize = slot.getMaxStackSize(item);
|
|
- if (item.getCount() > maxStackSize) {
|
|
+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && item.getCount() > maxStackSize) { // Leaves - grindstone overstacking
|
|
slot.setByPlayer(item.split(maxStackSize));
|
|
} else {
|
|
inventory.setItem(button, ItemStack.EMPTY);
|
|
@@ -616,7 +616,7 @@ public abstract class AbstractContainerMenu {
|
|
}
|
|
} else if (slot.mayPickup(player) && slot.mayPlace(item)) {
|
|
int maxStackSize = slot.getMaxStackSize(item);
|
|
- if (item.getCount() > maxStackSize) {
|
|
+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && item.getCount() > maxStackSize) { // Leaves - grindstone overstacking
|
|
slot.setByPlayer(item.split(maxStackSize));
|
|
slot.onTake(player, carried);
|
|
if (!inventory.add(carried)) {
|
|
@@ -776,10 +776,15 @@ public abstract class AbstractContainerMenu {
|
|
public abstract boolean stillValid(Player player);
|
|
|
|
protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) {
|
|
+ // Leaves start - Add force move
|
|
// Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent
|
|
return this.moveItemStackTo(stack, startIndex, endIndex, reverseDirection, false);
|
|
}
|
|
protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection, boolean isCheck) {
|
|
+ return this.moveItemStackTo(stack, startIndex, endIndex, reverseDirection, isCheck, false);
|
|
+ }
|
|
+ protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection, boolean isCheck, boolean forceMove) {
|
|
+ // Leaves end - Add force move
|
|
if (isCheck) {
|
|
stack = stack.copy();
|
|
}
|
|
@@ -844,6 +849,14 @@ public abstract class AbstractContainerMenu {
|
|
// Paper end - Add PlayerTradeEvent and PlayerPurchaseEvent
|
|
if (itemx.isEmpty() && slotx.mayPlace(stack)) {
|
|
int i1 = slotx.getMaxStackSize(stack);
|
|
+ // Leaves start - Add force move
|
|
+ if (forceMove) {
|
|
+ slotx.setByPlayer(stack.split(stack.getCount()));
|
|
+ slotx.setChanged();
|
|
+ flag = true;
|
|
+ break;
|
|
+ }
|
|
+ // Leaves end - Add force move
|
|
// Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent
|
|
if (isCheck) {
|
|
stack.shrink(Math.min(stack.getCount(), i1));
|
|
diff --git a/net/minecraft/world/inventory/GrindstoneMenu.java b/net/minecraft/world/inventory/GrindstoneMenu.java
|
|
index ad70a0f7debee27d9f3b2ff39cb0429b39485190..c8d3a8b9087460b20547dc49c1bf70bda87c218d 100644
|
|
--- a/net/minecraft/world/inventory/GrindstoneMenu.java
|
|
+++ b/net/minecraft/world/inventory/GrindstoneMenu.java
|
|
@@ -179,7 +179,7 @@ public class GrindstoneMenu extends AbstractContainerMenu {
|
|
int i2 = i + i1 + max * 5 / 100;
|
|
int i3 = 1;
|
|
if (!inputItem.isDamageableItem()) {
|
|
- if (inputItem.getMaxStackSize() < 2 || !ItemStack.matches(inputItem, additionalItem)) {
|
|
+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && inputItem.getMaxStackSize() < 2 || !ItemStack.matches(inputItem, additionalItem)) { // Leaves - allowGrindstoneOverstaking
|
|
return ItemStack.EMPTY;
|
|
}
|
|
|
|
@@ -248,7 +248,7 @@ public class GrindstoneMenu extends AbstractContainerMenu {
|
|
ItemStack item1 = this.repairSlots.getItem(0);
|
|
ItemStack item2 = this.repairSlots.getItem(1);
|
|
if (slotIndex == 2) {
|
|
- if (!this.moveItemStackTo(item, 3, 39, true)) {
|
|
+ if (!this.moveItemStackTo(item, 3, 39, true, false, org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking)) { // Leaves - allowGrindstoneOverstacking: Disable stack check
|
|
return ItemStack.EMPTY;
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
|
index 8a93c4b9571b3088dc92317544d209603880d3fa..005fd35dcae20d404922ef797cf22ef69ecd6c3a 100644
|
|
--- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
|
+++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
|
@@ -410,7 +410,11 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
|
ItemStack itemStack = this.items.get(index);
|
|
boolean flag = !stack.isEmpty() && ItemStack.isSameItemSameComponents(itemStack, stack);
|
|
this.items.set(index, stack);
|
|
- stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util
|
|
+ // Leaves end - grindstone overstacking
|
|
+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking || !org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(itemStack)) {
|
|
+ stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util
|
|
+ }
|
|
+ // Leaves end - grindstone overstacking
|
|
if (index == 0 && !flag && this.level instanceof ServerLevel serverLevel) {
|
|
this.cookingTotalTime = getTotalCookTime(serverLevel, this, this.recipeType, this.cookSpeedMultiplier); // Paper - cook speed multiplier API
|
|
this.cookingTimer = 0;
|
|
diff --git a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
|
index 701a12db0c342c9ff2c974e581b112182dec2ea6..1e6819928ffab524197003bd9469adb3976dce3a 100644
|
|
--- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
|
+++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
|
@@ -149,6 +149,12 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co
|
|
@Override
|
|
public void setItem(int slot, ItemStack stack) {
|
|
this.getItems().set(slot, stack);
|
|
+ // Leaves end - grindstone overstacking
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(stack)) {
|
|
+ this.setChanged();
|
|
+ return;
|
|
+ }
|
|
+ // Leaves end - grindstone overstacking
|
|
stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util
|
|
this.setChanged();
|
|
}
|
|
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
|
index a7ade5f683e43463f9ea42ad6843e9c80f2fa46c..83a8dc51d0346fb5b28922e7b54d5ee58b315228 100644
|
|
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
|
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
|
@@ -114,6 +114,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
|
public void setItem(int index, ItemStack stack) {
|
|
this.unpackLootTable(null);
|
|
this.getItems().set(index, stack);
|
|
+ // Leaves end - grindstone overstacking
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(stack)) {
|
|
+ return;
|
|
+ }
|
|
+ // Leaves end - grindstone overstacking
|
|
stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util
|
|
}
|
|
|