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

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:

 

    @Override
    public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack)
    {
        int l = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
        par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);
    }

 

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

 

        @SideOnly(Side.CLIENT)
        @Override
        public Icon getIcon(int side, int meta)
        {
        	if (meta == 0 && side == 1)
        		return topIcon0;
        	if (meta == 1 && side == 1)
        		return topIcon1;
        	if (meta == 2 && side == 1)
        		return topIcon2;
        	if (meta == 3 && side == 1)
        		return topIcon3;
        	return blockIcon;
        }

 

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

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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