Jump to content

1.7.10 problem with ligthing and rotation of slopes


leplopp

Recommended Posts

Hello

 

I have a problem with slopes in my mod.

 

I use a Blender .obj file in my Minecraft mod,
The block have a problem with the lighting, brightness.

The brightness of the block is wrong not as at a normal block.

I also have a problem with the rotation of the slopes. After each restart, the rotation of the slopes retruns to its default position.

 

here is a picture of the problem:

 

2017-05-06_13_52_44.thumb.png.420ed5f1336edaf6b36c8326ae7d0daa.png

 

 

and here is a picture in the Night:

 

2017-05-06_13_50_54.thumb.png.f8c393c7f69ae3563595e0bf0e8523bc.png

 

You can clearly see the problem in the picture.

What is wrong with the brigthness?

 

here is my Block code:

package mbm.blocks;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mbm.mbm;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;



	public class Blockroofs extends BlockContainer{
		


		public Blockroofs(Material material, int type) {
	        super(material);

	        this.setBlockName("Blockroof");
	        
	        
	    }
		
	    public boolean renderAsNormalBlock()
	    {
	        return false;
	    }

		@Override
	    public int getRenderType(){
	        return -1;
	    }

	    @Override
	    public boolean isOpaqueCube(){
	        return false;
	    }   
	    	
	    @Override
	    public boolean isBlockNormalCube() {
	    	return false;
	    }

	    @Override
	    public TileEntity createNewTileEntity(World world, int par2) {
	        return new TileEntityBlockroofs();
	    }
	    
	    @Override
	    public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack)
	    {
	    if (entity == null)
	    {
	    return;
	    }

	    TileEntityBlockroofs tile = (TileEntityBlockroofs) world.getTileEntity(x, y, z);
	    tile.direction = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
	    }
	    
	    @SideOnly(Side.CLIENT)
	    public void registerBlockIcons(IIconRegister iconRegister) {
	    this.blockIcon = iconRegister.registerIcon(mbm.MODID + ":" + this.getUnlocalizedName().substring(5));
	    }
	    
}

 

here is my TileEntity code:

 

package mbm.blocks;

import net.minecraft.tileentity.TileEntity;

public class TileEntityBlockroofs extends TileEntity {
	

    /* Rotation */
    public float rotation = 0;
   /* Scale */
   public float scale = 0;

   @Override
   public void updateEntity(){
       if (worldObj.isRemote) rotation = (float) 0.5;
      if (worldObj.isRemote) scale = (float) 0.5;
   }

public int direction;

}

 

here is my TileEntitySpecialRenderer code:

package mbm.blocks;

import org.lwjgl.opengl.GL11;

import mbm.mbm;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;

public class RenderTileEntityBlockroofs extends TileEntitySpecialRenderer{
	

	ResourceLocation texture;
	ResourceLocation objModelLocation;
	IModelCustom model;

	public RenderTileEntityBlockroofs(){
        texture = new ResourceLocation(mbm.MODID, "model/Blockroof.png");
        objModelLocation = new ResourceLocation(mbm.MODID, "model/Blockroof.obj"); // Blender .obj
        model = AdvancedModelLoader.loadModel(objModelLocation);
	}

	private void adjustRotatePivotViaMeta(World world, int x, int y, int z) {
		int meta = world.getBlockMetadata(x, y, z);
		GL11.glPushMatrix();
		GL11.glRotatef(meta * (+90), 0.0F, 0.0F, 1.0F);
		GL11.glPopMatrix();
		}

	@Override
    public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float timeSinceLastTick) {
		
		GL11.glPushMatrix();
	    
		GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
		this.bindTexture(texture);
		GL11.glRotatef(0F, 1.0F, 1.0F, 1.0F);

		GL11.glPushMatrix();
		TileEntityBlockroofs tile = (TileEntityBlockroofs) tileentity;
		int direction = tile.direction;
		GL11.glRotatef(direction * +90, 0.0F, 1.0F, 0.0F);
		
		GL11.glScaled(0.5, 0.5, 0.5);
		model.renderAll();
		GL11.glPopMatrix();
		GL11.glPopMatrix();
		
	}
	

}
	

 

here is my proxy code:

 

		TileEntitySpecialRenderer renderer = new RenderTileEntityBlockroofs();
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlockroofs.class, new RenderTileEntityBlockroofs());
        
        MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(mbm.Blockroof), new BlockitemRenderer(new TileEntityBlockroofs(), new 		  RenderTileEntityBlockroofs()));

 

here is my register in my mod:

 

//In the preinit

Blockroof = new Blockroofs(Material.iron, 0).setCreativeTab(mbmblocks).setBlockName("Blockroof");

//In the init

registerblocks();
  
//In the postinit
	
proxy.registermodells();
	
//In registerBlocks
  
private void registerblocks() {
	
GameRegistry.registerBlock(Blockroof, "Blockroof");
}

 

 

Thank you in advance^_^

 

 

Link to comment
Share on other sites

1.7.10 is no longer supported here.

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

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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