Jump to content

[1.7] Glitchy connected textures.


CJCutrone9

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

    • im stuck in a problem whit BlockEntities i cannot solve so im trying to work around it but in the less complex way possible  i think is posible to store data to the minecraft world  in older versions people talk about  WordDataSave i dont find anything about it for 1.20.4  i find a tutorial for player capability in 1.19    here is an event      //########## ########## ########## ##########     @SubscribeEvent     public static void onAttachCapabilitiesPlayer(AttachCapabilitiesEvent<Entity> event) {         if(event.getObject() instanceof Player) {             if(!event.getObject().getCapability(PlayerThirstProvider.PLAYER_THIRST).isPresent()) {                 event.addCapability(new ResourceLocation(mercmod.MOD_ID, "properties"), new PlayerThirstProvider());             }         }     }  soo i made this      //########## ########## ########## ##########     @SubscribeEvent     public static void onAttachCapabilitiesLevel(AttachCapabilitiesEvent<Level> event) {     } i think i can do some witchcraft  here  but is many things don't understand  to start whit i dont get yet how to recall the saved data from a BlockEntity  the handler still in progress the plan is to make a Map to store nbt data using the block coordinates as index later store that map as a big nbt      ########## any way the question is if theres alredy a tutorial for 1.20.4 for this ?? or some alredy working code from someone else doing something similar ?           
    • I tried this, and found out that Oculus is the mod that is crashing the game. I have removed it, and it now works fine! Thanks!
    • Hi @DanielderErbauer, I arrived here as I have the "as it does not exist in Block{minecraft:air}" error in a modpack I am trying to start. It's a long-shot, I know, but as the post that led this to being solved is missing, can I ask if you may recall what it said? Thanks in advance
    • Hm yeah sorry, not seeing anything else that's sticking out, I'd need to debug myself probably. Do you have a github or bitbucket repo? I could poke around when I have time to see what the problem might be.
    • looking around for the capabilities thing i found a piece of code and find this piece of code  //########## ########## ########## ########## @SubscribeEvent public static void addCustomTrades(VillagerTradesEvent event) { if(event.getType() == VillagerProfession.FLETCHER) { System.out.println("\n\n### VillagerProfession.FLETCHER \n\n");//<----------- Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades(); ItemStack stack = new ItemStack(ItemInit.ARROW_STEEL.get(), 16); int villagerLevel = 1; trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( new ItemStack(Items.EMERALD, 2), stack,1,3,0.02F)); } if(event.getType() == VillagerProfession.TOOLSMITH) { System.out.println("\n\n### VillagerProfession.TOOLSMITH \n\n");//<----------- Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades(); ItemStack stack = new ItemStack(ItemInit.INGOT_STEEL.get(), 1); int villagerLevel = 1; trades.get(villagerLevel).add((trader, rand) -> new MerchantOffer( new ItemStack(Items.EMERALD, 2), stack,10,8,0.02F)); } } //########## ########## ########## ########## the event is aknoledge and execute when the maps load  ### VillagerProfession.FLETCHER  ### VillagerProfession.TOOLSMITH  //########## But is not working      is a random piece of code is not working  could it be than this code is old 1.18 and no valid anymore for 1.20.4 or the thing are this numbers  stack,10,8,0.02F));  i dont know what this numbers means    ########## the question is ¿how to add things to the villager traders    thanks for your attention               
  • Topics

×
×
  • Create New...

Important Information

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