More work on the implementation of events

This commit is contained in:
WayofTime 2014-11-07 13:45:02 -05:00
parent dd3a093825
commit 39b4243a82
27 changed files with 217 additions and 259 deletions

View file

@ -0,0 +1,20 @@
package WayofTime.alchemicalWizardry.api.event;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.eventhandler.Event;
public class ItemBindEvent extends Event
{
public final EntityPlayer player;
public String key;
public ItemStack itemStack;
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack)
{
super();
this.player = player;
this.key = key;
this.itemStack = itemStack;
}
}

View file

@ -1,6 +1,8 @@
package WayofTime.alchemicalWizardry.api.rituals;
import net.minecraft.world.World;
public interface IRitualStone
{
public int getRuneType(World world, int x, int y, int z, int meta);
}

View file

@ -35,6 +35,16 @@ public class RitualComponent
{
return this.z;
}
public int getX(int direction)
{
return this.x;
}
public int getZ(int direction)
{
return this.z;
}
public int getStoneType()
{

View file

@ -158,7 +158,7 @@ public class Rituals
return false;
}
if (world.getBlockMetadata(x + rc.getX(), y + rc.getY(), z + rc.getZ()) != rc.getStoneType())
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x + rc.getX(), y + rc.getY(), z + rc.getZ())) != rc.getStoneType())
{
return false;
}
@ -176,7 +176,7 @@ public class Rituals
return false;
}
if (world.getBlockMetadata(x - rc.getZ(), y + rc.getY(), z + rc.getX()) != rc.getStoneType())
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x - rc.getZ(), y + rc.getY(), z + rc.getX())) != rc.getStoneType())
{
return false;
}
@ -194,7 +194,7 @@ public class Rituals
return false;
}
if (world.getBlockMetadata(x - rc.getX(), y + rc.getY(), z - rc.getZ()) != rc.getStoneType())
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x - rc.getX(), y + rc.getY(), z - rc.getZ())) != rc.getStoneType())
{
return false;
}
@ -212,7 +212,7 @@ public class Rituals
return false;
}
if (world.getBlockMetadata(x + rc.getZ(), y + rc.getY(), z - rc.getX()) != rc.getStoneType())
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x + rc.getZ(), y + rc.getY(), z - rc.getX())) != rc.getStoneType())
{
return false;
}

View file

@ -11,6 +11,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import WayofTime.alchemicalWizardry.api.event.ItemBindEvent;
import WayofTime.alchemicalWizardry.api.event.ItemDrainNetworkEvent;
import com.mojang.authlib.GameProfile;
@ -286,7 +287,12 @@ public class SoulNetworkHandler
if (item.stackTagCompound.getString("ownerName").equals(""))
{
item.stackTagCompound.setString("ownerName", SoulNetworkHandler.getUsername(player));
ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item);
if(!MinecraftForge.EVENT_BUS.post(event))
{
item.stackTagCompound.setString("ownerName", event.key);
}
}
}