Jump to content

Recommended Posts

Posted

PASTEBIN OF CODE

 

I am trying to make a block with connected textures for its top and bottom faces, and I've got it working except for the orientation of the textures. Using metadata, I can get the right type of texture, but not the right orientation of it. There are too many textures for metadata to handle (using separate textures for each orientation), and this cannot be a tile entity, as it is a decorative block.

 

Can I set something other than metadata, without making the block a tile entity, to get the right orientation of the texture? I tried using an instance variable, but of course that doesn't set per instance; every instance of the block changes when one does. I am starting to think what I want is not possible, only I know that others have done connected textures for decorative blocks, like glass.

 

Quite possibly, there's an obvious, better way to do this. I am still learning Java, so I apologize if I seem obtuse. Certainly this code is not elegant or pretty. Many thanks for any help or advice!

Posted

Could anyone point me to an example of connected textures code?

 

Or, alternately, help me to understand this code:

 

  On 7/16/2013 at 6:18 PM, f1rSt1k25 said:

  Quote

Im trying to make this glass block(That im going to make later today, also dont know how to make blocks transparent(yes I need a lot of help on stuff)) have connected texture but I cant find any tutorials that I could follow(yes im a noob, but I like to do things my way, not the professional way, yet) And I also need to update to 1.6 but I dont know how. I read somewhere that you need to make sure you backed up your code, then delete it all and do it again but with the current versions but I dont know. Any help would be greatly appreciated!

 

package f1rSt1k.blocks;

import java.util.List;
import java.util.Random;

import f1rSt1k.Main;

import net.minecraft.block.Block;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;

public class BlockDecorativeGlass extends BlockGlass 
{

public static boolean connectedTexture = true;

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

public BlockDecorativeGlass()
{
         super(502, Material.glass, false);
         setHardness(0.6F);
         setResistance(2.0F);
         setCreativeTab(Main.f1rSt1kCraftCreativeTab);
         setStepSound(soundGlassFootstep);
}

public int idDropped(int par1, Random par2Random, int par3)
{
    return Item.stick.itemID;
}

public int quantityDropped(Random par1Random)
{
    return 1 + par1Random.nextInt(4);
}



public void registerIcons(IconRegister iconRegistry)
{
         for (int i = 0; i < 47; i++) textures[i] = iconRegistry.registerIcon("f1rst1kcraft:woodGlass_" + (i+1));
}

public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
{
    
	if(connectedTexture){

	boolean[] bitMatrix = new boolean[8];
        
         if (side == 0 || side == 1)
         {
                 bitMatrix[0] = world.getBlockId(x-1, y, z-1) == this.blockID;
                 bitMatrix[1] = world.getBlockId(x, y, z-1) == this.blockID;
                 bitMatrix[2] = world.getBlockId(x+1, y, z-1) == this.blockID;
                 bitMatrix[3] = world.getBlockId(x-1, y, z) == this.blockID;
                 bitMatrix[4] = world.getBlockId(x+1, y, z) == this.blockID;
                 bitMatrix[5] = world.getBlockId(x-1, y, z+1) == this.blockID;
                 bitMatrix[6] = world.getBlockId(x, y, z+1) == this.blockID;
                 bitMatrix[7] = world.getBlockId(x+1, y, z+1) == this.blockID;
         }
         if (side == 2 || side == 3)
         {
                 bitMatrix[0] = world.getBlockId(x+(side==2?1:-1), y+1, z) == this.blockID;
                 bitMatrix[1] = world.getBlockId(x, y+1, z)                      == this.blockID;
                 bitMatrix[2] = world.getBlockId(x+(side==3?1:-1), y+1, z) == this.blockID;
                 bitMatrix[3] = world.getBlockId(x+(side==2?1:-1), y, z) == this.blockID;
                 bitMatrix[4] = world.getBlockId(x+(side==3?1:-1), y, z) == this.blockID;
                 bitMatrix[5] = world.getBlockId(x+(side==2?1:-1), y-1, z) == this.blockID;
                 bitMatrix[6] = world.getBlockId(x, y-1, z)                      == this.blockID;
                 bitMatrix[7] = world.getBlockId(x+(side==3?1:-1), y-1, z) == this.blockID;
         }
         if (side == 4 || side == 5)
         {
                 bitMatrix[0] = world.getBlockId(x, y+1, z+(side==5?1:-1)) == this.blockID;
                 bitMatrix[1] = world.getBlockId(x, y+1, z)                      == this.blockID;
                 bitMatrix[2] = world.getBlockId(x, y+1, z+(side==4?1:-1)) == this.blockID;
                 bitMatrix[3] = world.getBlockId(x, y, z+(side==5?1:-1)) == this.blockID;
                 bitMatrix[4] = world.getBlockId(x, y, z+(side==4?1:-1)) == this.blockID;
                 bitMatrix[5] = world.getBlockId(x, y-1, z+(side==5?1:-1)) == this.blockID;
                 bitMatrix[6] = world.getBlockId(x, y-1, z)                      == this.blockID;
                 bitMatrix[7] = world.getBlockId(x, y-1, z+(side==4?1:-1)) == this.blockID;
         }
        
         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]];
         
	}
	return textures[0];
}

public Icon getIcon(int side, int meta)
{
         return textures[0];
}
}

 

It just occurred to me: the GetBlockTexture lets you get the surrounding block IDs -- I'm going to see whether I can do it there, without metadata.

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

    • wait, i just did that. why didn't it work? also it's the same. help me!!!!
    • Culprit has been located! It was Tough As Nails + (plus) which was among one of the mods *added* before re-entering, in an attempt to improve compatibility. It, for some reason or another, did not want to work!
    • "You can either try to load it with only the vanilla data pack ("safe mode"), or go back to the title screen and fix it manually." Hello! I encountered this error just now while attempting to re-enter my world for the first time. Notably, no mods were removed before encountering this error and, while being able to find this error elsewhere on the internet, in my scenario it is seemingly caused by a specific mod, of which I cannot isolate. Things I have tried: - Enter "Safe Mode" (fails) - Remove datapacks (no change) - Reverted to old save data (no change) Here is the server log: https://mclo.gs/9vJQEfN I use Modrinth mod loader so please let me know how to share my mod list, and if it is needed.
    • So, i'm hosting (or attempting to host) a port-forwarded modded server for 1.12.2. There's quite a few mods in this pack, but they all run and have no compatibility issues (besides something causing the game to crash if you go fullscreen, a problem ive given up trying to identify or fix). It can run on 6gb of ram or less, and works fine in singleplayer. All of my friends that want to join have the exact same mod/config/game setup as I do (I personally helped them set everything up). Just to be safe, we've all allocated 12 gigabytes of RAM to the installation, and I've also allocated 12GB to the server itself. I am able to join with no issue and it runs fine. However, when they try to join, it gets stuck in the 'logging in' screen before their game becomes unresponsive. When they close it, it gives them the exit code 805306369, which usually means not enough RAM, but this cant be the case. On my screen, in the server, it shows them joining, and then disconnecting, so I dont think its a port-forwarding issue. They can all run it just fine in singleplayer as well. The annoying bit about this particular issue is that it generates no crash log. Does anyone have any suggestions? Thanks! Here is my debug log, and his, starting from the same place. MINE: [132647] [Netty Client IO #5INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132653.817 [132653] [Client threadINFO] [minecraftGuiConnecting] Connecting to 0, 25565 132654.682 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.common.core.transformer.ClassNodeTransformertransform29] Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 132654.684 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.map.core.transformer.ClassNodeTransformertransform29] Transforming class net.minecraft.client.network.NetHandlerPlayClient 132654.764 [132654] [Netty Client IO #9INFO] [FML] Server protocol version 2 132654.777 [132654] [Netty Client IO #9INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132656.193 [132656] [Client threadINFO] [FML] Injecting existing registry data into this client instance 132659.081 [132659] [Client threadINFO] [FML] Applying holder lookups 132659.082 [132659] [Client threadINFO] [FML] Holder lookups applied 132659.092 [132659] [Netty Client IO #9INFO] [FML] [Netty Client IO #9] Client side modded connection established HIS: [13:12:16] [Netty Client IO #0/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:25.597 [13:12:25] [Client thread/INFO] [minecraft/GuiConnecting]: Connecting to (my IP address and the server port 25565) 13:12:26.805 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.common.core.transformer.ClassNodeTransformer:transform:29]: Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 13:12:26.808 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.map.core.transformer.ClassNodeTransformer:transform:29]: Transforming class net.minecraft.client.network.NetHandlerPlayClient 13:12:26.936 [13:12:26] [Netty Client IO #1/INFO] [FML]: Server protocol version 2 13:12:27.114 [13:12:27] [Netty Client IO #1/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:27.480 [13:12:27] [Client thread/INFO] [FML]: Injecting existing registry data into this client instance 13:12:30.669 [13:12:30] [Client thread/INFO] [FML]: Applying holder lookups 13:12:30.671 [13:12:30] [Client thread/INFO] [FML]: Holder lookups applied 13:13:04.700 Process crashed with exit code -805306369 P.S - Both mods "CTM" and "FUSION" are present in both our folders so idk what that's about.
    • Please read the FAQ (link is orange banner at top of page), and post logs as described there, to an external site such as https://mclo.gs  
  • Topics

×
×
  • Create New...

Important Information

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