Jump to content

Strange Item Rendering Glitch - Dark Blocks in Inventory


Reika

Recommended Posts

I used an online tutorial to accomplish what BuildCraft, Redpower, and other big mods do to render custom-modelled blocks as 3D items in the inventory, using the ItemRendering system...

...And it caused a very strange error. Blocks - and only full-cube "Render Type 0" blocks - in the inventory will, when under a cursor, in the hotbar, or when my custom creative inventory tab is open, render rather darker than normal. Even more strangely, if I disable the rendering of a few of my custom blocks (Fan, Shaft, and Bridge Emitter - see code), this restricts to only in my custom inventory tab.

vjgeN9Q.png

My ItemRenderer code:

public class ItemMachineRenderer implements IItemRenderer {

private ModelAC acModel;
private ModelAerosolizer aeroModel;
private ModelBevel bevelModel;
private ModelBridge bridgeModel;
private ModelClutch clutchModel;
private ModelCombustion combustionModel;
private ModelCompactor compactorModel;
private ModelDC dcModel;
private ModelExtractor extractorModel;
private ModelFan fanModel;
private ModelFlywheel flywheelModel;
private ModelGearbox gearModel;
private ModelGearbox16 gearModel16;
private ModelGearbox8 gearModel8;
private ModelGearbox4 gearModel4;
private ModelHRay rayModel;
private ModelLamp lampModel;
private ModelPulseFurnace pulseModel;
private ModelPump pumpModel;
private ModelReservoir reservoirModel;
private ModelShaft shaftModel;
private ModelShaftV shaftvModel;
private ModelSteam steamModel;

private int Renderid;
private int engineType;
private int metadata;
private float floatControl;
//public static final float cheatControl = -200F;

public ItemMachineRenderer(int id) {

	acModel = new ModelAC();
	aeroModel = new ModelAerosolizer();
	bevelModel = new ModelBevel();
	bridgeModel = new ModelBridge();
	clutchModel = new ModelClutch();
	combustionModel = new ModelCombustion();
	compactorModel = new ModelCompactor();
	dcModel = new ModelDC();
	extractorModel = new ModelExtractor();
	fanModel = new ModelFan();
	flywheelModel = new ModelFlywheel();
	gearModel = new ModelGearbox();
	gearModel16 = new ModelGearbox16();
	gearModel8 = new ModelGearbox8();
	gearModel4 = new ModelGearbox4();
	rayModel = new ModelHRay();
	lampModel = new ModelLamp();
	pulseModel = new ModelPulseFurnace();
	pumpModel = new ModelPump();
	reservoirModel = new ModelReservoir();
	shaftModel = new ModelShaft();
	shaftvModel = new ModelShaftV();
	steamModel = new ModelSteam();

	Renderid = id;
	if (id == 0) {

	}
	if (id ==  {
		switch(this.metadata/4) {
		case 0:
			floatControl = -1000;
		break;
		case 1:
			floatControl = -2000;
		break;
		case 2:
			floatControl = -3000;
		break;
		case 3:
			floatControl = -4000;
		break;
		}
	}
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	//this.metadata = item.getItemDamage();
	if (item.itemID == mod_RotaryCraft.fan.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.aerosolizer.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.engine.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.bridgeemitter.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.clutch.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.compactor.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.extractor.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.floodlight.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.flywheel.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.gbevel.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.gearbox.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.heatray.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.pulsejet.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.pump.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.reservoir.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.shaft.blockID)
		return true;
	if (item.itemID == mod_RotaryCraft.splitter.blockID)
		return true;
	return false;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
	if (type.equals(helper.BLOCK_3D))
		return false;
	return true;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	switch (Renderid) {
	case 0:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityEngine(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 1:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityAerosolizer(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 2:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityGearBevel(), 0.0D, -0.1D, 0.0D, 0.0F);
	break;
	case 3:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityBridgeEmitter(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 4:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityClutch(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 5:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityCompactor(), 0.0D, -0.1D, 0.0D, 0.0F);
	break;
	case 6:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityExtractor(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 7:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityFan(), 0.0D, -0.1D, 0.0D, 0.0F);
	break;
	case 8:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityFlywheel(), 0.0D, 0.0D, 0.0D, floatControl);
	break;
	case 9:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityGearbox(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 10:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityHeatRay(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 11:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityFloodlight(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 12:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityPulseFurnace(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 13:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityPump(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	case 14:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityReservoir(), 0.0D, -0.1D, 0.0D, 0.0F);
	break;
	case 15:
		TileEntityRenderer.instance.renderTileEntityAt(new TileEntityShaft(), 0.0D, 0.0D, 0.0D, 0.0F);
	break;
	}
}

 

And the relevant part of my ClientProxy:

	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.engine.blockID, new ItemMachineRenderer(0));

	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.aerosolizer.blockID, new ItemMachineRenderer(1));		
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.gbevel.blockID, new ItemMachineRenderer(2));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.bridgeemitter.blockID, new ItemMachineRenderer(3));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.clutch.blockID, new ItemMachineRenderer(4));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.compactor.blockID, new ItemMachineRenderer(5));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.extractor.blockID, new ItemMachineRenderer(6));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.fan.blockID, new ItemMachineRenderer(7));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.flywheel.blockID, new ItemMachineRenderer();
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.gearbox.blockID, new ItemMachineRenderer(9));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.heatray.blockID, new ItemMachineRenderer(10));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.floodlight.blockID, new ItemMachineRenderer(11));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.pulsejet.blockID, new ItemMachineRenderer(12));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.pump.blockID, new ItemMachineRenderer(13));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.reservoir.blockID, new ItemMachineRenderer(14));
	MinecraftForgeClient.registerItemRenderer(mod_RotaryCraft.shaft.blockID, new ItemMachineRenderer(15));

Link to comment
Share on other sites

OK...this is strange. I have not changed any of my rendering code (though I have added classes like new Tile Entities, new GUIs, and the like), but the behavior of my glitch changed. In the OP I said I could limit it to my custom creative tab by disabling 3 renders...now it is limited there even with the renders enabled...

 

This is an improvement, but HOW did it change itself?

Link to comment
Share on other sites

OK, it built and ran without error, but it also had no effect.

Sample code:

public class RenderHRay extends TileEntitySpecialRenderer
{
    /** The normal small chest model. */
    private ModelHRay HRayModel = new ModelHRay();

    /**
     * Renders the TileEntity for the position.
     */
    public void renderTileEntityHeatRayAt(TileEntityHeatRay par1TileEntity, double par2, double par4, double par6, float par8)
    {
        int var9;

        if (par1TileEntity.worldObj == null)
        {
            var9 = 0;
        }
        else
        {
            Block var10 = par1TileEntity.getBlockType();
            var9 = par1TileEntity.getBlockMetadata();

            if (var10 != null && var9 == 0)
            {
                //((BlockHRayBlock1)var10).unifyAdjacentChests(par1TileEntity.worldObj, par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord);
                var9 = par1TileEntity.getBlockMetadata();
            }
        }

        if (true)
        {
            ModelHRay var14;

            if (true)
            {
                var14 = this.HRayModel;
                this.bindTextureByName("/Reika/RotaryCraft/HRay.png");
            }

            GL11.glPushMatrix();
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glTranslatef((float)par2, (float)par4 + 2.0F, (float)par6 + 1.0F);
            GL11.glScalef(1.0F, -1.0F, -1.0F);
            GL11.glTranslatef(0.5F, 0.5F, 0.5F);
            int var11 = 0;	 //used to rotate the model about metadata
            
            if (par1TileEntity.worldObj != null) {
            
            switch(par1TileEntity.getBlockMetadata()) {
            case 0:
            	var11 = 0;
            break;
            case 1:
            	var11 = 180;
            break;
            case 2:
            	var11 = 270;
            break;
            case 3:
            	var11 = 90;
            break;
            }

            GL11.glRotatef((float)var11+90, 0.0F, 1.0F, 0.0F);
            }
            else {
            	GL11.glEnable(GL11.GL_LIGHTING);
            }
            
            //GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
            //float var12 = par1TileEntity.prevLidAngle + (par1TileEntity.lidAngle - par1TileEntity.prevLidAngle) * par8;
            float var13;/*

            var12 = 1.0F - var12;
            var12 = 1.0F - var12 * var12 * var12;*/
            var14.renderAll();
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }
    }

    public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
    {
        this.renderTileEntityHeatRayAt((TileEntityHeatRay)par1TileEntity, par2, par4, par6, par8);
    }
}

Link to comment
Share on other sites

  • 2 weeks later...

After some messing around, using Lighting Disable will fix the problem, but it also makes the blocks look completely wrong (they do not render the shading correctly, and look "overexposed").

Ncnqmrc.png

 

So ... does it fix the problem or not :D If it does, disable the lighting when rendering and enable it when you exit the scope.

Link to comment
Share on other sites

After some messing around, using Lighting Disable will fix the problem, but it also makes the blocks look completely wrong (they do not render the shading correctly, and look "overexposed").

Ncnqmrc.png

 

So ... does it fix the problem or not :D If it does, disable the lighting when rendering and enable it when you exit the scope.

That is what I did. Also, it does not fix blocks that are "under the cursor" (being moved between slots).

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

    • Bottle Cap Torque Tester: Ensuring Precision in Packaging Integrity In the packaging industry, ensuring that containers are securely sealed is paramount for maintaining product quality and safety. One of the most critical components in this process is the bottle cap, which must be tightened to a precise torque to prevent leaks, contamination, or damage. The Bottle Cap Torque Tester by Pacorr is a high-precision instrument designed to test the opening and closing torque of bottle caps, ensuring the integrity of packaging. Importance of Torque Testing for Bottle Caps Torque is the rotational force applied to tighten or loosen a cap on a bottle. Too much torque can cause the cap or the neck of the bottle to break, while too little torque can result in leaks or tampered products. This is especially important for industries like pharmaceuticals, beverages, cosmetics, and chemicals, where any packaging failure can lead to significant financial loss and harm to consumers. The Bottle Cap Torque Tester Price ensures that every cap is perfectly tightened to the desired specification, preventing such issues and guaranteeing the safety and quality of the product inside. Key Features of Pacorr's Bottle Cap Torque Tester High Precision Measurement: The tester is designed to provide highly accurate torque readings for both capping and uncapping, giving manufacturers confidence in their packaging processes. Versatility: It can accommodate a wide range of bottle sizes and cap types, making it suitable for various industries, including beverages, pharmaceuticals, cosmetics, and more. Easy Operation: With an intuitive design, this machine allows for quick and easy testing, reducing the time needed for quality control checks. Digital Display: The digital readout provides clear, precise torque values, ensuring consistency in testing and improving the accuracy of results. Data Logging: Many models come equipped with data logging capabilities, allowing manufacturers to store and analyze torque measurements for future reference and quality assurance. Benefits of Using the Bottle Cap Torque Tester Improved Product Quality: By ensuring that caps are tightened to the correct torque, manufacturers can prevent leaks and maintain product freshness and safety. Compliance with Industry Standards: The tester helps manufacturers meet industry-specific regulations and standards, ensuring that their products are safe for consumers. Cost Savings: Preventing packaging failures reduces waste and avoids costly recalls, ultimately saving the company money. Enhanced Brand Reputation: Consistent quality control enhances consumer trust in the product, fostering a stronger brand reputation in the market. Applications in Various Industries Pharmaceuticals: In the pharmaceutical industry, packaging must be tamper-proof to ensure product safety. The Bottle Cap Torque Tester ensures that child-resistant caps are securely fastened, complying with safety regulations. Beverages: For carbonated drinks, the correct torque ensures the pressure inside the bottle is maintained without leaking. This helps maintain the product's taste and quality until it reaches the consumer. Cosmetics: Packaging for beauty products often requires precise torque control to ensure that liquids or creams do not leak, preventing product waste and enhancing the user experience. Food & Dairy: Food products need to be tightly sealed to maintain freshness. Incorrect torque can lead to spoilage and contamination, impacting the safety and quality of the food. Conclusion The Bottle Cap Torque Tester from Pacorr is an essential tool for industries where packaging integrity is critical. It helps manufacturers maintain high product quality, comply with regulations, and protect their brand reputation by ensuring that every bottle cap is perfectly sealed. Whether you're in the pharmaceutical, beverage, cosmetic, or food industry, the Bottle Cap Torque Tester is a must-have for efficient and accurate torque testing.
    • The mod is not exported,I'm writing the gradlew build command and it doesn't work. I'm doing the mod on macOS.
    • Asegúrate que tu mod sea de la misma versión que tu servidor si este mod no te funciona prueba otro https://www.curseforge.com/minecraft/search?class=mc-mods&page=1&pageSize=20&search=npc&sortBy=relevancy
    • https://modrinth.com/datapack/animated-doors https://www.spigotmc.org/resources/big-doors.58669/
  • Topics

×
×
  • Create New...

Important Information

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