Jump to content

[Semi-Solved/workaround] 1.11.2 Difference in wooden_door (Blocks.OAK_DOOR) and other doors?


Recommended Posts

Posted (edited)

I am replacing all the vanilla doors with a custom behavior (BlockDoubleDoor extends BlockDoor).

 

preInit{
	ironDoor=new BlockDoubleDoor("iron_door",Material.IRON,5.0F, SoundType.METAL,"iron_door"); 
	oakDoor=new BlockDoubleDoor("wooden_door",Material.WOOD,3.0F,SoundType.WOOD,"wooden_door");
	darkOakDoor=new BlockDoubleDoor("dark_oak_door",Material.WOOD,3.0F,SoundType.WOOD,"dark_oak_door");
	spruceDoor=new BlockDoubleDoor("spruce_door",Material.WOOD,3.0F,SoundType.WOOD,"spruce_door");
	jungleDoor=new BlockDoubleDoor("jungler_door",Material.WOOD,3.0F,SoundType.WOOD,"jungle_door");
	birchDoor=new BlockDoubleDoor("birch_door",Material.WOOD,3.0F,SoundType.WOOD,"birch_door");
	acaciaDoor=new BlockDoubleDoor("acacia_door",Material.WOOD,3.0F,SoundType.WOOD,"acacia_door");
	
	substitute(Blocks.IRON_DOOR,ironDoor); //works
	//substitute(Blocks.OAK_DOOR,oakDoor);	//errors, halts
	//substitute(Blocks.DARK_OAK_DOOR,darkOakDoor); //errors, halts
	
	substitute(Blocks.SPRUCE_DOOR,spruceDoor); //works
	substitute(Blocks.JUNGLE_DOOR,jungleDoor); //works
	substitute(Blocks.BIRCH_DOOR,birchDoor);	//works
	substitute(Blocks.ACACIA_DOOR,acaciaDoor); //works


}
public BlockDoubleDoor(String name, Material materialIn,float hardness, SoundType sound,String unlocalizedname){
		super(materialIn);
		this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(OPEN, Boolean.valueOf(false)).withProperty(HINGE, BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf(false)).withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER));
        setUnlocalizedName(unlocalizedname);
        setHardness(hardness);
        setSoundType(sound);
        
        
	}

 

public static void substitute(Block toReplace, Block newBlock) {
		if(newBlock instanceof BlockDoor){
			substitute(toReplace, newBlock, new ItemDoor(newBlock));
		}
		else{
			substitute(toReplace, newBlock, new ItemBlock(newBlock));
		}
	}

ublic static void substitute(Block toReplace, Block newBlock, Item newItem) {
		try {
			ResourceLocation oldName = Block.REGISTRY.getNameForObject(toReplace);
			String nameToSubstitute = oldName.toString();
			String nameToRegister = DadMod.modId + ":" + oldName.getResourcePath();
			
			System.out.println("Substitute:"+nameToSubstitute+" with "+nameToRegister);
			
			newBlock.setRegistryName(nameToRegister);
			GameRegistry.addSubstitutionAlias(nameToSubstitute.toString(), GameRegistry.Type.BLOCK, newBlock);
			
			newItem.setRegistryName(nameToRegister);
			GameRegistry.addSubstitutionAlias(nameToSubstitute.toString(), GameRegistry.Type.ITEM, newItem);
		} catch (ExistingSubstitutionException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}

error when trying to substitute dark oak or wooden doors:

"

java.lang.NullPointerException: Initializing game
        at net.minecraft.client.renderer.block.model.ModelResourceLocation.<init>(ModelResourceLocation.java:24)
        at net.minecraft.client.renderer.block.statemap.DefaultStateMapper.getModelResourceLocation(DefaultStateMapper.java:15)
        at net.minecraft.client.renderer.block.statemap.StateMapperBase.putStateModelLocations(StateMapperBase.java:56)
        at net.minecraft.client.renderer.block.statemap.BlockStateMapper.getVariants(BlockStateMapper.java:74)
        at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:122)
        at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:252)"

 

Seems like the replacement is working, but something about loading models is not.

 

All the jsons (blockstates,models (block & items), textures (with variants)) for all the types of doors were copied over to my projects and verified mutliple times that they are in the correct directories.

 

Is there anything different about the Dark Oak and Wooden doors that would cause them to fail, while the other ones work?

 

Edited by aw_wolfe
problem solved by isolating substitution in new mod by itself
Posted

Small progress, If I change to

//ok, I really don't think this was doing this before. But if I only register one of them it works, but trying to register both does not.

//works
	substitute(Blocks.OAK_DOOR,oakDoor);	
	//substitute(Blocks.DARK_OAK_DOOR,darkOakDoor);

//works
	//substitute(Blocks.OAK_DOOR,oakDoor);	
	substitute(Blocks.DARK_OAK_DOOR,darkOakDoor);

//errors
	substitute(Blocks.OAK_DOOR,oakDoor);	
	substitute(Blocks.DARK_OAK_DOOR,darkOakDoor);

 

Posted

Go to the log file and look for JSON warnings. Better yet, set a breakpoint in the JSON loader (and anywhere else that looks informative) and run in the debugger.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

No warnings in the log. I've been trying to debug for a bit, but not super familiar with eclipse and conditional breakpoints..so taking a while...not working the way I think it should. Anyway, ends up crashing when

 

protected void loadBlock(BlockStateMapper blockstatemapper, Block block, final ResourceLocation resourcelocation)

 

gets passed a resourcelocation with one of the original doors (class BlockDoor --instead of my BlockDoubleDoor and the resource location is a null).

Actual fault:

ModelBakery...

private ResourceLocation getBlockstateLocation(ResourceLocation location) // location is null
    {
        return new ResourceLocation(location.getResourceDomain(), "blockstates/" + location.getResourcePath() + ".json");
    }

 

Now, why is an original BlockDoor getting passed in? Why is it null? Not sure, would need to back continue tracking down.

 

However, I wanted to create a new project and just have the double doors, isolate my issue and post to github for help.  However, now....it compiles and runs , however the texutures aren't getting mapped. Arg!! same directory structure from my other project.  I'm not seeing my mapping error. Sees the language mappings, model mappings work, and my doubledoor functions, just get the pink/black blocks and items. I need sleep.

 

One step forward, two steps backward.

 

It's here if you have any inkling to take a look and see why the textures aren't mapping.

https://github.com/awwolfe/minecraft_double_door

 

Posted
22 hours ago, aw_wolfe said:

get the pink/black blocks and items.

Feed your json files to jsonlint, then pick through them looking for tiny errors (like errant underscores, capitalization etc), then post them here.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

jeffryfisher, super thanks for taking the time to try and help.

 

I have no idea why the doubledoor issues was failing in my original mod. Again, if either oak (wooden) or dark oak were substituted it worked fine, but if both were, then crashed. I have to assume something else in my mod was causing an issue, or forge had difficulty when a lot of other items/blocks are added, some kind of overflow issue ?

 

Anyway, isolating the double doors into a new mod showed that both could be substituted if done in a mod by itself.  Maybe a better design anyway to have separate mods with segragated functionality, rather than piling everything into a single mod.

 

I spent way too much time assuming something was wrong with the mapping of modid/item, directory structure, json files etc....Turned out I was calling the substitution in the fml init instead of preInit.  Arg, ugh. kicking myself, but nice to be able to move on to something else.

 

I updated the github repro. I love the doubledoor functionality, maybe someone else will want it or can use the code examples.

 

Tony

Posted

Your problem could still reappear later with your mod. If you register or substitue new items, for example. If it happens try changing the order of registration or try to register placeholder entries.

I reported this bug with substitution here : https://github.com/MinecraftForge/MinecraftForge/issues/3837

Note I said 19 in the report, but I think there are other value threshold than can trigger the bug. I have been trying for the last few days to precisely figure out the pattern without much success, but there's definitely one. Your classes&JSON are good and unrelated with this.

  • Like 1
Posted

Koward,

Thanks. I guess I'm still at the point where I assume anything wrong is my issue. Good to know that maybe I'm getting the hang of things...sorta. 

 

You do any custom work on Forge itself?

I was trying to setup a modified forge workspace, but couldn't get it to generate a complete snapshot (only got a few files).  Wanted to be able to substitute other things than Items or blocks.  Between only basic+ java, new to me gradle, new to me maven, new to me forge, and little time,  just couldn't get it and put it on the back burner.  Eventually, as I get a better understanding, I want to go back and work on a few things in forge itself.

Posted

Well it's a bit hard to help "just like that", all I can recommend you is to watch CPW's video ( https://www.youtube.com/watch?v=yanCpy8p2ZE ) if it's not already done.

There is already a PR to extend substitution, but it's for 1.10 so this one will not be accepted. You can find it here : https://github.com/MinecraftForge/MinecraftForge/pull/3462

Maybe there could also be a method in IForgeRegistry<T>, that would feel consistent with the new register events introduced in 1.11.

But all of this is a bit useless if that bloody bug is left unfixed ><".

  • Like 1

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

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
    • The link to your log does not work, it says it is forbidden, Error, this is a private paste or is pending moderation.
  • Topics

×
×
  • Create New...

Important Information

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