Jump to content

Recommended Posts

Posted

I want to get the coords of it from within it's own class file. I can get the coords in my renderer for whatever reason, but not in the tile entity's class.

 

TE

 

package mods.mine_modus.Tileentities;

 

import org.lwjgl.opengl.GL11;

 

import mods.mine_modus.Client.ClientProxy;

import mods.mine_modus.Client.Quantum_Materializer_TE_Renderer;

import net.minecraft.client.renderer.tileentity.TileEntityRenderer;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.IInventory;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.nbt.NBTTagList;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

 

public class Quantum_Materializer_TE extends TileEntity implements IInventory, mods.mine_modus.IShareItemStackTE {

 

        private ItemStack[] inv;

 

        public Quantum_Materializer_TE(){

       

                inv = new ItemStack[1];

        }

        @Override

        public int getSizeInventory() {

                return inv.length;

        }

 

        @Override

        public ItemStack getStackInSlot(int slot) { 

        return inv[slot];

        }

       

        @Override

        public void setInventorySlotContents(int slot, ItemStack stack) {

                inv[slot] = stack;

                if (stack != null && stack.stackSize > getInventoryStackLimit()) {

                        stack.stackSize = getInventoryStackLimit();

                }             

        }

 

        @Override

        public ItemStack decrStackSize(int slot, int amt) {

                ItemStack stack = getStackInSlot(slot);

                if (stack != null) {

                        if (stack.stackSize <= amt) {

                                setInventorySlotContents(slot, null);

                        } else {

                                stack = stack.splitStack(amt);

                                if (stack.stackSize == 0) {

                                        setInventorySlotContents(slot, null);

                                }

                        }

                }

                return stack;

        }

 

        @Override

        public ItemStack getStackInSlotOnClosing(int slot) {

                ItemStack stack = getStackInSlot(slot);

                if (stack != null) {

                        setInventorySlotContents(slot, null);

                }

                return stack;

        }

       

        public int getInventoryStackLimit() {

                return 8192;

        }

 

        @Override

        public boolean isUseableByPlayer(EntityPlayer player) {

                return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this &&

                player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;

        }

 

        @Override

        public void openChest() {}

 

        @Override

        public void closeChest() {}

       

        @Override

        public void readFromNBT(NBTTagCompound tagCompound) {

                super.readFromNBT(tagCompound);

               

                NBTTagList tagList = tagCompound.getTagList("Inventory");

                for (int i = 0; i < tagList.tagCount(); i++) {

                        NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i);

                        byte slot = tag.getByte("Slot");

                        if (slot >= 0 && slot < inv.length) {

                                inv[slot] = ItemStack.loadItemStackFromNBT(tag);

                        }

                }

        }

 

        @Override

        public void writeToNBT(NBTTagCompound tagCompound) {

                super.writeToNBT(tagCompound);

                               

                NBTTagList itemList = new NBTTagList();

                for (int i = 0; i < inv.length; i++) {

                        ItemStack stack = inv;

                        if (stack != null) {

                                NBTTagCompound tag = new NBTTagCompound();

                                tag.setByte("Slot", (byte) i);

                                stack.writeToNBT(tag);

                                itemList.appendTag(tag);

                        }

                }

                tagCompound.setTag("Inventory", itemList);

        }

 

                @Override

                public String getInvName() {

                        return "mod.vtsman_hodgecraft.shelfTE";

                }

 

public boolean func_94042_c() {

// TODO Auto-generated method stub

return false;

}

public boolean func_94041_b(int i, ItemStack itemstack) {

// TODO Auto-generated method stub

return false;

}

 

@Override

public boolean isInvNameLocalized() {

// TODO Auto-generated method stub

return false;

}

 

@Override

public boolean isStackValidForSlot(int i, ItemStack itemstack) {

// TODO Auto-generated method stub

return true;

}

 

    /**

    * Writes a tile entity to NBT.

    */

 

@Override

public void getStack(int x, int y, int z, Quantum_Materializer_TE_Renderer renderer) {

 

System.out.println(x);

System.out.println("this" + this.xCoord);

if(x == this.xCoord && y == this.yCoord && z == this.zCoord){

System.out.println("2");

renderer.stack = this.getStackInSlot(0);

}

}

 

}

 

 

 

Renderer

 

 

package mods.mine_modus.Client;

 

import mods.mine_modus.BlockApis;

import mods.mine_modus.IShareItemStackTE;

import mods.mine_modus.Tileentities.Quantum_Materializer_TE;

import net.minecraft.block.Block;

import net.minecraft.client.gui.FontRenderer;

import net.minecraft.client.renderer.entity.RenderItem;

import net.minecraft.client.renderer.entity.RenderManager;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.inventory.IInventory;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

 

import org.lwjgl.opengl.GL11;

import java.io.IOException;

import java.io.InputStream;

import java.util.Random;

 

import javax.management.JMX;

 

public class Quantum_Materializer_TE_Renderer extends TileEntitySpecialRenderer implements IShareItemStackTE{

RenderItem renderitem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);

private Quantum_Materializer_model model;

public Quantum_Materializer_TE_Renderer(){

model = new Quantum_Materializer_model();

}

public ItemStack stack;

static Class<Quantum_Materializer_TE> TE = Quantum_Materializer_TE.class;

public ItemStack getTEStack(TileEntity tile){

//TE = (Quantum_Materializer_TE) tile;

TE.cast(new Quantum_Materializer_TE()).getStack(tile.xCoord, tile.yCoord, tile.zCoord, this);

return stack;

}

public void renderAModelAt(Quantum_Materializer_TE tile, double d, double d1, double d2, float f) {

 

int rotation = 0;

if(tile.worldObj != null)

{

rotation = tile.getBlockMetadata();

}

bindTextureByName("/mods/mine_modus/Quantum Materialize.png"); //texture

GL11.glPushMatrix();

GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F);

GL11.glScalef(1.0F, -1F, -1F);

GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F);

model.renderAll();

GL11.glPopMatrix(); //end

}

 

 

public int id = 0;

 

 

@Override

public void renderTileEntityAt(TileEntity tileentity, double d0, double d1,

double d2, float f) {

EntityItem entityitem = new EntityItem(null);

Quantum_Materializer_TE TE = (Quantum_Materializer_TE)tileentity;

    entityitem.worldObj = TE.worldObj;

    entityitem.age = 0;

    entityitem.rotationYaw = (float)(0.0D);

    entityitem.lifespan = 100;

   

 

  // this.entityitem.setPosition((double)d0, (double)d1, (double)d2);

    entityitem.hoverStart = 2.0F;

  BlockApis b = new BlockApis();

this.renderAModelAt(TE, d0, d1, d2, f);

 

   

entityitem.setEntityItemStack(new ItemStack(Block.blockRedstone, 1));

GL11.glTranslated(d0 + 0.5d, d1 + 0.25D, d2+ 0.5d);

 

System.out.println(getTEStack(tileentity));

if(d0 != 0.0d && d1 != 0.0d && d2 != 0.0d){

 

if(TE.getStackInSlot(0) != null){

entityitem.setEntityItemStack(new ItemStack(b.getBlock(TE.getStackInSlot(0).itemID), 1));

 

renderitem.doRenderItem(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);

}

}

GL11.glScaled(1.0D / 1, 1.0D / 1, 1.0D / 1);

GL11.glTranslated(-1 * (d0 + 0.5d), (d1 + 0.25D) * -1, -1 * (d2+ 0.5d));

 

}

 

@Override

public void getStack(int x, int y, int z, Quantum_Materializer_TE_Renderer renderer) {

 

}

 

 

}

 

 

Posted
this.posX;

?

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.

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.