-
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.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
42 changed files
with
571 additions
and
11 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
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
156 changes: 156 additions & 0 deletions
156
.../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,156 @@ | ||
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 mod.chloeprime.modtechpoweredarsenal.network.ModNetwork; | ||
import mod.chloeprime.modtechpoweredarsenal.network.S2CEnchantedHit; | ||
import net.minecraft.core.particles.ParticleOptions; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.damagesource.DamageTypes; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.effect.MobEffects; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.MobType; | ||
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 String PDK_BULLET_SHRAPNEL_COUNT = ModTechPoweredArsenal.loc("flame_shrapnel_count").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; | ||
} | ||
|
||
var pd = event.getBullet().getPersistentData(); | ||
pd.putInt(PDK_BULLET_FLAME_TYPE, type); | ||
pd.putInt(PDK_BULLET_SHRAPNEL_COUNT, gunInfo.get().index().getBulletData().getBulletAmount()); | ||
} | ||
|
||
@SubscribeEvent(priority = EventPriority.HIGH) | ||
public static void onPreHurt(EntityHurtByGunEvent.Pre event) { | ||
var source1 = event.getDamageSource(GunDamageSourcePart.NON_ARMOR_PIERCING); | ||
|
||
var bullet = event.getBullet(); | ||
var victim = event.getHurtEntity(); | ||
if (victim == null || bullet == null) { | ||
return; | ||
} | ||
|
||
var pd = bullet.getPersistentData(); | ||
var shrapnelCount = Math.max(1, pd.getInt(PDK_BULLET_SHRAPNEL_COUNT)); | ||
baneOfArthropods(event, victim, shrapnelCount); | ||
|
||
var type = pd.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); | ||
} | ||
|
||
private static void baneOfArthropods(EntityHurtByGunEvent.Pre event, Entity hurtEntity, int shrapnelCount) { | ||
if (!(hurtEntity instanceof LivingEntity victim)) { | ||
return; | ||
} | ||
if (victim.getMobType() != MobType.ARTHROPOD) { | ||
return; | ||
} | ||
var damageBonus = 12.5F; | ||
var debuffDuration = victim.getRandom().nextIntBetweenInclusive(60, 70); | ||
var debuffAmplifier = 4; | ||
event.setBaseAmount(event.getBaseAmount() + damageBonus / shrapnelCount); | ||
victim.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, debuffDuration, debuffAmplifier)); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onPostHurt(EntityHurtByGunEvent.Post event) { | ||
if (event.getLogicalSide().isClient()) { | ||
return; | ||
} | ||
if (!(event.getHurtEntity() instanceof LivingEntity victim)) { | ||
return; | ||
} | ||
var pd = event.getBullet().getPersistentData(); | ||
int type = pd.getInt(PDK_BULLET_FLAME_TYPE); | ||
switch (type) { | ||
case BULLET_FLAME_TYPE_HEAT -> { | ||
var shrapnelCount = Math.max(1, pd.getInt(PDK_BULLET_SHRAPNEL_COUNT)); | ||
victim.setRemainingFireTicks((int) (shrapnelCount * 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
Oops, something went wrong.