Skip to content

Commit

Permalink
Fix (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal-Spider committed Jun 21, 2024
1 parent 881873e commit a1c6675
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
22 changes: 14 additions & 8 deletions common/src/main/java/it/crystalnest/soul_fire_d/api/Fire.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.StandingAndWallBlockItem;
import net.minecraft.world.item.enchantment.ArrowFireEnchantment;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.FireAspectEnchantment;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -258,12 +260,12 @@ public static final class Component<R, T extends R> {
/**
* Fire Aspect enchantment component.
*/
public static final Component<Enchantment, FireTypedFireAspectEnchantment> FIRE_ASPECT_ENCHANTMENT = new Component<>(Registry.ENCHANTMENT_REGISTRY, "_fire_aspect");
public static final Component<Enchantment, FireAspectEnchantment> FIRE_ASPECT_ENCHANTMENT = new Component<>(Registry.ENCHANTMENT_REGISTRY, "_fire_aspect");

/**
* Flame enchantment component.
*/
public static final Component<Enchantment, FireTypedFlameEnchantment> FLAME_ENCHANTMENT = new Component<>(Registry.ENCHANTMENT_REGISTRY, "_flame");
public static final Component<Enchantment, ArrowFireEnchantment> FLAME_ENCHANTMENT = new Component<>(Registry.ENCHANTMENT_REGISTRY, "_flame");

/**
* Registry key where the value associated to this component is stored.
Expand Down Expand Up @@ -752,14 +754,18 @@ public Builder reset(String fireId) {
public Fire build() throws IllegalStateException {
if (FireManager.isValidFireId(fireId) && FireManager.isValidModId(modId)) {
ResourceLocation fireType = FireManager.sanitize(modId, fireId);
if (fireAspectConfigurator != null && fireAspectConfigurator.isEmpty()) {
fireAspectConfigurator = Optional.of(builder -> builder);
if (fireAspectConfigurator != null) {
if (fireAspectConfigurator.isEmpty()) {
fireAspectConfigurator = Optional.of(builder -> builder);
}
components.put(Component.FIRE_ASPECT_ENCHANTMENT, register(fireType, fireAspectConfigurator, FireAspectBuilder::new));
}
if (flameConfigurator != null && flameConfigurator.isEmpty()) {
flameConfigurator = Optional.of(builder -> builder);
if (flameConfigurator != null) {
if (flameConfigurator.isEmpty()) {
flameConfigurator = Optional.of(builder -> builder);
}
components.put(Component.FLAME_ENCHANTMENT, register(fireType, flameConfigurator, FlameBuilder::new));
}
components.put(Component.FIRE_ASPECT_ENCHANTMENT, register(fireType, fireAspectConfigurator, FireAspectBuilder::new));
components.put(Component.FLAME_ENCHANTMENT, register(fireType, flameConfigurator, FlameBuilder::new));
return new Fire(fireType, light, damage, invertHealAndHarm, canRainDouse, inFire, onFire, behavior, components);
}
throw new IllegalStateException("Attempted to build a Fire with a non-valid fireId [" + fireId + "] or modId [" + modId + "].");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public abstract class AbstractArrowMixin implements FireTypeChanger {
*/
@Redirect(method = "onHitEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setSecondsOnFire(I)V"))
private void redirectSetSecondsOnFire(Entity caller, int seconds) {
FireTypedFlameEnchantment flame = FireManager.getComponent(getFireType(), Fire.Component.FLAME_ENCHANTMENT);
FireManager.setOnFire(caller, flame != null ? flame.duration(((Projectile) (Object) this).getOwner(), caller, seconds) : seconds, getFireType());
FireManager.setOnFire(caller, FireManager.getComponent(getFireType(), Fire.Component.FLAME_ENCHANTMENT) instanceof FireTypedFlameEnchantment flame ? flame.duration(((Projectile) (Object) this).getOwner(), caller, seconds) : seconds, getFireType());
}

/**
Expand Down

0 comments on commit a1c6675

Please sign in to comment.