-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new rule
StackableShulkerBoxesEnhancement
- Loading branch information
1 parent
36bc792
commit 9e00e3f
Showing
7 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...alcarpetaddition/mixins/rule/StackableShulkerBoxesEnhancement/HopperBlockEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/crystal0404/crystalcarpetaddition/utils/shulkerBoxUtils/ShulkerBoxsSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters