-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devour-spell' into 1.19.2
- Loading branch information
Showing
18 changed files
with
319 additions
and
2 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
114 changes: 114 additions & 0 deletions
114
src/main/java/io/redspace/ironsspellbooks/entity/spells/devour_jaw/DevourJaw.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,114 @@ | ||
package io.redspace.ironsspellbooks.entity.spells.devour_jaw; | ||
|
||
import io.redspace.ironsspellbooks.damage.DamageSources; | ||
import io.redspace.ironsspellbooks.entity.spells.AoeEntity; | ||
import io.redspace.ironsspellbooks.registries.EntityRegistry; | ||
import io.redspace.ironsspellbooks.registries.MobEffectRegistry; | ||
import io.redspace.ironsspellbooks.registries.SoundRegistry; | ||
import io.redspace.ironsspellbooks.spells.SpellType; | ||
import io.redspace.ironsspellbooks.util.ParticleHelper; | ||
import net.minecraft.core.particles.ParticleOptions; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.world.effect.MobEffectInstance; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.projectile.Projectile; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraftforge.network.NetworkHooks; | ||
|
||
public class DevourJaw extends AoeEntity { | ||
public DevourJaw(EntityType<? extends Projectile> pEntityType, Level pLevel) { | ||
super(pEntityType, pLevel); | ||
} | ||
|
||
LivingEntity target; | ||
|
||
public DevourJaw(Level level, LivingEntity owner, LivingEntity target) { | ||
this(EntityRegistry.DEVOUR_JAW.get(), level); | ||
setOwner(owner); | ||
this.target = target; | ||
} | ||
|
||
//dont need to serialize, dont need it only client either | ||
public int vigorLevel; | ||
|
||
@Override | ||
public void applyEffect(LivingEntity target) { | ||
if (target == this.target) | ||
if (DamageSources.applyDamage(target, getDamage(), SpellType.DEVOUR_SPELL.getDamageSource(this, getOwner()), SpellType.DEVOUR_SPELL.getSchoolType()) && getOwner() instanceof LivingEntity livingOwner) { | ||
livingOwner.heal(getDamage() * .15f); | ||
if (target.isDeadOrDying()) { | ||
var oldVigor = livingOwner.getEffect(MobEffectRegistry.VIGOR.get()); | ||
var addition = 0; | ||
if (oldVigor != null) | ||
addition = oldVigor.getAmplifier() + 1; | ||
livingOwner.addEffect(new MobEffectInstance(MobEffectRegistry.VIGOR.get(), 20 * 60, vigorLevel + addition, false, false, true)); | ||
livingOwner.heal((vigorLevel + 1) * 2); | ||
} | ||
} | ||
|
||
} | ||
|
||
public final int waitTime = 5; | ||
public final int warmupTime = waitTime + 8; | ||
public final int deathTime = warmupTime + 8; | ||
|
||
@Override | ||
public void tick() { | ||
if (tickCount < waitTime) { | ||
if (this.target != null) | ||
setPos(this.target.position()); | ||
} else if (tickCount == waitTime) { | ||
this.playSound(SoundRegistry.DEVOUR_BITE.get(), 2, 1); | ||
} else if (tickCount == warmupTime) { | ||
if (level.isClientSide) { | ||
float y = this.getYRot(); | ||
int countPerSide = 25; | ||
//These particles were not at all what I intended. But they're cooler. no clue how it works | ||
for (int i = -countPerSide; i < countPerSide; i++) { | ||
Vec3 motion = new Vec3(0, Math.abs(countPerSide) - i, countPerSide * .5f).yRot(y).normalize().multiply(.4f, .8f, .4f); | ||
level.addParticle(ParticleHelper.BLOOD, getX(), getY() + .5f, getZ(), motion.x, motion.y, motion.z); | ||
} | ||
} else { | ||
checkHits(); | ||
} | ||
} else if (tickCount > deathTime) | ||
discard(); | ||
} | ||
|
||
@Override | ||
protected float getInflation() { | ||
return 2f; | ||
} | ||
|
||
@Override | ||
public boolean shouldBeSaved() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void refreshDimensions() { | ||
return; | ||
} | ||
|
||
@Override | ||
public void ambientParticles() { | ||
return; | ||
} | ||
|
||
@Override | ||
public float getParticleCount() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public ParticleOptions getParticle() { | ||
return ParticleHelper.BLOOD; | ||
} | ||
|
||
@Override | ||
public Packet<?> getAddEntityPacket() { | ||
return NetworkHooks.getEntitySpawningPacket(this); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
src/main/java/io/redspace/ironsspellbooks/entity/spells/devour_jaw/DevourJawRenderer.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,79 @@ | ||
package io.redspace.ironsspellbooks.entity.spells.devour_jaw; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import com.mojang.math.Vector3f; | ||
import io.redspace.ironsspellbooks.IronsSpellbooks; | ||
import net.minecraft.client.model.EvokerFangsModel; | ||
import net.minecraft.client.model.geom.ModelLayers; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.entity.EntityRenderer; | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||
import net.minecraft.client.renderer.texture.OverlayTexture; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.Mth; | ||
|
||
public class DevourJawRenderer extends EntityRenderer<DevourJaw> { | ||
|
||
private final DevourJawModel model; | ||
|
||
public DevourJawRenderer(EntityRendererProvider.Context pContext) { | ||
super(pContext); | ||
this.model = new DevourJawModel(pContext.bakeLayer(ModelLayers.EVOKER_FANGS)); | ||
} | ||
|
||
public void render(DevourJaw entity, float yaw, float partialTicks, PoseStack poseStack, MultiBufferSource multiBufferSource, int light) { | ||
if (entity.tickCount < entity.waitTime) | ||
return; | ||
float f = entity.tickCount + partialTicks; | ||
poseStack.pushPose(); | ||
poseStack.mulPose(Vector3f.YP.rotationDegrees(-entity.getYRot())); | ||
poseStack.scale(-1, -1, 1); | ||
poseStack.scale(1.85f, 1.85f, 1.85f); | ||
this.model.setupAnim(entity, f, 0.0F, 0.0F, entity.getYRot(), entity.getXRot()); | ||
VertexConsumer vertexconsumer = multiBufferSource.getBuffer(RenderType.entityCutoutNoCull(getTextureLocation(entity))); | ||
this.model.renderToBuffer(poseStack, vertexconsumer, light, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); | ||
poseStack.popPose(); | ||
super.render(entity, yaw, partialTicks, poseStack, multiBufferSource, light); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getTextureLocation(DevourJaw pEntity) { | ||
return IronsSpellbooks.id("textures/entity/devour_jaw.png"); | ||
} | ||
|
||
static class DevourJawModel extends EvokerFangsModel<DevourJaw> { | ||
private final ModelPart root; | ||
private final ModelPart base; | ||
private final ModelPart upperJaw; | ||
private final ModelPart lowerJaw; | ||
|
||
public DevourJawModel(ModelPart pRoot) { | ||
super(pRoot); | ||
this.root = pRoot; | ||
this.base = pRoot.getChild("base"); | ||
this.upperJaw = pRoot.getChild("upper_jaw"); | ||
this.lowerJaw = pRoot.getChild("lower_jaw"); | ||
} | ||
|
||
@Override | ||
public void setupAnim(DevourJaw entity, float time, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) { | ||
time -= entity.waitTime; | ||
float interval = entity.warmupTime - entity.waitTime; | ||
|
||
float f = Mth.clamp(time / interval, 0, 1); | ||
f = 1 - f * f * f * f; | ||
this.upperJaw.zRot = (float) Math.PI - f * 0.35F * (float) Math.PI; | ||
this.lowerJaw.zRot = (float) Math.PI + f * 0.35F * (float) Math.PI; | ||
|
||
float f2 = (time / interval); | ||
f2 = .5f * Mth.cos(.5f * Mth.PI * (f2 - 1)) + .5f; | ||
f2 *= f2; | ||
this.upperJaw.y = -18F * f2 + 16f; | ||
this.lowerJaw.y = this.upperJaw.y; | ||
this.base.y = this.upperJaw.y; | ||
} | ||
} | ||
} |
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
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
93 changes: 93 additions & 0 deletions
93
src/main/java/io/redspace/ironsspellbooks/spells/blood/DevourSpell.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,93 @@ | ||
package io.redspace.ironsspellbooks.spells.blood; | ||
|
||
import io.redspace.ironsspellbooks.capabilities.magic.CastTargetingData; | ||
import io.redspace.ironsspellbooks.capabilities.magic.PlayerMagicData; | ||
import io.redspace.ironsspellbooks.entity.spells.devour_jaw.DevourJaw; | ||
import io.redspace.ironsspellbooks.spells.*; | ||
import io.redspace.ironsspellbooks.util.Utils; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.MutableComponent; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.sounds.SoundEvent; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.level.Level; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
|
||
public class DevourSpell extends AbstractSpell { | ||
public DevourSpell() { | ||
this(1); | ||
} | ||
|
||
@Override | ||
public List<MutableComponent> getUniqueInfo(LivingEntity caster) { | ||
return List.of( | ||
Component.translatable("ui.irons_spellbooks.damage", Utils.stringTruncation(getDamage(caster), 1)), | ||
Component.translatable("ui.irons_spellbooks.max_hp_on_kill", getHpBonus(caster)) | ||
); | ||
} | ||
|
||
public static DefaultConfig defaultConfig = new DefaultConfig() | ||
.setMinRarity(SpellRarity.UNCOMMON) | ||
.setSchool(SchoolType.BLOOD) | ||
.setMaxLevel(10) | ||
.setCooldownSeconds(20) | ||
.build(); | ||
|
||
public DevourSpell(int level) { | ||
super(SpellType.DEVOUR_SPELL); | ||
this.setLevel(level); | ||
this.manaCostPerLevel = 4; | ||
this.baseSpellPower = 6; | ||
this.spellPowerPerLevel = 1; | ||
this.castTime = 0; | ||
this.baseManaCost = 25; | ||
|
||
} | ||
|
||
@Override | ||
public Optional<SoundEvent> getCastStartSound() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Optional<SoundEvent> getCastFinishSound() { | ||
return Optional.empty(); | ||
} | ||
|
||
|
||
@Override | ||
public boolean checkPreCastConditions(Level level, LivingEntity entity, PlayerMagicData playerMagicData) { | ||
return Utils.preCastTargetHelper(level, entity, playerMagicData, getSpellType(), 6, .1f); | ||
} | ||
|
||
@Override | ||
public void onCast(Level world, LivingEntity entity, PlayerMagicData playerMagicData) { | ||
if (playerMagicData.getAdditionalCastData() instanceof CastTargetingData targetData) { | ||
var targetEntity = targetData.getTarget((ServerLevel) world); | ||
if (targetEntity != null) { | ||
targetEntity.setDeltaMovement(targetEntity.getDeltaMovement().add(targetEntity.position().subtract(entity.position()).scale(-.25f))); | ||
targetEntity.hurtMarked = true; | ||
DevourJaw devour = new DevourJaw(world, entity, targetEntity); | ||
devour.setPos(targetEntity.position()); | ||
devour.setYRot(entity.getYRot()); | ||
devour.setDamage(getDamage(entity)); | ||
devour.vigorLevel = (getHpBonus(entity) / 2) - 1; | ||
world.addFreshEntity(devour); | ||
} | ||
} | ||
|
||
super.onCast(world, entity, playerMagicData); | ||
} | ||
|
||
public float getDamage(LivingEntity caster) { | ||
return getSpellPower(caster); | ||
} | ||
|
||
public int getHpBonus(LivingEntity caster) { | ||
return 2 * (int) (getSpellPower(caster) * .25f); | ||
} | ||
|
||
} |
Oops, something went wrong.