Jump to content

[1.11] Custom tool mining speed not working


Villfuk02

Recommended Posts

I've made custom tool based of shovel, and i have set the iron variant's efficiency to 0.1F. It works on everything, that shovel works on(but it's mining slowly, just how have i set it). But on my own block it doesn't work - shovels mine it just like dirt, but the ModShovel mines it like if i had empty hand instead of mining it slowly, what should i do?

 

ArcheologyDirt

package vms.archeology.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import vms.archeology.Reference;
import vms.archeology.blocks.item.IMetaBlockName;
import vms.archeology.handlers.EnumHandler.Nations;
import vms.archeology.handlers.EnumHandler.Types;

public class ArcheologyDirt extends Block implements IMetaBlockName{

public static final PropertyInteger DROP_ID = PropertyInteger.create("id", 0, 15);

public ArcheologyDirt(String unlocalizedName) {
	super(Material.GROUND);
	this.setUnlocalizedName(unlocalizedName);
	this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName));
	this.setHardness(0.5f);
	this.setHarvestLevel("shovel", 0);
	this.setResistance(2.5f);
	this.setDefaultState(this.blockState.getBaseState().withProperty(DROP_ID, 0));
	this.setSoundType(SoundType.GROUND);
}

@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
	return Item.getItemFromBlock(Blocks.DIRT);

}
@Override
protected net.minecraft.block.state.BlockStateContainer createBlockState() {
	return new BlockStateContainer(this, new IProperty[] {DROP_ID});
}

@Override
public int getMetaFromState(IBlockState state) {
	return state.getValue(DROP_ID);
}

@Override
public IBlockState getStateFromMeta(int meta) {		
		return this.getDefaultState().withProperty(DROP_ID, meta);
}

@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
	for (int i = 0; i < 16; i++) {
		list.add(new ItemStack(itemIn, 1, i));
	}
}

@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
	return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos)));
}

@Override
public int damageDropped(IBlockState state) {
	return getMetaFromState(state);
}

@Override
public String getSpecialName(ItemStack stack) {
	return null;
}

}

ModShovel

package vms.archeology.items;

import java.util.List;
import java.util.Set;

import com.google.common.collect.Sets;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vms.archeology.Reference;
import vms.archeology.init.ModBlocks;
import net.minecraft.item.Item.ToolMaterial;

public class ModShovel extends ItemTool {
     
    private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(new Block[] {ModBlocks.archeology_dirt, Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH});
    
    public ModShovel(Item.ToolMaterial material)
    {
        super(-0.5F, -2.5F, material, EFFECTIVE_ON);
    }

    /**
     * Check whether this Item can harvest the given Block
     */
    public boolean canHarvestBlock(IBlockState blockIn)
    {
        Block block = blockIn.getBlock();
        return block == Blocks.SNOW_LAYER ? true : block == Blocks.SNOW;
    }

   

}

 

ModTools

package vms.archeology.init;

import akka.io.TcpListener.RegisterIncoming;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemSpade;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;
import vms.archeology.Reference;
import vms.archeology.items.ArcheologyShovel;

public class ModTools {

public static final ToolMaterial ironMaterial = EnumHelper.addToolMaterial(Reference.MODID + "iron", 2, 200, 0.1F, 2.0F, ;

public static ArcheologyShovel iron_archeology_shovel;

public static void init() {
	iron_archeology_shovel = new ArcheologyShovel(ironMaterial, "iron_archeology_shovel");
}

public static void register() {
	registerTool(iron_archeology_shovel);
}

public static void registerRenders() {
	registerRender(iron_archeology_shovel);
}

public static void registerTool(Item item) {
	GameRegistry.register(item);
}

public static void registerRender(Item item) {
	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, item.getUnlocalizedName().substring(5)), "inventory"));
}

}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have downloaded forge version 1.20.4 and I have Java 17 installed but my .jar will not open and the error log text file below is created     JVM info: Oracle Corporation - 17.0.10 - 17.0.10+11-LTS-240 java.net.preferIPv4Stack=true Current Time: 27/02/2024 19:43:19 Host: files.minecraftforge.net [51.79.83.165, 2607:5300:203:65a5:0:0:0:0] Host: maven.minecraftforge.net [51.79.83.165, 2607:5300:203:65a5:0:0:0:0] Host: libraries.minecraft.net [13.107.246.64, 13.107.213.64, 2620:1ec:46:0:0:0:0:64, 2620:1ec:bdf:0:0:0:0:64] Host: launchermeta.mojang.com [13.107.213.64, 13.107.246.64, 2620:1ec:bdf:0:0:0:0:64, 2620:1ec:46:0:0:0:0:64] Host: piston-meta.mojang.com [13.107.213.64, 13.107.246.64, 2620:1ec:46:0:0:0:0:64, 2620:1ec:bdf:0:0:0:0:64] java.net.UnknownHostException: No such host is known (authserver.mojang.com)     at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)     at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:933)     at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1543)     at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:852)     at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1532)     at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1384)     at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1305)     at net.minecraftforge.installer.DownloadUtils.getIps(DownloadUtils.java:290)     at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:120) Exception in thread "main"  java.lang.NullPointerException: Cannot invoke "java.util.List.stream()" because the return value of "net.minecraftforge.installer.DownloadUtils.getIps(String)" is null     at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:120)  
    • we tried both versions and both cant run on her laptop for some reason idk what to do  
    • Okay so we tried both versions and both cant run on her pc for some reason!  
    • Well. Make sure you installed a correct jdk for your forge mdk version. Make sure your JAVA_HOME and %PATH% environment-variables are setup correctly. (If you're on windows)   I downloaded an example forge mdk for my version and extracted the contents to a folder I'm working in Using Eclipse, I opened Eclipse and imported an existing gradle Project (with its root directory in the folder directory which I previously extracted my contents to). Waited for Eclipse to do its thing After it having finished, I ran genEclipseRuns, setupDecompWorkspace and setupDevWorkspace (Gradle Tasks > your mod name here > forgegradle)    If it still didn't work (and you're using Eclipse) run cleanEclipse and, in a command prompt  Also If I recall correctly, someone, somewhere said that the way you setup your workspace changes depending on your Minecraft Version. I did this in 1.8.9.
    • https://mclo.gs/ZlRMU4G Still crash, help 
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.