-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
323ee7d
commit 9ca04d7
Showing
40 changed files
with
533 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
.../java/mod/chloeprime/modtechpoweredarsenal/client/lightland/guns/FlamethrowerVisuals.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mod.chloeprime.modtechpoweredarsenal.client.lightland.guns; | ||
|
||
import com.tacz.guns.api.event.common.GunFireEvent; | ||
import mod.chloeprime.aaaparticles.api.common.AAALevel; | ||
import mod.chloeprime.aaaparticles.api.common.ParticleEmitterInfo; | ||
import mod.chloeprime.gunsmithlib.api.util.Gunsmith; | ||
import mod.chloeprime.modtechpoweredarsenal.ModTechPoweredArsenal; | ||
import mod.chloeprime.modtechpoweredarsenal.client.standard.MinecraftHolder; | ||
import mod.chloeprime.modtechpoweredarsenal.common.standard.guns.FlamethrowerBehavior; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
|
||
@Mod.EventBusSubscriber(Dist.CLIENT) | ||
public class FlamethrowerVisuals { | ||
public static final ResourceLocation COMMON_FLAME_EFFEK_ID = ModTechPoweredArsenal.loc("explosion/flamethrower"); | ||
public static final ResourceLocation SOUL_FLAME_EFFEK_ID = ModTechPoweredArsenal.loc("explosion/flamethrower_soul"); | ||
|
||
@SubscribeEvent | ||
public static void onClientShot(GunFireEvent event) { | ||
if (event.getLogicalSide().isServer()) { | ||
return; | ||
} | ||
var gun = Gunsmith.getGunInfo(event.getGunItemStack()).orElse(null); | ||
if (gun == null) { | ||
return; | ||
} | ||
int type = FlamethrowerBehavior.getType(gun); | ||
if (type == 0 || event.getShooter().isUnderWater()) { | ||
return; | ||
} | ||
var shooter = event.getShooter(); | ||
if (shooter == null || !shooter.level().isClientSide) { | ||
return; | ||
} | ||
var particle = type == FlamethrowerBehavior.BULLET_FLAME_TYPE_SOUL | ||
? SOUL_FLAME_EFFEK_ID | ||
: COMMON_FLAME_EFFEK_ID; | ||
var pei = ParticleEmitterInfo.create(shooter.level(), particle) | ||
.bindOnEntity(shooter) | ||
.useEntityHeadSpace() | ||
.entitySpaceRelativePosition(0.06, -0.28, -0.8); | ||
MinecraftHolder.MC.execute(() -> { | ||
if (shooter.isAlive()) { | ||
AAALevel.addParticle(shooter.level(), true, pei); | ||
} | ||
}); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/mod/chloeprime/modtechpoweredarsenal/client/standard/MinecraftHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package mod.chloeprime.modtechpoweredarsenal.client.standard; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
@ApiStatus.Internal | ||
public class MinecraftHolder { | ||
public static final Minecraft MC = Minecraft.getInstance(); | ||
} |
32 changes: 32 additions & 0 deletions
32
...loeprime/modtechpoweredarsenal/common/lightland/guns/SoulFlamethrowerBehaviorLCProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package mod.chloeprime.modtechpoweredarsenal.common.lightland.guns; | ||
|
||
import com.google.common.base.Suppliers; | ||
import dev.xkmc.l2library.base.effects.EffectUtil; | ||
import mod.chloeprime.modtechpoweredarsenal.ModLoadStatus; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.effect.MobEffect; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.function.Supplier; | ||
|
||
@Mod.EventBusSubscriber | ||
public class SoulFlamethrowerBehaviorLCProxy { | ||
private static final Supplier<MobEffect> SOUL_FLAME_DEBUFF = Suppliers.memoize( | ||
() -> ForgeRegistries.MOB_EFFECTS.getValue( | ||
new ResourceLocation("l2complements", "flame") | ||
) | ||
); | ||
|
||
public static void addSoulFlameDebuff(LivingEntity victim, @Nullable Entity shooter) { | ||
var size = victim.getActiveEffectsMap().size(); | ||
int time = ModLoadStatus.L2H_INSTALLED | ||
? SoulFlamethrowerBehaviorLHProxy.getFlameThornDebuffDuration() | ||
: 5 * 20; | ||
EffectUtil.addEffect(victim, new MobEffectInstance(SOUL_FLAME_DEBUFF.get(), time, size), EffectUtil.AddReason.FORCE, shooter); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...loeprime/modtechpoweredarsenal/common/lightland/guns/SoulFlamethrowerBehaviorLHProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package mod.chloeprime.modtechpoweredarsenal.common.lightland.guns; | ||
|
||
import dev.xkmc.l2hostility.init.data.LHConfig; | ||
import net.minecraftforge.fml.common.Mod; | ||
|
||
@Mod.EventBusSubscriber | ||
public class SoulFlamethrowerBehaviorLHProxy { | ||
public static int getFlameThornDebuffDuration() { | ||
return LHConfig.COMMON.flameThornTime.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
.../java/mod/chloeprime/modtechpoweredarsenal/common/standard/guns/FlamethrowerBehavior.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package mod.chloeprime.modtechpoweredarsenal.common.standard.guns; | ||
|
||
import com.google.common.collect.Sets; | ||
import com.tacz.guns.api.event.common.EntityHurtByGunEvent; | ||
import com.tacz.guns.api.event.common.GunDamageSourcePart; | ||
import com.tacz.guns.api.item.attachment.AttachmentType; | ||
import mod.chloeprime.gunsmithlib.api.common.BulletCreateEvent; | ||
import mod.chloeprime.gunsmithlib.api.util.GunInfo; | ||
import mod.chloeprime.gunsmithlib.api.util.Gunsmith; | ||
import mod.chloeprime.modtechpoweredarsenal.ModLoadStatus; | ||
import mod.chloeprime.modtechpoweredarsenal.ModTechPoweredArsenal; | ||
import mod.chloeprime.modtechpoweredarsenal.common.lightland.MtpaL2Module; | ||
import mod.chloeprime.modtechpoweredarsenal.common.lightland.guns.SoulFlamethrowerBehaviorLCProxy; | ||
import mod.chloeprime.modtechpoweredarsenal.common.standard.util.DamageSourceUtil; | ||
import mod.chloeprime.modtechpoweredarsenal.mixin.minecraft.DamageSourcesAccessor; | ||
import net.minecraft.core.particles.ParticleOptions; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.DamageTypeTags; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.damagesource.DamageTypes; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.projectile.Projectile; | ||
import net.minecraftforge.eventbus.api.EventPriority; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
@Mod.EventBusSubscriber | ||
public class FlamethrowerBehavior { | ||
public static final Set<ResourceLocation> FLAMETHROWERS = Sets.newConcurrentHashSet(Set.of( | ||
ModTechPoweredArsenal.loc("flamethrower") | ||
)); | ||
public static final Set<ResourceLocation> SOUL_FUEL_MAGS = Sets.newConcurrentHashSet(Set.of( | ||
MtpaL2Module.loc("ammo_mod_soul_fuel") | ||
)); | ||
public static final String PDK_BULLET_FLAME_TYPE = ModTechPoweredArsenal.loc("flame_type").toString(); | ||
public static final int BULLET_FLAME_TYPE_HEAT = 1; | ||
public static final int BULLET_FLAME_TYPE_SOUL = 2; | ||
|
||
public static int getType(GunInfo gun) { | ||
if (!FLAMETHROWERS.contains(gun.gunId())) { | ||
return 0; | ||
} | ||
return willShootSoulFlame(gun) ? BULLET_FLAME_TYPE_SOUL : BULLET_FLAME_TYPE_HEAT; | ||
} | ||
|
||
public static boolean willShootSoulFlame(GunInfo gun) { | ||
return SOUL_FUEL_MAGS.contains(gun.gunItem().getAttachmentId(gun.gunStack(), AttachmentType.EXTENDED_MAG)); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onBulletCreate(BulletCreateEvent event) { | ||
if (event.getBullet().level().isClientSide) { | ||
return; | ||
} | ||
Optional<GunInfo> gunInfo = Gunsmith.getGunInfo(event.getGun()); | ||
var isValidGun = gunInfo | ||
.map(GunInfo::gunId) | ||
.filter(FLAMETHROWERS::contains) | ||
.isPresent(); | ||
if (!isValidGun) { | ||
return; | ||
} | ||
var type = getType(gunInfo.get()); | ||
if (type <= 0) { | ||
return; | ||
} | ||
event.getBullet().getPersistentData().putInt(PDK_BULLET_FLAME_TYPE, type); | ||
} | ||
|
||
@SubscribeEvent(priority = EventPriority.HIGH) | ||
public static void onPreHurt(EntityHurtByGunEvent.Pre event) { | ||
var source1 = event.getDamageSource(GunDamageSourcePart.NON_ARMOR_PIERCING); | ||
var source2 = event.getDamageSource(GunDamageSourcePart.ARMOR_PIERCING); | ||
|
||
var bullet = event.getBullet(); | ||
var victim = event.getHurtEntity(); | ||
if (victim == null || bullet == null) { | ||
return; | ||
} | ||
var type = bullet.getPersistentData().getInt(PDK_BULLET_FLAME_TYPE); | ||
DamageSource newSource; | ||
switch (type) { | ||
case BULLET_FLAME_TYPE_HEAT -> { | ||
newSource = ((DamageSourcesAccessor) victim.damageSources()).invokeSource(DamageTypes.IN_FIRE, bullet, event.getAttacker()); | ||
} | ||
case BULLET_FLAME_TYPE_SOUL -> { | ||
if (source1.is(DamageSourceUtil.ANY_MAGIC)) { | ||
return; | ||
} | ||
newSource = victim.damageSources().indirectMagic(bullet, event.getAttacker()); | ||
} | ||
default -> { | ||
return; | ||
} | ||
} | ||
event.setDamageSource(GunDamageSourcePart.NON_ARMOR_PIERCING, newSource); | ||
event.setDamageSource(GunDamageSourcePart.ARMOR_PIERCING, newSource); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onPostHurt(EntityHurtByGunEvent.Post event) { | ||
if (event.getLogicalSide().isClient()) { | ||
return; | ||
} | ||
if (!(event.getHurtEntity() instanceof LivingEntity victim)) { | ||
return; | ||
} | ||
int type = event.getBullet().getPersistentData().getInt(PDK_BULLET_FLAME_TYPE); | ||
switch (type) { | ||
case BULLET_FLAME_TYPE_HEAT -> { | ||
victim.setRemainingFireTicks((int) (event.getBaseAmount() * 20)); | ||
} | ||
case BULLET_FLAME_TYPE_SOUL -> { | ||
if (ModLoadStatus.L2C_INSTALLED) { | ||
SoulFlamethrowerBehaviorLCProxy.addSoulFlameDebuff(victim, event.getAttacker()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static boolean disableServerBulletHole(Projectile bullet, ParticleOptions particle) { | ||
return bullet.getPersistentData().getInt(PDK_BULLET_FLAME_TYPE) > 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...main/java/mod/chloeprime/modtechpoweredarsenal/mixin/minecraft/DamageSourcesAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package mod.chloeprime.modtechpoweredarsenal.mixin.minecraft; | ||
|
||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.damagesource.DamageSources; | ||
import net.minecraft.world.damagesource.DamageType; | ||
import net.minecraft.world.entity.Entity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
@Mixin(DamageSources.class) | ||
public interface DamageSourcesAccessor { | ||
@Invoker | ||
DamageSource invokeSource(ResourceKey<DamageType> id, @Nullable Entity var1, @Nullable Entity var2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/resources/assets/modtech_arsenal/effeks/explosion/explosion_big_a.efkefc
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
src/main/resources/assets/modtech_arsenal/effeks/explosion/flamethrower.efkefc
Git LFS file not shown
Oops, something went wrong.