Fix crash
This commit is contained in:
parent
bfd93753eb
commit
8ad2147c42
4 changed files with 20 additions and 8 deletions
|
@ -70,7 +70,7 @@ public class CheckBoxElement extends ElementBase {
|
|||
sprite = checkBoxSprite.ticked();
|
||||
}
|
||||
drawSprite(drawContext, gui, sprite, getX(), getY() );
|
||||
drawText(drawContext, gui, label, getX() + getWidth() + 5, ((getY() + getHeight() / 2) - (gui.getTextRenderer().fontHeight / 2)), 0xFFFFFFFF);
|
||||
drawText(drawContext, gui, label, getX() + 18, ((getY() + getHeight() / 2) - (gui.getTextRenderer().fontHeight / 2)), 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ package reborncore.client.gui.builder.slot.elements;
|
|||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.text.Text;
|
||||
import reborncore.client.gui.builder.GuiBase;
|
||||
|
@ -59,11 +60,11 @@ public class ElementBase {
|
|||
}
|
||||
|
||||
public int getWidth() {
|
||||
return sprite.getSprite().getContents().getWidth();
|
||||
return getGuiSprite(sprite).getContents().getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return sprite.getSprite().getContents().getHeight();
|
||||
return getGuiSprite(sprite).getContents().getHeight();
|
||||
}
|
||||
|
||||
public boolean onClick(GuiBase<?> gui, double mouseX, double mouseY) {
|
||||
|
@ -92,8 +93,17 @@ public class ElementBase {
|
|||
drawContext.drawText(gui.getTextRenderer(), text, x, y, color, false);
|
||||
}
|
||||
|
||||
public void drawSprite(DrawContext drawContext, GuiBase<?> gui, SpriteIdentifier sprite, int x, int y) {
|
||||
drawContext.drawSprite(x + gui.getGuiLeft(), y + gui.getGuiTop(), 0, getWidth(), getHeight(), sprite.getSprite());
|
||||
public void drawSprite(DrawContext drawContext, GuiBase<?> gui, SpriteIdentifier spriteIdentifier, int x, int y) {
|
||||
final Sprite sprite = getGuiSprite(spriteIdentifier);
|
||||
|
||||
drawContext.drawSprite(
|
||||
x + gui.getGuiLeft(),
|
||||
y + gui.getGuiTop(),
|
||||
0,
|
||||
sprite.getContents().getWidth(),
|
||||
sprite.getContents().getHeight(),
|
||||
sprite
|
||||
);
|
||||
}
|
||||
|
||||
public void drawDefaultBackground(DrawContext drawContext, Screen gui, int x, int y, int width, int height) {
|
||||
|
@ -102,4 +112,8 @@ public class ElementBase {
|
|||
drawContext.drawTexture(GuiBuilder.defaultTextureSheet, x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2);
|
||||
drawContext.drawTexture(GuiBuilder.defaultTextureSheet, x + width / 2, y + height / 2, 150 - width / 2, 150 - height / 2, width / 2, height / 2);
|
||||
}
|
||||
|
||||
private Sprite getGuiSprite(SpriteIdentifier spriteIdentifier) {
|
||||
return GuiSpriteAtlasHolder.INSTANCE.getSprite(sprite.getTextureId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,8 @@ import net.minecraft.client.texture.Sprite;
|
|||
import net.minecraft.client.texture.SpriteAtlasHolder;
|
||||
import net.minecraft.client.texture.TextureManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class GuiSpriteAtlasHolder extends SpriteAtlasHolder {
|
||||
@Nullable
|
||||
public static GuiSpriteAtlasHolder INSTANCE;
|
||||
|
||||
public static final Identifier ATLAS_ID = new Identifier("reborncore", "textures/atlas/gui.png");
|
||||
|
|
Loading…
Reference in a new issue