Jump to content

Recommended Posts

Posted

In a mod I have been developing with a friend, I've made a decorative block that uses the same shape and such as a cake - however, it has this error that when it is placed, surrounding its bottom is a pixel-wide gap that shows the Void (or at least I assume it's the void). 

Spoiler

UHNtysL.png

fOjzwVm.png

 

Yet the block's model and all seems to be accurate, since it can be walked on appropriately without jumping, and fits what si visually seen. 

 

At any rate, here's the codestuffs for it-

BlockDogBowl.java

package slvr.LupineMod.blocks;

import java.util.Random;

import javax.annotation.Nullable;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import slvr.LupineMod.Reference;

public class BlockDogBowl extends Block {

	public BlockDogBowl() {
		super(Material.wood);
		setUnlocalizedName(Reference.ModBlocks.DOG_BOWL.getUnlocalizedName());
		setRegistryName(Reference.ModBlocks.DOG_BOWL.getRegistryName());
		this.setCreativeTab(CreativeTabs.tabDecorations);
		this.setHardness(2.0F);
		this.setStepSound(soundTypeWood);
		this.setResistance(10.0F);
	}
	
	public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
    {
		setBlockBounds(1.0F / 16.0F, 0.0F, 0.0625F, 1.0F - 0.0625F, 0.5F, 1.0F - 0.0625F);
    }
	
	@SideOnly(Side.CLIENT)
    public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos)
    {
		return this.getCollisionBoundingBox(worldIn, pos, worldIn.getBlockState(pos));
    }
    public boolean isFullCube(IBlockState state)
    {
        return false;
    }

    /**
     * Used to determine ambient occlusion and culling when rebuilding chunks for render
     */
    public boolean isOpaqueCube(IBlockState state)
    {
        return false;
    }

}

 

ModBlocks.java

package slvr.LupineMod.init;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;
import slvr.LupineMod.blocks.BlockDogBowl;

public class ModBlocks {
	
	public static Block dog_bowl;

	public static void init() {
		dog_bowl = new BlockDogBowl();
	}
	
	public static void register() {
		GameRegistry.registerBlock(dog_bowl);
	}
	
	public static void registerRenders() {
		registerRender(dog_bowl);
	}
	
	private static void registerBlock (Block block) {
		//GameRegistry.registerBlock(block);
		ItemBlock item = new ItemBlock(block);
		item.setRegistryName(block.getRegistryName());
		GameRegistry.registerItem(item);
	}
	
	private static void registerRender(Block block) {
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
	}
}

ClientProxy.java

package slvr.LupineMod.proxy;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import slvr.LupineMod.entities.*;
import slvr.LupineMod.init.ModBlocks;
import slvr.LupineMod.init.ModItems;

public class ClientProxy implements CommonProxy{
	
	@Override
	public void preInit(){
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityAfricanWildDog.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityRedWolf.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityCoyote.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityNetherhound.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityGermanShepherd.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityGoldenRetriever.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityPitBull.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityDingo.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityArcticWolf.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityEndWolf.class);
        ClientProxy.registerRenderForVariedWolf(slvr.LupineMod.entities.EntityNewGuineaSingingDog.class);
	}
	public void init(){
		ModItems.registerRenders();
		ModBlocks.registerRenders();

		
	}
	
	private static void registerRenderForVariedWolf(Class c){
		RenderingRegistry.registerEntityRenderingHandler(c, new IRenderFactory<EntityVariedWolf>()
		{
	     @Override
	     public Render<? super EntityVariedWolf> createRenderFor(RenderManager manager){
	    	 return new RenderVariedWolf(manager);
	     }
		});
	}
	

}

 

ItemDogBowl.json (blockstates folder)

{
    "variants": {
        "normal": { "model": "slupinemod:dog_bowl" }
    }
}

 

dog_bowl.json (models/block folder)

{
    "textures": {
        "particle": "blocks/planks_big_oak",
        "bottom": "blocks/planks_big_oak",
        "top": "slupinemod:blocks/dog_bowl_top",
        "side": "blocks/planks_big_oak"
    },
    "elements": [
        {   "from": [ 1, 0, 1 ],
            "to": [ 15, 8, 15 ],
            "faces": {
                "down":  { "uv": [ 1, 1, 15, 15 ], "texture": "#bottom", "cullface": "down" },
                "up":    { "uv": [ 1, 1, 15, 15 ], "texture": "#top" },
                "north": { "uv": [ 1, 8, 15, 16 ], "texture": "#side" },
                "south": { "uv": [ 1, 8, 15, 16 ], "texture": "#side" },
                "west":  { "uv": [ 1, 8, 15, 16 ], "texture": "#side" },
                "east":  { "uv": [ 1, 8, 15, 16 ], "texture": "#side" }
            }
        }
    ]
}

 

Any idea what could be causing this? It is certainly no game-breaking bug but it is annoying.

Posted

Try overriding Block#getBlockLayer to return BlockRenderLayer.CUTOUT or BlockRenderLayer.CUTOUT_MIPPED.

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/

Posted

....you will also need to override isFullCube and isOpaqueCube and return false.

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.

Posted (edited)
15 hours ago, Draco18s said:

....you will also need to override isFullCube and isOpaqueCube and return false.

 
 

Which he already does in his BlockDogBowl, though not with @Override, which he really should do.

Edited by larsgerrits

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/

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.