Jump to content

Multiple textures for blocks (top, side, bottom etc.)


teunie75
 Share

Recommended Posts

(I've read the post on the forums about textures)

But I still don't know how I can set textures for multiple sides, I already followed a tutorial on it.

That was using Deprecated code.

 

I want my block to have 4 different textures

Normal front

Activated (front)

Side(s)

Top and bottom

 

public class Furnace extends Block

{

private Icon top;

 

private Icon bottom;

 

private Icon side;

 

private Icon front;

 

private Icon burnFront;

 

 

public Furnace (int id) {

super(id, Material.iron);

 

}

 

 

}

 

Link to comment
Share on other sites

The pumpkin could have helped you.

 

Anyways, there is a method you can override. It's called Block.getIcon(int side, int meta); and takes the side for which to retrieve the texture and the metadata of the block in case you need it as parameters.

 

Example:

public Icon getIcon( int side, int meta ) {
    ForgeDirection dir = ForgeDirection.getOrientation(side);
    if( dir == ForgeDirection.UP ) {
        return meta == 0 ? iconTopUnpowered : iconTopPowered;
    }
    else if( dir == ForgeDirection.DOWN ) {
        return iconBottom;
    }
    else {
        return iconSide;
    }
}

Link to comment
Share on other sites

How can I use to front, because the things you've done can only use the sides and bottom and top. (That is working)

But how can I use the front (the side the player places it), as a seperate texture?

And how can I use the activation and change the texture.

Link to comment
Share on other sites

Whoa! this guy want's to get real crazy with his textures ;)

 

how about a furnace:

    public Icon getIcon(int par1, int par2)
    {
        return par1 == 1 ? this.furnaceIconTop : (par1 == 0 ? this.furnaceIconTop : (par1 != par2 ? this.blockIcon : this.furnaceIconFront));
    }

the metadata on the furnace is its rotation

Link to comment
Share on other sites

I still don't get it.

This is what I have right now

public Icon getIcon(int side, int meta) {

    ForgeDirection dir = ForgeDirection.getOrientation(side);

    if( dir == ForgeDirection.UP ) {

    return this.top;

    }

    else if( dir == ForgeDirection.DOWN ) {

        return this.bottom;

    }

    else {

    if (Need to check if this other side is turned towards the player){

    return front;

    }else{

    return this.side;

    }

    }

}

Link to comment
Share on other sites

    	if (Need to check if this other side is turned towards the player){
    	return front;
    	}else{
    		return this.side;
    	}

 

That would be using the metadata.

 

if(side == meta) {return front }

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

using the furnace code, setting the front the default direction seems to work

 

 

 

private void setDefaultDirection(World par1World, int par2, int par3, int par4)
{
    if (!par1World.isRemote)
    {
        int l = par1World.getBlockId(par2, par3, par4 - 1);
        int i1 = par1World.getBlockId(par2, par3, par4 + 1);
        int j1 = par1World.getBlockId(par2 - 1, par3, par4);
        int k1 = par1World.getBlockId(par2 + 1, par3, par4);
        byte b0 = 3;

        if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1])
        {
            b0 = 3;
        }

        if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l])
        {
            b0 = 2;
        }

        if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1])
        {
            b0 = 5;
        }

        if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1])
        {
            b0 = 4;
        }

        par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2);
    }
}

@SideOnly(Side.CLIENT)

/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
public Icon getIcon(int par1, int par2)
{
    return par1 == 1 ? this.GUIBlockTop : (par1 == 0 ? this.GUIBlockTop : (par1 != par2 ? this.blockIcon : this.GUIBlockFront));
}

 

 

Link to comment
Share on other sites

Ok, it works with the setDefaultDirection method.

This is the class now:

 

 

 

public class Furnace extends Block

{

@SideOnly(Side.CLIENT)

private Icon top;

 

@SideOnly(Side.CLIENT)

private Icon bottom;

 

@SideOnly(Side.CLIENT)

private Icon side;

 

@SideOnly(Side.CLIENT)

private Icon front;

 

public Furnace (int id) {

super(id, Material.iron);

 

}

 

public Icon getIcon(int side, int meta) {

    ForgeDirection dir = ForgeDirection.getOrientation(side);

    if( dir == ForgeDirection.UP ) {

    return this.top;

    }

    else if( dir == ForgeDirection.DOWN ) {

        return this.bottom;

    }

    else {

    if (side == meta){

    return front;

    }else{

    return this.side;

    }

    }

}

 

@Override

public void registerIcons(IconRegister ir){

this.side = ir.registerIcon("Furnace_side");

this.bottom = ir.registerIcon("Furnace_top");

this.top = ir.registerIcon("Furnace_top");

this.front = ir.registerIcon("Furnace_front");

}

 

private void setDefaultDirection(World par1World, int par2, int par3, int par4)

{

    if (!par1World.isRemote)

    {

        int l = par1World.getBlockId(par2, par3, par4 - 1);

        int i1 = par1World.getBlockId(par2, par3, par4 + 1);

        int j1 = par1World.getBlockId(par2 - 1, par3, par4);

        int k1 = par1World.getBlockId(par2 + 1, par3, par4);

        byte b0 = 3;

 

        if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1])

        {

            b0 = 3;

        }

 

        if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l])

        {

            b0 = 2;

        }

 

        if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1])

        {

            b0 = 5;

        }

 

        if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1])

        {

            b0 = 4;

        }

 

        par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2);

       

    }

}

 

public void onBlockAdded(World par1World, int par2, int par3, int par4)

    {

        super.onBlockAdded(par1World, par2, par3, par4);

        this.setDefaultDirection(par1World, par2, par3, par4);

    }

}

 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello! I downloaded the MrCrayfishs Furniture mod for 1.19.3. I also have 1.19.3 for forge and optifine. It's the only mod in my mods folder. It would be nice if anyone could help me. xx This is the crash report: ---- Minecraft Crash Report ---- // My bad. Time: 2023-01-30 13:17:38 Description: Mod loading error has occurred java.lang.Exception: Mod Loading has failed     at net.minecraftforge.logging.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:55) ~[forge-1.19.3-44.1.0-universal.jar%23155!/:?] {re:classloading}     at net.minecraftforge.client.loading.ClientModLoader.completeModLoading(ClientModLoader.java:167) ~[forge-1.19.3-44.1.0-universal.jar%23155!/:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:588) ~[client-1.19.3-20221207.122022-srg.jar%23150!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.Util.m_137521_(Util.java:432) ~[client-1.19.3-20221207.122022-srg.jar%23150!/:?] {re:classloading}     at net.minecraft.client.Minecraft.lambda$new$3(Minecraft.java:582) ~[client-1.19.3-20221207.122022-srg.jar%23150!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.gui.screens.LoadingOverlay.m_86412_(LoadingOverlay.java:137) ~[client-1.19.3-20221207.122022-srg.jar%23150!/:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.renderer.GameRenderer.m_109093_(GameRenderer.java:920) ~[client-1.19.3-20221207.122022-srg.jar%23150!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1135) ~[client-1.19.3-20221207.122022-srg.jar%23150!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.m_91374_(Minecraft.java:713) ~[client-1.19.3-20221207.122022-srg.jar%23150!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.m_239872_(Main.java:212) ~[1.19.3-forge-44.1.0.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:51) ~[1.19.3-forge-44.1.0.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}     at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}     at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}     at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}     at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:27) ~[fmlloader-1.19.3-44.1.0.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.8.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.8.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.8.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) ~[modlauncher-10.0.8.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) ~[modlauncher-10.0.8.jar:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.8.jar:?] {}     at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.8.jar:?] {}     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:141) ~[securejarhandler-2.1.4.jar:?] {} -- MOD cfm -- Details:     Caused by 0: java.lang.NoClassDefFoundError: net/minecraft/data/tags/BlockTagsProvider         at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:?] {}         at java.lang.Class.privateGetDeclaredConstructors(Class.java:3373) ~[?:?] {}         at java.lang.Class.getConstructor0(Class.java:3578) ~[?:?] {}         at java.lang.Class.getDeclaredConstructor(Class.java:2754) ~[?:?] {}         at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:68) ~[javafmllanguage-1.19.3-44.1.0.jar%23152!/:?] {}         at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$10(ModContainer.java:121) ~[fmlcore-1.19.3-44.1.0.jar%23151!/:?] {}         at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?] {}         at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[?:?] {}         at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?] {}         at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?] {}         at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?] {}         at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?] {}         at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?] {}     Mod File: /C:/Users/User/AppData/Roaming/.minecraft/mods/MrCrayfishs-Furniture-Mod-Forge-1.19.3.jar     Failure message: MrCrayfish's Furniture Mod (cfm) has failed to load correctly         java.lang.NoClassDefFoundError: net/minecraft/data/tags/BlockTagsProvider     Mod Version: 7.0.0-pre34     Mod Issue URL: https://github.com/MrCrayfish/MrCrayfishFurnitureMod/issues     Exception message: java.lang.ClassNotFoundException: net.minecraft.data.tags.BlockTagsProvider Stacktrace:     at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:141) ~[securejarhandler-2.1.4.jar:?] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?] {}     at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:?] {}     at java.lang.Class.privateGetDeclaredConstructors(Class.java:3373) ~[?:?] {}     at java.lang.Class.getConstructor0(Class.java:3578) ~[?:?] {}     at java.lang.Class.getDeclaredConstructor(Class.java:2754) ~[?:?] {}     at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:68) ~[javafmllanguage-1.19.3-44.1.0.jar%23152!/:?] {}     at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$10(ModContainer.java:121) ~[fmlcore-1.19.3-44.1.0.jar%23151!/:?] {}     at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?] {}     at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[?:?] {}     at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?] {}     at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?] {}     at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?] {}     at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?] {}     at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?] {} -- System Details -- Details:     Minecraft Version: 1.19.3     Minecraft Version ID: 1.19.3     Operating System: Windows 10 (amd64) version 10.0     Java Version: 17.0.3, Microsoft     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft     Memory: 241410776 bytes (230 MiB) / 503316480 bytes (480 MiB) up to 2147483648 bytes (2048 MiB)     CPUs: 4     Processor Vendor: AuthenticAMD     Processor Name: AMD FX-8800P Radeon R7, 12 Compute Cores 4C+8G      Identifier: AuthenticAMD Family 21 Model 96 Stepping 1     Microarchitecture: unknown     Frequency (GHz): 2.10     Number of physical packages: 1     Number of physical CPUs: 4     Number of logical CPUs: 4     Graphics card #0 name: AMD Radeon R7 Graphics     Graphics card #0 vendor: Advanced Micro Devices, Inc. (0x1002)     Graphics card #0 VRAM (MB): 256.00     Graphics card #0 deviceId: 0x9874     Graphics card #0 versionInfo: DriverVersion=27.20.1034.6     Memory slot #0 capacity (MB): 8192.00     Memory slot #0 clockSpeed (GHz): 2.13     Memory slot #0 type: DDR4     Memory slot #1 capacity (MB): 8192.00     Memory slot #1 clockSpeed (GHz): 2.13     Memory slot #1 type: DDR4     Virtual memory max (MB): 18519.90     Virtual memory used (MB): 7647.12     Swap memory total (MB): 2432.00     Swap memory used (MB): 35.46     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     ModLauncher: 10.0.8+10.0.8+main.0ef7e830     ModLauncher launch target: forgeclient     ModLauncher naming: srg     ModLauncher services:          mixin-0.8.5.jar mixin PLUGINSERVICE          eventbus-6.0.3.jar eventbus PLUGINSERVICE          fmlloader-1.19.3-44.1.0.jar slf4jfixer PLUGINSERVICE          fmlloader-1.19.3-44.1.0.jar object_holder_definalize PLUGINSERVICE          fmlloader-1.19.3-44.1.0.jar runtime_enum_extender PLUGINSERVICE          fmlloader-1.19.3-44.1.0.jar capability_token_subclass PLUGINSERVICE          accesstransformers-8.0.4.jar accesstransformer PLUGINSERVICE          fmlloader-1.19.3-44.1.0.jar runtimedistcleaner PLUGINSERVICE          modlauncher-10.0.8.jar mixin TRANSFORMATIONSERVICE          modlauncher-10.0.8.jar fml TRANSFORMATIONSERVICE      FML Language Providers:          minecraft@1.0         lowcodefml@null         javafml@null     Mod List:          client-1.19.3-20221207.122022-srg.jar             |Minecraft                     |minecraft                     |1.19.3              |COMMON_SET|Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f         forge-1.19.3-44.1.0-universal.jar                 |Forge                         |forge                         |44.1.0              |COMMON_SET|Manifest: 84:ce:76:e8:45:35:e4:0e:63:86:df:47:59:80:0f:67:6c:c1:5f:6e:5f:4d:b3:54:47:1a:9f:7f:ed:5e:f2:90         MrCrayfishs-Furniture-Mod-Forge-1.19.3.jar        |MrCrayfish's Furniture Mod    |cfm                           |7.0.0-pre34         |ERROR     |Manifest: NOSIGNATURE     Crash Report UUID: d668c79d-366a-4acb-9754-f4cd52ab88cb     FML: 44.1     Forge: net.minecraftforge:44.1.0
    • thanks for your help. I found that issue: https://github.com/MinecraftForge/MinecraftForge/issues/8498
    • i'm trying to have my friend join my modded server. I gave them all the mods i have installed and the 'mixmatched mod list' keeps poping up.
  • Topics

×
×
  • Create New...

Important Information

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