Added check for keepInventory to Soulbound

This commit is contained in:
CrazyPants committed 2014-11-26 18:45:29 +08:00
1 parent 3b11ccc1e0
commit 664d382ada
3 files changed
+16 -4

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ Changes
whitelisted by default. See PainterPaintSources_Core.xml for details.
- Added Thaumcraft Warded blocks to the default teleport black list
- Added support for a large number of new IMC messages. Details in crazypants.enderio.api.IMC
- #1098 Added Soul Bound enchantment. Items with this enchantment will not be dropped when the player dies
- #1098 Added Soulbound enchantment. Items with this enchantment will not be dropped when the player dies
Bugs
- Fix outer corners on connected texture blocks not being metadata sensitive when they should be
+1 -1
View File
@@ -786,7 +786,7 @@ enderio.gui.conduit.fluid.filter=Filter
enderio.gui.conduit.gas.autoExtract=Auto Extract
//Enchants
enchantment.enderio.soulBound=Soul Bound
enchantment.enderio.soulBound=Soulbound
//Configuration
enderio.config.title=Ender IO Configuration
@@ -12,8 +12,10 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import crazypants.enderio.config.Config;
@@ -48,8 +50,15 @@ public class EnchantmentSoulBound extends Enchantment {
return 1;
}
@SubscribeEvent
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerDeath(PlayerDropsEvent evt) {
if(evt.entityPlayer == null || evt.entityPlayer instanceof FakePlayer) {
return;
}
if(evt.entityPlayer.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
return;
}
ListIterator<EntityItem> iter = evt.drops.listIterator();
while (iter.hasNext()) {
EntityItem ei = iter.next();
@@ -67,7 +76,10 @@ public class EnchantmentSoulBound extends Enchantment {
if(!evt.wasDeath) {
return;
}
if(evt.original == null || evt.entityPlayer == null) {
if(evt.original == null || evt.entityPlayer == null || evt.entityPlayer instanceof FakePlayer) {
return;
}
if(evt.entityPlayer.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
return;
}
for (int i = 0; i < evt.original.inventory.mainInventory.length; i++) {