- 构建:Loom 1.18-SNAPSHOT、Gradle 9.7.1、official 映射 & - 依赖:carpet 26.1+v260401、fabric-api 0.155.3+26.1.2、fabric-permissions-api 0.7.0 & - 源码:~30 文件 + 28 mixin 从 Yarn 迁移到 Mojang official 映射 & - accessWidener 改为 official 命名空间 & - 适配新 API:Component/ChatFormatting/CommandSourceStack/Commands/ResourceKey/ & ServerLevel/ServerPlayer/Abilities/CraftingRemainingItem/PermissionSet/ValueInput-Output 等 & - 部分功能(elytraCraftable/datapack 注入/offlineFakePlayers)按新 API 近似重写,待实机验证
This commit is contained in:
1 parent
a1a2103f47
commit
8e44aaa780
36 files changed
+521
-576
No files matched your search
@@ -1,11 +1,10 @@
|
||||
package com.github.zly2006.carpetslsaddition.util;
|
||||
|
||||
import net.minecraft.block.ShulkerBoxBlock;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Objects;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.component.ItemContainerContents;
|
||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||
|
||||
public class ShulkerBoxItemUtil {
|
||||
public static final int SHULKERBOX_MAX_STACK_AMOUNT = 64;
|
||||
@@ -15,25 +14,17 @@ public class ShulkerBoxItemUtil {
|
||||
if (stack.isEmpty() && otherStack.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return Objects.equals(
|
||||
stack.getComponents().filtered(s -> s != DataComponentTypes.CONTAINER),
|
||||
stack.getComponents().filtered(s -> s != DataComponentTypes.CONTAINER)
|
||||
);
|
||||
return stack.getComponents().equals(otherStack.getComponents());
|
||||
}
|
||||
return ItemStack.areItemsAndComponentsEqual(stack, otherStack);
|
||||
return ItemStack.isSameItemSameComponents(stack, otherStack);
|
||||
}
|
||||
|
||||
public static boolean isEmptyShulkerBoxItem(ItemStack itemStack) {
|
||||
if (itemStack.getItem() instanceof BlockItem &&
|
||||
((BlockItem) itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock) {
|
||||
if (itemStack.getComponents().contains(DataComponentTypes.CONTAINER)) {
|
||||
return !itemStack.getComponents().get(DataComponentTypes.CONTAINER).iterateNonEmpty().iterator().hasNext();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
if (itemStack.getItem() instanceof BlockItem blockItem
|
||||
&& blockItem.getBlock() instanceof ShulkerBoxBlock) {
|
||||
return itemStack.getOrDefault(DataComponents.CONTAINER, ItemContainerContents.EMPTY)
|
||||
.allItemsCopyStream().findAny().isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user