Skip to content

Commit

Permalink
Double Jumps
Browse files Browse the repository at this point in the history
  • Loading branch information
mDiyo committed Jan 8, 2014
1 parent 79e46cb commit c8bf021
Show file tree
Hide file tree
Showing 16 changed files with 227 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/tconstruct/blocks/MeatBlock.java
Expand Up @@ -21,7 +21,7 @@ public class MeatBlock extends Block

public MeatBlock(int id)
{
super(id, Material.wood);
super(id, Material.sponge);
this.setHardness(1.0F);
this.setStepSound(Block.soundWoodFootstep);
//setBurnProperties(this.blockID, 5, 20);
Expand Down
35 changes: 23 additions & 12 deletions src/tconstruct/client/TClientEvents.java
@@ -1,31 +1,35 @@
package tconstruct.client;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.*;
import java.util.Random;
import net.minecraft.block.Block;

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundManager;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.*;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeInstance;
import net.minecraft.item.Item;
import net.minecraft.potion.*;
import net.minecraft.util.*;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.GuiIngameForge;
import net.minecraftforge.client.event.*;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.fluids.*;
import tconstruct.TConstruct;
import tconstruct.client.armor.WingModel;
import tconstruct.common.TContent;
import tconstruct.util.player.TPlayerStats;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class TClientEvents
Expand Down Expand Up @@ -91,11 +95,13 @@ public void postStitch (TextureStitchEvent.Post event)
Random rand = new Random();
int updateCounter = 0;

boolean tukmc = Loader.isModLoaded("tukmc_Vz");
GameSettings gs = Minecraft.getMinecraft().gameSettings;
/* HUD */
@ForgeSubscribe
public void renderHealthbar (RenderGameOverlayEvent.Pre event)
{
if (!Loader.isModLoaded("tukmc_Vz"))// Loader check to avoid conflicting with a GUI mod (thanks Vazkii!)
if (!tukmc)// Loader check to avoid conflicting with a GUI mod (thanks Vazkii!)
{
if (event.type == ElementType.HEALTH)
{
Expand Down Expand Up @@ -215,9 +221,14 @@ else if (i * 2 + 1 == health)
GuiIngameForge.left_height += 10;
if (absorb > 0)
GuiIngameForge.left_height += 10;

event.setCanceled(true);
}

if (event.type == ElementType.CROSSHAIRS && gs.thirdPersonView != 0)
{
event.setCanceled(true);
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/tconstruct/client/TClientTickHandler.java
Expand Up @@ -4,8 +4,6 @@

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import tconstruct.TConstruct;
import tconstruct.common.TContent;
import cpw.mods.fml.common.ITickHandler;
Expand All @@ -14,16 +12,18 @@
public class TClientTickHandler implements ITickHandler
{
Minecraft mc = Minecraft.getMinecraft();
//TControls controlInstance = ((TProxyClient)TConstruct.proxy).controlInstance;
TControls controlInstance = ((TProxyClient)TConstruct.proxy).controlInstance;

@Override
public void tickEnd (EnumSet<TickType> type, Object... tickData)
{
TContent.oreBerry.setGraphicsLevel(Block.leaves.graphicsLevel);
TContent.oreBerrySecond.setGraphicsLevel(Block.leaves.graphicsLevel);
TContent.slimeLeaves.setGraphicsLevel(Block.leaves.graphicsLevel);
/*if (mc.thePlayer != null && !mc.thePlayer.isAirBorne)
controlInstance.landOnGround();*/
if (mc.thePlayer != null && mc.thePlayer.onGround)
{
controlInstance.landOnGround();
}
}

@Override
Expand Down
45 changes: 17 additions & 28 deletions src/tconstruct/client/TControls.java
Expand Up @@ -8,6 +8,8 @@
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.potion.Potion;
import tconstruct.client.event.EventCloakRender;
Expand All @@ -26,7 +28,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 @@ -72,17 +74,13 @@ public void keyDown (EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, bo
{
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 @@ -91,31 +89,22 @@ public void keyDown (EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, bo
mc.thePlayer.motionY += (double) ((float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
}

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

if (!jumping)
{
jumping = mc.thePlayer.isAirBorne;
}*/
ItemStack shoes = mc.thePlayer.getCurrentArmor(0);
if (shoes.hasTagCompound() && shoes.getTagCompound().hasKey("TinkerArmor"))
{
NBTTagCompound shoeTag = shoes.getTagCompound().getCompoundTag("TinkerArmor");
midairJumps = shoeTag.getInteger("Double-Jump");
}
}
}
}
/*else if (kb == stiltsKey) //Stilts
{
float size = 1.8F;
if (!onStilts)
size = 0.8F;
TConstruct.playerTracker.updateSize(mc.thePlayer.username, size);
onStilts = !onStilts;
//updateServer(mc.thePlayer.username, (byte) 11);
if (onStilts)
{
onStilts = false;
}
else
{
onStilts = true;
}
}*/
}

@Override
Expand All @@ -132,13 +121,13 @@ public EnumSet<TickType> ticks ()

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

public void resetControls ()
{
doubleJump = false;
midairJumps = 0;
jumping = false;
climbing = false;
onGround = false;
Expand Down
15 changes: 15 additions & 0 deletions src/tconstruct/client/gui/CraftingStationGui.java
Expand Up @@ -88,6 +88,21 @@ void drawModularArmorStats (ItemStack stack, ArmorCore tool, NBTTagCompound tags
fontRenderer.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);
fontRenderer.drawString("- " + tipName, xSize + 8, base + (offset + tipNum) * 10, 0xffffff);
}
else
displayToolTips = false;
}
}

void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
Expand Down
6 changes: 4 additions & 2 deletions src/tconstruct/common/TContent.java
Expand Up @@ -1255,7 +1255,7 @@ private void addRecipesForCraftingTable ()
GameRegistry.addRecipe(new ShapedOreRecipe(chestplateWood, chest, 'w', "logWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(leggingsWood, pants, 'w', "logWood"));
GameRegistry.addRecipe(new ShapedOreRecipe(bootsWood, shoes, 'w', "logWood"));

ItemStack exoGoggleStack = new ItemStack(exoGoggles);
ItemStack exoChestStack = new ItemStack(exoChest);
ItemStack exoPantsStack = new ItemStack(exoPants);
Expand Down Expand Up @@ -1622,7 +1622,9 @@ private void addRecipesForToolBuilder ()
tb.registerArmorMod(new AModHealthBoost(2, allArmors, new ItemStack[] { new ItemStack(heartCanister, 1, 2) }, new int[] { 2 }, true));
tb.registerArmorMod(new AModDamageBoost(3, allArmors, new ItemStack[] { new ItemStack(Item.diamond), new ItemStack(Block.blockDiamond) }, new int[] { 1, 9 }, false, 3, 0.05));
tb.registerArmorMod(new AModDamageBoost(4, chest, new ItemStack[] { new ItemStack(Block.blockNetherQuartz, 1, Short.MAX_VALUE) }, new int[] { 1 }, true, 5, 1));
tb.registerArmorMod(new AModProtection(5, allArmors, new ItemStack[] { new ItemStack(largePlate, 1, 2) }, new int[] { 2 } ));
tb.registerArmorMod(new AModProtection(5, allArmors, new ItemStack[] { new ItemStack(largePlate, 1, 2) }, new int[] { 2 }));

tb.registerArmorMod(new AModDoubleJump(new ItemStack[] { new ItemStack(Item.ghastTear), new ItemStack(slimeGel, 1, 0), new ItemStack(slimeGel, 1, 1) }));

TConstructRegistry.registerActiveToolMod(new TActiveOmniMod());
}
Expand Down
20 changes: 18 additions & 2 deletions src/tconstruct/items/armor/ExoArmor.java
Expand Up @@ -72,9 +72,25 @@ 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/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
1 change: 1 addition & 0 deletions src/tconstruct/modifiers/armor/AModDamageBoost.java
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

0 comments on commit c8bf021

Please sign in to comment.