mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-26 15:03:07 +00:00
Added Soulbound support for Baubles
* Includes Baubles API 1.0.1.10 (will not be included in ender io jar)
This commit is contained in:
1 parent
9bbc87db50
commit
31c1c41c1b
6 files changed
+149
No files matched your search
@@ -10,6 +10,7 @@ import net.minecraft.enchantment.EnumEnchantmentType;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -20,6 +21,7 @@ import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.tool.BaublesTool;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
@Interface(iface = "tterrag.core.api.common.enchant.IAdvancedEnchant", modid = "ttCore")
|
||||
@@ -73,6 +75,21 @@ public class EnchantmentSoulBound extends Enchantment implements IAdvancedEnchan
|
||||
}
|
||||
}
|
||||
|
||||
// Note: Baubles will also add its items to evt.drops, but later. We cannot
|
||||
// wait for that because gravestone mods also listen to this event. So we have
|
||||
// to fetch Baubles items ourselves here.
|
||||
// For the same reason we cannot put the items into Baubles slots.
|
||||
IInventory baubles = BaublesTool.getInstance().getBaubles(evt.entityPlayer);
|
||||
if (baubles != null) {
|
||||
for (int i = 0; i < baubles.getSizeInventory(); i++) {
|
||||
ItemStack item = baubles.getStackInSlot(i);
|
||||
if(isSoulBound(item)) {
|
||||
addToPlayerInventory(evt.entityPlayer, item);
|
||||
baubles.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
|
||||
public class BaublesTool {
|
||||
|
||||
private static final BaublesTool instance = new withBaubles();
|
||||
|
||||
public static BaublesTool getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean hasBaubles() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IInventory getBaubles(EntityPlayer player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class withBaubles extends BaublesTool {
|
||||
@Method(modid = "Baubles")
|
||||
public boolean hasBaubles() {
|
||||
return true;
|
||||
}
|
||||
@Method(modid = "Baubles")
|
||||
public IInventory getBaubles(EntityPlayer player) {
|
||||
return baubles.api.BaublesApi.getBaubles(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user