Jump to content

Recommended Posts

Posted

Hey guys,

 

I fixed the original texture bug now, but my model wont rotate :( Any ideas?

 

 

package co.uk.silvania.city.tileentities;

import org.lwjgl.opengl.GL11;

import co.uk.silvania.city.FlenixCities;
import co.uk.silvania.city.client.models.ATMModel;
import co.uk.silvania.city.client.models.EscalatorModel;

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.resources.ResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;


public class TileEntityATMRenderer extends TileEntitySpecialRenderer {

private final ATMModel model;

public TileEntityATMRenderer() {
	this.model = new ATMModel();
}

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
	int i = te.getBlockMetadata();
	int meta = 180;

	if (i == 3) {
		meta = 0;
	}

	if (i == 5) {
		meta = 90;
	}

	if (i == 2) {
		meta = 180;
	}

	if (i == 4) {
		meta = 270;
	}

	GL11.glPushMatrix();
	Minecraft.getMinecraft().renderEngine.func_110577_a(new ResourceLocation("flenixcities", "textures/entities/atm.png"));
	GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
	GL11.glRotatef(meta, 0.0F, 1.0F, 0.0F);
	//GL11.glRotatef(((TileEntityBarrierEntity)tile).getRotationPivot()), 0.0F, 1.0F, 0.0F);
	GL11.glScalef(1.0F, -1F, -1F);
	this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
	GL11.glPopMatrix();
}

private void adjustLightFixture(World world, int i, int j, int k, Block block) {
	Tessellator tess = Tessellator.instance;
	float brightness = block.getBlockBrightness(world, i, j, k);
	int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
	int modulousModifier = skyLight % 65536;
	int divModifier = skyLight / 65536;
	tess.setColorOpaque_F(brightness, brightness, brightness);
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,  (float) modulousModifier,  divModifier);
}
}

 

 

package co.uk.silvania.city.tileentities;

import co.uk.silvania.city.FlenixCities;
import co.uk.silvania.city.items.ItemNote10;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class TileEntityATMBlock extends BlockContainer {


public TileEntityATMBlock(int id) {
	super(id, Material.iron);
	this.setCreativeTab(FlenixCities.tabEcon);
	this.setHardness(1.0F);
	this.setLightValue(0.5F);
}

@Override
public TileEntity createNewTileEntity(World world) {
	return new TileEntityATMEntity();
}

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


    @Override
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float j, float k, float l) {
    	TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
    	NBTTagCompound nbt = player.getEntityData();
    	if (player.getHeldItem() != null) {
    		if (player.getHeldItem().getItem() == FlenixCities.debitCard) {
    			player.addChatMessage("Your Balance is: " + nbt.getInteger("Balance"));
    			player.openGui(FlenixCities.instance, 0, world, x, y, z);
    		}
    	}
    	if (player.getHeldItem() != null) {
    		if (player.getHeldItem().getItem() == FlenixCities.note1000) {
    			nbt.setInteger("balance", (nbt.getInteger("Balance") + ItemNote10.moneyValue));
   				player.addChatMessage(ItemNote10.moneyValue + " Deposited! Your balance is now " + nbt.getInteger("balance"));
    		}
    	}
	return true;
    }

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

public boolean renderAsNormalBlock() {
	return false;
}

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4,
		EntityLiving par5EntityLiving, ItemStack par6ItemStack) {
	int var6 = MathHelper
			.floor_double(par5EntityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;

	if (var6 == 0) {
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 0);
	}

	if (var6 == 1) {
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 0);
	}

	if (var6 == 2) {
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 0);
	}

	if (var6 == 3) {
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 0);
	}
}	
}

 

Suddenly remembered there's a magical thing called a pumpkin I can look at. Fixed it now :D

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

Try this:

 

new ResourceLocation("flenixcities", "textures/entities/atm.png")

 

 

Out of the three things we have different I believe its your problem.

 

Other things:

Minecraft.getMinecraft()

FMLClientHandler.instance().getClient();

 

.renderEngine

.func_110434_K()

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.