Ребят, не могу понять, как поставить текстуру для Enitity у сундука.
Понимаю, что просить глупо, но все же попытаюсь.
Можете объяснить как привязать текстуру?
Если что, то да. Я идиот. Ванильный код смотрел, вроде суть понял, но хотелось бы убедиться.
Понимаю, что просить глупо, но все же попытаюсь.
Можете объяснить как привязать текстуру?
Код:
package assets.testmod.src;
import net.minecraft.entity.Entity;
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.util.ResourceLocation;
public class TileEntityStorage extends TileEntity implements IInventory
{
private ItemStack[] items = new ItemStack[15];
public int getSizeInventory()
{
return items.length;
}
public ItemStack getStackInSlot(int slot)
{
return items[slot];
}
public ItemStack decrStackSize(int slot, int amount)
{
if (items[slot] != null)
{
ItemStack itemstack;
if (items[slot].stackSize == amount)
{
itemstack = items[slot];
items[slot] = null;
onInventoryChanged();
return itemstack;
}
else
{
itemstack = items[slot].splitStack(amount);
if (items[slot].stackSize == 0)
{
items[slot] = null;
}
onInventoryChanged();
return itemstack;
}
}
else
{
return null;
}
}
public ItemStack getStackInSlotOnClosing(int slot)
{
if (items[slot] != null)
{
ItemStack itemstack = items[slot];
items[slot] = null;
return itemstack;
}
else
{
return null;
}
}
public void setInventorySlotContents(int slot, ItemStack stack)
{
items[slot] = stack;
if (stack != null && stack.stackSize > getInventoryStackLimit())
{
stack.stackSize = getInventoryStackLimit();
}
onInventoryChanged();
}
public String getInventoryName()
{
return "container.storage";
}
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
NBTTagList list = nbt.getTagList("Items");
items = new ItemStack[getSizeInventory()];
for (int i = 0; i < list.tagCount(); ++i)
{
NBTTagCompound comp = (NBTTagCompound)list.tagAt(i);
int j = comp.getByte("Slot") & 255;
if (j >= 0 && j < items.length)
{
items[j] = ItemStack.loadItemStackFromNBT(comp);
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
NBTTagList list = new NBTTagList();
for (int i = 0; i < items.length; ++i)
{
if (items[i] != null)
{
NBTTagCompound comp = new NBTTagCompound();
comp.setByte("Slot", (byte)i);
items[i].writeToNBT(comp);
list.appendTag(comp);
}
}
nbt.setTag("Items", list);
}
public int getInventoryStackLimit()
{
return 64;
}
public boolean isUseableByPlayer(EntityPlayer player)
{
return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this ? false : player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64.0D;
}
public void openInventory() {}
public void closeInventory() {}
public boolean isItemValidForSlot(int slot, ItemStack stack)
{
return true;
}
@Override
public String getInvName()
{
return null;
}
@Override
public boolean isInvNameLocalized()
{
return false;
}
@Override
public void openChest()
{
}
@Override
public void closeChest()
{
}
}
Если что, то да. Я идиот. Ванильный код смотрел, вроде суть понял, но хотелось бы убедиться.