Experimented with loosening traction with an Armour Upgrade (Forward works, strafing fails)

This commit is contained in:
WayofTime 2016-09-26 06:49:44 -04:00
parent a1eb8aad56
commit 82a73ba0cd
4 changed files with 53 additions and 16 deletions

View file

@ -86,4 +86,9 @@ public abstract class LivingArmourUpgrade
{ {
return 0; return 0;
} }
public boolean runOnClient()
{
return false;
}
} }

View file

@ -8,7 +8,6 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
@ -29,9 +28,13 @@ import net.minecraftforge.common.ISpecialArmor;
import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
import WayofTime.bloodmagic.api.saving.SoulNetwork; import WayofTime.bloodmagic.api.saving.SoulNetwork;
import WayofTime.bloodmagic.api.util.helper.NBTHelper; import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
@ -47,7 +50,6 @@ import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import org.lwjgl.input.Keyboard;
public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider
{ {
@ -361,8 +363,6 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
} }
} }
} }
return;
} }
if (this == ModItems.LIVING_ARMOUR_CHEST) if (this == ModItems.LIVING_ARMOUR_CHEST)

View file

@ -156,8 +156,16 @@ public class LivingArmour implements ILivingArmour
continue; continue;
} }
if (world.isRemote && upgrade.runOnClient())
{
upgrade.onTick(world, player, this); upgrade.onTick(world, player, this);
} }
}
if (world.isRemote)
{
return;
}
List<String> allowedUpgradesList = new ArrayList<String>(); List<String> allowedUpgradesList = new ArrayList<String>();
for (ItemStack stack : player.inventory.mainInventory) for (ItemStack stack : player.inventory.mainInventory)

View file

@ -1,8 +1,8 @@
package WayofTime.bloodmagic.livingArmour.downgrade; package WayofTime.bloodmagic.livingArmour.downgrade;
import net.minecraft.block.BlockIce;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; import WayofTime.bloodmagic.api.livingArmour.ILivingArmour;
@ -13,9 +13,6 @@ public class LivingArmourUpgradeSlippery extends LivingArmourUpgrade
public static final int[] costs = new int[] { -50 }; public static final int[] costs = new int[] { -50 };
public static final int[] slipperyDuration = new int[] { 30 * 20 }; public static final int[] slipperyDuration = new int[] { 30 * 20 };
public double prevMotionX = 0;
public double prevMotionZ = 0;
public LivingArmourUpgradeSlippery(int level) public LivingArmourUpgradeSlippery(int level)
{ {
super(level); super(level);
@ -24,20 +21,47 @@ public class LivingArmourUpgradeSlippery extends LivingArmourUpgrade
@Override @Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
{ {
double weight = 0.05;
if (world.isRemote && player.onGround) if (world.isRemote && player.onGround)
{ {
if (player.moveForward == 0) // if (player.moveForward == 0)
{ {
player.motionX = (player.motionX - this.prevMotionX) * weight + this.prevMotionX;
player.motionZ = (player.motionZ - this.prevMotionZ) * weight + this.prevMotionZ;
player.velocityChanged = true; float f6 = 0.91F;
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(player.posX, player.getEntityBoundingBox().minY - 1.0D, player.posZ);
if (player.onGround)
{
f6 = world.getBlockState(blockpos$pooledmutableblockpos).getBlock().slipperiness * 0.91F;
}
player.motionX /= (double) (f6 / 0.91);
player.motionZ /= (double) (f6 / 0.91);
float f7 = 0.16277136F / (f6 * f6 * f6);
float f8;
if (player.onGround)
{
f8 = player.getAIMoveSpeed() * f7;
} else
{
f8 = player.jumpMovementFactor;
}
player.moveRelative(-player.moveStrafing, -player.moveForward, f8);
player.moveRelative(player.moveStrafing, player.moveForward, f8 / 10);
player.motionX *= 0.90;
player.motionY *= 0.90;
}
} }
} }
this.prevMotionX = player.motionX; @Override
this.prevMotionZ = player.motionZ; public boolean runOnClient()
{
return true;
} }
@Override @Override