Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • (1.11.2) Replacing Blocks
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
J_Dev

(1.11.2) Replacing Blocks

By J_Dev, July 26, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 26, 2017

I created a new block for Minecraft 1.11.2. How do i go about replacing vanilla blocks with my new block? for example, i want to replace Grass and dirt with my new block. 

  • Quote

Share this post


Link to post
Share on other sites

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 26, 2017

Does Nobody know? seriously?

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted July 26, 2017

Please clarify what you mean by "replace".

  • Quote

Share this post


Link to post
Share on other sites

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 26, 2017
7 minutes ago, diesieben07 said:

Please clarify what you mean by "replace".

I want to completely get rid of Grass and dirt and instead spawn only my block

 

  • Quote

Share this post


Link to post
Share on other sites

JimiIT92    19

JimiIT92

JimiIT92    19

  • Dragon Slayer
  • JimiIT92
  • Members
  • 19
  • 723 posts
Posted July 26, 2017 (edited)

If you don't care about the generated one but only the placed one you can catch the onBlockPlaced event and set your block instead of vanilla one (like i do with my custom flower pot)

Edited July 26, 2017 by JimiIT92
  • Quote

Share this post


Link to post
Share on other sites

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 27, 2017
11 hours ago, diesieben07 said:

 

No, I want it to generate my block instead of Grass and Dirt

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted July 27, 2017

Update to 1.12 and use the new registry override feature.

  • Quote

Share this post


Link to post
Share on other sites

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 27, 2017
1 hour ago, diesieben07 said:

Update to 1.12 and use the new registry override feature.

Thank you, I updated to 1.12. But, how exactly do i do what you are describing, or do you know where i can read up on it?

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted July 27, 2017

You just register your Block with the registry name that you want to override and it will override the existing value.

  • Quote

Share this post


Link to post
Share on other sites

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 27, 2017
2 hours ago, diesieben07 said:

You just register your Block with the registry name that you want to override and it will override the existing value.

I did this and it worked. Thank you so much, however the block is no longer textured. How do i fix this?

 

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1624

Choonster

Choonster    1624

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1624
  • 5050 posts
Posted July 27, 2017
19 minutes ago, J_Dev said:

I did this and it worked. Thank you so much, however the block is no longer textured. How do i fix this?

 

That could be related to this issue. Are you using the latest version of Forge?

  • Quote

Share this post


Link to post
Share on other sites

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 27, 2017
6 minutes ago, Choonster said:

 

That could be related to this issue. Are you using the latest version of Forge?

yes

 

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1624

Choonster

Choonster    1624

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1624
  • 5050 posts
Posted July 27, 2017
1 minute ago, J_Dev said:

yes

 

Does the model work in single player?

  • Quote

Share this post


Link to post
Share on other sites

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 27, 2017
Just now, Choonster said:

 

Does the model work in single player?

No

 

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1624

Choonster

Choonster    1624

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1624
  • 5050 posts
Posted July 27, 2017
1 hour ago, J_Dev said:

No

 

Then it's probably an issue with your code rather than the Forge issue I linked.

 

Please post your code, the relevant JSON files and the FML log (logs/fml-client-latest.log in the game directory) using Gist or Pastebin.

  • Quote

Share this post


Link to post
Share on other sites

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 27, 2017
15 minutes ago, Choonster said:

 

Then it's probably an issue with your code rather than the Forge issue I linked.

 

Please post your code, the relevant JSON files and the FML log (logs/fml-client-latest.log in the game directory) using Gist or Pastebin.

https://pastebin.com/J_Dev

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1624

Choonster

Choonster    1624

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1624
  • 5050 posts
Posted July 27, 2017
Quote

[10:44:52] [main/ERROR] [FML/]: Exception loading model for variant minecraft:grass#normal for blockstate "minecraft:grass"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model minecraft:grass#normal with loader VariantLoader.INSTANCE, skipping
...
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException

 

Your replacement Block doesn't have the BlockGrass.SNOWY property, so Minecraft tries to load the model from the minecraft:grass#normal variant, which doesn't exist. You should include this property in your Block.

 

You should also register an IStateMapper for your replacement Block so that its models are loaded from a different blockstates file. This will prevent resource packs that replace the minecraft:grass blockstates file from replacing your Block's models (though resource packs that replace your blockstates file will still work, this is intended).

 

Your IStateMapper can extend StateMapperBase and implement StateMapperBase#getModelResourceLocation to do something similar to DefaultStateMapper#getModelResourceLocation, but use the location of your blockstates file as the domain and path of the ModelResourceLocation instead of using the registry name.

 

 

Quote

[10:44:52] [main/WARN] [FML/]: Unable to set public static net.minecraft.block.BlockGrass net.minecraft.init.Blocks.GRASS with value Block{minecraft:grass} (minecraft:grass)
java.lang.reflect.InvocationTargetException: null
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source) ~[?:?]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_102]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_102]
    at net.minecraftforge.registries.ObjectHolderRef$FinalFieldHelper.setField(ObjectHolderRef.java:180) ~[ObjectHolderRef$FinalFieldHelper.class:?]
    at net.minecraftforge.registries.ObjectHolderRef.apply(ObjectHolderRef.java:146) [ObjectHolderRef.class:?]

    at net.minecraftforge.registries.ObjectHolderRegistry.applyObjectHolders(ObjectHolderRegistry.java:170) [ObjectHolderRegistry.class:?]

...

Caused by: java.lang.IllegalArgumentException: Can not set static net.minecraft.block.BlockGrass field net.minecraft.init.Blocks.GRASS to com.j_dev.witherapocalypse.blocks.BlockWithered_Debris

 

Your replacement Block needs to extend BlockGrass.

  • Quote

Share this post


Link to post
Share on other sites

J_Dev    0

J_Dev

J_Dev    0

  • Tree Puncher
  • J_Dev
  • Members
  • 0
  • 17 posts
Posted July 27, 2017
1 hour ago, Choonster said:

 

Your replacement Block doesn't have the BlockGrass.SNOWY property, so Minecraft tries to load the model from the minecraft:grass#normal variant, which doesn't exist. You should include this property in your Block.

 

You should also register an IStateMapper for your replacement Block so that its models are loaded from a different blockstates file. This will prevent resource packs that replace the minecraft:grass blockstates file from replacing your Block's models (though resource packs that replace your blockstates file will still work, this is intended).

 

Your IStateMapper can extend StateMapperBase and implement StateMapperBase#getModelResourceLocation to do something similar to DefaultStateMapper#getModelResourceLocation, but use the location of your blockstates file as the domain and path of the ModelResourceLocation instead of using the registry name.

 

 

 

Your replacement Block needs to extend BlockGrass.

Okay I did everything else but I do not know how to do the IStateMapper thing. How do i do this, or could you point me to where i can learn about this. Thank you so much for the help so far, i reallt appreciate it. I am new to modding and all the help makes me really want to learn more.

 

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1624

Choonster

Choonster    1624

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1624
  • 5050 posts
Posted July 27, 2017
11 minutes ago, J_Dev said:

Okay I did everything else but I do not know how to do the IStateMapper thing. How do i do this, or could you point me to where i can learn about this.

 

Look at the DefaultStateMapper#getModelResourceLocation method to see how it returns a ModelResourceLocation with the Block's registry name as the domain/path and a property string of the IBlockState's property and values as the variant.

 

You need to extend StateMapperBase and implement StateMapperBase#getModelResourceLocation to return a ModelResourceLocation with your blockstates file's domain (your mod ID) and name as the domain/path and the property string as the variant.

 

If your mod ID is jwa and your blockstates file is called withered_debris.json, use "jwa:withered_debris" as the first argument of the ModelResourceLocation constructor. 

 

Once you've created this class, register an instance of it for your Block by calling ModelLoader.setCustomStateMapper. Do this in ModelRegistryEvent.

  • Like 1
  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • martingabrixx
      CORAL TOMBSTONE MOD NOT WORKS

      By martingabrixx · Posted 8 minutes ago

      the mod of version 1.12.2 works in minecraft in individual mode but in my online server of 1.12.2 it doesn't work, could someone help me?
    • Oliviafrostpaw
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw · Posted 36 minutes ago

      After some poking, the function is not firing whatsoever
    • RaphGamingz
      [1.14.4] Dimensions

      By RaphGamingz · Posted 1 hour ago

      Anyone?
    • RaphGamingz
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By RaphGamingz · Posted 1 hour ago

      Are you sure this is correct, shouldn’t it be  new ResourceLocation(“minecraft”,”grass”) And is the function firing?
    • mervinrasquinha
      Introducing Stonecage

      By mervinrasquinha · Posted 4 hours ago

      If you’re interested in a modpack with a little bit of tech, a little bit of magic, and a lot of adventure, I would love for you to try out my modpack Stonecage. Stonecage takes mods you might have seen before (and many you might not have), and adds a twist to them to make them fresh again. The main gimmick of the pack is that it makes stone unmineable, meaning you’ll have to explore caves and dungeons the way they were intended, and find solutions to problems you never knew existed. It aims to be a hardcore pack that’s more fair than most, and leaves you to seek combat and adventure on your own terms. While you may start out weak, you’ll find magical artifacts known as curios in your adventures that can be crafted into powerful baubles that will help you in combat and elsewhere. You’ll also find pieces of ancient machines that with research can be deciphered and put back together, bringing industry back to a world that has long been without it. The pack is heavily centered around researching these lost machines, and the research table will guide you through the modpack while giving you more freedom than a quest book would. With a small, curated list of mods, most computers will likely be able to run it, and the many, many lines of scripting keep these mods integrated into what feels like a cohesive whole. If this sounds like fun to you, I encourage you to check it out. If you do, I hope you have as much fun playing it as I did creating it.
  • Topics

    • martingabrixx
      0
      CORAL TOMBSTONE MOD NOT WORKS

      By martingabrixx
      Started 8 minutes ago

    • Oliviafrostpaw
      7
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw
      Started December 8

    • RaphGamingz
      1
      [1.14.4] Dimensions

      By RaphGamingz
      Started Yesterday at 07:45 AM

    • mervinrasquinha
      0
      Introducing Stonecage

      By mervinrasquinha
      Started 4 hours ago

    • Darth_Cobalt
      0
      Forge 1.14.4 crashes.

      By Darth_Cobalt
      Started 4 hours ago

  • Who's Online (See full list)

    • leonnardobr1
    • martingabrixx
    • ricoc90
    • crackedEgg
    • Simon_kungen
    • grillo781
    • Redstoneguy129
    • TrogloGeek
    • Oliviafrostpaw
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • (1.11.2) Replacing Blocks
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community