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

Merge tag 'v7.32' into 1.19.4-pre2

This commit is contained in:
Alexander01998 2023-03-01 19:10:25 +01:00
commit 554d5ae325
527 changed files with 4404 additions and 1335 deletions

View File

@ -12,7 +12,7 @@ loader_version=0.14.17
fabric_version=0.75.1+1.19.4
# Mod Properties
mod_version = v7.31-MC1.19.4-pre2
mod_version = v7.32-MC1.19.4-pre2
maven_group = net.wurstclient
archives_base_name = Wurst-Client

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -73,6 +73,11 @@ public class FriendsList
return friends.contains(name);
}
public boolean isFriend(Entity entity)
{
return entity != null && contains(entity.getEntityName());
}
public ArrayList<String> toList()
{
return new ArrayList<>(friends);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -49,29 +49,32 @@ public final class RotationFaker
public void faceVectorPacket(Vec3d vec)
{
RotationUtils.Rotation rotations =
RotationUtils.getNeededRotations(vec);
RotationUtils.Rotation needed = RotationUtils.getNeededRotations(vec);
ClientPlayerEntity player = WurstClient.MC.player;
fakeRotation = true;
serverYaw = rotations.getYaw();
serverPitch = rotations.getPitch();
serverYaw =
RotationUtils.limitAngleChange(player.getYaw(), needed.getYaw());
serverPitch = needed.getPitch();
}
public void faceVectorClient(Vec3d vec)
{
RotationUtils.Rotation rotations =
RotationUtils.getNeededRotations(vec);
RotationUtils.Rotation needed = RotationUtils.getNeededRotations(vec);
WurstClient.MC.player.setYaw(rotations.getYaw());
WurstClient.MC.player.setPitch(rotations.getPitch());
ClientPlayerEntity player = WurstClient.MC.player;
player.setYaw(
RotationUtils.limitAngleChange(player.getYaw(), needed.getYaw()));
player.setPitch(needed.getPitch());
}
public void faceVectorClientIgnorePitch(Vec3d vec)
{
RotationUtils.Rotation rotations =
RotationUtils.getNeededRotations(vec);
RotationUtils.Rotation needed = RotationUtils.getNeededRotations(vec);
WurstClient.MC.player.setYaw(rotations.getYaw());
ClientPlayerEntity player = WurstClient.MC.player;
WurstClient.MC.player.setYaw(
RotationUtils.limitAngleChange(player.getYaw(), needed.getYaw()));
WurstClient.MC.player.setPitch(0);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -56,7 +56,7 @@ public enum WurstClient
public static MinecraftClient MC;
public static IMinecraftClient IMC;
public static final String VERSION = "7.31";
public static final String VERSION = "7.32";
public static final String MC_VERSION = "1.19.4-pre2";
private WurstAnalytics analytics;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -609,9 +609,10 @@ public class PathFinder
matrixStack.pop();
// GL resets
RenderSystem.setShaderColor(1, 1, 1, 1);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LINE_SMOOTH);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -75,6 +75,6 @@ public abstract class PathProcessor
{
// reset keys
for(KeyBinding key : CONTROLS)
key.setPressed(((IKeyBinding)key).isActallyPressed());
((IKeyBinding)key).resetPressedState();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -13,6 +13,7 @@ import org.joml.Vector3f;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
@ -26,6 +27,7 @@ public final class PathRenderer
{
Tessellator tessellator = RenderSystem.renderThreadTesselator();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionProgram);
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES,
VertexFormats.POSITION);
@ -107,6 +109,7 @@ public final class PathRenderer
Tessellator tessellator = RenderSystem.renderThreadTesselator();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionProgram);
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES,
VertexFormats.POSITION);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,3 +1,10 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.altmanager;
import java.io.BufferedReader;

View File

@ -1,3 +1,10 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.altmanager;
import java.util.UUID;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,3 +1,10 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.altmanager;
public final class XBoxLiveToken

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -58,6 +58,8 @@ public final class ClickGui
private int txtColor;
private float opacity;
private float ttOpacity;
private int maxHeight;
private int maxSettingsHeight;
private String tooltip = "";
@ -612,6 +614,8 @@ public final class ClickGui
ttOpacity = clickGui.getTooltipOpacity();
bgColor = clickGui.getBackgroundColor();
txtColor = clickGui.getTextColor();
maxHeight = clickGui.getMaxHeight();
maxSettingsHeight = clickGui.getMaxSettingsHeight();
if(WurstClient.INSTANCE.getHax().rainbowUiHack.isEnabled())
acColor = RenderUtils.getRainbowColor();
@ -641,7 +645,8 @@ public final class ClickGui
if(!window.isMinimized())
{
window.setMaxHeight(187);
window.setMaxHeight(window instanceof SettingsWindow
? maxSettingsHeight : maxHeight);
window.validate();
// scrollbar

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -25,7 +25,7 @@ public final class SettingsWindow extends Window
setClosable(true);
setMinimizable(false);
setMaxHeight(187);
setMaxHeight(200);
pack();
setInitialPosition(parent, buttonY);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -40,7 +40,7 @@ public class Window
private boolean fixedWidth;
private int innerHeight;
private int maxHeight;
private int maxInnerHeight;
private int scrollOffset;
private boolean scrollingEnabled;
@ -133,10 +133,10 @@ public class Window
childrenHeight += c.getHeight() + 2;
childrenHeight += 2;
if(maxHeight > 0 && childrenHeight > maxHeight + 13)
if(maxInnerHeight > 0 && childrenHeight > maxInnerHeight + 13)
{
setWidth(Math.max(maxChildWidth + 3, titleBarWidth));
setHeight(maxHeight + 13);
setHeight(maxInnerHeight + 13);
}else
{
@ -164,10 +164,10 @@ public class Window
innerHeight = offsetY;
if(maxHeight == 0 || innerHeight < maxHeight)
if(maxInnerHeight == 0 || innerHeight < maxInnerHeight)
setHeight(innerHeight + 13);
else
setHeight(maxHeight + 13);
setHeight(maxInnerHeight + 13);
scrollingEnabled = innerHeight + 13 > height;
if(scrollingEnabled)
@ -328,12 +328,20 @@ public class Window
return innerHeight;
}
public final void setMaxHeight(int maxHeight)
public final void setMaxInnerHeight(int maxInnerHeight)
{
if(this.maxHeight != maxHeight)
if(maxInnerHeight < 0)
maxInnerHeight = 0;
if(this.maxInnerHeight != maxInnerHeight)
invalidate();
this.maxHeight = maxHeight;
this.maxInnerHeight = maxInnerHeight;
}
public final void setMaxHeight(int maxHeight)
{
setMaxInnerHeight(maxHeight - 13);
}
public final int getScrollOffset()

View File

@ -0,0 +1,142 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.clickgui.components;
import org.joml.Matrix4f;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import net.wurstclient.WurstClient;
import net.wurstclient.clickgui.ClickGui;
import net.wurstclient.clickgui.Component;
import net.wurstclient.settings.Setting;
public abstract class AbstractListEditButton extends Component
{
protected static final MinecraftClient MC = WurstClient.MC;
private final String buttonText = "Edit...";
private final int buttonWidth;
public AbstractListEditButton()
{
buttonWidth = MC.textRenderer.getWidth(buttonText);
}
protected abstract void openScreen();
protected abstract String getText();
protected abstract Setting getSetting();
@Override
public void handleMouseClick(double mouseX, double mouseY, int mouseButton)
{
if(mouseButton != 0)
return;
if(mouseX < getX() + getWidth() - buttonWidth - 4)
return;
openScreen();
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
float partialTicks)
{
ClickGui gui = WurstClient.INSTANCE.getGui();
float[] bgColor = gui.getBgColor();
float[] acColor = gui.getAcColor();
int txtColor = gui.getTxtColor();
float opacity = gui.getOpacity();
int x1 = getX();
int x2 = x1 + getWidth();
int x3 = x2 - buttonWidth - 4;
int y1 = getY();
int y2 = y1 + getHeight();
int scroll = getParent().isScrollingEnabled()
? getParent().getScrollOffset() : 0;
boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
&& mouseY < y2 && mouseY >= -scroll
&& mouseY < getParent().getHeight() - 13 - scroll;
boolean hText = hovering && mouseX < x3;
boolean hBox = hovering && mouseX >= x3;
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionProgram);
// tooltip
if(hText)
gui.setTooltip(getSetting().getWrappedDescription(200));
// background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x1, y1, 0).next();
bufferBuilder.vertex(matrix, x1, y2, 0).next();
bufferBuilder.vertex(matrix, x3, y2, 0).next();
bufferBuilder.vertex(matrix, x3, y1, 0).next();
tessellator.draw();
// box
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
hBox ? opacity * 1.5F : opacity);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0).next();
bufferBuilder.vertex(matrix, x3, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y1, 0).next();
tessellator.draw();
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0).next();
bufferBuilder.vertex(matrix, x3, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y1, 0).next();
bufferBuilder.vertex(matrix, x3, y1, 0).next();
tessellator.draw();
// setting name
RenderSystem.setShaderColor(1, 1, 1, 1);
TextRenderer fr = MC.textRenderer;
fr.draw(matrixStack, getText(), x1, y1 + 2, txtColor);
fr.draw(matrixStack, buttonText, x3 + 2, y1 + 2, txtColor);
GL11.glEnable(GL11.GL_BLEND);
}
@Override
public int getDefaultWidth()
{
TextRenderer fr = MC.textRenderer;
return fr.getWidth(getText()) + buttonWidth + 6;
}
@Override
public int getDefaultHeight()
{
return 11;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -13,11 +13,9 @@ 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;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
@ -27,8 +25,10 @@ import net.minecraft.item.ItemStack;
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;
import net.wurstclient.util.RenderUtils;
public final class BlockComponent extends Component
{
@ -121,7 +121,14 @@ public final class BlockComponent extends Component
String text = setting.getName() + ":";
fr.draw(matrixStack, text, x1, y1 + 2, txtColor);
renderIcon(matrixStack, stack, x3, y1, true);
MatrixStack modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.push();
Window parent = getParent();
modelViewStack.translate(parent.getX(),
parent.getY() + 13 + parent.getScrollOffset(), 0);
RenderUtils.drawItem(matrixStack, stack, x3, y1, true);
modelViewStack.pop();
RenderSystem.applyModelViewMatrix();
GL11.glEnable(GL11.GL_BLEND);
}
@ -140,46 +147,6 @@ public final class BlockComponent extends Component
return BLOCK_WITDH;
}
private void renderIcon(MatrixStack matrixStack, ItemStack stack, int x,
int y, boolean large)
{
matrixStack.push();
matrixStack.translate(x, y, 0);
float scale = large ? 1.5F : 0.75F;
matrixStack.scale(scale, scale, scale);
DiffuseLighting.enableGuiDepthLighting();
ItemStack grass = new ItemStack(Blocks.GRASS_BLOCK);
ItemStack renderStack = !stack.isEmpty() ? stack : grass;
WurstClient.MC.getItemRenderer().renderInGuiWithOverrides(matrixStack,
renderStack, 0, 0);
DiffuseLighting.disableGuiDepthLighting();
matrixStack.pop();
if(stack.isEmpty())
renderQuestionMark(matrixStack, x, y, large);
}
private void renderQuestionMark(MatrixStack matrixStack, int x, int y,
boolean large)
{
matrixStack.push();
matrixStack.translate(x, y, 0);
if(large)
matrixStack.scale(2, 2, 2);
GL11.glDisable(GL11.GL_DEPTH_TEST);
TextRenderer tr = WurstClient.MC.textRenderer;
tr.drawWithShadow(matrixStack, "?", 3, 2, 0xf0f0f0);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
matrixStack.pop();
}
private String getBlockName(ItemStack stack)
{
if(stack.isEmpty())

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -7,137 +7,38 @@
*/
package net.wurstclient.clickgui.components;
import org.joml.Matrix4f;
import org.lwjgl.opengl.GL11;
import java.util.Objects;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import net.wurstclient.WurstClient;
import net.wurstclient.clickgui.ClickGui;
import net.wurstclient.clickgui.Component;
import net.wurstclient.clickgui.screens.EditBlockListScreen;
import net.wurstclient.settings.BlockListSetting;
import net.wurstclient.settings.Setting;
public final class BlockListEditButton extends Component
public final class BlockListEditButton extends AbstractListEditButton
{
private final BlockListSetting setting;
private int buttonWidth;
public BlockListEditButton(BlockListSetting setting)
{
this.setting = setting;
TextRenderer fr = WurstClient.MC.textRenderer;
buttonWidth = fr.getWidth("Edit...");
this.setting = Objects.requireNonNull(setting);
setWidth(getDefaultWidth());
setHeight(getDefaultHeight());
}
@Override
public void handleMouseClick(double mouseX, double mouseY, int mouseButton)
protected void openScreen()
{
if(mouseButton != 0)
return;
if(mouseX < getX() + getWidth() - buttonWidth - 4)
return;
WurstClient.MC.setScreen(
new EditBlockListScreen(WurstClient.MC.currentScreen, setting));
MC.setScreen(new EditBlockListScreen(MC.currentScreen, setting));
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
float partialTicks)
protected String getText()
{
ClickGui gui = WurstClient.INSTANCE.getGui();
float[] bgColor = gui.getBgColor();
float[] acColor = gui.getAcColor();
int txtColor = gui.getTxtColor();
float opacity = gui.getOpacity();
int x1 = getX();
int x2 = x1 + getWidth();
int x3 = x2 - buttonWidth - 4;
int y1 = getY();
int y2 = y1 + getHeight();
int scroll = getParent().isScrollingEnabled()
? getParent().getScrollOffset() : 0;
boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
&& mouseY < y2 && mouseY >= -scroll
&& mouseY < getParent().getHeight() - 13 - scroll;
boolean hText = hovering && mouseX < x3;
boolean hBox = hovering && mouseX >= x3;
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionProgram);
// tooltip
if(hText)
gui.setTooltip(setting.getWrappedDescription(200));
// background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x1, y1, 0).next();
bufferBuilder.vertex(matrix, x1, y2, 0).next();
bufferBuilder.vertex(matrix, x3, y2, 0).next();
bufferBuilder.vertex(matrix, x3, y1, 0).next();
tessellator.draw();
// box
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
hBox ? opacity * 1.5F : opacity);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0).next();
bufferBuilder.vertex(matrix, x3, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y1, 0).next();
tessellator.draw();
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0).next();
bufferBuilder.vertex(matrix, x3, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y1, 0).next();
bufferBuilder.vertex(matrix, x3, y1, 0).next();
tessellator.draw();
// setting name
RenderSystem.setShaderColor(1, 1, 1, 1);
TextRenderer fr = WurstClient.MC.textRenderer;
String text = setting.getName() + ": " + setting.getBlockNames().size();
fr.draw(matrixStack, text, x1, y1 + 2, txtColor);
fr.draw(matrixStack, "Edit...", x3 + 2, y1 + 2, txtColor);
GL11.glEnable(GL11.GL_BLEND);
return setting.getName() + ": " + setting.getBlockNames().size();
}
@Override
public int getDefaultWidth()
protected Setting getSetting()
{
TextRenderer fr = WurstClient.MC.textRenderer;
String text = setting.getName() + ": " + setting.getBlockNames().size();
return fr.getWidth(text) + buttonWidth + 6;
}
@Override
public int getDefaultHeight()
{
return 11;
return setting;
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.clickgui.components;
import java.util.Objects;
import net.wurstclient.clickgui.screens.EditBookOffersScreen;
import net.wurstclient.settings.BookOffersSetting;
import net.wurstclient.settings.Setting;
public final class BookOffersEditButton extends AbstractListEditButton
{
private final BookOffersSetting setting;
public BookOffersEditButton(BookOffersSetting setting)
{
this.setting = Objects.requireNonNull(setting);
setWidth(getDefaultWidth());
setHeight(getDefaultHeight());
}
@Override
protected void openScreen()
{
MC.setScreen(new EditBookOffersScreen(MC.currentScreen, setting));
}
@Override
protected String getText()
{
return setting.getName() + ": " + setting.getOffers().size();
}
@Override
protected Setting getSetting()
{
return setting;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -7,137 +7,38 @@
*/
package net.wurstclient.clickgui.components;
import org.joml.Matrix4f;
import org.lwjgl.opengl.GL11;
import java.util.Objects;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import net.wurstclient.WurstClient;
import net.wurstclient.clickgui.ClickGui;
import net.wurstclient.clickgui.Component;
import net.wurstclient.clickgui.screens.EditItemListScreen;
import net.wurstclient.settings.ItemListSetting;
import net.wurstclient.settings.Setting;
public final class ItemListEditButton extends Component
public final class ItemListEditButton extends AbstractListEditButton
{
private final ItemListSetting setting;
private int buttonWidth;
public ItemListEditButton(ItemListSetting setting)
{
this.setting = setting;
TextRenderer fr = WurstClient.MC.textRenderer;
buttonWidth = fr.getWidth("Edit...");
this.setting = Objects.requireNonNull(setting);
setWidth(getDefaultWidth());
setHeight(getDefaultHeight());
}
@Override
public void handleMouseClick(double mouseX, double mouseY, int mouseButton)
protected void openScreen()
{
if(mouseButton != 0)
return;
if(mouseX < getX() + getWidth() - buttonWidth - 4)
return;
WurstClient.MC.setScreen(
new EditItemListScreen(WurstClient.MC.currentScreen, setting));
MC.setScreen(new EditItemListScreen(MC.currentScreen, setting));
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
float partialTicks)
protected String getText()
{
ClickGui gui = WurstClient.INSTANCE.getGui();
float[] bgColor = gui.getBgColor();
float[] acColor = gui.getAcColor();
int txtColor = gui.getTxtColor();
float opacity = gui.getOpacity();
int x1 = getX();
int x2 = x1 + getWidth();
int x3 = x2 - buttonWidth - 4;
int y1 = getY();
int y2 = y1 + getHeight();
int scroll = getParent().isScrollingEnabled()
? getParent().getScrollOffset() : 0;
boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
&& mouseY < y2 && mouseY >= -scroll
&& mouseY < getParent().getHeight() - 13 - scroll;
boolean hText = hovering && mouseX < x3;
boolean hBox = hovering && mouseX >= x3;
Matrix4f matrix = matrixStack.peek().getPositionMatrix();
Tessellator tessellator = RenderSystem.renderThreadTesselator();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShader(GameRenderer::getPositionProgram);
// tooltip
if(hText)
gui.setTooltip(setting.getWrappedDescription(200));
// background
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
opacity);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x1, y1, 0).next();
bufferBuilder.vertex(matrix, x1, y2, 0).next();
bufferBuilder.vertex(matrix, x3, y2, 0).next();
bufferBuilder.vertex(matrix, x3, y1, 0).next();
tessellator.draw();
// box
RenderSystem.setShaderColor(bgColor[0], bgColor[1], bgColor[2],
hBox ? opacity * 1.5F : opacity);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0).next();
bufferBuilder.vertex(matrix, x3, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y1, 0).next();
tessellator.draw();
RenderSystem.setShaderColor(acColor[0], acColor[1], acColor[2], 0.5F);
bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP,
VertexFormats.POSITION);
bufferBuilder.vertex(matrix, x3, y1, 0).next();
bufferBuilder.vertex(matrix, x3, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y2, 0).next();
bufferBuilder.vertex(matrix, x2, y1, 0).next();
bufferBuilder.vertex(matrix, x3, y1, 0).next();
tessellator.draw();
// setting name
RenderSystem.setShaderColor(1, 1, 1, 1);
TextRenderer fr = WurstClient.MC.textRenderer;
String text = setting.getName() + ": " + setting.getItemNames().size();
fr.draw(matrixStack, text, x1, y1 + 2, txtColor);
fr.draw(matrixStack, "Edit...", x3 + 2, y1 + 2, txtColor);
GL11.glEnable(GL11.GL_BLEND);
return setting.getName() + ": " + setting.getItemNames().size();
}
@Override
public int getDefaultWidth()
protected Setting getSetting()
{
TextRenderer fr = WurstClient.MC.textRenderer;
String text = setting.getName() + ": " + setting.getItemNames().size();
return fr.getWidth(text) + buttonWidth + 6;
}
@Override
public int getDefaultHeight()
{
return 11;
return setting;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -0,0 +1,421 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.clickgui.screens;
import java.util.List;
import java.util.stream.Collectors;
import org.lwjgl.glfw.GLFW;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.wurstclient.hacks.autolibrarian.BookOffer;
import net.wurstclient.settings.BookOffersSetting;
import net.wurstclient.util.ListWidget;
import net.wurstclient.util.MathUtils;
import net.wurstclient.util.RenderUtils;
public final class AddBookOfferScreen extends Screen
{
private final Screen prevScreen;
private final BookOffersSetting bookOffers;
private ListGui listGui;
private TextFieldWidget levelField;
private ButtonWidget levelPlusButton;
private ButtonWidget levelMinusButton;
private TextFieldWidget priceField;
private ButtonWidget pricePlusButton;
private ButtonWidget priceMinusButton;
private ButtonWidget addButton;
private ButtonWidget cancelButton;
private BookOffer offerToAdd;
private boolean alreadyAdded;
public AddBookOfferScreen(Screen prevScreen, BookOffersSetting bookOffers)
{
super(Text.literal(""));
this.prevScreen = prevScreen;
this.bookOffers = bookOffers;
}
@Override
public void init()
{
listGui = new ListGui(client, this);
levelField = new TextFieldWidget(client.textRenderer, width / 2 - 32,
height - 74, 28, 12, Text.literal(""));
addSelectableChild(levelField);
levelField.setMaxLength(2);
levelField.setTextPredicate(t -> {
if(t.isEmpty())
return true;
if(!MathUtils.isInteger(t))
return false;
int level = Integer.parseInt(t);
if(level < 1 || level > 10)
return false;
if(offerToAdd == null)
return true;
Enchantment enchantment = offerToAdd.getEnchantment();
return level <= enchantment.getMaxLevel();
});
levelField.setChangedListener(t -> {
if(!MathUtils.isInteger(t))
return;
int level = Integer.parseInt(t);
updateLevel(level, false);
});
priceField = new TextFieldWidget(client.textRenderer, width / 2 - 32,
height - 58, 28, 12, Text.literal(""));
addSelectableChild(priceField);
priceField.setMaxLength(2);
priceField.setTextPredicate(t -> t.isEmpty() || MathUtils.isInteger(t)
&& Integer.parseInt(t) >= 1 && Integer.parseInt(t) <= 64);
priceField.setChangedListener(t -> {
if(!MathUtils.isInteger(t))
return;
int price = Integer.parseInt(t);
updatePrice(price, false);
});
addDrawableChild(levelPlusButton =
ButtonWidget.builder(Text.literal("+"), b -> updateLevel(1, true))
.dimensions(width / 2 + 2, height - 74, 20, 12).build());
levelPlusButton.active = false;
addDrawableChild(levelMinusButton =
ButtonWidget.builder(Text.literal("-"), b -> updateLevel(-1, true))
.dimensions(width / 2 + 26, height - 74, 20, 12).build());
levelMinusButton.active = false;
addDrawableChild(pricePlusButton =
ButtonWidget.builder(Text.literal("+"), b -> updatePrice(1, true))
.dimensions(width / 2 + 2, height - 58, 20, 12).build());
pricePlusButton.active = false;
addDrawableChild(priceMinusButton =
ButtonWidget.builder(Text.literal("-"), b -> updatePrice(-1, true))
.dimensions(width / 2 + 26, height - 58, 20, 12).build());
priceMinusButton.active = false;
addDrawableChild(
addButton = ButtonWidget.builder(Text.literal("Add"), b -> {
bookOffers.add(offerToAdd);
client.setScreen(prevScreen);
}).dimensions(width / 2 - 102, height - 28, 100, 20).build());
addButton.active = false;
addDrawableChild(cancelButton = ButtonWidget
.builder(Text.literal("Cancel"), b -> client.setScreen(prevScreen))
.dimensions(width / 2 + 2, height - 28, 100, 20).build());
}
private void updateLevel(int i, boolean offset)
{
if(offerToAdd == null)
return;
String id = offerToAdd.id();
int level = offset ? offerToAdd.level() + i : i;
int price = offerToAdd.price();
Enchantment enchantment = offerToAdd.getEnchantment();
if(level < 1 || level > enchantment.getMaxLevel())
return;
updateSelectedOffer(new BookOffer(id, level, price));
}
private void updatePrice(int i, boolean offset)
{
if(offerToAdd == null)
return;
String id = offerToAdd.id();
int level = offerToAdd.level();
int price = offset ? offerToAdd.price() + i : i;
if(price < 1 || price > 64)
return;
updateSelectedOffer(new BookOffer(id, level, price));
}
private void updateSelectedOffer(BookOffer offer)
{
offerToAdd = offer;
alreadyAdded = offer != null && bookOffers.contains(offer);
addButton.active = offer != null && !alreadyAdded;
if(offer == null)
{
if(!levelField.getText().isEmpty())
levelField.setText("");
if(!priceField.getText().isEmpty())
priceField.setText("");
}else
{
String level = "" + offer.level();
if(!levelField.getText().equals(level))
levelField.setText(level);
String price = "" + offer.price();
if(!priceField.getText().equals(price))
priceField.setText(price);
}
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton)
{
boolean childClicked = super.mouseClicked(mouseX, mouseY, mouseButton);
levelField.mouseClicked(mouseX, mouseY, mouseButton);
priceField.mouseClicked(mouseX, mouseY, mouseButton);
listGui.mouseClicked(mouseX, mouseY, mouseButton);
if(!childClicked && mouseButton == 0
&& (mouseX < (width - 220) / 2 || mouseX > width / 2 + 129)
&& mouseY >= 32 && mouseY <= height - 80)
{
listGui.selected = -1;
updateSelectedOffer(null);
}
if(mouseButton == GLFW.GLFW_MOUSE_BUTTON_4)
cancelButton.onPress();
return childClicked;
}
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button,
double deltaX, double deltaY)
{
listGui.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
}
@Override
public boolean mouseReleased(double mouseX, double mouseY, int button)
{
listGui.mouseReleased(mouseX, mouseY, button);
return super.mouseReleased(mouseX, mouseY, button);
}
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount)
{
listGui.mouseScrolled(mouseX, mouseY, amount);
return super.mouseScrolled(mouseX, mouseY, amount);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int int_3)
{
switch(keyCode)
{
case GLFW.GLFW_KEY_ENTER:
if(addButton.active)
addButton.onPress();
break;
case GLFW.GLFW_KEY_ESCAPE:
cancelButton.onPress();
break;
case GLFW.GLFW_KEY_UP:
listGui.selectItem(listGui.selected - 1, 0, 0, 0);
break;
case GLFW.GLFW_KEY_DOWN:
listGui.selectItem(listGui.selected + 1, 0, 0, 0);
break;
default:
break;
}
return super.keyPressed(keyCode, scanCode, int_3);
}
@Override
public void tick()
{
levelPlusButton.active = offerToAdd != null
&& offerToAdd.level() < offerToAdd.getEnchantment().getMaxLevel();
levelMinusButton.active = offerToAdd != null && offerToAdd.level() > 1;
pricePlusButton.active = offerToAdd != null && offerToAdd.price() < 64;
priceMinusButton.active = offerToAdd != null && offerToAdd.price() > 1;
levelField.tick();
priceField.tick();
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
float partialTicks)
{
listGui.render(matrixStack, mouseX, mouseY, partialTicks);
matrixStack.push();
matrixStack.translate(0, 0, 300);
TextRenderer tr = client.textRenderer;
String titleText = "Available Books (" + listGui.getItemCount() + ")";
drawCenteredTextWithShadow(matrixStack, tr, titleText, width / 2, 12,
0xffffff);
levelField.render(matrixStack, mouseX, mouseY, partialTicks);
priceField.render(matrixStack, mouseX, mouseY, partialTicks);
super.render(matrixStack, mouseX, mouseY, partialTicks);
matrixStack.translate(width / 2 - 100, 0, 0);
drawTextWithShadow(matrixStack, tr, "Level:", 0, height - 72, 0xf0f0f0);
drawTextWithShadow(matrixStack, tr, "Max price:", 0, height - 56,
0xf0f0f0);
if(alreadyAdded && offerToAdd != null)
{
String errorText = offerToAdd.getEnchantmentNameWithLevel()
+ " is already on your list!";
drawTextWithShadow(matrixStack, tr, errorText, 0, height - 40,
0xff5555);
}
matrixStack.pop();
RenderUtils.drawItem(matrixStack, new ItemStack(Items.EMERALD),
width / 2 - 16, height - 58, false);
}
@Override
public boolean shouldPause()
{
return false;
}
@Override
public boolean shouldCloseOnEsc()
{
return false;
}
private static class ListGui extends ListWidget
{
private final MinecraftClient mc;
private final AddBookOfferScreen screen;
private final List<BookOffer> list;
private int selected = -1;
private long lastTime;
public ListGui(MinecraftClient mc, AddBookOfferScreen screen)
{
super(mc, screen.width, screen.height, 32, screen.height - 80, 30);
this.mc = mc;
this.screen = screen;
list = Registries.ENCHANTMENT.stream().map(BookOffer::create)
.filter(BookOffer::isValid).sorted()
.collect(Collectors.toList());
}
@Override
protected int getItemCount()
{
return list.size();
}
@Override
protected boolean selectItem(int index, int button, double mouseX,
double mouseY)
{
if(button != 0)
return true;
if(index == selected && Util.getMeasuringTimeMs() - lastTime < 250
&& screen.addButton.active)
screen.addButton.onPress();
if(index >= 0 && index < list.size())
{
selected = index;
screen.updateSelectedOffer(list.get(index));
lastTime = Util.getMeasuringTimeMs();
}
return true;
}
@Override
protected boolean isSelectedItem(int index)
{
return index == selected;
}
@Override
protected void renderBackground()
{
}
@Override
protected void renderItem(MatrixStack matrixStack, int index, int x,
int y, int var4, int mouseX, int mouseY, float partialTicks)
{
if(isSelectedItem(index))
drawSelectionOutline(matrixStack, x, y);
Item item = Registries.ITEM.get(new Identifier("enchanted_book"));
ItemStack stack = new ItemStack(item);
RenderUtils.drawItem(matrixStack, stack, x + 1, y + 1, true);
TextRenderer tr = mc.textRenderer;
BookOffer bookOffer = list.get(index);
Enchantment enchantment = bookOffer.getEnchantment();
String name = bookOffer.getEnchantmentName();
int nameColor = enchantment.isCursed() ? 0xff5555 : 0xf0f0f0;
tr.draw(matrixStack, name, x + 28, y, nameColor);
tr.draw(matrixStack, bookOffer.id(), x + 28, y + 9, 0xa0a0a0);
int maxLevel = enchantment.getMaxLevel();
String levels = maxLevel + (maxLevel == 1 ? " level" : " levels");
tr.draw(matrixStack, levels, x + 28, y + 18, 0xa0a0a0);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -10,23 +10,21 @@ package net.wurstclient.clickgui.screens;
import java.util.List;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.wurstclient.settings.BlockListSetting;
import net.wurstclient.util.BlockUtils;
import net.wurstclient.util.ListWidget;
import net.wurstclient.util.RenderUtils;
public final class EditBlockListScreen extends Screen
{
@ -198,7 +196,7 @@ public final class EditBlockListScreen extends Screen
matrixStack.pop();
listGui.renderIconAndGetName(matrixStack, new ItemStack(blockToAdd),
RenderUtils.drawItem(matrixStack, new ItemStack(blockToAdd),
width / 2 - 164, height - 52, false);
}
@ -265,62 +263,14 @@ public final class EditBlockListScreen extends Screen
ItemStack stack = new ItemStack(block);
TextRenderer fr = mc.textRenderer;
String displayName =
renderIconAndGetName(matrixStack, stack, x + 1, y + 1, true);
RenderUtils.drawItem(matrixStack, stack, x + 1, y + 1, true);
String displayName = stack.isEmpty() ? "\u00a7ounknown block\u00a7r"
: stack.getName().getString();
fr.draw(matrixStack, displayName, x + 28, y, 0xf0f0f0);
fr.draw(matrixStack, name, x + 28, y + 9, 0xa0a0a0);
fr.draw(matrixStack,
"ID: " + Block.getRawIdFromState(block.getDefaultState()),
x + 28, y + 18, 0xa0a0a0);
}
private String renderIconAndGetName(MatrixStack matrixStack,
ItemStack stack, int x, int y, boolean large)
{
if(stack.isEmpty())
{
matrixStack.push();
matrixStack.translate(x, y, 0);
if(large)
matrixStack.scale(1.5F, 1.5F, 1.5F);
else
matrixStack.scale(0.75F, 0.75F, 0.75F);
DiffuseLighting.enableGuiDepthLighting();
mc.getItemRenderer().renderInGuiWithOverrides(matrixStack,
new ItemStack(Blocks.GRASS_BLOCK), 0, 0);
DiffuseLighting.disableGuiDepthLighting();
matrixStack.pop();
matrixStack.push();
matrixStack.translate(x, y, 0);
if(large)
matrixStack.scale(2, 2, 2);
GL11.glDisable(GL11.GL_DEPTH_TEST);
TextRenderer fr = mc.textRenderer;
fr.drawWithShadow(matrixStack, "?", 3, 2, 0xf0f0f0);
GL11.glEnable(GL11.GL_DEPTH_TEST);
matrixStack.pop();
return "\u00a7ounknown block\u00a7r";
}
matrixStack.push();
matrixStack.translate(x, y, 0);
if(large)
matrixStack.scale(1.5F, 1.5F, 1.5F);
else
matrixStack.scale(0.75F, 0.75F, 0.75F);
DiffuseLighting.enableGuiDepthLighting();
mc.getItemRenderer().renderInGuiWithOverrides(matrixStack, stack, 0,
0);
DiffuseLighting.disableGuiDepthLighting();
matrixStack.pop();
return stack.getName().getString();
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -8,7 +8,6 @@
package net.wurstclient.clickgui.screens;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
@ -16,13 +15,12 @@ import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.wurstclient.WurstClient;
import net.wurstclient.settings.BlockSetting;
import net.wurstclient.util.BlockUtils;
import net.wurstclient.util.RenderUtils;
public final class EditBlockScreen extends Screen
{
@ -143,7 +141,7 @@ public final class EditBlockScreen extends Screen
if(blockToAdd == null)
blockToAdd = Blocks.AIR;
renderIcon(matrixStack, new ItemStack(blockToAdd),
RenderUtils.drawItem(matrixStack, new ItemStack(blockToAdd),
-64 + width / 2 - 100 + 52, 115 - 52, false);
}
@ -158,43 +156,4 @@ public final class EditBlockScreen extends Screen
{
return false;
}
private void renderIcon(MatrixStack matrixStack, ItemStack stack, int x,
int y, boolean large)
{
matrixStack.push();
matrixStack.translate(x, y, 0);
float scale = large ? 1.5F : 0.75F;
matrixStack.scale(scale, scale, scale);
DiffuseLighting.enableGuiDepthLighting();
ItemStack grass = new ItemStack(Blocks.GRASS_BLOCK);
ItemStack renderStack = !stack.isEmpty() ? stack : grass;
WurstClient.MC.getItemRenderer().renderInGuiWithOverrides(matrixStack,
renderStack, 0, 0);
DiffuseLighting.disableGuiDepthLighting();
matrixStack.pop();
if(stack.isEmpty())
renderQuestionMark(matrixStack, x, y, large);
}
private void renderQuestionMark(MatrixStack matrixStack, int x, int y,
boolean large)
{
matrixStack.push();
matrixStack.translate(x, y, 0);
if(large)
matrixStack.scale(2, 2, 2);
GL11.glDisable(GL11.GL_DEPTH_TEST);
TextRenderer tr = WurstClient.MC.textRenderer;
tr.drawWithShadow(matrixStack, "?", 3, 2, 0xf0f0f0);
GL11.glEnable(GL11.GL_DEPTH_TEST);
matrixStack.pop();
}
}

View File

@ -0,0 +1,328 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.clickgui.screens;
import org.lwjgl.glfw.GLFW;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.wurstclient.hacks.autolibrarian.BookOffer;
import net.wurstclient.settings.BookOffersSetting;
import net.wurstclient.util.MathUtils;
import net.wurstclient.util.RenderUtils;
public final class EditBookOfferScreen extends Screen
{
private final Screen prevScreen;
private final BookOffersSetting bookOffers;
private TextFieldWidget levelField;
private ButtonWidget levelPlusButton;
private ButtonWidget levelMinusButton;
private TextFieldWidget priceField;
private ButtonWidget pricePlusButton;
private ButtonWidget priceMinusButton;
private ButtonWidget saveButton;
private ButtonWidget cancelButton;
private BookOffer offerToSave;
private int index;
private boolean alreadyAdded;
public EditBookOfferScreen(Screen prevScreen, BookOffersSetting bookOffers,
int index)
{
super(Text.literal(""));
this.prevScreen = prevScreen;
this.bookOffers = bookOffers;
this.index = index;
offerToSave = bookOffers.getOffers().get(index);
}
@Override
public void init()
{
levelField = new TextFieldWidget(client.textRenderer, width / 2 - 32,
110, 28, 12, Text.literal(""));
addSelectableChild(levelField);
levelField.setMaxLength(2);
levelField.setTextPredicate(t -> {
if(t.isEmpty())
return true;
if(!MathUtils.isInteger(t))
return false;
int level = Integer.parseInt(t);
if(level < 1 || level > 10)
return false;
if(offerToSave == null)
return true;
Enchantment enchantment = offerToSave.getEnchantment();
return level <= enchantment.getMaxLevel();
});
levelField.setChangedListener(t -> {
if(!MathUtils.isInteger(t))
return;
int level = Integer.parseInt(t);
updateLevel(level, false);
});
priceField = new TextFieldWidget(client.textRenderer, width / 2 - 32,
126, 28, 12, Text.literal(""));
addSelectableChild(priceField);
priceField.setMaxLength(2);
priceField.setTextPredicate(t -> t.isEmpty() || MathUtils.isInteger(t)
&& Integer.parseInt(t) >= 1 && Integer.parseInt(t) <= 64);
priceField.setChangedListener(t -> {
if(!MathUtils.isInteger(t))
return;
int price = Integer.parseInt(t);
updatePrice(price, false);
});
addDrawableChild(levelPlusButton =
ButtonWidget.builder(Text.literal("+"), b -> updateLevel(1, true))
.dimensions(width / 2 + 2, 110, 20, 12).build());
levelPlusButton.active = false;
addDrawableChild(levelMinusButton =
ButtonWidget.builder(Text.literal("-"), b -> updateLevel(-1, true))
.dimensions(width / 2 + 26, 110, 20, 12).build());
levelMinusButton.active = false;
addDrawableChild(pricePlusButton =
ButtonWidget.builder(Text.literal("+"), b -> updatePrice(1, true))
.dimensions(width / 2 + 2, 126, 20, 12).build());
pricePlusButton.active = false;
addDrawableChild(priceMinusButton =
ButtonWidget.builder(Text.literal("-"), b -> updatePrice(-1, true))
.dimensions(width / 2 + 26, 126, 20, 12).build());
priceMinusButton.active = false;
addDrawableChild(
saveButton = ButtonWidget.builder(Text.literal("Save"), b -> {
if(offerToSave == null || !offerToSave.isValid())
return;
bookOffers.replace(index, offerToSave);
client.setScreen(prevScreen);
}).dimensions(width / 2 - 102, height / 3 * 2, 100, 20).build());
saveButton.active = false;
addDrawableChild(cancelButton = ButtonWidget
.builder(Text.literal("Cancel"), b -> client.setScreen(prevScreen))
.dimensions(width / 2 + 2, height / 3 * 2, 100, 20).build());
updateSelectedOffer(offerToSave);
}
private void updateLevel(int i, boolean offset)
{
if(offerToSave == null)
return;
String id = offerToSave.id();
int level = offset ? offerToSave.level() + i : i;
int price = offerToSave.price();
Enchantment enchantment = offerToSave.getEnchantment();
if(level < 1 || level > enchantment.getMaxLevel())
return;
updateSelectedOffer(new BookOffer(id, level, price));
}
private void updatePrice(int i, boolean offset)
{
if(offerToSave == null)
return;
String id = offerToSave.id();
int level = offerToSave.level();
int price = offset ? offerToSave.price() + i : i;
if(price < 1 || price > 64)
return;
updateSelectedOffer(new BookOffer(id, level, price));
}
private void updateSelectedOffer(BookOffer offer)
{
offerToSave = offer;
alreadyAdded =
offer != null && !offer.equals(bookOffers.getOffers().get(index))
&& bookOffers.contains(offer);
saveButton.active = offer != null && !alreadyAdded;
if(offer == null)
{
if(!levelField.getText().isEmpty())
levelField.setText("");
if(!priceField.getText().isEmpty())
priceField.setText("");
}else
{
String level = "" + offer.level();
if(!levelField.getText().equals(level))
levelField.setText(level);
String price = "" + offer.price();
if(!priceField.getText().equals(price))
priceField.setText(price);
}
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton)
{
boolean childClicked = super.mouseClicked(mouseX, mouseY, mouseButton);
levelField.mouseClicked(mouseX, mouseY, mouseButton);
priceField.mouseClicked(mouseX, mouseY, mouseButton);
if(mouseButton == GLFW.GLFW_MOUSE_BUTTON_4)
cancelButton.onPress();
return childClicked;
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int int_3)
{
switch(keyCode)
{
case GLFW.GLFW_KEY_ENTER:
if(saveButton.active)
saveButton.onPress();
break;
case GLFW.GLFW_KEY_ESCAPE:
cancelButton.onPress();
break;
default:
break;
}
return super.keyPressed(keyCode, scanCode, int_3);
}
@Override
public void tick()
{
levelPlusButton.active = offerToSave != null
&& offerToSave.level() < offerToSave.getEnchantment().getMaxLevel();
levelMinusButton.active =
offerToSave != null && offerToSave.level() > 1;
pricePlusButton.active =
offerToSave != null && offerToSave.price() < 64;
priceMinusButton.active =
offerToSave != null && offerToSave.price() > 1;
levelField.tick();
priceField.tick();
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
float partialTicks)
{
renderBackgroundTexture(matrixStack);
matrixStack.push();
matrixStack.translate(0, 0, 300);
TextRenderer tr = client.textRenderer;
String titleText = "Edit Book Offer";
drawCenteredTextWithShadow(matrixStack, tr, titleText, width / 2, 12,
0xffffff);
int x = width / 2 - 100;
int y = 64;
Item item = Registries.ITEM.get(new Identifier("enchanted_book"));
ItemStack stack = new ItemStack(item);
RenderUtils.drawItem(matrixStack, stack, x + 1, y + 1, true);
BookOffer bookOffer = offerToSave;
String name = bookOffer.getEnchantmentNameWithLevel();
Enchantment enchantment = bookOffer.getEnchantment();
int nameColor = enchantment.isCursed() ? 0xff5555 : 0xffffff;
tr.drawWithShadow(matrixStack, name, x + 28, y, nameColor);
tr.draw(matrixStack, bookOffer.id(), x + 28, y + 9, 0xa0a0a0);
String price;
if(bookOffer.price() >= 64)
price = "any price";
else
{
price = "max " + bookOffer.price();
RenderUtils.drawItem(matrixStack, new ItemStack(Items.EMERALD),
x + 28 + tr.getWidth(price), y + 16, false);
}
tr.draw(matrixStack, price, x + 28, y + 18, 0xa0a0a0);
levelField.render(matrixStack, mouseX, mouseY, partialTicks);
priceField.render(matrixStack, mouseX, mouseY, partialTicks);
super.render(matrixStack, mouseX, mouseY, partialTicks);
matrixStack.translate(width / 2 - 100, 112, 0);
drawTextWithShadow(matrixStack, tr, "Level:", 0, 0, 0xf0f0f0);
drawTextWithShadow(matrixStack, tr, "Max price:", 0, 16, 0xf0f0f0);
if(alreadyAdded && offerToSave != null)
{
String errorText = offerToSave.getEnchantmentNameWithLevel()
+ " is already on your list!";
drawTextWithShadow(matrixStack, tr, errorText, 0, 32, 0xff5555);
}
matrixStack.pop();
RenderUtils.drawItem(matrixStack, new ItemStack(Items.EMERALD),
width / 2 - 16, 126, false);
}
@Override
public boolean shouldPause()
{
return false;
}
@Override
public boolean shouldCloseOnEsc()
{
return false;
}
}

View File

@ -0,0 +1,284 @@
/*
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.clickgui.screens;
import java.util.List;
import org.lwjgl.glfw.GLFW;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.wurstclient.hacks.autolibrarian.BookOffer;
import net.wurstclient.settings.BookOffersSetting;
import net.wurstclient.util.ListWidget;
import net.wurstclient.util.RenderUtils;
public final class EditBookOffersScreen extends Screen
{
private final Screen prevScreen;
private final BookOffersSetting bookOffers;
private ListGui listGui;
private ButtonWidget editButton;
private ButtonWidget removeButton;
private ButtonWidget doneButton;
public EditBookOffersScreen(Screen prevScreen, BookOffersSetting bookOffers)
{
super(Text.literal(""));
this.prevScreen = prevScreen;
this.bookOffers = bookOffers;
}
@Override
public void init()
{
listGui = new ListGui(client, this, bookOffers.getOffers());
addDrawableChild(
ButtonWidget
.builder(Text.literal("Add"),
b -> client
.setScreen(new AddBookOfferScreen(this, bookOffers)))
.dimensions(width / 2 - 154, height - 56, 100, 20).build());
addDrawableChild(
editButton = ButtonWidget.builder(Text.literal("Edit"), b -> {
boolean selected = listGui.selected >= 0
&& listGui.selected < listGui.list.size();
if(!selected)
return;
client.setScreen(new EditBookOfferScreen(this, bookOffers,
listGui.selected));
}).dimensions(width / 2 - 50, height - 56, 100, 20).build());
editButton.active = false;
addDrawableChild(removeButton = ButtonWidget
.builder(Text.literal("Remove"),
b -> bookOffers.remove(listGui.selected))
.dimensions(width / 2 + 54, height - 56, 100, 20).build());
removeButton.active = false;
addDrawableChild(ButtonWidget.builder(Text.literal("Reset to Defaults"),
b -> client.setScreen(new ConfirmScreen(b2 -> {
if(b2)
bookOffers.resetToDefaults();
client.setScreen(EditBookOffersScreen.this);
}, Text.literal("Reset to Defaults"),
Text.literal("Are you sure?"))))
.dimensions(width - 106, 6, 100, 20).build());
addDrawableChild(doneButton = ButtonWidget
.builder(Text.literal("Done"), b -> client.setScreen(prevScreen))
.dimensions(width / 2 - 100, height - 32, 200, 20).build());
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton)
{
boolean childClicked = super.mouseClicked(mouseX, mouseY, mouseButton);
listGui.mouseClicked(mouseX, mouseY, mouseButton);
if(!childClicked && mouseButton == 0 && (mouseX < (width - 220) / 2
|| mouseX > width / 2 + 129 || mouseY < 32 || mouseY > height - 64))
listGui.selected = -1;
if(mouseButton == GLFW.GLFW_MOUSE_BUTTON_4)
doneButton.onPress();
return childClicked;
}
@Override
public boolean mouseDragged(double double_1, double double_2, int int_1,
double double_3, double double_4)
{
listGui.mouseDragged(double_1, double_2, int_1, double_3, double_4);
return super.mouseDragged(double_1, double_2, int_1, double_3,
double_4);
}
@Override
public boolean mouseReleased(double double_1, double double_2, int int_1)
{
listGui.mouseReleased(double_1, double_2, int_1);
return super.mouseReleased(double_1, double_2, int_1);
}
@Override
public boolean mouseScrolled(double double_1, double double_2,
double double_3)
{
listGui.mouseScrolled(double_1, double_2, double_3);
return super.mouseScrolled(double_1, double_2, double_3);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int int_3)
{
switch(keyCode)
{
case GLFW.GLFW_KEY_ENTER:
if(editButton.active)
editButton.onPress();
break;
case GLFW.GLFW_KEY_DELETE:
removeButton.onPress();
break;
case GLFW.GLFW_KEY_ESCAPE:
case GLFW.GLFW_KEY_BACKSPACE:
doneButton.onPress();
break;
case GLFW.GLFW_KEY_UP:
listGui.selectItem(listGui.selected - 1, 0, 0, 0);
break;
case GLFW.GLFW_KEY_DOWN:
listGui.selectItem(listGui.selected + 1, 0, 0, 0);
break;
default:
break;
}
return super.keyPressed(keyCode, scanCode, int_3);
}
@Override
public void tick()
{
boolean selected =
listGui.selected >= 0 && listGui.selected < listGui.list.size();
editButton.active = selected;
removeButton.active = selected;
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
float partialTicks)
{
listGui.render(matrixStack, mouseX, mouseY, partialTicks);
matrixStack.push();
matrixStack.translate(0, 0, 300);
drawCenteredTextWithShadow(matrixStack, client.textRenderer,
bookOffers.getName() + " (" + listGui.getItemCount() + ")",
width / 2, 12, 0xffffff);
super.render(matrixStack, mouseX, mouseY, partialTicks);
matrixStack.pop();
}
@Override
public boolean shouldPause()
{
return false;
}
@Override
public boolean shouldCloseOnEsc()
{
return false;
}
private static class ListGui extends ListWidget
{
private final MinecraftClient mc;
private final List<BookOffer> list;
private int selected = -1;
public ListGui(MinecraftClient mc, EditBookOffersScreen screen,
List<BookOffer> list)
{
super(mc, screen.width, screen.height, 32, screen.height - 64, 30);
this.mc = mc;
this.list = list;
}
@Override
protected int getItemCount()
{
return list.size();
}
@Override
protected boolean selectItem(int index, int int_2, double var3,
double var4)
{
if(index >= 0 && index < list.size())
selected = index;
return true;
}
@Override
protected boolean isSelectedItem(int index)
{
return index == selected;
}
@Override
protected void renderBackground()
{
}
@Override
protected void renderItem(MatrixStack matrixStack, int index, int x,
int y, int var4, int var5, int var6, float partialTicks)
{
if(isSelectedItem(index))
drawSelectionOutline(matrixStack, x, y);
Item item = Registries.ITEM.get(new Identifier("enchanted_book"));
ItemStack stack = new ItemStack(item);
RenderUtils.drawItem(matrixStack, stack, x + 1, y + 1, true);
TextRenderer tr = mc.textRenderer;
BookOffer bookOffer = list.get(index);
String name = bookOffer.getEnchantmentNameWithLevel();
Enchantment enchantment = bookOffer.getEnchantment();
int nameColor = enchantment.isCursed() ? 0xff5555 : 0xf0f0f0;
tr.draw(matrixStack, name, x + 28, y, nameColor);
tr.draw(matrixStack, bookOffer.id(), x + 28, y + 9, 0xa0a0a0);
String price;
if(bookOffer.price() >= 64)
price = "any price";
else
{
price = "max " + bookOffer.price();
RenderUtils.drawItem(matrixStack, new ItemStack(Items.EMERALD),
x + 28 + tr.getWidth(price), y + 16, false);
}
tr.draw(matrixStack, price, x + 28, y + 18, 0xa0a0a0);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
@ -10,16 +10,13 @@ package net.wurstclient.clickgui.screens;
import java.util.List;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.ConfirmScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -29,6 +26,7 @@ import net.minecraft.util.Identifier;
import net.wurstclient.settings.ItemListSetting;
import net.wurstclient.util.ItemUtils;
import net.wurstclient.util.ListWidget;
import net.wurstclient.util.RenderUtils;
public final class EditItemListScreen extends Screen
{
@ -205,7 +203,7 @@ public final class EditItemListScreen extends Screen
matrixStack.pop();
listGui.renderIconAndGetName(matrixStack, new ItemStack(itemToAdd),
RenderUtils.drawItem(matrixStack, new ItemStack(itemToAdd),
width / 2 - 164, height - 52, false);
}
@ -272,62 +270,13 @@ public final class EditItemListScreen extends Screen
ItemStack stack = new ItemStack(item);
TextRenderer fr = mc.textRenderer;
String displayName =
renderIconAndGetName(matrixStack, stack, x + 1, y + 1, true);
RenderUtils.drawItem(matrixStack, stack, x + 1, y + 1, true);
String displayName = stack.isEmpty() ? "\u00a7ounknown item\u00a7r"
: stack.getName().getString();
fr.draw(matrixStack, displayName, x + 28, y, 0xf0f0f0);
fr.draw(matrixStack, name, x + 28, y + 9, 0xa0a0a0);
fr.draw(matrixStack, "ID: " + Registries.ITEM.getRawId(item),
x + 28, y + 18, 0xa0a0a0);
}
private String renderIconAndGetName(MatrixStack matrixStack,
ItemStack stack, int x, int y, boolean large)
{
if(stack.isEmpty())
{
matrixStack.push();
matrixStack.translate(x, y, 0);
if(large)
matrixStack.scale(1.5F, 1.5F, 1.5F);
else
matrixStack.scale(0.75F, 0.75F, 0.75F);
DiffuseLighting.enableGuiDepthLighting();
mc.getItemRenderer().renderInGuiWithOverrides(matrixStack,
new ItemStack(Blocks.GRASS_BLOCK), 0, 0);
DiffuseLighting.disableGuiDepthLighting();
matrixStack.pop();
matrixStack.push();
matrixStack.translate(x, y, 0);
if(large)
matrixStack.scale(2, 2, 2);
GL11.glDisable(GL11.GL_DEPTH_TEST);
TextRenderer fr = mc.textRenderer;
fr.drawWithShadow(matrixStack, "?", 3, 2, 0xf0f0f0);
GL11.glEnable(GL11.GL_DEPTH_TEST);
matrixStack.pop();
return "\u00a7ounknown item\u00a7r";
}
matrixStack.push();
matrixStack.translate(x, y, 0);
if(large)
matrixStack.scale(1.5F, 1.5F, 1.5F);
else
matrixStack.scale(0.75F, 0.75F, 0.75F);
DiffuseLighting.enableGuiDepthLighting();
mc.getItemRenderer().renderInGuiWithOverrides(matrixStack, stack, 0,
0);
DiffuseLighting.disableGuiDepthLighting();
matrixStack.pop();
return stack.getName().getString();
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Wurst-Imperium and contributors.
* Copyright (c) 2014-2023 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this

Some files were not shown because too many files have changed in this diff Show More