Skip to content

Commit

Permalink
pull in some armor stuff from 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
progwml6 committed Feb 8, 2014
1 parent 8fdef45 commit 86f8a20
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 20 deletions.
7 changes: 7 additions & 0 deletions src/main/java/tconstruct/client/TClientEvents.java
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
Expand Down Expand Up @@ -95,6 +96,8 @@ public void postStitch (TextureStitchEvent.Post event)
//public static int right_height = 39;
Random rand = new Random();
int updateCounter = 0;

GameSettings gs = Minecraft.getMinecraft().gameSettings;

/* HUD */
@SubscribeEvent
Expand Down Expand Up @@ -222,6 +225,10 @@ else if (i * 2 + 1 == health)
GuiIngameForge.left_height += 10;

event.setCanceled(true);
if (event.type == ElementType.CROSSHAIRS && gs.thirdPersonView != 0)
{
event.setCanceled(true);
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/tconstruct/client/TClientTickHandler.java
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import tconstruct.TConstruct;
import tconstruct.common.TRepo;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
Expand All @@ -12,7 +13,7 @@ public class TClientTickHandler
{
Minecraft mc = Minecraft.getMinecraft();

//TControls controlInstance = ((TProxyClient)TConstruct.proxy).controlInstance;
TControls controlInstance = ((TProxyClient)TConstruct.proxy).controlInstance;
public TClientTickHandler()
{
}
Expand All @@ -26,8 +27,8 @@ public void onTick (ClientTickEvent event)
TRepo.oreBerry.setGraphicsLevel(Blocks.leaves.field_150121_P);
TRepo.oreBerrySecond.setGraphicsLevel(Blocks.leaves.field_150121_P);
TRepo.slimeLeaves.setGraphicsLevel(Blocks.leaves.field_150121_P);
/*if (mc.thePlayer != null && !mc.thePlayer.isAirBorne)
controlInstance.landOnGround();*/
if (mc.thePlayer != null && mc.thePlayer.onGround)
controlInstance.landOnGround();
}
}

Expand Down
21 changes: 9 additions & 12 deletions src/main/java/tconstruct/client/TControls.java
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.potion.Potion;
import tconstruct.TConstruct;
import tconstruct.client.event.EventCloakRender;
import tconstruct.client.tabs.TabRegistry;
Expand All @@ -24,7 +25,7 @@ public class TControls extends TKeyHandler
static Minecraft mc;

boolean jumping;
boolean doubleJump = true;
int midairJumps = 0;
boolean climbing = false;
boolean onGround = false;
boolean onStilts = false;
Expand Down Expand Up @@ -64,17 +65,13 @@ public void keyDown (Type types, KeyBinding kb, boolean tickEnd, boolean isRepea
{
EventCloakRender.instance.refreshCapes();
}
/*if (kb == jumpKey) //Double jump
if (kb == jumpKey) //Double jump
{
if (mc.thePlayer.capabilities.isCreativeMode)
return;

if (jumping && !doubleJump)
if (jumping && midairJumps >0)
{
System.out.println("Jump!");
//if (player == null)
//player = mc.thePlayer;
mc.thePlayer.motionY = 0.42D;
mc.thePlayer.fallDistance = 0;

Expand All @@ -83,13 +80,13 @@ public void keyDown (Type types, KeyBinding kb, boolean tickEnd, boolean isRepea
mc.thePlayer.motionY += (double) ((float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
}

doubleJump = true;
resetFallDamage(mc.thePlayer.username);
midairJumps --;
resetFallDamage(mc.thePlayer.getDisplayName());
}

if (!jumping)
jumping = mc.thePlayer.isAirBorne;
}*/
}
}
/*else if (kb == stiltsKey) //Stilts
{
Expand Down Expand Up @@ -118,13 +115,13 @@ public void keyUp (Type types, KeyBinding kb, boolean tickEnd)

public void landOnGround ()
{
doubleJump = false;
midairJumps = 0;
jumping = false;
}

public void resetControls ()
{
doubleJump = false;
midairJumps = 0;
jumping = false;
climbing = false;
onGround = false;
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/tconstruct/client/gui/CraftingStationGui.java
Expand Up @@ -88,6 +88,20 @@ void drawModularArmorStats (ItemStack stack, ArmorCore tool, NBTTagCompound tags
fontRendererObj.drawString(StatCollector.translateToLocal("gui.toolstation18") + tags.getInteger("Modifiers"), xSize + 8, base + offset * 10, 0xffffff);
offset++;
}
boolean displayToolTips = true;
int tipNum = 0;
while (displayToolTips)
{
tipNum++;
String tooltip = "ModifierTip" + tipNum;
if (tags.hasKey(tooltip))
{
String tipName = tags.getString(tooltip);
fontRendererObj.drawString("- " + tipName, xSize + 8, base + (offset + tipNum) * 10, 0xffffff);
}
else
displayToolTips = false;
}
}

void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/tconstruct/common/TRecipes.java
Expand Up @@ -88,6 +88,7 @@
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.util.IPattern;
import tconstruct.modifiers.armor.AModDamageBoost;
import tconstruct.modifiers.armor.AModDoubleJump;
import tconstruct.modifiers.armor.AModHealthBoost;
import tconstruct.modifiers.armor.AModKnockbackResistance;
import tconstruct.modifiers.armor.AModMoveSpeed;
Expand Down Expand Up @@ -399,6 +400,8 @@ protected static void addRecipesForToolBuilder ()
tb.registerArmorMod(new AModDamageBoost(4, chest, new ItemStack[] { new ItemStack(Blocks.quartz_block, 1, Short.MAX_VALUE) }, new int[] { 1 }, true, 5, 1));
tb.registerArmorMod(new AModProtection(5, allArmors, new ItemStack[] { new ItemStack(TRepo.largePlate, 1, 2) }, new int[] { 2 }));

tb.registerArmorMod(new AModDoubleJump(new ItemStack[] { new ItemStack(Items.ghast_tear), new ItemStack(TRepo.slimeGel, 1, 0), new ItemStack(TRepo.slimeGel, 1, 1) }));

TConstructRegistry.registerActiveToolMod(new TActiveOmniMod());
}

Expand Down
19 changes: 17 additions & 2 deletions src/main/java/tconstruct/items/armor/ExoArmor.java
Expand Up @@ -68,9 +68,24 @@ public void addInformation (ItemStack stack, EntityPlayer player, List list, boo
{
if (!stack.hasTagCompound())
return;
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(SET_NAME);
double protection = tag.getDouble("protection");
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(SET_NAME);
double protection = tags.getDouble("protection");
if (protection > 0)
list.add("\u00a7aProtection: " + protection + "%");
boolean displayToolTips = true;
int tipNum = 0;
while (displayToolTips)
{
tipNum++;
String tooltip = "Tooltip" + tipNum;
if (tags.hasKey(tooltip))
{
String tipName = tags.getString(tooltip);
if (!tipName.equals(""))
list.add(tipName);
}
else
displayToolTips = false;
}
}
}
60 changes: 60 additions & 0 deletions src/main/java/tconstruct/library/armor/AModInteger.java
@@ -0,0 +1,60 @@
package tconstruct.library.armor;

import java.util.EnumSet;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

/* Adds an integer NBTTag */

public class AModInteger extends ArmorMod
{
public final int modifyCount;
public final int amount;
public final String color;
public final String tooltipName;

public AModInteger(int effect, String dataKey, EnumSet<EnumArmorPart> armorTypes, ItemStack[] items, int count, int increase, String c, String tip)
{
super(effect, dataKey, armorTypes, items);
this.modifyCount = count;
this.amount = increase;
color = c;
tooltipName = tip;
}

@Override
protected boolean canModify (ItemStack armor, ItemStack[] input)
{
ArmorCore item = (ArmorCore) armor.getItem();
if (armorTypes.contains(item.armorPart))
{
NBTTagCompound tags = armor.getTagCompound().getCompoundTag(getTagName());
return tags.getInteger("Modifiers") >= modifyCount;
}
return false;
}

@Override
public void modify (ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(getTagName());
if (tags.hasKey(key))
{
int increase = tags.getInteger(key);
increase += this.amount;
tags.setInteger(key, increase);
}
else
{
tags.setInteger(key, amount);
}

int modifiers = tags.getInteger("Modifiers");
modifiers -= modifyCount;
tags.setInteger("Modifiers", modifiers);

addToolTip(tool, color + tooltipName, color + key);
}

}
@@ -1,12 +1,10 @@
package tconstruct.modifiers.armor;
package tconstruct.library.armor;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;

import net.minecraft.item.ItemStack;
import tconstruct.library.armor.ArmorMod;
import tconstruct.library.armor.EnumArmorPart;

public abstract class ArmorModTypeFilter extends ArmorMod
{
Expand Down
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import tconstruct.library.armor.ArmorCore;
import tconstruct.library.armor.ArmorModTypeFilter;
import tconstruct.library.armor.EnumArmorPart;

//TODO: Condense attribute modifiers into one class
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/tconstruct/modifiers/armor/AModDoubleJump.java
@@ -0,0 +1,72 @@
package tconstruct.modifiers.armor;

import java.util.EnumSet;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.armor.AModInteger;
import tconstruct.library.armor.ArmorCore;
import tconstruct.library.armor.EnumArmorPart;

public class AModDoubleJump extends AModInteger
{
public AModDoubleJump(ItemStack[] items)
{
super(6, "Double-Jump", EnumSet.of(EnumArmorPart.SHOES), items, 5, 1, "\u00a7a", "Double-Jump");
}

@Override
protected boolean canModify (ItemStack armor, ItemStack[] input)
{
ArmorCore item = (ArmorCore) armor.getItem();
if (armorTypes.contains(item.armorPart))
{
NBTTagCompound tags = armor.getTagCompound().getCompoundTag(getTagName());
return tags.getInteger("Modifiers") >= modifyCount && tags.getInteger("Double-Jump") < 3;
}
return false;
}

@Override
protected int addToolTip (ItemStack tool, String tooltip, String modifierTip)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(getTagName());
int tipNum = 0;
while (true)
{
tipNum++;
String tip = "Tooltip" + tipNum;
if (!tags.hasKey(tip))
{
tags.setString(tip, tooltip);
String modTip = "ModifierTip" + tipNum;
tags.setString(modTip, modifierTip);
return tipNum;
}
else
{
String tag = tags.getString(tip);
if (tag.contains("Double-Jump") || tag.contains("Triple-Jump"))
{
tags.setString(tip, getProperName(tooltip, tag));
String modTip = "ModifierTip" + tipNum;
tag = tags.getString(modTip);
tags.setString(modTip, getProperName(modifierTip, tag));
return tipNum;
}
}
}
}

@Override
protected String getProperName (String tooltip, String tag)
{
if (tag.contains("Double-Jump"))
return color+"Triple-Jump";

if (tag.contains("Triple-Jump"))
return color+"Quadruple-Jump";

return color+"Double-Jump";
}
}
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import tconstruct.library.armor.ArmorCore;
import tconstruct.library.armor.ArmorModTypeFilter;
import tconstruct.library.armor.EnumArmorPart;

//TODO: Condense attribute modifiers into one class
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/tconstruct/modifiers/armor/AModJumpBoost.java
@@ -0,0 +1,6 @@
package tconstruct.modifiers.armor;

public class AModJumpBoost
{

}
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import tconstruct.library.armor.ArmorCore;
import tconstruct.library.armor.ArmorModTypeFilter;
import tconstruct.library.armor.EnumArmorPart;

//TODO: Condense attribute modifiers into one class
Expand Down
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import tconstruct.library.armor.ArmorCore;
import tconstruct.library.armor.ArmorModTypeFilter;
import tconstruct.library.armor.EnumArmorPart;

public class AModMoveSpeed extends ArmorModTypeFilter
Expand Down
Expand Up @@ -4,6 +4,7 @@

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.armor.ArmorModTypeFilter;
import tconstruct.library.armor.EnumArmorPart;

public class AModProtection extends ArmorModTypeFilter
Expand Down

0 comments on commit 86f8a20

Please sign in to comment.