mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-20 09:16:20 +02:00
Fix BlockComponent
This commit is contained in:
parent
bfc666550a
commit
310a1cef25
@ -11,6 +11,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
@ -27,6 +28,7 @@ import net.minecraft.util.math.Matrix4f;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.clickgui.ClickGui;
|
||||
import net.wurstclient.clickgui.Component;
|
||||
import net.wurstclient.clickgui.Window;
|
||||
import net.wurstclient.clickgui.screens.EditBlockScreen;
|
||||
import net.wurstclient.settings.BlockSetting;
|
||||
|
||||
@ -95,6 +97,8 @@ public final class BlockComponent extends Component
|
||||
{
|
||||
String tooltip = "\u00a76Name:\u00a7r " + getBlockName(stack);
|
||||
tooltip += "\n\u00a76ID:\u00a7r " + setting.getBlockName();
|
||||
tooltip += "\n\u00a76Block #:\u00a7r "
|
||||
+ Block.getRawIdFromState(setting.getBlock().getDefaultState());
|
||||
tooltip += "\n\n\u00a7e[left-click]\u00a7r to edit";
|
||||
tooltip += "\n\u00a7e[right-click]\u00a7r to reset";
|
||||
gui.setTooltip(tooltip);
|
||||
@ -140,15 +144,16 @@ public final class BlockComponent extends Component
|
||||
private void renderIcon(MatrixStack matrixStack, ItemStack stack, int x,
|
||||
int y, boolean large)
|
||||
{
|
||||
matrixStack.push();
|
||||
MatrixStack modelViewStack = RenderSystem.getModelViewStack();
|
||||
modelViewStack.push();
|
||||
|
||||
matrixStack.translate(x, y, 0);
|
||||
Window parent = getParent();
|
||||
modelViewStack.translate(parent.getX(),
|
||||
parent.getY() + 13 + parent.getScrollOffset(), 0);
|
||||
modelViewStack.translate(x, y, 0);
|
||||
float scale = large ? 1.5F : 0.75F;
|
||||
// matrixStack.scale(scale, scale, scale);
|
||||
matrixStack.scale(scale, scale, scale);
|
||||
modelViewStack.scale(scale, scale, scale);
|
||||
|
||||
// RenderSystem.enableTexture();
|
||||
// RenderSystem.setShader(GameRenderer::method_34542);
|
||||
DiffuseLighting.enableGuiDepthLighting();
|
||||
ItemStack grass = new ItemStack(Blocks.GRASS_BLOCK);
|
||||
ItemStack renderStack = !stack.isEmpty() ? stack : grass;
|
||||
@ -156,7 +161,8 @@ public final class BlockComponent extends Component
|
||||
0, 0);
|
||||
DiffuseLighting.disableGuiDepthLighting();
|
||||
|
||||
matrixStack.pop();
|
||||
modelViewStack.pop();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
|
||||
if(stack.isEmpty())
|
||||
renderQuestionMark(matrixStack, x, y, large);
|
||||
|
@ -10,6 +10,8 @@ package net.wurstclient.clickgui.screens;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
@ -23,6 +25,7 @@ import net.minecraft.text.LiteralText;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.settings.BlockSetting;
|
||||
import net.wurstclient.util.BlockUtils;
|
||||
import net.wurstclient.util.MathUtils;
|
||||
|
||||
public final class EditBlockScreen extends Screen
|
||||
{
|
||||
@ -65,8 +68,14 @@ public final class EditBlockScreen extends Screen
|
||||
|
||||
private void done()
|
||||
{
|
||||
String value = blockField.getText();
|
||||
Block block = BlockUtils.getBlockFromName(value);
|
||||
Block block;
|
||||
String nameOrId = blockField.getText();
|
||||
|
||||
if(MathUtils.isInteger(nameOrId))
|
||||
block =
|
||||
Block.getStateFromRawId(Integer.parseInt(nameOrId)).getBlock();
|
||||
else
|
||||
block = BlockUtils.getBlockFromName(nameOrId);
|
||||
|
||||
if(block != null)
|
||||
setting.setBlock(block);
|
||||
@ -115,26 +124,42 @@ public final class EditBlockScreen extends Screen
|
||||
|
||||
boolean lblAbove =
|
||||
!blockField.getText().isEmpty() || blockField.isFocused();
|
||||
String lblText = lblAbove ? "Block name or ID:" : "block name or ID";
|
||||
String lblText =
|
||||
lblAbove ? "Block ID or number:" : "block ID or number";
|
||||
int lblX = lblAbove ? 50 : 68;
|
||||
int lblY = lblAbove ? -66 : -50;
|
||||
int lblColor = lblAbove ? 0xF0F0F0 : 0x808080;
|
||||
drawStringWithShadow(matrixStack, tr, lblText, lblX, lblY, lblColor);
|
||||
|
||||
fill(matrixStack, 48, -56, 64, -36, 0xffa0a0a0);
|
||||
fill(matrixStack, 49, -55, 64, -37, 0xff000000);
|
||||
fill(matrixStack, 214, -56, 244, -55, 0xffa0a0a0);
|
||||
fill(matrixStack, 214, -37, 244, -36, 0xffa0a0a0);
|
||||
fill(matrixStack, 244, -56, 246, -36, 0xffa0a0a0);
|
||||
fill(matrixStack, 214, -55, 243, -52, 0xff000000);
|
||||
fill(matrixStack, 214, -40, 243, -37, 0xff000000);
|
||||
fill(matrixStack, 215, -55, 216, -37, 0xff000000);
|
||||
fill(matrixStack, 242, -55, 245, -37, 0xff000000);
|
||||
int border = blockField.isFocused() ? 0xffffffff : 0xffa0a0a0;
|
||||
int black = 0xff000000;
|
||||
|
||||
Block blockToAdd = BlockUtils.getBlockFromName(blockField.getText());
|
||||
renderIcon(matrixStack, new ItemStack(blockToAdd), 52, -52, false);
|
||||
fill(matrixStack, 48, -56, 64, -36, border);
|
||||
fill(matrixStack, 49, -55, 64, -37, black);
|
||||
fill(matrixStack, 214, -56, 244, -55, border);
|
||||
fill(matrixStack, 214, -37, 244, -36, border);
|
||||
fill(matrixStack, 244, -56, 246, -36, border);
|
||||
fill(matrixStack, 214, -55, 243, -52, black);
|
||||
fill(matrixStack, 214, -40, 243, -37, black);
|
||||
fill(matrixStack, 215, -55, 216, -37, black);
|
||||
fill(matrixStack, 242, -55, 245, -37, black);
|
||||
|
||||
matrixStack.pop();
|
||||
|
||||
Block blockToAdd;
|
||||
String nameOrId = blockField.getText();
|
||||
|
||||
if(MathUtils.isInteger(nameOrId))
|
||||
blockToAdd =
|
||||
Block.getStateFromRawId(Integer.parseInt(nameOrId)).getBlock();
|
||||
else
|
||||
blockToAdd = BlockUtils.getBlockFromName(nameOrId);
|
||||
|
||||
if(blockToAdd == null)
|
||||
blockToAdd = Blocks.AIR;
|
||||
|
||||
renderIcon(matrixStack, new ItemStack(blockToAdd),
|
||||
-64 + width / 2 - 100 + 52, 115 - 52, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -152,11 +177,12 @@ public final class EditBlockScreen extends Screen
|
||||
private void renderIcon(MatrixStack matrixStack, ItemStack stack, int x,
|
||||
int y, boolean large)
|
||||
{
|
||||
matrixStack.push();
|
||||
MatrixStack modelViewStack = RenderSystem.getModelViewStack();
|
||||
modelViewStack.push();
|
||||
|
||||
matrixStack.translate(x, y, 0);
|
||||
modelViewStack.translate(x, y, 0);
|
||||
float scale = large ? 1.5F : 0.75F;
|
||||
matrixStack.scale(scale, scale, scale);
|
||||
modelViewStack.scale(scale, scale, scale);
|
||||
|
||||
DiffuseLighting.enableGuiDepthLighting();
|
||||
ItemStack grass = new ItemStack(Blocks.GRASS_BLOCK);
|
||||
@ -165,7 +191,8 @@ public final class EditBlockScreen extends Screen
|
||||
0, 0);
|
||||
DiffuseLighting.disableGuiDepthLighting();
|
||||
|
||||
matrixStack.pop();
|
||||
modelViewStack.pop();
|
||||
RenderSystem.applyModelViewMatrix();
|
||||
|
||||
if(stack.isEmpty())
|
||||
renderQuestionMark(matrixStack, x, y, large);
|
||||
|
@ -56,6 +56,7 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
|
||||
private ArrayList<ButtonData> buttonDatas = new ArrayList<>();
|
||||
|
||||
private Window window = new Window("");
|
||||
private int windowComponentY;
|
||||
|
||||
public NavigatorFeatureScreen(Feature feature, NavigatorMainScreen parent)
|
||||
{
|
||||
@ -147,7 +148,7 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
|
||||
if(!settings.isEmpty())
|
||||
{
|
||||
text += "\n\nSettings:";
|
||||
window.setY(getStringHeight(text) + 2);
|
||||
windowComponentY = getStringHeight(text) + 2;
|
||||
|
||||
for(int i = 0; i < Math.ceil(window.getInnerHeight() / 9.0); i++)
|
||||
text += "\n";
|
||||
@ -283,7 +284,8 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
|
||||
|
||||
// component settings
|
||||
WurstClient.INSTANCE.getGui().handleNavigatorMouseClick(
|
||||
x - middleX + 154, y - 60 - scroll - window.getY(), button, window);
|
||||
x - middleX + 154, y - 60 - scroll - windowComponentY, button,
|
||||
window);
|
||||
}
|
||||
|
||||
private void goBack()
|
||||
@ -322,6 +324,7 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
|
||||
|
||||
// background
|
||||
int bgx1 = middleX - 154;
|
||||
window.setX(bgx1);
|
||||
int bgx2 = middleX + 154;
|
||||
int bgy1 = 60;
|
||||
int bgy2 = height - 43;
|
||||
@ -329,11 +332,10 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
|
||||
setColorToBackground();
|
||||
drawQuads(matrixStack, bgx1, bgy1, bgx2,
|
||||
Math.max(bgy1, Math.min(bgy2 - (buttons.isEmpty() ? 0 : 24),
|
||||
bgy1 + scroll + window.getY())));
|
||||
bgy1 + scroll + windowComponentY)));
|
||||
drawQuads(matrixStack, bgx1,
|
||||
Math.max(bgy1,
|
||||
Math.min(bgy2 - (buttons.isEmpty() ? 0 : 24),
|
||||
bgy1 + scroll + window.getY() + window.getInnerHeight())),
|
||||
Math.max(bgy1, Math.min(bgy2 - (buttons.isEmpty() ? 0 : 24),
|
||||
bgy1 + scroll + windowComponentY + window.getInnerHeight())),
|
||||
bgx2, bgy2);
|
||||
drawBoxShadow(matrixStack, bgx1, bgy1, bgx2, bgy2);
|
||||
|
||||
@ -346,7 +348,8 @@ public final class NavigatorFeatureScreen extends NavigatorScreen
|
||||
WurstClient.INSTANCE.getGui().setTooltip("");
|
||||
window.validate();
|
||||
|
||||
int windowY = bgy1 + scroll + window.getY();
|
||||
int windowY = bgy1 + scroll + windowComponentY;
|
||||
window.setY(windowY - 13);
|
||||
matrixStack.push();
|
||||
matrixStack.translate(bgx1, windowY, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user