Baubles

Baubles

116M Downloads

Render bauble via capabilities

Zeitheron opened this issue ยท 0 comments

commented

My idea here is to add support to call IBaubleRender through ItemStack's capability.

Here is the modified dispatchRenders method that I quickly wrote:

private void dispatchRenders(IBaublesItemHandler inv, EntityPlayer player, RenderType type, float partialTicks) {
	for(int i = 0; i < inv.getSlots(); i++) {
		ItemStack stack = inv.getStackInSlot(i);
		if(stack != null && !stack.isEmpty()) {
			Item item = stack.getItem();
			IRenderBauble render = null;
			if(item instanceof IRenderBauble)
				render = (IRenderBauble) item;
			else if(stack.hasCapability(BaublesCapabilities.CAPABILITY_ITEM_BAUBLE, null)) {
				IBauble bauble = stack.getCapability(BaublesCapabilities.CAPABILITY_ITEM_BAUBLE, null);
				if(bauble instanceof IRenderBauble)
					render = (IRenderBauble) bauble;
			}
			if(render != null) {
				GlStateManager.pushMatrix();
				GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
				GlStateManager.color(1F, 1F, 1F, 1F);
				render.onPlayerBaubleRender(stack, player, type, partialTicks);
				GlStateManager.popMatrix();
			}
		}
	}
}

I will implement capability rendering on my side for time being, but implementing this would GREATLY improve bauble abilities for developers!

Thanks in advance! ^=^