Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

My Tile Entity is not correctly rendering on world load (should be rendered "EnderTeleportingStationModelF", instead "EnderTeleportingStationModel").

 

Block code:

 

package ru.pearx.largestuff.te;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import ru.pearx.largestuff.Main;

public class EnderTeleportingStation extends BlockContainer {
public EnderTeleportingStation(Material mat) {
	super(mat);
	setCreativeTab(Main.TabLargeStuff);
	setBlockName("enderTeleportingStation");
	setBlockBounds(0F, 0F, 0F, 1F, 0.2F, 1F);
	isBlockContainer = true;
}

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

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

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

@Override
public void registerBlockIcons(IIconRegister reg) {
	blockIcon = reg.registerIcon(Main.GetTextureName("EnderTeleportingStationIcon"));
}

@Override
public TileEntity createNewTileEntity(World w, int i) {
	return new EnderTeleportingStationEntity();
}

@Override
public void breakBlock(World w, int x, int y, int z, Block b, int i) {
	super.breakBlock(w, x, y, z, b, i);
	w.removeTileEntity(x, y, z);
}

@Override
public void randomDisplayTick(World w, int x, int y, int z, Random rand) {
	super.randomDisplayTick(w, x, y, z, rand);
	TileEntity te = w.getTileEntity(x, y, z);
	if (te instanceof EnderTeleportingStationEntity) {
		EnderTeleportingStationEntity ets = (EnderTeleportingStationEntity) te;
		if (ets.posY != -9999999) 
		{
			for (int i = 0; i < 100; i++) {
				w.spawnParticle("portal", x + 0.50000, y, z + 0.50000, 0, rand.nextFloat(), 0);
			}
		}
	}
}

@Override
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int i, float f, float f2, float f3) 
{
	TileEntity te = w.getTileEntity(x, y, z);
	if (te instanceof EnderTeleportingStationEntity) 
	{
		EnderTeleportingStationEntity ets = (EnderTeleportingStationEntity) te;
		if (ets.posY !=  -9999999) 
		{
			Main.proxy.Teleport(w, p, ets.dim, ets.posX, ets.posY, ets.posZ, "minecraft:mob.endermen.portal");
			return true;
		}
	}
	return false;
}
}

 

Tile Entity code:

 

package ru.pearx.largestuff.te;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;

public class EnderTeleportingStationEntity extends TileEntity
{
public double posX;
public double posY =  -9999999;
public double posZ;
public int dim;

@Override
public void readFromNBT(NBTTagCompound tag) 
{
	System.out.println("read");
	super.readFromNBT(tag);
	this.posX = tag.getDouble("posX");
	this.posY = tag.getDouble("posY");
	this.posZ = tag.getDouble("posZ");
	this.dim = tag.getInteger("dim");
}
@Override
public void writeToNBT(NBTTagCompound tag) 
{
	super.writeToNBT(tag);
	tag.setDouble("posX", this.posX);
	tag.setDouble("posY", this.posY);
	tag.setDouble("posZ", this.posZ);
	tag.setInteger("dim", this.dim);
}
}

 

Model code:

 

package ru.pearx.largestuff.te;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class EnderTeleportingStationModel extends ModelBase
{
  //fields
    ModelRenderer Base;
    ModelRenderer Oneborder;
    ModelRenderer Twoborder;
    ModelRenderer Threeborder;
    ModelRenderer Fourborder;
    ModelRenderer Mechhandone;
    ModelRenderer Mechhandtwo;
    ModelRenderer Mechhandthree;
    ModelRenderer Mechhandfour;
    ModelRenderer Mechhand2one;
    ModelRenderer Mechhand2two;
    ModelRenderer Mechhand2three;
    ModelRenderer Mechhand2four;
  
  public EnderTeleportingStationModel()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      Base = new ModelRenderer(this, 0, 0);
      Base.addBox(0F, 0F, 0F, 16, 1, 16);
      Base.setRotationPoint(-8F, 23F, -8F);
      Base.setTextureSize(64, 64);
      Base.mirror = true;
      setRotation(Base, 0F, 0F, 0F);
      Oneborder = new ModelRenderer(this, 0, 17);
      Oneborder.addBox(0F, 0F, 0F, 4, 1, 1);
      Oneborder.setRotationPoint(-2F, 22F, -3F);
      Oneborder.setTextureSize(64, 64);
      Oneborder.mirror = true;
      setRotation(Oneborder, 0F, 0F, 0F);
      Twoborder = new ModelRenderer(this, 10, 17);
      Twoborder.addBox(0F, 0F, 0F, 4, 1, 1);
      Twoborder.setRotationPoint(-2F, 22F, 2F);
      Twoborder.setTextureSize(64, 64);
      Twoborder.mirror = true;
      setRotation(Twoborder, 0F, 0F, 0F);
      Threeborder = new ModelRenderer(this, 20, 17);
      Threeborder.addBox(0F, 0F, 0F, 1, 1, 4);
      Threeborder.setRotationPoint(-3F, 22F, -2F);
      Threeborder.setTextureSize(64, 64);
      Threeborder.mirror = true;
      setRotation(Threeborder, 0F, 0F, 0F);
      Fourborder = new ModelRenderer(this, 30, 17);
      Fourborder.addBox(0F, 0F, 0F, 1, 1, 4);
      Fourborder.setRotationPoint(2F, 22F, -2F);
      Fourborder.setTextureSize(64, 64);
      Fourborder.mirror = true;
      setRotation(Fourborder, 0F, 0F, 0F);
      Mechhandone = new ModelRenderer(this, 0, 19);
      Mechhandone.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhandone.setRotationPoint(-10F, 14F, -10F);
      Mechhandone.setTextureSize(64, 64);
      Mechhandone.mirror = true;
      setRotation(Mechhandone, 0.1745329F, 0F, -0.1745329F);
      Mechhandtwo = new ModelRenderer(this, 4, 19);
      Mechhandtwo.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhandtwo.setRotationPoint(-10F, 14F, 9F);
      Mechhandtwo.setTextureSize(64, 64);
      Mechhandtwo.mirror = true;
      setRotation(Mechhandtwo, -0.1745329F, 0F, -0.1745329F);
      Mechhandthree = new ModelRenderer(this, 4, 19);
      Mechhandthree.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhandthree.setRotationPoint(9F, 14F, 9F);
      Mechhandthree.setTextureSize(64, 64);
      Mechhandthree.mirror = true;
      setRotation(Mechhandthree, -0.1745329F, 0F, 0.1745329F);
      Mechhandfour = new ModelRenderer(this, 4, 19);
      Mechhandfour.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhandfour.setRotationPoint(9F, 14F, -10F);
      Mechhandfour.setTextureSize(64, 64);
      Mechhandfour.mirror = true;
      setRotation(Mechhandfour, 0.1745329F, 0F, 0.1745329F);
      Mechhand2one = new ModelRenderer(this, 0, 19);
      Mechhand2one.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhand2one.setRotationPoint(-8F, 4.5F, -8F);
      Mechhand2one.setTextureSize(64, 64);
      Mechhand2one.mirror = true;
      setRotation(Mechhand2one, -0.1745329F, 0F, 0.1745329F);
      Mechhand2two = new ModelRenderer(this, 1, 19);
      Mechhand2two.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhand2two.setRotationPoint(-8F, 4.5F, 7F);
      Mechhand2two.setTextureSize(64, 64);
      Mechhand2two.mirror = true;
      setRotation(Mechhand2two, 0.1745329F, 0F, 0.1745329F);
      Mechhand2three = new ModelRenderer(this, 1, 19);
      Mechhand2three.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhand2three.setRotationPoint(7F, 4.5F, 7F);
      Mechhand2three.setTextureSize(64, 64);
      Mechhand2three.mirror = true;
      setRotation(Mechhand2three, 0.1745329F, 0F, -0.1745329F);
      Mechhand2four = new ModelRenderer(this, 1, 19);
      Mechhand2four.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhand2four.setRotationPoint(7F, 4.5F, -8F);
      Mechhand2four.setTextureSize(64, 64);
      Mechhand2four.mirror = true;
      setRotation(Mechhand2four, -0.1745329F, 0F, -0.1745329F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    Base.render(f5);
    Oneborder.render(f5);
    Twoborder.render(f5);
    Threeborder.render(f5);
    Fourborder.render(f5);
    Mechhandone.render(f5);
    Mechhandtwo.render(f5);
    Mechhandthree.render(f5);
    Mechhandfour.render(f5);
    Mechhand2one.render(f5);
    Mechhand2two.render(f5);
    Mechhand2three.render(f5);
    Mechhand2four.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
  }

}

 

Model 2 code:

 

package ru.pearx.largestuff.te;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class EnderTeleportingStationModelF extends ModelBase
{
  //fields
    ModelRenderer Base;
    ModelRenderer Oneborder;
    ModelRenderer Twoborder;
    ModelRenderer Threeborder;
    ModelRenderer Fourborder;
    ModelRenderer Mechhandone;
    ModelRenderer Mechhandtwo;
    ModelRenderer Mechhandthree;
    ModelRenderer Mechhandfour;
    ModelRenderer Focus;
    ModelRenderer Mechhand2one;
    ModelRenderer Mechhand2two;
    ModelRenderer Mechhand2three;
    ModelRenderer Mechhand2four;
  
  public EnderTeleportingStationModelF()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      Base = new ModelRenderer(this, 0, 0);
      Base.addBox(0F, 0F, 0F, 16, 1, 16);
      Base.setRotationPoint(-8F, 23F, -8F);
      Base.setTextureSize(64, 64);
      Base.mirror = true;
      setRotation(Base, 0F, 0F, 0F);
      Oneborder = new ModelRenderer(this, 0, 17);
      Oneborder.addBox(0F, 0F, 0F, 4, 1, 1);
      Oneborder.setRotationPoint(-2F, 22F, -3F);
      Oneborder.setTextureSize(64, 64);
      Oneborder.mirror = true;
      setRotation(Oneborder, 0F, 0F, 0F);
      Twoborder = new ModelRenderer(this, 10, 17);
      Twoborder.addBox(0F, 0F, 0F, 4, 1, 1);
      Twoborder.setRotationPoint(-2F, 22F, 2F);
      Twoborder.setTextureSize(64, 64);
      Twoborder.mirror = true;
      setRotation(Twoborder, 0F, 0F, 0F);
      Threeborder = new ModelRenderer(this, 20, 17);
      Threeborder.addBox(0F, 0F, 0F, 1, 1, 4);
      Threeborder.setRotationPoint(-3F, 22F, -2F);
      Threeborder.setTextureSize(64, 64);
      Threeborder.mirror = true;
      setRotation(Threeborder, 0F, 0F, 0F);
      Fourborder = new ModelRenderer(this, 30, 17);
      Fourborder.addBox(0F, 0F, 0F, 1, 1, 4);
      Fourborder.setRotationPoint(2F, 22F, -2F);
      Fourborder.setTextureSize(64, 64);
      Fourborder.mirror = true;
      setRotation(Fourborder, 0F, 0F, 0F);
      Mechhandone = new ModelRenderer(this, 0, 19);
      Mechhandone.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhandone.setRotationPoint(-10F, 14F, -10F);
      Mechhandone.setTextureSize(64, 64);
      Mechhandone.mirror = true;
      setRotation(Mechhandone, 0.1745329F, 0F, -0.1745329F);
      Mechhandtwo = new ModelRenderer(this, 4, 19);
      Mechhandtwo.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhandtwo.setRotationPoint(-10F, 14F, 9F);
      Mechhandtwo.setTextureSize(64, 64);
      Mechhandtwo.mirror = true;
      setRotation(Mechhandtwo, -0.1745329F, 0F, -0.1745329F);
      Mechhandthree = new ModelRenderer(this, 4, 19);
      Mechhandthree.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhandthree.setRotationPoint(9F, 14F, 9F);
      Mechhandthree.setTextureSize(64, 64);
      Mechhandthree.mirror = true;
      setRotation(Mechhandthree, -0.1745329F, 0F, 0.1745329F);
      Mechhandfour = new ModelRenderer(this, 4, 19);
      Mechhandfour.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhandfour.setRotationPoint(9F, 14F, -10F);
      Mechhandfour.setTextureSize(64, 64);
      Mechhandfour.mirror = true;
      setRotation(Mechhandfour, 0.1745329F, 0F, 0.1745329F);
      Focus = new ModelRenderer(this, 0, 30);
      Focus.addBox(0F, 0F, 0F, 4, 1, 4);
      Focus.setRotationPoint(-2F, 22F, -2F);
      Focus.setTextureSize(64, 64);
      Focus.mirror = true;
      setRotation(Focus, 0F, 0F, 0F);
      Mechhand2one = new ModelRenderer(this, 0, 19);
      Mechhand2one.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhand2one.setRotationPoint(-8F, 4.5F, -8F);
      Mechhand2one.setTextureSize(64, 64);
      Mechhand2one.mirror = true;
      setRotation(Mechhand2one, -0.1745329F, 0F, 0.1745329F);
      Mechhand2two = new ModelRenderer(this, 1, 19);
      Mechhand2two.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhand2two.setRotationPoint(-8F, 4.5F, 7F);
      Mechhand2two.setTextureSize(64, 64);
      Mechhand2two.mirror = true;
      setRotation(Mechhand2two, 0.1745329F, 0F, 0.1745329F);
      Mechhand2three = new ModelRenderer(this, 1, 19);
      Mechhand2three.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhand2three.setRotationPoint(7F, 4.5F, 7F);
      Mechhand2three.setTextureSize(64, 64);
      Mechhand2three.mirror = true;
      setRotation(Mechhand2three, 0.1745329F, 0F, -0.1745329F);
      Mechhand2four = new ModelRenderer(this, 1, 19);
      Mechhand2four.addBox(0F, 0F, 0F, 1, 10, 1);
      Mechhand2four.setRotationPoint(7F, 4.5F, -8F);
      Mechhand2four.setTextureSize(64, 64);
      Mechhand2four.mirror = true;
      setRotation(Mechhand2four, -0.1745329F, 0F, -0.1745329F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    Base.render(f5);
    Oneborder.render(f5);
    Twoborder.render(f5);
    Threeborder.render(f5);
    Fourborder.render(f5);
    Mechhandone.render(f5);
    Mechhandtwo.render(f5);
    Mechhandthree.render(f5);
    Mechhandfour.render(f5);
    Focus.render(f5);
    Mechhand2one.render(f5);
    Mechhand2two.render(f5);
    Mechhand2three.render(f5);
    Mechhand2four.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity e)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
  }

}

 

Render code:

 

package ru.pearx.largestuff.te;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import ru.pearx.largestuff.Main;

public class EnderTeleportingStationRender extends TileEntitySpecialRenderer
{
    private ModelBase model;
    @Override
    public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) 
    {
    	EnderTeleportingStationEntity ets = (EnderTeleportingStationEntity) te;
    	if(ets.posY != -9999999)
    		model = new EnderTeleportingStationModelF();
    	else
    		model = new EnderTeleportingStationModel();
        GL11.glPushMatrix();
        GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
        ResourceLocation textures = (new ResourceLocation(Main.GetTextureName("textures/blocks/EnderTeleportingStation.png")));
        Minecraft.getMinecraft().renderEngine.bindTexture(textures);                  
        GL11.glPushMatrix();
        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
        model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
    }
}

 

Model correctly render if "posY" variable changed in loaded game (ex. onItemUse).

___

Sorry for my bad English, I'm Russian.

  • Author

Solved. Sorry for the stupid issue.

Edited by mrAppleXZ

  • 4 years later...
Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.