Jump to content

Recommended Posts

Posted

Hi everyone,

 

I am thinking of adding something more complicated and dont know how to do it.

I want to add a non existing block which marks blocks that needs to be removed by the player, like clicking on a button and see which blocks need to be removed, that the tileentity have enought space to go on. Like marking the blocks, that needs to be removed with a red X or something like this. It should not change the blocks at all.

 

Hope it is understandable.

 

Thanks for your answers,

 

Kaneka

Posted

Likely you need to subscribe to one of the rendering events and draw some additional geometry in the locations you wish it to appear.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

It is an entity because it does not change the block.

You are looking for something that is invisible with a red x in the middle of it, or just a plain red x for your entity model.

You are looking for something with lifetime.

You are also looking for something that doesn't move when summoned (like a firework)

 

this is just a possibility...

 

the only way I know to create "phantom" or non existing but existing blocks is if you open about 3 or 4 browsers. (even 1 or 2 depending on your system)

Then open up minecraft. Then summon fallingsand entities at a straight flying linear type entity.

This will cause the phenomena (which sucks) because they don't act like air blocks... they act like some kind of glitchy spiderweb barrier block. you can't go through them.

Posted

Hi

 

If you are looking for something like this:

then you'll probably find RenderWorldLastEvent event useful.

In the event, use the Tessellator to draw your markers, for example something along these lines, where the [x1,y1,z1] etc define the four corners of a square just in front of the face you're drawing, and you repeat this method for all faces of every cube you want to outline:

 

  public static void drawBoxWithCross(double x1, double x2, double x3, double x4,
                                      double y1, double y2, double y3, double y4,
                                      double z1, double z2, double z3, double z4)
  {
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldRenderer = tessellator.getWorldRenderer();
    worldRenderer.startDrawing(GL11.GL_LINE_STRIP);
    worldRenderer.addVertex(x1, y1, z1);
    worldRenderer.addVertex(x2, y2, z2);
    worldRenderer.addVertex(x3, y3, z3);
    worldRenderer.addVertex(x4, y4, z4);
    worldRenderer.addVertex(x1, y1, z1);
    tessellator.draw();

    worldRenderer.startDrawing(GL11.GL_LINES);
    worldRenderer.addVertex(x1, y1, z1);
    worldRenderer.addVertex(x3, y3, z3);
    worldRenderer.addVertex(x2, y2, z2);
    worldRenderer.addVertex(x4, y4, z4);
    tessellator.draw();
  }

That code was for 1.8 so it might be slightly different now, but it gives you the basic idea?

 

-TGG

 

Posted

It has a different name in different versions. I think in 1.10 it's called VertexBuffer

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • 2 weeks later...
Posted

Is there a tutorial or a codeexample where I can see how to add rendering processes when pushing a button in a gui?

When button is pushed switch a boolean. Then when boolean is true and or false which ever you decide make stuff render.

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.

Posted

ok, thanks.

Now I just need a tutorial or examplecode on how to make stuff render, cause all I found is just "how to texture blocks in 1.7", nothing about 1.10. I just need to render red crosses.

Posted

ok, thanks.

Now I just need a tutorial or examplecode on how to make stuff render, cause all I found is just "how to texture blocks in 1.7", nothing about 1.10. I just need to render red crosses.

Do you know how the tesselator works?

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.

Posted

Just what I read in the tutorials about the "texture block" tutorial, but not that much

First create a texture aka the one you want to draw. Once you have done that locate where you need to type the render code aka one of the rendering events. Use minecrafts texture manager to bund the texture you made. Then call GL11.translatef() to move the rendering to the block pos. Then use a tesselator to draw the image.

Note: I may be missing a step...

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.

Posted

That was how to render a block, I just want to draw lines to make crosses to mark some existing blocks. best would be examplecode, but thanks for xou effort till here

Posted

That was how to render a block, I just want to draw lines to make crosses to mark some existing blocks. best would be examplecode, but thanks for xou effort till here

The texture is the cross as tesselator (as far as i know) draws images and not "shapes".

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.

Posted

Hi

 

If you are looking for something like this:

then you'll probably find RenderWorldLastEvent event useful.

In the event, use the Tessellator to draw your markers, for example something along these lines, where the [x1,y1,z1] etc define the four corners of a square just in front of the face you're drawing, and you repeat this method for all faces of every cube you want to outline:

 

  public static void drawBoxWithCross(double x1, double x2, double x3, double x4,
                                      double y1, double y2, double y3, double y4,
                                      double z1, double z2, double z3, double z4)
  {
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldRenderer = tessellator.getWorldRenderer();
    worldRenderer.startDrawing(GL11.GL_LINE_STRIP);
    worldRenderer.addVertex(x1, y1, z1);
    worldRenderer.addVertex(x2, y2, z2);
    worldRenderer.addVertex(x3, y3, z3);
    worldRenderer.addVertex(x4, y4, z4);
    worldRenderer.addVertex(x1, y1, z1);
    tessellator.draw();

    worldRenderer.startDrawing(GL11.GL_LINES);
    worldRenderer.addVertex(x1, y1, z1);
    worldRenderer.addVertex(x3, y3, z3);
    worldRenderer.addVertex(x2, y2, z2);
    worldRenderer.addVertex(x4, y4, z4);
    tessellator.draw();
  }

That code was for 1.8 so it might be slightly different now, but it gives you the basic idea?

 

-TGG

 

Isn´t this some way doing it? All I need to know is where to call this method, and what I need to do additionally to make it work.  I never worked with openGL or RenderWorldLastEvent. Thats my problem.

Posted

WorldRenderer has become VertexBuffer and instead of addVertex it is the way diesieben said. You also must call vb.startDrawing(glnum, DefaultVertexFormats...) mess around with that last var because i do not know what it would be in this case.

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.

Posted

Note that the drawing part is only one part of the problem you have to solve. The other part is knowing and remembering all the block positions that you have marked.

 

So first of all you will need to extend the players to have the ability to remember a List (or similar Java collection) of BlockPos locations that have been marked. In older versions you'd use IExtendedEntityProperties but I think now you would do this using a custom Capability. Make sure that however you store this, it gets synced between server and client (unless you don't mind if it is temporary in which case you could probably just do all the marking code on client).

 

I'm assuming maybe you will mark the blocks with a special tool. So you will need to make that tool item and then in the onUse() method of your item, if it has been used on a block, you would need to add the BlockPos to your list.

 

Only then can you really use the stuff you're discussing above to draw the X on the blocks.

 

Note also it can even get more complicated if you want to handle the case where a marked block gets deleted. Because you will then need to remove the BlockPos from the List, otherwise the air will continue to be marked. So instead of a List you might want to use a Map or similar where you index with BlockPos and record the type of block that was there -- then if that block changes in that location you can remove the entry from the Map.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Thanks for the detailed answer,

The blocks should be marked just temporarly.

I thought about the TESR doint this, cause the gui and the button should be connected to a tileentity.

Would this be to laggy, cause I dont need thet complex shapes, just the red crosses for a period of 10-20 seconds?

Posted

Thanks for the detailed answer,

The blocks should be marked just temporarly.

I thought about the TESR doint this, cause the gui and the button should be connected to a tileentity.

Would this be to laggy, cause I dont need thet complex shapes, just the red crosses for a period of 10-20 seconds?

Is it your own blocks? Or is it Vanilla blocks? If it is the first one just use a blockstate that flips on when you press the button. With that there is no need to use events or A tesselator.

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.

Posted

It should be all blocks, as i told in my first post, it should show which blocks needs to be removed before the machine can go on working, so it could be any block. vanilla, my mod or other mod.

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

    • Hi here is an update. I was able to fix the code so my mod does not crash Minecraft. Please understand that I am new to modding but I honestly am having a hard time understanding how anyone can get this to work without having extensive programming and debugging experience as well as searching across the Internet, multiple gen AI bots (claude, grok, openai), and examining source code hidden in the gradle directory and in various github repositories. I guess I am wrong because clearly there are thousands of mods so maybe I am just a newbie. Ok, rant over, here is a step by step summary so others can save the 3 days it took me to figure this out.   1. First, I am using forge 54.1.0 and Minecraft 1.21.4 2. I am creating a mod to add a shotgun to Minecraft 3. After creating the mod and compiling it, I installed the .jar file to the proper directory in Minecraft and used 1.21.4-forge-54.1.0 4. The mod immediately crashed with the error: Caused by: java.lang.NullPointerException: Item id not set 5. Using the stack trace, I determined that the Exception was being thrown from the net.minecraft.world.item.Item.Properties class 6. It seems that there are no javadocs for this class, so I used IntelliJ which was able to provide a decompiled version of the class, which I then examined to see the source of the error. Side question: Are there javadocs? 7. This method, specifically, was the culprit: protected String effectiveDescriptionId() {      return this.descriptionId.get(Objects.requireNonNull(this.id, "Item id not set"));  } 8. Now my quest was to determine how to set this.id. Looking at the same source file, I determined there was another method:  public Item.Properties setId(ResourceKey<Item> pId) {             this.id = pId;             return this;   } 9. So now, I need to figure out how to call setId(). This required working backwards a bit. Starting from the constructor, I stubbed out the variable p which is of type Item.Properties public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); Rather than putting this all on one line, I split it up for readability like this: private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); Here is was the missing function, setId(), which takes a type of ResourceKey<Item>. My next problem is that due to the apparent lack of documentation (I tried searching the docs on this site) I could not determine the full import path to ResourceKey. I did some random searching on the Internet and stumbled across a Github repository which gave two clues: import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; Then I created the rk variable like this: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); And now putting it all together in order: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); This compiled and the mod no longer crashes. I still have more to do on it, but hopefully this will save someone hours. I welcome any feedback and if I missed some obvious modding resource or tutorial that has this information. If not, I might suggest we add it somewhere for people trying to write a mod that doesn't crash. Thank you !!!  
    • I will keep adding to this thread with more information in case anyone can help, or at the very least I can keep my troubleshooting organized. I decided to downgrade to 54.1.0 in the hopes that this would fix the issue but it didn't. At least now I am on a "recommended" version. The crash report did confirm my earlier post that the Exception is coming from effectiveDescriptionId(). I'll continue to see if I can find a way to set the ID manually.   Caused by: java.lang.NullPointerException: Item id not set         at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item$Properties.effectiveDescriptionId(Item.java:465) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item.<init>(Item.java:111) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ShotgunItem.<init>(ShotgunItem.java:19) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ModItems.lambda$static$0(ModItems.java:15) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/net.minecraftforge.registries.DeferredRegister$EventDispatcher.lambda$handleEvent      
    • It just randomly stop working after a rebooted my dedicated server PLEASE HELP!   com.google.gson   Failed to start the minecraft server com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive; at path $  
    • It was working perfectly fine last night but now I'm getting an exit code -1 with the textbox: The game crashed: rendering overlay Error: net.minecraftforge.fml.ModLoadingException: Supplementaries (supplementaries) encountered an error during the done event phase Here's the crash log: https://pastebin.com/KmesArYS Any help is apricated
    • Link to Crashlog: https://pastebin.com/bKqH9fx2 Trying to set up a custom mod pack, was going smoothly up until recently as the WorldLoader screen, (the one that appears when you select "create new world" in Singleplayer), was clicked to test that it was running fine. Most Recent Few mods added were; - Create (+ its addons) - Immersive Weathering [Forge] I've tried all I could think of since loading up the game worked fine and I've never had this issue before.  Any help is appreciated.  
  • Topics

×
×
  • Create New...

Important Information

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