Jump to content

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


aw_wolfe

Recommended Posts

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
Link to comment
Share on other sites

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);

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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