Finish implementing jump upgrade
"living armor is done guys it has a properly functioning upgrade now :LUL:"
This commit is contained in:
parent
59142c2a9c
commit
0003cc7847
4 changed files with 65 additions and 10 deletions
|
@ -35,7 +35,7 @@ import java.util.stream.Collectors;
|
|||
* - [ ] Grave Digger
|
||||
* - [ ] Grim Reaper Sprint
|
||||
* - [ ] Health boost
|
||||
* - [-] Jump
|
||||
* - [x] Jump
|
||||
* - [ ] Knockback Resist
|
||||
* - [ ] Melee Damage
|
||||
* - [ ] Night Sight
|
||||
|
|
|
@ -3,8 +3,10 @@ package com.wayoftime.bloodmagic.core.living;
|
|||
import com.wayoftime.bloodmagic.BloodMagic;
|
||||
import com.wayoftime.bloodmagic.core.RegistrarBloodMagicLivingArmor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
|
@ -22,12 +24,33 @@ public class LivingStatusWatcher {
|
|||
return;
|
||||
|
||||
int level = stats.getLevel(RegistrarBloodMagicLivingArmor.UPGRADE_JUMP.getKey());
|
||||
player.motionY += 0.05 * level;
|
||||
double jumpBonus = RegistrarBloodMagicLivingArmor.UPGRADE_JUMP.getBonusValue("jump", level).doubleValue();
|
||||
player.motionY += jumpBonus;
|
||||
|
||||
if (level >= 3) {
|
||||
Vec3d lookVec = player.getLookVec();
|
||||
player.motionX += player.motionX == 0 ? 0 : lookVec.x * 0.07D * level;
|
||||
player.motionZ += player.motionZ == 0 ? 0 : lookVec.z * 0.07D * level;
|
||||
player.motionX += player.motionX == 0 ? 0 : lookVec.x * jumpBonus;
|
||||
player.motionZ += player.motionZ == 0 ? 0 : lookVec.z * jumpBonus;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onDamage(LivingHurtEvent event) {
|
||||
if (!(event.getEntity() instanceof EntityPlayer))
|
||||
return;
|
||||
|
||||
if (event.getSource() != DamageSource.FALL)
|
||||
return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) event.getEntity();
|
||||
LivingStats stats = LivingUtil.applyNewExperience(player, RegistrarBloodMagicLivingArmor.UPGRADE_JUMP, 1);
|
||||
if (stats == null)
|
||||
return;
|
||||
|
||||
int level = stats.getLevel(RegistrarBloodMagicLivingArmor.UPGRADE_JUMP.getKey());
|
||||
double fallBonus = RegistrarBloodMagicLivingArmor.UPGRADE_JUMP.getBonusValue("fall", level).doubleValue();
|
||||
float oldAmount = event.getAmount();
|
||||
float newAmount = oldAmount * Math.max(1F - (float) fallBonus, 0F);
|
||||
event.setAmount(newAmount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class LivingUpgrade {
|
|||
|
||||
@Nonnull
|
||||
public Number getBonusValue(String id, int level) {
|
||||
return bonuses.getOrDefault(id, Bonus.DEFAULT).modifiers.get(level);
|
||||
return bonuses.getOrDefault(id, Bonus.DEFAULT).modifiers.get(level - 1);
|
||||
}
|
||||
|
||||
public LivingUpgrade withAttributeProvider(IAttributeProvider attributeProvider) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue