Jump to content

[1.6.4] Collision with custom block (Solved)


ColdFox

Recommended Posts

I've a block with a tile entity for use a custom model and I've set the block bounds. The problem is that when the player's head gets into the "normal" block area, the player gets pushed away from it as it would happen when the player collides with a entity. Am I missing something?

 

2zp2po4.jpg

 

SlabBlock

 

 

public class SlabBlock extends BlockContainer implements ITileEntityProvider {

public SlabBlock(int id, Block par2Block) {

super(id, par2Block.blockMaterial);

        this.setHardness(par2Block.blockHardness);

        this.setResistance(par2Block.blockResistance / 3.0F);

        this.setStepSound(par2Block.stepSound);

this.setCreativeTab(mod_MoreBlocksMod.tabMoreBlocks);

this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);

 

}

 

public void registerIcons(IconRegister iconReg) {

this.blockIcon = iconReg.registerIcon("minecraft:"+ mod_MoreBlocksMod.blockTypes[this.blockID - mod_MoreBlocksMod.slabBlockIDFinal]);

}

 

/**

    * Called when the block is placed in the world.

    */

    public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)

    {

        int l = determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase);

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

    }

   

    /**

    * Updates the blocks bounds based on its current state. Args: world, x, y, z

    */

    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)

    {

        int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4);

       

        switch(l){

    case 0:

    this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);

    break;

    case 1:

    this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);

    break;

    case 2:

    this.setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 1.0F, 1.0F);

    break;

    case 3:

    this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5F);

    break;

    case 4:

    this.setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    break;

    case 5:

    this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 1.0F, 1.0F);

    break;

        }

 

    }

   

    /**

    * gets the way this piston should face for that entity that placed it.

    */

    public static int determineOrientation(World par0World, int par1, int par2, int par3, EntityLivingBase par4EntityLivingBase)

    {

        if (MathHelper.abs((float)par4EntityLivingBase.posX - (float)par1) < 2.0F && MathHelper.abs((float)par4EntityLivingBase.posZ - (float)par3) < 2.0F)

        {

            double d0 = par4EntityLivingBase.posY + 1.82D - (double)par4EntityLivingBase.yOffset;

 

            if (d0 - (double)par2 > 2.0D)

            {

                return 1;

            }

 

            if ((double)par2 - d0 > 0.0D)

            {

                return 0;

            }

        }

 

        int l = MathHelper.floor_double((double)(par4EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

        return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));

    }

 

 

   

public boolean shouldSideBeRendered(IBlockAccess iblockaccess, int i,

int j, int k, int l) {

return false;

}

 

public boolean isOpaqueCube() {

return false;

}

 

@Override

public TileEntity createNewTileEntity(World world) {

return new SlabTileEntity();

}

 

 

 

 

SlabTileEntity

 

public SlabTileEntity setBlockTypeAndMeta(Block block, int meta) {

this.blockType = block;

this.blockMetadata = meta;

return this;

}

 

 

Link to comment
Share on other sites

I've run into this, and every time I have it's a pain in the ass to fix.

 

I'll try and find the solution...

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

Ah here we are.  You need to override getCollisionBoundingBoxFromPool.

You'll have to work out what bounding box you need, but the syntax looks like this:

 

	public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
	return AxisAlignedBB.getAABBPool(xmin, ymin, zmin, xmax, ymax, zmax);
    }

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

Ah here we are.  You need to override getCollisionBoundingBoxFromPool.

You'll have to work out what bounding box you need, but the syntax looks like this:

 

	public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
	return AxisAlignedBB.getAABBPool(xmin, ymin, zmin, xmax, ymax, zmax);
    }

 

So I tried like this:

 

    @Override
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
    	int l = par1World.getBlockMetadata(par2, par3, par4);
        switch(l){
    	case 0:
    		return AxisAlignedBB.getAABBPool().getAABB((double)par2 + 0.0, (double)par3+0.5, (double)par4 + 0.0, (double)par2 + 1, (double)par3 + 1, (double)par4 + 1);
    	case 1:
    		return AxisAlignedBB.getAABBPool().getAABB((double)par2 + 0.0, (double)par3+0.0, (double)par4 + 0.0, (double)par2 + 1, (double)par3 + 0.5, (double)par4 + 1);
    	case 2:
    		return AxisAlignedBB.getAABBPool().getAABB((double)par2 + 0.0, (double)par3+0.0, (double)par4 + 0.5, (double)par2 + 1, (double)par3 + 1, (double)par4 + 1);
    	case 3:
    		return AxisAlignedBB.getAABBPool().getAABB((double)par2 + 0.0, (double)par3+0.0, (double)par4 + 0.0, (double)par2 + 1, (double)par3 + 1, (double)par4 + 0.5);
    	case 4:
    		return AxisAlignedBB.getAABBPool().getAABB((double)par2 + 0.5, (double)par3+0.0, (double)par4 + 0.0, (double)par2 + 1, (double)par3 + 1, (double)par4 + 1);
    	case 5:
    		return AxisAlignedBB.getAABBPool().getAABB((double)par2 + 0.0, (double)par3+0.5, (double)par4 + 0.0, (double)par2 + 0.5, (double)par3 + 1, (double)par4 + 1);
        default:
        	System.err.println("Something went wrong. Invalid metadata.");
        	return AxisAlignedBB.getAABBPool().getAABB((double)par2 + 0.0, (double)par3+0.5, (double)par4 + 0.0, (double)par2 + 1, (double)par3 + 1, (double)par4 + 1);
        }
    }

 

and it's the same :S I also tried with different values but or it's the same, or it's almost like a normal block.

 

EDIT: Fixed, I forgot the method

/**
     * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
     */
    public boolean renderAsNormalBlock()
    {
        return false;
    }

 

:facepalm:

Link to comment
Share on other sites

This is a really old block (like 1.5 or before) but I had the same problem and solved it.

 

I thought that was it, but see if this helps you at all.

 

package draco18s.micromods.peephole;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockPeepHole extends Block {

public BlockPeepHole(int par1, int par2, Material par3Material) {
	super(par1, par2, par3Material);
	this.setBlockName("Peephole");
	setHardness(1.0F);
	setResistance(5.0F);
	setStepSound(soundStoneFootstep);
	setCreativeTab(CreativeTabs.tabBlock);
	setLightOpacity(0);
}

public String getTextureFile() {
	return CommonProxy.BLOCKS_PNG;
}

public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
	int var6 = world.getBlockMetadata(x, y, z);
	switch(var6) {
		case 1:
			this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
			break;
		case 2:
			this.setBlockBounds(0.0F, 0.0F, 0.9375F, 1.0F, 1.0F, 1.0F);
			break;
		case 3:
			this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0625F);
			break;
		case 4:
			this.setBlockBounds(0.9375F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
			break;
		case 5:
			this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0625F, 1.0F, 1.0F);
			break;
		case 6:
			this.setBlockBounds(0.0F, 0.9375F, 0.0F, 1.0F, 1.0F, 1.0F);
			break;
		case 0:
		case 7:
			this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
			break;
	}
}

public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
	return null;
    }

public void onBlockAdded(World par1World, int par2, int par3, int par4)
    {
        super.onBlockAdded(par1World, par2, par3, par4);
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        this.setDefaultDirection(par1World, par2, par3, par4);
        this.onNeighborBlockChange(par1World, par2, par3, par4, this.blockID);
    }

private void setDefaultDirection(World par1World, int par2, int par3, int par4)
    {
        if (!par1World.isRemote)
        {
            int var5 = par1World.getBlockId(par2, par3, par4 - 1);
            int var6 = par1World.getBlockId(par2, par3, par4 + 1);
            int var7 = par1World.getBlockId(par2 - 1, par3, par4);
            int var8 = par1World.getBlockId(par2 + 1, par3, par4);
            int var10 = par1World.getBlockId(par2, par3-1, par4);
            int var11 = par1World.getBlockId(par2, par3+1, par4);
            byte var9 = 7;

            if ((var5 != blockID && Block.opaqueCubeLookup[var5]) && !Block.opaqueCubeLookup[var6])
            {
                var9 = 3;
            }

            if ((var6 != blockID && Block.opaqueCubeLookup[var6]) && !Block.opaqueCubeLookup[var5])
            {
                var9 = 2;
            }

            if ((var7 != blockID && Block.opaqueCubeLookup[var7]) && !Block.opaqueCubeLookup[var8])
            {
                var9 = 5;
            }

            if ((var8 != blockID && Block.opaqueCubeLookup[var8]) && !Block.opaqueCubeLookup[var7])
            {
                var9 = 4;
            }

            if ((var10 != blockID && Block.opaqueCubeLookup[var10]) && !Block.opaqueCubeLookup[var11])
            {
                var9 = 1;
            }

            if ((var11 != blockID && Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var10])
            {
                var9 = 6;
            }

            int var99 = ((var5 != blockID && Block.opaqueCubeLookup[var5])?1:0) + ((var6 != blockID && Block.opaqueCubeLookup[var6])?1:0) + ((var7 != blockID && Block.opaqueCubeLookup[var7])?1:0) + ((var8 != blockID && Block.opaqueCubeLookup[var8])?1:0) + ((var10 != blockID && Block.opaqueCubeLookup[var10])?1:0) + ((var11 != blockID && Block.opaqueCubeLookup[var11])?1:0);
            
            if(var99 > 1)
            {
            	par1World.setBlockMetadataWithNotify(par2, par3, par4, 7);
        	}
            else {
            	par1World.setBlockMetadataWithNotify(par2, par3, par4, var9);
            }
        }
    }

public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
        if(var6 == 0 || var6 == 7) {
        	return this.blockIndexInTexture+1;
        }
        else if(var6 == 6) {
        	var6 = 0;
        }
        return par5 != var6 ? this.blockIndexInTexture+1:this.blockIndexInTexture;
    }

public boolean isOpaqueCube()
    {
        return true;
    }

    public boolean renderAsNormalBlock()
    {
        return false;
    }
    
    public void setBlockBoundsForItemRender()
    {
    	this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5F);
    }
    
    public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
    {
        //int var6 = par1World.getBlockMetadata(par2, par3, par4);
        boolean var7 = canPlaceBlockAt(par1World, par2, par3, par4);

        if (!var7)
        {
            this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
            par1World.setBlockWithNotify(par2, par3, par4, 0);
        }

        super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
    }
    
    public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
    {
    	int var5 = par1World.getBlockId(par2, par3, par4 - 1);
        int var6 = par1World.getBlockId(par2, par3, par4 + 1);
        int var7 = par1World.getBlockId(par2 - 1, par3, par4);
        int var8 = par1World.getBlockId(par2 + 1, par3, par4);
        int var10 = par1World.getBlockId(par2, par3-1, par4);
        int var11 = par1World.getBlockId(par2, par3+1, par4);
        
        /*if (var5 == blockID || var6 == blockID || var7 == blockID || var8 == blockID || var10 == blockID || var11 == blockID)
        {
        	return false;
        }*/
        
        byte var9 = 7;

        if ((var5 != blockID && Block.opaqueCubeLookup[var5]) && !Block.opaqueCubeLookup[var6])
        {
            var9 = 3;
        }

        if ((var6 != blockID && Block.opaqueCubeLookup[var6]) && !Block.opaqueCubeLookup[var5])
        {
            var9 = 2;
        }

        if ((var7 != blockID && Block.opaqueCubeLookup[var7]) && !Block.opaqueCubeLookup[var8])
        {
            var9 = 5;
        }

        if ((var8 != blockID && Block.opaqueCubeLookup[var8]) && !Block.opaqueCubeLookup[var7])
        {
            var9 = 4;
        }

        if ((var10 != blockID && Block.opaqueCubeLookup[var10]) && !Block.opaqueCubeLookup[var11])
        {
            var9 = 1;
        }

        if ((var11 != blockID && Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var10])
        {
            var9 = 6;
        }

        if (var9 == 7)
        {
        	return false;
        }
        
        int var99 = ((var5 != blockID && Block.opaqueCubeLookup[var5])?1:0) + ((var6 != blockID && Block.opaqueCubeLookup[var6])?1:0) + ((var7 != blockID && Block.opaqueCubeLookup[var7])?1:0) + ((var8 != blockID && Block.opaqueCubeLookup[var8])?1:0) + ((var10 != blockID && Block.opaqueCubeLookup[var10])?1:0) + ((var11 != blockID && Block.opaqueCubeLookup[var11])?1:0);
        
        if (var99 != 1)
        {
        	return false;
        }
        
        return true;
    }
}

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

This is a really old block (like 1.5 or before) but I had the same problem and solved it.

 

I thought that was it, but see if this helps you at all.

 

package draco18s.micromods.peephole;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockPeepHole extends Block {

public BlockPeepHole(int par1, int par2, Material par3Material) {
	super(par1, par2, par3Material);
	this.setBlockName("Peephole");
	setHardness(1.0F);
	setResistance(5.0F);
	setStepSound(soundStoneFootstep);
	setCreativeTab(CreativeTabs.tabBlock);
	setLightOpacity(0);
}

public String getTextureFile() {
	return CommonProxy.BLOCKS_PNG;
}

public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
	int var6 = world.getBlockMetadata(x, y, z);
	switch(var6) {
		case 1:
			this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
			break;
		case 2:
			this.setBlockBounds(0.0F, 0.0F, 0.9375F, 1.0F, 1.0F, 1.0F);
			break;
		case 3:
			this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0625F);
			break;
		case 4:
			this.setBlockBounds(0.9375F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
			break;
		case 5:
			this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0625F, 1.0F, 1.0F);
			break;
		case 6:
			this.setBlockBounds(0.0F, 0.9375F, 0.0F, 1.0F, 1.0F, 1.0F);
			break;
		case 0:
		case 7:
			this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
			break;
	}
}

public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
	return null;
    }

public void onBlockAdded(World par1World, int par2, int par3, int par4)
    {
        super.onBlockAdded(par1World, par2, par3, par4);
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        this.setDefaultDirection(par1World, par2, par3, par4);
        this.onNeighborBlockChange(par1World, par2, par3, par4, this.blockID);
    }

private void setDefaultDirection(World par1World, int par2, int par3, int par4)
    {
        if (!par1World.isRemote)
        {
            int var5 = par1World.getBlockId(par2, par3, par4 - 1);
            int var6 = par1World.getBlockId(par2, par3, par4 + 1);
            int var7 = par1World.getBlockId(par2 - 1, par3, par4);
            int var8 = par1World.getBlockId(par2 + 1, par3, par4);
            int var10 = par1World.getBlockId(par2, par3-1, par4);
            int var11 = par1World.getBlockId(par2, par3+1, par4);
            byte var9 = 7;

            if ((var5 != blockID && Block.opaqueCubeLookup[var5]) && !Block.opaqueCubeLookup[var6])
            {
                var9 = 3;
            }

            if ((var6 != blockID && Block.opaqueCubeLookup[var6]) && !Block.opaqueCubeLookup[var5])
            {
                var9 = 2;
            }

            if ((var7 != blockID && Block.opaqueCubeLookup[var7]) && !Block.opaqueCubeLookup[var8])
            {
                var9 = 5;
            }

            if ((var8 != blockID && Block.opaqueCubeLookup[var8]) && !Block.opaqueCubeLookup[var7])
            {
                var9 = 4;
            }

            if ((var10 != blockID && Block.opaqueCubeLookup[var10]) && !Block.opaqueCubeLookup[var11])
            {
                var9 = 1;
            }

            if ((var11 != blockID && Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var10])
            {
                var9 = 6;
            }

            int var99 = ((var5 != blockID && Block.opaqueCubeLookup[var5])?1:0) + ((var6 != blockID && Block.opaqueCubeLookup[var6])?1:0) + ((var7 != blockID && Block.opaqueCubeLookup[var7])?1:0) + ((var8 != blockID && Block.opaqueCubeLookup[var8])?1:0) + ((var10 != blockID && Block.opaqueCubeLookup[var10])?1:0) + ((var11 != blockID && Block.opaqueCubeLookup[var11])?1:0);
            
            if(var99 > 1)
            {
            	par1World.setBlockMetadataWithNotify(par2, par3, par4, 7);
        	}
            else {
            	par1World.setBlockMetadataWithNotify(par2, par3, par4, var9);
            }
        }
    }

public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
    {
        int var6 = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
        if(var6 == 0 || var6 == 7) {
        	return this.blockIndexInTexture+1;
        }
        else if(var6 == 6) {
        	var6 = 0;
        }
        return par5 != var6 ? this.blockIndexInTexture+1:this.blockIndexInTexture;
    }

public boolean isOpaqueCube()
    {
        return true;
    }

    public boolean renderAsNormalBlock()
    {
        return false;
    }
    
    public void setBlockBoundsForItemRender()
    {
    	this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5F);
    }
    
    public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
    {
        //int var6 = par1World.getBlockMetadata(par2, par3, par4);
        boolean var7 = canPlaceBlockAt(par1World, par2, par3, par4);

        if (!var7)
        {
            this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
            par1World.setBlockWithNotify(par2, par3, par4, 0);
        }

        super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
    }
    
    public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
    {
    	int var5 = par1World.getBlockId(par2, par3, par4 - 1);
        int var6 = par1World.getBlockId(par2, par3, par4 + 1);
        int var7 = par1World.getBlockId(par2 - 1, par3, par4);
        int var8 = par1World.getBlockId(par2 + 1, par3, par4);
        int var10 = par1World.getBlockId(par2, par3-1, par4);
        int var11 = par1World.getBlockId(par2, par3+1, par4);
        
        /*if (var5 == blockID || var6 == blockID || var7 == blockID || var8 == blockID || var10 == blockID || var11 == blockID)
        {
        	return false;
        }*/
        
        byte var9 = 7;

        if ((var5 != blockID && Block.opaqueCubeLookup[var5]) && !Block.opaqueCubeLookup[var6])
        {
            var9 = 3;
        }

        if ((var6 != blockID && Block.opaqueCubeLookup[var6]) && !Block.opaqueCubeLookup[var5])
        {
            var9 = 2;
        }

        if ((var7 != blockID && Block.opaqueCubeLookup[var7]) && !Block.opaqueCubeLookup[var8])
        {
            var9 = 5;
        }

        if ((var8 != blockID && Block.opaqueCubeLookup[var8]) && !Block.opaqueCubeLookup[var7])
        {
            var9 = 4;
        }

        if ((var10 != blockID && Block.opaqueCubeLookup[var10]) && !Block.opaqueCubeLookup[var11])
        {
            var9 = 1;
        }

        if ((var11 != blockID && Block.opaqueCubeLookup[var11]) && !Block.opaqueCubeLookup[var10])
        {
            var9 = 6;
        }

        if (var9 == 7)
        {
        	return false;
        }
        
        int var99 = ((var5 != blockID && Block.opaqueCubeLookup[var5])?1:0) + ((var6 != blockID && Block.opaqueCubeLookup[var6])?1:0) + ((var7 != blockID && Block.opaqueCubeLookup[var7])?1:0) + ((var8 != blockID && Block.opaqueCubeLookup[var8])?1:0) + ((var10 != blockID && Block.opaqueCubeLookup[var10])?1:0) + ((var11 != blockID && Block.opaqueCubeLookup[var11])?1:0);
        
        if (var99 != 1)
        {
        	return false;
        }
        
        return true;
    }
}

 

I forgot to override the method renderAsNormalBlock() so the tile entity had a normal block "size". Thanks anyway ;)

Link to comment
Share on other sites

I forgot to override the method renderAsNormalBlock() so the tile entity had a normal block "size". Thanks anyway ;)

 

That would do it!

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

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

    • Try deliting feur builder  It caused this issue in my modpack
    • I am not using hardcoded recipes, I'm using Vanilla's already existing code for leather armor dying. (via extending and implementing DyeableArmorItem / DyeableLeatherItem respectively) I have actually figured out that it's something to do with registering item colors to the ItemColors instance, but I'm trying to figure out where exactly in my mod's code I would be placing a call to the required event handler. Unfortunately the tutorial is criminally undescriptive. The most I've found is that it has to be done during client initialization. I'm currently trying to do the necessary setup via hijacking the item registry since trying to modify the item classes directly (via using SubscribeEvent in the item's constructor didn't work. Class so far: // mrrp mrow - mcmod item painter v1.0 - catzrule ch package catzadvitems.init; import net.minecraft.client.color.item.ItemColors; import net.minecraft.world.item.Item; import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.client.event.ColorHandlerEvent; import catzadvitems.item.DyeableWoolArmorItem; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class Painter { @ObjectHolder("cai:dyeable_wool_chestplate") public static final Item W_CHEST = null; @ObjectHolder("cai:dyeable_wool_leggings") public static final Item W_LEGS = null; @ObjectHolder("cai:dyeable_wool_boots") public static final Item W_SOCKS = null; public Painter() { // left blank, idk if forge throws a fit if constructors are missing, not taking the chance of it happening. } @SubscribeEvent public static void init(FMLClientSetupEvent event) { new Painter(); } @Mod.EventBusSubscriber private static class ForgeBusEvents { @SubscribeEvent public static void registerItemColors(ColorHandlerEvent.Item event) { ItemColors col = event.getItemColors(); col.register(DyeableUnderArmorItem::getItemDyedColor, W_CHEST, W_LEGS, W_SOCKS); //placeholder for other dye-able items here later.. } } } (for those wondering, i couldn't think of a creative wool helmet name)
    • nvm found out it was because i had create h and not f
    • Maybe there's something happening in the 'leather armor + dye' recipe itself that would be updating the held item texture?
    • @SubscribeEvent public static void onRenderPlayer(RenderPlayerEvent.Pre e) { e.setCanceled(true); model.renderToBuffer(e.getPoseStack(), pBuffer, e.getPackedLight(), 0f, 0f, 0f, 0f, 0f); //ToaPlayerRenderer.render(); } Since getting the render method from a separate class is proving to be bit of a brick wall for me (but seems to be the solution in older versions of minecraft/forge) I've decided to try and pursue using the renderToBuffer method directly from the model itself. I've tried this route before but can't figure out what variables to feed it for the vertexConsumer and still can't seem to figure it out; if this is even a path to pursue.  The vanilla model files do not include any form of render methods, and seem to be fully constructed from their layer definitions? Their renderer files seem to take their layers which are used by the render method in the vanilla MobRenderer class. But for modded entities we @Override this function and don't have to feed the method variables because of that? I assume that the render method in the extended renderer takes the layer definitions from the renderer classes which take those from the model files. Or maybe instead of trying to use a render method I should be calling the super from the renderer like   new ToaPlayerRenderer(context, false); Except I'm not sure what I would provide for context? There's a context method in the vanilla EntityRendererProvider class which doesn't look especially helpful. I've been trying something like <e.getEntity(), model<e.getEntity()>> since that generally seems to be what is provided to the renderers for context, but I don't know if it's THE context I'm looking for? Especially since the method being called doesn't want to take this or variations of this.   In short; I feel like I'm super super close but I have to be missing something obvious? Maybe this insane inane ramble post will provide some insight into this puzzle?
  • Topics

×
×
  • Create New...

Important Information

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