Skip to content
Permalink
Browse files

Buff redstone mod, refactor broad tools to match

  • Loading branch information...
mDiyo committed Apr 15, 2014
1 parent c904033 commit 34a4c8c80f969cafd696b41d963c2a041347d4cd
@@ -18,6 +18,7 @@

import tconstruct.blocks.logic.CraftingStationLogic;
import tconstruct.library.armor.ArmorCore;
import tconstruct.library.tools.HarvestTool;
import tconstruct.library.tools.ToolCore;

public class CraftingStationGui extends GuiContainer
@@ -212,9 +213,9 @@ void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
//Mining
if (categories.contains("dualharvest"))
{
float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f;
float stoneboundSpeed = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
float mineSpeed = tags.getInteger("MiningSpeed") / 100f * ((HarvestTool) tool).breakSpeedModifier();
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f * ((HarvestTool) tool).breakSpeedModifier();
float stoneboundSpeed = (float) Math.log(durability / ((HarvestTool) tool).stoneboundModifier() + 1) * 2 * stonebound;
DecimalFormat df = new DecimalFormat("##.##");
df.setRoundingMode(RoundingMode.DOWN);
float trueSpeed = mineSpeed + stoneboundSpeed;
@@ -261,9 +262,9 @@ else if (categories.contains("harvest"))
heads++;
}

float trueSpeed = mineSpeed / (heads * 100f);
float trueSpeed = mineSpeed / (heads * 100f) * ((HarvestTool) tool).breakSpeedModifier();

float stoneboundSpeed = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
float stoneboundSpeed = (float) Math.log(durability / ((HarvestTool) tool).stoneboundModifier() + 1) * 2 * stonebound;
DecimalFormat df = new DecimalFormat("##.##");
df.setRoundingMode(RoundingMode.DOWN);
trueSpeed += stoneboundSpeed;
@@ -25,8 +25,8 @@
import tconstruct.inventory.ToolStationContainer;
import tconstruct.library.client.TConstructClientRegistry;
import tconstruct.library.client.ToolGuiElement;
import tconstruct.library.tools.HarvestTool;
import tconstruct.library.tools.ToolCore;

import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -290,9 +290,9 @@ void drawModularToolStats (ItemStack stack, ToolCore tool, NBTTagCompound tags)
//Mining
if (categories.contains("dualharvest"))
{
float mineSpeed = tags.getInteger("MiningSpeed") / 100f;
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f;
float stoneboundSpeed = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
float mineSpeed = tags.getInteger("MiningSpeed") / 100f * ((HarvestTool) tool).breakSpeedModifier();
float mineSpeed2 = tags.getInteger("MiningSpeed2") / 100f * ((HarvestTool) tool).breakSpeedModifier();
float stoneboundSpeed = (float) Math.log(durability / ((HarvestTool) tool).stoneboundModifier() + 1) * 2 * stonebound;
DecimalFormat df = new DecimalFormat("##.##");
df.setRoundingMode(RoundingMode.DOWN);
float trueSpeed = mineSpeed + stoneboundSpeed;
@@ -339,9 +339,9 @@ else if (categories.contains("harvest"))
heads++;
}

float trueSpeed = mineSpeed / (heads * 100f);
float trueSpeed = mineSpeed / (heads * 100f) * ((HarvestTool) tool).breakSpeedModifier();

float stoneboundSpeed = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
float stoneboundSpeed = (float) Math.log(durability / ((HarvestTool) tool).stoneboundModifier() + 1) * 2 * stonebound;
DecimalFormat df = new DecimalFormat("##.##");
df.setRoundingMode(RoundingMode.DOWN);
trueSpeed += stoneboundSpeed;
@@ -52,7 +52,7 @@ public Object getServerGuiElement (int ID, EntityPlayer player, World world, int
else if (ID < 100)
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
System.out.println(tile instanceof InventoryLogic);
//System.out.println(tile instanceof InventoryLogic);
if (tile != null && tile instanceof InventoryLogic)
{
return ((InventoryLogic) tile).getGuiContainer(player.inventory, world, x, y, z);
@@ -245,53 +245,15 @@ public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPl
}

@Override
public float getStrVsBlock (ItemStack stack, Block block, int meta)
public float breakSpeedModifier ()
{
if (!stack.hasTagCompound())
return 1.0f;

NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (tags.getBoolean("Broken"))
return 0.1f;

Material[] materials = getEffectiveMaterials();
for (int i = 0; i < materials.length; i++)
{
if (materials[i] == block.blockMaterial)
{
float mineSpeed = tags.getInteger("MiningSpeed");
int heads = 1;
if (tags.hasKey("MiningSpeed2"))
{
mineSpeed += tags.getInteger("MiningSpeed2");
heads++;
}

if (tags.hasKey("MiningSpeedHandle"))
{
mineSpeed += tags.getInteger("MiningSpeedHandle");
heads++;
}

if (tags.hasKey("MiningSpeedExtra"))
{
mineSpeed += tags.getInteger("MiningSpeedExtra");
heads++;
}
float trueSpeed = mineSpeed / (heads * 300f);
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
int durability = tags.getInteger("Damage");

float stonebound = tags.getFloat("Shoddy");
float bonusLog = (float) Math.log(durability / 216f + 1) * 2 * stonebound;
trueSpeed += bonusLog;
return 0.4f;
}

if (hlvl <= tags.getInteger("HarvestLevel"))
return trueSpeed;
return 0.1f;
}
}
return super.getStrVsBlock(stack, block, meta);
@Override
public float stoneboundModifier ()
{
return 216f;
}

}
@@ -343,78 +343,17 @@ public boolean onBlockStartBreak (ItemStack stack, int x, int y, int z, EntityPl
}

@Override
public float getStrVsBlock (ItemStack stack, Block block, int meta)
public float breakSpeedModifier ()
{
if (!stack.hasTagCompound())
return 1.0f;

NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (tags.getBoolean("Broken"))
return 0.1f;

Material[] materials = getEffectiveMaterials();
for (int i = 0; i < materials.length; i++)
{
if (materials[i] == block.blockMaterial)
{
return getblockSpeed(tags, block, meta);
}
}

/*if (block == Block.silverfish)
return getblockSpeed(tags, block, meta);*/

return super.getStrVsBlock(stack, block, meta);
return 0.4f;
}

float getblockSpeed (NBTTagCompound tags, Block block, int meta)
@Override
public float stoneboundModifier ()
{
float mineSpeed = tags.getInteger("MiningSpeed");
int heads = 1;
if (tags.hasKey("MiningSpeed2"))
{
mineSpeed += tags.getInteger("MiningSpeed2");
heads++;
}
if (tags.hasKey("MiningSpeedHandle"))
{
mineSpeed += tags.getInteger("MiningSpeedHandle");
heads++;
}

if (tags.hasKey("MiningSpeedExtra"))
{
mineSpeed += tags.getInteger("MiningSpeedExtra");
heads++;
}
float trueSpeed = mineSpeed / (heads * 300f);
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
int durability = tags.getInteger("Damage");

float stonebound = tags.getFloat("Shoddy");
float bonusLog = (float) Math.log(durability / 216f + 1) * 2 * stonebound;
trueSpeed += bonusLog;

if (hlvl <= tags.getInteger("HarvestLevel"))
return trueSpeed;
return 0.1f;
return 216f;
}

/*@Override
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
{
super.onUpdate(stack, world, entity, par4, par5);
if (entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
ItemStack equipped = player.getCurrentEquippedItem();
if (equipped == stack)
{
player.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, 1, 1));
}
}
}*/

@Override
public String[] toolCategories ()
{
@@ -83,53 +83,15 @@ public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boo
}*/

@Override
public float getStrVsBlock (ItemStack stack, Block block, int meta)
public float breakSpeedModifier ()
{
if (!stack.hasTagCompound())
return 1.0f;

NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (tags.getBoolean("Broken"))
return 0.1f;

Material[] materials = getEffectiveMaterials();
for (int i = 0; i < materials.length; i++)
{
if (materials[i] == block.blockMaterial)
{
float mineSpeed = tags.getInteger("MiningSpeed");
int heads = 1;
if (tags.hasKey("MiningSpeed2"))
{
mineSpeed += tags.getInteger("MiningSpeed2");
heads++;
}

if (tags.hasKey("MiningSpeedHandle"))
{
mineSpeed += tags.getInteger("MiningSpeedHandle");
heads++;
}

if (tags.hasKey("MiningSpeedExtra"))
{
mineSpeed += tags.getInteger("MiningSpeedExtra");
heads++;
}
float trueSpeed = mineSpeed / (heads * 300f);
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
int durability = tags.getInteger("Damage");

float stonebound = tags.getFloat("Shoddy");
float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
trueSpeed += bonusLog;
return 0.4f;
}

if (hlvl <= tags.getInteger("HarvestLevel"))
return trueSpeed;
return 0.1f;
}
}
return super.getStrVsBlock(stack, block, meta);
@Override
public float stoneboundModifier ()
{
return 216f;
}

@Override
@@ -103,18 +103,28 @@ float calculateStrength (NBTTagCompound tags, Block block, int meta)
mineSpeed += tags.getInteger("MiningSpeedExtra");
heads++;
}
float trueSpeed = mineSpeed / (heads * 100f);
float trueSpeed = mineSpeed / (heads * 100f) * breakSpeedModifier();
int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
int durability = tags.getInteger("Damage");

float stonebound = tags.getFloat("Shoddy");
float bonusLog = (float) Math.log(durability / 72f + 1) * 2 * stonebound;
float bonusLog = (float) Math.log(durability / stoneboundModifier() + 1) * 2 * stonebound;
trueSpeed += bonusLog;

if (hlvl <= tags.getInteger("HarvestLevel"))
return trueSpeed;
return 0.1f;
}

public float breakSpeedModifier()
{
return 1.0f;
}

public float stoneboundModifier()
{
return 72f;
}

public boolean canHarvestBlock (Block block)
{
@@ -5,15 +5,13 @@
import java.util.List;
import java.util.Map;

import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
import tconstruct.library.tools.Weapon;

import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.Weapon;

public class ModLapis extends ToolModTypeFilter
{
@@ -70,7 +68,18 @@ public void modify (ItemStack[] input, ItemStack tool)
int keyPair[] = tags.getIntArray(key);
keyPair[0] += increase;
tags.setIntArray(key, keyPair);
if (tool.getItem() instanceof Weapon)
ToolCore toolcore = (ToolCore) tool.getItem();
String[] types = toolcore.toolCategories();
boolean weapon = false;
boolean harvest = false;
for (String s : types)
{
if (s.equals("harvest"))
harvest = true;
else if (s.equals("weapon"))
weapon = true;
}
if (weapon)
{
if (keyPair[0] >= 450)
addEnchantment(tool, Enchantment.looting, 3);
@@ -79,7 +88,7 @@ else if (keyPair[0] >= 300)
else if (keyPair[0] >= 100)
addEnchantment(tool, Enchantment.looting, 1);
}
else
if (harvest)
{
if (keyPair[0] >= 450)
addEnchantment(tool, Enchantment.fortune, 3);
Oops, something went wrong.

0 comments on commit 34a4c8c

Please sign in to comment.
You can’t perform that action at this time.