Skip to content

Commit

Permalink
Thks Ropeca's People! Add Tinker Modifiers. version 1.09
Browse files Browse the repository at this point in the history
  • Loading branch information
LoveHoly committed Sep 21, 2014
1 parent 80d55a0 commit 37c6f23
Show file tree
Hide file tree
Showing 51 changed files with 296 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "1.08"
version = "1.09"
group= "exastris"
archivesBaseName = "Ex-Astris"

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/ExAstris/Bridge/TConstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

import ExAstris.Data.ModData;
import ExAstris.Data.MoltenData;
import ExAstris.Modifier.ModCrooked;
import ExAstris.Modifier.ModHammered;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.client.TConstructClientRegistry;
import tconstruct.library.crafting.Smeltery;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.smeltery.TinkerSmeltery;
import cpw.mods.fml.common.registry.GameRegistry;
import exnihilo.registries.OreRegistry;
import exnihilo.registries.helpers.Color;
//import static net.minecraftforge.fluids.FluidRegistry.getFluid;
import exnihilo.registries.HeatRegistry;

public class TConstruct {
public static void Initialize()
{
Expand All @@ -22,6 +29,7 @@ public static void Initialize()
{
addHeatRegistry();
}
addModifiers();
}
public static void addNetherOre()
{
Expand Down Expand Up @@ -53,4 +61,14 @@ public static void addHeatRegistry()


}
static void addModifiers()
{
ToolBuilder.instance.registerToolMod(new ModCrooked(new ItemStack[] { new ItemStack(GameRegistry.findItem("exnihilo", "crook_bone"), 1, 0) }, 60));
TConstructClientRegistry.addEffectRenderMapping(60, "exastris", "crook", true);

ToolBuilder.instance.registerToolMod(new ModHammered(new ItemStack[] { new ItemStack(GameRegistry.findItem("exnihilo", "hammer_diamond"), 1, 0) }, 61));
TConstructClientRegistry.addEffectRenderMapping(61, "exastris", "hammer", true);

TConstructRegistry.registerActiveToolMod(new TConstructModifier());
}
}
119 changes: 119 additions & 0 deletions src/main/java/ExAstris/Bridge/TConstructModifier.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package ExAstris.Bridge;

import java.util.ArrayList;
import java.util.Iterator;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import exnihilo.data.ModData;
import exnihilo.registries.HammerRegistry;
import exnihilo.registries.helpers.Smashable;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import tconstruct.library.ActiveToolMod;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ToolCore;

public class TConstructModifier extends ActiveToolMod {

@Override
public boolean beforeBlockBreak (ToolCore tool, ItemStack item, int X, int Y, int Z, EntityLivingBase player)
{
NBTTagCompound tags = item.getTagCompound().getCompoundTag("InfiTool");
if (tags.getBoolean("Crooked"))
{
World world = player.worldObj;
Block block = world.getBlock(X,Y,Z);
int meta = world.getBlockMetadata(X, Y, Z);
boolean validTarget = false;
boolean extraDropped = false;


if (!world.isRemote && block != null && block.isLeaves(world, X, Y, Z))
{

if (ModData.ALLOW_SILKWORMS && world.rand.nextInt(130) == 0)
{
world.spawnEntityInWorld(new EntityItem(world, X + 0.5D, Y + 0.5D, Z + 0.5D, new ItemStack(GameRegistry.findItem("exnihilo", "silkworm"), 1, 0)));
}

if (block.equals(GameRegistry.findBlock("exnihilo", "infested_leaves")))
{
if (ModData.ALLOW_SILKWORMS && world.rand.nextInt(20) == 0)
{
world.spawnEntityInWorld(new EntityItem(world, X + 0.5D, Y + 0.5D, Z + 0.5D, new ItemStack(GameRegistry.findItem("exnihilo", "silkworm"), 1, 0)));
}
}

AbilityHelper.damageTool(item, 1, player, false);
}
return false;
}
if (tags.getBoolean("Hammered"))
{
World world = player.worldObj;
Block block = world.getBlock(X,Y,Z);
int blockMeta = world.getBlockMetadata(X,Y,Z);
int fortune = EnchantmentHelper.getFortuneModifier(player);

ArrayList<Smashable> rewards = HammerRegistry.getRewards(block, blockMeta);
boolean validTarget = false;

if (!rewards.isEmpty())
{
Iterator<Smashable> it = rewards.iterator();
while(it.hasNext())
{
Smashable reward = it.next();

if (!world.isRemote && world.rand.nextFloat() <= reward.chance + (reward.luckMultiplier * fortune))
{
EntityItem entityitem = new EntityItem(world, (double)X + 0.5D, (double)Y + 0.5D, (double)Z + 0.5D, new ItemStack(reward.item, 1, reward.meta));

double f3 = 0.05F;
entityitem.motionX = world.rand.nextGaussian() * f3;
entityitem.motionY = (0.2d);
entityitem.motionZ = world.rand.nextGaussian() * f3;

world.spawnEntityInWorld(entityitem);
}

validTarget = true;
}

if (validTarget)
{
AbilityHelper.damageTool(item, 1, player, false);

if (!world.isRemote)
{
world.setBlockToAir(X, Y, Z);
}
}

return true;
}
else
{
return false;
}
}
return false;
}

@Override
public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
if (toolTags.hasKey("Crooked"))
{
return 0;
}
else return currentDamage;
}
}
89 changes: 89 additions & 0 deletions src/main/java/ExAstris/Modifier/ModCrooked.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package ExAstris.Modifier;

import java.util.Arrays;
import java.util.List;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolCore;
import tconstruct.modifiers.tools.ModBoolean;

public class ModCrooked extends ModBoolean {

static String name = "Crooked";
static String color = "\u00a77";
static String tooltip = "Crooked";

public ModCrooked(ItemStack[] items, int effect) {
super(items, effect, name, color, tooltip);
}

@Override
protected boolean canModify(ItemStack tool, ItemStack[] input)
{
ToolCore toolitem = (ToolCore) tool.getItem();
if (!validType(toolitem)) return false;

NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.getBoolean("Lava") && !tags.hasKey("Lapis") && !tags.hasKey("Silk Touch") && !tags.hasKey("Hammered"))
{
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key);
}

return false;
}

public void modify(ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
tags.setBoolean(name, true);

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

int attack = tags.getInteger("Attack");
attack = 0;
tags.setInteger("Attack", attack);

int miningSpeed = tags.getInteger("MiningSpeed");
miningSpeed -= 300;
if (miningSpeed < 0)
miningSpeed = 0;
tags.setInteger("MiningSpeed", miningSpeed);

if (tags.hasKey("MiningSpeed2"))
{
int miningSpeed2 = tags.getInteger("MiningSpeed2");
miningSpeed2 -= 300;
if (miningSpeed2 < 0)
miningSpeed2 = 0;
tags.setInteger("MiningSpeed2", miningSpeed2);
}

float knockback = tags.getFloat("Knockback");

knockback *= 1.5F;

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

public boolean validType (ToolCore tool)
{
if(tool.getToolName().equals("Mattock") ||
tool.getToolName().equals("Hatchet") ||
tool.getToolName().equals("Broadsword") ||
tool.getToolName().equals("Longsword") ||
tool.getToolName().equals("Rapier") ||
tool.getToolName().equals("Cutlass") ||
tool.getToolName().equals("Cleaver") ||
tool.getToolName().equals("Lumber Axe") ||
tool.getToolName().equals("Scythe") )
{
return true;
}

return false;
}

}
69 changes: 69 additions & 0 deletions src/main/java/ExAstris/Modifier/ModHammered.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package ExAstris.Modifier;

import java.util.Arrays;
import java.util.List;

import tconstruct.library.tools.ToolCore;
import tconstruct.modifiers.tools.ModBoolean;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

public class ModHammered extends ModBoolean {

static String name = "Hammered";
static String color = "\u00a79";
static String tooltip = "Smashing";

public ModHammered(ItemStack[] items, int i)
{
super(items, i, name, color, tooltip);
}

@Override
protected boolean canModify(ItemStack tool, ItemStack[] input)
{
ToolCore toolitem = (ToolCore) tool.getItem();
if (!validType(toolitem)) return false;

NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");

if (!tags.getBoolean("Lava") && !tags.hasKey("Lapis") && !tags.hasKey("Silk Touch") && !tags.hasKey("Crooked"))
{
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key);
}
return false;
}

public void modify(ItemStack[] input, ItemStack tool)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
tags.setBoolean(name, true);

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

int miningSpeed = tags.getInteger("MiningSpeed");
miningSpeed -= 400;
if (miningSpeed < 0)
miningSpeed = 0;
tags.setInteger("MiningSpeed", miningSpeed);

int attack = tags.getInteger("Attack");
attack += 3;
tags.setInteger("Attack", attack);

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

public boolean validType (ToolCore tool)
{
if(tool.getToolName().equals("Pickaxe") ||
tool.getToolName().equals("Hammer") )
{
return true;
}
return false;

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 37c6f23

Please sign in to comment.