use of org.spongepowered.common.accessor.world.damagesource.DamageSourceAccessor in project SpongeCommon by SpongePowered.
the class SpongeIndirectEntityDamageSourceBuilder method build.
@Override
public IndirectEntityDamageSource build() throws IllegalStateException {
checkState(this.reference.get() != null);
checkState(this.proxy.get() != null);
checkState(this.damageType != null);
final net.minecraft.world.damagesource.IndirectEntityDamageSource damageSource = new net.minecraft.world.damagesource.IndirectEntityDamageSource(this.damageType.name(), (net.minecraft.world.entity.Entity) this.reference.get(), (net.minecraft.world.entity.Entity) this.proxy.get());
final DamageSourceAccessor accessor = (DamageSourceAccessor) damageSource;
if (this.creative) {
accessor.invoker$bypassInvul();
}
if (this.scales) {
damageSource.setScalesWithDifficulty();
}
if (this.magical) {
damageSource.setMagic();
}
if (this.bypasses) {
accessor.invoker$bypassArmor();
}
if (this.absolute) {
accessor.invoker$bypassMagic();
}
if (this.explosion) {
damageSource.setExplosion();
}
if (this.exhaustion != null) {
accessor.accessor$exhaustion(this.exhaustion.floatValue());
}
return (IndirectEntityDamageSource) damageSource;
}
use of org.spongepowered.common.accessor.world.damagesource.DamageSourceAccessor in project SpongeCommon by SpongePowered.
the class SpongeDamageSourceBuilder method build.
@SuppressWarnings("ConstantConditions")
@Override
public DamageSource build() throws IllegalStateException {
checkState(this.damageType != null, "DamageType was null!");
final net.minecraft.world.damagesource.DamageSource source = DamageSourceAccessor.invoker$new(this.damageType.toString());
final DamageSourceAccessor accessor = (DamageSourceAccessor) source;
if (!this.scales && this.bypasses && !this.explosion && !this.absolute && !this.magical && !this.creative && !this.fire && this.exhaustion == null && this.damageType.equals(DamageTypes.DROWN)) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.DROWN;
}
if (!this.scales && !this.bypasses && !this.explosion && !this.absolute && !this.magical && !this.creative && !this.fire && this.exhaustion == null && this.damageType.equals(DamageTypes.DRYOUT.get())) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.DRY_OUT;
}
if (!this.scales && !this.bypasses && !this.explosion && !this.absolute && !this.magical && !this.creative && !this.fire && this.exhaustion == null && this.damageType.equals(DamageTypes.FALL.get())) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.FALL;
}
if (!this.scales && !this.bypasses && !this.explosion && !this.absolute && !this.magical && !this.creative && this.fire && this.exhaustion == null && this.damageType.equals(DamageTypes.FIRE.get())) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.ON_FIRE;
}
if (!this.scales && this.bypasses && !this.explosion && !this.absolute && !this.magical && !this.creative && !this.fire && this.exhaustion == null && this.damageType.equals(DamageTypes.GENERIC.get())) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.GENERIC;
}
if (!this.scales && this.bypasses && !this.explosion && !this.absolute && this.magical && !this.creative && !this.fire && this.exhaustion == null && this.damageType.equals(DamageTypes.MAGIC.get())) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.MAGIC;
}
if (!this.scales && this.bypasses && !this.explosion && this.absolute && !this.magical && !this.creative && !this.fire && this.exhaustion == null && this.damageType.equals(DamageTypes.HUNGER.get())) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.STARVE;
}
if (!this.scales && this.bypasses && !this.explosion && !this.absolute && !this.magical && this.creative && !this.fire && this.exhaustion == null && this.damageType.equals(DamageTypes.VOID.get())) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.OUT_OF_WORLD;
}
if (!this.scales && !this.bypasses && !this.explosion && !this.absolute && this.magical && !this.creative && !this.fire && this.exhaustion == null && this.damageType.equals(DamageTypes.MAGIC.get())) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.WITHER;
}
if (this.absolute) {
accessor.invoker$bypassMagic();
}
if (this.bypasses) {
accessor.invoker$bypassArmor();
}
if (this.creative) {
accessor.invoker$bypassInvul();
}
if (this.magical) {
source.setMagic();
}
if (this.scales) {
source.setScalesWithDifficulty();
}
if (this.explosion) {
source.setExplosion();
}
if (this.exhaustion != null) {
accessor.accessor$exhaustion(this.exhaustion.floatValue());
}
if (this.fire) {
accessor.invoker$setIsFire();
}
return (DamageSource) source;
}
use of org.spongepowered.common.accessor.world.damagesource.DamageSourceAccessor in project SpongeCommon by SpongePowered.
the class SpongeFallingBlockDamgeSourceBuilder method build.
@SuppressWarnings("ConstantConditions")
@Override
public FallingBlockDamageSource build() throws IllegalStateException {
checkState(this.reference.get() != null);
checkState(this.damageType != null);
final MinecraftFallingBlockDamageSource damageSource = new MinecraftFallingBlockDamageSource(this.damageType.name(), (FallingBlockEntity) this.reference.get());
final DamageSourceAccessor accessor = (DamageSourceAccessor) (Object) damageSource;
if (this.creative) {
accessor.invoker$bypassInvul();
}
if (this.scales) {
damageSource.setScalesWithDifficulty();
}
if (this.magical) {
damageSource.setMagic();
}
if (this.bypasses) {
accessor.invoker$bypassArmor();
}
if (this.absolute) {
accessor.invoker$bypassMagic();
}
if (this.explosion) {
damageSource.setExplosion();
}
if (this.exhaustion != null) {
accessor.accessor$exhaustion(this.exhaustion.floatValue());
}
return (FallingBlockDamageSource) (Object) damageSource;
}
use of org.spongepowered.common.accessor.world.damagesource.DamageSourceAccessor in project SpongeCommon by SpongePowered.
the class SpongeBlockDamageSourceBuilder method build.
@SuppressWarnings("ConstantConditions")
@Override
public BlockDamageSource build() throws IllegalStateException {
checkState(this.location != null);
checkState(this.blockSnapshot != null);
checkState(this.damageType != null);
final MinecraftBlockDamageSource damageSource = new MinecraftBlockDamageSource(this.damageType.name(), this.location);
final DamageSourceAccessor accessor = (DamageSourceAccessor) (Object) damageSource;
if (this.absolute) {
accessor.invoker$bypassMagic();
}
if (this.bypasses) {
accessor.invoker$bypassArmor();
}
if (this.scales) {
damageSource.setScalesWithDifficulty();
}
if (this.explosion) {
damageSource.setExplosion();
}
if (this.magical) {
damageSource.setMagic();
}
if (this.creative) {
accessor.invoker$bypassInvul();
}
if (this.exhaustion != null) {
accessor.accessor$exhaustion(this.exhaustion.floatValue());
}
if (this.fire) {
accessor.invoker$setIsFire();
}
return (BlockDamageSource) (Object) damageSource;
}
use of org.spongepowered.common.accessor.world.damagesource.DamageSourceAccessor in project SpongeCommon by SpongePowered.
the class SpongeEntityDamageSourceBuilder method build.
@SuppressWarnings("ConstantConditions")
@Override
public EntityDamageSource build() throws IllegalStateException {
checkState(this.damageType != null, "Damage type cannot be null!");
checkState(this.reference.get() != null);
final net.minecraft.world.damagesource.EntityDamageSource damageSource = new net.minecraft.world.damagesource.EntityDamageSource(this.damageType.name(), (net.minecraft.world.entity.Entity) this.reference.get());
final DamageSourceAccessor accessor = (DamageSourceAccessor) damageSource;
if (this.creative) {
accessor.invoker$bypassInvul();
}
if (this.scales) {
damageSource.setScalesWithDifficulty();
}
if (this.magical) {
damageSource.setMagic();
}
if (this.bypasses) {
accessor.invoker$bypassArmor();
}
if (this.absolute) {
accessor.invoker$bypassMagic();
}
if (this.explosion) {
damageSource.setExplosion();
}
if (this.exhaustion != null) {
accessor.accessor$exhaustion(this.exhaustion.floatValue());
}
return (EntityDamageSource) damageSource;
}
Aggregations