Jump to content

(1.16.1).setLightLevel and .setRequiresTool gives error Cannot resolve method 'setLightLevel' in 'Properties'


20ChenM

Recommended Posts

I just moved my 1.15.2 mod to 1.16.1 by replacing the build.gradle with a 1.16.1 build.gradle from the 1.16.1 mdk. I then recreated the workspace. For some reason though, the .set commands dont work and I get an error saying:Cannot resolve method 'setLightLevel' in 'Properties'

 

 

My Code:

package com.Michael.TutorialMod2.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.ToolType;

public class RubyBlock extends Block {


    public RubyBlock() {
        super(Block.Properties.create(Material.IRON)
        .hardnessAndResistance(5.0f,6.0f)
                        .sound(SoundType.METAL)
                .harvestLevel(3)
                .harvestTool(ToolType.PICKAXE)
                .setLightLevel(value ->1)
        );
    }
}
Link to comment
Share on other sites

Hi

Every time the Minecraft version updates, there are a lot of changes to functions; sometimes it's just the names, other times the signatures changes, and sometimes whole classes and groups of classes are refactored to work differently.

 

The best way to fix these problems during an update is 

1) Find a vanilla class that uses the method in (eg) 1.15.2

2) Find the same vanilla class in 1.16.3, browse through the code until you find the code that calls the same method and see what it has changed to.

 

90% of the time you'll find it within a minute.

 

-TGG

Link to comment
Share on other sites

I figured it out. My mappings were out of date. i was in 20200543.1.16 but I should have been in 20200723.1.16.1 

For anyone that has the same problem as me and comes across this forum, you can change the mapping version by going to the build.gradle file in your forge mdk and it will be around line 29.

Link to comment
Share on other sites

50 minutes ago, 20ChenM said:

what is an srg name?

Every class, method, field, parameter, and local variable has 4 names:

 

  1. Notch Names (these are what the game is originally programmed in). We do not have these for most things, Mojang is (supposedly?) publishing a deobf map, but I don't think it is in use by Forge yet.
  2. Obfuscated Names (these are what you would see if you opened Minecraft's source in a decompiler). a, aa, ab, abb, etc. It is unreadable.
  3. SRG Names (these are the first step in deobfuscation, machine translation from the obfuscated source to a consistent mapping). Not human readable, but the same method will always deobf to the same SRG name even as things change and get new Obfuscated names.
  4. MCP Names (these are the human readable ones). These take time and constant effort to map.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

5 hours ago, 20ChenM said:

I figured it out. My mappings were out of date. i was in 20200543.1.16 but I should have been in 20200723.1.16.1 

For anyone that has the same problem as me and comes across this forum, you can change the mapping version by going to the build.gradle file in your forge mdk and it will be around line 29.

  

I never had issues with this before, but I guess the mappings that come with the MDK download are out of date? Didn't know we had to manually change them when downloading the MDK I guess that's new also on 1.16. Or is there a reason the "Recommended" version doesn't update this value?

 

My 1.16.3 download (forge-1.16.3-34.1.0-mdk) had on mappings

 

mappings channel: 'snapshot', version: '20200514-1.16'

 

Where you got the 20200723.1.16.1 from? So I can got get the corresponding for the 1.16.3- 34.1.0 version.

 

Thanks a lot.

 

 

Link to comment
Share on other sites

5 minutes ago, American2050 said:

  

I never had issues with this before, but I guess the mappings that come with the MDK download are out of date? Didn't know we had to manually change them when downloading the MDK I guess that's new also on 1.16. Or is there a reason the "Recommended" version doesn't update this value?

 

My 1.16.3 download (forge-1.16.3-34.1.0-mdk) had on mappings

 


mappings channel: 'snapshot', version: '20200514-1.16'

 

Where you got the 20200723.1.16.1 from? So I can got get the corresponding for the 1.16.3- 34.1.0 version.

 

Thanks a lot.

 

 

Take a look at this topic here: https://forums.minecraftforge.net/topic/91282-1161-setrequirestool/?tab=comments#comment-423212

  • Thanks 1

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
  • Topics

×
×
  • Create New...

Important Information

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