Jump to content

Jontom Xire

  • Posts

  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Jontom Xire's Achievements

Tree Puncher

Tree Puncher (2/8)



  1. You are right, it was the community wiki: https://forge.gemwire.uk/wiki/Model_JSONs examplemod:blocks/test → assets/examplemod/textures/blocks/test.png ... minecraft:block/cube_all, not minecraft:block/cube_all.json And this is a doozy at https://forge.gemwire.uk/wiki/Item_Properties: { "parent": "item/generated", "textures": { "__comment": "Default", "layer0": "examplemod:items/example_partial" }, "overrides": [ { "__comment": "power >= .75", "predicate": { "examplemod:power": 0.75 }, "model": "examplemod:item/example_powered" } ] } The "layer0" definition uses "items" and the "model" in the overrides uses "item". I think there were more using the plural, but it was a while ago and I don't have time to search them all out right now.
  2. I'm not talking about the forge documentation, which has a link to a fairly thorough page on the Minecraft wiki about the model JSON files, but that page in turn is inconsistent in the examples. Specifically, sometimes it uses "block" and sometimes it uses "blocks".
  3. I have added a few more files and modified the JSON one I had. I now have: assets/stats_and_skills/blockstates/bone_altar.json: { "variants": { "": { "model": "stats_and_skills:block/bone_altar" } } } assets/stats_and_skills/models/item/bone_altar.json: { "parent": "item/generated", "textures": { "layer0": "stats_and_skills:block/bone_altar" } } assets/stats_and_skills/models/block/bone_altar.json: { "parent": "block/cube", "textures": { "": "stats_and_skills:block/bone_altar", "inventory": "stats_and_skills:block/bone_altar", "all": "stats_and_skills:block/bone_altar" }, "elements": [ { "from": [ 0, 0, 0 ], "to": [ 16, 16, 16 ], "faces": { "down": { "texture": "#all", "cullface": "down" }, "up": { "texture": "#all", "cullface": "up" }, "north": { "texture": "#all", "cullface": "north" }, "south": { "texture": "#all", "cullface": "south" }, "west": { "texture": "#all", "cullface": "west" }, "east": { "texture": "#all", "cullface": "east" } } } ] } I also renamed the directory from "blocks" to "block" for the textures. The documentation that is available is very inconsistent here. It all seems to work now.
  4. I thought I posted this last night, but it was late and I was tired, so it may be in the wrong forum, or maybe I just didn't click the post button. If there is a duplicate, my apologies. In my main class I have this, as per the example code: public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID); public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); public static final RegistryObject<Block> BONE_ALTAR = BLOCKS.register("bone_altar", () -> new Block(BlockBehaviour.Properties.copy(Material.STONE).requiresCorrectToolForDrops())); public static final RegistryObject<Item> BONE_ALTAR_ITEM = ITEMS.register("bone_altar", () -> new BlockItem(BONE_ALTAR.get(), new Item.Properties())); I figured out how to add it to a creative mode tab, and placed one, and the texture is just a magenta and black check. The texture I want to use is at src/main/resources/assets/stats_and_skills/textures/blocks/bone_altar.png. The model file is at src/main/resources/assets/stats_and_skills/models/blocks/bone_altar.json and looks like: { "parent": "block/cube", "textures": { "particle": "block/bone_altar", "all": "block/bone_altar" }, "elements": [ { "from": [ 0, 0, 0 ], "to": [ 16, 16, 16 ], "faces": { "down": { "texture": "#all", "cullface": "down" }, "up": { "texture": "#all", "cullface": "up" }, "north": { "texture": "#all", "cullface": "north" }, "south": { "texture": "#all", "cullface": "south" }, "west": { "texture": "#all", "cullface": "west" }, "east": { "texture": "#all", "cullface": "east" } } } ] } I am guessing that a file is in the wrong location, or the model file is using the wrong path to the texture. Or something. I have no idea, and the documentation really needs a bit more in the way of examples.
  5. The Advanced XRay Mod has up to date code that really helped me out. Many thanks to the authors whose code provided inspiration. And I only copy and pasted the code to feed the vertices into the vertex buffer. Please don't sue me.
  6. I will second Ash's post since that is EXACTLY the problem I had yesterday when trying to run a dedicated server for the first time. You will need to download the JDK since the JRE is only available for Java 8. Apparently Sun/Oracle/whoever think you will only ever need Java 8 for everything.
  7. I changed "DistExecutor.unsafeRunWhenOn" to "DistExecutor.safeRunWhenOn". No change. However, I also at the same time made "DistExecutor.safeRunWhenOn" call an empty function in another class. Completely empty. However I did not remove/comment out my original safe_handler() function which is no longer being called AT ALL from ANYWHERE! Still got a crash. Code that is simply not being called at all. I renamed the function to NOT_CALLED() to be really really sure it isn't being called at all somehow. Still crashed. Commented out the body of the NOT_CALLED() function and it works just fine. Looks like @OnlyIn is my only option, as long as I can find the import...
  8. And to answer my own question...the documentation, if you read the "Common mistakes" section REALLY closely, holds all the answers, including a hint about race conditions when using static members in a normal client installation. The bit I really needed to read was about: ...@OnlyIn(Dist) annotation.... Now all I need to do is figure out which import that is in. HOWEVER: The documentation also says: There is NO reason for using this annotation directly. Use DistExecutor or a check on FMLEnvironment#dist instead. I am. It doesn't work! Yes my supplied method is in the same class, but I tried putting it in a different class and it didn't work either.
  9. I've tracked down this specific issue to this code, and now I am confused because I am sure I am handling this as per the documentation: public static void handler(SyncMsg msg, Supplier<NetworkEvent.Context> ctx) { ctx.get().enqueueWork(() -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> safe_handler(msg))); ctx.get().setPacketHandled(true); } public static void safe_handler(SyncMsg msg) { Player player = (Player)(Minecraft.getInstance().player); PlayerData data = PlayerData.get(player); ... The crash occurs when loading the mod, long before any of this code is executed. Minecraft.getInstance() is a static function, but surely this won't get executed until a message is received by the client.
  10. I have finally got around to setting up a dedicated Minecraft server and my mod crashes. The first crash was easy. It complained about trying to instantiate a Screen. A quick search of my code showed that my client event handler class was "static final" initialising my screen. I changed it to dynamic initialisation, moved client tick event registration into the FMLClientSetupEvent handler and all was well...or so I hoped. I now get this error: [17:03:22] [main/ERROR] [minecraft/Main]: Failed to start the minecraft server net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [ Stats and Skills (stats_and_skills) has failed to load correctly §7java.lang.RuntimeException: Attempted to load class net/minecraft/client/player/LocalPlayer for invalid dist DEDICATED_SERVER So, I did a search of my code for LocalPlayer...and found nothing. I am not importing that class, not instantiating it, not (apparently) referencing it, anywhere. I am not asking you to solve this problem. There will, I am sure, be others after this. I am asking for tips on how to find the root cause of such problems and would also appreciate tips on avoiding them in the first place.
  11. Awesome tips, thanks. I figured that the camera would be positioned where the player's eyes were I am currently using the LevelRenderer that comes with the event. Should I be using the GameRenderer instead, or are they in fact the same thing.
  12. Like this? centre = centre - player.getEyePosition(); Do I not also need to apply camera view angle rotation or anything? I was hoping that the level renderer would apply all necessary scaling, translation, and rotation.
  13. Here is my code. It is late, I am tired, I have worked hard to get something sensible to compile in the face of significantly incomplete documentation, and it doesn't work. I would be so very very grateful if someone could help me work out why this isn't working. @SubscribeEvent public static void onViewBlocks(RenderLevelStageEvent event) { Minecraft minecraft = Minecraft.getInstance(); Player player = (Player)(minecraft.player); if (RenderLevelStageEvent.Stage.AFTER_SOLID_BLOCKS == event.getStage()) { ClientLevel level = minecraft.level; LevelRenderer renderer = event.getLevelRenderer(); OutlineBufferSource buffer_source = minecraft.renderBuffers().outlineBufferSource(); VertexConsumer vertex_consumer = buffer_source.getBuffer(RenderType.lines()); // Highlight all blocks within 4 blocks range. int min_x = player.getBlockX() - 4; int max_x = player.getBlockX() + 4; int min_y = player.getBlockY() - 4; int max_y = player.getBlockY() + 4; int min_z = player.getBlockZ() - 4; int max_z = player.getBlockZ() + 4; for (int x = min_x; x < max_x; x++) { for (int y = min_y; y < max_y; y++) { for (int z = min_z; z < max_z; z++) { BlockPos block = new BlockPos(x, y, z) Vec3 centre = block.getCenter(); if (centre.distanceToSqr(player.getEyePosition()) <= m_range_squared) { int ore = getOre(level.getBlockState(block).getBlock()); // Check that the block is an ore we want to highlight. if (-1 < ore) { // If I put debug in here, it successfully reports the block as to be highlighted. renderer.renderLineBox(vertex_consumer, (centre.x - 0.5), (centre.y - 0.5), (centre.z - 0.5), (centre.x + 0.5), (centre.y + 0.5), (centre.z + 0.5), ORE_COLOURS[ore].r, ORE_COLOURS[ore].g, ORE_COLOURS[ore].b, 0.5f); // Not sure if 0.0 is solid colour or transparent. I'm tired. Forgive me! } } } } } }
  14. Also...how do I get a VertexConsumer? Apparently I need one to render anything, but I cannot figure out from the reverse engineered documentation where I can get one.
  15. Thanks. Where do I find the source code for the GameRenderer, or do you just mean look at the APIs available? RenderLevelStageEvent gives me a LevelRenderer which has a renderLineBox() function. I am going to have a go with that but am not sure if the line box will be rendered in front even though the vertex positions are behind other blocks.
  • Create New...

Important Information

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