Changes to Item Binding
Allows event to cancel the binding (rather than set key to "" which had the same effect but was messy) Prevents binding by Fake Players
This commit is contained in:
parent
aa33b6b8ff
commit
976599afe0
50 changed files with 152 additions and 268 deletions
|
@ -1,9 +1,11 @@
|
|||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class ItemBindEvent extends Event
|
||||
{
|
||||
public final EntityPlayer player;
|
||||
|
|
|
@ -379,22 +379,22 @@ public class SoulNetworkHandler
|
|||
}
|
||||
}
|
||||
|
||||
public static void checkAndSetItemOwner(ItemStack item, EntityPlayer player)
|
||||
public static boolean checkAndSetItemOwner(ItemStack item, EntityPlayer player)
|
||||
{
|
||||
if (item.getTagCompound() == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
if (item.hasTagCompound() && !item.getTagCompound().getString("ownerName").equals("")) return true;
|
||||
|
||||
if (item.getTagCompound().getString("ownerName").equals(""))
|
||||
ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item);
|
||||
|
||||
if(!MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item);
|
||||
|
||||
if(!MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
item.getTagCompound().setString("ownerName", event.key);
|
||||
}
|
||||
if (!item.hasTagCompound())
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
item.getTagCompound().setString("ownerName", event.key);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void checkAndSetItemOwner(ItemStack item, String ownerName)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue