Jump to content

New tool does not get recognized as tool when using .setRequiresTool on wood


Frontsalat
 Share

Recommended Posts

Again me,

 

the title basically says it. I'm using a reflection method in my main class to prevent chopping wood with your bare hands, so that you'll need proper tools to actually chop the wood. Works fine so far, but when trying to chop the wood with one of my newly imported copper axe (which I assume is the proper tool), it does not harvest the wooden block. Either it does not get recognized as tool, or it is recognized as weapon. But then, there seems to benothing wrong with the code?

 

Axe Code

 

package MetallurgyRealism;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemAxe;

public class ToolAxeCopper extends ItemAxe{

public ToolAxeCopper(int i, EnumToolMaterial enumToolMaterial){
	super(i, enumToolMaterial);
	setMaxStackSize(1);
	setCreativeTab(MetallurgyRealismModBase.MetallurgyRealismTab);
}

@Override
public void registerIcons(IconRegister iconRegister)
{
	itemIcon = iconRegister.registerIcon("MetallurgyRealism:axecopper");
}

}

 

Enum Code

 

public static EnumToolMaterial CopperMaterial = EnumHelper.addToolMaterial("CopperMaterial", 3, 5, 15.0F, 1, 15);

 

Register and ID code

 

public static Item toolAxeCopper;
int toolAxeCopperID = 6029;
toolAxeCopper = new ToolAxeCopper(toolAxeCopperID, CopperMaterial).setUnlocalizedName("axecopper");
GameRegistry.registerItem(toolAxeCopper, "ToolAxeCopper");
LanguageRegistry.addName(toolAxeCopper, "Copper Axe");

Link to comment
Share on other sites

I think I found the solution. Of what ever reason the game treated my tool as weapon, so I had to put this code snippet into the axe class...

 

    public boolean canHarvestBlock(Block par1Block)
    {
        return par1Block.blockID == Block.wood.blockID;
    }

 

...I believe that the video tutorial that learned me how to import tools/weapons mixed both items. It's obvious that tools need another method of coding. However, it's working now, plus the code like I imported now, is much easier then the actual tool code needed...:D

Link to comment
Share on other sites

I think I found the solution. Of what ever reason the game treated my tool as weapon, so I had to put this code snippet into the axe class...

 

    public boolean canHarvestBlock(Block par1Block)
    {
        return par1Block.blockID == Block.wood.blockID;
    }

 

...I believe that the video tutorial that learned me how to import tools/weapons mixed both items. It's obvious that tools need another method of coding. However, it's working now, plus the code like I imported now, is much easier then the actual tool code needed...:D

 

The problem I see here is that you can only harvest wooden logs with your axe. To let your axe harvest all wooden types, you can check if the block's material is equal to the Material.wood.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

    public boolean canHarvestBlock(Block par1Block)
    {
        return par1Block.blockID == Block.wood.blockID || par1Block.blockID == Block.chest.blockID || par1Block.blockID == Block.planks.blockID || par1Block.blockID == Block.bookShelf.blockID || par1Block.blockID == Block.stoneDoubleSlab.blockID || par1Block.blockID == Block.stoneSingleSlab.blockID || par1Block.blockID == Block.pumpkin.blockID || par1Block.blockID == Block.pumpkinLantern.blockID;
    }

 

;)

Link to comment
Share on other sites

    public boolean canHarvestBlock(Block par1Block)
    {
        return par1Block.blockID == Block.wood.blockID || par1Block.blockID == Block.chest.blockID || par1Block.blockID == Block.planks.blockID || par1Block.blockID == Block.bookShelf.blockID || par1Block.blockID == Block.stoneDoubleSlab.blockID || par1Block.blockID == Block.stoneSingleSlab.blockID || par1Block.blockID == Block.pumpkin.blockID || par1Block.blockID == Block.pumpkinLantern.blockID;
    }

 

;)

I notice "stoneDoubleSlab" and "stoneSingleSlab" in there... mayhap you want to change that to woodDouble/SingleSlab?

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello! When I'm trying to get items by tag during the recipe serialization, I'm getting an empty list. I have a guess that item tags're not loaded by the time minecraft loads my recipes. Here's my code: Class that saves information about ingredient's count Recipe serializer with some aux methods: Registry: Example of the json recipe file:  
    • I tried to install client forge on my linux desktop. But after "installation" it's missing forge[version].jar file in .minecraft/versions. I tried java 11 and 8 environment with same result. Here link to log file from installation: https://drive.google.com/file/d/1vtg9NT-WX5ilb1aNUvZlOv54gKWJuaT1/view?usp=share_link. I don't know what to do. I give for every directory permissions that I don't think that is issue. I will try check older versions if universal file work. Debian 11 (kernel 5.10)
    • I recently got error 1 in the launcher, so I restarted the .minecraft. After restarting it, I can't get the Forge 1.19.2 - 43.1.1 installer to run, I tried other versions and I get the same result, it opens a black box that closes instantly and nothing happens. I already tried to restart my pc, minecraft, update and reinstall java, run vanilla 1.19.2 and more recent versions of the game, disable Windows Firewall and antivirus and I still haven't solved it. Many times I installed forge and never ran into this problem. If I could receive assistance I would be very grateful.  
    • Here's the default loot table for gravel block: { "type": "minecraft:block", "pools": [ { "rolls": 1.0, "bonus_rolls": 0.0, "entries": [ { "type": "minecraft:alternatives", "children": [ { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:match_tool", "predicate": { "enchantments": [ { "enchantment": "minecraft:silk_touch", "levels": { "min": 1 } } ] } } ], "name": "minecraft:gravel" }, { "type": "minecraft:alternatives", "conditions": [ { "condition": "minecraft:survives_explosion" } ], "children": [ { "type": "minecraft:item", "conditions": [ { "condition": "minecraft:table_bonus", "enchantment": "minecraft:fortune", "chances": [ 0.1, 0.14285715, 0.25, 1.0 ] } ], "name": "minecraft:flint" }, { "type": "minecraft:item", "name": "minecraft:gravel" } ] } ] } ] } ] } This is a finicky loot table. If I add anything to it, nothing drops. I've added pools, entries, children ... you name it. Does anyone know the particulars about this table? I mean, periodically gravel drops flint instead of a gravel block. I understand the condition that could drop flint if the block survives an explosion. Otherwise, it drops the gravel block itself. I would like to further understand why the use of `children` and the set of `chance` values given in the explosion child entry. What I do understand is that `"type" : "minecraft:alternatives"` means that if this child/entry is successful, then it stops generating loot for this entry/pool. How often does the flint drop and is that taken care of in another location? Is that in a `"condition" : "minecraft:table_bonus"` loot table? Hmmm... I'll have to go take a look and see if there is something called table_bonus.json.
    • No mod is working. Im trying to create a pack for some friends but cant get past this. I reinstalled Forge and I got a complete install pop up like normal   [29Jan2023 14:17:58.884] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, Oddie23110, --version, 1.19.3-forge-44.1.8, --gameDir, C:\Users\Oddie\AppData\Roaming\.minecraft, --assetsDir, C:\Users\Oddie\AppData\Roaming\.minecraft\assets, --assetIndex, 2, --uuid, d7db39d1b1f940ac841852e76fe1844c, --accessToken, ????????, --clientId, M2JmY2FlYTktNzE1OC00NzYwLThlMzUtNGIxYzA1MzcwNTli, --xuid, 2535431288182209, --userType, msa, --versionType, release, --width, 1600, --height, 900, --launchTarget, forgeclient, --fml.forgeVersion, 44.1.8, --fml.mcVersion, 1.19.3, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20221207.122022] [29Jan2023 14:17:58.889] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.8+10.0.8+main.0ef7e830 starting: java version 17.0.3 by Microsoft; OS Windows 10 arch amd64 version 10.0 [29Jan2023 14:17:59.094] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/Oddie/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2392!/ Service=ModLauncher Env=CLIENT [29Jan2023 14:17:59.498] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Oddie\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.19.3-44.1.8\fmlcore-1.19.3-44.1.8.jar is missing mods.toml file [29Jan2023 14:17:59.503] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Oddie\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.19.3-44.1.8\javafmllanguage-1.19.3-44.1.8.jar is missing mods.toml file [29Jan2023 14:17:59.507] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Oddie\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.19.3-44.1.8\lowcodelanguage-1.19.3-44.1.8.jar is missing mods.toml file [29Jan2023 14:17:59.513] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Oddie\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.19.3-44.1.8\mclanguage-1.19.3-44.1.8.jar is missing mods.toml file [29Jan2023 14:17:59.653] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select a dependency jar for JarJar which was passed in as source: flywheel. Using Mod File: C:\Users\Oddie\AppData\Roaming\.minecraft\mods\flywheel-forge-1.19.2-0.6.8.a.jar [29Jan2023 14:17:59.654] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 1 dependencies adding them to mods collection [29Jan2023 14:18:00.624] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [29Jan2023 14:18:00.629] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.19.3-forge-44.1.8, --gameDir, C:\Users\Oddie\AppData\Roaming\.minecraft, --assetsDir, C:\Users\Oddie\AppData\Roaming\.minecraft\assets, --uuid, d7db39d1b1f940ac841852e76fe1844c, --username, Oddie23110, --assetIndex, 2, --accessToken, ????????, --clientId, M2JmY2FlYTktNzE1OC00NzYwLThlMzUtNGIxYzA1MzcwNTli, --xuid, 2535431288182209, --userType, msa, --versionType, release, --width, 1600, --height, 900] [29Jan2023 14:18:00.827] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/renderer/texture/TextureAtlas$Preparations (java.lang.ClassNotFoundException: net.minecraft.client.renderer.texture.TextureAtlas$Preparations) [29Jan2023 14:18:00.827] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.renderer.texture.TextureAtlas$Preparations was not found flywheel.mixins.json:atlas.SheetDataAccessor [29Jan2023 14:18:00.840] [main/WARN] [mixin/]: Error loading class: me/jellysquid/mods/sodium/client/render/chunk/data/ChunkRenderData$Builder (java.lang.ClassNotFoundException: me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData$Builder) [29Jan2023 14:18:00.840] [main/WARN] [mixin/]: @Mixin target me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData$Builder was not found flywheel.mixins.json:instancemanage.SodiumChunkRenderDataMixin [29Jan2023 14:18:00.853] [main/WARN] [mixin/]: Error loading class: com/mojang/math/Matrix3f (java.lang.ClassNotFoundException: com.mojang.math.Matrix3f) [29Jan2023 14:18:00.854] [main/WARN] [mixin/]: @Mixin target com.mojang.math.Matrix3f was not found flywheel.mixins.json:matrix.Matrix3fMixin [29Jan2023 14:18:00.855] [main/WARN] [mixin/]: Error loading class: com/mojang/math/Matrix4f (java.lang.ClassNotFoundException: com.mojang.math.Matrix4f) [29Jan2023 14:18:00.856] [main/WARN] [mixin/]: @Mixin target com.mojang.math.Matrix4f was not found flywheel.mixins.json:matrix.Matrix4fMixin [29Jan2023 14:18:00.974] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/renderer/texture/TextureAtlas$Preparations (java.lang.ClassNotFoundException: net.minecraft.client.renderer.texture.TextureAtlas$Preparations) [29Jan2023 14:18:03.993] [pool-3-thread-1/INFO] [net.minecraft.util.datafix.DataFixers/]: Building unoptimized datafixer [29Jan2023 14:18:05.173] [Render thread/WARN] [mixin/]: Error loading class: com/mojang/math/Quaternion (java.lang.ClassNotFoundException: com.mojang.math.Quaternion) [29Jan2023 14:18:05.175] [Render thread/FATAL] [mixin/]: Mixin apply failed flywheel.mixins.json:matrix.PoseStackMixin -> com.mojang.blaze3d.vertex.PoseStack: org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException Unexpecteded ClassMetadataNotFoundException whilst transforming the mixin class: [MAIN Applicator Phase -> flywheel.mixins.json:matrix.PoseStackMixin -> Apply Methods -> (Lcom/mojang/math/Quaternion;)Lcom/jozufozu/flywheel/util/transform/TransformStack;:multiply -> Transform LVT -> var=quaternion -> desc=Lcom/mojang/math/Quaternion;] org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException: Unexpecteded ClassMetadataNotFoundException whilst transforming the mixin class: [MAIN Applicator Phase -> flywheel.mixins.json:matrix.PoseStackMixin -> Apply Methods -> (Lcom/mojang/math/Quaternion;)Lcom/jozufozu/flywheel/util/transform/TransformStack;:multiply -> Transform LVT -> var=quaternion -> desc=Lcom/mojang/math/Quaternion;]     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformMethod(MixinTargetContext.java:491) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyNormalMethod(MixinApplicatorStandard.java:532) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMethods(MixinApplicatorStandard.java:518) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.applyMixin(MixinApplicatorStandard.java:386) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:325) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:383) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:365) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:250) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.service.modlauncher.MixinTransformationHandler.processClass(MixinTransformationHandler.java:131) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.launch.MixinLaunchPluginLegacy.processClass(MixinLaunchPluginLegacy.java:131) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:156) ~[modlauncher-10.0.8.jar:10.0.8+10.0.8+main.0ef7e830]     at cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:113) ~[securejarhandler-2.1.6.jar:?]     at cpw.mods.cl.ModuleClassLoader.lambda$findClass$15(ModuleClassLoader.java:219) ~[securejarhandler-2.1.6.jar:?]     at cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:229) ~[securejarhandler-2.1.6.jar:?]     at cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:219) ~[securejarhandler-2.1.6.jar:?]     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:135) ~[securejarhandler-2.1.6.jar:?]     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]     at com.mojang.blaze3d.systems.RenderSystem.<clinit>(RenderSystem.java:83) ~[1.19.3-forge-44.1.8.jar:?]     at net.minecraft.client.main.Main.m_239872_(Main.java:174) ~[1.19.3-forge-44.1.8.jar:?]     at net.minecraft.client.main.Main.main(Main.java:51) ~[1.19.3-forge-44.1.8.jar:?]     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:27) ~[fmlloader-1.19.3-44.1.8.jar:?]     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.8.jar:?]     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?] Caused by: org.spongepowered.asm.mixin.throwables.ClassMetadataNotFoundException: com.mojang.math.Quaternion     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformSingleDescriptor(MixinTargetContext.java:983) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformSingleDescriptor(MixinTargetContext.java:943) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformLVT(MixinTargetContext.java:544) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     at org.spongepowered.asm.mixin.transformer.MixinTargetContext.transformMethod(MixinTargetContext.java:450) ~[mixin-0.8.5.jar:0.8.5+Jenkins-b310.git-155314e6e91465dad727e621a569906a410cd6f4]     ... 36 more  
  • Topics

×
×
  • Create New...

Important Information

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