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
|
@ -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) {
|
||||
|
|
|
@ -1,9 +1,41 @@
|
|||
{
|
||||
"id": "bloodmagic:jump",
|
||||
"levels": [
|
||||
{ "xp": 10, "cost": 1 },
|
||||
{ "xp": 20, "cost": 5 },
|
||||
{ "xp": 30, "cost": 25 },
|
||||
{ "xp": 40, "cost": 125 }
|
||||
]
|
||||
{ "xp": 10, "cost": 3 },
|
||||
{ "xp": 20, "cost": 6 },
|
||||
{ "xp": 30, "cost": 11 },
|
||||
{ "xp": 40, "cost": 23 },
|
||||
{ "xp": 40, "cost": 37 },
|
||||
{ "xp": 40, "cost": 50 },
|
||||
{ "xp": 40, "cost": 70 },
|
||||
{ "xp": 40, "cost": 100 },
|
||||
{ "xp": 40, "cost": 140 },
|
||||
{ "xp": 40, "cost": 200 }
|
||||
],
|
||||
"bonuses": {
|
||||
"jump": [
|
||||
0.1,
|
||||
0.2,
|
||||
0.3,
|
||||
0.4,
|
||||
0.5,
|
||||
0.7,
|
||||
0.75,
|
||||
0.9,
|
||||
1.1,
|
||||
1.3
|
||||
],
|
||||
"fall": [
|
||||
0.1,
|
||||
0.2,
|
||||
0.3,
|
||||
0.4,
|
||||
0.5,
|
||||
0.6,
|
||||
0.7,
|
||||
0.75,
|
||||
0.8,
|
||||
0.85
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue