- 14
- 1
Если увеличивать количество "слотов" в классе GUI и менять картинку (текстуру), картинка (320х320) скейлится с чересчур мелкой сеткой для слотов. Слоты просто "не влезают" в картинку бэкграунда контейнера.
Вот картинка ГУИ сундука, 320 х 320. Это вычисленный размер (16<слотов> * 18<размер-слота> + 15<перемычек> + 12<две-боковые-рамки>).
Но несмотря на то, что в типе сундука меняется xSize (320) и ySize (320) и бэкграунд должен был бы рендериться один в один, изображение частично дублируется, и слоты не совпадают с сеткой.
(светлый прямоугольник — это собственно слот)....
Мозги сломала, где рендерится бэкграунд гуишного контейнера? Как убрать scale картинки фона?
При том, что нормальный дефолтный фон рендерится без скейлинга
Вот картинка ГУИ сундука, 320 х 320. Это вычисленный размер (16<слотов> * 18<размер-слота> + 15<перемычек> + 12<две-боковые-рамки>).
Но несмотря на то, что в типе сундука меняется xSize (320) и ySize (320) и бэкграунд должен был бы рендериться один в один, изображение частично дублируется, и слоты не совпадают с сеткой.
(светлый прямоугольник — это собственно слот)....
Мозги сломала, где рендерится бэкграунд гуишного контейнера? Как убрать scale картинки фона?
При том, что нормальный дефолтный фон рендерится без скейлинга
package ru.AykaOwl.storagemod.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import ru.AykaOwl.storagemod.container.ContainerOwlChest;
import ru.AykaOwl.storagemod.tile.TileEntityOwlChest;
import ru.AykaOwl.storagemod.utils.OwlChestType;
public class GUIStorage extends GuiContainer
{
private GUIStorage.GUIChest type;
private InventoryPlayer inventory;
private IInventory chest;
public int getRowLength() {
return this.type.mainType.getRowLength();
}
private GUIStorage(GUIStorage.GUIChest type, IInventory player, IInventory chest) {
super(type.makeContainer(player, chest));
this.chest = chest;
this.type = type;
this.xSize = type.xSize;
this.ySize = type.ySize;
this.allowUserInput = true;
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(9.0F, 9.0F, 9.0F, 1.0F);
this.mc.getTextureManager().bindTexture(this.type.guiResourceList.location);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
System.out.println("this.width : " + this.width);
drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
}
public enum GUIChest {
SIMPLEOWL(184, 202, GUIStorage.ResourceList.SIMPLEOWL, OwlChestType.SIMPLEOWL),
WHITEOWL(320, 256, GUIStorage.ResourceList.WHITEOWL, OwlChestType.WHITEOWL);
private int xSize;
private int ySize;
private GUIStorage.ResourceList guiResourceList;
public OwlChestType mainType;
GUIChest(int xSize, int ySize, GUIStorage.ResourceList guiResourceList, OwlChestType mainType) {
this.xSize = xSize;
this.ySize = ySize;
this.guiResourceList = guiResourceList;
this.mainType = mainType;
}
protected Container makeContainer(IInventory player, IInventory chest) {
return new ContainerOwlChest(player, chest, this.mainType, this.xSize, this.ySize);
}
public static GUIStorage buildGUI(OwlChestType type, IInventory playerInventory, TileEntityOwlChest chestInventory) {
return new GUIStorage(values()[chestInventory.getType().ordinal()], playerInventory, chestInventory);
}
}
public enum ResourceList
{
SIMPLEOWL(new ResourceLocation("storagemod", "textures/gui/owlcontainer.png")),
WHITEOWL(new ResourceLocation("storagemod", "textures/gui/whiteowlcontainer.png"));
ResourceList(ResourceLocation loc) {
this.location = loc;
}
public final ResourceLocation location;
}
}
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import ru.AykaOwl.storagemod.container.ContainerOwlChest;
import ru.AykaOwl.storagemod.tile.TileEntityOwlChest;
import ru.AykaOwl.storagemod.utils.OwlChestType;
public class GUIStorage extends GuiContainer
{
private GUIStorage.GUIChest type;
private InventoryPlayer inventory;
private IInventory chest;
public int getRowLength() {
return this.type.mainType.getRowLength();
}
private GUIStorage(GUIStorage.GUIChest type, IInventory player, IInventory chest) {
super(type.makeContainer(player, chest));
this.chest = chest;
this.type = type;
this.xSize = type.xSize;
this.ySize = type.ySize;
this.allowUserInput = true;
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(9.0F, 9.0F, 9.0F, 1.0F);
this.mc.getTextureManager().bindTexture(this.type.guiResourceList.location);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
System.out.println("this.width : " + this.width);
drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
}
public enum GUIChest {
SIMPLEOWL(184, 202, GUIStorage.ResourceList.SIMPLEOWL, OwlChestType.SIMPLEOWL),
WHITEOWL(320, 256, GUIStorage.ResourceList.WHITEOWL, OwlChestType.WHITEOWL);
private int xSize;
private int ySize;
private GUIStorage.ResourceList guiResourceList;
public OwlChestType mainType;
GUIChest(int xSize, int ySize, GUIStorage.ResourceList guiResourceList, OwlChestType mainType) {
this.xSize = xSize;
this.ySize = ySize;
this.guiResourceList = guiResourceList;
this.mainType = mainType;
}
protected Container makeContainer(IInventory player, IInventory chest) {
return new ContainerOwlChest(player, chest, this.mainType, this.xSize, this.ySize);
}
public static GUIStorage buildGUI(OwlChestType type, IInventory playerInventory, TileEntityOwlChest chestInventory) {
return new GUIStorage(values()[chestInventory.getType().ordinal()], playerInventory, chestInventory);
}
}
public enum ResourceList
{
SIMPLEOWL(new ResourceLocation("storagemod", "textures/gui/owlcontainer.png")),
WHITEOWL(new ResourceLocation("storagemod", "textures/gui/whiteowlcontainer.png"));
ResourceList(ResourceLocation loc) {
this.location = loc;
}
public final ResourceLocation location;
}
}
Последнее редактирование: