Jump to content

Recommended Posts

Posted

I working on a block with the same propreties of the cauldron. It works fine, the rightclicking stuff, but it is not rendering.

I just renders the hitbox/collisionboxes of the block, but no caudron.

 

I just using the same code as the cauldron renderer in the renderBlocks file.

I'm using an ISimpleBlockRenderingHandler.

this is the code I use:

public class RenderBarrel implements ISimpleBlockRenderingHandler {

@Override
public void renderInventoryBlock(Block block, int metadata, int modelID,
		RenderBlocks renderer) {
  
}

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,
		Block block, int modelId, RenderBlocks renderer) {
	return this.renderWorldBlock(world, x, y, z, (BlockBarrel)block, modelId, renderer);

}

public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,
		BlockBarrel block, int modelId, RenderBlocks renderer) {

	if(ClientProxy.renderPass == 0) {

        renderer.renderStandardBlock(block, x, y, z);
        Tessellator tessellator = Tessellator.instance;
        tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
        float f = 1.0F;
        int l = block.colorMultiplier(world, x, y, z);
        float f1 = (float)(l >> 16 & 255) / 255.0F;
        float f2 = (float)(l >> 8 & 255) / 255.0F;
        float f3 = (float)(l & 255) / 255.0F;
        float f4;

        if (EntityRenderer.anaglyphEnable)
        {
            float f5 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
            f4 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
            float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
            f1 = f5;
            f2 = f4;
            f3 = f6;
        }

        tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
        IIcon icon = block.getBlockTextureFromSide(2);
        f4 = 0.125F;
        renderer.renderFaceXPos(block, (double)((float)x - 1.0F + f4), (double)y, (double)z, icon);
        renderer.renderFaceXNeg(block, (double)((float)x + 1.0F - f4), (double)y, (double)z, icon);
        renderer.renderFaceZPos(block, (double)x, (double)y, (double)((float)z - 1.0F + f4), icon);
        renderer.renderFaceZNeg(block, (double)x, (double)y, (double)((float)z + 1.0F - f4), icon);
        IIcon icon1 = BlockBarrel.getCauldronIcon("inner");
        renderer.renderFaceYPos(block, (double)x, (double)((float)y - 1.0F + 0.25F), (double)z, icon1);
        renderer.renderFaceYNeg(block, (double)x, (double)((float)y + 1.0F - 0.75F), (double)z, icon1);
        int i1 = world.getBlockMetadata(x, y, z);

        if (i1 > 0)
        {
            IIcon icon2 = BlockLiquid.getLiquidIcon("water_still");

            if (i1 > 3)
            {
                i1 = 3;
            }
            
            f = 1.0F;
            l = 0xe50000;
            f1 = (float)(l >> 16 & 255) / 255.0F;
            f2 = (float)(l >> 8 & 255) / 255.0F;
            f3 = (float)(l & 255) / 255.0F;
         

            if (EntityRenderer.anaglyphEnable)
            {
                float f5 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
                f4 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
                float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
                f1 = f5;
                f2 = f4;
                f3 = f6;
            }

            tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);

            renderer.renderFaceYPos(block, (double)x, (double)((float)y - 1.0F + (6.0F + (float)i1 * 3.0F) / 16.0F), (double)z, icon2);
        }
	} else {

		  renderer.renderStandardBlock(Main.BarrelBlock, x, y, z);
	}

        return true;
}

@Override
public int getRenderId() {

	return ClientProxy.renderID;
}

@Override
public boolean shouldRender3DInInventory(int modelId) {
	return false;
}

}

Coding, Testing, Smiling, Publishing!

Posted

We need more info.

Where do you register your ISBRH?

Do you use the renderID also in your block class?

 

For that we need your Mod class, Block class and ClientProxy class, too.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

We need more info.

Where do you register your ISBRH?

Do you use the renderID also in your block class?

 

For that we need your Mod class, Block class and ClientProxy class, too.

You're right.

Everything is registered as it was in 1.6. It worked then!

 

This is the ClientProxy

public class ClientProxy extends CommonProxy {

public static int renderID;

public static int renderPass = 0;



@Override
public void registerRenderers() {

	renderID = RenderingRegistry.getNextAvailableRenderId();

	RenderingRegistry.registerBlockHandler(new RenderBarrel());

	RenderingRegistry.registerEntityRenderingHandler(EntityAdvancedMob.class, new RenderAdvancedMob(new ModelBiped(), 0.5F));
	RenderingRegistry.registerEntityRenderingHandler(EntityGiant.class, new RenderGiant(new ModelBiped(), 0.5F, 1.5F));

//more registers, but not needed for topic.

}


}

 

This is the BlockBarrel.

public class BlockBarrel extends Block
{

@SideOnly(Side.CLIENT)
private static  IIcon field_94378_a;
@SideOnly(Side.CLIENT)
private IIcon cauldronTopIcon;
@SideOnly(Side.CLIENT)
private static IIcon cauldronBottomIcon;

public BlockBarrel() 
{
	super(Material.wood);
	this.setStepSound(Block.soundTypeWood);
}

@SideOnly(Side.CLIENT)
    public IIcon getIcon(int p_149691_1_, int p_149691_2_)
    {
        return p_149691_1_ == 1 ? this.cauldronBottomIcon : (p_149691_1_ == 0 ? this.cauldronBottomIcon : this.blockIcon);
    }

@SideOnly(Side.CLIENT)
    public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_)
    {
        if (p_149673_5_ == 1)
        {
            return this.cauldronBottomIcon;
        }
        else if (p_149673_5_ == 0)
        {
            return this.cauldronBottomIcon;
        }
        else
        {
            return this.blockIcon;
        }
    }

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
	this.field_94378_a = par1IconRegister.registerIcon("agecraft:Barrel Inner");
	this.cauldronTopIcon = par1IconRegister.registerIcon("agecraft:Barrel Top");
	this.cauldronBottomIcon = par1IconRegister.registerIcon("agecraft:Barrel Bottom");
	this.blockIcon = par1IconRegister.registerIcon("agecraft:Barrel Side");
}

@SideOnly(Side.CLIENT)
    public static IIcon getCauldronIcon(String p_150026_0_)
    {
        return p_150026_0_.equals("inner") ? field_94378_a : (p_150026_0_.equals("bottom") ? cauldronBottomIcon : null);
    }

public boolean renderAsNormalBlock()
    {
        return false;
    }

public boolean isOpaqueCube()
    {
        return false;
    }

@Override
public int getRenderBlockPass()
{
	return ClientProxy.renderID;
}

/**
 * Called upon block activation (right click on the block.)
 */
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
	if (par1World.isRemote)
	{
		return true;
	}
	else
	{
		ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem();

		if (itemstack == null)
		{
			return true;
		}
		else
		{
			int i1 = par1World.getBlockMetadata(par2, par3, par4);
			int j1 = func_111045_h_(i1);

			if (itemstack.getItem() == AgeCraft.Grape)
			{
				if (j1 < 3)
                    {
                        if (!par5EntityPlayer.capabilities.isCreativeMode)
                        {
                        	par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, new ItemStack(Items.bucket));
                        }

                        this.func_150024_a(par1World, par2, par3, par4, 3);
                    }

                    return true;
			}
			/*TODO if (itemstack.itemID == Item.appleRed.itemID)
			{
				if (j1 > 3 && j1 <= 6)
				{
					par1World.setBlockMetadataWithNotify(par2, par3, par4, 6, 2);
					par1World.func_96440_m(par2, par3, par4, this.blockID);
				}

				return true;
			}*/
			else
			{
				if (itemstack.getItem() == AgeCraft.Empty_WineBottle)
				{
					if (j1 > 0 && j1 <= 3)
					{
						ItemStack itemstack1 = new ItemStack(AgeCraft.Full_WineBottle);

						if (!par5EntityPlayer.inventory.addItemStackToInventory(itemstack1))
						{
							par1World.spawnEntityInWorld(new EntityItem(par1World, (double)par2 + 0.5D, (double)par3 + 1.5D, (double)par4 + 0.5D, itemstack1));
						}
						else if (par5EntityPlayer instanceof EntityPlayerMP)
						{
							((EntityPlayerMP)par5EntityPlayer).sendContainerToPlayer(par5EntityPlayer.inventoryContainer);
						}

						--itemstack.stackSize;

						if (itemstack.stackSize <= 0)
						{
							par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, (ItemStack)null);
						}

						this.func_150024_a(par1World, par2, par3, par4, 0);
					}
				}

				return true;
			}
		}
	}
}

public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_)
    {
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F);
        super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
        float f = 0.125F;
        this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
        super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
        super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
        this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
        this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
        super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
        this.setBlockBoundsForItemRender();
    }

public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_)
    {
        int l = func_150027_b(p_149670_1_.getBlockMetadata(p_149670_2_, p_149670_3_, p_149670_4_));
        float f = (float)p_149670_3_ + (6.0F + (float)(3 * l)) / 16.0F;

        if (!p_149670_1_.isRemote && p_149670_5_.isBurning() && l > 0 && p_149670_5_.boundingBox.minY <= (double)f)
        {
            p_149670_5_.extinguish();
            this.func_150024_a(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, l - 1);
        }
    }

public static int func_150027_b(int p_150027_0_)
    {
        return p_150027_0_;
    }

public void setBlockBoundsForItemRender()
    {
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

public void func_150024_a(World world, int par1, int par2, int par3, int par4)
    {
	world.setBlockMetadataWithNotify(par1, par2, par3, MathHelper.clamp_int(par4, 0, 3), 2);
	world.func_147453_f(par1, par2, par3, this);
    }


/**
 * If this returns true, then comparators facing away from this block will use the value from
 * getComparatorInputOverride instead of the actual redstone signal strength.
 */
public boolean hasComparatorInputOverride()
{
	return true;
}

/**
 * If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
 * strength when this block inputs to a comparator.
 */
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
{
	int i1 = par1World.getBlockMetadata(par2, par3, par4);
	return func_111045_h_(i1);
}

public static int func_111045_h_(int par0)
{
	return par0;
}

@SideOnly(Side.CLIENT)
    public static float getRenderLiquidLevel(int p_150025_0_)
    {
        int j = MathHelper.clamp_int(p_150025_0_, 0, 3);
        return (float)(6 + 3 * j) / 16.0F;
    }

}

Coding, Testing, Smiling, Publishing!

Posted

getRenderBlockPass must be getRenderType.

The getRenderBlockPass only determines if the block texture should render as solid (return 0) or with transparency (return 1)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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.