I'm trying to do a simple chest just to understand how this work, and try make a backpack, but i'm trying to use a tutorials, but I'm stuck, my code is returning the getPos in color red, like a error, and Idk what to do, I'm so lost. code are unfinished. can please someone help-me? thanks <3
the error is here public boolean isUseableByPlayer
package me.network.archadia.tileentites;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.*;
public class TileEntityContainer extends TileEntity implements IInventory {
private ItemStack[] inventory;
private String customName;
public TileEntityContainer() {
this.inventory = new ItemStack[this.getSizeInventory()];
}
@Override
public int getSizeInventory() {
return 23;
}
@Override
public ItemStack getStackInSlot(int index) {
if(index < 0 || index >= this.getSizeInventory()){
return null;
}
return this.inventory[index];
}
@Override
public ItemStack decrStackSize(int index, int count) {
if (this.getStackInSlot(index) != null) {
ItemStack itemstack;
if (this.getStackInSlot(index).stackSize <= count) {
itemstack = this.getStackInSlot(index);
this.setInventorySlotContents(index, null);
this.markDirty();
return itemstack;
} else {
itemstack = this.getStackInSlot(index).splitStack(count);
if (this.getStackInSlot(index).stackSize <= 0) {
this.setInventorySlotContents(index, null);
} else {
this.setInventorySlotContents(index, this.getStackInSlot(index));
}
this.markDirty();
return itemstack;
}
} else {
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
return null;
}
@Override
public void setInventorySlotContents(int index, ItemStack stack)
{
if(index < 0 || index >= this.getSizeInventory())
{
return;
}
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
{
stack.stackSize = this.getInventoryStackLimit();
}
if(stack != null && stack.stackSize == 0)
{
stack = null;
}
this.inventory[index] = stack;
this.markDirty();
}
@Override
public String getInventoryName() {
return this.hasCustomInventoryName() ? this.customName : "container.tile_entity_container";
}
@Override
public boolean hasCustomInventoryName() {
return this.customName != null && !this.customName.equals("");
}
public IChatComponent getDisplayName()
{
return this.hasCustomInventoryName() ? new ChatComponentText(this.getInventoryName()) : new ChatComponentTranslation(this.getInventoryName());
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
//Getting the error here, in red>>>>>>>>>>>VVVVVVV and this is red too>>>VVV
return this.worldObj.getTileEntity(this.getPos()) == this && player.getDistanceSq(this.pos.add(0.5, 0.5, 0.5)) <= 64;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
return true;
}
public void clear()
{
for(int i =0; i < this.getInventoryStackLimit(); i++)
{
this.setInventorySlotContents(i, null);
}
}
}
I'm trying to do a simple chest just to understand how this work, and try make a backpack, but i'm trying to use a tutorials, but I'm stuck, my code is returning the getPos in color red, like a error, and Idk what to do, I'm so lost. code are unfinished. can please someone help-me? thanks <3
the error is here public boolean isUseableByPlayer
The
doesn't exist in 1.7.10Use xCoord, yCoord and zCoord.