Skip to content

Commit

Permalink
Replace the hardcoded stick/bone handle with an oredicted variant usi…
Browse files Browse the repository at this point in the history
…ng the ToolBuildEvent
  • Loading branch information
bonii-xx committed Aug 15, 2014
1 parent e786518 commit 0b7a8f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/main/java/tconstruct/library/crafting/ToolBuilder.java
Expand Up @@ -116,11 +116,8 @@ public int getMaterialID (ItemStack stack)
if (stack == null)
return -1;
Item item = stack.getItem();
if (item == Items.stick)
return 0;
else if (item == Items.bone)
return 5;
else if (item instanceof IToolPart)

if (item instanceof IToolPart)
return ((IToolPart) item).getMaterialID(stack);

return -1;
Expand Down
28 changes: 23 additions & 5 deletions src/main/java/tconstruct/tools/TinkerToolEvents.java
Expand Up @@ -19,14 +19,12 @@
import net.minecraft.util.Vec3;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
import tconstruct.TConstruct;
import tconstruct.armor.player.TPlayerStats;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.event.PartBuilderEvent;
import tconstruct.library.event.SmelteryCastEvent;
import tconstruct.library.event.SmelteryCastedEvent;
import tconstruct.library.event.ToolCraftEvent;
import tconstruct.library.event.*;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ArrowMaterial;
import tconstruct.library.tools.BowMaterial;
Expand All @@ -39,6 +37,8 @@
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;

import java.util.List;

public class TinkerToolEvents
{
@SubscribeEvent
Expand All @@ -58,7 +58,25 @@ public void onCrafting (ItemCraftedEvent event)
}
}
}


@SubscribeEvent
public void buildTool(ToolBuildEvent event)
{
// check if the handle is a bone
if(event.handleStack.getItem() == Items.bone) {
event.handleStack = new ItemStack(TinkerTools.toolRod, 1, 5); // bone tool rod
return;
}

// check if the handle is a stick
List<ItemStack> sticks = OreDictionary.getOres("stickWood");
for(ItemStack stick : sticks)
if (OreDictionary.itemMatches(stick, event.handleStack, false)) {
event.handleStack = new ItemStack(TinkerTools.toolRod, 1, 0); // wooden tool rod
return;
}
}

@SubscribeEvent
public void craftTool (ToolCraftEvent.NormalTool event)
{
Expand Down

0 comments on commit 0b7a8f6

Please sign in to comment.