Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


Lylac
 Share

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.

Guest
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • public abstract class NitroglycerinFluid extends ForgeFlowingFluid { // Directly reference a log4j logger. private static final Logger LOGGER = LogManager.getLogger(); protected NitroglycerinFluid(Properties properties) { super(properties); } public static Properties createProperties() { return new Properties(() -> ModFluids.NITROGLYCERIN, () -> ModFluids.FLOWING_NITROGLYCERIN, FluidAttributes.builder(new ResourceLocation("sussybakaplus:block/nitroglycerin_still"), new ResourceLocation("sussybakaplus:block/nitroglycerin_flow")).overlay(new ResourceLocation("sussybakaplus:block/nitroglycerin_overlay")).density(3000).viscosity(1000).luminosity(15).temperature(1300)).tickRate(1).canMultiply().bucket(() -> ModItems.NITROGLYCERIN_BUCKET).block(() -> ModBlocks.NITROGLYCERIN); } @Override public boolean isSource(FluidState state) { return false; } @Override public int getAmount(FluidState state) { return state.getValue(LEVEL); } public void animateTick(Level p_76445_, BlockPos p_76446_, FluidState p_76447_, Random p_76448_) { LOGGER.info("animate"); if (!p_76447_.isSource() && !p_76447_.getValue(FALLING)) { if (p_76448_.nextInt(64) == 0) { p_76445_.playLocalSound((double)p_76446_.getX() + 0.5D, (double)p_76446_.getY() + 0.5D, (double)p_76446_.getZ() + 0.5D, SoundEvents.WATER_AMBIENT, SoundSource.BLOCKS, p_76448_.nextFloat() * 0.25F + 0.75F, p_76448_.nextFloat() + 0.5F, false); } } else if (p_76448_.nextInt(10) == 0) { p_76445_.addParticle(ParticleTypes.UNDERWATER, (double)p_76446_.getX() + p_76448_.nextDouble(), (double)p_76446_.getY() + p_76448_.nextDouble(), (double)p_76446_.getZ() + p_76448_.nextDouble(), 0.0D, 0.0D, 0.0D); } } @Nullable public ParticleOptions getDripParticle() { return ParticleTypes.DRIPPING_WATER; } @Override protected void beforeDestroyingBlock(LevelAccessor accessor, BlockPos pos, BlockState state) { BlockEntity blockentity = state.hasBlockEntity() ? accessor.getBlockEntity(pos) : null; LOGGER.info("spread to " + state.getBlock().getRegistryName().toString()); if (state.getBlock().getRegistryName().getPath().equals("fire")) { float f = 4.0F; Minecraft.getInstance().level.explode(null, pos.getX(), pos.getY(), pos.getZ(), f, Explosion.BlockInteraction.BREAK); } //Block.dropResources(state, accessor, pos, blockentity); } @Override public void tick(Level level, BlockPos pos, FluidState state) { //super.tick(level, pos, state); LOGGER.info("tick"); if (this.hasBurningNeighbors(level, pos)) { LOGGER.info("EXPLODING!!!"); float f = 4.0F; level.explode(null, pos.getX(), pos.getY(), pos.getZ(), f, Explosion.BlockInteraction.BREAK); } else { LOGGER.info(pos.toShortString() + " doesn't have any buring neighbors"); } } private boolean hasBurningNeighbors(LevelReader levelReader, BlockPos pos) { for(Direction direction : Direction.values()) { if (this.isBurning(levelReader, pos.relative(direction))) { return true; } } return false; } private boolean isBurning(LevelReader levelReader, BlockPos pos) { return (pos.getY() < levelReader.getMinBuildHeight() || pos.getY() >= levelReader.getMaxBuildHeight() || levelReader.hasChunkAt(pos)) && levelReader.getBlockState(pos).isBurning(levelReader, pos); } protected float getExplosionResistance() { return 0.0F; } public int getTickDelay(LevelReader p_76226_) { return p_76226_.dimensionType().ultraWarm() ? 1 : 1; } protected boolean isRandomlyTicking() { return true; } public Optional<SoundEvent> getPickupSound() { return Optional.of(SoundEvents.BUCKET_FILL); } } My Fluid Class
    • So how do I get the container? It doesn't need to be a event btw.
    • It says it in the log. It's 16. You need to use Java 8 instead of Java 16 for versions before 1.17.
    • What java version are you using (run "java -version" to get it)
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.