Jump to content

Recommended Posts

Posted

Hey guys,

 

Is there any way to rotate the ENTIRE block (ie, not just the sides but the top as well?) Whenever I've tried rotation before, the sides change but not the top. It seems kind of silly to me that it works like that...

 

So, is it possible? I've looked through various classes (eg log, piston) but they are a bit more complex than what I want because the block itself is on it's side before it rotates the "top".

 

 

I only actually need to rotate the top-facing texture, but rotating the entire block is fine if that's easier.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

Here's an example of a block I want to do this on:

 

package co.uk.silvania.roads.block;

import removed.to.keep.clean;

public class RBDoubleYellowStripe extends Block
{
    public RBDoubleYellowStripe(int id) {
        super(id, Material.rock);
        this.setHardness(1.0F);
        this.setStepSound(Block.soundStoneFootstep);
this.setCreativeTab(Roads.tabRoads);
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.825F, 1.0F);
    }
       
@SideOnly(Side.CLIENT)
private Icon sides;
@SideOnly(Side.CLIENT)
private Icon top;

public void registerIcons(IconRegister iconRegister) {
        this.top = iconRegister.registerIcon("Roads:TarmacSideDoubleYellowStripe");
        this.sides = iconRegister.registerIcon("Roads:TarmacPlain");
}

    public boolean renderAsNormalBlock() {
        return false;
    }
    
    public boolean isOpaqueCube() {
    	return false;
    }
   
    @SideOnly(Side.CLIENT)
    @Override
    public Icon getIcon(int side, int meta)
    {
    	if (side == 1)
    		return top;
    	return sides;
    }
}

 

I only really need to rate the "top" texture, but if the "sides" get changed that doesn't matter at all.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

The way I am doing this is just to have different textures for each of the ways a block may face, then depending on your meta data getIcon can just return the appropriate icon. This of course means rotating and saving your top texture into multiple images and storing them using registerIcons, and possibly there is a better way to do this, but this way does work and it is very easy to do.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

Posted
  On 6/4/2013 at 3:15 AM, redria7 said:

The way I am doing this is just to have different textures for each of the ways a block may face, then depending on your meta data getIcon can just return the appropriate icon. This of course means rotating and saving your top texture into multiple images and storing them using registerIcons, and possibly there is a better way to do this, but this way does work and it is very easy to do.

 

 

To an extent, I've figured it out now. I can rotate it two ways (forward or sideways), but to get the "sideways" it has to be placed against a block.

I'm still tinkering though because I want four directions, but here's the code if you want it:

 

        public int getRenderType()
        {
            return 31;
        }
    	       
        public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta)
        {
            int j1 = meta & 3;
            byte b0 = 0;

            switch (side)
            {
                case 0:
                case 1:
                    b0 = 0;
                    break;
                case 2:
                case 3:
                    b0 = 8;
                    break;
                case 4:
                case 5:
                    b0 = 4;
            }

            return j1 | b0;
        }

        //This is the actual rotation part. I've tried all 16 metadatas, only these three seem to work.
        @SideOnly(Side.CLIENT)
        public Icon getIcon(int side, int meta)
        {
            int k = meta & 12;
            if (k == 0 && (side == 1)) {
            	return top;
        	} else if (k == 4 && (side == 1)) {
            	return top;
            } else if (k == 8 && (side == 1)) {
            	return top;
            }
		return sides;
        }

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

You are using the wrong method to set your meta data. you need to use:

 

  Reveal hidden contents

 

For that method I literally took it straight from the pumpkin class. That sets the meta data depending on the direction you are facing when you place the block. It does not take into account if you are looking up or down, just N, S, E, W.

 

Then getIcon will be something like...

 

  Reveal hidden contents

 

Of course you would have to set each of your topIcon variables along with blockIcon. This would give you a block where you rotate the top icon and the other sides all have the same texture. You can, of course, change this. The bottom is side == 0, top is side == 1, and the 4 sides are 2-5.

Read my thoughts on my summer mod work and tell me what you think!

http://www.minecraftforge.net/forum/index.php/topic,8396.0.html

 

I absolutely love her when she smiles

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

    • wait, i just did that. why didn't it work? also it's the same. help me!!!!
    • Culprit has been located! It was Tough As Nails + (plus) which was among one of the mods *added* before re-entering, in an attempt to improve compatibility. It, for some reason or another, did not want to work!
    • "You can either try to load it with only the vanilla data pack ("safe mode"), or go back to the title screen and fix it manually." Hello! I encountered this error just now while attempting to re-enter my world for the first time. Notably, no mods were removed before encountering this error and, while being able to find this error elsewhere on the internet, in my scenario it is seemingly caused by a specific mod, of which I cannot isolate. Things I have tried: - Enter "Safe Mode" (fails) - Remove datapacks (no change) - Reverted to old save data (no change) Here is the server log: https://mclo.gs/9vJQEfN I use Modrinth mod loader so please let me know how to share my mod list, and if it is needed.
    • So, i'm hosting (or attempting to host) a port-forwarded modded server for 1.12.2. There's quite a few mods in this pack, but they all run and have no compatibility issues (besides something causing the game to crash if you go fullscreen, a problem ive given up trying to identify or fix). It can run on 6gb of ram or less, and works fine in singleplayer. All of my friends that want to join have the exact same mod/config/game setup as I do (I personally helped them set everything up). Just to be safe, we've all allocated 12 gigabytes of RAM to the installation, and I've also allocated 12GB to the server itself. I am able to join with no issue and it runs fine. However, when they try to join, it gets stuck in the 'logging in' screen before their game becomes unresponsive. When they close it, it gives them the exit code 805306369, which usually means not enough RAM, but this cant be the case. On my screen, in the server, it shows them joining, and then disconnecting, so I dont think its a port-forwarding issue. They can all run it just fine in singleplayer as well. The annoying bit about this particular issue is that it generates no crash log. Does anyone have any suggestions? Thanks! Here is my debug log, and his, starting from the same place. MINE: [132647] [Netty Client IO #5INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132653.817 [132653] [Client threadINFO] [minecraftGuiConnecting] Connecting to 0, 25565 132654.682 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.common.core.transformer.ClassNodeTransformertransform29] Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 132654.684 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.map.core.transformer.ClassNodeTransformertransform29] Transforming class net.minecraft.client.network.NetHandlerPlayClient 132654.764 [132654] [Netty Client IO #9INFO] [FML] Server protocol version 2 132654.777 [132654] [Netty Client IO #9INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132656.193 [132656] [Client threadINFO] [FML] Injecting existing registry data into this client instance 132659.081 [132659] [Client threadINFO] [FML] Applying holder lookups 132659.082 [132659] [Client threadINFO] [FML] Holder lookups applied 132659.092 [132659] [Netty Client IO #9INFO] [FML] [Netty Client IO #9] Client side modded connection established HIS: [13:12:16] [Netty Client IO #0/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:25.597 [13:12:25] [Client thread/INFO] [minecraft/GuiConnecting]: Connecting to (my IP address and the server port 25565) 13:12:26.805 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.common.core.transformer.ClassNodeTransformer:transform:29]: Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 13:12:26.808 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.map.core.transformer.ClassNodeTransformer:transform:29]: Transforming class net.minecraft.client.network.NetHandlerPlayClient 13:12:26.936 [13:12:26] [Netty Client IO #1/INFO] [FML]: Server protocol version 2 13:12:27.114 [13:12:27] [Netty Client IO #1/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:27.480 [13:12:27] [Client thread/INFO] [FML]: Injecting existing registry data into this client instance 13:12:30.669 [13:12:30] [Client thread/INFO] [FML]: Applying holder lookups 13:12:30.671 [13:12:30] [Client thread/INFO] [FML]: Holder lookups applied 13:13:04.700 Process crashed with exit code -805306369 P.S - Both mods "CTM" and "FUSION" are present in both our folders so idk what that's about.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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