
Aidanamite
Members-
Posts
2 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
Aidanamite's Achievements

Tree Puncher (2/8)
0
Reputation
-
Minecraft Version: 1.12.2 So I've created a custom block with a huge number of possible varients so I've been trying to setup a tile entity to handle its rendering instead of waiting over 30 minutes for the game to start every time. The block is working correctly and everything and I've gotten most of the rendering working however I'm having an issue with the shading on the tile entity. For the purposes of the block I want it to look/render like the other blocks, as such I've made it generate a BakedModel and then parse that through the game's block rendering method. This is working for the most part except for the shading. Left: tile entity, Right: normal block Smooth lighting on: Smooth lighting off: Right: normal block, Left: tile entity Smooth lighting on: Smooth lighting off: Center: normal block, Left & Right: tile entity Smooth lighting on: (Note: smooth lighting does not seem to apply to the tile entities render) This is the section of the block's class that does the model generation and rendering: public class MCreatorCobble extends Elementsdesignblock.ModElement { public class BlockCustomEntityRender extends TileEntitySpecialRenderer<BlockCustomEntity> { //private BlockCustomEntityModel model; public BlockCustomEntityRender() { super(); } public void render(BlockCustomEntity te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { super.render(te,x,y,z,partialTicks,destroyStage,alpha); World world = te.getWorld(); BlockPos pos = te.getPos(); IBlockState state = world.getBlockState(pos); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); BlockColors colours = Minecraft.getMinecraft().getBlockColors(); BlockType type = blockTypes[BlockCustom.getMaterialId(state)]; try { BlockCustomEntityModel model = new BlockCustomEntityModel(state,type); GlStateManager.color(1f, 1f, 1f, alpha); GlStateManager.pushMatrix(); GlStateManager.translate(x - pos.getX(), y - pos.getY(), z - pos.getZ()); GlStateManager.bindTexture(ModelManager().getTextureMap().getGlTextureId()); bufferbuilder.begin(7, DefaultVertexFormats.ITEM); BlockModelRenderer().renderModel(world, model.model, state, pos, bufferbuilder, true); tessellator.draw(); GlStateManager.popMatrix(); GlStateManager.color(1f, 1f, 1f, 1f); } catch (Exception e) { if (e instanceof ReportedException) { CrashReport cr = ((ReportedException)e).getCrashReport(); System.err.println(cr.getCompleteReport()); cr.getCrashCause().printStackTrace(System.err); } else { System.err.println("Block with id " + Block.getIdFromBlock(type.block) + " failed to render\n" + e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(System.err); } } } } public class BlockCustomEntityModel { public List<BakedQuad> faces = Lists.<BakedQuad>newArrayList(); public IBakedModel model; public BlockCustomEntityModel() { super(); } public BlockCustomEntityModel(IBlockState state, BlockType type) { super(); TextureMap tm = ModelManager().getTextureMap(); TextureAtlasSprite spriteUp = tm.getTextureExtry(type.textureUp.main.texture); TextureAtlasSprite spriteDown = tm.getTextureExtry(type.textureDown.main.texture); TextureAtlasSprite spriteSide = tm.getTextureExtry(type.textureSide.main.texture); TextureAtlasSprite spriteUp2 = (type.textureUp.secondary == null ? null : tm.getTextureExtry(type.textureUp.secondary.texture)); TextureAtlasSprite spriteDown2 = (type.textureDown.secondary == null ? null : tm.getTextureExtry(type.textureDown.secondary.texture)); TextureAtlasSprite spriteSide2 = (type.textureSide.secondary == null ? null : tm.getTextureExtry(type.textureSide.secondary.texture)); if (spriteUp != null && spriteDown != null && spriteSide != null && (type.textureUp.secondary == null || spriteUp2 != null) && (type.textureDown.secondary == null || spriteDown2 != null) && (type.textureSide.secondary == null || spriteSide2 != null)) for (AxisAlignedBB axisalignedbb : BlockCustom.getCollisionBoxList(state)) { float minX = (float)(axisalignedbb.minX * 16); float minY = (float)(axisalignedbb.minY * 16); float minZ = (float)(axisalignedbb.minZ * 16); float maxX = (float)(axisalignedbb.maxX * 16); float maxY = (float)(axisalignedbb.maxY * 16); float maxZ = (float)(axisalignedbb.maxZ * 16); int x = 16-(int)minX; int X = 16-(int)maxX; int y = 16-(int)minY; int Y = 16-(int)maxY; int z = 16-(int)minZ; int Z = 16-(int)maxZ; addFaces(type.textureUp, minX,minY,minZ, maxX,maxY,maxZ, EnumFacing.UP, 16-x, 16-z, 16-X, 16-Z, spriteUp, spriteUp2); addFaces(type.textureDown, minX,minY,minZ, maxX,maxY,maxZ, EnumFacing.DOWN, 16-x, Z, 16-X, z, spriteDown, spriteDown2); addFaces(type.textureSide, minX,minY,minZ, maxX,maxY,maxZ, EnumFacing.WEST, 16-z, Y, 16-Z, y, spriteSide, spriteSide2); addFaces(type.textureSide, minX,minY,minZ, maxX,maxY,maxZ, EnumFacing.EAST, Z, Y, z, y, spriteSide, spriteSide2); addFaces(type.textureSide, minX,minY,minZ, maxX,maxY,maxZ, EnumFacing.NORTH, X, Y, x, y, spriteSide, spriteSide2); addFaces(type.textureSide, minX,minY,minZ, maxX,maxY,maxZ, EnumFacing.SOUTH, 16-x, Y, 16-X, y, spriteSide, spriteSide2); } else RenderFailed(Block.getIdFromBlock(type.block) + ":" + type.meta); Map<EnumFacing, List<BakedQuad>> fm = Maps.newEnumMap(EnumFacing.class); for (EnumFacing enumfacing : EnumFacing.values()) fm.put(enumfacing, Lists.newArrayList()); model = new SimpleBakedModel(faces, fm, true, true, spriteUp, ItemCameraTransforms.DEFAULT, ItemOverrideList.NONE); } private void addFaces(TextureData texture, float minX, float minY, float minZ, float maxX, float maxY, float maxZ, EnumFacing facing, float minU, float minV, float maxU, float maxV, TextureAtlasSprite sprite1, TextureAtlasSprite sprite2) { faces.add(MCreatorCobble.FaceBakery().makeBakedQuad( new Vector3f(minX,minY,minZ), new Vector3f(maxX,maxY,maxZ), new BlockPartFace(facing, texture.main.tint, texture.main.texture, new BlockFaceUV(new float[] {minU, minV, maxU, maxV}, 0)), sprite1, facing, ModelRotation.X0_Y0, null, true, true )); if (texture.secondary != null) faces.add(MCreatorCobble.FaceBakery().makeBakedQuad( new Vector3f(minX,minY,minZ), new Vector3f(maxX,maxY,maxZ), new BlockPartFace(facing, texture.secondary.tint, texture.secondary.texture, new BlockFaceUV(new float[] {minU, minV, maxU, maxV}, 0)), sprite2, facing, ModelRotation.X0_Y0, null, true, true )); } } } I've tried a large number of things, including: changing GlStateManager: the blending profile (trying to set to "DEFAULT" causes an exception to occur: "java.lang.ArrayIndexOutOfBoundsException: -33984 at net.minecraft.client.renderer.GlStateManager.bindTexture(GlStateManager.java:483)") matrix mode color blendFunc alphaFunc enabling/disabling GlStateManager: lighting light 0 through 7 blend alpha cull depth rescale normal However I've been unable to find any combination of these that some much as changes the shading that is done on the block. Any help or suggestions would be appritiated. Also if my post is missing any important information please feel free to ask. the block's full java file can be found here: MCreatorCobble.java
-
I am creating a mod that has a block that has several different light emission levels (depending on the blockstate of the block it will glow with different amounts of light). However I am having an issue where if the block's light changes too rapidly (like more than twice a second or something) the game throws a ConcurrentModificationException and crashes. Error StackTrace: java.util.ConcurrentModificationException: null at java.util.HashMap$HashIterator.nextNode(HashMap.java:1445) ~[?:1.8.0_222] at java.util.HashMap$KeyIterator.next(HashMap.java:1469) ~[?:1.8.0_222] at net.minecraft.client.renderer.RenderGlobal.updateClouds(RenderGlobal.java:1244) ~[RenderGlobal.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1961) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1187) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:441) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:25) [start/:?] If I set the light output to a fixed level, it operates fine. I have tried invoking the light updates when the state changes but that has not seemed to change anything.