2018-02-05 17:04:38 -08:00
|
|
|
package WayofTime.bloodmagic.apibutnotreally.event;
|
2014-11-06 21:25:53 -05:00
|
|
|
|
2015-10-29 20:22:14 -07:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
2015-07-29 08:23:01 -04:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
|
|
|
|
2016-06-12 13:41:02 -07:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2016-03-22 21:10:05 -04:00
|
|
|
/**
|
|
|
|
* Base event class for Soul Network related events.
|
2017-08-15 21:30:48 -07:00
|
|
|
* <p>
|
2016-04-05 16:16:17 -04:00
|
|
|
* {@link #ownerUUID} contains the owner's UUID {@link #syphon} contains the
|
|
|
|
* amount of LP to be drained
|
2016-03-22 21:10:05 -04:00
|
|
|
*/
|
2017-08-15 21:30:48 -07:00
|
|
|
public class SoulNetworkEvent extends Event {
|
2016-03-22 21:10:05 -04:00
|
|
|
public final String ownerUUID;
|
2015-10-29 20:22:14 -07:00
|
|
|
public int syphon;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public SoulNetworkEvent(String ownerUUID, int syphon) {
|
2016-03-22 21:10:05 -04:00
|
|
|
this.ownerUUID = ownerUUID;
|
2015-10-29 20:22:14 -07:00
|
|
|
this.syphon = syphon;
|
|
|
|
}
|
|
|
|
|
2016-03-22 21:10:05 -04:00
|
|
|
/**
|
2016-04-05 16:16:17 -04:00
|
|
|
* This event is called when an
|
2018-02-05 17:04:38 -08:00
|
|
|
* {@link WayofTime.bloodmagic.apibutnotreally.impl.ItemBindable} is being drained
|
2016-04-05 16:16:17 -04:00
|
|
|
* inside of a {@link net.minecraft.tileentity.TileEntity}.
|
2017-08-15 21:30:48 -07:00
|
|
|
* <p>
|
2016-03-22 21:10:05 -04:00
|
|
|
* If canceled, the drain will not be executed.
|
|
|
|
*/
|
2015-10-29 20:22:14 -07:00
|
|
|
@Cancelable
|
2017-08-15 21:30:48 -07:00
|
|
|
public static class ItemDrainInContainerEvent extends SoulNetworkEvent {
|
2015-10-29 20:22:14 -07:00
|
|
|
public ItemStack stack;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public ItemDrainInContainerEvent(ItemStack stack, String ownerName, int syphon) {
|
2015-10-29 20:22:14 -07:00
|
|
|
super(ownerName, syphon);
|
|
|
|
this.stack = stack;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-22 21:10:05 -04:00
|
|
|
/**
|
2016-04-05 16:16:17 -04:00
|
|
|
* This event is called when a {@link EntityPlayer} drains the Soul Network
|
2017-08-15 21:30:48 -07:00
|
|
|
* <p>
|
2016-03-22 21:10:05 -04:00
|
|
|
* If canceled, the drain will not be executed.
|
|
|
|
*/
|
2015-10-29 20:22:14 -07:00
|
|
|
@Cancelable
|
2017-08-15 21:30:48 -07:00
|
|
|
public static class PlayerDrainNetworkEvent extends SoulNetworkEvent {
|
2015-10-29 20:22:14 -07:00
|
|
|
public final EntityPlayer player;
|
2016-01-01 10:34:17 +01:00
|
|
|
// If true, will damage regardless of if the network had enough inside it
|
|
|
|
public boolean shouldDamage;
|
2015-10-29 20:22:14 -07:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) {
|
2015-10-29 20:22:14 -07:00
|
|
|
super(ownerNetwork, drainAmount);
|
2015-11-02 09:51:11 -08:00
|
|
|
this.shouldDamage = false;
|
2015-10-29 20:22:14 -07:00
|
|
|
this.player = player;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Cancelable
|
2017-08-15 21:30:48 -07:00
|
|
|
public static class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent {
|
2016-06-12 13:41:02 -07:00
|
|
|
@Nullable
|
2015-10-29 20:22:14 -07:00
|
|
|
public final ItemStack itemStack;
|
2016-01-01 10:34:17 +01:00
|
|
|
/**
|
|
|
|
* Amount of damage that would incur if the network could not drain
|
|
|
|
* properly
|
|
|
|
*/
|
|
|
|
public float damageAmount;
|
2015-10-29 20:22:14 -07:00
|
|
|
|
|
|
|
/**
|
2015-12-30 15:34:40 -05:00
|
|
|
* Set result to deny the action i.e. damage/drain anyways. Cancelling
|
|
|
|
* event prevents action without penalties
|
2017-08-15 21:30:48 -07:00
|
|
|
*
|
|
|
|
* @param player Player using the item
|
|
|
|
* @param ownerNetwork Network that the item is tied to
|
|
|
|
* @param itemStack Item used
|
|
|
|
* @param drainAmount Original drain amount - change to alter cost
|
2015-10-29 20:22:14 -07:00
|
|
|
*/
|
2017-08-15 21:30:48 -07:00
|
|
|
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, @Nullable ItemStack itemStack, int drainAmount) {
|
2015-10-29 20:22:14 -07:00
|
|
|
super(player, ownerNetwork, drainAmount);
|
|
|
|
this.itemStack = itemStack;
|
2015-11-28 18:25:46 -08:00
|
|
|
this.damageAmount = (float) (drainAmount) / 100.0f;
|
2015-10-29 20:22:14 -07:00
|
|
|
}
|
|
|
|
}
|
2014-11-06 21:25:53 -05:00
|
|
|
}
|