Jump to content

Recommended Posts

Posted

Hi everyone,

 

Basically I'm trying to add a texture overlay to one individual block. Not to a block class, but for example to the block located 50, 50, 50. Whatever type of block it is. My Mod should be able to be installed via a ZIP file, so no changes in original source code.

 

Example: http://www.9minecraft.net/light-level-overlay-mod/

 

--

 

 

My TickHandler:

RenderingRegistry.instance().renderWorldBlock(Minecraft.getMinecraft().renderGlobal.globalRenderBlocks, Minecraft.getMinecraft().renderGlobal.globalRenderBlocks.blockAccess, x, y, z, Block.blocksList[ Minecraft.getMinecraft().theWorld.getBlockId( x, y, z ) ], Mod.instance.blockModel );

 

RenderBlocks.java (I basically disabled normal rendering, and see no more blocks.

public boolean renderBlockByRenderType(Block par1Block, int par2, int par3, int par4)
    {/*
        int l = par1Block.getRenderType();

        if (l == -1)
        {
            return false;
        }
        else
        {
            par1Block.setBlockBoundsBasedOnState(this.blockAccess, par2, par3, par4);
            this.setRenderBoundsFromBlock(par1Block);

            switch (l)
            {
                //regex: ' : \(l == ([\d]+) \?' replace: ';\ncase \1: return' ::: IMPORTANT: REMEMBER THIS ON FIRST line!
                case 0: return this.renderStandardBlock(par1Block, par2, par3, par4);
                case 4: return this.renderBlockFluids(par1Block, par2, par3, par4);
                case 31: return this.renderBlockLog(par1Block, par2, par3, par4);
                case 1: return this.renderCrossedSquares(par1Block, par2, par3, par4);
                case 2: return this.renderBlockTorch(par1Block, par2, par3, par4);
                case 20: return this.renderBlockVine(par1Block, par2, par3, par4);
                case 11: return this.renderBlockFence((BlockFence)par1Block, par2, par3, par4);
                case 39: return this.renderBlockQuartz(par1Block, par2, par3, par4);
                case 5: return this.renderBlockRedstoneWire(par1Block, par2, par3, par4);
                case 13: return this.renderBlockCactus(par1Block, par2, par3, par4);
                case 9: return this.renderBlockMinecartTrack((BlockRailBase)par1Block, par2, par3, par4);
                case 19: return this.renderBlockStem(par1Block, par2, par3, par4);
                case 23: return this.renderBlockLilyPad(par1Block, par2, par3, par4);
                case 6: return this.renderBlockCrops(par1Block, par2, par3, par4);
                case 3: return this.renderBlockFire((BlockFire)par1Block, par2, par3, par4);
                case 8: return this.renderBlockLadder(par1Block, par2, par3, par4);
                case 7: return this.renderBlockDoor(par1Block, par2, par3, par4);
                case 10: return this.renderBlockStairs((BlockStairs)par1Block, par2, par3, par4);
                case 27: return this.renderBlockDragonEgg((BlockDragonEgg)par1Block, par2, par3, par4);
                case 32: return this.renderBlockWall((BlockWall)par1Block, par2, par3, par4);
                case 12: return this.renderBlockLever(par1Block, par2, par3, par4);
                case 29: return this.renderBlockTripWireSource(par1Block, par2, par3, par4);
                case 30: return this.renderBlockTripWire(par1Block, par2, par3, par4);
                case 14: return this.renderBlockBed(par1Block, par2, par3, par4);
                case 15: return this.renderBlockRepeater((BlockRedstoneRepeater)par1Block, par2, par3, par4);
                case 36: return this.renderBlockRedstoneLogic((BlockRedstoneLogic)par1Block, par2, par3, par4);
                case 37: return this.renderBlockComparator((BlockComparator)par1Block, par2, par3, par4);
                case 16: return this.renderPistonBase(par1Block, par2, par3, par4, false);
                case 17: return this.renderPistonExtension(par1Block, par2, par3, par4, true);
                case 18: return this.renderBlockPane((BlockPane)par1Block, par2, par3, par4);
                case 21: return this.renderBlockFenceGate((BlockFenceGate)par1Block, par2, par3, par4);
                case 24: return this.renderBlockCauldron((BlockCauldron)par1Block, par2, par3, par4);
                case 33: return this.renderBlockFlowerpot((BlockFlowerPot)par1Block, par2, par3, par4);
                case 35: return this.renderBlockAnvil((BlockAnvil)par1Block, par2, par3, par4);
                case 25: return this.renderBlockBrewingStand((BlockBrewingStand)par1Block, par2, par3, par4);
                case 26: return this.renderBlockEndPortalFrame((BlockEndPortalFrame)par1Block, par2, par3, par4);
                case 28: return this.renderBlockCocoa((BlockCocoa)par1Block, par2, par3, par4);
                case 34: return this.renderBlockBeacon((BlockBeacon)par1Block, par2, par3, par4);
                case 38: return this.renderBlockHopper((BlockHopper)par1Block, par2, par3, par4);
                default: return FMLRenderAccessLibrary.renderWorldBlock(this, blockAccess, par2, par3, par4, par1Block, l);
            }
        }*/return false;

 

My BlockRenderer:

System.out.println("RENDERING WORLD BLOCK. " + x + " " + y + " " + z + " " + block + " " + modelId);
       
        //renders the basic block
        renderer.renderStandardBlock(block, x, y + 1, z);

 

It prints to the console every frame. It does not render the standard block.

 

Anyone got a clue?

 

Thanks in advance,

 

Jaspa_Jones  :D

Posted

Are you wanting this to just always be there or are you specifically wanting it to happen when you have another block placed already? If you place a block in order to have the overlay, you could use a custom renderer on that placed block and draw your overlay from there. To make it cover the block that is there in the first place, you could set the block bounds to be just ever so slightly larger than a normal block, so it completely covers the normal block that is there already.

 

If you want it to just exist there, I can't really help you.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Posted

thats just me but instead of disabling normal block rendering id try only rendering the text/wtv "hovering" over the block

 

like 0.01 meter higher so that you dont have intersection with the normal block

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

Thank you guys for replying!

 

Well basically, I'm writing a mod that features Area Protection and I would like to highlight the protected areas in red. So I would like to make an partly transparent overlay over all the blocks that are protected. No matter what type of block they are.

 

So I do know which blocks (x, y, z) I would like to replace, but the Custom Render function in Forge is (I think) only designed to override block renderers per block type, not per individual block.

 

I would love to not use this Custom Render function and instead draw some overlay in OpenGL for example. I just don't really know where to start with this.

Posted

not to be a dick but i think ForgeEssential is already making something similar. (as am i but thats another story)

 

suggestion: anyone correct me if its not a good idea

 

try to spawn "entities"  kinda like mobs but they dont attack have hp or wtv, they jsut render the area protection

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

Yeah I know, but it's still in Alpha state and for Minecraft 1.4.7. Couldn't wait and started :)

 

That sounds complicated, but I get your idea. Do you have any experience doing things like this? Personally, I've never spawned any mobs. I've tried to stop mobs from moving once, but didn't succeed.

 

Do I need to create a custom mob for this? How can I spawn and kill a mob? And how can I remove its texture?

 

Thanks!

Posted

I have no idea personall i do it with blocks because i want the mayor of the town to be able to change the width/height/length of a plot (plots are "protected area") 

 

i didnt know ForgeEssential was only for 147, mines 152 ready ;)

 

technicly they're not mobs, they are entities, like a higher level in hierarchy. their only point as entities is ... to exists i guess. i do knwo they is a tutorial or 2 on the wiki about this. maybe you could try spawning a custom mob and then removing the "mob" part of the mob

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

I think there will be a problem with this. I only want the client to see the protected area highlighted and not the server. Only the Major should have access to this feature of displaying protected areas.

 

The first attempt I did was replacing Block ID's client side which pretty much did the job. However, my console started throwing lots and lots of errors about wrong synchronization between client and server. That's why I would actually prefer to not change anything gameplay related. I would prefer to just like draw another block that is a little bit bigger over the other block like redria7 said using OpenGL. Wouldn't that be a bit more neat and also better?

 

If I would take that route, I just have to know how to draw a block at that particular point and then increase its size a bit. I know how to access OpenGL from Minecraft, but I don't know how to get the right position and draw a solid color cube right there.

Posted

Tile entity my friend. A tile entity with a gui where you can alter size and... do exactly what flame is doing!

Or try the entity. Mobs, players, TE's, all of these are entities. Items on the ground are entities. Creating one wouldn't be impossible. Maybe make something similar to a spawn egg, except instead of spawning a mob, it spawns an entity that has a set size and shape and covers a large area, with no collision etc. Then your mayor can give each person one egg from creative mode, and the players can throw the egg at a location and it locks that location to them.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Posted

no hold on, tile entities are working in MY case because this how i want the player to interact with their lands. you have to use a tool that fits YOUR needs. maybe eggs are a good idea, maybe they're not.

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

My case is very simple:

 

I simply have the locations of blocks which are protected stored. For example:

X, Y, Z

50, 50, 50

50, 51, 51

51, 50, 51

 

Then when the Mayor presses P, these protected blocks will highlight. And when he presses P again they will return to normal. The blocks stay the same, it's just the way the user sees them that changes.

Posted

yeah but the question is, how are these blocks are selected/created, do you have to enter a command? do you have to right click them ? have you tought about air block, block placing etc etc.

 

 

 

 

 

 

 

btw the answer to "do you have to enter a command" better be no

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

*sight*

 

we have forge.... we have user interfaces...... we should be able to make mods that are 100% command free, its way more interactive and fun to interact with beautiful menu then to type

 

"/hur dur create area protected set group=admin 51, 51, 51, 100, 100, 100"

 

i know you're just using whats already there. but i think I'm getting cancer from these.

 

honestly I'm really excited to release my mod because we can finally start getting rid of those sign shop ....

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

no hold on, tile entities are working in MY case because this how i want the player to interact with their lands. you have to use a tool that fits YOUR needs. maybe eggs are a good idea, maybe they're not.

Sorry, tile entity is my thought for this on how it would work easiest. By pointing out that that's exactly what you were doing already I was (not very clearly) pointing out that that method was already being done, so using a different method would probably be a good idea.

I respect the fact that you are willing to help someone doing something similar to what you are doing when you haven't released yet. :)

I plan on going open source the moment I release, but I am trying to hide my more fun features until I release just in case someone else likes the idea and releases first. I'm a little selfish that way.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Posted

im a bit.. special.. and very confident/positive that my mod will be one of the best in its genre.

 

But hey, we'll see in 2 month if people like what I've done.

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

plus, people here are usually very new to coding in general. they're not a threat to the popularity of my mod. IF i ahve somethign to fear. it would be people who are working in secret. (kinda like me)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

im a bit.. special.. and very confident/positive that my mod will be one of the best in its genre.

 

But hey, we'll see in 2 month if people like what I've done.

I'm pretty confident in what I've done, but I also want that reveal moment. Where I have everything finished and I get to just show everything at once. So, you know, a couple spotlighters can say "oh wow" and no one else notices and life continues as normal...

 

I don't think there is really anything to fear: I think most people go into modding because they have a specific idea in mind to start with, but I play my little games.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Posted

you have to go out with a bang like:

 

hey i made this its new its fresh nobody has done thsi before.

 

unless you're doign somethign dull like "obsidian tools" generally people will like what you've done

 

compatibility is important too. If your mod isnt compatible with the "mainstream" mods you will have problem ;)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

I understand that you really think I shouldn't use commands. Well, I was planning to extend the Mod of course and this would be my first step into the next direction. I like to take small steps. Also, I'm not that new to programming. I'm just not that used to making Minecraft Mods (yet).

 

Now I hope my question is a bit more clear and it would be nice if someone could point me into the right direction. I've heard about TileEntities, adding Mobs, Drawing blocks over blocks, etc. I don't really know which way to go. I mean, I'd probably find out. It's just that I prefer asking for advice prior to reinventing the wheel :)

Posted

I, uh, may have obsidian tools.

BUT

That is one of the things I did when I was learning how to mod. And I made it interesting. Kind of.

I have lots of other stuff that is part of my pack. And I plan on calling it a mini mod pack because I'll have several independent mod sections that can be turned on and off through config if someone cares enough.

Anyway, I'll let this thread continue. I've hijacked it long enough.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Posted
I'm not that new to programming.

i wasn't necessarily referring to you, sorry :P

 

Tile Entity are basically extra information about a block, for example, sign have a tile entity that contains the text they are suppose to show

,beacon block contains information about their state (on off) and which buff they are giving

 

it is important to note that you cant place tile entities on block that dont support them, aka dirt, stone air, flower etc, etc

 

in my case i am using a new block called the plotblock. its tile entity contains the information about the width/height/length of the plot, this way i can use these information to draw a frame to visualize what are the limits that the plot owner can build in (as well as extra information like the cost of the plot etc etc)

 

the difference between using TE (tile entities) and entities is that tile entities are tied to a bloc. while entities are free to be placed anywhere.

you could technicly make an invisible entity that has information about the width/height/length of the protected area and x, y,z  and use this entity to draw a big box that represents the limit of the area.

 

for TE they're are good tutorial on the wiki about how why when to use them. as for entitiy i am not sure as i am not using them (yet).

 

@redria7, ahaha, sorry xD, but you understand what i mean?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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

    • Hello, I have this same problem. Did you manage to find a solution? Any help would be appreciated. Thanks.
    • log: https://mclo.gs/QJg3wYX as stated in the title, my game freezes upon loading into the server after i used a far-away waystone in it. The modpack i'm using is better minecraft V18. Issue only comes up in this specific server, singleplayer and other servers are A-okay. i've already experimented with removing possible culprits like modernfix and various others to no effect. i've also attempted a full reinstall of the modpack profile. Issue occurs shortly after the 'cancel' button dissapears on the 'loading world' section of the loading screen.   thanks in advance.
    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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