Move some base classes into the API

Add Javadocs for API classes that didn't already have them

Redo

'nother redo

Another redo

Update ItemSigil.java

Last one, I swear

Fix
This commit is contained in:
Arcaratus 2016-03-22 21:10:05 -04:00
parent 6a40dbab0a
commit 0383f0fb31
41 changed files with 331 additions and 343 deletions

View file

@ -1,5 +1,9 @@
package WayofTime.bloodmagic.api.altar;
/**
* List of different components used to construct
* different tiers of altars.
*/
public enum EnumAltarComponent
{
GLOWSTONE,

View file

@ -14,10 +14,16 @@ public class BoundToolEvent extends Event
this.player = player;
}
/**
* This event is called when a {@link WayofTime.bloodmagic.item.ItemBoundTool}
* is being charged.
*
* If canceled, will result in the charging being canceled.
*/
@Cancelable
public static class Charge extends BoundToolEvent
{
public ItemStack result;
public Charge(EntityPlayer player, ItemStack result)
@ -27,10 +33,16 @@ public class BoundToolEvent extends Event
}
}
/**
* This event is called when a {@link WayofTime.bloodmagic.item.ItemBoundTool}'s
* charge is released.
*
* If canceled, will result in the charge not being released.
*/
@Cancelable
public static class Release extends BoundToolEvent
{
public final ItemStack boundTool;
public int charge;

View file

@ -12,6 +12,18 @@ public class ItemBindEvent extends Event
public String key;
public ItemStack itemStack;
/**
* This event is called whenever a player attempts to bind a {@link WayofTime.bloodmagic.api.iface.IBindable} item.
*
* @param player
* The player doing the binding
* @param key
* The UUID of the player doing the binding
* @param itemStack
* The {@link ItemStack} that the player is binding
*
* This event is {@link Cancelable}.<br>
*/
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack)
{
super();

View file

@ -55,7 +55,6 @@ public class RitualEvent extends Event
@Cancelable
public static class RitualRunEvent extends RitualEvent
{
public RitualRunEvent(IMasterRitualStone mrs, String owner, Ritual ritual)
{
super(mrs, owner, ritual);

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.api.event;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
@ -13,6 +14,23 @@ public class SacrificeKnifeUsedEvent extends Event
public boolean shouldDrainHealth;
public boolean shouldFillAltar;
/**
* This event is called whenever a player attempts to use a {@link WayofTime.bloodmagic.item.ItemSacrificialDagger}
* to self-sacrifice near an altar.
*
* @param player
* The player doing the sacrificing
* @param shouldDrainHealth
* Determines whether or not health is lost
* @param shouldFillAltar
* Determines whether or not an altar should be filled
* @param hp
* Amount of health lost
* @param lpAdded
* Amount of LP added to the altar
*
* This event is {@link Cancelable}.<br>
*/
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp, int lpAdded)
{
this.player = player;

View file

@ -5,21 +5,32 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* Base event class for Soul Network related events.
*
* {@link #ownerUUID} contains the owner's UUID
* {@link #syphon} contains the amount of LP to be drained
*/
public class SoulNetworkEvent extends Event
{
public final String ownerName;
public final String ownerUUID;
public int syphon;
public SoulNetworkEvent(String ownerName, int syphon)
public SoulNetworkEvent(String ownerUUID, int syphon)
{
this.ownerName = ownerName;
this.ownerUUID = ownerUUID;
this.syphon = syphon;
}
/**
* This event is called when an {@link WayofTime.bloodmagic.api.impl.ItemBindable}
* is being drained inside of a {@link net.minecraft.tileentity.TileEntity}.
*
* If canceled, the drain will not be executed.
*/
@Cancelable
public static class ItemDrainInContainerEvent extends SoulNetworkEvent
{
public ItemStack stack;
public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon)
@ -29,10 +40,15 @@ public class SoulNetworkEvent extends Event
}
}
/**
* This event is called when a {@link EntityPlayer}
* drains the Soul Network
*
* If canceled, the drain will not be executed.
*/
@Cancelable
public static class PlayerDrainNetworkEvent extends SoulNetworkEvent
{
public final EntityPlayer player;
// If true, will damage regardless of if the network had enough inside it
public boolean shouldDamage;
@ -48,7 +64,6 @@ public class SoulNetworkEvent extends Event
@Cancelable
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent
{
public final ItemStack itemStack;
/**
* Amount of damage that would incur if the network could not drain

View file

@ -1,5 +1,9 @@
package WayofTime.bloodmagic.api.iface;
/**
* Any item that implements this interface will not be pulled into the Altar on
* right click.
*/
public interface IAltarReader
{

View file

@ -1,5 +1,9 @@
package WayofTime.bloodmagic.api.iface;
/**
* Used for all {@link WayofTime.bloodmagic.api.impl.ItemSigil}
* <b>EXCEPT</b> Sigils of Holdings.
*/
public interface ISigil
{
}

View file

@ -0,0 +1,41 @@
package WayofTime.bloodmagic.api.impl;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
/**
* Base class for all bindable items.
*/
public class ItemBindable extends Item implements IBindable
{
public ItemBindable()
{
super();
setMaxStackSize(1);
}
// IBindable
@Override
public boolean onBind(EntityPlayer player, ItemStack stack)
{
return true;
}
@Override
public String getOwnerName(ItemStack stack)
{
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
}
@Override
public String getOwnerUUID(ItemStack stack)
{
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
}
}

View file

@ -0,0 +1,38 @@
package WayofTime.bloodmagic.api.impl;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import lombok.Getter;
import net.minecraft.item.ItemStack;
/**
* Base class for all (static) sigils.
*/
public class ItemSigil extends ItemBindable implements ISigil
{
@Getter
private int lpUsed;
public ItemSigil(int lpUsed)
{
super();
this.lpUsed = lpUsed;
}
public boolean isUnusable(ItemStack stack)
{
NBTHelper.checkNBT(stack);
return stack.getTagCompound().getBoolean(Constants.NBT.UNUSABLE);
}
public ItemStack setUnusable(ItemStack stack, boolean unusable)
{
NBTHelper.checkNBT(stack);
stack.getTagCompound().setBoolean(Constants.NBT.UNUSABLE, unusable);
return stack;
}
}

View file

@ -0,0 +1,92 @@
package WayofTime.bloodmagic.api.impl;
import WayofTime.bloodmagic.api.iface.IActivatable;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
* Base class for all toggleable sigils.
*/
public class ItemSigilToggleable extends ItemSigil implements IActivatable
{
private boolean toggleable;
public ItemSigilToggleable(int lpUsed)
{
super(lpUsed);
setToggleable();
}
public void setToggleable()
{
this.toggleable = true;
}
public boolean getActivated(ItemStack stack)
{
return stack.getItemDamage() > 0;
}
public ItemStack setActivatedState(ItemStack stack, boolean activated)
{
if (this.toggleable)
stack.setItemDamage(activated ? 1 : 0);
return stack;
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
if (!world.isRemote && !isUnusable(stack))
{
if (player.isSneaking())
setActivatedState(stack, !getActivated(stack));
if (getActivated(stack) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
return super.onItemRightClick(stack, world, player, hand);
}
return super.onItemRightClick(stack, world, player, hand);
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
return (NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()) && onSigilUse(stack, player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}
public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
{
return false;
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
{
if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack))
{
if (worldIn.getWorldTime() % 100 == 0)
{
if (!NetworkHelper.getSoulNetwork((EntityPlayerMP) entityIn).syphonAndDamage((EntityPlayer) entityIn, getLpUsed()))
{
setActivatedState(stack, false);
}
}
onSigilUpdate(stack, worldIn, (EntityPlayer) entityIn, itemSlot, isSelected);
}
}
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
{
}
}

View file

@ -10,7 +10,6 @@ import WayofTime.bloodmagic.api.registry.OrbRegistry;
import com.google.common.base.Strings;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
@ -223,7 +222,7 @@ public class NetworkHelper
if (MinecraftForge.EVENT_BUS.post(event))
return false;
int drainAmount = syphonFromNetwork(event.ownerName, event.syphon);
int drainAmount = syphonFromNetwork(event.ownerUUID, event.syphon);
if (drainAmount == 0 || event.shouldDamage)
hurtPlayer(player, event.syphon);
@ -254,7 +253,7 @@ public class NetworkHelper
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
return false;
return syphonFromNetwork(event.ownerName, event.syphon) >= syphon;
return syphonFromNetwork(event.ownerUUID, event.syphon) >= syphon;
}
@Deprecated