Class AbstractDamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- java.lang.Object
-
- org.spongepowered.api.event.cause.entity.damage.source.common.AbstractDamageSourceBuilder<T,B>
-
- All Implemented Interfaces:
AbstractBuilder<T>
,Buildable.Builder<T>
,DamageSource.DamageSourceBuilder<T,B>
,Builder<T,B>
,CopyableBuilder<T,B>
,ResettableBuilder<T,B>
- Direct Known Subclasses:
AbstractEntityDamageSource.AbstractEntityDamageSourceBuilder
public abstract class AbstractDamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>> extends java.lang.Object implements DamageSource.DamageSourceBuilder<T,B>
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
absolute
protected boolean
bypasses
protected boolean
creative
protected DamageType
damageType
protected @Nullable java.lang.Double
exhaustion
protected boolean
explosion
protected boolean
fire
protected boolean
magical
protected boolean
scales
-
Constructor Summary
Constructors Constructor Description AbstractDamageSourceBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description B
absolute()
Sets whether thisDamageSource
's damage is absolute and will ignore potion effects and enchantments.B
bypassesArmor()
Sets thisDamageSource
as dealing damage that bypasses armor modifiers.B
creative()
Sets thisDamageSource
as considered to damage creative, or otherwise "normally unharmable" players.B
exhaustion(double exhaustion)
Sets the amount of exhaustion thisDamageSource
will add to the entity, generally only to players.B
explosion()
Sets thisDamageSource
as an explosion.B
fire()
Sets thisDamageSource
's damage to be considered "fire" damage.B
from(T value)
Resets this builder to the values of the given built object.B
magical()
Sets thisDamageSource
as considered to be magical damage.B
reset()
Resets this builder to a "default" state such that there is no remaining data to set.B
scalesWithDifficulty()
Sets thisDamageSource
's damage to be scaled byDifficulty
.B
type(DamageType damageType)
Sets theDamageType
of this source.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.spongepowered.api.event.cause.entity.damage.source.DamageSource.DamageSourceBuilder
build, type
-
-
-
-
Field Detail
-
scales
protected boolean scales
-
bypasses
protected boolean bypasses
-
explosion
protected boolean explosion
-
absolute
protected boolean absolute
-
magical
protected boolean magical
-
creative
protected boolean creative
-
fire
protected boolean fire
-
exhaustion
protected @Nullable java.lang.Double exhaustion
-
damageType
protected DamageType damageType
-
-
Method Detail
-
fire
public B fire()
Description copied from interface:DamageSource.DamageSourceBuilder
Sets thisDamageSource
's damage to be considered "fire" damage.- Specified by:
fire
in interfaceDamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Returns:
- This builder
-
scalesWithDifficulty
public B scalesWithDifficulty()
Description copied from interface:DamageSource.DamageSourceBuilder
Sets thisDamageSource
's damage to be scaled byDifficulty
.- Specified by:
scalesWithDifficulty
in interfaceDamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Returns:
- This builder
-
bypassesArmor
public B bypassesArmor()
Description copied from interface:DamageSource.DamageSourceBuilder
Sets thisDamageSource
as dealing damage that bypasses armor modifiers.This sets the exhaustion increase caused by this source to 0. You can override this with
DamageSource.DamageSourceBuilder.exhaustion(double)
.- Specified by:
bypassesArmor
in interfaceDamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Returns:
- This builder
-
explosion
public B explosion()
Description copied from interface:DamageSource.DamageSourceBuilder
Sets thisDamageSource
as an explosion.- Specified by:
explosion
in interfaceDamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Returns:
- This builder
-
absolute
public B absolute()
Description copied from interface:DamageSource.DamageSourceBuilder
Sets whether thisDamageSource
's damage is absolute and will ignore potion effects and enchantments.This sets the exhaustion increase caused by this source to 0. You can override this with
DamageSource.DamageSourceBuilder.exhaustion(double)
.- Specified by:
absolute
in interfaceDamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Returns:
- This builder
-
magical
public B magical()
Description copied from interface:DamageSource.DamageSourceBuilder
Sets thisDamageSource
as considered to be magical damage. An example is potions.- Specified by:
magical
in interfaceDamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Returns:
- This builder
-
creative
public B creative()
Description copied from interface:DamageSource.DamageSourceBuilder
Sets thisDamageSource
as considered to damage creative, or otherwise "normally unharmable" players.- Specified by:
creative
in interfaceDamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Returns:
- This builder
-
exhaustion
public B exhaustion(double exhaustion)
Description copied from interface:DamageSource.DamageSourceBuilder
Sets the amount of exhaustion thisDamageSource
will add to the entity, generally only to players.In vanilla gameplay, the default is 0.1, unless if the damage is absolute or bypasses armor, where the exhaustion gets set to 0. This builder follows this mechanic, but if you set the exhaustion through this method that will be overridden.
If you don't set this exhaustion manually, calling
DamageSource.DamageSourceBuilder.absolute()
orDamageSource.DamageSourceBuilder.bypassesArmor()
will set this 0 and if you don't this will default to 0.1.- Specified by:
exhaustion
in interfaceDamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Parameters:
exhaustion
- The amount of exhaustion to add to the entity- Returns:
- This builder
-
type
public B type(DamageType damageType)
Description copied from interface:DamageSource.DamageSourceBuilder
Sets theDamageType
of this source.This is required to be set.
- Specified by:
type
in interfaceDamageSource.DamageSourceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Parameters:
damageType
- The desired damage type- Returns:
- This builder
-
from
public B from(T value)
Description copied from interface:CopyableBuilder
Resets this builder to the values of the given built object.- Specified by:
from
in interfaceCopyableBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Parameters:
value
- The built object- Returns:
- This builder, for chaining
-
reset
public B reset()
Description copied from interface:Builder
Resets this builder to a "default" state such that there is no remaining data to set. This is to be the presumed "default" state.- Specified by:
reset
in interfaceBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Specified by:
reset
in interfaceResettableBuilder<T extends DamageSource,B extends DamageSource.DamageSourceBuilder<T,B>>
- Returns:
- This builder, for chaining
-
-