Posted April 27, 201411 yr There isn't a fix for this vanilla bug in forge yet, so I'm making do with a temp fix and got stuck along the way. If you know of something that could help with this please reference it down below. Based on google search, I've hardly found any documentation relating to this texture bug, and it would help the populace out. I've been digging around in these files: BlockBed.class, BlockDirectional.class, Block.class, Direction.class, and ItemBed.class to understand how beds render their textures. To my understanding, the bed takes the side of the block and the coords of the block itself and it is able to assign a texture using those four integers(1 for side, and 3 for coords) Here is the code for the texturing of the bed: @SideOnly(Side.CLIENT) public IIcon getIcon(int p_149691_1_, int p_149691_2_) { if (p_149691_1_ == 0) { return Blocks.planks.getBlockTextureFromSide(p_149691_1_); } else { int k = getDirection(p_149691_2_); int l = Direction.bedDirection[k][p_149691_1_]; int i1 = isBlockHeadOfBed(p_149691_2_) ? 1 : 0; return (i1 != 1 || l != 2) && (i1 != 0 || l != 3) ? (l != 5 && l != 4 ? this.field_149983_N[i1] : this.field_149982_M[i1]) : this.field_149980_b[i1]; } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { this.field_149983_N = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_top"), p_149651_1_.registerIcon(this.getTextureName() + "_head_top")}; this.field_149980_b = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_end"), p_149651_1_.registerIcon(this.getTextureName() + "_head_end")}; this.field_149982_M = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_side"), p_149651_1_.registerIcon(this.getTextureName() + "_head_side")}; } And my Snippet of that code. Im using this to understand the math behind this. Player is facing south Side = 2 Coords = -190, 4, 1301 Head of Bed = -190, 4, 1301 Feet of Bed = -190, 4, 1302 public IIcon getIcon(int 3, int (-190, 4, 1301)) { if (2 == 0) FALSE { return Blocks.planks.getBlockTextureFromSide(p_149691_1_); } else { int k = getDirection((-190, 4, 1301)); int l = Direction.bedDirection[k][2]; int i1 = isBlockHeadOfBed(-190, 4, 1301) ? 1 : 0; TRUE : 1 return (1 != 1 FALSE || l != 2) && (i1 != 0 || l != 3) ? (l != 5 && l != 4 ? this.field_149983_N[i1] : this.field_149982_M[i1]) : this.field_149980_b[i1]; } } In this I am using the north direction of the block which is bed_head_end.png. It's also the Head of the bed as well. But the part I'm stuck at is Direction.bedDirection[k][2]; where it takes the coords of the bed and the side too and somehow compares that to a number. Thoughts? Advice?
April 27, 201411 yr The metadata of the bed tells the direction of the bed. so, we can get the texture using the side and direction(metadata). * Remember that int value cannot save three values, so it cannot represent the coordinates. the coordinates have nothing to do with rendering. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
April 27, 201411 yr Hi The bed code from 1.6.4 is the same, but I've refactored it a bit to make the logic more clear. public Icon getIcon(int side, int metadata) { if (side == 0) { return Block.planks.getBlockTextureFromSide(side); } else { int bedDirection = getDirection(metadata); int bedSide = Direction.bedDirection[bedDirection][side]; int thisIsHeadOfBed = isBlockHeadOfBed(metadata) ? 1 : 0; if (thisIsHeadOfBed == 1 && bedSide == 2) { return this.bedEndIcons[thisIsHeadOfBed]; } else { if (thisIsHeadOfBed == 0 && bedSide == 3) { return this.bedEndIcons[thisIsHeadOfBed]; } else { if (bedSide == 5 || bedSide == 4) { return this.bedSideIcons[thisIsHeadOfBed]; } else { return this.bedTopIcons[thisIsHeadOfBed]; } } } } } This link might also help understand about directions ("side") in Minecraft, assuming you don't already know http://greyminecraftcoder.blogspot.com.au/2013/07/blocks.html The bed can be placed in one of four orientations, and there are two parts. This information is encoded into the bottom three bits of metadata; bedDirectionBits and thisIsHeadOfBed extract this back out. The bedDirection[][] array is used to convert the side and the bed orientation into the "bed side", i.e. a number showing which of the six faces of the bed is being drawn. -TGG
April 27, 201411 yr Author Player is facing WEST Side = 5 Bed Direction = 2? Head of Bed = -190, 4, 1301 Feet of Bed = -190, 4, 1302 [bed Direction][side] public static final int[][] bedDirection = new int[2][5] {{1, 0, 3, 2, 5, 4}, {1, 0, 5, 4, 2, 3}, {1, 0, 2, 3, 4, 5}, {1, 0, 4, 5, 3, 2}}; public IIcon getIcon(int Side, int (Bed Direction)) if (5 == 0) FALSE (Side == 0) { return Blocks.planks.getBlockTextureFromSide(p_149691_1_); } else { int k = getDirection(0); BedDirection int l = Direction.bedDirection[2][5]; int l = 5 int i1 = isBlockHeadOfBed(TRUE) ? 1 : 0; = 1 return (i1 != 1 FALSE || l != 2 TRUE) TRUE && (i1 != 0 TRUE || l != 3 TRUE) TRUE = TRUE ? (l != 5 FALSE && l != 4 TRUE = FALSE ? this.field_149983_N[i1] : this.field_149982_M[i1]) : this.field_149980_b[i1]; Field M[1] } } i1 != 1 ~ Checks if face is on Head FALSE l != 2 ~ Checks if face is on north side TRUE TRUE i1 != 0 ~ Checks if face is on foot TRUE l !=3 ~ Checks if face is on south side TRUE TRUE TRUE l != 5 ~ Checks if face is either on east side FALSE l != 4 ~ Checks if face is either on west side TRUE FALSE l == 5 ~ Checks if face is either on east side TRUE l != 4 ~ Checks if face is either on west side TRUE TRUE (i1 != 1 || l != 2) && (i1 != 0 || l != 3) ? (l != 5 && l != 4 ? N : M) : b <-- Old (i1 != 1 || l != 2) && (i1 != 0 || l != 3) ? (l != 5 && l != 4 ? N : (l == 5 && l !=4) ? M : O) : b <-- New Field O[1] ~~~~~~~~~~~~~~~ @SideOnly(Side.CLIENT) private IIcon[] field_149982_O; return (i1 != 1 || l != 2) && (i1 != 0 || l != 3) ? (l != 5 && l != 4 ? this.field_149983_N[i1] : (l ==5 && l !=4) ? this.field_149982_M[i1] : this.field_149982_O[i1]) : this.field_149980_b[i1]; this.field_149982_O = new IIcon[] {p_149651_1_.registerIcon(PODmod.MODID+":"+this.getTextureName()+"_feet_side"), p_149651_1_.registerIcon(PODmod.MODID+":"+this.getTextureName()+"_head_side")}; From what I gathered, with help from you guys, I've been able to come up with a new part to add to the ternary operator equation here. The old one did not have the support for 8 faces needed for the bed. That was the first problem to the bug, and now with a fourth line added to render the bugged side of the bed comes the second problem. The textures need to be flipped with IconFlipped(). I'm still new to modding, so I'm not really sure how to implement IconFlipped() into field O. I'll keep looking in BlockDoor.Class, but hopefully something comes up. Thanks for helping so far
May 9, 201411 yr Author @SideOnly(Side.CLIENT) public IIcon getIcon(int p_149691_1_, int p_149691_2_) { if (p_149691_1_ == 0) { return Blocks.planks.getBlockTextureFromSide(p_149691_1_); } else { int k = getDirection(p_149691_2_); int l = Direction.bedDirection[k][p_149691_1_]; int i1 = isBlockHeadOfBed(p_149691_2_) ? 1 : 0; if (i1 == 1 && l == 2) { return this.field_149980_b[i1]; } else if (i1 == 0 && l == 3) { return this.field_149980_b[i1]; } else switch (l) { case 1: return this.field_149983_N[i1]; case 2: return this.field_149982_O[i1]; <--Dummy case 3: return this.field_149982_O[i1]; <--Dummy case 4: return (k == 2 ? this.field_149982_M[i1] : (k == 1 ? this.field_149982_M[i1] : new IconFlipped(this.field_149982_M[i1], true, false))); case 5: return (k == 3 ? this.field_149982_M[i1] : (k == 0 ? this.field_149982_M[i1] : new IconFlipped(this.field_149982_M[i1], true, false))); default: return this.field_149983_N[i1]; } } } ~~~~~~~~~~~~~~~~~~~~~ return (i1 != 1 || l != 2) && (i1 != 0 || l != 3) ? (l != 5 && l != 4 ? this.field_149983_N[i1] : ( l !=5 ? (k == 2 ? this.field_149982_M[i1] : (k == 1 ? this.field_149982_M[i1] : new IconFlipped(this.field_149982_M[i1], true, false))) : (k == 3 ? this.field_149982_M[i1] : (k == 0 ? this.field_149982_M[i1] : new IconFlipped(this.field_149982_M[i1], true, false))))) : this.field_149980_b[i1]; in BlockBed.class replace this.field_149982_M[i1] with: ( l !=5 ? (k == 2 ? this.field_149982_M[i1] : (k == 1 ? this.field_149982_M[i1] : new IconFlipped(this.field_149982_M[i1], true, false))) : (k == 3 ? this.field_149982_M[i1] : (k == 0 ? this.field_149982_M[i1] : new IconFlipped(this.field_149982_M[i1], true, false)))) https://31.media.tumblr.com/3f23ae0b31f4d8d9404cadc2ae203b21/tumblr_n5a3xxv8Ki1tnzqt4o1_1280.png[/img] https://31.media.tumblr.com/95ac18c286c1e8253814bbcd8692c864/tumblr_n5a3xxv8Ki1tnzqt4o2_1280.png[/img] After much trial and error I fixed the texture bug. When I made the switch case statement in the notes/code above it helped me realize that the broken textures could not use the int i1 and l alone. Thanks to grey I was then able to use int k to work out a solution and found out how bed are truly rendered. The way beds are rendered is that l is used to handle the stored values of the sides of a bed depending how a bed is placed; 0, 1, 2, 3, 4, and 5 are stored in 4 arrays that correspond to the four directions in minecraft. 0 and 1 are the bottom and top, 2 and 3 are the ends, and 4 and 5 are used for the sides of a bed. Cases 4 and 5 (refer to the switch statement) handle how to render the textures for the sides of the bed and use k to do just that. k determines where the bed is facing when placed by a player. Using k it became easy to sort out the integers and fix the problem. for example, lets say the player is facing north at a side of a bed which has a value of 5, and the bed is facing south which is 0. using the notes from my last post we can find out which side l needs to store by using bedDirection and going 0 over and then 5 over starting from 0. so that gives l 4; k is 0, and the i1 is the head of the bed which is 1. using the switch statement here as a guide is an advantage, but if you are someone new to coding then I suggest learning boolean equations quickly as it is an easy subject. So now our side is a case 4 here, its k is not equal to 2 nor 1, so it will render as a flipped icon of the head side part of the bed texture. I only get 1 day a week to work on my mod as I am working on other cool stuff in the mean time, so generally this took me about 3 days to get. I hope you found this useful.
May 11, 201411 yr nice, is there a chance you can/will release that as a mod for the recommended forge, or will this only incorporated with the next forge releases? Greetings, Ray PS. There is the same, or at least a similar bug with the door =) a mod with a fix for both would be awesome, it's easier to send this friends =)
May 12, 201411 yr Author I'm not sure what I can do myself since I'm pretty new here too. There is a way to override minecraft files in 1.7.2 and force this fix upon the vanilla bed, but you'd have to create a new bed class to do it. I can put in a new suggestion for this after I go back to the door bug; I'm sure it's the same as the bed texture just the coding is different.
May 12, 201411 yr well since i've no idea how you can write a mod out of this fix, i pray that you'll get it I think the forge mod will not that soon released for the new minecraft version, so we'll play 1.7.2 for the next weeks/month and a fix mod would be really awesome! Thanks for the response =) Ray (sorry for my bad english, it's a long time since i had it in school)
July 16, 201411 yr But my mods for 1.7.2 will be useless right? ._. If so, can somebody tell me how to change forge 1.7.2 to fix it :c?
July 16, 201411 yr I know that it is easy to change to 1.7.10 i already did it, but it crahes because of my 1.7.2 mods - which i know is normal- but i want both - a normal bed and my mods What do i have to change for the bed glitch? I mean inside of forge 1.7.2 not a version change.
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.