Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Soul Fire'd and fix a bug #60

Open
wants to merge 3 commits into
base: 1.20
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version "1.4-SNAPSHOT"
id 'fabric-loom' version "1.5-SNAPSHOT"
id 'io.github.ladysnake.chenille' version '0.11.3'
}

Expand Down Expand Up @@ -58,6 +58,16 @@ repositories {
maven { url "https://maven.willbl.dev/releases" }
// bookshelf
maven { url 'https://maven.blamejared.com' }
// Soul Fire'd
maven {
name = "Crystal Nest"
url = "https://maven.crystalnest.it"
}
// FCAP for Soul Fire'd.
maven {
name = "Fuzs Mod Resources"
url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/"
}
}

dependencies {
Expand All @@ -82,6 +92,8 @@ dependencies {
modRuntimeOnly(libs.bundles.enchancement) {
exclude group: "net.fabricmc.fabric-api"
}

modImplementation "it.crystalnest:soul-fire-d-fabric:${project.minecraft_version}-${soul_fire_d_version}"
}

processResources {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ archives_base_name = impaled
findbugs_version = 3.0.2
jb_annotations_version = 15.0
apiguardian_version = 1.0.0
soul_fire_d_version = 4.0.0

#Publishing
owners = Ladysnake
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/ladysnake/impaled/common/Impaled.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public void onInitialize() {

// add loot to dungeons, mineshafts, jungle temples, and stronghold libraries chests loot tables
UniformLootNumberProvider lootTableRange = UniformLootNumberProvider.create(1, 1);
LootCondition chanceLootCondition = RandomChanceLootCondition.builder(60).build();
LootCondition.Builder chanceLootCondition = RandomChanceLootCondition.builder(60);
LootTableEvents.MODIFY.register((resourceManager, lootManager, id, supplier, setter) -> {
if (BASTION_TREASURE_CHEST_LOOT_TABLE_ID.equals(id)) {
LootPool lootPool = LootPool.builder()
LootPool.Builder lootPool = LootPool.builder()
.rolls(lootTableRange)
.conditionally(chanceLootCondition)
.with(ItemEntry.builder(ImpaledItems.ANCIENT_TRIDENT).build()).build();
.with(ItemEntry.builder(ImpaledItems.ANCIENT_TRIDENT));

supplier.pool(lootPool);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.ladysnake.impaled.common.entity;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.world.World;

public abstract class FireTridentEntity extends ImpaledTridentEntity {
public FireTridentEntity(EntityType<? extends FireTridentEntity> entityType, World world) {
super(entityType, world);
}

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
if (entityHitResult.getEntity() instanceof LivingEntity livingEntity && livingEntity.getType() != EntityType.ENDERMAN) {
setTargetOnFireFor(livingEntity, 1);
}
super.onEntityHit(entityHitResult);
}

@Override
protected void onHit(LivingEntity target) {
super.onHit(target);
setTargetOnFireFor(target, 8);
}

@Override
public boolean isOnFire() {
return true;
}

@Override
public boolean doesRenderOnFire() {
return false;
}

@Override
public void tick() {
super.tick();

if (this.isSubmergedInWater() && this.getWorld().isClient() && this.random.nextInt(5) == 0) {
this.getWorld().addParticle(ParticleTypes.BUBBLE_COLUMN_UP, this.getX() + random.nextGaussian() / 10, this.getY() + random.nextGaussian() / 10, this.getZ() + random.nextGaussian() / 10, 0, this.random.nextFloat(), 0);
}
}

protected abstract void setTargetOnFireFor(LivingEntity target, int seconds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,15 @@

import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.world.World;

public class HellforkEntity extends ImpaledTridentEntity {
public class HellforkEntity extends FireTridentEntity {
public HellforkEntity(EntityType<? extends HellforkEntity> entityType, World world) {
super(entityType, world);
}

@Override
protected void onHit(LivingEntity target) {
super.onHit(target);
target.setOnFireFor(8);
}

@Override
public boolean isOnFire() {
return true;
}

@Override
public boolean doesRenderOnFire() {
return false;
}

@Override
public void tick() {
super.tick();

if (this.isSubmergedInWater() && this.getWorld().isClient() && this.random.nextInt(5) == 0) {
this.getWorld().addParticle(ParticleTypes.BUBBLE_COLUMN_UP, this.getX() + random.nextGaussian() / 10, this.getY() + random.nextGaussian() / 10, this.getZ() + random.nextGaussian() / 10, 0, this.random.nextFloat(), 0);
}
protected void setTargetOnFireFor(LivingEntity target, int seconds) {
target.setOnFireFor(seconds);
}
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
package org.ladysnake.impaled.common.entity;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.world.World;
import org.ladysnake.impaled.compat.SoulFired;

public class SoulforkEntity extends ImpaledTridentEntity {
public class SoulforkEntity extends FireTridentEntity {
public SoulforkEntity(EntityType<? extends SoulforkEntity> entityType, World world) {
super(entityType, world);
}

@Override
protected void onHit(LivingEntity target) {
super.onHit(target);
target.setOnFireFor(8);
}

@Override
public boolean isOnFire() {
return true;
}

@Override
public boolean doesRenderOnFire() {
return false;
}

@Override
public void tick() {
super.tick();

if (this.isSubmergedInWater() && this.getWorld().isClient() && this.random.nextInt(5) == 0) {
this.getWorld().addParticle(ParticleTypes.BUBBLE_COLUMN_UP, this.getX() + random.nextGaussian() / 10, this.getY() + random.nextGaussian() / 10, this.getZ() + random.nextGaussian() / 10, 0, this.random.nextFloat(), 0);
protected void setTargetOnFireFor(LivingEntity target, int seconds) {
if (FabricLoader.getInstance().isModLoaded("soul_fire_d")) {
SoulFired.setOnSoulFireFor(target, seconds);
} else {
target.setOnFireFor(seconds);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class ImpaledItems {
public static final Item ELDER_GUARDIAN_EYE = new Item((new Item.Settings()).rarity(Rarity.UNCOMMON));
public static final Item ANCIENT_TRIDENT = new Item((new Item.Settings()).rarity(Rarity.UNCOMMON).fireproof());
public static final PitchforkItem PITCHFORK = new PitchforkItem((new Item.Settings()).maxDamage(150), ImpaledEntityTypes.PITCHFORK);
public static final HellforkItem HELLFORK = new HellforkItem((new Item.Settings()).maxDamage(325).fireproof().fireproof(), ImpaledEntityTypes.HELLFORK);
public static final HellforkItem SOULFORK = new HellforkItem((new Item.Settings()).maxDamage(325).fireproof().fireproof(), ImpaledEntityTypes.SOULFORK);
public static final HellforkItem HELLFORK = new HellforkItem((new Item.Settings()).maxDamage(325).fireproof(), ImpaledEntityTypes.HELLFORK);
public static final HellforkItem SOULFORK = new HellforkItem((new Item.Settings()).maxDamage(325).fireproof(), ImpaledEntityTypes.SOULFORK);
public static final ElderTridentItem ELDER_TRIDENT = new ElderTridentItem((new Item.Settings()).maxDamage(250), ImpaledEntityTypes.ELDER_TRIDENT);
public static final AtlanItem ATLAN = new AtlanItem((new Item.Settings()).maxDamage(250), ImpaledEntityTypes.ATLAN);
public static final MaelstromItem MAELSTROM = new MaelstromItem((new Item.Settings()).maxDamage(80));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ladysnake.impaled.common.item;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.enchantment.EnchantmentHelper;
Expand All @@ -17,6 +18,7 @@
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import org.ladysnake.impaled.compat.SoulFired;
import org.ladysnake.impaled.common.entity.ImpaledTridentEntity;
import org.ladysnake.impaled.common.init.ImpaledItems;

Expand All @@ -27,7 +29,12 @@ public HellforkItem(Settings settings, EntityType<? extends ImpaledTridentEntity

@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
target.setOnFireFor(4 + attacker.getRandom().nextInt(4));
int seconds = 4 + attacker.getRandom().nextInt(4);
if (this == ImpaledItems.SOULFORK && FabricLoader.getInstance().isModLoaded("soul_fire_d")) {
SoulFired.setOnSoulFireFor(target, seconds);
} else {
target.setOnFireFor(seconds);
}
return super.postHit(stack, target, attacker);
}

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/ladysnake/impaled/compat/SoulFired.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.ladysnake.impaled.compat;

import it.crystalnest.soul_fire_d.api.FireManager;
import net.minecraft.entity.Entity;

public final class SoulFired {
private SoulFired() {}

public static void setOnSoulFireFor(Entity entity, int seconds) {
FireManager.setOnFire(entity, seconds, FireManager.SOUL_FIRE_TYPE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import org.ladysnake.impaled.common.enchantment.BetterImpaling;
import org.ladysnake.impaled.common.item.HellforkItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Slice;

@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin extends LivingEntity {
Expand All @@ -21,4 +25,8 @@ private float getAttackDamage(float baseDamage, Entity target) {
return baseDamage + BetterImpaling.getAttackDamage(this.getMainHandStack(), target);
}

@ModifyConstant(method = "attack", constant = @Constant(expandZeroConditions = Constant.Condition.GREATER_THAN_ZERO), slice = @Slice(from = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/enchantment/EnchantmentHelper;getFireAspect(Lnet/minecraft/entity/LivingEntity;)I", ordinal = 0)))
private int checkFireDamage(int constant) {
return this.getMainHandStack().getItem() instanceof HellforkItem ? -1 : constant;
}
}
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"java": ">=17",
"fabric": ">=0.48.0"
},
"suggests": {
"soul_fire_d": "^4.0.0"
},
"custom": {
"loom:injected_interfaces": {
"net/minecraft/class_8109": [
Expand Down