Skip to content

Commit

Permalink
Fix fire damage implementation in builders
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Jan 28, 2023
1 parent 3a371bb commit ccda7c5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public DamageSource build() throws IllegalStateException {
&& !this.creative
&& !this.fire
&& this.exhaustion == null
&& this.damageType.equals(DamageTypes.DROWN)
&& this.damageType.equals(DamageTypes.DROWN.get())
) {
return (DamageSource) net.minecraft.world.damagesource.DamageSource.DROWN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public EntityDamageSource build() throws IllegalStateException {
if (this.exhaustion != null) {
accessor.accessor$exhaustion(this.exhaustion.floatValue());
}
if (this.fire) {
accessor.invoker$setIsFire();
}
return (EntityDamageSource) damageSource;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,17 @@

import java.lang.ref.WeakReference;

public final class SpongeFallingBlockDamgeSourceBuilder extends AbstractDamageSourceBuilder<FallingBlockDamageSource, FallingBlockDamageSource.Builder> implements FallingBlockDamageSource.Builder {
public final class SpongeFallingBlockDamageSourceBuilder extends AbstractDamageSourceBuilder<FallingBlockDamageSource, FallingBlockDamageSource.Builder> implements FallingBlockDamageSource.Builder {

protected WeakReference<Entity> reference = null;

@Override
public SpongeFallingBlockDamgeSourceBuilder entity(final Entity entity) {
public SpongeFallingBlockDamageSourceBuilder entity(final Entity entity) {
checkArgument(entity instanceof FallingBlock);
this.reference = new WeakReference<>(entity);
return this;
}

@Override
public FallingBlockDamageSource.Builder fire() {
return null;
}

@SuppressWarnings("ConstantConditions")
@Override
public FallingBlockDamageSource build() throws IllegalStateException {
Expand Down Expand Up @@ -84,6 +79,9 @@ public FallingBlockDamageSource build() throws IllegalStateException {
if (this.exhaustion != null) {
accessor.accessor$exhaustion(this.exhaustion.floatValue());
}
if (this.fire) {
accessor.invoker$setIsFire();
}
return (FallingBlockDamageSource) (Object) damageSource;
}

Expand All @@ -95,7 +93,7 @@ public FallingBlockDamageSource.Builder from(final FallingBlockDamageSource valu
}

@Override
public SpongeFallingBlockDamgeSourceBuilder reset() {
public SpongeFallingBlockDamageSourceBuilder reset() {
super.reset();
this.reference = null;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public IndirectEntityDamageSource build() throws IllegalStateException {
if (this.exhaustion != null) {
accessor.accessor$exhaustion(this.exhaustion.floatValue());
}
if (this.fire) {
accessor.invoker$setIsFire();
}
return (IndirectEntityDamageSource) damageSource;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
import org.spongepowered.common.event.cause.entity.damage.SpongeDamageSourceBuilder;
import org.spongepowered.common.event.cause.entity.damage.SpongeDamageType;
import org.spongepowered.common.event.cause.entity.damage.SpongeEntityDamageSourceBuilder;
import org.spongepowered.common.event.cause.entity.damage.SpongeFallingBlockDamgeSourceBuilder;
import org.spongepowered.common.event.cause.entity.damage.SpongeFallingBlockDamageSourceBuilder;
import org.spongepowered.common.event.cause.entity.damage.SpongeIndirectEntityDamageSourceBuilder;
import org.spongepowered.common.fluid.SpongeFluidStackBuilder;
import org.spongepowered.common.fluid.SpongeFluidStackSnapshotBuilder;
Expand Down Expand Up @@ -277,7 +277,7 @@ public void registerDefaultBuilders() {
.register(DamageSource.Builder.class, SpongeDamageSourceBuilder::new)
.register(EntityDamageSource.Builder.class, SpongeEntityDamageSourceBuilder::new)
.register(IndirectEntityDamageSource.Builder.class, SpongeIndirectEntityDamageSourceBuilder::new)
.register(FallingBlockDamageSource.Builder.class, SpongeFallingBlockDamgeSourceBuilder::new)
.register(FallingBlockDamageSource.Builder.class, SpongeFallingBlockDamageSourceBuilder::new)
.register(BlockDamageSource.Builder.class, SpongeBlockDamageSourceBuilder::new)
.register(Explosion.Builder.class, SpongeExplosionBuilder::new)
.register(BlockState.Builder.class, SpongeBlockStateBuilder::new)
Expand Down

0 comments on commit ccda7c5

Please sign in to comment.