-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
266e669
commit 6f6ecd5
Showing
8 changed files
with
148 additions
and
3 deletions.
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
19 changes: 19 additions & 0 deletions
19
src/main/java/io/github/Andrew6rant/stacker/mixin/AnvilScreenHandlerMixin.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,19 @@ | ||
package io.github.Andrew6rant.stacker.mixin; | ||
|
||
import net.minecraft.inventory.Inventory; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.screen.AnvilScreenHandler; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(AnvilScreenHandler.class) | ||
public class AnvilScreenHandlerMixin { | ||
// Credit to ZoeyTheEgoist for this mixin | ||
@Redirect(method = "onTakeOutput", at = @At(value = "INVOKE", target = "Lnet/minecraft/inventory/Inventory;setStack(ILnet/minecraft/item/ItemStack;)V", ordinal = 3)) | ||
private void setDecrementSlot1StackCount(Inventory inventory, int slot, ItemStack stack) { | ||
ItemStack newStack = inventory.getStack(1); | ||
newStack.decrement(1); | ||
inventory.setStack(1, newStack); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/io/github/Andrew6rant/stacker/mixin/DispenserBehaviorMixin.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,46 @@ | ||
package io.github.Andrew6rant.stacker.mixin; | ||
|
||
import net.minecraft.block.DispenserBlock; | ||
import net.minecraft.block.dispenser.ItemDispenserBehavior; | ||
import net.minecraft.block.entity.DispenserBlockEntity; | ||
import net.minecraft.item.FluidModificationItem; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.util.math.BlockPointer; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(targets = "net/minecraft/block/dispenser/DispenserBehavior$8") | ||
public class DispenserBehaviorMixin { | ||
// Credit to ZoeyTheEgoist for this mixin | ||
/** | ||
* @author Astrazoey | ||
*/ | ||
@Overwrite | ||
public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) { | ||
ItemDispenserBehavior fallbackBehavior = new ItemDispenserBehavior(); | ||
ItemStack emptyBucketStack = new ItemStack(Items.BUCKET); | ||
FluidModificationItem fluidModificationItem = (FluidModificationItem) stack.getItem(); | ||
BlockPos blockPos = pointer.getPos().offset(pointer.getBlockState().get(DispenserBlock.FACING)); | ||
World world = pointer.getWorld(); | ||
|
||
if (fluidModificationItem.placeFluid( null, world, blockPos, null)) { | ||
fluidModificationItem.onEmptied( null, world, stack, blockPos); | ||
if (stack.getCount() > 1) { | ||
ItemStack newStack = stack.copy(); | ||
newStack.decrement(1); | ||
if (((DispenserBlockEntity)pointer.getBlockEntity()).addToFirstFreeSlot(emptyBucketStack.copy()) < 0) { | ||
fallbackBehavior.dispense(pointer, emptyBucketStack.copy()); | ||
} | ||
return newStack; | ||
} else { | ||
return new ItemStack(Items.BUCKET); | ||
} | ||
} else { | ||
return fallbackBehavior.dispense(pointer, stack); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/io/github/Andrew6rant/stacker/mixin/HorseScreenHandlerMixin.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,18 @@ | ||
package io.github.Andrew6rant.stacker.mixin; | ||
|
||
import io.github.Andrew6rant.stacker.util.HorseScreenInterface; | ||
import net.minecraft.inventory.Inventory; | ||
import net.minecraft.screen.slot.Slot; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(targets = "net/minecraft/screen/HorseScreenHandler$1") | ||
public class HorseScreenHandlerMixin extends Slot implements HorseScreenInterface { | ||
// Credit to ZoeyTheEgoist for this mixin | ||
public HorseScreenHandlerMixin(Inventory inventory, int index, int x, int y) { | ||
super(inventory, index, x, y); | ||
} | ||
@Override | ||
public int getMaxItemCount() { | ||
return 1; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/io/github/Andrew6rant/stacker/mixin/InmisFixMixin.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,30 @@ | ||
package io.github.Andrew6rant.stacker.mixin; | ||
|
||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.TypedActionResult; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Pseudo | ||
@Mixin(targets = "draylar.inmis.item.BackpackItem") | ||
public class InmisFixMixin { | ||
/* | ||
@Inject(method = "use", at = @At("RETURN"), cancellable = true) | ||
public void useOverride(CallbackInfoReturnable<TypedActionResult<net.minecraft.item.ItemStack>> cir, World world, PlayerEntity user, Hand hand) { | ||
if (user.getStackInHand(hand).getCount() > 1) { | ||
cir.setReturnValue(TypedActionResult.fail(user.getStackInHand(hand))); | ||
} | ||
cir.setReturnValue(cir.getReturnValue()); | ||
//cir.setReturnValue(TypedActionResult.success(user.getStackInHand(hand))); | ||
} | ||
*/ | ||
@Inject(method = "openScreen", at = @At("RETURN"), cancellable = true) | ||
private static void openScreenOverride(CallbackInfoReturnable cir){ | ||
cir.setReturnValue(null); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/io/github/Andrew6rant/stacker/mixin/JukeboxBlockMixin.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,19 @@ | ||
package io.github.Andrew6rant.stacker.mixin; | ||
|
||
import net.minecraft.block.JukeboxBlock; | ||
import net.minecraft.block.entity.JukeboxBlockEntity; | ||
import net.minecraft.item.ItemStack; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(JukeboxBlock.class) | ||
public class JukeboxBlockMixin { | ||
// Credit to ZoeyTheEgoist for this mixin | ||
@Redirect(method = "setRecord", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/JukeboxBlockEntity;setRecord(Lnet/minecraft/item/ItemStack;)V")) | ||
public void setCountToOne(JukeboxBlockEntity jukeboxBlockEntity, ItemStack stack) { | ||
ItemStack newStack = stack.copy(); | ||
newStack.setCount(1); | ||
jukeboxBlockEntity.setRecord(newStack); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/io/github/Andrew6rant/stacker/util/HorseScreenInterface.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,6 @@ | ||
package io.github.Andrew6rant.stacker.util; | ||
|
||
public interface HorseScreenInterface { | ||
// Credit to ZoeyTheEgoist for this interface | ||
public int getMaxItemCount(); | ||
} |
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