-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMixinBucketItem.java
More file actions
25 lines (21 loc) · 1.01 KB
/
MixinBucketItem.java
File metadata and controls
25 lines (21 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package online.connlost.allstackable.mixin;
import online.connlost.allstackable.util.ItemsHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BucketItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
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(BucketItem.class)
public class MixinBucketItem {
@Inject(method = "getEmptiedStack", at = @At(value = "HEAD"), cancellable = true)
private static void stackableBucket(ItemStack stack, PlayerEntity player, CallbackInfoReturnable<ItemStack> cir){
if (ItemsHelper.isModified(stack) && stack.getCount() > 1 && !player.getAbilities().creativeMode){
ItemsHelper.insertNewItem(player, new ItemStack(Items.BUCKET));
stack.decrement(1);
cir.setReturnValue(stack);
}
}
}