Тут вопрос не времени и страданий, а атмосферы) Не будет ли некрасиво делать свою гуи необычной?svk написал(а):Сделай с текстурой, делов то.
Найти текстуру в инете, и волшебной палочкой убрать майновский фон и засунуть свой.
Как лучше?FanKar написал(а):Честно - мне не нрав xD
С мобами очень легко)))Tuborg написал(а):Эх, FanKar был прав - мне еще рано(, который день бьюсь с гуи! Но, к счастью сложнее этого по-моему может быть разве что моб. Если не трудно может кто скинуть полезных ссылок? Я уже сделал тайл, гуи с инвентарем игрока, но вот гуи с контейнером тайла не могу(,Я уже декомпилировал пару модов но все одно - вылет с ошибкой "Ticking memory connection". Буду счастлив если мне кто-нибудь поможет.P.S. Этот гуи - важнейший на данном этапе контент, технологичское крыло мода будет идти отсюда, пропустить это никак нельзя.
О Господи, самое главное забыл, простите.Вылетает когда делаю слот с InventoryPlayer, не вылетает когда EntityPlayer.inventory, Вылетает когда TileEntity(мой тайл).Мне нужно узнать как не будет вылетать с тайлом.(Agravaine написал(а):Зачем?
public class ContainerGS extends Container {
private TileEntityGS p_i1812_2_;
private TileEntityGS tileFurnace;
private int lastCookTime;
private int lastBurnTime;
private int lastItemBurnTime;
public ContainerGS(EntityPlayer player)
{
this.tileFurnace = p_i1812_2_;
int i;
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
}
}
@SideOnly(Side.CLIENT)
public void updateProgressBar(int p_75137_1_, int p_75137_2_)
{
if (p_75137_1_ == 0)
{
this.tileFurnace.GGrindTime = p_75137_2_;
}
if (p_75137_1_ == 1)
{
this.tileFurnace.GGrindTime = p_75137_2_;
}
if (p_75137_1_ == 2)
{
this.tileFurnace.currentGGrindTime = p_75137_2_;
}
}
public boolean canInteractWith(EntityPlayer p_75145_1_)
{
return (p_75145_1_) != null;
}
/**
* Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
*/
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_)
{
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(p_82846_2_);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (p_82846_2_ == 2)
{
if (!this.mergeItemStack(itemstack1, 3, 39, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
else if (p_82846_2_ != 1 && p_82846_2_ != 0)
{
if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null)
{
if (!this.mergeItemStack(itemstack1, 0, 1, false))
{
return null;
}
}
else if (TileEntityFurnace.isItemFuel(itemstack1))
{
if (!this.mergeItemStack(itemstack1, 1, 2, false))
{
return null;
}
}
else if (p_82846_2_ >= 3 && p_82846_2_ < 30)
{
if (!this.mergeItemStack(itemstack1, 30, 39, false))
{
return null;
}
}
else if (p_82846_2_ >= 30 && p_82846_2_ < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack((ItemStack)null);
}
else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
{
return null;
}
slot.onPickupFromSlot(p_82846_1_, itemstack1);
}
return itemstack;
}
public class GuiHandlerGMP implements IGuiHandler {
public static TileEntityGS tile;
public static EntityPlayer inv;
public Object getServerGuiElement(int id, EntityPlayer player, World wrd, int x, int y, int z){
switch(id){//В зависимости от id выбираем контейнер
case 1://
return new ContainerGS(player);//Вместо player можем дать что угодно, TileEntity, ItemStack предмета(сумки например), это же ваш класс с вашим конструктором
default:
return null;
}
}
public Object getClientGuiElement(int id, EntityPlayer player, World wrd, int x, int y, int z){
switch(id){//В зависимости от id выбираем gui
case 1:
return new GuiGS(player);//Важно, дать те же параметры, что и контейнеру, в классе GUI увидите
default:
return null;
}
}
}
public class GuiGS extends GuiContainer{
final private ResourceLocation texture = new ResourceLocation("gmp", "textures/gui/GuiGS.png");//Ваши modid и путь к текстуре gui
public GuiGS(EntityPlayer inv){
super(new ContainerGS(inv));//Теперь понятно, зачем такие же параметры?
xSize = 256;//Тут размеры, сколько на сколько собстно, кликабельная картинка вашего gui(ведь файл текстуры должен быть 256 на 256!)
ySize = 256;// и до скольки мы обрежем при рендере, чтобы понятно было.
}
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
this.drawTexturedModalRect((super.width - super.xSize) / 2, (super.height - super.ySize) / 2, 0, 0, super.xSize, super.ySize);
}
}
public class TileEntityGS extends TileEntity implements ISidedInventory
{
private static final int[] slotsTop = new int[] {0};
private static final int[] slotsBottom = new int[] {2, 1};
private static final int[] slotsSides = new int[] {1};
private ItemStack[] GSItemStacks = new ItemStack[3];
public int GWorkTime;
public int currentGGrindTime;
public int GGrindTime;
private String field_145958_o;
public int getSizeInventory()
{
return this.GSItemStacks.length;
}
public String getInventoryName()
{
return this.hasCustomInventoryName() ? this.field_145958_o : "container.furnace";
}
public int[] getAccessibleSlotsFromSide(int p_94128_1_)
{
return p_94128_1_ == 0 ? slotsBottom : (p_94128_1_ == 1 ? slotsTop : slotsSides);
}
public boolean hasCustomInventoryName()
{
return this.field_145958_o != null && this.field_145958_o.length() > 0;
}
public ItemStack getStackInSlot(int p_70301_1_)
{
return this.GSItemStacks[p_70301_1_];
}
public boolean isUseableByPlayer(EntityPlayer p_70300_1_)
{
return true;
}
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_)
{
if (this.GSItemStacks[p_70298_1_] != null)
{
ItemStack itemstack;
if (this.GSItemStacks[p_70298_1_].stackSize <= p_70298_2_)
{
itemstack = this.GSItemStacks[p_70298_1_];
this.GSItemStacks[p_70298_1_] = null;
return itemstack;
}
else
{
itemstack = this.GSItemStacks[p_70298_1_].splitStack(p_70298_2_);
if (this.GSItemStacks[p_70298_1_].stackSize == 0)
{
this.GSItemStacks[p_70298_1_] = null;
}
return itemstack;
}
}
else
{
return null;
}
}
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_)
{
this.GSItemStacks[p_70299_1_] = p_70299_2_;
if (p_70299_2_ != null && p_70299_2_.stackSize > this.getInventoryStackLimit())
{
p_70299_2_.stackSize = this.getInventoryStackLimit();
}
}
public void readFromNBT(NBTTagCompound p_145839_1_)
{
super.readFromNBT(p_145839_1_);
NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10);
this.GSItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
byte b0 = nbttagcompound1.getByte("Slot");
if (b0 >= 0 && b0 < this.GSItemStacks.length)
{
this.GSItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.GWorkTime = p_145839_1_.getShort("BurnTime");
this.GGrindTime = p_145839_1_.getShort("CookTime");
this.currentGGrindTime = getGrindTime(this.GSItemStacks[1]);
if (p_145839_1_.hasKey("CustomName", 8))
{
this.field_145958_o = p_145839_1_.getString("CustomName");
}
}
public void writeToNBT(NBTTagCompound p_145841_1_)
{
super.writeToNBT(p_145841_1_);
p_145841_1_.setShort("GWorkTime", (short)this.GWorkTime);
p_145841_1_.setShort("GGrindTime", (short)this.GGrindTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.GSItemStacks.length; ++i)
{
if (this.GSItemStacks[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte)i);
this.GSItemStacks[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
p_145841_1_.setTag("Items", nbttaglist);
}
public int getInventoryStackLimit()
{
return 64;
}
@SideOnly(Side.CLIENT)
public int getCookProgressScaled(int p_145953_1_)
{
return this.GGrindTime * p_145953_1_ / 200;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int p_145955_1_)
{
if (this.currentGGrindTime == 0)
{
this.currentGGrindTime = 200;
}
return this.GGrindTime * p_145955_1_ / this.currentGGrindTime;
}
public boolean isBurning()
{
return this.GGrindTime > 0;
}
public static int getGrindTime(ItemStack p_145952_0_)
{
if (p_145952_0_ == null)
{
return 0;
}
else
{
int moddedBurnTime = net.minecraftforge.event.ForgeEventFactory.getFuelBurnTime(p_145952_0_);
if (moddedBurnTime >= 0) return moddedBurnTime;
Item item = p_145952_0_.getItem();
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air)
{
Block block = Block.getBlockFromItem(item);
if (block == Blocks.wooden_slab)
{
return 150;
}
if (block.getMaterial() == Material.wood)
{
return 300;
}
if (block == Blocks.coal_block)
{
return 16000;
}
}
if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemHoe && ((ItemHoe)item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.stick) return 100;
if (item == Items.coal) return 1600;
if (item == Items.lava_bucket) return 20000;
if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
if (item == Items.blaze_rod) return 2400;
return GameRegistry.getFuelValue(p_145952_0_);
}
}
public void openInventory() {}
public void closeInventory() {}
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_)
{
return p_94041_1_ == 2 ? false : (p_94041_1_ == 1 ? isItemFuel(p_94041_2_) : true);
}
public static boolean isItemFuel(ItemStack p_145954_0_)
{
/**
* Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
* fuel
*/
return getGrindTime(p_145954_0_) > 0;
}
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_)
{
return this.isItemValidForSlot(p_102007_1_, p_102007_2_);
}
public ItemStack getStackInSlotOnClosing(int p_70304_1_)
{
if (this.GSItemStacks[p_70304_1_] != null)
{
ItemStack itemstack = this.GSItemStacks[p_70304_1_];
this.GSItemStacks[p_70304_1_] = null;
return itemstack;
}
else
{
return null;
}
}
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_)
{
return p_102008_3_ != 0 || p_102008_1_ != 1 || p_102008_2_.getItem() == Items.bucket;
}