[1.7.10]-Сундук без своего гуи, стандартный но в моем моде

Как я понял в рендере надо указывать свою текстуру таким кодом
Код:
private static final ResourceLocation field_147504_g = new ResourceLocation("textures/entity/chest/IceChest.png");
Бинд текстуры
Код:
                else
                {
                    this.bindTexture(field_147504_g);

            
            
                modelchest = this.field_147511_i;
                
                
Уже несколько дней не могу решить эту проблему=(
Вот как это выглядит :
[merge_posts_bbcode]Добавлено: 16.12.2014 23:10:04[/merge_posts_bbcode]

:(
 
Ну... Ни чем помочь нельзя, если ни чего понять. Не понятно, как ты регистрируешь рендер для блока. (код блока, код главного файла и код клиент прокси [если он есть], рендер блока.)
 
Код:
private static final ResourceLocation field_147504_g = new ResourceLocation("textures/entity/chest/IceChest.png");
Во-первых, название переменной может быть любым.
Во-вторых, не правильно ты понял. Надо так:
Код:
private static final ResourceLocation field_147504_g = new ResourceLocation("modid", "textures/entity/chest/IceChest.png");[size=2]
Таким образом текстура должна лежать в assets/modid/textures/entity/chest и называться IceChest
и быть в формате .png
 
Что не так?
Код:
package ua.IceJuice.manual.render;

import java.util.Calendar;

import net.minecraft.block.Block;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.model.ModelLargeChest;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import ua.IceJuice.manual.blocks.IceChest;
import ua.IceJuice.manual.entity.TileEntityIceChest;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class IceChestRenderer extends TileEntitySpecialRenderer
{
    
    private static final ResourceLocation field_147504_g = new ResourceLocation("Twilight_Tundra:texture/entity/chest/IceChest.png");
    private ModelChest field_147510_h = new ModelChest();
    private ModelChest field_147511_i = new ModelLargeChest();
    private boolean field_147509_j;

    public IceChestRenderer()
    {
        Calendar calendar = Calendar.getInstance();

        if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26)
        {
            this.field_147509_j = true;
        }
    }

    public void renderTileEntityAt(TileEntityIceChest p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_)
    {
        int i;

        if (!p_147500_1_.hasWorldObj())
        {
            i = 0;
        }
        else
        {
            Block block = p_147500_1_.getBlockType();
            i = p_147500_1_.getBlockMetadata();

            if (block instanceof IceChest && i == 0)
            {
                try
                {
                ((IceChest)block).func_149954_e(p_147500_1_.getWorldObj(), p_147500_1_.xCoord, p_147500_1_.yCoord, p_147500_1_.zCoord);
                }
                catch (ClassCastException e)
                {
                    FMLLog.severe("Attempted to render a chest at %d,  %d, %d that was not a chest", p_147500_1_.xCoord, p_147500_1_.yCoord, p_147500_1_.zCoord);
                }
                i = p_147500_1_.getBlockMetadata();
            }

            p_147500_1_.checkForAdjacentChests();
        }

        if (p_147500_1_.adjacentChestZNeg == null && p_147500_1_.adjacentChestXNeg == null)
        {
            ModelChest modelchest;

            if (p_147500_1_.adjacentChestXPos == null && p_147500_1_.adjacentChestZPos == null)
            {
                modelchest = this.field_147510_h;}

                else
                {
                    this.bindTexture(field_147504_g);

            
            
                modelchest = this.field_147511_i;
                
                    
                
            }
                

            GL11.glPushMatrix();
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glTranslatef((float)p_147500_2_, (float)p_147500_4_ + 1.0F, (float)p_147500_6_ + 1.0F);
            GL11.glScalef(1.0F, -1.0F, -1.0F);
            GL11.glTranslatef(0.5F, 0.5F, 0.5F);
            short short1 = 0;

            if (i == 2)
            {
                short1 = 180;
            }

            if (i == 3)
            {
                short1 = 0;
            }

            if (i == 4)
            {
                short1 = 90;
            }

            if (i == 5)
            {
                short1 = -90;
            }

            if (i == 2 && p_147500_1_.adjacentChestXPos != null)
            {
                GL11.glTranslatef(1.0F, 0.0F, 0.0F);
            }

            if (i == 5 && p_147500_1_.adjacentChestZPos != null)
            {
                GL11.glTranslatef(0.0F, 0.0F, -1.0F);
            }

            GL11.glRotatef((float)short1, 0.0F, 1.0F, 0.0F);
            GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
            float f1 = p_147500_1_.prevLidAngle + (p_147500_1_.lidAngle - p_147500_1_.prevLidAngle) * p_147500_8_;
            float f2;

            if (p_147500_1_.adjacentChestZNeg != null)
            {
                f2 = p_147500_1_.adjacentChestZNeg.prevLidAngle + (p_147500_1_.adjacentChestZNeg.lidAngle - p_147500_1_.adjacentChestZNeg.prevLidAngle) * p_147500_8_;

                if (f2 > f1)
                {
                    f1 = f2;
                }
            }

            if (p_147500_1_.adjacentChestXNeg != null)
            {
                f2 = p_147500_1_.adjacentChestXNeg.prevLidAngle + (p_147500_1_.adjacentChestXNeg.lidAngle - p_147500_1_.adjacentChestXNeg.prevLidAngle) * p_147500_8_;

                if (f2 > f1)
                {
                    f1 = f2;
                }
            }

            f1 = 1.0F - f1;
            f1 = 1.0F - f1 * f1 * f1;
            modelchest.chestLid.rotateAngleX = -(f1 * (float)Math.PI / 2.0F);
            modelchest.renderAll();
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            GL11.glPopMatrix();
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }
    }

    public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_)
    {
        this.renderTileEntityAt((TileEntityIceChest)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_);
    }
}


[merge_posts_bbcode]Добавлено: 18.12.2014 18:20:17[/merge_posts_bbcode]
 
Не там ставишь bindTexture для модели. Ты хоть сам понимаешь, что у тебя написано?
[merge_posts_bbcode]Добавлено: 18.12.2014 19:42:54[/merge_posts_bbcode]

Если конечно понимаешь, что ты написал. (я почти ни чего не понял.)
 
Попробуй поставить твой "this.bindTexture(field_147504_g);", перед (выше) твоим "modelchest.renderAll();". Чтобы понять, что у тебя написано, это нужно переделать твой код на понятный вид.
 
timaxa007 я сундук не когда не делал, делал по английскому тутору, сейчас попробую.
Код рендера я перепишу..
Нет, не работает, я буду переписывать.
 
Сундук сделан, с текстурой.Но появилась проблема, пропадают вещи при перезаходе из сундука , и перезаходе в мир
Что не так в коде?
Код:
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_)
        {
            if (this.chestContents[p_70298_1_] != null)
            {
                ItemStack itemstack;

                if (this.chestContents[p_70298_1_].stackSize <= p_70298_2_)
                {
                    itemstack = this.chestContents[p_70298_1_];
                    this.chestContents[p_70298_1_] = null;
                    this.markDirty();
                    return itemstack;
                }
                else
                {
                    itemstack = this.chestContents[p_70298_1_].splitStack(p_70298_2_);

                    if (this.chestContents[p_70298_1_].stackSize == 0)
                    {
                        this.chestContents[p_70298_1_] = null;
                    }

                    this.markDirty();
                    return itemstack;
                }
            }
            else
            {
                return null;
            }
        }
 
Возможно, несделал всё, чтобы сохранялись вещи в блоке. Подсказка: твой TileEntity.
 
timaxa007 написал(а):
Возможно, несделал всё, чтобы сохранялись вещи в блоке. Подсказка: твой TileEntity.
Я дал код, при перезаходе все пропадает, а так уже все хорошо.
Главное то, что именно эта проблема очень "неловкая".
[merge_posts_bbcode]Добавлено: 19.12.2014 21:34:33[/merge_posts_bbcode]
Сейчас роюсь ищу что не так сделал..Не могу понять, вроде все правильно..
"ТайлЕнтити"
 
Ты дал, только часть кода. Где "readFromNBT" и "writeToNBT", и вроде ещё нужно "getDescriptionPacket" и "onDataPacket"?
 
Всё пропадает при перезаходе т.к. ты не сохраняешь и не считываешь NBT.
 
[font=Verdana, Helvetica, Arial, sans-serif]timaxa007, [/font]
Код:
public class TileEntityIceChest extends TileEntityChest{
    
    
    
    private int cachedChestType;
    private ItemStack[] chestContents = new ItemStack[36];
    private String customName;

    public TileEntityIceChest(int p_i45397_1_) {
        super(p_i45397_1_);
        
    }
        
         public TileEntityIceChest adjacentChestZNeg;
        /** Contains the chest tile located adjacent to this one (if any) */
        public TileEntityIceChest adjacentChestXPos;
        /** Contains the chest tile located adjacent to this one (if any) */
        public TileEntityIceChest adjacentChestXNeg;
        /** Contains the chest tile located adjacent to this one (if any) */
        public TileEntityIceChest adjacentChestZPos;
        
        /**
         * Returns the name of the inventory
         */
        public String getInventoryName()
        {
            return this.hasCustomInventoryName() ? this.customName : "Ice Chest";
        }
        
        /**
         * Returns if the inventory is named
         */
        public boolean hasCustomInventoryName()
        {
            return this.customName != null && this.customName.length() > 0;
        }

        public void func_145976_a(String p_145976_1_)
        {
            this.customName = p_145976_1_;
        }
        
        public void readFromNBT(NBTTagCompound p_145839_1_)
        {
            super.readFromNBT(p_145839_1_);
            NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10);
            this.chestContents = new ItemStack[this.getSizeInventory()];

            if (p_145839_1_.hasKey("CustomName", 8))
            {
                this.customName = p_145839_1_.getString("CustomName");
            }

            for (int i = 0; i < nbttaglist.tagCount(); ++i)
            {
                NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                int j = nbttagcompound1.getByte("Slot") & 255;

                if (j >= 0 && j < this.chestContents.length)
                {
                    this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                }
            }
        }
        
        public void writeToNBT(NBTTagCompound p_145841_1_)
        {
            super.writeToNBT(p_145841_1_);
            NBTTagList nbttaglist = new NBTTagList();

            for (int i = 0; i < this.chestContents.length; ++i)
            {
                if (this.chestContents[i] != null)
                {
                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                    nbttagcompound1.setByte("Slot", (byte)i);
                    this.chestContents[i].writeToNBT(nbttagcompound1);
                    nbttaglist.appendTag(nbttagcompound1);
                }
            }

            p_145841_1_.setTag("Items", nbttaglist);

            if (this.hasCustomInventoryName())
            {
                p_145841_1_.setString("CustomName", this.customName);
            }
        }
        
        private void func_145978_a(TileEntityChest p_145978_1_, int p_145978_2_)
        {
            if (p_145978_1_.isInvalid())
            {
                this.adjacentChestChecked = false;
            }
            else if (this.adjacentChestChecked)
            {
                switch (p_145978_2_)
                {
                    case 0:
                        if (this.adjacentChestZPos != p_145978_1_)
                        {
                            this.adjacentChestChecked = false;
                        }

                        break;
                    case 1:
                        if (this.adjacentChestXNeg != p_145978_1_)
                        {
                            this.adjacentChestChecked = false;
                        }

                        break;
                    case 2:
                        if (this.adjacentChestZNeg != p_145978_1_)
                        {
                            this.adjacentChestChecked = false;
                        }

                        break;
                    case 3:
                        if (this.adjacentChestXPos != p_145978_1_)
                        {
                            this.adjacentChestChecked = false;
                        }
                }
            }
        }
        
        /**
         * Performs the check for adjacent chests to determine if this chest is double or not.
         */
        public void checkForAdjacentChests()
        {
            if (!this.adjacentChestChecked)
            {
                this.adjacentChestChecked = true;
                this.adjacentChestZNeg = null;
                this.adjacentChestXPos = null;
                this.adjacentChestXNeg = null;
                this.adjacentChestZPos = null;

                if (this.func_145977_a(this.xCoord - 1, this.yCoord, this.zCoord))
                {
                    this.adjacentChestXNeg = (TileEntityIceChest)this.worldObj.getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord);
                }

                if (this.func_145977_a(this.xCoord + 1, this.yCoord, this.zCoord))
                {
                    this.adjacentChestXPos = (TileEntityIceChest)this.worldObj.getTileEntity(this.xCoord + 1, this.yCoord, this.zCoord);
                }

                if (this.func_145977_a(this.xCoord, this.yCoord, this.zCoord - 1))
                {
                    this.adjacentChestZNeg = (TileEntityIceChest)this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 1);
                }

                if (this.func_145977_a(this.xCoord, this.yCoord, this.zCoord + 1))
                {
                    this.adjacentChestZPos = (TileEntityIceChest)this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 1);
                }

                if (this.adjacentChestZNeg != null)
                {
                    this.adjacentChestZNeg.func_145978_a(this, 0);
                }

                if (this.adjacentChestZPos != null)
                {
                    this.adjacentChestZPos.func_145978_a(this, 2);
                }

                if (this.adjacentChestXPos != null)
                {
                    this.adjacentChestXPos.func_145978_a(this, 1);
                }

                if (this.adjacentChestXNeg != null)
                {
                    this.adjacentChestXNeg.func_145978_a(this, 3);
                }
            }
        }

        private boolean func_145977_a(int p_145977_1_, int p_145977_2_, int p_145977_3_)
        {
            if (this.worldObj == null)
            {
                return false;
            }
            else
            {
                Block block = this.worldObj.getBlock(p_145977_1_, p_145977_2_, p_145977_3_);
                return block instanceof IceChest && ((IceChest)block).field_149956_a == this.func_145980_j();
            }
        }
        
        public int func_145980_j()
        {
            if (this.cachedChestType == -1)
            {
                if (this.worldObj == null || !(this.getBlockType() instanceof IceChest))
                {
                    return 0;
                }

                this.cachedChestType = ((IceChest)this.getBlockType()).field_149956_a;
            }

            return this.cachedChestType;
        }
        
        
        
        
        
        public int getInventoryStackLimit()
        {
            return 64;
        }
        
        public boolean isUseableByPlayer(EntityPlayer p_70300_1_)
        {
            return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : p_70300_1_.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
        }
        
        public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_)
        {
            return true;
        }
        
        public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_)
        {
            if (p_145842_1_ == 1)
            {
                this.numPlayersUsing = p_145842_2_;
                return true;
            }
            else
            {
                return super.receiveClientEvent(p_145842_1_, p_145842_2_);
            }
        }
        
        public ItemStack getStackInSlot(int par1){
            return this.chestContents[par1];
        }
        
        public ItemStack decrStackSize(int par1, int par2){
            
            if (this.chestContents[par1] != null){
                ItemStack itemstack;
                
            if (this.chestContents[par1].stackSize <= par2)
            {    
                itemstack = this.chestContents[par1];
                this.chestContents[par1] = null;
                this.markDirty();
                return itemstack;
            }
                
            else
            {
                itemstack = this.chestContents[par1].splitStack(par2);

                if (this.chestContents[par1].stackSize == 0)
                {
                    this.chestContents[par1] = null;
                }

                this.markDirty();
                return itemstack;
            }
        }
        else
        {
            return null;
        }
    }
        public ItemStack getStackInSlotOnClosing(int par1){
            
            if(this.chestContents[par1] != null){
                ItemStack itemstack = this.chestContents[par1];
                this.chestContents[par1] = null;
                return itemstack;
            }
            else{
                return null;
            }
            
            
        }
        
        public void setInventorySlotContents(int par1, ItemStack itemStack)
        {
            this.chestContents[par1] = itemStack;

            if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit())
            {
                itemStack.stackSize = this.getInventoryStackLimit();
            }

            this.markDirty();
        }
}
 
Опять-же ты просто скопировал и даже не всё. Нету "implements IInventory", добавь и он предложит добавить не достающие части кода. А учитывая, что ты просто скопировал и код и ты даже не пытался изменить в читабельный вид кода - тогда и возможно, что и работать у тебя не будет.
 
Сарказм или нет? А так-же проверь, зарегистрирована твоя "TileEntityIceChest".
 
Назад
Сверху