From ffa3d19073c3145bb82c1a3b11a26eaad802fa90 Mon Sep 17 00:00:00 2001 From: Trcx Date: Sat, 21 Mar 2015 11:13:51 -0500 Subject: [PATCH] added speedtester to help trouble shoot #8, also switched to extending itemTool rather than just item...I hope that might help fix #8 --- .../trcx/swapper/Common/BlockSpeedTester.java | 26 +++++++++++++++++++ .../com/trcx/swapper/Common/Item/Swapper.java | 9 ++++--- src/main/java/com/trcx/swapper/Main.java | 6 +++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/trcx/swapper/Common/BlockSpeedTester.java diff --git a/src/main/java/com/trcx/swapper/Common/BlockSpeedTester.java b/src/main/java/com/trcx/swapper/Common/BlockSpeedTester.java new file mode 100644 index 0000000..83e8de6 --- /dev/null +++ b/src/main/java/com/trcx/swapper/Common/BlockSpeedTester.java @@ -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_); + } +} diff --git a/src/main/java/com/trcx/swapper/Common/Item/Swapper.java b/src/main/java/com/trcx/swapper/Common/Item/Swapper.java index fa77373..f008fc3 100644 --- a/src/main/java/com/trcx/swapper/Common/Item/Swapper.java +++ b/src/main/java/com/trcx/swapper/Common/Item/Swapper.java @@ -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; @@ -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"; @@ -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); @@ -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){ @@ -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); } diff --git a/src/main/java/com/trcx/swapper/Main.java b/src/main/java/com/trcx/swapper/Main.java index 5140eed..b76086a 100644 --- a/src/main/java/com/trcx/swapper/Main.java +++ b/src/main/java/com/trcx/swapper/Main.java @@ -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; @@ -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]; @@ -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()); }