Jump to content

Recommended Posts

Posted

So i have been trying to rotate a texture of a block face with no success. I have tried to do it with ISBRH, but it seems like every documentation of it is either outdated or i can't get it to work.

I just need to rotate the top and the botom face of a block, because they are rotated the same way as always. Here is my code:

package mali_plavi.automation.blocks;

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import mali_plavi.automation.AutomationMain;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class AutomatorBlock extends Block{

private int x,y,z;
private World w;

public AutomatorBlock(String n, Material m) {
	super(m);
	this.setBlockName(n);
	this.setBlockTextureName(AutomationMain.MODID + ":" + n);
}

protected IIcon bottom;
protected IIcon top;
protected IIcon left;
protected IIcon right;
protected IIcon front;
protected IIcon back;

private int facing = 0;

@Override
public void registerBlockIcons(IIconRegister r){
	this.bottom = r.registerIcon(textureName + "_bottom");
	this.top = r.registerIcon(textureName + "_top");
	this.front = r.registerIcon(textureName + "_front");
	this.left = r.registerIcon(textureName + "_left");
	this.right = r.registerIcon(textureName + "_right");
	this.back = r.registerIcon(textureName + "_back");
}

@Override
public void onBlockPlacedBy(World w, int p1, int p2, int p3, EntityLivingBase e, ItemStack i) {
	facing = determineOrientation(w, p1, p2, p3, e);
	w.setBlockMetadataWithNotify(p1, p2, p3, facing, 2);
	System.out.println(w.getBlockMetadata(p1, p2, p3));
	x = p1;
	y = p2;
	z = p3;
	this.w = w;

}

@Override
public IIcon getIcon(int side, int meta){
	if(meta == 2){
		if(side == 0) return bottom;
		if(side == 1) return top;
		if(side == 2) return front;
		if(side == 3) return back;
		if(side == 4) return right;
		if(side == 5) return left;
	}
	if(meta == 3){
		if(side == 0) return bottom;
		if(side == 1) return top;
		if(side == 2) return back;
		if(side == 3) return front;
		if(side == 4) return left;
		if(side == 5) return right;
	}

	return blockIcon;
}
public static int determineOrientation(World par0World, int par1, int par2, int par3, EntityLivingBase par4EntityLivingBase) {
	if (MathHelper.abs((float)par4EntityLivingBase.posX - (float)par1) < 2.0F && MathHelper.abs((float)par4EntityLivingBase.posZ - (float)par3) < 2.0F) {
		double d0 = par4EntityLivingBase.posY + 1.82D - (double)par4EntityLivingBase.yOffset;

	/*	if (d0 - (double)par2 > 2.0D) {
			return 1;
		}

		if ((double)par2 - d0 > 0.0D) {
			return 0;
		}*/
	}
	int l = MathHelper.floor_double((double)(par4EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
	return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
}
}

 

Any help is appreciated, thanks.

Posted

0) Why are you still on 1.7.10?

 

1) You know that with just a block you can't rotate the top face, yes?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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



×
×
  • Create New...

Important Information

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