Skip to content

Commit

Permalink
new rule StackableShulkerBoxesEnhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal0404 committed Jan 7, 2025
1 parent 36bc792 commit 9e00e3f
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public class CCASettings {
@Restriction(require = @Condition(value = ModIds.MC, versionPredicates = ">=1.21"))
public static boolean ReIntroduceOldVersionWitchLootTable = false;

@Rule(categories = {CCA, MC_TWEAKS})
@Restriction(conflict = @Condition(ModIds.PCA))
public static boolean StackableShulkerBoxesEnhancement = false;

/**
* Creative Tools
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file is part of the Crystal Carpet Addition project, licensed under the
* GNU General Public License v3.0
*
* Copyright (C) 2025 Crystal0404 and contributors
*
* Crystal Carpet Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Crystal Carpet Addition is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Crystal Carpet Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package crystal0404.crystalcarpetaddition.mixins.rule.StackableShulkerBoxesEnhancement;

import carpet.CarpetSettings;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import crystal0404.crystalcarpetaddition.CCASettings;
import crystal0404.crystalcarpetaddition.utils.ModIds;
import crystal0404.crystalcarpetaddition.utils.shulkerBoxUtils.ShulkerBoxsSet;
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import net.minecraft.block.entity.HopperBlockEntity;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Restriction(conflict = @Condition(ModIds.PCA))
@Mixin(HopperBlockEntity.class)
public abstract class HopperBlockEntityMixin {
@WrapOperation(
method = "transfer(Lnet/minecraft/inventory/Inventory;Lnet/minecraft/inventory/Inventory;" +
"Lnet/minecraft/item/ItemStack;ILnet/minecraft/util/math/Direction;)Lnet/minecraft/item/ItemStack;",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/entity/HopperBlockEntity;" +
"canMergeItems(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z"
)
)
private static boolean transferMixin(ItemStack first, ItemStack second, Operation<Boolean> original) {
if (
CCASettings.StackableShulkerBoxesEnhancement
&& CarpetSettings.shulkerBoxStackSize != 1
&& ShulkerBoxsSet.ITEMS_SET.contains(first.getItem())
) {
return false;
} else {
return original.call(first, second);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ public final class ModIds {

// https://github.com/LlamaLad7/MixinExtras
public static final String ME = "mixinextras";

// https://github.com/plusls/plusls-carpet-addition
public static final String PCA = "pca";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* This file is part of the Crystal Carpet Addition project, licensed under the
* GNU General Public License v3.0
*
* Copyright (C) 2025 Crystal0404 and contributors
*
* Crystal Carpet Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Crystal Carpet Addition is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Crystal Carpet Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package crystal0404.crystalcarpetaddition.utils.shulkerBoxUtils;

import com.google.common.collect.ImmutableSet;
import net.minecraft.item.Item;
import net.minecraft.item.Items;

public final class ShulkerBoxsSet {
public static final ImmutableSet<Item> ITEMS_SET = ImmutableSet.of(
Items.SHULKER_BOX,
Items.WHITE_SHULKER_BOX,
Items.ORANGE_SHULKER_BOX,
Items.MAGENTA_SHULKER_BOX,
Items.LIGHT_BLUE_SHULKER_BOX,
Items.YELLOW_SHULKER_BOX ,
Items.LIME_SHULKER_BOX,
Items.PINK_SHULKER_BOX,
Items.GRAY_SHULKER_BOX,
Items.LIGHT_GRAY_SHULKER_BOX,
Items.CYAN_SHULKER_BOX,
Items.PURPLE_SHULKER_BOX,
Items.BLUE_SHULKER_BOX,
Items.BROWN_SHULKER_BOX,
Items.GREEN_SHULKER_BOX,
Items.RED_SHULKER_BOX,
Items.BLACK_SHULKER_BOX
);
}
5 changes: 5 additions & 0 deletions src/main/resources/assets/cca/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ cca:
desc: Restored loot dropped after a witch's death to be the same as before Minecraft-1.21
extra.0: It is recommended to use it in conjunction with the "ReIntroduceOldVersionRaid"

StackableShulkerBoxesEnhancement:
name: StackableShulkerBoxesEnhancement
desc: ShulkerBoxes sucked or filled by hoppers do not stack
extra.0: This rule takes effect only after the "stackableShulkerBoxes" rule of Carpet is enabled

# ===Creative Tools===

ShulkerBoxPowerOutputExpansion:
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/assets/cca/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ cca:
"0": 建议与"重新引入旧版袭击"一起使用
"1": 它会覆盖相关数据包的修改, 如果你需要使用自定义数据包修改女巫战利品表, 请关闭此规则

StackableShulkerBoxesEnhancement:
name: 可堆叠潜影盒增强
desc: 由漏斗吸取或填入的潜影盒不会堆叠
extra.0: 在开启Carpet的"stackableShulkerBoxes"规则后此规则才会生效

# ===Creative Tools===

ShulkerBoxPowerOutputExpansion:
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/cca.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"rule.ReIntroduceOldVersionRaid.RaiderEntityMixin",
"rule.ReIntroduceOldVersionRaid.RaidMixin",
"rule.ReIntroduceOldVersionWitchLootTable.LivingEntityMixin",
"rule.ShulkerBoxPowerOutputExpansion.ShulkerBoxBlockMixin"
"rule.ShulkerBoxPowerOutputExpansion.ShulkerBoxBlockMixin",
"rule.StackableShulkerBoxesEnhancement.HopperBlockEntityMixin"
],
"client": [
"rule.WhatIsThis.Happy"
Expand Down

0 comments on commit 9e00e3f

Please sign in to comment.