Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
Да не, 3D блока иль че у тебя там xDMinebot написал(а):Рендер, чего? GUI?
Ну так, а вообще чекни TileEntityChest, полностью скопировав его.Minebot написал(а):Ааа, я понял. Эта же фигня от форджа для 1.6.4 походу. У меня для 1.8.9. Это значит не надо что ли. Там рендер предметов по другому делается
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot)
{
ItemStack previous = null;
Slot slot = (Slot) this.inventorySlots.get(fromSlot);
if (slot != null && slot.getHasStack()) {
ItemStack current = slot.getStack();
previous = current.copy();
if (fromSlot < 6) {
if (!this.mergeItemStack(current, 5, 45, true))
return null;
} else {
if (!this.mergeItemStack(current, 0, 5, false))
return null;
}
if (current.stackSize == 0)
slot.putStack((ItemStack) null);
else
slot.onSlotChanged();
if (current.stackSize == previous.stackSize)
return null;
slot.onPickupFromSlot(playerIn, current);
}
return previous;
}
Ну, слоты, че еще сказать.Minebot написал(а):Хах) Ну так есть вторая ошибка. Когда ложу 1 предмет в контейнер, он удваивается и если я попытаюсь его вытащить, то он исчезает
package com.minebot.statics.gui;
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.IChatComponent;
public class TileEntityMagnet extends TileEntity implements IInventory
{
private String customName;
private ItemStack[] inv;
public TileEntityMagnet(){ inv = new ItemStack[5]; }
@Override
public String getName() {
return "gui.tileentitymagnet";
}
@Override
public boolean hasCustomName() {
return true;
}
@Override
public IChatComponent getDisplayName() {
// TODO Auto-generated method stub
return null;
}
@Override
public int getSizeInventory() {
return inv.length;
}
@Override
public ItemStack getStackInSlot(int index) {
return inv[index];
}
@Override
public ItemStack decrStackSize(int index, int count) {
if (this.inv[index] != null)
{
if (this.inv[index].stackSize <= count)
{
ItemStack itemstack1 = this.inv[index];
this.inv[index] = null;
this.markDirty();
return itemstack1;
}
else
{
ItemStack itemstack = this.inv[index].splitStack(count);
if (this.inv[index].stackSize == 0)
{
this.inv[index] = null;
}
this.markDirty();
return itemstack;
}
}
else
{
return null;
}
}
@Override
public ItemStack removeStackFromSlot(int index) {
if (this.inv[index] != null)
{
ItemStack itemstack = this.inv[index];
this.inv[index] = null;
return itemstack;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int index, ItemStack stack) {
this.inv[index] = stack;
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
{
stack.stackSize = this.getInventoryStackLimit();
}
this.markDirty();
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return true;
}
@Override
public void openInventory(EntityPlayer player) {
}
@Override
public void closeInventory(EntityPlayer player) {
}
@Override
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("Items", 10);
this.inv = new ItemStack[this.getSizeInventory()];
if (compound.hasKey("CustomName", 8))
{
this.customName = compound.getString("CustomName");
}
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound.getByte("Slot") & 255;
if (j >= 0 && j < this.inv.length)
{
this.inv[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
}
}
}
@Override
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.inv.length; ++i)
{
if (this.inv[i] != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.inv[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
if (this.hasCustomName())
{
compound.setString("CustomName", this.customName);
}
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
return false;
}
@Override
public int getField(int id) {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setField(int id, int value) {
// TODO Auto-generated method stub
}
@Override
public int getFieldCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void clear() {
}
}