Skip to content

Commit

Permalink
Finish armor porting
Browse files Browse the repository at this point in the history
  • Loading branch information
mDiyo committed Jul 4, 2014
1 parent c13c8f8 commit 2bb35b1
Show file tree
Hide file tree
Showing 10 changed files with 449 additions and 229 deletions.
92 changes: 92 additions & 0 deletions resources/assets/tinker/manuals/firstday.xml
Expand Up @@ -21,6 +21,11 @@ By Skyla</text>
<icon>workbench</icon>
<jump>5</jump>
</link>
<link>
<text>Armor Modifiers</text>
<icon>travelvest</icon>
<jump>4</jump>
</link>
</page>

<page type="text">
Expand Down Expand Up @@ -219,4 +224,91 @@ Note: The Smeltery is required to process all metals, including iron.</text>
</recipe>
</page>

<page type="text">
<text>The following armor modifiers seem to be missing names or in flux. No word is available on the accuracy or new home of these pages.</text>
</page>

<page type="modifier">
<tooltype>travelgoggles</tooltype>
<recipe>nightvision</recipe>
</page>

<page type="crafting">
<text>Vision</text>
<recipe>
<name>dodge</name>
<size>two</size>
</recipe>
</page>

<page type="crafting">
<text>Corrupted Sight</text>
<recipe>
<name>stealth</name>
<size>two</size>
</recipe>
</page>

<page type="modifier">
<tooltype>travelwings</tooltype>
<recipe>doublejump</recipe>
</page>

<page type="crafting">
<text>Freefall</text>
<recipe>
<name>doublejump</name>
<size>two</size>
</recipe>
</page>

<page type="crafting">
<text>Aer</text>
<recipe>
<name>featherfall</name>
<size>three</size>
</recipe>
</page>

<page type="crafting">
<text>Travel</text>
<recipe>
<name>doublejumpboots</name>
<size>two</size>
</recipe>
</page>

<page type="modifier">
<tooltype>travelboots</tooltype>
<recipe>waterwalk</recipe>
</page>

<page type="modifier">
<tooltype>travelboots</tooltype>
<recipe>leadboots</recipe>
</page>

<page type="modifier">
<tooltype>travelboots</tooltype>
<recipe>slimysoles</recipe>
</page>

<page type="modifier">
<tooltype>travelgloves</tooltype>
<recipe>glovehaste</recipe>
</page>

<page type="crafting">
<text>Flesh</text>
<recipe>
<name>gloveclimb</name>
<size>two</size>
</recipe>
</page>

<page type="modifier">
<tooltype>travelgloves</tooltype>
<recipe>gloveknuckles</recipe>
</page>

</book>
59 changes: 59 additions & 0 deletions src/main/java/tconstruct/armor/ArmorAbilities.java
@@ -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 src/main/java/tconstruct/armor/ArmorAbilitiesClient.java
@@ -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;
}
}

0 comments on commit 2bb35b1

Please sign in to comment.