
gottsch
Members-
Posts
72 -
Joined
-
Last visited
Everything posted by gottsch
-
Hi. I'm updating a TileEntitySpecialRenderer to 1.8 but I keep getting this error on all calls from the WorldRenderer even though it's clearly defined, intialized and accessible to the entire method: error: error: cannot find symbol wr.setColorOpaque_F(1f, 1f, 1f); symbol: method setColorOpaque_F(1f, 1f, 1f) location: variable wr of type WorldRenderer (same with setBrightness() method) code: public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float scale, int p_180535_9_) { World world = tileEntity.getWorld(); // bind the overlay resource texture Minecraft.getMinecraft().renderEngine.bindTexture(getOreTexture()); // set up GL GL11.glPushMatrix(); GL11.glTranslated(x, y, z); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_LIGHTING); Tessellator t = Tessellator.getInstance(); WorldRenderer wr = t.getWorldRenderer(); // set the the alpha settings // these three enable opacity of whole image - not sure that that is what i want GL11.glEnable(GL11.GL_BLEND); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); wr.setColorOpaque_F(1f, 1f, 1f); ... Any ideas? Eclipse isn't showing anything wrong. I deleted my build folder to ensure nothing is being cached, cleaned the project, even switch from forge 1.8/1281 to forge 1.8/1285.
-
Thanks. I guess i'll just have to update my code you helped me with for 1.7.10.
-
Hi. I'm updating a mod from 1.7.10 to 1.8. I have an ore block in which I use the vanilla/resourcepack stone as the texture with my ore as the overlay. Following grass as an example I setup all my .json files similar (adding top and bottom with overlay). Now the block renders white with the overlay, but the item in my hand renders correctly. Not sure what is going there as I thought an item takes its model info from the block. Ex. blockstates / titanium_ore.json: { "variants": { "normal": { "model": "sgs_metals:titanium_block" } } } models.block / titanium_ore.json: { "parent": "sgs_metals:block/titanium_ore_parent", "textures": { "particle": "blocks/stone", "bottom": "blocks/stone", "top": "blocks/stone", "side": "blocks/stone", "overlay": "sgs_metals:blocks/titanium_ore_overlay" } } models.block / titanium_ore_parent { "elements": [ { "from": [ 0, 0, 0 ], "to": [ 16, 16, 16 ], "faces": { "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" }, "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top", "cullface": "up", "tintindex": 0 }, "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "north" }, "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "south" }, "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "west" }, "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "east" } } }, { "from": [ 0, 0, 0 ], "to": [ 16, 16, 16 ], "faces": { "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "down" }, "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "up" }, "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" }, "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" }, "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" }, "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" } } } ] } models.item / titanium_ore: { "parent": "sgs_metals:block/titanium_ore", "display": { "thirdperson": { "rotation": [ 10, -45, 170 ], "translation": [ 0, 1.5, -2.75 ], "scale": [ 0.375, 0.375, 0.375 ] } } }
-
Indeed, Z-fighting was the culprit. It all works swimmingly now. Thanks to all for helping me walk through this. The overlay ore texture on top of the default/resourcepack block texture looks much better than my static ore block. It can blend in with whatever resourcepack so much easier now. Thanks again!
-
I understand the gist of what your suggesting, but I'm not sure how I would accomplish this. (I'm not in a place where I can test it at the moment). Will my block render itself in the world before my TESR executes()? ie. if i used an empty render() method the TESR would I see the plain block? Or are you suggesting I somehow use the code the renderBlockBeacon() method in the RenderBlocks class? All of it's code is reliant on other methods with RenderBlocks which I'd have to copy or extend.
-
Ok, I tried doing as you instructed. You can see the light source affect the block coloring in a chunky gradient fashion, however, they still look nothing like the original stone block. ie not smooth gradient and different color. (I removed my ore overlay to make it clearer) My blocks are highlighted in red, vanilla in blue. i'm posting the whole class: /** * */ package com.sgs.metals.client.render.tileentity; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; import com.sgs.metals.Metals; public class OreTileEntityRenderer extends TileEntitySpecialRenderer { private ResourceLocation blockTexture; private ResourceLocation oreTexture; /** * * @param blockTexture * @param oreTexture */ public OreTileEntityRenderer(String blockTexture, String oreTexture ) { setBlockTexture(new ResourceLocation(blockTexture)); setOreTexture(new ResourceLocation(oreTexture)); } /* (non-Javadoc) * @see net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer#renderTileEntityAt(net.minecraft.tileentity.TileEntity, double, double, double, float) */ @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale) { int au = 0; int av = 0; int bu= 0; int bv = 1; int cu = 1; int cv = 1; int du = 1; int dv = 0; // get the world from tile entity World world = tileEntity.getWorldObj(); // get the x,y,z coords of the tile entity/block int bx = tileEntity.xCoord; int by = tileEntity.yCoord; int bz = tileEntity.zCoord; // get the block Block block = world.getBlock(bx, by, bz); // get the color multiplier int l = block.colorMultiplier(world, bx, by, bz); float cf = (float)(l >> 16 & 255) / 255.0F; float cf1 = (float)(l >> 8 & 255) / 255.0F; float cf2 = (float)(l & 255) / 255.0F; if (EntityRenderer.anaglyphEnable) { float cf3 = (cf * 30.0F + cf1 * 59.0F + cf2 * 11.0F) / 100.0F; float cf4 = (cf * 30.0F + cf1 * 70.0F) / 100.0F; float cf5 = (cf * 30.0F + cf2 * 70.0F) / 100.0F; cf = cf3; cf1 = cf4; cf2 = cf5; } //////////////////// // opaque colors float f3 = 0.5F; float f4 = 1.0F; float f5 = 0.8F; float f6 = 0.6F; float f7 = f4 * cf; float f8 = f4 * cf1; float f9 = f4 * cf2; float f10 = f3; float f11 = f5; float f12 = f6; float f13 = f3; float f14 = f5; float f15 = f6; float f16 = f3; float f17 = f5; float f18 = f6; f10 = f3 * cf; f11 = f5 * cf; f12 = f6 * cf; f13 = f3 * cf1; f14 = f5 * cf1; f15 = f6 * cf1; f16 = f3 * cf2; f17 = f5 * cf2; f18 = f6 * cf2; // bind the texture to use Minecraft.getMinecraft().renderEngine.bindTexture(getBlockTexture()); // set up GL GL11.glPushMatrix(); GL11.glTranslated(x, y, z); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_LIGHTING); Tessellator t = Tessellator.instance; // for (int i = 0; i <=1; i++) { // if (i > 0) { // // bind the overlay resource texture // Minecraft.getMinecraft().renderEngine.bindTexture(getOreTexture()); // // set the the alpha settings // // these three enable opacity of whole image - not sure that that is what i want // GL11.glEnable(GL11.GL_BLEND); // GL11.glDepthMask(false); // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // } // draw the opaque block // north-face // xyz clockwise t.startDrawingQuads(); t.setColorOpaque_F(f11, f14, f17); t.setBrightness(block.getMixedBrightnessForBlock(world, bx, by, bz - 1)); // add the vertices t.addVertexWithUV(0, 0, 0, cu, cv); //A:c t.addVertexWithUV(0, 1, 0, du, dv); //B:d t.addVertexWithUV(1, 1, 0, au, av); //C:a t.addVertexWithUV(1, 0, 0, bu, bv); //D:b t.draw(); // south face // xyz counter-clockwise; uv hortizontal flip t.startDrawingQuads(); t.setColorOpaque_F(f11, f14, f17); t.setBrightness(block.getMixedBrightnessForBlock(world, bx, by, bz + 1)); t.addVertexWithUV(0, 0, 1, bu, bv); //c t.addVertexWithUV(1, 0, 1, cu, cv); //b t.addVertexWithUV(1, 1, 1, du, dv); //d t.addVertexWithUV(0, 1, 1, au, av); //a t.draw(); // east face // xyz clockwise t.startDrawingQuads(); t.setColorOpaque_F(f12, f15, f18); t.setBrightness(block.getMixedBrightnessForBlock(world, bx + 1, by, bz)); t.addVertexWithUV(1, 0, 0, cu, cv); t.addVertexWithUV(1, 1, 0, du, dv); t.addVertexWithUV(1, 1, 1, au, av); t.addVertexWithUV(1, 0, 1, bu, bv); t.draw(); // west face // xyz counter-clockwise t.startDrawingQuads(); t.setColorOpaque_F(f12, f15, f18); t.setBrightness(block.getMixedBrightnessForBlock(world, bx - 1, by, bz)); t.addVertexWithUV(0, 0, 0, bu, bv); t.addVertexWithUV(0, 0, 1, cu, cv); t.addVertexWithUV(0, 1, 1, du, dv); t.addVertexWithUV(0, 1, 0, au, av); t.draw(); // top face // xyz clockwise t.startDrawingQuads(); t.setColorOpaque_F(f7, f8, f9); t.setBrightness(block.getMixedBrightnessForBlock(world, bx, by + 1, bz)); t.addVertexWithUV(0, 1, 0, cu, cv); t.addVertexWithUV(0, 1, 1, du, dv); t.addVertexWithUV(1, 1, 1, au, av); t.addVertexWithUV(1, 1, 0, bu, bv); t.draw(); // bottom face // xyz counter clockwise t.startDrawingQuads(); t.setColorOpaque_F(f10, f13, f16); t.setBrightness(block.getMixedBrightnessForBlock(world, bx, by - 1, bz)); t.addVertexWithUV(0, 0, 0, bu, bv); t.addVertexWithUV(1, 0, 0, cu, cv); t.addVertexWithUV(1, 0, 1, du, dv); t.addVertexWithUV(0, 0, 1, au, av); t.draw(); // } // clean up GL11.glPopAttrib(); GL11.glPopMatrix(); } /** * @return the texture */ public ResourceLocation getBlockTexture() { return blockTexture; } /** * @return the texture */ public ResourceLocation getOreTexture() { return oreTexture; } /** * @param texture the texture to set */ public void setBlockTexture(ResourceLocation texture) { this.blockTexture = texture; } public synchronized void setOreTexture(ResourceLocation oreTexture) { this.oreTexture = oreTexture; } }
-
Thanks TheGreyGhost, However, following the code for the call tessellator.setBrightness(block.getMixedBrightnessForBlock(this.blockAccess, x, y- 1, z)) requires that I pass something that implements IBlockAccess into getMixedBrightnessForBlock(). A TESR doesn't provide that property. How else can I obtain an IBlockAccess object? Thanks
-
Whenever I create a Tile Entity and render it with TileEntitySpecialRenderer, the resultant model is always a different shade than the original texture that is used. Here is an example. In this case, i'm using OpenGL to render the block with the standard stone texture with an custom overlay for the ore. For this instance I followed this thread: http://www.minecraftforge.net/forum/index.php/topic,26033.msg132818.html#msg132818. However, this did not solve my issue. This also happens when I use a Techne generated model. (My blocks have the red arrows pointing at them) Here is TESR code I used for this example public class OreTileEntityRenderer extends TileEntitySpecialRenderer { private ResourceLocation blockTexture; private ResourceLocation oreTexture; /** * * @param blockTexture * @param oreTexture */ public OreTileEntityRenderer(String blockTexture, String oreTexture ) { setBlockTexture(new ResourceLocation(blockTexture)); setOreTexture(new ResourceLocation(oreTexture)); } @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale) { int au = 0; int av = 0; int bu= 0; int bv = 1; int cu = 1; int cv = 1; int du = 1; int dv = 0; // bind the texture to use Minecraft.getMinecraft().renderEngine.bindTexture(getBlockTexture()); // set up GL GL11.glPushMatrix(); GL11.glTranslated(x, y, z); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_LIGHTING); Tessellator t = Tessellator.instance; for (int i = 0; i <=1; i++) { if (i > 0) { Minecraft.getMinecraft().renderEngine.bindTexture(getOreTexture()); GL11.glEnable(GL11.GL_BLEND); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glAlphaFunc(GL11.GL_LESS, 1.0f); } // draw the opaque block t.startDrawingQuads(); t.setColorOpaque_F(1.0F, 1.0F, 1.0F); // add the vertices t.addVertexWithUV(0, 0, 0, cu, cv); //A:c t.addVertexWithUV(0, 1, 0, du, dv); //B:d t.addVertexWithUV(1, 1, 0, au, av); //C:a t.addVertexWithUV(1, 0, 0, bu, bv); //D:b t.draw(); ... // removed rest for brevity Any help is much appreciated. UPDATE: And light sources change the color when other blocks (stone) aren't. This there a block variable I have to set? This doesn't seem like a rendering problem.
-
So apparently, if I'm reading the code correctly, you can not add new BiomeDictionary.Type's as there is a private list whose length is set. private static ArrayList[] typeInfoList = new ArrayList[Type.values().length]; That length is not updated when calling registerBiomeType. public static boolean registerBiomeType(BiomeGenBase biome, Type ... types) { types = listSubTags(types); if(BiomeGenBase.getBiomeGenArray()[biome.biomeID] != null) { for(Type type : types) { if(typeInfoList[type.ordinal()] == null) { typeInfoList[type.ordinal()] = new ArrayList(); } typeInfoList[type.ordinal()].add(biome); } if(biomeList[biome.biomeID] == null) { biomeList[biome.biomeID] = new BiomeInfo(types); } else { for(Type type : types) { biomeList[biome.biomeID].typeList.add(type); } } return true; } return false; } My code in the first post fails at: typeInfoList[type.ordinal()].add(biome); So, my thought was to extend the BiomeDictionary and override this method to work properly, but I didn't know if it then would still work with other mods that register new biomes?
-
I was looking to differentiate between Ocean and Deep Ocean by assigning a new biome Type to BiomeGenBase.deepOcean by using the following code snippet: Type deepOcean = BiomeDictionary.Type.getType("DEEP OCEAN"); BiomeDictionary.registerBiomeType(BiomeGenBase.deepOcean, deepOcean); However, I get this error: java.lang.ArrayIndexOutOfBoundsException: 31 at net.minecraftforge.common.BiomeDictionary.registerBiomeType(BiomeDictionary.java:152) ... It's like array to store the biome types isn't being resized. Anyone know the way to do this?
-
I'm doing very little saving of data really. What I am attempting to do is create a virtual entity that exists when the actual entity is removed - transferring the actual entity state to the virtual entity. Then when the actual entity is reloaded, I can transfer state back from virtual entity to actual entity. I'm attempting to perform entity processing even when the entity would normally saved off because it exceeds the maximum chunk distance from the player.
-
Thanks, that will probably do the trick for the loading entity portion. (Crud, I forgot to ask, but I'm assuming there would something similar for a TileEntity). I'm looking for something more towards Note2, I want to do some data-saving and processing before entity is removed - again, doesn't have to mean the entity is killed, just unloaded. My overall goal is to track the moment a certain entity joins the world, and the moment it leaves the world, whether that be by spawn, load, death or save.
-
I was wondering if there is a way to know when an entity (mob or animal) is loaded (not necessarily spawned) and when they are removed (not necessarily killed or despawned) from active memory? I was thinking of using the EntityJoinWorldEvent, but I didn't know if that was when the entity was first spawned or loaded back into the game. As well, I didn't find an event that might be fired when the entity was saved off. Thanks
-
[SOLVED][1.7.10] Loading/Saving Data on Game Load/Save
gottsch replied to gottsch's topic in Modder Support
Thanks again! -
[SOLVED][1.7.10] Loading/Saving Data on Game Load/Save
gottsch replied to gottsch's topic in Modder Support
Thanks diesieben07. Is there an event or something I can use to load/setup my data structure when the map first loads up? And calling markDirty - is this required only once? ie. it sets a flag and when the game is saved (user initiated game save) that flag is checked, or would I have to call this every time i change my data (Minecraft saves the data continually behind-the-scenes)? -
I have a data structure that I'm maintaining in the main Mod class. I would like to persist this data with the game file when the game/map saves and load it when the game/map loads. I seen several places where it is suggested to use WorldSavedData. I understand that this will save extra data with the world map. What I'm not connecting the dots on is how to access this from my Mod class. Are there WorldLoadEvent and WorldSaveEvents that I can register to? What I don't want to do is continually update WorldSavedData from a TileEntity or Entity or something. My data structure would be help in memory and I would like to read/dump it once at game load/save. Thanks!
-
Thanks. Is there a way to do it with using an Entity as opposed to a double Block structure?
-
Hello, I created a Techne model that is two blocks wide. I can render this no problem, however I don't know how to properly set the bounding box up. I tried setting the bounds using setBlockBounds(0F,0F,0F, 2F, 1F, 1F) and this indeed created a 2-block wide bounding box (black wire-frame), however, I can walk right through the model/block at the 2nd block area. Any thoughts? Thanks
-
[1.7.10] Custom Painting Rendering Half Block Off
gottsch replied to gottsch's topic in Modder Support
Thanks, but these params are ints, so this value will just get truncated back to the whole int value. But for good measure, I attempted with +/-1. The outcome was the same (just a full block in a different direction). Just to make clear, the painting initially renders in the correct place, but then almost immediately shifts upwards. If I add more block to make a higher wall, it will shift even higher depending on the way I look at it.