Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
449 additions
and
229 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package tconstruct.armor; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import tconstruct.library.modifier.IModifyable; | ||
import tconstruct.util.player.TPlayerStats; | ||
import cpw.mods.fml.common.Loader; | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
import cpw.mods.fml.common.gameevent.TickEvent; | ||
|
||
public class ArmorAbilities | ||
{ | ||
//Abilities | ||
boolean morphed; | ||
boolean morphLoaded = Loader.isModLoaded("Morph"); | ||
|
||
@SubscribeEvent | ||
public void playerTick (TickEvent.PlayerTickEvent event) | ||
{ | ||
EntityPlayer player = event.player; | ||
TPlayerStats stats = TPlayerStats.get(player); | ||
if (stats.climbWalls) | ||
{ | ||
double motionX = player.posX - player.lastTickPosX; | ||
double motionZ = player.posZ - player.lastTickPosZ; | ||
double motionY = player.posY - player.lastTickPosY - 0.762; | ||
if (motionY > 0.0D && (motionX == 0D || motionZ == 0D)) | ||
{ | ||
player.fallDistance = 0.0F; | ||
} | ||
} | ||
//TODO: Proper minimap support | ||
/*ItemStack stack = player.inventory.getStackInSlot(8); | ||
if (stack != null && stack.getItem() instanceof ItemMap) | ||
{ | ||
stack.getItem().onUpdate(stack, player.worldObj, player, 8, true); | ||
}*/ | ||
if (!player.isPlayerSleeping()) | ||
{ | ||
ItemStack chest = player.getCurrentArmor(2); | ||
if (chest == null || !(chest.getItem() instanceof IModifyable)) | ||
{ | ||
if (!morphLoaded || !morphed) | ||
PlayerAbilityHelper.setEntitySize(player, 0.6F, 1.8F); | ||
} | ||
else | ||
{ | ||
NBTTagCompound tag = chest.getTagCompound().getCompoundTag(((IModifyable) chest.getItem()).getBaseTagName()); | ||
int dodge = tag.getInteger("Perfect Dodge"); | ||
if (dodge > 0) | ||
{ | ||
if (!morphLoaded || !morphed) | ||
PlayerAbilityHelper.setEntitySize(player, Math.max(0.15F, 0.6F - (dodge * 0.09f)), 1.8F - (dodge * 0.04f)); | ||
} | ||
} | ||
} | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
src/main/java/tconstruct/armor/ArmorAbilitiesClient.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,122 @@ | ||
package tconstruct.armor; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import tconstruct.armor.items.TravelGear; | ||
import tconstruct.client.TControls; | ||
import tconstruct.library.modifier.IModifyable; | ||
import tconstruct.util.player.TPlayerStats; | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
import cpw.mods.fml.common.gameevent.TickEvent; | ||
|
||
public class ArmorAbilitiesClient | ||
{ | ||
Minecraft mc; | ||
TControls controlInstance; | ||
|
||
ItemStack prevFeet; | ||
double prevMotionY; | ||
boolean morphed; | ||
float prevMouseSensitivity; | ||
boolean sprint; | ||
|
||
public ArmorAbilitiesClient(Minecraft mc, TControls p) | ||
{ | ||
this.mc = mc; | ||
this.controlInstance = p; | ||
} | ||
|
||
@SubscribeEvent | ||
public void playerTick (TickEvent.PlayerTickEvent event) | ||
{ | ||
EntityPlayer player = event.player; | ||
TPlayerStats stats = TPlayerStats.get(player); | ||
if (mc.thePlayer.onGround) | ||
{ | ||
controlInstance.landOnGround(); | ||
} | ||
if (stats.climbWalls && player.isCollidedHorizontally && !player.isSneaking()) | ||
{ | ||
player.motionY = 0.1176D; | ||
player.fallDistance = 0.0f; | ||
} | ||
|
||
//Feet changes | ||
ItemStack feet = player.getCurrentArmor(0); | ||
if (feet != null) | ||
{ | ||
if (feet.getItem() instanceof TravelGear && player.stepHeight < 1.0f) | ||
{ | ||
player.stepHeight += 0.6f; | ||
} | ||
if (feet.getItem() instanceof IModifyable && !player.isSneaking()) | ||
{ | ||
NBTTagCompound tag = feet.getTagCompound().getCompoundTag(((IModifyable) feet.getItem()).getBaseTagName()); | ||
int sole = tag.getInteger("Slimy Soles"); | ||
if (sole > 0) | ||
{ | ||
if (!player.isSneaking() && player.onGround && prevMotionY < -0.4) | ||
player.motionY = -prevMotionY * (Math.min(0.99, sole * 0.2)); | ||
} | ||
} | ||
prevMotionY = player.motionY; | ||
} | ||
if (feet != prevFeet) | ||
{ | ||
if (prevFeet != null && prevFeet.getItem() instanceof TravelGear) | ||
player.stepHeight -= 0.6f; | ||
if (feet != null && feet.getItem() instanceof TravelGear) | ||
player.stepHeight += 0.6f; | ||
prevFeet = feet; | ||
} | ||
|
||
//Legs or wing changes | ||
/*ItemStack legs = player.getCurrentArmor(1); | ||
if (legs != null && legs.getItem() instanceof IModifyable) | ||
{ | ||
NBTTagCompound tag = legs.getTagCompound().getCompoundTag(((IModifyable) legs.getItem()).getBaseTagName()); | ||
if (player.isSprinting()) | ||
{ | ||
if (!sprint) | ||
{ | ||
sprint = true; | ||
int sprintboost = tag.getInteger("Sprint Assist"); | ||
if (player.isSprinting() && sprintboost > 0) | ||
{ | ||
prevMouseSensitivity = gs.mouseSensitivity; | ||
gs.mouseSensitivity *= 1 - (0.15 * sprintboost); | ||
} | ||
} | ||
} | ||
else if (sprint) | ||
{ | ||
sprint = false; | ||
gs.mouseSensitivity = prevMouseSensitivity; | ||
} | ||
}*/ | ||
if (!player.isPlayerSleeping() && !morphed) | ||
{ | ||
ItemStack chest = player.getCurrentArmor(2); | ||
if (chest == null || !(chest.getItem() instanceof IModifyable)) | ||
{ | ||
PlayerAbilityHelper.setEntitySize(player, 0.6F, 1.8F); | ||
} | ||
else | ||
{ | ||
NBTTagCompound tag = chest.getTagCompound().getCompoundTag(((IModifyable) chest.getItem()).getBaseTagName()); | ||
int dodge = tag.getInteger("Perfect Dodge"); | ||
if (dodge > 0) | ||
{ | ||
PlayerAbilityHelper.setEntitySize(player, Math.max(0.15F, 0.6F - (dodge * 0.09f)), 1.8F - (dodge * 0.04f)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
EntityPlayer getPlayer () | ||
{ | ||
return mc.thePlayer; | ||
} | ||
} |
Oops, something went wrong.