End Stone Smelter GUI fix
This commit is contained in:
parent
c418fc4d04
commit
bf171754c7
1 changed files with 33 additions and 35 deletions
|
@ -2,7 +2,6 @@ package ru.betterend.client.gui;
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.gui.components.ImageButton;
|
import net.minecraft.client.gui.components.ImageButton;
|
||||||
|
@ -10,7 +9,6 @@ import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
|
||||||
import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener;
|
import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.FormattedText;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.inventory.ClickType;
|
import net.minecraft.world.inventory.ClickType;
|
||||||
|
@ -28,43 +26,42 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
||||||
|
|
||||||
public EndStoneSmelterScreen(EndStoneSmelterScreenHandler handler, Inventory inventory, Component title) {
|
public EndStoneSmelterScreen(EndStoneSmelterScreenHandler handler, Inventory inventory, Component title) {
|
||||||
super(handler, inventory, title);
|
super(handler, inventory, title);
|
||||||
this.recipeBook = new EndStoneSmelterRecipeBookScreen();
|
recipeBook = new EndStoneSmelterRecipeBookScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
super.init();
|
super.init();
|
||||||
this.narrow = this.width < 379;
|
narrow = width < 379;
|
||||||
this.recipeBook.init(width, height, minecraft, narrow, menu);
|
recipeBook.init(width, height, minecraft, narrow, menu);
|
||||||
this.leftPos = this.recipeBook.updateScreenPosition(narrow, width, imageWidth);
|
leftPos = recipeBook.updateScreenPosition(narrow, width, imageWidth);
|
||||||
this.addButton(new ImageButton(leftPos + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE, (buttonWidget) -> {
|
addButton(new ImageButton(leftPos + 20, height / 2 - 49, 20, 18, 0, 0, 19, RECIPE_BUTTON_TEXTURE, (buttonWidget) -> {
|
||||||
this.recipeBook.initVisuals(narrow);
|
recipeBook.initVisuals(narrow);
|
||||||
this.recipeBook.toggleVisibility();
|
recipeBook.toggleVisibility();
|
||||||
this.leftPos = this.recipeBook.updateScreenPosition(narrow, width, imageWidth);
|
leftPos = recipeBook.updateScreenPosition(narrow, width, imageWidth);
|
||||||
((ImageButton) buttonWidget).setPosition(this.leftPos + 20, height / 2 - 49);
|
((ImageButton) buttonWidget).setPosition(leftPos + 20, height / 2 - 49);
|
||||||
}));
|
}));
|
||||||
this.titleLabelX = (this.imageWidth - this.font.width((FormattedText)this.title)) / 2;
|
titleLabelX = (imageWidth - font.width(title)) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
this.recipeBook.tick();
|
recipeBook.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||||
this.renderBackground(matrices);
|
renderBackground(matrices);
|
||||||
if (this.recipeBook.isVisible() && this.narrow) {
|
if (recipeBook.isVisible() && narrow) {
|
||||||
this.renderBg(matrices, delta, mouseX, mouseY);
|
renderBg(matrices, delta, mouseX, mouseY);
|
||||||
this.recipeBook.render(matrices, mouseX, mouseY, delta);
|
recipeBook.render(matrices, mouseX, mouseY, delta);
|
||||||
} else {
|
} else {
|
||||||
this.recipeBook.render(matrices, mouseX, mouseY, delta);
|
recipeBook.render(matrices, mouseX, mouseY, delta);
|
||||||
super.render(matrices, mouseX, mouseY, delta);
|
super.render(matrices, mouseX, mouseY, delta);
|
||||||
this.recipeBook.renderGhostRecipe(matrices, leftPos, topPos, true, delta);
|
recipeBook.renderGhostRecipe(matrices, leftPos, topPos, true, delta);
|
||||||
}
|
}
|
||||||
|
renderTooltip(matrices, mouseX, mouseY);
|
||||||
this.renderTooltip(matrices, mouseX, mouseY);
|
recipeBook.renderTooltip(matrices, leftPos, topPos, mouseX, mouseY);
|
||||||
this.recipeBook.renderTooltip(matrices, leftPos, topPos, mouseX, mouseY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,7 +69,7 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
||||||
if (this.recipeBook.mouseClicked(mouseX, mouseY, button)) {
|
if (this.recipeBook.mouseClicked(mouseX, mouseY, button)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return this.narrow && this.recipeBook.isVisible() ? true : super.mouseClicked(mouseX, mouseY, button);
|
return narrow && recipeBook.isVisible() || super.mouseClicked(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +81,7 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
|
||||||
return this.recipeBook.keyPressed(keyCode, scanCode, modifiers) ? false : super.keyPressed(keyCode, scanCode, modifiers);
|
return !recipeBook.keyPressed(keyCode, scanCode, modifiers) && super.keyPressed(keyCode, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,36 +92,37 @@ public class EndStoneSmelterScreen extends AbstractContainerScreen<EndStoneSmelt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean charTyped(char chr, int keyCode) {
|
public boolean charTyped(char chr, int keyCode) {
|
||||||
return this.recipeBook.charTyped(chr, keyCode) ? true : super.charTyped(chr, keyCode);
|
return recipeBook.charTyped(chr, keyCode) || super.charTyped(chr, keyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recipesUpdated() {
|
public void recipesUpdated() {
|
||||||
this.recipeBook.recipesUpdated();
|
recipeBook.recipesUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecipeBookComponent getRecipeBookComponent() {
|
public RecipeBookComponent getRecipeBookComponent() {
|
||||||
return this.recipeBook;
|
return recipeBook;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderBg(PoseStack matrices, float delta, int mouseX, int mouseY) {
|
protected void renderBg(PoseStack matrices, float delta, int mouseX, int mouseY) {
|
||||||
|
if (minecraft == null) return;
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
this.minecraft.getTextureManager().bind(INVENTORY_LOCATION);
|
minecraft.getTextureManager().bind(BACKGROUND_TEXTURE);
|
||||||
this.blit(matrices, leftPos, topPos, 0, 0, imageWidth, imageHeight);
|
blit(matrices, leftPos, topPos, 0, 0, imageWidth, imageHeight);
|
||||||
int p;
|
int progress;
|
||||||
if (menu.isBurning()) {
|
if (menu.isBurning()) {
|
||||||
p = menu.getFuelProgress();
|
progress = menu.getFuelProgress();
|
||||||
this.blit(matrices, leftPos + 56, topPos + 36 + 12 - p, 176, 12 - p, 14, p + 1);
|
blit(matrices, leftPos + 56, topPos + 36 + 12 - progress, 176, 12 - progress, 14, progress + 1);
|
||||||
}
|
}
|
||||||
p = menu.getSmeltProgress();
|
progress = menu.getSmeltProgress();
|
||||||
this.blit(matrices, leftPos + 92, topPos + 34, 176, 14, p + 1, 16);
|
blit(matrices, leftPos + 92, topPos + 34, 176, 14, progress + 1, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removed() {
|
public void removed() {
|
||||||
this.recipeBook.removed();
|
recipeBook.removed();
|
||||||
super.removed();
|
super.removed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue