Skip to content

Commit

Permalink
Fix BeltHelperMixin
Browse files Browse the repository at this point in the history
Close #63
  • Loading branch information
MarbleGateKeeper committed Nov 3, 2023
1 parent fde3f2f commit 03b8815
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
package plus.dragons.createcentralkitchen.foundation.mixin.common.create;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.simibubi.create.AllTags;
import com.simibubi.create.content.kinetics.belt.BeltHelper;
import net.minecraft.world.item.ItemStack;
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;

@Mixin(value = BeltHelper.class, remap = false, priority = 900)
public class BeltHelperMixin {

/**
* For improving the usage of tag create:upright_on_belt so items with containers inherits upright behavior from their containers.
*
* @param original If the item is in tag create:upright_on_belt
* @param stack the item
* @return if the item should be upright on belt
* @author LimonBlaze
*/
@ModifyExpressionValue(method = "isItemUpright", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/AllTags$AllItemTags;matches(Lnet/minecraft/world/item/ItemStack;)Z"))
private static boolean cck$isItemUpright(boolean original, ItemStack stack) {
return original || (stack.hasContainerItem() && stack.getContainerItem().is(AllTags.AllItemTags.UPRIGHT_ON_BELT.tag));

@Inject(method = "isItemUpright", at = @At("RETURN"), cancellable = true)
private static void cck$isItemUpright(ItemStack stack, CallbackInfoReturnable<Boolean> cir) {
if(stack.hasContainerItem() && stack.getContainerItem().is(AllTags.AllItemTags.UPRIGHT_ON_BELT.tag)){
cir.setReturnValue(true);
}
}

}

0 comments on commit 03b8815

Please sign in to comment.