0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-20 01:12:13 +02:00

Fix EditItemListScreen

This commit is contained in:
Alexander01998 2022-01-13 01:23:33 +01:00
parent b659cf8c50
commit 1ed1ec9b33

View File

@ -12,6 +12,8 @@ import java.util.List;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
@ -135,14 +137,19 @@ public final class EditItemListScreen extends Screen
switch(keyCode)
{
case GLFW.GLFW_KEY_ENTER:
addButton.onPress();
if(addButton.active)
addButton.onPress();
break;
case GLFW.GLFW_KEY_DELETE:
removeButton.onPress();
if(!itemNameField.isFocused())
removeButton.onPress();
break;
case GLFW.GLFW_KEY_ESCAPE:
doneButton.onPress();
break;
default:
break;
}
@ -167,17 +174,18 @@ public final class EditItemListScreen extends Screen
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
float partialTicks)
{
renderBackground(matrixStack);
listGui.render(matrixStack, mouseX, mouseY, partialTicks);
drawCenteredText(matrixStack, client.textRenderer,
itemList.getName() + " (" + listGui.getItemCount() + ")", width / 2,
12, 0xffffff);
matrixStack.push();
matrixStack.translate(0, 0, 300);
itemNameField.render(matrixStack, mouseX, mouseY, partialTicks);
super.render(matrixStack, mouseX, mouseY, partialTicks);
matrixStack.push();
matrixStack.translate(-64 + width / 2 - 152, 0, 0);
if(itemNameField.getText().isEmpty() && !itemNameField.isFocused())
@ -189,19 +197,23 @@ public final class EditItemListScreen extends Screen
matrixStack.pop();
}
fill(matrixStack, 48, height - 56, 64, height - 36, 0xffa0a0a0);
fill(matrixStack, 49, height - 55, 64, height - 37, 0xff000000);
fill(matrixStack, 214, height - 56, 244, height - 55, 0xffa0a0a0);
fill(matrixStack, 214, height - 37, 244, height - 36, 0xffa0a0a0);
fill(matrixStack, 244, height - 56, 246, height - 36, 0xffa0a0a0);
fill(matrixStack, 214, height - 55, 243, height - 52, 0xff000000);
fill(matrixStack, 214, height - 40, 243, height - 37, 0xff000000);
fill(matrixStack, 215, height - 55, 216, height - 37, 0xff000000);
fill(matrixStack, 242, height - 55, 245, height - 37, 0xff000000);
listGui.renderIconAndGetName(matrixStack, new ItemStack(itemToAdd), 52,
height - 52, false);
int border = itemNameField.isFocused() ? 0xffffffff : 0xffa0a0a0;
int black = 0xff000000;
fill(matrixStack, 48, height - 56, 64, height - 36, border);
fill(matrixStack, 49, height - 55, 64, height - 37, black);
fill(matrixStack, 214, height - 56, 244, height - 55, border);
fill(matrixStack, 214, height - 37, 244, height - 36, border);
fill(matrixStack, 244, height - 56, 246, height - 36, border);
fill(matrixStack, 214, height - 55, 243, height - 52, black);
fill(matrixStack, 214, height - 40, 243, height - 37, black);
fill(matrixStack, 215, height - 55, 216, height - 37, black);
fill(matrixStack, 242, height - 55, 245, height - 37, black);
matrixStack.pop();
listGui.renderIconAndGetName(matrixStack, new ItemStack(itemToAdd),
width / 2 - 164, height - 52, false);
}
private static class ListGui extends ListWidget
@ -259,8 +271,8 @@ public final class EditItemListScreen extends Screen
renderIconAndGetName(matrixStack, stack, x + 1, y + 1, true);
fr.draw(matrixStack, displayName, x + 28, y, 0xf0f0f0);
fr.draw(matrixStack, name, x + 28, y + 9, 0xa0a0a0);
fr.draw(matrixStack, "ID: " + Registry.ITEM.getId(item).toString(),
x + 28, y + 18, 0xa0a0a0);
fr.draw(matrixStack, "ID: " + Registry.ITEM.getRawId(item), x + 28,
y + 18, 0xa0a0a0);
}
private String renderIconAndGetName(MatrixStack matrixStack,
@ -268,18 +280,21 @@ public final class EditItemListScreen extends Screen
{
if(stack.isEmpty())
{
matrixStack.push();
matrixStack.translate(x, y, 0);
MatrixStack modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.push();
modelViewStack.translate(x, y, 0);
if(large)
matrixStack.scale(1.5F, 1.5F, 1.5F);
modelViewStack.scale(1.5F, 1.5F, 1.5F);
else
matrixStack.scale(0.75F, 0.75F, 0.75F);
modelViewStack.scale(0.75F, 0.75F, 0.75F);
DiffuseLighting.enableGuiDepthLighting();
mc.getItemRenderer().renderInGuiWithOverrides(
new ItemStack(Blocks.GRASS_BLOCK), 0, 0);
DiffuseLighting.disableGuiDepthLighting();
matrixStack.pop();
modelViewStack.pop();
RenderSystem.applyModelViewMatrix();
matrixStack.push();
matrixStack.translate(x, y, 0);
@ -292,20 +307,23 @@ public final class EditItemListScreen extends Screen
matrixStack.pop();
return "\u00a7ounknown item\u00a7r";
}
matrixStack.push();
matrixStack.translate(x, y, 0);
MatrixStack modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.push();
modelViewStack.translate(x, y, 0);
if(large)
matrixStack.scale(1.5F, 1.5F, 1.5F);
modelViewStack.scale(1.5F, 1.5F, 1.5F);
else
matrixStack.scale(0.75F, 0.75F, 0.75F);
modelViewStack.scale(0.75F, 0.75F, 0.75F);
DiffuseLighting.enableGuiDepthLighting();
mc.getItemRenderer().renderInGuiWithOverrides(stack, 0, 0);
DiffuseLighting.disableGuiDepthLighting();
matrixStack.pop();
modelViewStack.pop();
RenderSystem.applyModelViewMatrix();
return stack.getName().getString();
}