Jump to content

Understanding texture/model of blocks in inventory


indemnity83

Recommended Posts

 

I'm sure I'm just being dense because even though I've tried to find tutorials or other examples here in the forums I still cannot get a simple block with variants to render the item in my hand, inventory or on the ground. The full source code is here, I'll try to pluck out the bits I think are important but it may just be easier to go look at the actual source code. 

 

I have a block with variants; those variants determine the texture to be applied (among other things). And I've registered the single block and the item block inside my preInit() handler

 

public class BlockIronTank extends Block {
	public static final PropertyEnum<IronTankType> VARIANT = PropertyEnum.create("variant", IronTankType.class);

    ...
}

 

// This happens inside the preInit() handler
GameRegistry.register(ironTankBlock);
GameRegistry.register(ironTankItemBlock);

 

I also have a blockstate and block model:

 

Quote

 

blockstate:

{
  "forge_marker": 1,
  "variants": {
    "variant": {
      "glass": {
        "comment": "This is just here to suppress a warning that the glass variant has no blockstate, it's never actually used",
        "textures": {
          "particle": "buildcraftfactory:blocks/tank/side",
          "end": "buildcraftfactory:blocks/tank/end",
          "side": "buildcraftfactory:blocks/tank/side",
          "side_stacked": "buildcraftfactory:blocks/tank/side_joined_below"
        }
      },
      "copper": {
        "textures": {
          "particle": "irontanks:blocks/coppertank/side",
          "end": "irontanks:blocks/coppertank/end",
          "side": "irontanks:blocks/coppertank/side",
          "side_stacked": "irontanks:blocks/coppertank/side_stacked"
        }
      },
      "iron": {
        "textures": {
          "particle": "irontanks:blocks/irontank/side",
          "end": "irontanks:blocks/irontank/end",
          "side": "irontanks:blocks/irontank/side",
          "side_stacked": "irontanks:blocks/irontank/side_stacked"
        }
      },
      "silver": {
        "textures": {
          "particle": "irontanks:blocks/silvertank/side",
          "end": "irontanks:blocks/silvertank/end",
          "side": "irontanks:blocks/silvertank/side",
          "side_stacked": "irontanks:blocks/silvertank/side_stacked"
        }
      },
      "gold": {
        "textures": {
          "particle": "irontanks:blocks/goldtank/side",
          "end": "irontanks:blocks/goldtank/end",
          "side": "irontanks:blocks/goldtank/side",
          "side_stacked": "irontanks:blocks/goldtank/side_stacked"
        }
      },
      "diamond": {
        "textures": {
          "particle": "irontanks:blocks/diamondtank/side",
          "end": "irontanks:blocks/diamondtank/end",
          "side": "irontanks:blocks/diamondtank/side",
          "side_stacked": "irontanks:blocks/diamondtank/side_stacked"
        }
      },
      "obsidian": {
        "textures": {
          "particle": "irontanks:blocks/obsidiantank/side",
          "end": "irontanks:blocks/obsidiantank/end",
          "side": "irontanks:blocks/obsidiantank/side",
          "side_stacked": "irontanks:blocks/obsidiantank/side_stacked"
        }
      }
    }
  }
}

 

model:

{
  "elements": [
    {
      "from": [2, 0, 2],
      "to": [14, 16, 14],
      "faces": {
        "down": {"texture": "#end", "cullface": "down"},
        "up": {"texture": "#end", "cullface": "up"},
        "north": {"texture": "#side"},
        "south": {"texture": "#side"},
        "west": {"texture": "#side"},
        "east": {"texture": "#side"}
      }
    }
  ]
}

 

So far everything works. I can place the blocks and they render as expected and it seems like all that should be required at this point it to apply some transformations so it scales right in the player's hand etc; so I have an iron_tank item model too that inherits the block model and applies the transformations:

 

{
  "parent": "irontanks:block/iron_tank",
  "display": {
    "gui": {
      "rotation": [30, 225, 0],
      "translation": [0, 0, 0],
      "scale": [0.625, 0.625, 0.625]
    },
    "ground": {
      "rotation": [0, 0, 0],
      "translation": [0, 3, 0],
      "scale": [0.25, 0.25, 0.25]
    },
    "fixed": {
      "rotation": [0, 0, 0],
      "translation": [0, 0, 0],
      "scale": [0.5, 0.5, 0.5]
    },
    "thirdperson_righthand": {
      "rotation": [75, 45, 0],
      "translation": [0, 2.5, 0],
      "scale": [0.375, 0.375, 0.375]
    },
    "firstperson_righthand": {
      "rotation": [0, 45, 0],
      "translation": [0, 0, 0],
      "scale": [0.40, 0.40, 0.40]
    },
    "firstperson_lefthand": {
      "rotation": [0, 225, 0],
      "translation": [0, 0, 0],
      "scale": [0.40, 0.40, 0.40]
    }
  }
}

 

Link to comment
Share on other sites

The problem is that you don't ever register a item model to your block's items, at least as far as I could tell. You need to call ModelLoader.setCustomModelResourceLocation and you can check out this thread for more info.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Semi-progress, 

 

I added the following chunk of code:

 

for (IronTankType type : IronTankType.VALUES) {
	ModelLoader.setCustomModelResourceLocation(Content.ironTankItemBlock, type.metaValue, new ModelResourceLocation(Content.ironTankItemBlock.getRegistryName(), "stacked=false,variant=" + type.name));
}

 

and now the item renders in my hand with the right shape and transformation; but now nothing has a texture (neither in my hand, nor placed as a block)

 

 

2017-07-22_09.55.06.png

Link to comment
Share on other sites

The FML log (logs/fml-client-latest.log in the game directory) should say why the textures aren't working, please post it using Gist or Pastebin.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Indeed, there aren't any model/texture errors in the log.

 

Please update your Git repository with the latest version of your code, I'd like to debug this locally.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Is it possibly because I haven't moved the rendering stuff into a client only proxy yet? I didn't actually think this was going to be a problem functionally, just performance so I wanted to get everything working, then refactor things into their best homes. 

Link to comment
Share on other sites

40 minutes ago, indemnity83 said:

Is it possibly because I haven't moved the rendering stuff into a client only proxy yet? I didn't actually think this was going to be a problem functionally, just performance so I wanted to get everything working, then refactor things into their best homes. 

 

Registering the models in common code will crash the dedicated server, but it should work in single player.

 

Something's causing the iron_tank model to be treated differently to the iron_tank_stacked model (it's loaded but not baked), but I haven't determined what that is yet.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Progress! I have the blocks rendering again, and now the item in my hand has all the right transformations, but without textures. I actually think the item in my hand not having textures is maybe a different problem having to do with blockstates and how item don't pay any attention to blockstates. 

 

What I changed was removing the "stacked" variant information from the resource string on load. No idea why that was hanging things up, but that part at least seems to be working again. 

2017-07-27_22.33.36.png

Link to comment
Share on other sites

12 hours ago, indemnity83 said:

What I changed was removing the "stacked" variant information from the resource string

The whole JSON resource paradigm is extremely fragile. Strings must be matched exactly. Your IDE isn't there to flag typos. Just one misplaced underscore or mixed-case string (semantic error) in either your JSON or the variable that must match it) can derail a JSON file, even if the JSON passes json lint (which you should be using to prove your JSON files are at least syntactically kosher). Therefore, sometimes it helps to have your text editor search for all occurrences of identifiers related to a nonfunctional object. What it fails to find might surprise you. If that doesn't trip anything, then set break points in your methods that concatenate strings so you can examine them 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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, I have built a new ai model that can create any minecraft texture 16X16 pixels from a text prompt. I've deployed this model on a server with a standard http request.  I want to build a mod where the player can enter text through the chat/text box and load the created texture from the ai model to a simple block. Any ideas for where to start?, I think the most challenging part is loading texture to an object dynamically, do you know any similar projects?
    • If donation/download revenue won't cut it I may also be willing to make arrangements to pay for at least an assistant that can deal with Networking(Pipe Logic & Packets), and ANYTHING rendering related that is not adding basic block models(Anything to do with OpenGL, especially in minecraft, makes my head spin and I just can't wrap my mind around it). We can discuss amounts through messages if it comes to this.
    • Hello, I installed minecraft 1.16.2, then i downloaded forge 1.16.2-33.0.20 and it just won t open...no error message...
    • [29may2023 23:10:06.337] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, Fabu10th, --version, 1.19.3-forge-44.1.23, --gameDir, C:\Users\fabuo\AppData\Roaming\.minecraft, --assetsDir, C:\Users\fabuo\AppData\Roaming\.minecraft\assets, --assetIndex, 2, --uuid, 1f7b7b2f9e814cf4b23dfa2f0ccb79a1, --accessToken, ????????, --clientId, N2EyZmZhMTUtYjA0OC00N2RkLTg2NTgtZDM2YTUwNTZlODFj, --xuid, 2535425619212215, --userType, msa, --versionType, release, --launchTarget, forgeclient, --fml.forgeVersion, 44.1.23, --fml.mcVersion, 1.19.3, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20221207.122022] [29may2023 23:10:06.341] [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 [29may2023 23:10:07.130] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.onLoad [29may2023 23:10:07.131] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file URL: union:/C:/Users/fabuo/AppData/Roaming/.minecraft/mods/OptiFine_1.19.3_HD_U_I3.jar%23265!/ [29may2023 23:10:07.138] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file: C:\Users\fabuo\AppData\Roaming\.minecraft\mods\OptiFine_1.19.3_HD_U_I3.jar [29may2023 23:10:07.140] [main/INFO] [optifine.OptiFineTransformer/]: Target.PRE_CLASS is available [29may2023 23:10:07.185] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/fabuo/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2398!/ Service=ModLauncher Env=CLIENT [29may2023 23:10:07.190] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.initialize [29may2023 23:10:07.783] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\fabuo\AppData\Roaming\.minecraft\libraries\net\minecraftforge\fmlcore\1.19.3-44.1.23\fmlcore-1.19.3-44.1.23.jar is missing mods.toml file [29may2023 23:10:07.787] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\fabuo\AppData\Roaming\.minecraft\libraries\net\minecraftforge\javafmllanguage\1.19.3-44.1.23\javafmllanguage-1.19.3-44.1.23.jar is missing mods.toml file [29may2023 23:10:07.791] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\fabuo\AppData\Roaming\.minecraft\libraries\net\minecraftforge\lowcodelanguage\1.19.3-44.1.23\lowcodelanguage-1.19.3-44.1.23.jar is missing mods.toml file [29may2023 23:10:07.794] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\fabuo\AppData\Roaming\.minecraft\libraries\net\minecraftforge\mclanguage\1.19.3-44.1.23\mclanguage-1.19.3-44.1.23.jar is missing mods.toml file [29may2023 23:10:07.935] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 8 dependencies adding them to mods collection [29may2023 23:10:08.445] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.transformers [29may2023 23:10:08.451] [main/INFO] [optifine.OptiFineTransformer/]: Targets: 395 [29may2023 23:10:09.288] [main/INFO] [optifine.OptiFineTransformationService/]: additionalClassesLocator: [optifine., net.optifine.] [29may2023 23:10:10.427] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [29may2023 23:10:10.610] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [ca.spottedleaf.starlight.mixin.MixinConnector] [29may2023 23:10:10.610] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.19.3-forge-44.1.23, --gameDir, C:\Users\fabuo\AppData\Roaming\.minecraft, --assetsDir, C:\Users\fabuo\AppData\Roaming\.minecraft\assets, --uuid, 1f7b7b2f9e814cf4b23dfa2f0ccb79a1, --username, Fabu10th, --assetIndex, 2, --accessToken, ????????, --clientId, N2EyZmZhMTUtYjA0OC00N2RkLTg2NTgtZDM2YTUwNTZlODFj, --xuid, 2535425619212215, --userType, msa, --versionType, release] [29may2023 23:10:10.650] [main/INFO] [Rubidium/]: Loaded configuration file for Rubidium: 30 options available, 0 override(s) found [29may2023 23:10:10.684] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.686] [main/WARN] [mixin/]: Reference map 'yungsextras.refmap.json' for yungsextras_forge.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.703] [main/WARN] [mixin/]: Reference map 'xlpackets.refmap.json' for xlpackets.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.718] [main/WARN] [mixin/]: Reference map 'configured.refmap.json' for configured.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.728] [main/WARN] [mixin/]: Reference map 'simplyswords-common-refmap.json' for simplyswords-common.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.729] [main/WARN] [mixin/]: Reference map 'simplyswords-forge-refmap.json' for simplyswords.mixins.json could not be read. If this is a development environment you can ignore this message [29may2023 23:10:10.767] [main/WARN] [mixin/]: Reference map 'apexcore.refmap.json' for apexcore.mixins.json could not be read. If this is a development environment you can ignore this message
    • I'm looking for someone who for the most part would be taking over my mods main development. With work I just can't give it the time it deserves but I think it will be a good mod to fill the void of BuildCraft while still having its own unique twist. It is currently still only on 1.16.5 only because I just haven't had the time to try and get an update plus there were features I was working on that I had wanted to hammer out first. Not to mention I'm just not very good at Java or Programming in general. I can get things done and they mostly work but I am just not skilled enough to keep my brain child alive and honestly optimized. My only real requirement is that if I choose to come back I want to be able to jump back in and do so(Not take over per say just add to it again from time to time). I have a basic outline of how I want things to work in general for the things not added yet that were planned features and I also have some started but not yet finished ideas in. I'm currently working on getting a repo up on github that has my most current code so that way its easier for everyone involved to contribute. I'm sure the best first step would be to update to the newest version of forge first before doing this to give the next person a good head start but I'm sure alot of my stuff needs rewritten anyways so I figured I'd do this now as it sits.  Any other questions or details can be worked out through messages but if you are interested please drop a reply. Here is the link to the curseforge page which you can use to get to the github repo: https://www.curseforge.com/minecraft/mc-mods/mechanicraft For anyone who is interested please leave a reply. You will be added to the curseforge as a member and since I will be contributing less 80% of anything that is earned/donated because of this mod will be kicked your way(Can be controlled through curseforge, they have a way to split the earning).
  • Topics

×
×
  • Create New...

Important Information

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