Jump to content

[1.7.2][Solved]Need Help for Temp Fix Bed Texture Bug


Lylac

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

  • 2 weeks later...

    @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))))

 

width=800 height=457https://31.media.tumblr.com/3f23ae0b31f4d8d9404cadc2ae203b21/tumblr_n5a3xxv8Ki1tnzqt4o1_1280.png[/img]

width=800 height=457https://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.

Link to comment
Share on other sites

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 =)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

well since i've no idea how you can write a mod out of this fix, i pray that you'll get it :D

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)

Link to comment
Share on other sites

  • 2 months later...

I know that it is easy to change to 1.7.10 :D 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 :x

 

What do i have to change for the bed glitch? I mean inside of forge 1.7.2 not a version change.

Link to comment
Share on other sites

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

    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa Di dunia perjudian online yang begitu kompetitif, mencari platform yang dapat memberikan kemenangan maksimal (Maxwin) dan hasil terbaik (Gacor) adalah prioritas bagi para penjudi yang cerdas. Dalam upaya ini, OLXTOTO telah muncul sebagai pemain kunci yang mengubah lanskap perjudian online dengan menawarkan pengalaman tanpa tandingan.     Sejak diluncurkan, OLXTOTO telah menjadi sorotan industri perjudian online. Dikenal sebagai "Platform Maxwin dan Gacor Terbesar Sepanjang Masa", OLXTOTO telah menarik perhatian pemain dari seluruh dunia dengan reputasinya yang solid dan kinerja yang luar biasa. Salah satu fitur utama yang membedakan OLXTOTO dari pesaingnya adalah komitmen mereka untuk memberikan pengalaman berjudi yang unik dan memuaskan. Dengan koleksi game yang luas dan beragam, termasuk togel, slot online, live casino, dan banyak lagi, OLXTOTO menawarkan sesuatu untuk semua orang. Dibangun dengan teknologi terkini dan didukung oleh tim ahli yang berdedikasi, platform ini memastikan bahwa setiap pengalaman berjudi di OLXTOTO tidak hanya menghibur, tetapi juga menguntungkan. Namun, keunggulan OLXTOTO tidak hanya terletak pada permainan yang mereka tawarkan. Mereka juga terkenal karena keamanan dan keadilan yang mereka berikan kepada para pemain mereka. Dengan sistem keamanan tingkat tinggi dan audit rutin yang dilakukan oleh otoritas regulasi independen, para pemain dapat yakin bahwa setiap putaran permainan di OLXTOTO adalah adil dan transparan. Tidak hanya itu, OLXTOTO juga dikenal karena layanan pelanggan yang luar biasa. Dengan tim dukungan yang ramah dan responsif, para pemain dapat yakin bahwa setiap pertanyaan atau masalah mereka akan ditangani dengan cepat dan efisien. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi platform pilihan bagi para penjudi online yang mencari kemenangan maksimal dan hasil terbaik. Jadi, jika Anda ingin bergabung dengan jutaan pemain yang telah merasakan keajaiban OLXTOTO, jangan ragu untuk mendaftar dan mulai bermain hari ini!  
    • OLXTOTO adalah bandar slot yang terkenal dan terpercaya di Indonesia. Mereka menawarkan berbagai jenis permainan slot yang menarik dan menghibur. Dengan tampilan yang menarik dan grafis yang berkualitas tinggi, pemain akan merasa seperti berada di kasino sungguhan. OLXTOTO juga menyediakan layanan pelanggan yang ramah dan responsif, siap membantu pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Daftar =  https://surkale.me/Olxtotodotcom1
    • DAFTAR & LOGIN BIGO4D   Bigo4D adalah situs slot online yang populer dan menarik perhatian banyak pemain slot di Indonesia. Dengan berbagai game slot yang unik dan menarik, Bigo4D menjadi tempat yang ideal untuk pemula dan pahlawan slot yang berpengalaman. Dalam artikel ini, kami akan membahas tentang Bigo4D sebagai situs slot terbesar dan menarik yang saat ini banyak dijajaki oleh pemain slot online.
    • DAFTAR & LOGIN BIGO4D Bigo4D adalah situs togel online yang menjadi pilihan banyak pemain di Indonesia. Dengan berbagai keunggulan yang dimilikinya, Bigo4D mampu menjadi situs togel terbesar di pasaran saat ini. Dalam artikel ini, kami akan membahas secara lengkap tentang Bigo4d dan alasan-alasannya menjadi situs togel favorit banyak pemain.
    • Slot Gacor >> Mudah Maxwin Bersama Djarum4D   Slot gacor adalah salah satu jenis permainan judi online yang sangat populer di Indonesia. Bermain slot gacor berarti bermain permainan slot dengan kemungkinan keluaran yang lebih tinggi daripada slot tradisional. Dalam artikel ini, kami akan membahas secara lengkap tentang slot gacor, mulai dari pengertian dasar, cara bermain, strategi pemain, serta aspek keamanan dan etika dalam bermain.
  • Topics

×
×
  • Create New...

Important Information

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