mirror of
https://github.com/GTNewHorizons/Avaritia.git
synced 2026-11-28 15:56:03 +00:00
fix the issue where the vertical acceleration was incorrect due to being different from de's calculation (#85)
This commit is contained in:
1 parent
fe88f453a5
commit
9af2a97ba7
4 files changed
+62
-18
No files matched your search
+16
-4
@@ -27,6 +27,21 @@ public class InfinityArmorConfigHelpers {
|
||||
return player.isSprinting() || player.isSneaking();
|
||||
}
|
||||
|
||||
public static boolean isEffectiveOnSprint(ItemStack stack) {
|
||||
if (!InfinityArmorConfigHelpers.getBoolean(stack, InfinityArmorConfigKeys.ARMOR_EFFECTIVE_ON_SPRINT, false)) {
|
||||
return true;
|
||||
}
|
||||
return Compat.draconicEvolution && InfinityConfigProfileBridge.isCtrlDown();
|
||||
}
|
||||
|
||||
public static boolean isSpaceDown() {
|
||||
return Compat.draconicEvolution && InfinityConfigProfileBridge.isSpaceDown();
|
||||
}
|
||||
|
||||
public static boolean isShiftDown() {
|
||||
return Compat.draconicEvolution && InfinityConfigProfileBridge.isShiftDown();
|
||||
}
|
||||
|
||||
public static float getConditionalMultiplier(ItemStack stack, EntityPlayer player, String key, float defaultValue) {
|
||||
float configuredValue = getFloat(stack, key, defaultValue);
|
||||
if (!getBoolean(stack, InfinityArmorConfigKeys.ARMOR_SPRINT_ONLY, false)) {
|
||||
@@ -38,9 +53,6 @@ public class InfinityArmorConfigHelpers {
|
||||
public static float getConditionalFlightMultiplier(ItemStack stack, EntityPlayer player, String key,
|
||||
float defaultValue) {
|
||||
float configuredValue = getFloat(stack, key, defaultValue);
|
||||
if (!getBoolean(stack, InfinityArmorConfigKeys.ARMOR_EFFECTIVE_ON_SPRINT, false)) {
|
||||
return configuredValue;
|
||||
}
|
||||
return isSprintConditionActive(stack, player) ? configuredValue : 0F;
|
||||
return isEffectiveOnSprint(stack) ? configuredValue : 0F;
|
||||
}
|
||||
}
|
||||
+26
-13
@@ -7,9 +7,9 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import fox.spiteful.avaritia.Config;
|
||||
import fox.spiteful.avaritia.compat.Compat;
|
||||
import fox.spiteful.avaritia.items.LudicrousItems;
|
||||
@@ -27,11 +27,12 @@ public class InfinityArmorRuntimeHandler {
|
||||
private final Set<String> playersWithFoot = new HashSet<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public void updatePlayerAbilityStatus(LivingUpdateEvent event) {
|
||||
if (!(event.entityLiving instanceof EntityPlayer player)) {
|
||||
public void updatePlayerAbilityStatus(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = event.player;
|
||||
String key = playerKey(player);
|
||||
updateFlight(player, key);
|
||||
updateFootAbilities(player, key);
|
||||
@@ -126,13 +127,27 @@ public class InfinityArmorRuntimeHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean jumping = ((EntityLivingBaseAccessor) player).getIsJumping();
|
||||
float verticalMultiplier = InfinityArmorAbilityResolver.getFlightVerticalModifier(chest, player);
|
||||
float accelerationScale = resolveVerticalAccelerationScale(verticalMultiplier);
|
||||
if (jumping && player.motionY > 0 && player.motionY < 2) {
|
||||
player.motionY *= accelerationScale;
|
||||
} else if (player.isSneaking() && player.motionY < 0 && player.motionY > -2) {
|
||||
player.motionY *= accelerationScale;
|
||||
if (player.onGround || player.motionY == 0 || (Compat.draconicEvolution && verticalMultiplier <= 0F)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean spaceDown = InfinityArmorConfigHelpers.isSpaceDown();
|
||||
boolean shiftDown = InfinityArmorConfigHelpers.isShiftDown();
|
||||
if (spaceDown && !shiftDown) {
|
||||
player.motionY = 0.225D * verticalMultiplier;
|
||||
} else if (shiftDown && !spaceDown) {
|
||||
player.motionY = -0.225D * verticalMultiplier;
|
||||
}
|
||||
|
||||
if (!Compat.draconicEvolution) {
|
||||
boolean jumping = ((EntityLivingBaseAccessor) player).getIsJumping();
|
||||
float accelerationScale = resolveVerticalAccelerationScale();
|
||||
if (jumping && player.motionY > 0 && player.motionY < 2) {
|
||||
player.motionY *= accelerationScale;
|
||||
} else if (player.isSneaking() && player.motionY < 0 && player.motionY > -2) {
|
||||
player.motionY *= accelerationScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,10 +200,8 @@ public class InfinityArmorRuntimeHandler {
|
||||
return speed;
|
||||
}
|
||||
|
||||
private float resolveVerticalAccelerationScale(float configuredValue) {
|
||||
if (Compat.draconicEvolution) {
|
||||
return configuredValue <= 0F ? 1.0F : 1.5F + (configuredValue * 0.1F);
|
||||
}
|
||||
private float resolveVerticalAccelerationScale() {
|
||||
return 1.5F + (LEGACY_VERTICAL_ACCELERATION * 0.1F);
|
||||
}
|
||||
|
||||
}
|
||||
+16
@@ -2,6 +2,7 @@ package fox.spiteful.avaritia.compat.draconicevolution;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.utils.IConfigurableItem;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
@@ -19,4 +20,19 @@ public class InfinityConfigProfileBridge {
|
||||
public static float getFloat(ItemStack stack, String key, float defaultValue) {
|
||||
return IConfigurableItem.ProfileHelper.getFloat(stack, key, defaultValue);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "DraconicEvolution")
|
||||
public static boolean isSpaceDown() {
|
||||
return DraconicEvolution.proxy.isSpaceDown();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "DraconicEvolution")
|
||||
public static boolean isShiftDown() {
|
||||
return DraconicEvolution.proxy.isShiftDown();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "DraconicEvolution")
|
||||
public static boolean isCtrlDown() {
|
||||
return DraconicEvolution.proxy.isCtrlDown();
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import fox.spiteful.avaritia.Avaritia;
|
||||
import fox.spiteful.avaritia.Config;
|
||||
@@ -93,7 +94,9 @@ public class LudicrousItems {
|
||||
infinity_axe = register(new ItemAxeInfinity(), "Infinity_Axe");
|
||||
// morv_in_a_box = register(new ItemMorvInABox(), "MorvInABox");
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new InfinityArmorRuntimeHandler());
|
||||
InfinityArmorRuntimeHandler handler = new InfinityArmorRuntimeHandler();
|
||||
MinecraftForge.EVENT_BUS.register(handler);
|
||||
FMLCommonHandler.instance().bus().register(handler);
|
||||
}
|
||||
|
||||
public static boolean isInfinite(EntityPlayer player) {
|
||||
|
||||
Reference in new issue
Block a user