Jump to content

Recommended Posts

Posted

I'm right now updating my mod from 1.7.10 to 1.8.9 and I need semitransparent rendering for one of my blocks and a lot of items. The block and the items are rendered as an .obj File and are modeled in blender. Problem: I have no idea on how to do this and I need to know if minecraft and/or forge as implemented some sort of Distance based rendering for 1.8.9 yet.

 

I hope someone can help me.

Posted

Ok, after a lot of testing i found a method that lets me render semitransparent Block in the correct order, but from time to time the block gets rendered wrong and I don't know why (the method, that does it is "public EnumWorldBlockLayer getBlockLayer()" from the slime block). I think this could be a forge bug. I still need a way to render .obj items semitransparent.

How the block should look like:

 

 

How the block from time to time looks like:

 

 

Code:

 

 

TileEntity:

package tileEntitys;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.client.model.obj.OBJModel;

public class TileEntity_TestBlock extends TileEntity implements ITickable{
    
    public TileEntity_TestBlock(){
    }
    
    @Override
    public void writeToNBT(NBTTagCompound compound) {
    	super.writeToNBT(compound);
    }
    @Override
    public void readFromNBT(NBTTagCompound compound) {
    	super.readFromNBT(compound);
    }

@Override
public void update() {
}

}

 

BlockClass:

package blocks.TestCreations;

import com.google.common.collect.Lists;

import reference.Constants;
import reference.Methref;
import tileEntitys.TileEntity_TestBlock;
import base.MainClass;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.model.obj.OBJModel;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;


/**
* A block, created only for testing purposes.
* @since 14.02.2016
* @author Pythonschlange
*
*/
public class Block_TestBlock extends Block implements ITileEntityProvider{
/**
 * The constructor for the TestBlock.
 * @param material -The material of the block.
 * 
 * @since 14.02.2016
 * @author Pythonschlange
 */
public Block_TestBlock(Material material) {
	super(material);
	this.setCreativeTab(Constants.tabStuffForMC);
	this.setLightLevel(1.0F);
	this.setHardness(5.0F);
	this.setStepSound(Block.soundTypeStone);
	this.setUnlocalizedName(Constants.UnlocalizedNameBlock_TestBlock);
	//this.setBlockTextureName(Constants.ModID + ":" + "testblock");
}
    @Override
    public boolean isOpaqueCube() { return false; }

    @Override
    public boolean isFullCube() { return false; }

    @Override
    public boolean isVisuallyOpaque() { return false; }
    
    @SideOnly(Side.CLIENT)
    public EnumWorldBlockLayer getBlockLayer(){
        return EnumWorldBlockLayer.TRANSLUCENT;
    }
    
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
	return new TileEntity_TestBlock();
}
}

 

ClientProxy:

package base.Proxies;


import blocks.AllBlocks;
import items.AllItems;
import reference.Constants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

/**
* Here go things that only the Client has to do.
* @since 14.02.2016
* @author Pythonschlange
*
*/
public class ClientProxy extends CommonProxy {


@Override
public void preInit(FMLPreInitializationEvent e){
	super.preInit(e);

	OBJLoader.instance.addDomain(Constants.ModID.toLowerCase());
        Item item2 = Item.getItemFromBlock(AllBlocks.blockTestblock);
        ModelLoader.setCustomModelResourceLocation(item2, 0, new ModelResourceLocation(Constants.ModID.toLowerCase() + ":" + AllBlocks.blockTestblock.getUnlocalizedName().substring(5)));
}

@Override
public void load(FMLInitializationEvent event){
	super.load(event);
	blocks.BlockRenderRegister.registerBlockRenderer();
	items.ItemRenderRegister.registerItemRenderer();
}
@Override
public void postInit(FMLPostInitializationEvent event){
	super.postInit(event);
}
}

blockstate.json:

{
    "forge_marker": 1,
    "defaults": {
        "textures": {
            "#Material.001": "stuffformc:blocks/TestBlock_TsTexture",
            "#Material.002": "stuffformc:blocks/TestBlock_SphereTexture",
            "#Material.003": "stuffformc:blocks/TestBlock_CasingTexture"},
        "model": "stuffformc:TestBlock_Casing.obj"
     },
    "variants": {
        "normal": [{}],
        "inventory": [{
            "transform": "forge:default-block"
        }]
    }
}

block.json(I don't know for sure, but i think this doesn't get called):

{
    "parent": "stuffformc:blockstates/testblock",
    "textures": {
        "all": "stuffformc:blocks/TestBlock_CasingTexture"
    }
}

Item.json(doesn't work right now, if you know how to do the ItemRenderer for .obj models please tell me):

{
    "parent":"stuffformc:blockstates/testblock",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

 

 

EDIT: I also would like to know, how to animate an .obj model (item and/or block). I'm happy for any response :D

Posted

Okay, this is new stuff... is there anywere a place where the Json file (and it's arguments, functions...) is explained? Because I searched for way to long and found nothing. And if there isn't, would someone be kind enough to quickly explain how Jsons work (background would be nice, but I just need to know what all the arguments in the file are doing and how they work)

I'm thankfull for every respond. :)

Posted
This Gist appears to explain the grammar of the animation state machine JSON. I haven't seen any other documentation of it.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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



×
×
  • Create New...

Important Information

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