Merge branch 'master' into master

This commit is contained in:
noil 2020-05-25 17:46:44 -04:00 committed by GitHub
commit 7fb7c9b299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 123 additions and 19 deletions

View File

@ -107,7 +107,15 @@ public final class Seppuku {
this.getEventManager().dispatchEvent(new EventLoad());
this.logger.info("Loaded");
// Add runtime hook to listen for shutdown to save configs
Runtime.getRuntime().addShutdownHook(new Thread("Seppuku Shutdown Hook") {
@Override
public void run() {
getConfigManager().saveAll();
}
});
this.logger.info("Seppuku Loaded Successfully");
}
public void errorChat(String message) {

View File

@ -41,6 +41,10 @@ public class HudComponent {
}
public void keyTyped(char typedChar, int keyCode) {
}
public boolean collidesWith(HudComponent other) {
// Collision x-axis?
boolean collisionX = this.x + this.w > other.x &&

View File

@ -35,6 +35,12 @@ public final class GuiHudEditor extends GuiScreen {
}
}
}
for (HudComponent component : Seppuku.INSTANCE.getHudManager().getComponentList()) {
if (component.isVisible()) {
component.keyTyped(typedChar, keyCode);
}
}
}
@Override

View File

@ -0,0 +1,73 @@
package me.rigamortis.seppuku.impl.gui.hud.component;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.gui.hud.component.DraggableHudComponent;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor;
import me.rigamortis.seppuku.impl.module.render.HudModule;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
import java.security.Key;
/**
* created by noil on 5/7/2020
*/
public final class FirstLaunchComponent extends DraggableHudComponent {
private Module hudModule;
private String textData;
public FirstLaunchComponent() {
super("FirstLaunch");
final String textData = "Welcome to Seppuku Client!\n\n" +
"Press ~ (tilda/grave) to open the GUI / hud-editor.";
this.setTextData(textData);
this.setVisible(true);
this.setSnappable(false);
this.setW(200);
this.setH(38);
this.setX(2);
this.setY(2);
this.hudModule = Seppuku.INSTANCE.getModuleManager().find(HudModule.class);
}
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
super.render(mouseX, mouseY, partialTicks);
final Minecraft mc = Minecraft.getMinecraft();
// Background
RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF202020);
// Render text data
mc.fontRenderer.drawSplitString(this.textData, (int) this.getX() + 2, (int) this.getY() + 2, 200, 0xFFFFFFFF);
}
public void onClose() {
if (this.hudModule != null) {
if(this.hudModule.isEnabled()) {
this.hudModule.onEnable();
}else {
this.hudModule.toggle();
}
this.hudModule.setEnabled(true);
}
this.setVisible(false);
}
public String getTextData() {
return textData;
}
public void setTextData(String textData) {
this.textData = textData;
}
}

View File

@ -30,9 +30,6 @@ public class PopupComponent extends DraggableHudComponent {
final Minecraft mc = Minecraft.getMinecraft();
if (!(mc.currentScreen instanceof GuiHudEditor)) // ensure we are in the hud editor screen only
return;
// background
RenderUtil.drawRect(this.getX(), this.getY(), this.getX() + this.getW(), this.getY() + this.getH(), 0xFF202020);
@ -54,7 +51,7 @@ public class PopupComponent extends DraggableHudComponent {
mouseY <= this.getY() + CLOSE_BUTTON_SIZE;
if (insideCloseButton && button == 0) {
this.setVisible(false);
this.onCloseButton();
}
}
@ -65,4 +62,8 @@ public class PopupComponent extends DraggableHudComponent {
public void setTextData(String textData) {
this.textData = textData;
}
public void onCloseButton() {
this.setVisible(false);
}
}

View File

@ -33,13 +33,13 @@ public final class TutorialComponent extends PopupComponent {
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
super.render(mouseX, mouseY, partialTicks);
final Minecraft mc = Minecraft.getMinecraft();
if (!(mc.currentScreen instanceof GuiHudEditor)) // ensure we are in the hud editor screen only
return;
super.render(mouseX, mouseY, partialTicks);
// drag me!
mc.fontRenderer.drawStringWithShadow("(drag me!)", this.getX() + this.getW() - 80, this.getY() + 10, 0xFFAAAAAA);
}

View File

@ -18,7 +18,7 @@ public final class ConfigManager {
private File moduleConfigDir;
private File hudComponentConfigDir;
private boolean firstLaunch;
private boolean firstLaunch = false;
private List<Configurable> configurableList = new ArrayList<>();
@ -31,7 +31,7 @@ public final class ConfigManager {
private void generateDirectories() {
this.configDir = new File(CONFIG_PATH);
if (!this.configDir.exists()) {
this.firstLaunch = true;
this.setFirstLaunch(true);
this.configDir.mkdirs();
}

View File

@ -5,11 +5,14 @@ import me.rigamortis.seppuku.api.event.render.EventRender2D;
import me.rigamortis.seppuku.api.gui.hud.component.HudComponent;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.ReflectionUtil;
import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor;
import me.rigamortis.seppuku.impl.gui.hud.anchor.AnchorPoint;
import me.rigamortis.seppuku.impl.gui.hud.component.*;
import me.rigamortis.seppuku.impl.gui.hud.component.module.ModuleListComponent;
import me.rigamortis.seppuku.impl.module.render.HudModule;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiIngame;
import net.minecraft.client.gui.ScaledResolution;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -29,6 +32,8 @@ public final class HudManager {
private List<HudComponent> componentList = new CopyOnWriteArrayList<>();
private List<AnchorPoint> anchorPoints = new ArrayList<>();
private final FirstLaunchComponent firstLaunchComponent;
public HudManager() {
final ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft());
@ -86,6 +91,9 @@ public final class HudManager {
// Organize alphabetically
this.componentList = this.componentList.stream().sorted((obj1, obj2) -> obj1.getName().compareTo(obj2.getName())).collect(Collectors.toList());
// Create first launch component
this.firstLaunchComponent = new FirstLaunchComponent();
Seppuku.INSTANCE.getEventManager().addEventListener(this);
}
@ -98,6 +106,16 @@ public final class HudManager {
public void onRender(EventRender2D event) {
final Minecraft mc = Minecraft.getMinecraft();
if (this.firstLaunchComponent != null && mc.world != null) {
if (Seppuku.INSTANCE.getConfigManager().isFirstLaunch()) {
if (mc.currentScreen instanceof GuiHudEditor) {
firstLaunchComponent.onClose();
} else if (firstLaunchComponent.isVisible()) {
firstLaunchComponent.render(0, 0, event.getPartialTicks());
}
}
}
final int chatHeight = (mc.currentScreen instanceof GuiChat) ? 14 : 0;
for (AnchorPoint point : this.anchorPoints) {

View File

@ -24,7 +24,6 @@ public final class KeybindsModule extends Module {
if(mod != null) {
if(mod.getType() != ModuleType.HIDDEN && event.getKey() == Keyboard.getKeyIndex(mod.getKey()) && Keyboard.getKeyIndex(mod.getKey()) != Keyboard.KEY_NONE) {
mod.toggle();
Seppuku.INSTANCE.getConfigManager().saveAll();
}
}
}

View File

@ -167,9 +167,9 @@ public final class ElytraFlyModule extends Module {
mc.player.motionX = 0;
mc.player.motionZ = 0;
if (mc.player.movementInput.jump) {
mc.player.motionY = this.speed.getValue() / 2;
mc.player.motionY = this.speed.getValue() / 2;
} else if (mc.player.movementInput.sneak) {
mc.player.motionY = -this.speed.getValue() / 2;
mc.player.motionY = -this.speed.getValue() / 2;
}
if (mc.player.movementInput.moveStrafe != 0 || mc.player.movementInput.moveForward != 0) {
mc.player.motionX = directionSpeedControl[0];

View File

@ -23,7 +23,7 @@ public final class HudModule extends Module {
public final Value<Boolean> hidePotions = new Value<Boolean>("HidePotions", new String[]{"HidePotions", "HidePots", "Hide_Potions"}, "Hides the Vanilla potion hud (at the top right of the screen).", true);
public HudModule() {
super("Hud", new String[]{"Overlay"}, "Shows lots of useful info", "NONE", -1, ModuleType.RENDER);
super("Hud", new String[]{"Overlay"}, "Renders hud components on the screen.", "NONE", -1, ModuleType.RENDER);
this.setHidden(true);
}
@ -31,11 +31,7 @@ public final class HudModule extends Module {
public void render(EventRender2D event) {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.gameSettings.showDebugInfo) {
return;
}
if (mc.currentScreen instanceof GuiHudEditor) {
if (mc.gameSettings.showDebugInfo || mc.currentScreen instanceof GuiHudEditor || mc.player == null) {
return;
}
@ -43,7 +39,6 @@ public final class HudModule extends Module {
GlStateManager.enableBlend();
for (HudComponent component : Seppuku.INSTANCE.getHudManager().getComponentList()) {
if (component.isVisible()) {
//dont render components with the TOP_CENTER anchor if we are looking at the tab list
if (component instanceof DraggableHudComponent) {
final DraggableHudComponent draggableComponent = (DraggableHudComponent) component;