feat: 新增载具可堆叠规则(矿车/船堆叠至64)
mixin ItemInstance.getMaxStackSize,规则开启时矿车/船返回64,实现自动堆叠。新增item mixin分组。
This commit is contained in:
1 parent
b2d09b241c
commit
022b2144d3
5 files changed
+51
-3
No files matched your search
@@ -77,4 +77,7 @@ public class SLSCarpetSettings {
|
|||||||
|
|
||||||
@Rule(categories = {SLSA, RuleCategory.FEATURE})
|
@Rule(categories = {SLSA, RuleCategory.FEATURE})
|
||||||
public static boolean unbreakableDecoratedPot = false;
|
public static boolean unbreakableDecoratedPot = false;
|
||||||
|
|
||||||
|
@Rule(categories = {SLSA, RuleCategory.FEATURE})
|
||||||
|
public static boolean stackableVehicles = false;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.github.zly2006.carpetslsaddition.mixin.item;
|
||||||
|
|
||||||
|
import com.github.zly2006.carpetslsaddition.SLSCarpetSettings;
|
||||||
|
import net.minecraft.world.item.BoatItem;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemInstance;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.MinecartItem;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 载具堆叠:让矿车/船的物品可以堆叠到 64。
|
||||||
|
*
|
||||||
|
* <p>26.1.2 的堆叠上限来自 {@code ItemInstance.getMaxStackSize()} 的 default 实现:
|
||||||
|
* 读取 {@code DataComponents.MAX_STACK_SIZE} 组件,默认 1(故矿车/船默认不堆叠)。
|
||||||
|
*
|
||||||
|
* <p>本 mixin 注入该 default 方法:规则 {@code stackableVehicles} 开启时,
|
||||||
|
* 若物品是矿车({@link MinecartItem})或船({@link BoatItem}),返回 64。
|
||||||
|
* 由于堆叠上限变大,同类载具在拾取/整理时会自动合并,实现"自动堆叠"。
|
||||||
|
*/
|
||||||
|
@Mixin(ItemInstance.class)
|
||||||
|
public interface ItemInstanceMixin {
|
||||||
|
|
||||||
|
@Inject(method = "getMaxStackSize", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void stackableVehicles(CallbackInfoReturnable<Integer> cir) {
|
||||||
|
if (!SLSCarpetSettings.stackableVehicles) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(this instanceof ItemStack stack)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Item item = stack.getItem();
|
||||||
|
if (item instanceof MinecartItem || item instanceof BoatItem) {
|
||||||
|
cir.setReturnValue(64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -72,5 +72,7 @@
|
|||||||
"carpet.slsa.bot.respawned": "The bot %s's online time has been reset.",
|
"carpet.slsa.bot.respawned": "The bot %s's online time has been reset.",
|
||||||
"carpet.slsa.bot.not_a_bot": "The player %s is not created by carpet sls addition, so you can't reset the online time.",
|
"carpet.slsa.bot.not_a_bot": "The player %s is not created by carpet sls addition, so you can't reset the online time.",
|
||||||
|
|
||||||
"carpet.slsa.block.deep_slate_core": "Deepslate Core"
|
"carpet.slsa.block.deep_slate_core": "Deepslate Core",
|
||||||
|
"carpet.rule.stackableVehicles.name": "Stackable vehicles",
|
||||||
|
"carpet.rule.stackableVehicles.desc": "Minecarts and boats can stack up to 64, auto-merging on pickup"
|
||||||
}
|
}
|
||||||
@@ -72,5 +72,7 @@
|
|||||||
"carpet.slsa.bot.respawned": "假人%s的在线时长已重置!",
|
"carpet.slsa.bot.respawned": "假人%s的在线时长已重置!",
|
||||||
"carpet.slsa.bot.not_a_bot": "假人%s不是由Carpet SLS Addition生成的,所以你不能重置它的在线时间!",
|
"carpet.slsa.bot.not_a_bot": "假人%s不是由Carpet SLS Addition生成的,所以你不能重置它的在线时间!",
|
||||||
|
|
||||||
"carpet.slsa.block.deep_slate_core": "深板岩核心"
|
"carpet.slsa.block.deep_slate_core": "深板岩核心",
|
||||||
|
"carpet.rule.stackableVehicles.name": "载具可堆叠",
|
||||||
|
"carpet.rule.stackableVehicles.desc": "矿车和船的物品可以堆叠到64,拾取时自动合并"
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
"block.MixinDecoratedPotBlock",
|
"block.MixinDecoratedPotBlock",
|
||||||
"block.MixinTrialSpawnerData",
|
"block.MixinTrialSpawnerData",
|
||||||
"block.MixinTrialSpawnerState",
|
"block.MixinTrialSpawnerState",
|
||||||
|
"item.ItemInstanceMixin",
|
||||||
"carpet.MixinEntityPlayerMPFake",
|
"carpet.MixinEntityPlayerMPFake",
|
||||||
"carpet.MixinPlayerCommand",
|
"carpet.MixinPlayerCommand",
|
||||||
"elytra.ItemAccessor",
|
"elytra.ItemAccessor",
|
||||||
@@ -42,4 +43,4 @@
|
|||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user