Skip to content

Commit

Permalink
added speedtester to help trouble shoot #8, also switched to extendin…
Browse files Browse the repository at this point in the history
…g itemTool rather than just item...I hope that might help fix #8
  • Loading branch information
Trcx528 committed Mar 21, 2015
1 parent 03079c8 commit ffa3d19
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
26 changes: 26 additions & 0 deletions src/main/java/com/trcx/swapper/Common/BlockSpeedTester.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.trcx.swapper.Common;

import cpw.mods.fml.common.FMLLog;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import org.apache.logging.log4j.Level;

/**
* Created by Trcx on 3/21/2015.
*/
public class BlockSpeedTester extends Block {

public BlockSpeedTester() {
super(Material.rock);
setHardness(0.5f);
setHarvestLevel("pickaxe",0);
}

@Override
public void harvestBlock(World world, EntityPlayer player, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) {
FMLLog.log("Swapper",Level.INFO,player.getHeldItem().toString() + " " + player.getHeldItem().getItem().getDigSpeed(player.getHeldItem(),this,0));
super.harvestBlock(world, player, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_);
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/trcx/swapper/Common/Item/Swapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cofh.api.energy.IEnergyContainerItem;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import com.trcx.swapper.Common.OpenMods.ItemInventory;
import com.trcx.swapper.Main;
import cpw.mods.fml.common.Optional;
Expand Down Expand Up @@ -39,7 +40,7 @@
//TODO funny rendering with itemBlock

@Optional.Interface(iface = "cofh.api.energy.IEnergyContainerItem", modid = "ITA")
public class Swapper extends Item implements IEnergyContainerItem{
public class Swapper extends ItemTool implements IEnergyContainerItem{

private static final String stringLASTTOOL = "LastTool";

Expand All @@ -62,8 +63,10 @@ public class Swapper extends Item implements IEnergyContainerItem{
testTools.put("sword", new ItemStack(Items.wooden_sword));
}

private static final Set field_150915_c = Sets.newHashSet(new Block[]{Blocks.cobblestone, Blocks.double_stone_slab, Blocks.stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, Blocks.gold_ore, Blocks.diamond_ore, Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, Blocks.redstone_ore, Blocks.lit_redstone_ore, Blocks.rail, Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail});

public Swapper(){
super();
super(0.0F,ToolMaterial.IRON, field_150915_c);
setCreativeTab(CreativeTabs.tabTools);
setMaxStackSize(1);
setMaxDamage(Integer.MAX_VALUE);
Expand Down Expand Up @@ -147,7 +150,6 @@ public boolean onBlockStartBreak(ItemStack swapper, int X, int Y, int Z, EntityP

@Override
public float getDigSpeed(ItemStack swapper, Block block, int metadata) {

String effTool = block.getHarvestTool(metadata);
ItemStack is;
if (effTool == null){
Expand Down Expand Up @@ -322,7 +324,6 @@ public ItemStack onEaten(ItemStack swapper, World world, EntityPlayer player) {
if (is != null) {
ItemStack ret = is.getItem().onEaten(is, world, player);
putLastStack(swapper,is);
return ret;//not sure which stack this should return honestly...
}
return super.onEaten(swapper, world, player);
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/trcx/swapper/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.common.config.Configuration;
import java.io.IOException;
Expand All @@ -23,6 +24,7 @@ public class Main
public static final String VERSION = "1.0.4";

public static Item Swapper;
public static Block SpeedTester;
public static String[] swapperBlacklist = new String[2];


Expand All @@ -47,6 +49,10 @@ public void preInit(FMLPreInitializationEvent event) throws IOException{

Swapper = new Swapper().setUnlocalizedName("Swapper").setTextureName("swapper:Swapper");
GameRegistry.registerItem(Swapper, "swapper");

SpeedTester = new BlockSpeedTester();
GameRegistry.registerBlock(SpeedTester, "SpeedTester");

NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

}
Expand Down

0 comments on commit ffa3d19

Please sign in to comment.