-
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.
Revert "move Itemizer out of mixins" since event version doesn't work…
… for unknown reasons
- Loading branch information
1 parent
2d3dac4
commit 842d726
Showing
3 changed files
with
31 additions
and
30 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
30 changes: 30 additions & 0 deletions
30
src/main/java/ru/glassspirit/cnpcntrpg/mixin/MixinDataInventory.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 ru.glassspirit.cnpcntrpg.mixin; | ||
|
||
import net.minecraft.entity.item.EntityItem; | ||
import net.minecraft.item.ItemStack; | ||
import noppes.npcs.entity.data.DataInventory; | ||
import org.spongepowered.api.Sponge; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import ru.glassspirit.cnpcntrpg.sponge.ItemizerHelper; | ||
|
||
@Mixin(value = DataInventory.class, remap = false) | ||
public abstract class MixinDataInventory { | ||
|
||
@Redirect(method = "dropStuff", at = @At(value = "INVOKE", target = "Lnoppes/npcs/entity/data/DataInventory;getEntityItem(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/entity/item/EntityItem;")) | ||
private EntityItem onDropStuffItemizer(DataInventory data, ItemStack stack) { | ||
if (Sponge.getPluginManager().isLoaded("itemizer")) { | ||
if (stack.getDisplayName().startsWith("#IT")) { | ||
String[] str = stack.getDisplayName().split("#"); | ||
if (str[2].equalsIgnoreCase("id")) { | ||
return data.getEntityItem((ItemStack) (Object) ItemizerHelper.getItemService().retrieve(str[3]).orElse(org.spongepowered.api.item.inventory.ItemStack.empty())); | ||
} else if (str[2].equalsIgnoreCase("pool")) { | ||
return data.getEntityItem((ItemStack) (Object) ItemizerHelper.getItemService().fetch(str[3]).orElse(org.spongepowered.api.item.inventory.ItemStack.empty())); | ||
} | ||
} | ||
} | ||
return data.getEntityItem(stack); | ||
} | ||
|
||
} |
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