mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
The return of achievements
- Re-added achievements - Organised all imports (seemed all over the place) - Formatted all code (seemed very combined, used the TinkerStyle)
This commit is contained in:
1 parent
ae2d8d6e4d
commit
80efde613a
419 files changed
+2406
-4144
No files matched your search
@@ -1,40 +1,27 @@
|
||||
package tconstruct.library.tools;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import java.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.monster.*;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.*;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.stats.AchievementList;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.stats.*;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.entity.player.UseHoeEvent;
|
||||
import tconstruct.library.ActiveToolMod;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.*;
|
||||
import tconstruct.library.util.PiercingEntityDamage;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
|
||||
public class AbilityHelper
|
||||
{
|
||||
@@ -139,8 +126,7 @@ public class AbilityHelper
|
||||
|
||||
if (damage > 0 || enchantDamage > 0)
|
||||
{
|
||||
boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness)
|
||||
&& player.ridingEntity == null && entity instanceof EntityLivingBase;
|
||||
boolean criticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null && entity instanceof EntityLivingBase;
|
||||
|
||||
for (ActiveToolMod mod : TConstructRegistry.activeModifiers)
|
||||
{
|
||||
@@ -212,8 +198,7 @@ public class AbilityHelper
|
||||
|
||||
if (knockback > 0)
|
||||
{
|
||||
entity.addVelocity((double) (-MathHelper.sin(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F), 0.1D,
|
||||
(double) (MathHelper.cos(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F));
|
||||
entity.addVelocity((double) (-MathHelper.sin(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F), 0.1D, (double) (MathHelper.cos(player.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F));
|
||||
player.motionX *= 0.6D;
|
||||
player.motionZ *= 0.6D;
|
||||
player.setSprinting(false);
|
||||
@@ -309,8 +294,7 @@ public class AbilityHelper
|
||||
|
||||
if (!(living instanceof EntityPlayer) || player.canAttackPlayer((EntityPlayer) living))
|
||||
{
|
||||
List var6 = player.worldObj.getEntitiesWithinAABB(EntityWolf.class,
|
||||
AxisAlignedBB.getBoundingBox(player.posX, player.posY, player.posZ, player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D));
|
||||
List var6 = player.worldObj.getEntitiesWithinAABB(EntityWolf.class, AxisAlignedBB.getBoundingBox(player.posX, player.posY, player.posZ, player.posX + 1.0D, player.posY + 1.0D, player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D));
|
||||
Iterator var4 = var6.iterator();
|
||||
|
||||
while (var4.hasNext())
|
||||
@@ -386,7 +370,7 @@ public class AbilityHelper
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean damageEnergyTool(ItemStack stack, NBTTagCompound tags, Entity entity)
|
||||
public static boolean damageEnergyTool (ItemStack stack, NBTTagCompound tags, Entity entity)
|
||||
{
|
||||
if (!tags.hasKey("Energy"))
|
||||
return false;
|
||||
@@ -424,7 +408,8 @@ public class AbilityHelper
|
||||
{
|
||||
ToolCore tool = (ToolCore) stack.getItem();
|
||||
// first try charging from the hotbar
|
||||
if(entity instanceof EntityPlayer) {
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
// workaround for charging flux-capacitors making tools unusable
|
||||
chargeEnergyFromHotbar(stack, (EntityPlayer) entity, tags);
|
||||
energy = tool.getEnergyStored(stack);
|
||||
@@ -440,7 +425,6 @@ public class AbilityHelper
|
||||
energy -= trueSpeed * 2;
|
||||
tags.setInteger("Energy", energy);
|
||||
|
||||
|
||||
stack.setItemDamage(1 + (tool.getMaxEnergyStored(stack) - energy) * (stack.getMaxDamage() - 1) / tool.getMaxEnergyStored(stack));
|
||||
}
|
||||
return true;
|
||||
@@ -449,13 +433,13 @@ public class AbilityHelper
|
||||
protected static void chargeEnergyFromHotbar (ItemStack stack, EntityPlayer player, NBTTagCompound tags)
|
||||
{
|
||||
// cool kids only
|
||||
if(!(stack.getItem() instanceof ToolCore))
|
||||
if (!(stack.getItem() instanceof ToolCore))
|
||||
return;
|
||||
|
||||
ToolCore tool = (ToolCore)stack.getItem();
|
||||
ToolCore tool = (ToolCore) stack.getItem();
|
||||
|
||||
// check if the tool can actually receive energy
|
||||
if(tool.receiveEnergy(stack, 1, true) != 1)
|
||||
if (tool.receiveEnergy(stack, 1, true) != 1)
|
||||
// no you're not going to charge that potato battery on your tool
|
||||
return;
|
||||
|
||||
@@ -464,7 +448,7 @@ public class AbilityHelper
|
||||
int missing = max - buffer;
|
||||
|
||||
// you're full. xbox go home.
|
||||
if(missing <= 0)
|
||||
if (missing <= 0)
|
||||
return;
|
||||
|
||||
// iterate through hotbar
|
||||
@@ -473,10 +457,10 @@ public class AbilityHelper
|
||||
ItemStack slot = player.inventory.mainInventory[iter];
|
||||
|
||||
// check if item is not another tool
|
||||
if(slot == null || slot.getItem() instanceof ToolCore)
|
||||
if (slot == null || slot.getItem() instanceof ToolCore)
|
||||
continue;
|
||||
// check if item gives energy
|
||||
if(!(slot.getItem() instanceof IEnergyContainerItem))
|
||||
if (!(slot.getItem() instanceof IEnergyContainerItem))
|
||||
continue;
|
||||
|
||||
IEnergyContainerItem fluxItem = (IEnergyContainerItem) slot.getItem();
|
||||
@@ -488,7 +472,7 @@ public class AbilityHelper
|
||||
}
|
||||
}
|
||||
// update energy
|
||||
tags.setInteger("Energy", max-missing);
|
||||
tags.setInteger("Energy", max - missing);
|
||||
}
|
||||
|
||||
public static void breakTool (ItemStack stack, NBTTagCompound tags, Entity entity)
|
||||
@@ -546,7 +530,7 @@ public class AbilityHelper
|
||||
if (side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt))
|
||||
{
|
||||
Block block1 = Blocks.farmland;
|
||||
world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
|
||||
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
|
||||
|
||||
if (world.isRemote)
|
||||
{
|
||||
@@ -680,7 +664,7 @@ public class AbilityHelper
|
||||
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
|
||||
}
|
||||
|
||||
public static float calcToolSpeed(ToolCore tool, NBTTagCompound tags)
|
||||
public static float calcToolSpeed (ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
float mineSpeed = tags.getInteger("MiningSpeed");
|
||||
int heads = 1;
|
||||
@@ -702,7 +686,7 @@ public class AbilityHelper
|
||||
heads++;
|
||||
}
|
||||
float speedMod = 1f;
|
||||
if(tool instanceof HarvestTool)
|
||||
if (tool instanceof HarvestTool)
|
||||
speedMod = ((HarvestTool) tool).breakSpeedModifier();
|
||||
|
||||
float trueSpeed = mineSpeed / (heads * 100f) * speedMod;
|
||||
@@ -711,12 +695,12 @@ public class AbilityHelper
|
||||
return trueSpeed;
|
||||
}
|
||||
|
||||
public static float calcStoneboundBonus(ToolCore tool, NBTTagCompound tags)
|
||||
public static float calcStoneboundBonus (ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
int durability = tags.getInteger("Damage");
|
||||
float stonebound = tags.getFloat("Shoddy");
|
||||
float stoneboundMod = 72f;
|
||||
if(tool instanceof HarvestTool)
|
||||
if (tool instanceof HarvestTool)
|
||||
stoneboundMod = ((HarvestTool) tool).stoneboundModifier();
|
||||
|
||||
return (float) Math.log(durability / stoneboundMod + 1) * 2 * stonebound;
|
||||
|
||||
Reference in new issue
Block a user