Jump to content

Recommended Posts

Posted (edited)

Hi there,

 

   My goal is to have this block look kind of like a lone fence post (minus attaching to adjacent blocks) where the object is cutout and the surfaces of the blocks around it are rendered.  I've tried duplicating a fence post but that became overly complicated and I got a bit lost.  Sadly this is what my block is doing so far (see attached).

 

   Using Eclipse and modding MC 1.12.2.  Here's my block class and definition:

package com.testmod.mod.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockRenderLayer;

public class BlockBasic extends Block {
	public BlockBasic(String name, Material material) {
		super(material);
		setUnlocalizedName(name);
		setRegistryName(name);
	}
	
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.TRANSLUCENT;
    }

    public boolean isFullCube(IBlockState state)
    {
        return false;
    }
    
    public boolean isOpaqueCube() {
    	return false;
    }
    
    public boolean isVisuallyOpaque() {
    	return false;
    }
}

 

package com.testmod.mod.init;

import com.testmod.mod.Reference;
import com.testmod.mod.blocks.BlockBasic;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod.EventBusSubscriber(modid=Reference.MODID)
public class ModBlocks {
	static Block firstBlock;
	static Block fenceDupe;
	
    public static void init() {
    	firstBlock = new BlockBasic("firstBlock", Material.WOOD);
	}
    
    public boolean isOpaqueCube(IBlockState state)
    {
        return false;
    }

    public boolean isFullCube(IBlockState state)
    {
        return false;
    }
	
	@SubscribeEvent
	public static void registerBlocks(RegistryEvent.Register<Block> event) {
		event.getRegistry().registerAll(firstBlock);
	}
	
	@SubscribeEvent
	public static void registerItemBlocks(RegistryEvent.Register<Item> event) {
		event.getRegistry().registerAll(new ItemBlock(firstBlock).setRegistryName(firstBlock.getRegistryName()));
	}
	
	@SubscribeEvent
	public static void registerRenders(ModelRegistryEvent event) {
		registerRender(Item.getItemFromBlock(firstBlock));
	}
	
	public static void registerRender(Item item) {
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation( item.getRegistryName(), "inventory"));
	}
}

 

I've added what I *think should be working, but no joy.  Anyone point me in the right direction?  BTW; new to Minecraft modding so forgive me if I've missed something obvious.

 

Thanks!

2019-01-09_18.53.00.png

Edited by Niroque
Posted

Ah I had forgotten to add that back in.  I tried many variants as I went down the code rabbit hole.  It still shows the same though. :/

Posted

I already have this to override, is there another way to override them that's more reliable?

 

    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.TRANSLUCENT;
    }
    
    public boolean isNormalCube(IBlockState state)
    {
        return false;
    }

    public boolean isFullCube(IBlockState state)
    {
        return false;
    }
    
    public boolean isOpaqueCube(IBlockState state) {
    	return false;
    }
    
    public boolean isVisuallyOpaque() {
    	return false;
    }

 

Posted (edited)

No, those overrides should be sufficient.  What does your model JSON look like?

 

Also, you should be using CUTOUT_MIPPED for your block render layer (getBlockLayer()). TRANSLUCENT is for blocks like glass or ice.

Edited by desht
  • Like 1
Posted

Here's my firstblock.json:
 

{
    "__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)",
    "textures": {
        "0": "tm:blocks/firstblock",
        "1": "tm:blocks/firstblock"
    },
    "display": {
        "head": {
            "rotation": [ 0, 180, 0 ],
            "translation": [ 0, 0, 0 ],
            "scale": [ 1, 1, 1 ]
        },
        "firstperson_righthand": {
            "rotation": [ 0, 315, 0 ],
            "translation": [ 0, 2.5, 0 ],
            "scale": [ 0.4, 0.4, 0.4 ]
        },
        "thirdperson_lefthand": {
            "rotation": [ 75, 45, 0 ],
            "translation": [ 0, 2.5, 0 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        },
        "firstperson_lefthand": {
            "rotation": [ 0, 0, 45 ],
            "translation": [ 0, 2.5, 0 ],
            "scale": [ 0.4, 0.4, 0.4 ]
        },
        "gui": {
            "rotation": [ 30, 45, 0 ],
            "translation": [ 0, 0, 0 ],
            "scale": [ 0.625, 0.625, 0.625 ]
        },
        "ground": {
            "rotation": [ 0, 0, 0 ],
            "translation": [ 0, 3, 0 ],
            "scale": [ 0.25, 0.25, 0.25 ]
        },
        "fixed": {
            "rotation": [ 0, 180, 0 ],
            "translation": [ 0, 0, 0 ],
            "scale": [ 1, 1, 1 ]
        },
        "thirdperson_righthand": {
            "rotation": [ 75, 315, 0 ],
            "translation": [ 0, 2.5, 0 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    },
    "elements": [
        {
            "name": "Cube",
            "from": [ 2, 1, 4 ], 
            "to": [ 4, 10, 6 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0, 0, 2, 9 ] },
                "east": { "texture": "#0", "uv": [ 0, 0, 2, 9 ] },
                "south": { "texture": "#0", "uv": [ 0, 0, 2, 9 ] },
                "west": { "texture": "#0", "uv": [ 0, 0, 2, 9 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 11, 1, 4 ], 
            "to": [ 13, 10, 6 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 1, 7, 3, 16 ] },
                "east": { "texture": "#0", "uv": [ 9, 7, 11, 16 ] },
                "south": { "texture": "#0", "uv": [ 5, 0, 7, 9 ] },
                "west": { "texture": "#0", "uv": [ 0, 7, 2, 16 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 11, 1, 14 ], 
            "to": [ 13, 10, 16 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 8, 5, 10, 14 ] },
                "east": { "texture": "#0", "uv": [ 0, 3, 2, 12 ] },
                "south": { "texture": "#0", "uv": [ 4, 4, 6, 13 ] },
                "west": { "texture": "#0", "uv": [ 13, 0, 15, 9 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 2, 1, 14 ], 
            "to": [ 4, 10, 16 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 4, 7, 6, 16 ] },
                "east": { "texture": "#0", "uv": [ 13, 3, 15, 12 ] },
                "south": { "texture": "#0", "uv": [ 8, 5, 10, 14 ] },
                "west": { "texture": "#0", "uv": [ 9, 0, 11, 9 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 2, 9, 4 ], 
            "to": [ 13, 10, 16 ], 
            "faces": {
                "north": { "texture": "#1", "uv": [ 0, 0, 11, 1 ] },
                "east": { "texture": "#1", "uv": [ 0, 0, 12, 1 ] },
                "south": { "texture": "#1", "uv": [ 0, 0, 11, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 12, 1 ] },
                "up": { "texture": "#1", "uv": [ 0, 0, 11, 12 ] },
                "down": { "texture": "#1", "uv": [ 0, 0, 11, 12 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 2, 9, 5 ], 
            "to": [ 4, 21, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 1, 0, 3, 12 ] },
                "east": { "texture": "#0", "uv": [ 0, 4, 2, 16 ] },
                "south": { "texture": "#0", "uv": [ 9, 4, 11, 16 ] },
                "west": { "texture": "#0", "uv": [ 5, 4, 7, 16 ] },
                "up": { "texture": "#0", "uv": [ 1, 2, 3, 4 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 11, 9, 5 ], 
            "to": [ 13, 21, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 0, 0, 2, 12 ] },
                "east": { "texture": "#0", "uv": [ 5, 4, 7, 16 ] },
                "south": { "texture": "#0", "uv": [ 0, 0, 2, 12 ] },
                "west": { "texture": "#0", "uv": [ 0, 0, 2, 12 ] },
                "up": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 2, 2 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 4, 12, 6 ], 
            "to": [ 11, 13, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "east": { "texture": "#1", "uv": [ 0, 0, 1, 1 ] },
                "south": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 1, 1 ] },
                "up": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "down": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 4, 20, 6 ], 
            "to": [ 11, 21, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 8.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "east": { "texture": "#1", "uv": [ 0, 0, 1, 1 ] },
                "south": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 1, 1 ] },
                "up": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] },
                "down": { "texture": "#1", "uv": [ 0, 0, 7, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 9, 11, 6 ], 
            "to": [ 10, 20, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 10, 7, 11, 16 ] },
                "east": { "texture": "#0", "uv": [ 5, 4, 6, 13 ] },
                "south": { "texture": "#0", "uv": [ 14, 4, 15, 13 ] },
                "west": { "texture": "#0", "uv": [ 5, 4, 6, 13 ] },
                "up": { "texture": "#0", "uv": [ 2, 7, 3, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 7, 11, 6 ], 
            "to": [ 8, 20, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 2, 7, 3, 16 ] },
                "east": { "texture": "#0", "uv": [ 0, 0, 1, 9 ] },
                "south": { "texture": "#0", "uv": [ 6, 6, 7, 15 ] },
                "west": { "texture": "#0", "uv": [ 0, 0, 1, 9 ] },
                "up": { "texture": "#0", "uv": [ 2, 7, 3, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 5, 11, 6 ], 
            "to": [ 6, 20, 7 ], 
            "rotation": { "origin": [ 8.0, 8.0, 5.0 ], "axis": "x", "angle": -22.5 },
            "faces": {
                "north": { "texture": "#0", "uv": [ 0, 3, 1, 12 ] },
                "east": { "texture": "#0", "uv": [ 1, 3, 2, 12 ] },
                "south": { "texture": "#0", "uv": [ 0, 6, 1, 15 ] },
                "west": { "texture": "#0", "uv": [ 2, 7, 3, 16 ] },
                "up": { "texture": "#0", "uv": [ 2, 7, 3, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 1 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 2, 3, 6 ], 
            "to": [ 3, 4, 14 ], 
            "faces": {
                "east": { "texture": "#1", "uv": [ 0, 0, 8, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 8, 1 ] },
                "up": { "texture": "#0", "uv": [ 0, 0, 1, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 8 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 12, 3, 6 ], 
            "to": [ 13, 4, 14 ], 
            "faces": {
                "east": { "texture": "#1", "uv": [ 0, 0, 8, 1 ] },
                "west": { "texture": "#1", "uv": [ 0, 0, 8, 1 ] },
                "up": { "texture": "#0", "uv": [ 0, 0, 1, 8 ] },
                "down": { "texture": "#0", "uv": [ 0, 0, 1, 8 ] }
            }
        },
        {
            "name": "Cube",
            "from": [ 3, 3, 9 ], 
            "to": [ 12, 4, 11 ], 
            "faces": {
                "north": { "texture": "#1", "uv": [ 0, 0, 9, 1 ] },
                "south": { "texture": "#1", "uv": [ 0, 0, 9, 1 ] },
                "up": { "texture": "#1", "uv": [ 0, 0, 9, 2 ] },
                "down": { "texture": "#1", "uv": [ 0, 0, 9, 2 ] }
            }
        }
    ]
}

 

Posted

After weeding out chaff leftover from debugging...

For anyone running into this, if you use:

public class YourBlockClass extends Block {

    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT_MIPPED;
    }

...
}

You also need to include:

    public boolean isOpaqueCube(IBlockState state) {
    	return false;
    }

 

In the end though, (for my block purposes anyhow) I was able to omit the usage of BlockRenderLayer getBlockLayer() and now only use isOpaqueCube(IBlockState state) in my block class.  The reason it wasn't working before is because I didn't include the passed variable "IBlockState state" in my early debugging (see my initial post).  I was having a hard time finding a working example since it took a while for me to find a way to see minecraft source code that wasn't obfuscated (mc modding newb).  Hope this helps someone!

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

×
×
  • Create New...

Important Information

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