-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows adjustment of the max stack size of IC2 seeds from the ic2 def…
…ault of 1, to hodgepodge's default of 64. (#33)
- Loading branch information
1 parent
bbfb7fa
commit 2f5bb1e
Showing
4 changed files
with
23 additions
and
24 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
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
36 changes: 15 additions & 21 deletions
36
.../com/mitchej123/hodgepodge/mixins/fixic2directinventoryaccess/item/MixinItemCropSeed.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 |
---|---|---|
@@ -1,39 +1,33 @@ | ||
package com.mitchej123.hodgepodge.mixins.fixic2directinventoryaccess.item; | ||
|
||
import com.mitchej123.hodgepodge.core.HodgepodgeMixinPlugin; | ||
import ic2.core.init.InternalName; | ||
import ic2.core.item.ItemCropSeed; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.world.World; | ||
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.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(value = ItemCropSeed.class) | ||
public class MixinItemCropSeed { | ||
public class MixinItemCropSeed extends Item { | ||
@Inject(method = "onItemUse", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/EntityPlayer;inventory:Lnet/minecraft/entity/player/InventoryPlayer;"), cancellable = true) | ||
public void onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float a, float b, float c, CallbackInfoReturnable<Boolean> ci) { | ||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); | ||
ItemStack currentItem = entityplayer.inventory.getCurrentItem(); | ||
currentItem.stackSize -= 1; | ||
ci.setReturnValue(true); | ||
ci.cancel(); | ||
} | ||
@Inject(at=@At("RETURN"), method="<init>(Lic2/core/init/InternalName;)V", remap = false) | ||
public void AdjustMaxStackSize(InternalName internalName, CallbackInfo ci) { | ||
final int maxStackSize = HodgepodgeMixinPlugin.config.ic2SeedMaxStackSize; | ||
if(maxStackSize != 1) { | ||
HodgepodgeMixinPlugin.log.info("Setting IC2 seed max stack size to " + maxStackSize); | ||
setMaxStackSize(maxStackSize); | ||
} | ||
} | ||
} | ||
|
||
|
||
// Alternative that doesn't use the remapping | ||
|
||
//@Mixin(value = { ItemCropSeed.class}, remap = false) | ||
//public class MixinItemCropSeed { | ||
// @Inject(method = | ||
// "Lic2/core/item/ItemCropSeed;func_77648_a(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;IIIIFFF)Z" | ||
// , at = @At(value = "FIELD", | ||
// target = "Lnet/minecraft/entity/player/EntityPlayer;field_71071_by:Lnet/minecraft/entity/player/InventoryPlayer;" | ||
// ), cancellable=true | ||
// ) | ||
// public void onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float a, float b, float c, CallbackInfoReturnable<Boolean> ci) { | ||
// System.out.println("Naughty naughty seedbag"); | ||
// entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); | ||
// ci.setReturnValue(true); | ||
// ci.cancel(); | ||
// } | ||
//} |