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

[1.7] Glitchy connected textures.


CJCutrone9
 Share

Recommended Posts

Hello all, I am back, and once again, I have a problem. (Go figure). This time it is in updating to 1.7. In 1.6.4, all my connected textures worked perfectly, now when I update to 1.7, most work perfectly. Every now and again, the texture flips itself 180. But only if it is on the x positive, or z negative side. Not sure what is going on... Here is the code:

 

package com.Cutrone.Lights.blocks;

import com.Cutrone.Geo.common.Geo_Main;
import com.Cutrone.Lights.common.Lights_Common;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class Generic extends Block{

public boolean hasConnectedTexture = false;
public boolean isMaelstrom = false;
public boolean hasTileEntity = false;
public boolean isGlass = false;

public int tr = 0;

public IIcon[] textures = new IIcon[47];

public int[] textureRefByID = { 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 
	19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 0, 0, 6, 6, 0, 
	0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 
	2, 2, 27, 14, 4, 4, 5, 5, 4, 4, 5, 5, 17, 17, 22, 26, 17, 17, 22, 26, 16, 16, 
	20, 20, 16, 16, 28, 28, 21, 21, 46, 42, 21, 21, 43, 38, 4, 4, 5, 5, 4, 4, 5, 5, 
	9, 9, 30, 12, 9, 9, 30, 12, 16, 16, 20, 20, 16, 16, 28, 28, 25, 25, 45, 37, 25, 
	25, 40, 32, 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1,
	1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3,
	3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 4, 4, 5, 5, 4,
	4, 5, 5, 17, 17, 22, 26, 17, 17, 22, 26, 7, 7, 24, 24, 7, 7, 10, 10, 29, 29, 44, 
	41, 29, 29, 39, 33, 4, 4, 5, 5, 4, 4, 5, 5, 9, 9, 30, 12, 9, 9, 30, 12, 7, 7, 24, 
	24, 7, 7, 10, 10, 8, 8, 36, 35, 8, 8, 34, 11 };

public Generic(Material material, boolean glass, boolean Trans) {
	super(material);

	isGlass = glass;

	if(isGlass && Trans){
		this.setLightOpacity(1);
	}


}
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        Block i1 = par1IBlockAccess.getBlock(par2, par3, par4);
        return i1 == this ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
    }
public boolean isOpaqueCube()
{
	if(isGlass){
		return false;
	}else{
		return true;
	}
   
}

public int getRenderBlockPass(){
	if(isGlass){
		return 0;
	}else{
		return 1;
	}    
    }
public boolean renderAsNormalBlock(){
	if(isGlass){
		return false;
	}else{
		return true;
	}    
    }

@SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister iconRegistry){
	for (int i = 0; i < 47; i++){ 
		textures[i] = iconRegistry.registerIcon(Lights_Common.modid +":"+this.getTextureName() + "_" + (i+1));
	}
    }

@Override
public IIcon getIcon(int side, int meta){

		return textures[0];

}
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){			
	boolean[] bitMatrix = new boolean[8];

if (side == 0 || side == 1){                 
		bitMatrix[0] = world.getBlock(x-1, y, z-1) == this;  
		bitMatrix[1] = world.getBlock(x, y, z-1) == this;   
		bitMatrix[2] = world.getBlock(x+1, y, z-1) == this; 
		bitMatrix[3] = world.getBlock(x-1, y, z) == this;  
		bitMatrix[4] = world.getBlock(x+1, y, z) == this;   
		bitMatrix[5] = world.getBlock(x-1, y, z+1) == this; 
		bitMatrix[6] = world.getBlock(x, y, z+1) == this;   
		bitMatrix[7] = world.getBlock(x+1, y, z+1) == this; 
		}         
	if (side == 2 || side == 3){
		bitMatrix[0] = world.getBlock(x+(side==2?1:-1), y+1, z) == this;
		bitMatrix[1] = world.getBlock(x, y+1, z)== this;
		bitMatrix[2] = world.getBlock(x+(side==3?1:-1), y+1, z) == this;
		bitMatrix[3] = world.getBlock(x+(side==2?1:-1), y, z) == this;  
		bitMatrix[4] = world.getBlock(x+(side==3?1:-1), y, z) == this;  
		bitMatrix[5] = world.getBlock(x+(side==2?1:-1), y-1, z) == this;
		bitMatrix[6] = world.getBlock(x, y-1, z) == this;  
		bitMatrix[7] = world.getBlock(x+(side==3?1:-1), y-1, z) == this;
		}        
	if (side == 4 || side == 5){     
		bitMatrix[0] = world.getBlock(x, y+1, z+(side==5?1:-1)) == this;
		bitMatrix[1] = world.getBlock(x, y+1, z) == this;   
		bitMatrix[2] = world.getBlock(x, y+1, z+(side==4?1:-1)) == this;
		bitMatrix[3] = world.getBlock(x, y, z+(side==5?1:-1)) == this;
		bitMatrix[4] = world.getBlock(x, y, z+(side==4?1:-1)) == this;
		bitMatrix[5] = world.getBlock(x, y-1, z+(side==5?1:-1)) == this;
		bitMatrix[6] = world.getBlock(x, y-1, z)== this;
		bitMatrix[7] = world.getBlock(x, y-1, z+(side==4?1:-1)) == this; 
		}                 
	int idBuilder = 0;         
	for (int i = 0; i <= 7; i++) 
		idBuilder = idBuilder + (bitMatrix[i]?(i==0?1:(i==1?2:(i==2?4:(i==3?8:(i==4?16:(i==5?32:(i==6?64:128))))))):0);
	return idBuilder>255||idBuilder<0?textures[0]:textures[textureRefByID[idBuilder]];

}


}

Link to comment
Share on other sites

  • 2 weeks later...

It seems that textures are getting flipped (or not getting flipped) like they did in previous versions.

 

Either way, I solved it by creating a custom block renderer and drawing the faces individually and then flipping the textures for the north and east faces.

 

here is a bit of the code I used:

       @Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,Block block, int modelId, RenderBlocks renderer) {
                        block.setBlockBounds(0, 0, 0, 1, 1, 1);
		renderer.setRenderBoundsFromBlock(block);

		for (int d = 0; d<6;d++) {
			ForgeDirection dir1 = ForgeDirection.getOrientation(d);
			if (block.shouldSideBeRendered(world, x, y, z, dir1.getOpposite().ordinal())) {
				if (dir1==ForgeDirection.NORTH || dir1==ForgeDirection.EAST) {
					renderer.flipTexture=true;
				}
				switch(d) {
				case 0:renderer.renderFaceYNeg(block, x, y, z, block.getIcon(world, x, y, z, d));break;
				case 1:renderer.renderFaceYPos(block, x, y, z, block.getIcon(world, x, y, z, d));break;
				case 2:renderer.renderFaceZNeg(block, x, y, z, block.getIcon(world, x, y, z, d));break;
				case 3:renderer.renderFaceZPos(block, x, y, z, block.getIcon(world, x, y, z, d));break;
				case 4:renderer.renderFaceXNeg(block, x, y, z, block.getIcon(world, x, y, z, d));break;
				case 5:renderer.renderFaceXPos(block, x, y, z, block.getIcon(world, x, y, z, d));break;
				}
				renderer.flipTexture=false;
			}
		}

	     renderer.clearOverrideBlockTexture();
                     block.setBlockBounds(0f, 0f, 0f, 1f, 1f, 1f);
                     renderer.setRenderBoundsFromBlock(block);
}

47MdL.png

Link to comment
Share on other sites

  • 1 month later...

Sorry to bump this thread, but i have the same problem. I know why it is, but i don't know how to fix it. The reason they are getting flipped, is because there was a bug in minecraft a long time, and the modders had worked around that bug, but now that the bug is fixed, you need to remove the work-around, but i don't know how to do that.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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



×
×
  • Create New...

Important Information

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