Jump to content

[1.7.10] [Solved] Connected textures not working


Silly511

Recommended Posts

I've followed a tutorial on connected textures, but for some reason my block always has a missing texture. Here's my code:

 

ConnectedTextures Class:

package net.sparklepopprograms.core.render;

import java.io.Serializable;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;

public class ConnectedTextures extends Block {

public static IIcon[] textures = new IIcon[47];
public static 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};

protected ConnectedTextures(Material mat) {
	super(mat);
}

@Override
@SideOnly(Side.CLIENT)
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).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[1] = world.getBlock(x, y, z-1).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[2] = world.getBlock(x+1, y, z-1).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[3] = world.getBlock(x-1, y, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[4] = world.getBlock(x+1, y, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[5] = world.getBlock(x-1, y, z+1).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[6] = world.getBlock(x, y, z+1).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[7] = world.getBlock(x+1, y, z+1).getUnlocalizedName() == this.getUnlocalizedName();
	 }

	 if (side == 2 || side == 3) {
		 bitMatrix[0] = world.getBlock(x+(side==2?1:-1), y+1, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[1] = world.getBlock(x, y+1, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[2] = world.getBlock(x+(side==3?1:-1), y+1, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[3] = world.getBlock(x+(side==2?1:-1), y, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[4] = world.getBlock(x+(side==3?1:-1), y, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[5] = world.getBlock(x+(side==2?1:-1), y-1, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[6] = world.getBlock(x, y-1, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[7] = world.getBlock(x+(side==3?1:-1), y-1, z).getUnlocalizedName() == this.getUnlocalizedName();
	 }

	 if (side == 4 || side == 5) {
		 bitMatrix[0] = world.getBlock(x, y+1, z+(side==5?1:-1)).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[1] = world.getBlock(x, y+1, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[2] = world.getBlock(x, y+1, z+(side==4?1:-1)).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[3] = world.getBlock(x, y, z+(side==5?1:-1)).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[4] = world.getBlock(x, y, z+(side==4?1:-1)).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[5] = world.getBlock(x, y-1, z+(side==5?1:-1)).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[6] = world.getBlock(x, y-1, z).getUnlocalizedName() == this.getUnlocalizedName();
		 bitMatrix[7] = world.getBlock(x, y-1, z+(side==4?1:-1)).getUnlocalizedName() == this.getUnlocalizedName();
	 }

	 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]];
}

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

}

 

Block Class:

package net.sparklepopprograms.enchantedaura.blocks;

import net.minecraft.block.material.Material;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.sparklepopprograms.core.render.ConnectedTextures;
import net.sparklepopprograms.enchantedaura.EnchantedAura;
import net.sparklepopprograms.enchantedaura.EnchantedAuraBlocks;

public class SoildLight extends ConnectedTextures {

public SoildLight() {
	super(Material.glass);
	this.setBlockName("SoildLight");
	this.setBlockTextureName(EnchantedAura.modid + ":SoildLight");
	this.setCreativeTab(EnchantedAura.tab);
}

}

 

And here's the tutorial: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571290-forge-domis-advanced-modding-tutorials-taking What am I doing wrong?

Link to comment
Share on other sites

.getUnlocalizedName() == this.getUnlocalizedName();

 

Hesus Christie!

 

You have no idea what you're doing, do you.

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.

Link to comment
Share on other sites

.getUnlocalizedName() == this.getUnlocalizedName();

 

Hesus Christie!

 

You have no idea what you're doing, do you.

 

No, probably not. I just thought that if the unlocalized name of a block was the same as another block, then that means their both the same block. What should I do instead of that?

Link to comment
Share on other sites

if(block == otherBlock) ..?

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.

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



×
×
  • Create New...

Important Information

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