Skip to content

Instantly share code, notes, and snippets.

@gabizou
Last active August 29, 2015 14:06
Show Gist options
  • Save gabizou/93fc7bbdada07c756cdd to your computer and use it in GitHub Desktop.
Save gabizou/93fc7bbdada07c756cdd to your computer and use it in GitHub Desktop.
package org.spongepowered.api.component.attribute;
import org.spongepowered.api.component.Component;
/**
* Gives a "damageable" attribute
*/
public interface Damage extends Component {
/**
* Checks if {@link org.spongepowered.api.entity.Entity} is invulnerable.
*
* @return true If {@link org.spongepowered.api.entity.Entity} is invulnerable
*/
boolean isInvulnerable();
/**
* Sets {@link org.spongepowered.api.entity.Entity} invulnerable if true.
*
* @param invulnerable true to make invulnerable
*/
void setInvulnerable(boolean invulnerable);
/**
* Deals damage to the {@link org.spongepowered.api.entity.Entity}. This
* should consider the damage to be {@link DamageType#GENERIC}.
*
* @param damage damage to deal
*/
void dealDamage(double damage);
/**
* Deals damage to the {@link org.spongepowered.api.entity.Entity} with the
* perscribed {@link DamageType}.
*
* @param damage the damage to deal
* @param damageType the damage type
*/
void dealDamage(double damage, DamageType damageType);
/**
* Represents the damage source and/or type for the damage being dealt to
* an {@link org.spongepowered.api.entity.Entity}
*/
public class DamageType {
/**
* Generic damage
*/
public static final DamageType GENERIC = new DamageType("minecraft.damageCause.generic");
/**
* Damage from standing in a fire burning block
*/
public static final DamageType FIRE = new DamageType("minecraft.damageCause.inFire");
/**
* Damage from being on fire
*/
public static final DamageType BURNING = new DamageType("minecraft.damageCause.onFire");
/**
* Damage from standing in a lava block
*/
public static final DamageType LAVA = new DamageType("minecraft.damageCause.lava");
/**
* Damage from being stuck in a physical block
*/
public static final DamageType SUFFOCATION = new DamageType("minecraft.damageCause.inWall");
/**
* Damage from being stuck in water and having no air
*/
public static final DamageType DROWNING = new DamageType("minecraft.damageCause.drown");
/**
* Damage from having no saturation
*/
public static final DamageType STARVATION = new DamageType("minecraft.damageCause.starve");
/**
* Damage from being too close to a cactus like object
*/
public static final DamageType CACTUS = new DamageType("minecraft.damageCause.cactus");
/**
* Damage from falling too far a distance
*/
public static final DamageType FALLING = new DamageType("minecraft.damageCause.fall");
/**
* Damage from being below the limits of the world (in the void)
*/
public static final DamageType VOID = new DamageType("minecraft.damageCause.outOfWorld");
/**
* Damage from magical sources
*/
public static final DamageType MAGICAL = new DamageType("minecraft.damageCause.magic");
/**
* Damage from withering potion effect
*/
public static final DamageType WITHER = new DamageType("minecraft.damageCause.wither");
/**
* Damage from an anvil falling on top of the entity
*/
public static final DamageType ANVIL = new DamageType("minecraft.damageCause.anvil");
/**
* Damage from a falling block falling on top of the entity
*/
public static final DamageType FALLING_BLOCK = new DamageType("minecraft.damageCause.fallingBlock");
/**
* Damage from a potion effect
*/
public static final DamageType POTION = new DamageType("sponge.damageType.potion");
/**
* Damage from a projectile hitting an entity
*/
public static final DamageType PROJECTILE = new DamageType("sponge.damageType.projectile");
private final String identifier;
protected DamageType(String identifier) {
this.identifier = identifier;
}
/**
* Gets the identifying string related to this damage type.
*
* @return the identifying string
*/
public String getIdentifier() {
return this.identifier;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment