-
Posts
16559 -
Joined
-
Last visited
-
Days Won
155
Posts posted by Draco18s
-
-
I've been doing something similar, but the way I did it was to yoink the relevant block texture, render it, then render a second quad with my overlay on it, a very tiny fraction of a pixel above* the first quad. Just enough offset so there's no z-fighting, but too small to see. 1F/256 is good.
I have, however, been having a devil of a time getting block brightness to be calculated correctly. Think I thought of a solution, and that's a faux block that gets rendered using the normal renderer after rendering the base material block in the same manner.
*relative to the block face
-
We are not the curators of vanilla code documentation.
I actually had no idea.
-
*Facepalm* no need to convert it to an item stack and then getItem()...
Item.itemList[theID]
Also, my bad, it's itemsList, I was going from memory.
-
/** * Returns whether this block is collideable based on the arguments passed in Args: blockMetaData, unknownFlag */ public boolean canCollideCheck(int par1, boolean par2) { return this.isCollidable(); }
The par2 boolean is a flag that relates to collision raycasts, say, by the player's mouse cursor.
I had a dispenser-like block that I wanted to fire multiple arrows from, found that because of some offsets (so that they would be emitted from different locations, regardless of orientation) was causing some arrows to collide with the block itself. So I looked into making the block non-collidable for that purpose.
Found the above function (well, knew it existed, but implemented it for an override and did this:
public boolean canCollideCheck(int par1, boolean par2) { return this.isCollidable() & par2; }
I could now no longer right-click interact with my block, but the arrows passed through it as desired.
Changed to
public boolean canCollideCheck(int par1, boolean par2) { return this.isCollidable() | par2; }
And retained the desired behavior and regained the ability to interact with it.
Scratch that, was a total fluke due to the RNG.
(There are 4 spots my arrows fire from, two of them collide, two don't, the test I thought things worked right was just a fluke of the RNG picking the two that worked).
Back-tracing the code it appears that this boolean is true if and only if the player right-clicks while holding a boat. I suspect that this code is used to place the boat on top of water rather than underneath.
-
new ItemStack(Item.itemList[theID])
Check for null.
-
Buildcraft is on Github, too.
-
Thanks so much. Just understanding the basic structure of what I'm trying to do here will help a good deal. In this example, should MyTileEntityRenderer also implement IMerchant and IInventory? Rendering a gui is still a little confusing to me, but I know I need at least one of those two.
Maybe? I don't recognize those two classes at the moment.
-
items ids are in the 4800s
Items != blocks.
ITEM IDs can go as high as 31999. BLOCK IDs can go up to 4095.
-
No, I mean beta 1.5_01, which is what that mod is written for. I first started somewhere around Beta 1.6.
I'd gone looking. And...I missed that version (apparently I skimmed the quicklinks which only went back to 1.7, so I'd moved on down to Alpha).
-
Did this:
int brightness = Block.blocksList[block.stone.blockID].getMixedBrightnessForBlock(world, x, y, z);
Instead of this:
int brightness = block.getMixedBrightnessForBlock(world, x, y, z);
And it got better. Only "flaw" is that it has the brightness/color of the top face rather than the side face of that location (specifically, the brightness/color of the top face of the block below where I'm rendering).
-
The problem is, brightness works differently for specially rendered blocks and normal blocks.
Dafuk.
-
Still need help with this. Brightness integers are weird.
I solved the alpha problem (seems that bits 9 to 16 effect the alpha, 21 to 24 are brightness, and the lowest 8 are color; 17 to 20 appear unused) but now I have an absolute brightness issue and color problem.
I'm actually stripping out the 3rd bit of the absolute brightness to tone it down some (helps, but not enough in some cases; 4th bit too much in all cases).
And this is what it looks like under various conditions:
Full sun. Color is off. Absolute brightness perfect.
Near-full darkness. Very slight color difference. Absolute brightness perfect.
Torch light. Color perfect. Absolute brightness out of whack.
-
Eurgh. I think it's more readable if you name those ContainerMyBlock, TileEntityMyBlock, and RenderMyBlock respectively. In fact, I need to get my partner atrain99 to rename our classes like that
Whichever. A lot of tutorials and such always do it as MyFoo and MyBar
-
Modifying tool usage values might be tricky (without base class editing). I'm not familiar with how it would be done, but essentially you'd have to overwrite EnumToolMaterial which has a private constructor.
(Amusingly, it also uses "Emerald" for diamond tools. Hehe.)
-
Good gracious! 1.5_01... that's about when I started playing Minecraft. I thought you said 1.2.5... Still, it can be done. Actually, it's easier. But it'll be a hard task for you to update...
And before me, though not by much. (*cough* also I think you meant 1.0.5_01)
I can't find my original registration date, but it's around Alpha v1.1.2_01, which is the earliest reference I have to my having played, only two weeks later.
-
If you want an actually-blank third row* then just omit that parameter.
GameRegistry.addRecipe(new ItemStack(ModItems.ClayIngot), new Object[]{ "x x", " x ", Character.valueOf('x'), ModItems.ClayIngot});
Also, you can do 'x' instead of Character.valueOf('x'), Java distinguishes between " (for strings) and ' (for chars).
*It's not a colum, DELTA_12, it's a row
-
Step 1:
class MyTileEntityBlock extends BlockContainer
Yes, it creates a container but that's because the original vanilla TE objects have inventories. You don't need to utilize this fact, nor do you need to utilize the NBT data that can easily get saved via entities.
Step 2:
class MyTileEntityEntity extends TileEntity
This class is what's created when you place the block. The parent class (BlockContainer) will throw an "add unimplemented methods" error, one of which will be function that returns a tile entity. You'd add "return new MyTileEntityEntity()" there. WARNING: do not pass parameters or change properties of the TE at this point, as you will want to read these values from the NBT data or they'll get reset on world load.
Step 3
public class MyTileEntityRenderer extends TileEntitySpecialRenderer
This will handle your TE rendering. You may also have a model that you're using or you might use the tessalator directly. I've done both.
Step 4
In your base mod class:
RenderingRegistry.registerBlockHandler(new MyTileEntityRenderer());
You should also use RenderingRegistry.getNextAvailableRenderId() to get a rendering ID and pass it to both your block and render class.
-
Thank you, I'll be here all week.
*Bows*
-
Modification of actual rendering algorithms = definitely.
Doable: yes
"Easy" without base class editing: yes
Simple: hell no. At least, not for your first mod.
(I still fuck up simple block rendering now and then)
-
That seems to be working better, but...
:\
-
OpenGL can't render to Physical World; there appears to be a lack of a drawing API into real space.
(Google Glass is providing a work around soon, though)
-
Try world.getBlockLightValue().
I shall try that. Ty.
-
We'll start with a picture of what I have
http://s11.postimg.org/k3dpbpw83/2013_06_10_17_42_07.png[/img]
The block itself actually exists in a different place than its rendering. One block down and one block "in" (the block attaches to a solid surface, like a ladder, and renders 1 block below that in order to cover an open space, for tripwire hooks).
Problem is, I can't get it to render at the correct brightness. The getMixedBrightnessForBlock function seems to return full sun despite the fact that that space is not under full sun (if I cover things over it still renders too bright, although it does dim as the light value is reduced).
How can I fix this?
Render code:
package draco18s.traps.client; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderCoverPlate implements ISimpleBlockRenderingHandler { private int renderType; public RenderCoverPlate(int r) { renderType = r; } @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; int l = world.getBlockMetadata(x, y, z); //gets the texture based on block location, the block blends in to neighbors, grabbing their texture Icon icon = block.getBlockTexture(world, x, y, z, 2); double f = 1F/64; switch(l) { case 2: z++; break; case 3: z--; break; case 4: x++; break; case 5: x--; break; } y--; int brightness = block.getMixedBrightnessForBlock(world, x, y, z); tessellator.setBrightness(brightness); tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); double d0 = (double)icon.getMinU(); double d1 = (double)icon.getMinV(); double d2 = (double)icon.getMaxU(); double d3 = (double)icon.getMaxV(); double d5 = (double)(x + 1); double d7 = (double)(x); double d9 = (double)(z); double d11 = (double)(z + 1); double d13 = (double)(y + 1); double d15 = (double)(y); tessellator.addVertexWithUV(d7, d13, d9, d2, d1); tessellator.addVertexWithUV(d7, d15, d9, d2, d3); tessellator.addVertexWithUV(d5, d15, d9, d0, d3); tessellator.addVertexWithUV(d5, d13, d9, d0, d1); tessellator.addVertexWithUV(d5, d13, d9, d2, d1); tessellator.addVertexWithUV(d5, d15, d9, d2, d3); tessellator.addVertexWithUV(d5, d15, d11, d0, d3); tessellator.addVertexWithUV(d5, d13, d11, d0, d1); tessellator.addVertexWithUV(d7, d13, d11, d0, d1); tessellator.addVertexWithUV(d7, d15, d11, d0, d3); tessellator.addVertexWithUV(d7, d15, d9, d2, d3); tessellator.addVertexWithUV(d7, d13, d9, d2, d1); tessellator.addVertexWithUV(d5, d13, d11, d2, d1); tessellator.addVertexWithUV(d5, d15, d11, d2, d3); tessellator.addVertexWithUV(d7, d15, d11, d0, d3); tessellator.addVertexWithUV(d7, d13, d11, d0, d1); //gets the little "hole" texture from the blocks registered texture, renders ever so slightly in front to avoid z-fighting icon = block.getIcon(0, 0); d0 = (double)icon.getMinU(); d1 = (double)icon.getMinV(); d2 = (double)icon.getMaxU(); d3 = (double)icon.getMaxV(); d5 = (double)(x + 1 + f); d7 = (double)(x - f); d9 = (double)(z - f); d11 = (double)(z + 1 + f); d13 = (double)(y + 1); d15 = (double)(y); tessellator.addVertexWithUV(d7, d13, d9, d2, d1); tessellator.addVertexWithUV(d7, d15, d9, d2, d3); tessellator.addVertexWithUV(d5, d15, d9, d0, d3); tessellator.addVertexWithUV(d5, d13, d9, d0, d1); tessellator.addVertexWithUV(d5, d13, d9, d2, d1); tessellator.addVertexWithUV(d5, d15, d9, d2, d3); tessellator.addVertexWithUV(d5, d15, d11, d0, d3); tessellator.addVertexWithUV(d5, d13, d11, d0, d1); tessellator.addVertexWithUV(d7, d13, d11, d0, d1); tessellator.addVertexWithUV(d7, d15, d11, d0, d3); tessellator.addVertexWithUV(d7, d15, d9, d2, d3); tessellator.addVertexWithUV(d7, d13, d9, d2, d1); tessellator.addVertexWithUV(d5, d13, d11, d2, d1); tessellator.addVertexWithUV(d5, d15, d11, d2, d3); tessellator.addVertexWithUV(d7, d15, d11, d0, d3); tessellator.addVertexWithUV(d7, d13, d11, d0, d1); return false; } @Override public boolean shouldRender3DInInventory() { return true; } @Override public int getRenderId() { return renderType; } }
-
You need a EntityRegistry.registerModEntity call.
Example:
EntityRegistry.registerModEntity(EntityMyEnt.class, "MyEntity", 1, this, 350, 5, false);
Render custom model as a tile entity
in Modder Support
Posted
You....are not doing things the way I'm doing them, and it does not appear that your....renderer has any quads or a model to draw.
Here's mine:
SpikesModel
Model was exported from Techne and minorly tweaked.*
*Imports and oddly, the model came in upside down and I had to figure out how to flip it back over.