diff --git a/LoTAS-Fabric/build.gradle b/LoTAS-Fabric/build.gradle
index c719fc68..5e297ccf 100644
--- a/LoTAS-Fabric/build.gradle
+++ b/LoTAS-Fabric/build.gradle
@@ -1,6 +1,6 @@
import groovy.json.JsonOutput
-version = "2.0.4"
+version = "2.1.0"
group = "de.pfannekuchen.lotas"
apply from: 'versions2/preprocessor.gradle'
diff --git a/LoTAS-Fabric/settings.gradle b/LoTAS-Fabric/settings.gradle
index 5d640092..83d6f1b9 100644
--- a/LoTAS-Fabric/settings.gradle
+++ b/LoTAS-Fabric/settings.gradle
@@ -18,7 +18,8 @@ def versions2 = [
'1.17.1',
'1.18.2',
'1.19.0',
- '1.19.2'
+ '1.19.2',
+ '1.19.3'
]
versions2.collect {":versions2:$it"}.each {
include it
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/LoTASModContainer.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/LoTASModContainer.java
index 81823237..7f2a49fc 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/LoTASModContainer.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/LoTASModContainer.java
@@ -8,18 +8,12 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URL;
-import java.net.URLConnection;
-import java.nio.file.Files;
-import java.util.List;
import javax.net.ssl.HttpsURLConnection;
-import org.apache.commons.io.FileUtils;
-
import de.pfannekuchen.lotas.core.utils.ConfigUtils;
import de.pfannekuchen.lotas.core.utils.TextureYoinker;
import de.pfannekuchen.lotas.gui.InfoHud;
-import de.pfannekuchen.lotas.gui.SeedListScreen;
import de.pfannekuchen.lotas.mods.TickrateChangerMod;
import net.fabricmc.api.ModInitializer;
import net.minecraft.client.Minecraft;
@@ -47,15 +41,10 @@ public class LoTASModContainer implements ModInitializer {
@Override
public void onInitialize() {
hud = new InfoHud();
- /* Load the Seeds for the (disabled) Seeds Menu */
- try {
- loadSeeds();
- } catch (Exception e1) {
- e1.printStackTrace();
- }
/* Load the Configuration and set the tickrate if required */
try {
- ConfigUtils.init(new File(Minecraft.getInstance().gameDirectory, "lotas.properties"));
+ Minecraft mc = Minecraft.getInstance();
+ ConfigUtils.init(new File(mc.gameDirectory, "lotas.properties"));
if (ConfigUtils.getBoolean("tools", "saveTickrate"))
TickrateChangerMod.updateTickrate(ConfigUtils.getInt("hidden", "tickrate"));
} catch (IOException e) {
@@ -106,8 +95,11 @@ public static void loadShieldsTASTools() {
} catch (IOException e) {
e.printStackTrace();
}
+ //#if MC>=11903
+//$$ LoTASModContainer.shield=new ResourceLocation("lotas", "shield/bottleshield.png");
+ //#else
LoTASModContainer.shield=new ResourceLocation("textures/shield/bottleshield.png");
- // AccessorModelLoader.setShieldBase(new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEX, new Identifier("lotas","pan_cake")));
+ //#endif
}
public static void loadShieldsMCTAS() {
@@ -130,33 +122,10 @@ public static void loadShieldsMCTAS() {
e.printStackTrace();
}
+ //#if MC>=11903
+//$$ LoTASModContainer.shield=new ResourceLocation("lotas", "shield/bottleshield.png");
+ //#else
LoTASModContainer.shield=new ResourceLocation("textures/shield/bottleshield.png");
+ //#endif
}
-
-
- /**
- * Loads a list of seeds together with preview images from mgnet.work/seeds/seedsX.XX.X.txt and creates a List
- * @throws IOException
- */
- public void loadSeeds() throws Exception {
- File file = new File("seeddata.txt");
- try {
- URL url = new URL("https://data.mgnet.work/lotas/seeds/1.14.4.txt"); // TODO: wait why does this say 1.14.4...
- URLConnection conn = url.openConnection();
- conn.setReadTimeout(5000);
- file.createNewFile();
- FileUtils.copyInputStreamToFile(conn.getInputStream(), file);
- } catch (Exception e) {
- e.printStackTrace();
- }
- List strings = Files.readAllLines(file.toPath());
- for (String line : strings) {
- String seed = line.split(":")[0];
- String name = line.split(":")[1];
- String description = line.split(":")[2];
-
- SeedListScreen.seeds.add(new SeedListScreen.Seed(seed, name, description));
- }
- }
-
}
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/MCVer.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/MCVer.java
index 6df23e13..d3120d94 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/MCVer.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/MCVer.java
@@ -1,15 +1,9 @@
package de.pfannekuchen.lotas.core;
-import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
-import com.mojang.blaze3d.vertex.BufferBuilder;
-import com.mojang.blaze3d.vertex.DefaultVertexFormat;
-import com.mojang.blaze3d.vertex.Tesselator;
-import com.mojang.math.Quaternion;
import de.pfannekuchen.lotas.mixin.accessors.AccessorButtons;
-import de.pfannekuchen.lotas.mixin.accessors.AccessorScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiComponent;
@@ -18,13 +12,13 @@
import net.minecraft.client.gui.components.Button.OnPress;
import net.minecraft.client.gui.components.Checkbox;
import net.minecraft.client.gui.components.EditBox;
-import net.minecraft.client.gui.components.Widget;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
/**
@@ -51,7 +45,8 @@ public class MCVer {
//#endif
//$$ }
//$$ public static net.minecraft.server.level.ServerLevel getCurrentLevel() {
-//$$ return (ServerLevel) Minecraft.getInstance().getSingleplayerServer().getPlayerList().getPlayers().get(0).level;
+//$$ ServerPlayer player = Minecraft.getInstance().getSingleplayerServer().getPlayerList().getPlayers().get(0);
+//$$ return (ServerLevel) player.level;
//$$ }
//$$ public static String getCurrentWorldFolder() {
//#if MC>=11601
@@ -90,18 +85,23 @@ public static String getCurrentWorldFolder() {
//$$ GuiComponent.fill(stack, a, b, c, d, e);
//$$ }
//$$ public static void drawCenteredString(Screen s, String text, int x, int y, int color) {
+//$$ Minecraft mc = Minecraft.getInstance();
//$$ if (text == null) text = " ";
//#if MC>=11605
-//$$ Screen.drawCenteredString(stack, Minecraft.getInstance().font, text, x, y, color);
+//$$ Screen.drawCenteredString(stack, mc.font, text, x, y, color);
//#else
-//$$ s.drawCenteredString(stack, Minecraft.getInstance().font, net.minecraft.network.chat.FormattedText.of(text), x, y, color);
+//$$ s.drawCenteredString(stack, mc.font, net.minecraft.network.chat.FormattedText.of(text), x, y, color);
//#endif
//$$ }
//$$ public static Checkbox Checkbox(int i, int j, int k, int l, String text, boolean bl) {
//$$ return new Checkbox(i, j, k, l, MCVer.literal(text), bl);
//$$ }
//$$ public static Button Button(int i, int j, int k, int l, String text, OnPress onpress) {
+ //#if MC>=11903
+//$$ return Button.builder(MCVer.literal(text), onpress).pos(i, j).size(k, l).build();
+ //#else
//$$ return new Button(i, j, k, l, MCVer.literal(text), onpress);
+ //#endif
//$$ }
//$$ public static EditBox EditBox(Font f, int i, int j, int k, int l, String text) {
//$$ return new EditBox(f, i, j, k, l, MCVer.literal(text));
@@ -116,17 +116,27 @@ public static String getCurrentWorldFolder() {
//$$ component.render(stack, mouseX, mouseY, delta);
//$$ }
//$$ public static void drawShadow(String text, int x, int y, int color) {
+//$$ Minecraft mc = Minecraft.getInstance();
//$$ if(text!=null) {
//#if MC>=11605
-//$$ Minecraft.getInstance().font.drawShadow(stack, text, x, y, color);
+//$$ mc.font.drawShadow(stack, text, x, y, color);
//#else
-//$$ Minecraft.getInstance().font.drawShadow(stack, net.minecraft.network.chat.FormattedText.of(text), x, y, color);
+//$$ mc.font.drawShadow(stack, net.minecraft.network.chat.FormattedText.of(text), x, y, color);
//#endif
//$$ }
//$$ }
//$$ public static void renderBackground(Screen screen) {
//$$ screen.renderBackground(stack);
//$$ }
+ //#if MC>=11903
+//$$ public static org.joml.Quaternionf fromYXZ(float f, float g, float h) {
+//$$ org.joml.Quaternionf quaternion = new org.joml.Quaternionf(0.0f, 0.0f, 0.0f, 1.0f);
+//$$ quaternion.mul(new org.joml.Quaternionf(0.0f, (float)Math.sin(f / 2.0f), 0.0f, (float)Math.cos(f / 2.0f)));
+//$$ quaternion.mul(new org.joml.Quaternionf((float)Math.sin(g / 2.0f), 0.0f, 0.0f, (float)Math.cos(g / 2.0f)));
+//$$ quaternion.mul(new org.joml.Quaternionf(0.0f, 0.0f, (float)Math.sin(h / 2.0f), (float)Math.cos(h / 2.0f)));
+//$$ return quaternion;
+//$$ }
+ //#endif
//#else
public static Checkbox Checkbox(int i, int j, int k, int l, String text, boolean bl) {
return new Checkbox(i, j, k, l, text, bl);
@@ -243,7 +253,11 @@ public static void drawCenteredString(Screen s, String text, int x, int y, int c
//$$
//$$ public static void rotated(Object stack, double i, double j, double k, double l) {
//$$ com.mojang.blaze3d.vertex.PoseStack poseStack = (com.mojang.blaze3d.vertex.PoseStack)stack;
-//$$ poseStack.mulPose(new Quaternion((float)i,(float) j,(float) k,(float) l));
+ //#if MC>=11903
+//$$ poseStack.mulPose(new org.joml.Quaternionf((float)i,(float) j,(float) k,(float) l));
+ //#else
+//$$ poseStack.mulPose(new com.mojang.math.Quaternion((float)i,(float) j,(float) k,(float) l));
+ //#endif
//$$ }
//$$
//$$ public static void enableDepthTest() {
@@ -446,7 +460,23 @@ public static BlockEntityRenderDispatcher getBlockEntityDispatcher() {
}
//#endif
- // =============================================== 1.16.5 | 1.17 BUTTONS =========================================
+ // =============================================== 1.19.3 BUTTONS ================================================
+ //#if MC>=11903
+//$$ public static T addButton(Screen screen, T button) {
+//$$ ((de.pfannekuchen.lotas.core.utils.AccessorScreen2)screen).addRenderableWidget(button);
+//$$ return button;
+//$$ }
+//$$
+//$$ public static net.minecraft.client.gui.components.Renderable getButton(Screen obj, int buttonID) {
+//$$ return ((AccessorButtons)obj).getButtons().get(buttonID);
+//$$ }
+//$$
+//$$
+//$$ public static int getButtonSize(Screen obj) {
+//$$ return ((AccessorButtons)obj).getButtons().size();
+//$$ }
+ //#else
+ // =============================================== 1.16.5 | 1.17 | 1.19.2 BUTTONS =========================================
//#if MC>=11700
//$$ public static T addButton(Screen screen, T button) {
//$$ ((de.pfannekuchen.lotas.core.utils.AccessorScreen2)screen).addRenderableWidget(button);
@@ -454,13 +484,13 @@ public static BlockEntityRenderDispatcher getBlockEntityDispatcher() {
//$$ }
//#else
public static T addButton(Screen screen, T button) {
- ((AccessorScreen)screen).invokeAddButton(button);
+ ((de.pfannekuchen.lotas.mixin.accessors.AccessorScreen)screen).invokeAddButton(button);
return button;
}
//#endif
-
+
//#if MC>=11700
-//$$ public static Widget getButton(Screen obj, int buttonID) {
+//$$ public static net.minecraft.client.gui.components.Widget getButton(Screen obj, int buttonID) {
//$$ return ((AccessorButtons)obj).getButtons().get(buttonID);
//$$ }
//#else
@@ -468,7 +498,7 @@ public static AbstractWidget getButton(Screen obj, int buttonID){
return (AbstractWidget) ((AccessorButtons)obj).getButtons().get(buttonID);
}
//#endif
-
+
//#if MC>=11700
//$$ public static int getButtonSize(Screen obj) {
//$$ return ((AccessorButtons)obj).getButtons().size();
@@ -478,6 +508,7 @@ public static int getButtonSize(Screen obj){
return ((AccessorButtons)obj).getButtons().size();
}
//#endif
+ //#endif
// =============================================== 1.16.5 | 1.17 TEXTURES =========================================
public static void bind(TextureManager textureManager, ResourceLocation resource) {
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/AccessorScreen2.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/AccessorScreen2.java
index fb56fc8d..506745d2 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/AccessorScreen2.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/AccessorScreen2.java
@@ -1,8 +1,13 @@
package de.pfannekuchen.lotas.core.utils;
+
//#if MC>=11800
//$$ public interface AccessorScreen2 {
+ //#if MC>=11903
+//$$ public T addRenderableWidget(T widget);
+ //#else
//$$ public T addRenderableWidget(T widget);
+ //#endif
//#else
//#if MC>=11700
//$$ public interface AccessorScreen2 {
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/PotionRenderer.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/PotionRenderer.java
index 457600be..b4431617 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/PotionRenderer.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/PotionRenderer.java
@@ -19,11 +19,15 @@ public static void render(Object poseStack, double xPos, double yPos, double rot
MCVer.translated(poseStack, xPos, yPos, 0);
MCVer.scaled(poseStack, scale, scale, scale);
+ //#if MC>=11903
+//$$ MCVer.stack.mulPose(MCVer.fromYXZ(0F, 0F, (float) rotation) );
+ //#else
//#if MC>=11700
//$$ MCVer.stack.mulPose(com.mojang.math.Quaternion.fromXYZ(0, 0, (float) rotation));
//#else
MCVer.rotated(poseStack, rotation, 0, 0, 1);
//#endif
+ //#endif
int orangeBright=0xE35720;
int orange=0xC24218;
@@ -133,11 +137,15 @@ public static void render(Object poseStack, double xPos, double yPos, double rot
renderPixel(6, y, white);
renderPixel(7, y, white);
+ //#if MC>=11903
+//$$ MCVer.stack.mulPose(MCVer.fromYXZ(0F, 0F, (float) -rotation));
+ //#else
//#if MC>=11700
//$$ MCVer.stack.mulPose(com.mojang.math.Quaternion.fromXYZ(0, 0, (float) -rotation));
//#else
MCVer.rotated(poseStack, -rotation, 0, 0, 1);
//#endif
+ //#endif
MCVer.scaled(poseStack, (double)1/scale, (double)1/scale, (double)1/scale);
MCVer.translated(poseStack, -xPos, -yPos, 0);
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/RenderUtils.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/RenderUtils.java
index 7d69faf0..b37d6bc3 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/RenderUtils.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/utils/RenderUtils.java
@@ -84,7 +84,11 @@ public static void drawSolidBox(Object poseStack, AABB bb, float r, float g, flo
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferBuilder = tesselator.getBuilder();
//#if MC>=11700
+ //#if MC>=11903
+//$$ org.joml.Matrix4f matrix = ((com.mojang.blaze3d.vertex.PoseStack) poseStack).last().pose();
+ //#else
//$$ com.mojang.math.Matrix4f matrix = ((com.mojang.blaze3d.vertex.PoseStack) poseStack).last().pose();
+ //#endif
//$$ com.mojang.blaze3d.systems.RenderSystem.setShader(net.minecraft.client.renderer.GameRenderer::getPositionColorShader);
//$$ bufferBuilder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
//$$ bufferBuilder.vertex(matrix, (float)bb.minX, (float)bb.minY, (float)bb.minZ).color(r, g, b, a).endVertex();
@@ -169,7 +173,11 @@ public static void drawOutlinedBox(Object poseStack, AABB bb) {
BufferBuilder bufferBuilder = tesselator.getBuilder();
//#if MC>=11700
+ //#if MC>=11903
+//$$ org.joml.Matrix4f matrix = ((com.mojang.blaze3d.vertex.PoseStack) poseStack).last().pose();
+ //#else
//$$ com.mojang.math.Matrix4f matrix = ((com.mojang.blaze3d.vertex.PoseStack) poseStack).last().pose();
+ //#endif
//$$ com.mojang.blaze3d.systems.RenderSystem.setShader(net.minecraft.client.renderer.GameRenderer::getPositionColorShader);
//$$ bufferBuilder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
//$$ bufferBuilder.vertex(matrix, (float)bb.minX, (float)bb.minY, (float)bb.minZ).color(1F, 1F, 1F, 1F).endVertex();
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/DeadbushDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/DeadbushDropManipulation.java
index e58501a5..f432c0d3 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/DeadbushDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/DeadbushDropManipulation.java
@@ -79,6 +79,13 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ drop0Stick.setPosition(x, y + 96);
+//$$ drop1Stick.setPosition(x, y + 120);
+//$$ drop2Stick.setPosition(x, y + 144);
+ //#else
enabled.x = x;
enabled.y = y;
@@ -88,6 +95,7 @@ public void update() {
drop1Stick.y = y + 120;
drop2Stick.x = x;
drop2Stick.y = y + 144;
+ //#endif
drop0Stick.setWidth(width - x - 128 - 16);
drop1Stick.setWidth(width - x - 128 - 16);
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/GlowstoneDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/GlowstoneDropManipulation.java
index 9e034835..33e3f6fd 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/GlowstoneDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/GlowstoneDropManipulation.java
@@ -79,6 +79,13 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ drop2Glowstonedust.setPosition(x, y + 96);
+//$$ drop3Glowstonedust.setPosition(x, y + 120);
+//$$ drop4Glowstonedust.setPosition(x, y + 144);
+ //#else
enabled.x = x;
enabled.y = y;
@@ -88,6 +95,7 @@ public void update() {
drop3Glowstonedust.y = y + 120;
drop4Glowstonedust.x = x;
drop4Glowstonedust.y = y + 144;
+ //#endif
drop2Glowstonedust.setWidth(width - x - 128 - 16);
drop3Glowstonedust.setWidth(width - x - 128 - 16);
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/GravelDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/GravelDropManipulation.java
index 5e5f0e73..31c0db7e 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/GravelDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/GravelDropManipulation.java
@@ -70,12 +70,20 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ dropGravel.setPosition(x, y + 96);
+//$$ dropFlint.setPosition(x, y + 120);
+ //#else
enabled.x = x;
enabled.y = y;
dropGravel.x = x;
dropGravel.y = y + 96;
dropFlint.x = x;
dropFlint.y = y + 120;
+ //#endif
+
dropGravel.setWidth(width - x - 128 - 16);
dropFlint.setWidth(width - x - 128 - 16);
}
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/LeafDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/LeafDropManipulation.java
index 890b08d3..fdece8d5 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/LeafDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/LeafDropManipulation.java
@@ -86,6 +86,13 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ dropApple.setPosition(x, y + 96);
+//$$ dropStick.setPosition(x+22, y + 96);
+//$$ dropSapling.setPosition(x+44, y + 96);
+ //#else
enabled.x = x;
enabled.y = y;
dropApple.x = x;
@@ -94,6 +101,7 @@ public void update() {
dropStick.y = y + 96;
dropSapling.x = x + 44;
dropSapling.y = y + 96;
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/OreDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/OreDropManipulation.java
index 9c828d7c..55be3572 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/OreDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/OreDropManipulation.java
@@ -68,6 +68,13 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ optimizeRedstone.setPosition(x, 64);
+//$$ optimizeLapis.setPosition(x, 80);
+//$$ optimizeCopper.setPosition(x, 96);
+ //#else
enabled.x = x;
enabled.y = y;
optimizeRedstone.y = 64;
@@ -78,6 +85,7 @@ public void update() {
//$$ optimizeCopper.x = x;
//$$ optimizeCopper.y = 96;
//#endif
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/PlantsDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/PlantsDropManipulation.java
index 331eecfd..b6d66583 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/PlantsDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/PlantsDropManipulation.java
@@ -89,6 +89,20 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ optimizeCarrots.setPosition(x, 64);
+//$$ optimizeBeetroot.setPosition(x, 80);
+//$$ optimizeMelons.setPosition(x, 96);
+//$$ optimizeWheat.setPosition(x, 112);
+//$$ optimizePotato.setPosition(x, 128);
+//$$ optimizeCocoa.setPosition(x, 144);
+//$$ optimizeChorus.setPosition(x, 160);
+//$$ optimizeNetherwart.setPosition(x, 176);
+//$$ optimizeSweetBerry.setPosition(x, 192);
+//$$ optimizeMushroom.setPosition(x, 208);
+ //#else
enabled.x = x;
enabled.y = y;
optimizeCarrots.y = 64;
@@ -111,6 +125,7 @@ public void update() {
optimizeNetherwart.x = x;
optimizeSweetBerry.x = x;
optimizeMushroom.x = x;
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/SealanternDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/SealanternDropManipulation.java
index 9d4aca69..7c93de4c 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/SealanternDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/blockdrops/SealanternDropManipulation.java
@@ -67,6 +67,12 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ drop2Pris.setPosition(x, y + 96);
+//$$ drop3Pris.setPosition(x, y + 120);
+ //#else
enabled.x = x;
enabled.y = y;
@@ -74,7 +80,8 @@ public void update() {
drop2Pris.y = y + 96;
drop3Pris.x = x;
drop3Pris.y = y + 120;
-
+ //#endif
+
drop2Pris.setWidth(width - x - 128 - 16);
drop3Pris.setWidth(width - x - 128 - 16);
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/DrownedDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/DrownedDropManipulation.java
index 342c9c49..7b287583 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/DrownedDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/DrownedDropManipulation.java
@@ -63,10 +63,16 @@ public List redirectDrops(Entity entity, int looting) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ drops.setPosition(x, y + 96);
+ //#else
enabled.x = x;
enabled.y = y;
drops.x = x;
drops.y = y + 96;
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/FishDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/FishDropManipulation.java
index fcda845d..6101b04a 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/FishDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/FishDropManipulation.java
@@ -62,6 +62,15 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ optimizeCod.setPosition(x, y + 64);
+//$$ optimizePufferfish.setPosition(x, y + 80);
+//$$ optimizeDolphin.setPosition(x, y + 96);
+//$$ optimizeSalmon.setPosition(x, y + 112);
+//$$ optimizeTropical.setPosition(x, y + 128);
+ //#else
enabled.x = x;
enabled.y = y;
optimizeCod.y = 64;
@@ -74,6 +83,7 @@ public void update() {
optimizeDolphin.x = x;
optimizeSalmon.x = x;
optimizeTropical.x = x;
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/MonsterDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/MonsterDropManipulation.java
index e141888d..68b20820 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/MonsterDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/MonsterDropManipulation.java
@@ -98,6 +98,21 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ optimizeCaveSpider.setPosition(x, 64);
+//$$ optimizeEnderman.setPosition(x, 80);
+//$$ optimizeElderGuardian.setPosition(x, 96);
+//$$ optimizeCreeper.setPosition(x, 112);
+//$$ optimizePhantom.setPosition(x, 128);
+//$$ optimizeSlime.setPosition(x, 144);
+//$$ optimizeVindicator.setPosition(x, 160);
+//$$ optimizeSkeleton.setPosition(x, 176);
+//$$ optimizeShulker.setPosition(x, 192);
+//$$ optimizeGuardian.setPosition(x, 208);
+//$$ optimizeWitch.setPosition(x, 224);
+ //#else
enabled.x = x;
enabled.y = y;
optimizeCaveSpider.y = 64;
@@ -122,6 +137,7 @@ public void update() {
optimizeShulker.x = x;
optimizeGuardian.x = x;
optimizeWitch.x = x;
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/NetherMobDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/NetherMobDropManipulation.java
index 375c82fa..08ad440f 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/NetherMobDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/NetherMobDropManipulation.java
@@ -66,6 +66,15 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ optimizeBlaze.setPosition(x, 64);
+//$$ optimizePigman.setPosition(x, 80);
+//$$ optimizeMagmaCube.setPosition(x, 96);
+//$$ optimizeWitherskeleton.setPosition(x, 112);
+//$$ optimizeGhast.setPosition(x, 128);
+ //#else
enabled.x = x;
enabled.y = y;
optimizeBlaze.y = 64;
@@ -78,6 +87,7 @@ public void update() {
optimizeMagmaCube.x = x;
optimizeWitherskeleton.x = x;
optimizeGhast.x = x;
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/PassiveDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/PassiveDropManipulation.java
index f1940d93..7da5fe03 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/PassiveDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/PassiveDropManipulation.java
@@ -135,6 +135,25 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ optimizeChicken.setPosition(x, 64);
+//$$ optimizeSkeletonhorse.setPosition(x, 80);
+//$$ optimizeCat.setPosition(x, 96);
+//$$ optimizeMooshroom.setPosition(x, 112);
+//$$ optimizeCow.setPosition(x, 128);
+//$$ optimizePig.setPosition(x, 144);
+//$$ optimizeParrot.setPosition(x, 160);
+//$$ optimizeRabbit.setPosition(x, 176);
+//$$ optimizeSnowgolem.setPosition(x, 192);
+//$$ optimizeSheep.setPosition(x, 208);
+//$$ optimizeSquid.setPosition(x, 224);
+//$$ optimizeHorses.setPosition(x, 240);
+//$$ optimizeTurtle.setPosition(x, 256);
+//$$ optimizeIronGolem.setPosition(x, 272);
+//$$ optimizePolarbear.setPosition(x, 288);
+ //#else
enabled.x = x;
enabled.y = y;
optimizeChicken.y = 64;
@@ -167,6 +186,7 @@ public void update() {
optimizeTurtle.x = x;
optimizeIronGolem.x = x;
optimizePolarbear.x = x;
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/ZombieDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/ZombieDropManipulation.java
index 0877c8c4..7b993387 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/ZombieDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/entitydrops/ZombieDropManipulation.java
@@ -78,6 +78,13 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ dropIron.setPosition(x, y + 96);
+//$$ dropPotato.setPosition(x+22, y + 96);
+//$$ dropCarrot.setPosition(x+44, y + 96);
+ //#else
enabled.x = x;
enabled.y = y;
dropIron.x = x;
@@ -86,6 +93,7 @@ public void update() {
dropPotato.y = y + 96;
dropCarrot.x = x + 44;
dropCarrot.y = y + 96;
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/rest/BarteringDropManipulation.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/rest/BarteringDropManipulation.java
index 5a5779d0..f3678468 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/rest/BarteringDropManipulation.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/dropmanipulation/drops/rest/BarteringDropManipulation.java
@@ -113,10 +113,16 @@ public List redirectDrops(Entity entity, int lootingBonus) {
@Override
public void update() {
+ //#if MC>=11903
+//$$ enabled.setPosition(x, y);
+//$$
+//$$ elementwidgets.setPosition(x, y + 80);
+ //#else
enabled.x = x;
enabled.y = y;
elementwidgets.x = x;
elementwidgets.y = y + 80;
+ //#endif
}
@Override
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/DropManipulationScreen.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/DropManipulationScreen.java
index 4e005e5a..93237a73 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/DropManipulationScreen.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/DropManipulationScreen.java
@@ -130,7 +130,11 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
//$$ MCVer.enableDepthTest();
//$$ MCVer.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
//$$
+ //#if MC>=11903
+//$$ org.joml.Matrix4f matrix = MCVer.stack.last().pose();
+ //#else
//$$ com.mojang.math.Matrix4f matrix = MCVer.stack.last().pose();
+ //#endif
//$$ com.mojang.blaze3d.systems.RenderSystem.setShader(net.minecraft.client.renderer.GameRenderer::getPositionShader);
//$$ bufferBuilder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
//$$ bufferBuilder.vertex(matrix, 24, 24, 0).endVertex();
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/InfoHud.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/InfoHud.java
index 2f9a95be..72f68427 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/InfoHud.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/InfoHud.java
@@ -10,6 +10,7 @@
import java.util.Properties;
import java.util.concurrent.Callable;
+import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL11;
@@ -101,18 +102,25 @@ private void setDefaults(String string, int y) {
*/
public void identify(int mouseX, int mouseY) {
int index = 0;
+ Minecraft mc = Minecraft.getInstance();
for (InfoLabel label : lists) {
int x=0;
int y=0;
try {
x = Integer.parseInt(configuration.getProperty(label.displayName + "_x"));
y = Integer.parseInt(configuration.getProperty(label.displayName + "_y"));
+
+ Pair newPos = getScreenOffset(x, y, label);
+
+ x = newPos.getLeft();
+ y = newPos.getRight();
+
} catch (NumberFormatException e) {
configuration.setProperty(label.displayName + "_x", "0");
configuration.setProperty(label.displayName + "_y", "0");
saveConfig();
}
- int w = x + Minecraft.getInstance().font.width(label.renderText);
+ int w = x + mc.font.width(label.renderText);
int h = y + 15;
if (mouseX >= x && mouseX <= w && mouseY >= y && mouseY <= h) {
@@ -195,8 +203,9 @@ private double snapToGridY(double y) {
* Saves the Configuration
*/
private void saveConfig() {
+ Minecraft mc = Minecraft.getInstance();
try {
- File tasmodDir = new File(Minecraft.getInstance().gameDirectory, "lotas");
+ File tasmodDir = new File(mc.gameDirectory, "lotas");
tasmodDir.mkdir();
File configFile = new File(tasmodDir, "infogui.cfg");
if (!configFile.exists()) configFile.createNewFile();
@@ -218,9 +227,10 @@ public boolean checkInit() {
if (configuration != null) return false;
/* Check whether already rendered before */
try {
+ Minecraft mc = Minecraft.getInstance();
configuration = new Properties();
if (!resetLayout) {
- File tasmodDir = new File(Minecraft.getInstance().gameDirectory, "lotas");
+ File tasmodDir = new File(mc.gameDirectory, "lotas");
tasmodDir.mkdir();
File configFile = new File(tasmodDir, "infogui.cfg");
if (!configFile.exists()) configFile.createNewFile();
@@ -234,74 +244,74 @@ public boolean checkInit() {
setDefaults("tickrate", y);
lists.add(new InfoLabel("tickrate", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Tickrate";
return "Tickrate: " + TickrateChangerMod.tickrate;
}));
y += 14;
setDefaults("position", y);
lists.add(new InfoLabel("position", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "XYZ";
- return String.format("%.2f %.2f %.2f", MCVer.getX(Minecraft.getInstance().player), MCVer.getY(Minecraft.getInstance().player), MCVer.getZ(Minecraft.getInstance().player));
+ return String.format("%.2f %.2f %.2f", MCVer.getX(mc.player), MCVer.getY(mc.player), MCVer.getZ(mc.player));
}));
y += 14;
setDefaults("preciseposition", y);
lists.add(new InfoLabel("preciseposition", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Precise XYZ";
- return String.format("%f %f %f", MCVer.getX(Minecraft.getInstance().player), MCVer.getY(Minecraft.getInstance().player), MCVer.getZ(Minecraft.getInstance().player));
+ return String.format("%f %f %f", MCVer.getX(mc.player), MCVer.getY(mc.player), MCVer.getZ(mc.player));
}));
y += 14;
setDefaults("chunkposition", y);
lists.add(new InfoLabel("chunkposition", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Chunk Position";
//#if MC>=11700
-//$$ return String.format("%d %d", Minecraft.getInstance().player.chunkPosition().getRegionLocalX(), Minecraft.getInstance().player.chunkPosition().getRegionLocalZ());
+//$$ return String.format("%d %d", mc.player.chunkPosition().getRegionLocalX(), mc.player.chunkPosition().getRegionLocalZ());
//#else
- return String.format("%d %d %d", Minecraft.getInstance().player.xChunk, Minecraft.getInstance().player.yChunk, Minecraft.getInstance().player.zChunk);
+ return String.format("%d %d %d", mc.player.xChunk, mc.player.yChunk, mc.player.zChunk);
//#endif
}));
y += 14;
setDefaults("worldseed", y);
lists.add(new InfoLabel("worldseed", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Worldseed";
- return Minecraft.getInstance().getSingleplayerServer().getPlayerList().getPlayers().get(0).getLevel().getSeed() + "";
+ return mc.getSingleplayerServer().getPlayerList().getPlayers().get(0).getLevel().getSeed() + "";
}));
y += 14;
setDefaults("ticks", y);
lists.add(new InfoLabel("ticks", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Ticks";
return TickrateChangerMod.ticksPassedServer + "";
}));
y += 14;
setDefaults("savestates", y);
lists.add(new InfoLabel("savestates", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Savestate Count";
return ("Savestates: " + SavestateMod.TrackerFile.savestateCount);
}));
y += 14;
setDefaults("loadstates", y);
lists.add(new InfoLabel("loadstates", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Loadstate Count";
return ("Loadstates: " + SavestateMod.TrackerFile.loadstateCount);
}));
y += 14;
setDefaults("timer", y);
lists.add(new InfoLabel("timer", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Timer";
return Timer.ticks == -1 ? "Timer is paused" : Timer.getDuration(Duration.ofMillis(Timer.ticks * 50));
}));
y += 14;
setDefaults("rtatimer", y);
lists.add(new InfoLabel("rtatimer", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "RTATimer";
if (Timer.running) TickrateChangerMod.rta = Duration.ofMillis(System.currentTimeMillis() - Timer.startTime.toMillis());
return Timer.ticks == -1 ? "" : ("RTA: " + Timer.getDuration(TickrateChangerMod.rta));
@@ -309,10 +319,10 @@ public boolean checkInit() {
y += 14;
setDefaults("bps", y);
lists.add(new InfoLabel("bps", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Speed/BPS";
- double distTraveledLastTickX = MCVer.getX(Minecraft.getInstance().player) - Minecraft.getInstance().player.xOld;
- double distTraveledLastTickZ = MCVer.getZ(Minecraft.getInstance().player) - Minecraft.getInstance().player.zOld;
+ double distTraveledLastTickX = MCVer.getX(mc.player) - mc.player.xOld;
+ double distTraveledLastTickZ = MCVer.getZ(mc.player) - mc.player.zOld;
//#if MC>=11700
//$$ return String.format("%.2f", Mth.sqrt((float) (distTraveledLastTickX * distTraveledLastTickX + distTraveledLastTickZ * distTraveledLastTickZ)) / 0.05F) + " blocks/sec";
//#else
@@ -322,7 +332,7 @@ public boolean checkInit() {
y += 14;
setDefaults("keystroke", y);
lists.add(new InfoLabel("keystroke", configuration, () -> {
- if (Minecraft.getInstance().screen == this)
+ if (mc.screen == this)
return "Keystrokes";
return KeystrokeUtils.getKeystrokes();
}));
@@ -340,30 +350,20 @@ public void drawHud() {
int ypos = 190;
for (InfoLabel label : lists) {
+ Minecraft mc = Minecraft.getInstance();
+
int lx = label.x;
int ly = label.y;
- int marginX = 5;
- int marginY = 5;
-
-
- int widthScaled=MCVer.getGLWindow().getGuiScaledWidth();
- int heightScaled=MCVer.getGLWindow().getGuiScaledHeight();
+ Pair newPos = getScreenOffset(lx, ly, label);
- if (getBBRight(lx, label.renderText) > widthScaled) {
- int offset = getBBRight(lx, label.renderText);
- lx = lx - (offset - widthScaled) - marginX;
- }
-
- if (getBBDown(ly) > heightScaled) {
- int offset = getBBDown(ly);
- ly = ly - (offset - heightScaled) - marginY;
- }
+ lx = newPos.getLeft();
+ ly = newPos.getRight();
if (label.visible) {
drawRectWithText(label.renderText, lx, ly, label.renderRect);
- } else if (Minecraft.getInstance().screen != null) {
- if (Minecraft.getInstance().screen.getClass().getSimpleName().contains("InfoHud")) {
+ } else if (mc.screen != null) {
+ if (mc.screen.getClass().getSimpleName().contains("InfoHud")) {
//#if MC>=11700
//$$ MCVer.pushMatrix(MCVer.stack);
//#else
@@ -380,7 +380,7 @@ public void drawHud() {
//#endif
}
}
- if (Minecraft.getInstance().screen instanceof InfoHud) {
+ if (mc.screen instanceof InfoHud) {
MCVer.drawShadow("Leftclick to move", width - ypos, xpos - 30, 0x60FF00);
MCVer.drawShadow("Middleclick to enable", width - ypos, xpos - 20, 0x60FF00);
MCVer.drawShadow("Rightclick to add black background", width - ypos, xpos - 10, 0x60FF00);
@@ -403,9 +403,30 @@ private void drawRectWithText(String text, int x, int y, boolean rect) {
MCVer.drawShadow(text, x + 2, y + 3, 0xFFFFFF);
GL11.glEnable(3042 /*GL_BLEND*/);
}
+
+ private Pair getScreenOffset(int x, int y, InfoLabel label){
+ int widthScaled=MCVer.getGLWindow().getGuiScaledWidth();
+ int heightScaled=MCVer.getGLWindow().getGuiScaledHeight();
+
+ int marginX = 5;
+ int marginY = 5;
+
+ if (getBBRight(x, label.renderText) > widthScaled) {
+ int offset = getBBRight(x, label.renderText);
+ x = x - (offset - widthScaled) - marginX;
+ }
+
+ if (getBBDown(y) > heightScaled) {
+ int offset = getBBDown(y);
+ y = y - (offset - heightScaled) - marginY;
+ }
+
+ return Pair.of(x, y);
+ }
private int getBBRight(int x, String text) {
- return x + Minecraft.getInstance().font.width(text) + 4;
+ Minecraft mc = Minecraft.getInstance();
+ return x + mc.font.width(text) + 4;
}
private int getBBDown(int y) {
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/LoTASIngameGui.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/LoTASIngameGui.java
new file mode 100644
index 00000000..ece8cf98
--- /dev/null
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/LoTASIngameGui.java
@@ -0,0 +1,501 @@
+package de.pfannekuchen.lotas.gui;
+
+import java.awt.Color;
+import java.time.Duration;
+
+import org.lwjgl.glfw.GLFW;
+
+import de.pfannekuchen.lotas.core.MCVer;
+import de.pfannekuchen.lotas.core.utils.ConfigUtils;
+import de.pfannekuchen.lotas.core.utils.Keyboard;
+import de.pfannekuchen.lotas.core.utils.Timer;
+import de.pfannekuchen.lotas.gui.widgets.SmallCheckboxWidget;
+import de.pfannekuchen.lotas.mods.AIManipMod;
+import de.pfannekuchen.lotas.mods.DupeMod;
+import de.pfannekuchen.lotas.mods.SavestateMod;
+import de.pfannekuchen.lotas.mods.TickrateChangerMod;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Font;
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.client.gui.screens.PauseScreen;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.util.Mth;
+
+/**
+ * The LoTAS pause screen
+ *
+ * @author Scribble
+ * @since 2.0.5
+ */
+public class LoTASIngameGui {
+
+ private EditBox savestateNameField;
+ private EditBox tickrateField;
+
+ // =============== BUTTONS
+ private Button savestateButton;
+ private Button loadstateButton;
+
+ private Button tickrateIncreaseButton;
+ private Button tickrateDecreaseButton;
+
+ private Button dropButton;
+ private Button dragonButton;
+ private Button spawningButton;
+ private Button aiButton;
+
+ private Button saveItemsButton;
+ private Button loadItemsButton;
+
+ private Button jumpTicksButton;
+ private Button tickDisplayButton;
+
+ private SmallCheckboxWidget avoidDamageCheckbox;
+
+ private SmallCheckboxWidget dropAwayCheckbox;
+ private SmallCheckboxWidget dropTowardsMeCheckbox;
+
+ private SmallCheckboxWidget optimizeExplosionsCheckbox;
+
+ private SmallCheckboxWidget rightAutoClickerCheckbox;
+
+ private Button timerButton;
+
+ // =============== STUFF
+
+ private Screen parentScreen;
+
+ private Font fontRenderer;
+
+ /**
+ * Whether a small tutorial should be displayed on how to use the tickJump
+ */
+ private static boolean tickjumpText = true;
+
+ private boolean tickrateFail = false;
+
+ /**
+ * Constructs new buttons for LoTAS' gui
+ * @param screen The current screen
+ */
+ public LoTASIngameGui(Screen screen) {
+
+ this.parentScreen = screen;
+
+ Minecraft mc = Minecraft.getInstance();
+
+ fontRenderer = mc.font;
+
+ int width = screen.width;
+ int height = screen.height;
+
+ // =============== SAVESTATE
+
+ savestateButton = constructSavestateButton();
+
+ loadstateButton = constructLoadstateButton();
+
+ // =============== TICKRATE
+
+ tickrateIncreaseButton = MCVer.Button(5, 15, 48, 20, "+", btn -> {
+ if (Screen.hasShiftDown()) {
+ activateTickrateField(true);
+ } else {
+ TickrateChangerMod.index++;
+ TickrateChangerMod.index = Mth.clamp(TickrateChangerMod.index, 1, 10);
+ TickrateChangerMod.updateTickrate(TickrateChangerMod.ticks[TickrateChangerMod.index]);
+ }
+ });
+
+ tickrateDecreaseButton = MCVer.Button(55, 15, 48, 20, "-", btn -> {
+ if (Screen.hasShiftDown()) {
+ activateTickrateField(true);
+ } else {
+ TickrateChangerMod.index--;
+ TickrateChangerMod.index = Mth.clamp(TickrateChangerMod.index, 1, 10);
+ TickrateChangerMod.updateTickrate(TickrateChangerMod.ticks[TickrateChangerMod.index]);
+ }
+ });
+
+ // =============== MANIPULATION
+
+ dropButton = MCVer.Button((width / 4) * 0 + 1, height - 20, width / 4 - 2, 20, "Manipulate Drops", btn -> {
+ mc.setScreen(new DropManipulationScreen((PauseScreen) parentScreen));
+ });
+
+ dragonButton = MCVer.Button((width / 4) * 1 + 2, height - 20, width / 4 - 2, 20, "Manipulate Dragon", btn -> {
+ mc.setScreen(new DragonManipulationScreen((PauseScreen) parentScreen));
+ });
+
+ spawningButton = MCVer.Button((width / 4) * 2 + 3, height - 20, width / 4 - 2, 20, "Manipulate Spawning", btn -> {
+ mc.setScreen(new SpawnManipulationScreen());
+ });
+
+ aiButton = MCVer.Button((width / 4) * 3 + 4, height - 20, width / 4 - 4, 20, "Manipulate AI", btn -> {
+ mc.setScreen(new AIManipulationScreen());
+ });
+
+ // =============== DUPEMOD
+
+ saveItemsButton = MCVer.Button(5, 55, 98, 20, "Save Items", btn -> {
+ DupeMod.save(Minecraft.getInstance());
+ btn.active = false;
+ });
+
+ loadItemsButton = MCVer.Button(5, 77, 98, 20, "Load Items", btn -> {
+ DupeMod.load(Minecraft.getInstance());
+ btn.active = false;
+ });
+
+ // =============== JUMP TICKS
+
+ jumpTicksButton = MCVer.Button(37, 115, 66, 20, "Jump ticks", btn -> {
+ TickrateChangerMod.ticksToJump = (int) TickrateChangerMod.ticks[TickrateChangerMod.ji];
+ btn.active = false;
+ tickDisplayButton.active = false;
+ MCVer.setMessage(btn, "Jumping...");
+ tickjumpText = false;
+ });
+
+ tickDisplayButton = MCVer.Button(5, 115, 30, 20, TickrateChangerMod.ticks[TickrateChangerMod.ji] + "t", btn -> {
+ if (Screen.hasShiftDown()) {
+ TickrateChangerMod.ji--;
+ } else {
+ TickrateChangerMod.ji++;
+ }
+
+ int upper = 9;
+ int lower = 2;
+
+ if (TickrateChangerMod.ji > upper)
+ TickrateChangerMod.ji = lower;
+
+ else if (TickrateChangerMod.ji < lower)
+ TickrateChangerMod.ji = upper;
+ });
+
+ // =============== CHECKBOXES
+
+ avoidDamageCheckbox = new SmallCheckboxWidget(2, height - 20 - 15, "Avoid taking damage", !ConfigUtils.getBoolean("tools", "takeDamage"), box -> {
+ ConfigUtils.setBoolean("tools", "takeDamage", !box.isChecked());
+ ConfigUtils.save();
+ });
+
+ dropTowardsMeCheckbox = new SmallCheckboxWidget(2, height - 32 - 15, "Drop towards me", ConfigUtils.getBoolean("tools", "manipulateVelocityTowards"), box -> {
+ ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", box.isChecked());
+ if (box.isChecked()) {
+ ConfigUtils.setBoolean("tools", "manipulateVelocityAway", false);
+ dropAwayCheckbox.silentPress(false);
+ }
+ ConfigUtils.save();
+ });
+
+ dropAwayCheckbox = new SmallCheckboxWidget(2, height - 44 - 15, "Drop away from me", ConfigUtils.getBoolean("tools", "manipulateVelocityAway"), box -> {
+ ConfigUtils.setBoolean("tools", "manipulateVelocityAway", box.isChecked());
+ if (box.isChecked()) {
+ ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", false);
+ dropTowardsMeCheckbox.silentPress(false);
+ }
+ ConfigUtils.save();
+ });
+
+ optimizeExplosionsCheckbox = new SmallCheckboxWidget(2, height - 56 - 15, "Optimize Explosions", ConfigUtils.getBoolean("tools", "manipulateExplosionDropChance"), box -> {
+ ConfigUtils.setBoolean("tools", "manipulateExplosionDropChance", box.isChecked());
+ ConfigUtils.save();
+ });
+
+ rightAutoClickerCheckbox = new SmallCheckboxWidget(2, height - 68 - 15, "Right Auto Clicker", ConfigUtils.getBoolean("tools", "rAutoClicker"), box -> {
+ ConfigUtils.setBoolean("tools", "rAutoClicker", box.isChecked());
+ ConfigUtils.save();
+ });
+
+ // =============== TIMER
+
+ timerButton = MCVer.Button(width / 2 - 102, height / 4 + 144 + -16, 204, 20, "Reset Timer", btn -> {
+ Timer.ticks = -1;
+ Timer.startTime = Duration.ofMillis(System.currentTimeMillis());
+ });
+ }
+
+ public void addCustomButtons() {
+
+ dragonButton.active = MCVer.getCurrentLevel().getDragons().size() > 0; // Disable the button if no dragon is in the current level
+
+ aiButton.active = AIManipMod.isEntityInRange(); // Disable if no entity is in range
+
+ loadstateButton.active = SavestateMod.hasSavestate();
+
+ MCVer.addButton(parentScreen, savestateButton);
+ MCVer.addButton(parentScreen, loadstateButton);
+
+ MCVer.addButton(parentScreen, tickrateIncreaseButton);
+ MCVer.addButton(parentScreen, tickrateDecreaseButton);
+
+ MCVer.addButton(parentScreen, dropButton);
+ MCVer.addButton(parentScreen, dragonButton);
+ MCVer.addButton(parentScreen, spawningButton);
+ MCVer.addButton(parentScreen, aiButton);
+
+ MCVer.addButton(parentScreen, saveItemsButton);
+ MCVer.addButton(parentScreen, loadItemsButton);
+
+ MCVer.addButton(parentScreen, jumpTicksButton);
+ MCVer.addButton(parentScreen, tickDisplayButton);
+
+ MCVer.addButton(parentScreen, avoidDamageCheckbox);
+ MCVer.addButton(parentScreen, dropTowardsMeCheckbox);
+ MCVer.addButton(parentScreen, dropAwayCheckbox);
+ MCVer.addButton(parentScreen, optimizeExplosionsCheckbox);
+ MCVer.addButton(parentScreen, rightAutoClickerCheckbox);
+
+ MCVer.addButton(parentScreen, timerButton);
+ }
+
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+
+ // Tickratechanger text
+ MCVer.drawShadow("Tickrate Changer (" + TickrateChangerMod.tickrate + ")", 5, 5, 0xFFFFFF);
+
+ // Duping text
+ MCVer.drawShadow("Duping", 10, 45, 0xFFFFFF);
+
+ // Tickjump stuff
+ MCVer.drawShadow("Tickjump", 10, 105, 0xFFFFFF);
+ if (jumpTicksButton.active == false) {
+ MCVer.drawShadow("Tickjump is ready,", 8, 137, 0xFFFFFF);
+ MCVer.drawShadow("press ESC to continue", 8, 147, 0xFFFFFF);
+ }
+
+ boolean isShiftDown = Screen.hasShiftDown();
+
+ // Show Tickjump number
+ String color = isShiftDown ? "\u00A76" : "";
+
+ //#if MC>=11900
+//$$ tickDisplayButton.setMessage(net.minecraft.network.chat.Component.literal(color + TickrateChangerMod.ticks[TickrateChangerMod.ji] + "t"));
+ //#else
+ //#if MC>=11601
+//$$ tickDisplayButton.setMessage(new net.minecraft.network.chat.TextComponent(color + TickrateChangerMod.ticks[TickrateChangerMod.ji] + "t"));
+ //#else
+ tickDisplayButton.setMessage(color + TickrateChangerMod.ticks[TickrateChangerMod.ji] + "t");
+ //#endif
+ //#endif
+
+ // Hint
+ if (isShiftDown && tickjumpText) {
+ MCVer.drawCenteredString(parentScreen, "\u00A7a^^^^^^^^", 70, 139, 0xFFFFFF);
+ MCVer.drawCenteredString(parentScreen, String.format("\u00A7aReopens the Game Menu"), 70, 145, 0xFFFFFF);
+ MCVer.drawCenteredString(parentScreen, String.format("\u00A7aafter %s ticks", TickrateChangerMod.ticks[TickrateChangerMod.ji]), 70, 155, 0xFFFFFF);
+ }
+
+ // Draw shift tooltip
+ if (isShiftDown) {
+ MCVer.setMessage(savestateButton, "\u00A76Name Savestate"); // Make the text gpolden on shift
+ MCVer.setMessage(loadstateButton, "\u00A76Choose State");
+ MCVer.setMessage(tickrateIncreaseButton, "\u00A76Custom");
+ MCVer.setMessage(tickrateDecreaseButton, "\u00A76Tickrate");
+ } else {
+ MCVer.setMessage(savestateButton, "Savestate");
+ MCVer.setMessage(loadstateButton, "Loadstate");
+ MCVer.setMessage(tickrateIncreaseButton, "+");
+ MCVer.setMessage(tickrateDecreaseButton, "-");
+ }
+
+ int width = parentScreen.width;
+ int height = parentScreen.height;
+
+ MCVer.drawCenteredString(parentScreen, "Hold Shift to access more features", width / 2, height / 4 + 152, 0xFFFFFF);
+
+ // Render Edit boxes
+ if (savestateNameField != null) {
+ MCVer.render(savestateNameField, mouseX, mouseY, partialTicks);
+ if (savestateNameField.getValue().isEmpty()) {
+ //#if MC>=11903
+//$$ MCVer.drawCenteredString(parentScreen, "Press \u2936 to apply", savestateNameField.getX() + 47, savestateNameField.getY() + 4, 0x777777);
+ //#else
+ MCVer.drawCenteredString(parentScreen, "Press \u2936 to apply", savestateNameField.x + 47, savestateNameField.y + 4, 0x777777);
+ //#endif
+ }
+ }
+ if (tickrateField != null) {
+ MCVer.render(tickrateField, mouseX, mouseY, partialTicks);
+ if (tickrateField.getValue().isEmpty()) {
+ //#if MC>=11903
+//$$ MCVer.drawCenteredString(parentScreen, "Press \u2936 to apply", tickrateField.getX() + 47, tickrateField.getY() + 4, 0x777777);
+ //#else
+ MCVer.drawCenteredString(parentScreen, "Press \u2936 to apply", tickrateField.x + 47, tickrateField.y + 4, 0x777777);
+ //#endif
+ }
+ }
+
+ // Render Savestate text
+ if (SavestateMod.showSavestateDone) {
+ long timeSince = System.currentTimeMillis() - SavestateMod.timeTitle;
+ if (timeSince >= 1800) {
+ SavestateMod.showSavestateDone = false;
+ loadstateButton.active = SavestateMod.hasSavestate();
+ return;
+ }
+ MCVer.drawCenteredString(parentScreen, "\u00A76Savestate successful...", width / 2, 20, new Color(1F, 1F, 1F, 1F - (timeSince / 2000F)).getRGB());
+ } else if (SavestateMod.showLoadstateDone) {
+ long timeSince = System.currentTimeMillis() - SavestateMod.timeTitle;
+ if (timeSince >= 1800) {
+ SavestateMod.showLoadstateDone = false;
+ return;
+ }
+ MCVer.drawCenteredString(parentScreen, "\u00A76Loadstate successful...", width / 2, 20, new Color(1F, 1F, 1F, 1F - (timeSince / 2000F)).getRGB());
+ }
+
+ // Render tickrate fail
+ if (tickrateFail) {
+ MCVer.drawCenteredString(parentScreen, "\u00A7cPlease enter a number!", 170, 22, 0xFFFFFF);
+ }
+ }
+
+ public void mouseClicked(double mouseX, double mouseY, int mouseButton) {
+ if (savestateNameField != null) {
+ if (!savestateNameField.isMouseOver(mouseX, mouseY)) {
+ activateSavestateField(false);
+ } else {
+ savestateNameField.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+ }
+
+ if (tickrateField != null) {
+ if (!tickrateField.isMouseOver(mouseX, mouseY)) {
+ activateTickrateField(false);
+ } else {
+ tickrateField.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+ }
+ }
+
+ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
+
+ boolean somethingFocused = false;
+
+ if (savestateNameField != null) {
+ savestateNameField.keyPressed(keyCode, scanCode, modifiers);
+
+ boolean focused = savestateNameField.isFocused();
+ somethingFocused = focused;
+
+ if (keyCode == GLFW.GLFW_KEY_ENTER && focused) {
+
+ if (savestateNameField.getValue().isEmpty()) {
+ SavestateMod.savestate(null);
+ } else {
+ SavestateMod.savestate(savestateNameField.getValue());
+ }
+
+ activateSavestateField(false);
+ }
+ }
+
+ if (tickrateField != null) {
+ tickrateField.keyPressed(keyCode, scanCode, modifiers);
+
+ boolean focused = tickrateField.isFocused();
+ somethingFocused = focused;
+
+ if (keyCode == GLFW.GLFW_KEY_ENTER && focused) {
+
+ if (!tickrateField.getValue().isEmpty()) {
+ try {
+ TickrateChangerMod.updateTickrate(Float.parseFloat(tickrateField.getValue()));
+ activateTickrateField(false);
+ } catch (NumberFormatException e) {
+ tickrateFail = true;
+ }
+ }
+ }
+ }
+ return somethingFocused;
+ }
+
+ public void charTyped(char typedChar, int keyCode) {
+ if (savestateNameField != null)
+ savestateNameField.charTyped(typedChar, keyCode);
+ if (tickrateField != null)
+ tickrateField.charTyped(typedChar, keyCode);
+ }
+
+ private void activateTickrateField(boolean activate) {
+ if (activate) {
+ tickrateField = MCVer.EditBox(fontRenderer, 7, 17, 94, 16, "");
+ tickrateIncreaseButton.active = false;
+ tickrateDecreaseButton.active = false;
+ tickrateIncreaseButton.visible = false;
+ tickrateDecreaseButton.visible = false;
+ parentScreen.setFocused(tickrateField);
+ tickrateField.setFocus(true);
+ } else {
+ tickrateField = null;
+ tickrateFail = false;
+ tickrateIncreaseButton.active = true;
+ tickrateDecreaseButton.active = true;
+ tickrateIncreaseButton.visible = true;
+ tickrateDecreaseButton.visible = true;
+ }
+ }
+
+ private void activateSavestateField(boolean activate) {
+ if (activate) {
+ savestateNameField = MCVer.EditBox(fontRenderer, parentScreen.width / 2 - 100, parentScreen.height / 4 + 82, 94, 16, "");
+ savestateButton.active = false;
+ savestateButton.visible = false;
+ parentScreen.setFocused(savestateNameField);
+ savestateNameField.setFocus(true);
+ } else {
+ savestateNameField = null;
+ savestateButton.active = true;
+ savestateButton.visible = true;
+ }
+ }
+
+ public Button constructSavestateButton() {
+ //#if MC>=11903
+//$$ return net.minecraft.client.gui.components.Button.builder(net.minecraft.network.chat.Component.literal("Savestate"), btn -> {
+//$$ if (Screen.hasShiftDown()) {
+//$$ activateSavestateField(true);
+//$$ } else
+//$$ SavestateMod.savestate(null);
+//$$ }).width(98).build();
+ //#else
+ return MCVer.Button(parentScreen.width / 2 - 102, parentScreen.height / 4 + 48 + -16 + 24 + 24, 98, 20, "Savestate", btn -> {
+ if (Screen.hasShiftDown()) {
+ activateSavestateField(true);
+ } else
+ SavestateMod.savestate(null);
+ });
+ //#endif
+ }
+
+ public Button constructLoadstateButton() {
+ //#if MC>=11903
+//$$ return net.minecraft.client.gui.components.Button.builder(net.minecraft.network.chat.Component.literal("Loadstate"), btn -> {
+//$$ if (Screen.hasShiftDown())
+//$$ Minecraft.getInstance().setScreen(new LoadstateScreen());
+//$$ else
+//$$ SavestateMod.loadstate(-1);
+//$$ }).width(98).build();
+ //#else
+ return MCVer.Button(parentScreen.width / 2 + 4, parentScreen.height / 4 + 48 + -16 + 24 + 24, 98, 20, "Loadstate", btn -> {
+ if (Screen.hasShiftDown())
+ Minecraft.getInstance().setScreen(new LoadstateScreen());
+ else
+ SavestateMod.loadstate(-1);
+ });
+ //#endif
+ }
+
+ public Button getSavestateButton() {
+ return savestateButton;
+ }
+
+ public AbstractWidget getLoadstateButton() {
+ return loadstateButton;
+ }
+}
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/SeedListScreen.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/SeedListScreen.java
deleted file mode 100644
index 1aa2e6dc..00000000
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/SeedListScreen.java
+++ /dev/null
@@ -1,282 +0,0 @@
-package de.pfannekuchen.lotas.gui;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.lwjgl.opengl.GL11;
-
-import com.mojang.blaze3d.platform.GlStateManager;
-import com.mojang.blaze3d.platform.NativeImage;
-import com.mojang.blaze3d.vertex.BufferBuilder;
-import com.mojang.blaze3d.vertex.DefaultVertexFormat;
-import com.mojang.blaze3d.vertex.Tesselator;
-
-import de.pfannekuchen.lotas.core.MCVer;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiComponent;
-import net.minecraft.client.gui.components.Button;
-import net.minecraft.client.gui.screens.ProgressScreen;
-import net.minecraft.client.gui.screens.Screen;
-import net.minecraft.client.gui.screens.TitleScreen;
-import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen;
-import net.minecraft.client.renderer.texture.DynamicTexture;
-import net.minecraft.resources.ResourceLocation;
-
-/**
- * List of Seeds, unused
- * @author Pancake
- */
-public class SeedListScreen extends Screen {
-
- public Seed selectedSeed = null;
- public static ArrayList seeds = new ArrayList<>();
- /** @see de.pfannekuchen.lotas.LoTAS List of all downloaded seeds */
-
- public static Map seedsId = new HashMap<>();
-
- /**
- * Seed class
- */
- public static class Seed {
- private String seed;
- private String name;
- private String description;
-
- public Seed(String seed, String name, String description) {
- this.seed = seed;
- this.name = name;
- this.description = description;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getSeed() {
- return seed;
- }
- }
-
- public SeedListScreen() {
- super(MCVer.literal("Seeds"));
- }
-
- /**
- * Listens for mouse clicks and selects the seed entry
- *
- */
- @Override
- public boolean mouseClicked(double mouseX, double mouseY, int button) {
- mouseY -= 52;
- if (mouseY > 0 && mouseY < seeds.size() * 40) {
- int index = (int) Math.floor(mouseY / 40);
- selectedSeed = seeds.get(index);
- ((Button)MCVer.getButton(this, 1)).active = true;
- }
- return super.mouseClicked(mouseX, mouseY + 52, button);
- }
-
- /**
- * Downloads the Seed to an Identifier
- * @param seed
- */
- public ResourceLocation downloadSeed(String seed) throws IOException {
- if (seedsId.containsKey(seed + ""))
- return seedsId.get(seed + "");
- URL url = new URL("https://data.mgnet.work/lotas/seeds/images" + seed + ".png");
- NativeImage image = NativeImage.read(url.openStream());
- DynamicTexture txt = new DynamicTexture(image);
- ResourceLocation iff = Minecraft.getInstance().getTextureManager().register(seed + "", txt);
- seedsId.put(seed + "", iff);
- return iff;
- }
-
- /**
- * Adds Done and Create World buttons to Seed menu
- */
- @Override
- protected void init() {
- MCVer.addButton(this, MCVer.Button(width / 2 - 100, height - 28, 200, 20, "Done", button -> {
- Minecraft.getInstance().setScreen(new SelectWorldScreen(new TitleScreen()));
- }));
- Button create = MCVer.Button(width / 2 - 100, height - 52, 200, 20, "Create World", button -> {
-
- //#if MC>=11700
-//$$ Minecraft.getInstance().setScreen(new ProgressScreen(true));
- //#else
- Minecraft.getInstance().setScreen(new ProgressScreen());
- //#endif
-// CreateWorldScreen createWorldScreen = new CreateWorldScreen(this);
-// AccessorCreateWorldScreen accessorCWS = (AccessorCreateWorldScreen) createWorldScreen;
-// accessorCWS.setSeed(selectedSeed.seed);
-// accessorCWS.setCheatsEnabled(true);
-// Minecraft.getInstance().setScreen(createWorldScreen);
- });
- create.active = false;
- MCVer.addButton(this, create);
- super.init();
- }
-
- /**
- * Renders background from top to bottom
- */
- protected void renderHoleBackground(int top, int bottom, int alphaTop, int alphaBottom) {
- Tesselator tessellator = Tesselator.getInstance();
- BufferBuilder bufferBuilder = tessellator.getBuilder();
- MCVer.bind(Minecraft.getInstance().getTextureManager(), GuiComponent.BACKGROUND_LOCATION);
- MCVer.color4f(.5f, .5f, .5f, .4F);
- //#if MC>=11700
-//$$ bufferBuilder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
- //#else
- bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
- //#endif
- bufferBuilder.vertex((double) 0, (double) bottom, 0.0D).uv(0.0F, ((float) bottom / 32.0F)).color(64, 64, 64, alphaBottom).endVertex();
- bufferBuilder.vertex((double) (0 + this.width), (double) bottom, 0.0D).uv(((float) this.width / 32.0F), ((float) bottom / 32.0F)).color(64, 64, 64, alphaBottom).endVertex();
- bufferBuilder.vertex((double) (0 + this.width), (double) top, 0.0D).uv(((float) this.width / 32.0F), ((float) top / 32.0F)).color(64, 64, 64, alphaTop).endVertex();
- bufferBuilder.vertex((double) 0, (double) top, 0.0D).uv(0.0F, ((float) top / 32.0F)).color(64, 64, 64, alphaTop).endVertex();
- tessellator.end();
- }
-
- /**
- * Draw all Seed Entries from seeds
- */
- public void drawSeeds(Object obj) throws IOException {
- Tesselator tessellator = Tesselator.getInstance();
- BufferBuilder bufferBuilder = tessellator.getBuilder();
-
- int y = 52;
- int x = this.width / 3;
- int n = 32;
- for (Seed seed : seeds) {
- if (selectedSeed == seed) {
- double r = x;
- int q = x + Minecraft.getInstance().font.width(seed.description) + 38;
- MCVer.disableTexture();
- float f = 1.0F;
- MCVer.color4f(f, f, f, 0.5F);
- //#if MC>=11700
-//$$ bufferBuilder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
- //#else
- bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
- //#endif
- bufferBuilder.vertex((double) r - 1, (double) (y + n + 2), 1.0D).endVertex();
- bufferBuilder.vertex((double) q - 1, (double) (y + n + 2), 1.0D).endVertex();
- bufferBuilder.vertex((double) q - 1, (double) (y - 2), 1.0D).endVertex();
- bufferBuilder.vertex((double) r - 1, (double) (y - 2), 1.0D).endVertex();
- tessellator.end();
- MCVer.color4f(0.0F, 0.0F, 0.0F, 0.5F);
- //#if MC>=11700
-//$$ bufferBuilder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
- //#else
- bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
- //#endif
- bufferBuilder.vertex((double) (r), (double) (y + n + 1), 1.0D).endVertex();
- bufferBuilder.vertex((double) (q - 2), (double) (y + n + 1), 1.0D).endVertex();
- bufferBuilder.vertex((double) (q - 2), (double) (y - 1), 1.0D).endVertex();
- bufferBuilder.vertex((double) (r), (double) (y - 1), 1.0D).endVertex();
- tessellator.end();
- MCVer.enableTexture();
- }
- MCVer.drawShadow(seed.name, x + 35, y + 3, 16777215);
- MCVer.drawShadow(seed.description, x + 35, y + 14, 8421504);
- MCVer.drawShadow(seed.seed, x + 35, y + 24, 8421504);
- MCVer.color4f(1.0F, 1.0F, 1.0F, 1.0F);
- try {
- MCVer.bind(Minecraft.getInstance().getTextureManager(), downloadSeed(seed.seed));
- MCVer.blit(x + 1, y, 0.0F, 0.0F, 32, 32, 32, 32);
- } catch (Exception e) {
-
- }
- y += 40;
- }
- }
-
- //#if MC>=11601
-//$$ @Override public void render(com.mojang.blaze3d.vertex.PoseStack stack, int mouseX, int mouseY, float partialTicks) {
-//$$ MCVer.stack = stack;
- //#else
- @Override public void render(int mouseX, int mouseY, float partialTicks) {
- //#endif
- int left = 0;
- int right = width;
- int top = 48;
- int bottom = height - 64;
-
- MCVer.renderBackground(this);
-
- MCVer.disableLighting();
- MCVer.disableFog();
- Tesselator tessellator = Tesselator.getInstance();
- BufferBuilder bufferBuilder = tessellator.getBuilder();
-
- MCVer.bind(Minecraft.getInstance().getTextureManager(), GuiComponent.BACKGROUND_LOCATION);
-
- MCVer.color4f(1f, 1f, 1f, 1F);
- //#if MC>=11700
-//$$ bufferBuilder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
- //#else
- bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
- //#endif
-
- bufferBuilder.vertex((double) left, (double) bottom, 0.0D).uv(((float) left / 32.0F), ((float) (bottom + (int) 1) / 32.0F)).color(32, 32, 32, 255).endVertex();
- bufferBuilder.vertex((double) right, (double) bottom, 0.0D).uv(((float) right / 32.0F), ((float) (bottom + (int) 1) / 32.0F)).color(32, 32, 32, 255).endVertex();
- bufferBuilder.vertex((double) right, (double) top, 0.0D).uv(((float) right / 32.0F), ((float) (top + (int) 1) / 32.0F)).color(32, 32, 32, 255).endVertex();
- bufferBuilder.vertex((double) left, (double) top, 0.0D).uv(((float) left / 32.0F), ((float) (top + (int) 1) / 32.0F)).color(32, 32, 32, 255).endVertex();
- tessellator.end();
-
- // OpenGL Stuff
- MCVer.disableDepthTest();
- this.renderHoleBackground(0, top, 255, 255);
- this.renderHoleBackground(bottom, this.height, 255, 255);
- MCVer.enableBlend();
- MCVer.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE);
- MCVer.disableAlphaTest();
- MCVer.shadeModel(7425);
-
- MCVer.disableTexture();
-
- // Draw top gradient
- //#if MC>=11700
-//$$ bufferBuilder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
- //#else
- bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
- //#endif
- bufferBuilder.vertex(left, top + 4, 0.0D).uv(0.0F, 1.0F).color(0, 0, 0, 0).endVertex();
- bufferBuilder.vertex(right, top + 4, 0.0D).uv(1.0F, 1.0F).color(0, 0, 0, 0).endVertex();
- bufferBuilder.vertex(right, top, 0.0D).uv(1.0F, 0.0F).color(0, 0, 0, 255).endVertex();
- bufferBuilder.vertex(left, top, 0.0D).uv(0.0F, 0.0F).color(0, 0, 0, 255).endVertex();
- tessellator.end();
-
- // Draw bottom gradient
- //#if MC>=11700
-//$$ bufferBuilder.begin(com.mojang.blaze3d.vertex.VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
- //#else
- bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION);
- //#endif
- bufferBuilder.vertex(left, bottom, 0.0D).uv(0.0F, 1.0F).color(0, 0, 0, 255).endVertex();
- bufferBuilder.vertex(right, bottom, 0.0D).uv(1.0F, 1.0F).color(0, 0, 0, 255).endVertex();
- bufferBuilder.vertex(right, bottom - 4, 0.0D).uv(1.0F, 0.0F).color(0, 0, 0, 0).endVertex();
- bufferBuilder.vertex(left, bottom - 4, 0.0D).uv(0.0F, 0.0F).color(0, 0, 0, 0).endVertex();
- tessellator.end();
-
- MCVer.enableTexture();
- MCVer.shadeModel(7424);
- MCVer.enableAlphaTest();
- MCVer.disableBlend();
-
- MCVer.drawCenteredString(this, "Seeds", width / 2, 8, 0xFFFFFF);
-
- try {
- drawSeeds(null);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-}
\ No newline at end of file
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/DropdownWidget.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/DropdownWidget.java
index b206f100..b6ed0855 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/DropdownWidget.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/DropdownWidget.java
@@ -75,6 +75,37 @@ private void onSearchBoxTextChanged(String searchContents) {
//#else
@Override public void renderButton(int mouseX, int mouseY, float delta) {
//#endif
+ //#if MC>=11903
+ //$$ int buttonWidth = (this.height);
+ //$$ int searchBoxWidth = this.width - buttonWidth - PADDING_H;
+ //$$ int buttonX, searchBoxX;
+ //$$ if(textRenderer.isBidirectional()) {
+ //$$ buttonX = this.getX();
+ //$$ searchBoxX = this.getX() + buttonWidth + PADDING_H;
+ //$$ } else {
+ //$$ searchBoxX = this.getX();
+ //$$ buttonX = this.getX() + searchBoxWidth + PADDING_H;
+ //$$ }
+ //$$ searchBox.setX(searchBoxX);
+ //$$ searchBox.setY(this.getY());
+ //$$ searchBox.setWidth(searchBoxWidth);
+ //$$ dropdownButton.setX(buttonX);
+ //$$ dropdownButton.setY(this.getY());
+ //$$ dropdownButton.setWidth(buttonWidth);
+ //$$ MCVer.render(searchBox, mouseX, mouseY, delta);
+ //$$ MCVer.render(dropdownButton, mouseX, mouseY, delta);
+ //$$ dropdown.setX(searchBoxX);
+ //$$ dropdown.setY(searchBox.getY() + 20 + 1);
+ //$$ dropdownOpenUp = false;
+ //$$ int dropdownHeight = getLineHeight(textRenderer) * DropdownListWidget.DISPLAYED_LINE_COUNT;
+ //$$ if(Minecraft.getInstance().screen != null) {
+ //$$ int areaBottom = Minecraft.getInstance().screen.height - 20; // fuck
+ //$$ if(dropdown.getY() + dropdownHeight > areaBottom) {
+ //$$ dropdown.setY(searchBox.getY() - dropdownHeight);
+ //$$ dropdownOpenUp = true;
+ //$$ }
+ //$$ }
+ //#else
int buttonWidth = (this.height);
int searchBoxWidth = this.width - buttonWidth - PADDING_H;
int buttonX, searchBoxX;
@@ -106,6 +137,7 @@ private void onSearchBoxTextChanged(String searchContents) {
}
dropdown.setWidth(searchBoxWidth + DropdownListWidget.SCROLL_BAR_PADDING + DropdownListWidget.SCROLL_BAR_WIDTH);
dropdown.setHeight(dropdownHeight);
+ //#endif
}
//#if MC>=11601
@@ -319,8 +351,13 @@ public boolean updateSuggestedSelections(String match) {
//#endif
Font textRenderer = DropdownWidget.this.textRenderer;
int lineHeight = getLineHeight(textRenderer);
+ //#if MC>=11903
+ //$$ int bgx0 = this.getX();
+ //$$ int bgy0 = this.getY();
+ //#else
int bgx0 = this.x;
int bgy0 = this.y;
+ //#endif
int bgx1 = bgx0 + this.width - SCROLL_BAR_WIDTH - SCROLL_BAR_PADDING;
int bgy1 = bgy0 + this.height;
// render background
@@ -329,7 +366,11 @@ public boolean updateSuggestedSelections(String match) {
// render selections
int endIdx = Math.min(suggestedSelections.size(), scrollIdx + DISPLAYED_LINE_COUNT);
for(int i = scrollIdx; i < endIdx; i++) {
+ //#if MC>=11903
+ //$$ int y = this.getY() + lineHeight * (i - scrollIdx);
+ //#else
int y = this.y + lineHeight * (i - scrollIdx);
+ //#endif
if(i == selectedIndex) {
int sx0 = bgx0 - 1;
int sy0 = y;
@@ -420,7 +461,11 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
+ //#if MC>=11903
+ //$$ int offsetIdx = (int)(mouseY - this.getY()) / getLineHeight(DropdownWidget.this.textRenderer);
+ //#else
int offsetIdx = (int)(mouseY - this.y) / getLineHeight(DropdownWidget.this.textRenderer);
+ //#endif
int absoluteIdx = offsetIdx + scrollIdx;
if(absoluteIdx < suggestedSelections.size()) {
setSelectedIndex(absoluteIdx);
@@ -442,15 +487,29 @@ public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
}
return true;
}
+//#if MC>=11903
+//$$ @Override
+//$$ protected void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput var1) {
+//$$ }
+//#else
//#if MC>=11700
//$$ @Override
//$$ public void updateNarration(net.minecraft.client.gui.narration.NarrationElementOutput narrationElementOutput) {
//$$ }
//#endif
+//#endif
+
}
+//#if MC>=11903
+//$$ @Override
+//$$ protected void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput var1) {
+//$$ }
+//#else
//#if MC>=11700
//$$ @Override
//$$ public void updateNarration(net.minecraft.client.gui.narration.NarrationElementOutput narrationElementOutput) {
//$$ }
//#endif
+//#endif
+
}
\ No newline at end of file
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/EntitySliderWidget.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/EntitySliderWidget.java
index e703d355..041f5d25 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/EntitySliderWidget.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/EntitySliderWidget.java
@@ -93,8 +93,13 @@ private String getDisplayString() {
//#else
int i = (this.isHovered() ? 2 : 1) * 20;
//#endif
+ //#if MC>=11903
+//$$ MCVer.blit(this.getX() + (int) (this.sliderPosition * (double) (this.width - 8)), this.getY(), 0, 46 + i, 4, 20);
+//$$ MCVer.blit(this.getX() + (int) (this.sliderPosition * (double) (this.width - 8)) + 4, this.getY(), 196, 46 + i, 4, 20);
+ //#else
MCVer.blit(this.x + (int) (this.sliderPosition * (double) (this.width - 8)), this.y, 0, 46 + i, 4, 20);
MCVer.blit(this.x + (int) (this.sliderPosition * (double) (this.width - 8)) + 4, this.y, 196, 46 + i, 4, 20);
+ //#endif
}
/**
@@ -105,7 +110,11 @@ private String getDisplayString() {
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
if (this.visible) {
if (this.isMouseDown) {
+ //#if MC>=11903
+//$$ this.sliderPosition = (float) (mouseX - (this.getX() + 4)) / (float) (this.width - 8);
+ //#else
this.sliderPosition = (float) (mouseX - (this.x + 4)) / (float) (this.width - 8);
+ //#endif
if (this.sliderPosition < 0.0F) {
this.sliderPosition = 0.0F;
@@ -118,8 +127,13 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
}
MCVer.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ //#if MC>=11903
+//$$ MCVer.blit(this.getX() + (int) (this.sliderPosition * (float) (this.width - 8)), this.getY(), 0, 66, 4, 20);
+//$$ MCVer.blit(this.getX() + (int) (this.sliderPosition * (float) (this.width - 8)) + 4, this.getY(), 196, 66, 4, 20);
+ //#else
MCVer.blit(this.x + (int) (this.sliderPosition * (float) (this.width - 8)), this.y, 0, 66, 4, 20);
MCVer.blit(this.x + (int) (this.sliderPosition * (float) (this.width - 8)) + 4, this.y, 196, 66, 4, 20);
+ //#endif
}
return true;
}
@@ -145,7 +159,11 @@ public void setSliderPosition(float position) {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int delta) {
if (super.mouseClicked(mouseX, mouseY, delta)) {
+ //#if MC>=11903
+//$$ this.sliderPosition = (float) (mouseX - (this.getX() + 4)) / (float) (this.width - 8);
+ //#else
this.sliderPosition = (float) (mouseX - (this.x + 4)) / (float) (this.width - 8);
+ //#endif
if (this.sliderPosition < 0.0F) {
this.sliderPosition = 0.0F;
@@ -170,10 +188,16 @@ public void updateManipList(List manipList) {
entities=manipList;
}
+ //#if MC>=11903
+//$$ @Override
+//$$ protected void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput var1) {
+//$$ }
+ //#else
//#if MC>=11700
//$$ @Override
//$$ public void updateNarration(net.minecraft.client.gui.narration.NarrationElementOutput narrationElementOutput) {
-//$$
//$$ }
//#endif
+ //#endif
+
}
\ No newline at end of file
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/ImageButton.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/ImageButton.java
index 1194a405..6f3c67b5 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/ImageButton.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/ImageButton.java
@@ -15,11 +15,15 @@ public class ImageButton extends Button {
private ResourceLocation pic;
public ImageButton(int x, int y, Button.OnPress action, ResourceLocation pic) {
+ //#if MC>=11903
+//$$ super(x, y, 20, 20, MCVer.literal(""), action, DEFAULT_NARRATION);
+ //#else
//#if MC>=11601
//$$ super(x, y, 20, 20, MCVer.literal(""), action);
//#else
super(x, y, 20, 20, "", action);
//#endif
+ //#endif
this.pic = pic;
}
@@ -41,7 +45,11 @@ public void renderButton(int mouseX, int mouseY, float delta) {
//#endif
MCVer.bind(Minecraft.getInstance().getTextureManager(), pic);
MCVer.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+ //#if MC>=11903
+//$$ MCVer.blit(getX(), getY(), 0.0F, 0.0F, 20, 20, 20, 20);
+ //#else
MCVer.blit(x, y, 0.0F, 0.0F, 20, 20, 20, 20);
+ //#endif
}
}
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/SmallCheckboxWidget.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/SmallCheckboxWidget.java
index b354436b..5414b463 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/SmallCheckboxWidget.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/gui/widgets/SmallCheckboxWidget.java
@@ -13,8 +13,12 @@
* @author Pancake
*/
public class SmallCheckboxWidget extends AbstractButton {
+ //#if MC>=11903
+//$$ private static final ResourceLocation TEXTURE = new ResourceLocation("lotas", "gui/small_checkbox.png");
+ //#else
private static final ResourceLocation TEXTURE = new ResourceLocation("textures/gui/small_checkbox.png");
- boolean checked;
+ //#endif
+ private boolean checked;
Consumer action;
public SmallCheckboxWidget(int x, int y, String message, boolean checked) {
@@ -42,6 +46,20 @@ public boolean isChecked() {
return this.checked;
}
+ //#if MC>=11903
+//$$ @Override public void renderButton(com.mojang.blaze3d.vertex.PoseStack stack, int mouseX, int mouseY, float delta) {
+//$$ MCVer.stack = stack;
+//$$ Minecraft minecraftClient = Minecraft.getInstance();
+//$$ MCVer.bind(minecraftClient.getTextureManager(), TEXTURE);
+//$$ MCVer.blit(this.getX(), this.getY(), 0.0F, 0.0F, 11, this.height, 11, 11);
+//$$ this.renderBg(MCVer.stack, minecraftClient, mouseX, mouseY);
+//$$ MCVer.drawShadow(this.getMessage().getString(), this.getX() + 16, this.getY() + (this.height - 8) / 2, 14737632 | Mth.ceil(this.alpha * 255.0F) << 24);
+//$$ if (isChecked()) {
+//$$ MCVer.disableDepthTest();
+//$$ MCVer.drawShadow("x", this.getX() + 3, this.getY() + 1, 0xFFFFFF);
+//$$ }
+//$$ }
+ //#else
//#if MC>=11601
//$$ @Override public void renderButton(com.mojang.blaze3d.vertex.PoseStack stack, int mouseX, int mouseY, float delta) {
//$$ MCVer.stack = stack;
@@ -56,21 +74,30 @@ public boolean isChecked() {
//$$ MCVer.drawShadow(this.getMessage().getString(), this.x + 16, this.y + (this.height - 8) / 2, 14737632 | Mth.ceil(this.alpha * 255.0F) << 24);
//#else
this.renderBg(minecraftClient, mouseX, mouseY);
- drawString(Minecraft.getInstance().font, this.getMessage(), this.x + 16, this.y + (this.height - 8) / 2, 14737632 | Mth.ceil(this.alpha * 255.0F) << 24);
+ drawString(minecraftClient.font, this.getMessage(), this.x + 16, this.y + (this.height - 8) / 2, 14737632 | Mth.ceil(this.alpha * 255.0F) << 24);
//#endif
if (isChecked()) {
MCVer.disableDepthTest();
MCVer.drawShadow("x", this.x + 3, this.y + 1, 0xFFFFFF);
}
}
+ //#endif
public void silentPress(boolean f) {
this.checked = f;
}
+
+ //#if MC>=11903
+//$$ @Override
+//$$ protected void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput var1) {
+//$$
+//$$ }
+ //#else
//#if MC>=11700
//$$ @Override
//$$ public void updateNarration(net.minecraft.client.gui.narration.NarrationElementOutput narrationElementOutput) {
//$$
//$$ }
//#endif
+ //#endif
}
\ No newline at end of file
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraftClient.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraftClient.java
index 2a47675d..f067477e 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraftClient.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraftClient.java
@@ -93,39 +93,47 @@ public void injectloadWorld(net.minecraft.client.multiplayer.MultiPlayerLevel wo
public void loadRenderingLate(CallbackInfo ci) {
/* Load Textures because FabricAPI has been removed */
try {
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/apple.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("apple.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/carrot.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("carrot.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/deadbush.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("deadbush.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/diamond_ore.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("diamond_ore.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/drowned.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("drowned.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/fish.gif"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("fish.gif"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/glowstone.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("glowstone.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/gold.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("gold.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/gravel.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("gravel.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/iron.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("iron.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/leaf.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("leaf.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/plants.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("plants.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/potato.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("potato.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/sapling.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("sapling.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/sealantern.gif"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("sealantern.gif"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/sheep.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("sheep.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/spider.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("spider.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/stick.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("stick.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/wither_skeleton.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("wither_skeleton.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/zombie.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("zombie.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "dragon/breath.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("breath.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "dragon/flying.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("flying.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "dragon/shooting.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("shooting.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "heck/potion.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("potion.png"))));
+ registerTexture("drops/apple.png", "apple.png");
+ registerTexture("drops/carrot.png", "carrot.png");
+ registerTexture("drops/deadbush.png", "deadbush.png");
+ registerTexture("drops/diamond_ore.png", "diamond_ore.png");
+ registerTexture("drops/drowned.png", "drowned.png");
+ registerTexture("drops/fish.gif", "fish.gif");
+ registerTexture("drops/glowstone.png", "glowstone.png");
+ registerTexture("drops/gold.png", "gold.png");
+ registerTexture("drops/gravel.png", "gravel.png");
+ registerTexture("drops/iron.png", "iron.png");
+ registerTexture("drops/leaf.png", "leaf.png");
+ registerTexture("drops/plants.png", "plants.png");
+ registerTexture("drops/potato.png", "potato.png");
+ registerTexture("drops/sapling.png", "sapling.png");
+ registerTexture("drops/sealantern.gif", "sealantern.gif");
+ registerTexture("drops/sheep.png", "sheep.png");
+ registerTexture("drops/spider.png", "spider.png");
+ registerTexture("drops/stick.png", "stick.png");
+ registerTexture("drops/wither_skeleton.png", "wither_skeleton.png");
+ registerTexture("drops/zombie.png", "zombie.png");
+ registerTexture("dragon/breath.png", "breath.png");
+ registerTexture("dragon/flying.png", "flying.png");
+ registerTexture("dragon/shooting.png", "shooting.png");
+ registerTexture("heck/potion.png", "potion.png");
+
+ registerTexture("drops/piglin.png", "piglin.png");
+ registerTexture("drops/copper.png", "copper.png");
+
+ registerTexture("gui/small_checkbox.png", "small_checkbox.png");
+ registerTexture("shield/bottleshield.png", "bottleshield.png");
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/piglin.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("piglin.png"))));
- Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", "drops/copper.png"), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream("copper.png"))));
} catch (IOException e) {
e.printStackTrace();
}
/* Load Shields */
LoTASModContainer.loadShieldsMCTAS();
}
+
+ private void registerTexture(String path, String file) throws IOException{
+ Minecraft.getInstance().getTextureManager().register(new ResourceLocation("lotas", path), new DynamicTexture(NativeImage.read(LoTASModContainer.class.getResourceAsStream(file))));
+ }
/**
* Called before a tick passes
@@ -155,12 +163,12 @@ public void injectrunTick(CallbackInfo ci) {
//$$ if (Minecraft.getInstance().level != null) {
//$$ Minecraft.getInstance().getSingleplayerServer().halt(true);
//$$ }
-//$$
+//$$
//$$ Minecraft.getInstance().forceSetScreen(new GenericDirtMessageScreen(new net.minecraft.network.chat.TranslatableComponent("createWorld.preparing")));
//$$ LevelSettings levelSettings2;
//$$ levelSettings2 = new LevelSettings(UUID.randomUUID().toString().substring(0, 10), GameType.CREATIVE, false, Difficulty.EASY, true, new GameRules(), net.minecraft.world.level.DataPackConfig.DEFAULT);
//$$ Minecraft.getInstance().createLevel(UUID.randomUUID().toString().substring(0, 10), levelSettings2, net.minecraft.core.RegistryAccess.RegistryHolder.builtin(), net.minecraft.world.level.levelgen.WorldGenSettings.create(net.minecraft.core.RegistryAccess.builtin(), new Properties()).withSeed(true, OptionalLong.of(LoTASModContainer.i)));
-//$$
+//$$
//$$ LoTASModContainer.i = -1;
//$$ System.gc();
//$$ }
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorButtons.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorButtons.java
index 1741ae9f..225e08ea 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorButtons.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorButtons.java
@@ -4,12 +4,15 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
-import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.client.gui.screens.Screen;
@Mixin(Screen.class)
public interface AccessorButtons {
+ //#if MC>=11903
+//$$ @Accessor("renderables")
+//$$ public List getButtons();
+ //#else
//#if MC>=11700
//$$ @Accessor("renderables")
//$$ public List getButtons();
@@ -18,4 +21,5 @@ public interface AccessorButtons {
public List getButtons();
//#endif
+ //#endif
}
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorScreen.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorScreen.java
index 4c04903f..86825270 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorScreen.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorScreen.java
@@ -15,15 +15,24 @@
//$$ public class AccessorScreen implements AccessorScreen2{
//$$
//$$ @Shadow
+ //#if MC>=11903
+//$$ private List renderables;
+ //#else
//$$ private List renderables;
+ //#endif
//$$ @Shadow
//$$ private List children;
//$$ @Shadow
//$$ private List narratables;
//$$
//$$ @Override
+ //#if MC>=11903
+//$$ public T addRenderableWidget(T widget) {
+//$$ this.renderables.add((net.minecraft.client.gui.components.Renderable) widget);
+ //#else
//$$ public T addRenderableWidget(T widget) {
//$$ this.renderables.add((net.minecraft.client.gui.components.Widget) widget);
+ //#endif
//$$ this.children.add(widget);
//$$ this.narratables.add((net.minecraft.client.gui.narration.NarratableEntry) widget);
//$$ return widget;
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinLevelStorage.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinLevelStorage.java
new file mode 100644
index 00000000..2ca4ad20
--- /dev/null
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinLevelStorage.java
@@ -0,0 +1,28 @@
+package de.pfannekuchen.lotas.mixin.patches;
+
+//#if MC<11601
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import de.pfannekuchen.lotas.mods.SavestateMod;
+
+@Mixin(net.minecraft.world.level.storage.LevelStorage.class)
+public class MixinLevelStorage {
+ @Inject(method = "saveLevelData", at = @At(value = "INVOKE", target = "Ljava/io/File;exists()Z", ordinal = 0), cancellable = true)
+ public void cancelLevelDataCreation(CallbackInfo ci) {
+ if(SavestateMod.isLoading) {
+ ci.cancel();
+ }
+ }
+}
+//#endif
+
+//@Mixin(net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess.class)
+//@Inject(method = "Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;saveDataTag(Lnet/minecraft/core/RegistryAccess;)V", at = @At(value = "INVOKE", target = "Ljava/io/File;exists()Z", ordinal = 0), cancellable = true)
+//public void cancelLevelDataCreation(CallbackInfo ci) {
+// if(SavestateMod.isLoading) {
+// ci.cancel();
+// }
+//}
\ No newline at end of file
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinServerPlayerEntityPatch.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinServerPlayerEntityPatch.java
index 607c6d06..b1f9d8a4 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinServerPlayerEntityPatch.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinServerPlayerEntityPatch.java
@@ -27,6 +27,9 @@
@Mixin(ServerPlayer.class)
public abstract class MixinServerPlayerEntityPatch extends Player {
+ //#if MC>=11903
+//$$ public MixinServerPlayerEntityPatch(Level level, net.minecraft.core.BlockPos blockPos, float f, GameProfile gameProfile, net.minecraft.world.entity.player.ProfilePublicKey profilePublicKey) { super(level, blockPos, f, gameProfile); }
+ //#else
//#if MC>=11900
//$$ public MixinServerPlayerEntityPatch(Level level, net.minecraft.core.BlockPos blockPos, float f, GameProfile gameProfile, net.minecraft.world.entity.player.ProfilePublicKey profilePublicKey) { super(level, blockPos, f, gameProfile, profilePublicKey); }
//#else
@@ -40,6 +43,7 @@ public abstract class MixinServerPlayerEntityPatch extends Player {
public MixinServerPlayerEntityPatch(Level world, GameProfile profile) { super(world, profile); }
//#endif
//#endif
+ //#endif
@Final
@Shadow
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/MixinRenderShield.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/MixinRenderShield.java
index dd836c66..06282b9d 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/MixinRenderShield.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/MixinRenderShield.java
@@ -29,7 +29,7 @@
//#else
//$$ @ModifyVariable(method = "renderByItem", at = @At(value = "STORE"), index = 9, ordinal = 0)
//#endif
- //#if MC>=11600
+ //#if MC>=11601
//$$ public com.mojang.blaze3d.vertex.VertexConsumer changeShield(com.mojang.blaze3d.vertex.VertexConsumer vertexconsumer, net.minecraft.world.item.ItemStack itemStack, net.minecraft.client.renderer.block.model.ItemTransforms.TransformType transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, int i, int j){
//#else
//$$ public com.mojang.blaze3d.vertex.VertexConsumer changeShield(com.mojang.blaze3d.vertex.VertexConsumer vertexconsumer, net.minecraft.world.item.ItemStack itemStack, com.mojang.blaze3d.vertex.PoseStack poseStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, int i, int j){
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiIngameMenu.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiIngameMenu.java
index 1d886c74..4d32c36a 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiIngameMenu.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiIngameMenu.java
@@ -1,37 +1,21 @@
package de.pfannekuchen.lotas.mixin.render.gui;
-import java.awt.Color;
-import java.time.Duration;
-
-import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.ModifyArg;
+import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import de.pfannekuchen.lotas.core.MCVer;
-import de.pfannekuchen.lotas.core.utils.ConfigUtils;
-import de.pfannekuchen.lotas.core.utils.Keyboard;
-import de.pfannekuchen.lotas.core.utils.Timer;
-import de.pfannekuchen.lotas.gui.AIManipulationScreen;
-import de.pfannekuchen.lotas.gui.DragonManipulationScreen;
-import de.pfannekuchen.lotas.gui.DropManipulationScreen;
-import de.pfannekuchen.lotas.gui.LoadstateScreen;
-import de.pfannekuchen.lotas.gui.SpawnManipulationScreen;
-import de.pfannekuchen.lotas.gui.widgets.SmallCheckboxWidget;
-import de.pfannekuchen.lotas.mods.AIManipMod;
-import de.pfannekuchen.lotas.mods.DupeMod;
-import de.pfannekuchen.lotas.mods.SavestateMod;
-import de.pfannekuchen.lotas.mods.TickrateChangerMod;
-import net.minecraft.client.Minecraft;
+import de.pfannekuchen.lotas.gui.LoTASIngameGui;
import net.minecraft.client.gui.components.Button;
-import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screens.PauseScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
-import net.minecraft.util.Mth;
/**
* Adds Utility Buttons to the Game Menu
@@ -42,136 +26,32 @@ protected MixinGuiIngameMenu(Component title) {
super(title);
}
- public EditBox savestateName;
- public EditBox tickrateField;
-
@Shadow @Final
private boolean showPauseMenu;
-
- SmallCheckboxWidget fw = null; // do not pay attention
-
+
+ @Unique
+ private LoTASIngameGui lotasGui;
+
+ //#if MC>=11903
+//$$ @Inject(at = @At("HEAD"), method = "init")
+ //#else
@Inject(at = @At("RETURN"), method = "init")
+ //#endif
public void addCustomButtons(CallbackInfo ci) {
+
if(!showPauseMenu) return;
+
// Move Buttons higher
+ //#if MC<11903
for (int i=0;i {
- if (Keyboard.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) {
- savestateName = MCVer.EditBox(Minecraft.getInstance().font, this.width / 2 - 100, this.height / 4 + 96 + -16, 98, 20, "");
- btn.active = false;
- setFocused(savestateName);
- } else
- SavestateMod.savestate(null);
- }));
- MCVer.addButton(this, MCVer.Button(this.width / 2 + 4, this.height / 4 + 48 + -16 + 24 + 24, 98, 20, "Loadstate", btn -> {
- if (Keyboard.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT))
- Minecraft.getInstance().setScreen(new LoadstateScreen());
- else
- SavestateMod.loadstate(-1);
- }));
- MCVer.addButton(this, MCVer.Button(5, 15, 48, 20, "+", b -> {
- if (Keyboard.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) {
- tickrateField = MCVer.EditBox(Minecraft.getInstance().font, 4, 15, 103, 20, "");
- b.active = false;
- setFocused(b);
- } else {
- TickrateChangerMod.index++;
- TickrateChangerMod.index = Mth.clamp(TickrateChangerMod.index, 1, 10);
- TickrateChangerMod.updateTickrate(TickrateChangerMod.ticks[TickrateChangerMod.index]);
- }
- }));
- MCVer.addButton(this, MCVer.Button(55, 15, 48, 20, "-", b -> {
- if (Keyboard.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) {
- tickrateField = MCVer.EditBox(Minecraft.getInstance().font, 4, 15, 103, 20, "");
- b.active = false;
- setFocused(b);
- } else {
- TickrateChangerMod.index--;
- TickrateChangerMod.index = Mth.clamp(TickrateChangerMod.index, 1, 10);
- TickrateChangerMod.updateTickrate(TickrateChangerMod.ticks[TickrateChangerMod.index]);
- }
- }));
- MCVer.addButton(this, MCVer.Button((width / 4) * 0 + 1, height - 20, width / 4 - 2, 20, "Manipulate Drops", btn -> {
- Minecraft.getInstance().setScreen(new DropManipulationScreen((PauseScreen) (Object) this));
- }));
-
- MCVer.addButton(this, MCVer.Button((width / 4) * 1 + 2, height - 20, width / 4 - 2, 20, "Manipulate Dragon", btn -> {
- Minecraft.getInstance().setScreen(new DragonManipulationScreen((PauseScreen) (Object) this));
- })).active = MCVer.getCurrentLevel().getDragons().size() > 0;
- MCVer.addButton(this, MCVer.Button((width / 4) * 2 + 3, height - 20, width / 4 - 2, 20, "Manipulate Spawning", btn -> {
- Minecraft.getInstance().setScreen(new SpawnManipulationScreen());
- }));
-
- MCVer.addButton(this, MCVer.Button((width / 4) * 3 + 4, height - 20, width / 4 - 4, 20, "Manipulate AI", btn -> {
- Minecraft.getInstance().setScreen(new AIManipulationScreen());
- })).active=AIManipMod.isEntityInRange();
-
- MCVer.addButton(this, MCVer.Button(5, 55, 98, 20, "Save Items", btn -> {
- DupeMod.save(Minecraft.getInstance());
- btn.active = false;
- }));
- MCVer.addButton(this, MCVer.Button(5, 75, 98, 20, "Load Items", btn -> {
- DupeMod.load(Minecraft.getInstance());
- btn.active = false;
- }));
- MCVer.addButton(this, MCVer.Button(37, 115, 66, 20, "Jump ticks", btn -> {
- TickrateChangerMod.ticksToJump = (int) TickrateChangerMod.ticks[TickrateChangerMod.ji];
- btn.active = false;
- MCVer.setMessage(btn, "Jumping...");
- }));
-
- MCVer.addButton(this, MCVer.Button(5, 115, 30, 20, TickrateChangerMod.ticks[TickrateChangerMod.ji] + "t", btn -> {
- TickrateChangerMod.ji++;
- if (TickrateChangerMod.ji > 10)
- TickrateChangerMod.ji = 1;
- //#if MC>=11700
-//$$ ((de.pfannekuchen.lotas.mixin.accessors.AccessorButtons)this).getButtons().clear();
- //#else
- buttons.clear();
- //#endif
- init();
- }));
- MCVer.addButton(this, new SmallCheckboxWidget(2, height - 20 - 15, "Avoid taking damage", !ConfigUtils.getBoolean("tools", "takeDamage"), b -> {
- ConfigUtils.setBoolean("tools", "takeDamage", !b.isChecked());
- ConfigUtils.save();
- }));
-
- MCVer.addButton(this, new SmallCheckboxWidget(2, height - 32 - 15, "Drop towards me", ConfigUtils.getBoolean("tools", "manipulateVelocityTowards"), b -> {
- ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", b.isChecked());
- if (b.isChecked()) {
- ConfigUtils.setBoolean("tools", "manipulateVelocityAway", false);
- fw.silentPress(false);
- }
- ConfigUtils.save();
- }));
- final SmallCheckboxWidget tw = (SmallCheckboxWidget) MCVer.getButton(this, MCVer.getButtonSize(this)-1);
- MCVer.addButton(this, new SmallCheckboxWidget(2, height - 44 - 15, "Drop away from me", ConfigUtils.getBoolean("tools", "manipulateVelocityAway"), b -> {
- ConfigUtils.setBoolean("tools", "manipulateVelocityAway", b.isChecked());
- if (b.isChecked()) {
- ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", false);
- tw.silentPress(false);
- }
- ConfigUtils.save();
- }));
- fw = (SmallCheckboxWidget) MCVer.getButton(this, MCVer.getButtonSize(this)-1);
- MCVer.addButton(this, new SmallCheckboxWidget(2, height - 56 - 15, "Optimize Explosions", ConfigUtils.getBoolean("tools", "manipulateExplosionDropChance"), b -> {
- ConfigUtils.setBoolean("tools", "manipulateExplosionDropChance", b.isChecked());
- ConfigUtils.save();
- }));
- MCVer.addButton(this, new SmallCheckboxWidget(2, height - 68 - 15, "Right Auto Clicker", ConfigUtils.getBoolean("tools", "rAutoClicker"), b -> {
- ConfigUtils.setBoolean("tools", "rAutoClicker", b.isChecked());
- ConfigUtils.save();
- }));
- MCVer.addButton(this, MCVer.Button(this.width / 2 - 102, this.height / 4 + 144 + -16, 204, 20, "Reset Timer", btn -> {
- Timer.ticks = -1;
- Timer.startTime = Duration.ofMillis(System.currentTimeMillis());
- }));
+ lotasGui = new LoTASIngameGui(this);
+ lotasGui.addCustomButtons();
}
@@ -188,87 +68,43 @@ public Button getButton(int index) {
public void drawScreen(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
//#endif
if(!showPauseMenu) return;
- if (Keyboard.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) {
- MCVer.setMessage(getButton(8), "\u00A76Name Savestate");
- MCVer.setMessage(getButton(9), "\u00A76Choose State");
- MCVer.setMessage(getButton(10), "\u00A76Custom");
- MCVer.setMessage(getButton(11), "\u00A76Tickrate");
- } else {
- MCVer.setMessage(getButton(8), "Savestate");
- MCVer.setMessage(getButton(9), "Loadstate");
- MCVer.setMessage(getButton(10), "+");
- MCVer.setMessage(getButton(11), "-");
- }
- MCVer.drawCenteredString(this, "Hold Shift to access more features", width / 2, this.height / 4 + 152, 0xFFFFFF);
- if (savestateName != null) MCVer.render(savestateName, mouseX, mouseY, partialTicks);
- if (tickrateField != null) MCVer.render(tickrateField, mouseX, mouseY, partialTicks);
-
- if (SavestateMod.showSavestateDone) {
- long timeSince = System.currentTimeMillis() - SavestateMod.timeTitle;
- if (timeSince >= 1800) {
- SavestateMod.showSavestateDone = false;
- ((Button)MCVer.getButton(this, 9)).active=SavestateMod.hasSavestate();
- return;
- }
- MCVer.drawCenteredString(this, "\u00A76Savestate successful...", width / 2, 20, new Color(1F, 1F, 1F, 1F - (timeSince / 2000F)).getRGB());
- } else if (SavestateMod.showLoadstateDone) {
- long timeSince = System.currentTimeMillis() - SavestateMod.timeTitle;
- if (timeSince >= 1800) {
- SavestateMod.showLoadstateDone = false;
- return;
- }
- MCVer.drawCenteredString(this, "\u00A76Loadstate successful...", width / 2, 20, new Color(1F, 1F, 1F, 1F - (timeSince / 2000F)).getRGB());
- }
- MCVer.drawShadow("Tickrate Changer (" + TickrateChangerMod.tickrate + ")", 5, 5, 0xFFFFFF);
- int i = 18;
- MCVer.drawShadow("Tickjump", 10, 105, 0xFFFFFF);
- if (getButton(i).active == false) {
- MCVer.drawShadow("Tickjump is ready,", 8, 137, 0xFFFFFF);
- MCVer.drawShadow("press ESC to continue", 8, 147, 0xFFFFFF);
- }
-
- MCVer.drawShadow("Duping", 10, 45, 0xFFFFFF);
+
+ lotasGui.drawScreen(mouseX, mouseY, partialTicks);
+
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
- if (savestateName != null)
- savestateName.mouseClicked(mouseX, mouseY, mouseButton);
- if (tickrateField != null)
- tickrateField.mouseClicked(mouseX, mouseY, mouseButton);
+ lotasGui.mouseClicked(mouseX, mouseY, mouseButton);
return super.mouseClicked(mouseX, mouseY, mouseButton);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
- if (savestateName != null) {
- savestateName.keyPressed(keyCode, scanCode, modifiers);
- boolean focused = savestateName.isFocused();
- if (keyCode == GLFW.GLFW_KEY_ENTER && focused) {
- if (savestateName.getValue().isEmpty())
- SavestateMod.savestate(null);
- else
- SavestateMod.savestate(savestateName.getValue());
- }
- }
- if (tickrateField != null) {
- tickrateField.keyPressed(keyCode, scanCode, modifiers);
- boolean focused = tickrateField.isFocused();
- if (keyCode == GLFW.GLFW_KEY_ENTER && focused) {
- if (!tickrateField.getValue().isEmpty())
- TickrateChangerMod.updateTickrate(Float.parseFloat(tickrateField.getValue()));
- }
+ boolean focused = lotasGui.keyPressed(keyCode, scanCode, modifiers);
+ if(!focused) {
+ return super.keyPressed(keyCode, scanCode, modifiers);
}
- return super.keyPressed(keyCode, scanCode, modifiers);
+ return true;
}
@Override
public boolean charTyped(char typedChar, int keyCode) {
- if (savestateName != null)
- savestateName.charTyped(typedChar, keyCode);
- if (tickrateField != null)
- tickrateField.charTyped(typedChar, keyCode);
+ lotasGui.charTyped(typedChar, keyCode);
return super.charTyped(typedChar, keyCode);
}
-
+
+ //#if MC>=11903
+//$$ @Redirect(method = "createPauseMenu", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/GridWidget$RowHelper;addChild(Lnet/minecraft/client/gui/components/AbstractWidget;I)Lnet/minecraft/client/gui/components/AbstractWidget;"))
+//$$ public net.minecraft.client.gui.components.AbstractWidget redirect_createPauseMenu(net.minecraft.client.gui.components.GridWidget.RowHelper parent, net.minecraft.client.gui.components.AbstractWidget button, int i) {
+//$$ parent.addChild(lotasGui.getSavestateButton());
+//$$ parent.addChild(lotasGui.getLoadstateButton());
+//$$ return parent.addChild(button, i);
+//$$ }
+//$$
+//$$ @ModifyArg(method = "createPauseMenu", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/LayoutSettings;paddingTop(I)Lnet/minecraft/client/gui/components/LayoutSettings;"), index = 0)
+//$$ public int redirect_createPauseMenu(int padding) {
+//$$ return 25;
+//$$ }
+ //#endif
}
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiSelectWorldScreen.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiSelectWorldScreen.java
index 8233b4e3..f8bc2f62 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiSelectWorldScreen.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiSelectWorldScreen.java
@@ -31,11 +31,6 @@ protected MixinGuiSelectWorldScreen(Component title) {
@Inject(at = @At("TAIL"), method = "init")
public void injectinit(CallbackInfo ci) {
- /*
- * TODO: Fucking fix this mess
- * addButton(MCVer.Button(2, 2, 98, 20, "Seed List", button -> {
- Minecraft.getInstance().setScreen(new SeedListScreen());
- }));*/
MCVer.addButton(this, widget = new SmallCheckboxWidget(width - 160, 4, "Open ESC when joining world", ConfigUtils.getBoolean("tools", "hitEscape"), b -> {
ConfigUtils.setBoolean("tools", "hitEscape", widget.isChecked());
ConfigUtils.save();
diff --git a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mods/SavestateMod.java b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mods/SavestateMod.java
index 144be25f..8e7b96a1 100644
--- a/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mods/SavestateMod.java
+++ b/LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/mods/SavestateMod.java
@@ -15,6 +15,7 @@
import de.pfannekuchen.lotas.core.MCVer;
import de.pfannekuchen.lotas.core.utils.Timer;
import de.pfannekuchen.lotas.mixin.render.gui.MixinGuiIngameMenu;
+import de.pfannekuchen.lotas.mods.SavestateMod.TrackerFile;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.server.IntegratedServer;
@@ -35,8 +36,11 @@ public class SavestateMod {
public static double motionY;
public static double motionZ;
+ /** Temporary variable to indicate that the "Savestate Done" Label should show up */
public static boolean showSavestateDone;
+ /** Temporary variable to indicate that the "Loadstate Done" Label should show up */
public static boolean showLoadstateDone;
+ /** Temporary variable to indicate that the Labels above should fade out */
public static long timeTitle;
public static boolean isLoading;
@@ -134,43 +138,78 @@ public static void loadstate(int number) {
isLoading = true;
+ // Store the tickrate before the loadstate
float tickratesaved=TickrateChangerMod.tickrateServer;
TickrateChangerMod.updateTickrate(20);
- final IntegratedServer server = mc.getSingleplayerServer();
-
+ // stop the server without saving the world
+ IntegratedServer server = mc.getSingleplayerServer();
for (ServerLevel worldserver : server.getAllLevels()) {
worldserver.noSave = true;
}
- mc.getSingleplayerServer().halt(true);
-
final String worldName = MCVer.getCurrentWorldFolder();
final File worldDir = new File(mc.gameDirectory, "saves/" + worldName);
final File savestatesDir = new File(mc.gameDirectory, "saves/savestates/");
+ mc.level.disconnect();
+ mc.clearLevel();
+
int existingSavestates = savestatesDir.listFiles((d, s) -> {
return s.startsWith(worldName + "-Savestate");
}).length;
- if (number != -1)
- existingSavestates = number;
+ if (number != -1) existingSavestates = number;
- final File savestateDir = new File(savestatesDir, worldName + "-Savestate" + (existingSavestates));
+ // Deleting the savestate dir
+ File savestateDir = new File(savestatesDir, worldName + "-Savestate" + (existingSavestates));
try {
- final String data = new String(com.google.common.io.Files.toByteArray(new File(savestateDir, "savestate.dat")));
FileUtils.deleteDirectory(worldDir);
+ } catch (NumberFormatException | IOException e) {
+ System.out.println("Failed to delete the current world. Trying to salvage it...");
+ e.printStackTrace();
+ try {
+ Thread.sleep(20L);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ try {
+ FileUtils.copyDirectory(savestateDir, worldDir);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ // Copying savestates
+ try {
FileUtils.copyDirectory(savestateDir, worldDir);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+
+ File savestateFile = new File(savestateDir, "savestate.dat");
- motionX = Double.parseDouble(data.split(":")[0]);
- motionY = Double.parseDouble(data.split(":")[1]);
- motionZ = Double.parseDouble(data.split(":")[2]);
- Timer.ticks = Integer.parseInt(data.split(":")[3]);
- applyVelocity = true;
- TrackerFile.increaseLoadstates(savestatesDir, worldName);
- } catch (NumberFormatException | IOException e) {
+ // Load savestate data
+
+ String data= "";
+ try {
+ if(savestateFile.exists())
+ data = new String(com.google.common.io.Files.toByteArray(savestateFile));
+
+ if(!data.isEmpty()) {
+ // re apply the velocity to make a seamless transition
+ motionX = Double.parseDouble(data.split(":")[0]);
+ motionY = Double.parseDouble(data.split(":")[1]);
+ motionZ = Double.parseDouble(data.split(":")[2]);
+ Timer.ticks = Integer.parseInt(data.split(":")[3]);
+ applyVelocity = true;
+ TrackerFile.increaseLoadstates(savestatesDir, worldName);
+ }
+ } catch(Exception e){
+ System.out.println("Failed to read savestate data:");
e.printStackTrace();
}
+
mc.gui.getChat().clearMessages(true);
GLFW.glfwSetCursorPos(MCVer.getGLWindow().getWindow(), x, y);
@@ -188,8 +227,8 @@ public static void loadstate(int number) {
GLFW.glfwSetCursorPos(MCVer.getGLWindow().getWindow(), x, y);
mc.mouseHandler.turnPlayer();
- System.gc();
TickrateChangerMod.updateTickrate(tickratesaved);
+ System.gc();
}
/**
diff --git a/LoTAS-Fabric/src/main/resources/de/pfannekuchen/lotas/core/bottleshield.png b/LoTAS-Fabric/src/main/resources/de/pfannekuchen/lotas/core/bottleshield.png
new file mode 100644
index 00000000..a401a806
Binary files /dev/null and b/LoTAS-Fabric/src/main/resources/de/pfannekuchen/lotas/core/bottleshield.png differ
diff --git a/LoTAS-Fabric/src/main/resources/de/pfannekuchen/lotas/core/small_checkbox.png b/LoTAS-Fabric/src/main/resources/de/pfannekuchen/lotas/core/small_checkbox.png
new file mode 100644
index 00000000..bbf21410
Binary files /dev/null and b/LoTAS-Fabric/src/main/resources/de/pfannekuchen/lotas/core/small_checkbox.png differ
diff --git a/LoTAS-Fabric/src/main/resources/fabric.mod.json b/LoTAS-Fabric/src/main/resources/fabric.mod.json
index 354a5a2a..f0e56968 100644
--- a/LoTAS-Fabric/src/main/resources/fabric.mod.json
+++ b/LoTAS-Fabric/src/main/resources/fabric.mod.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "lotas",
- "version": "2.0.4",
+ "version": "2.1.0",
"name": "LoTAS",
"description": "Low Optimization Tool Assisted Speedrun Mod",
@@ -10,7 +10,7 @@
"Scribble"
],
"contact": {
- "homepage": "https://mgnet.work/",
+ "homepage": "https://minecrafttas.com/",
"sources": "https://github.com/MCPfannkuchenYT/LoTAS"
},
diff --git a/LoTAS-Fabric/src/main/resources/lotas.accesswidener b/LoTAS-Fabric/src/main/resources/lotas.accesswidener
index 01391ae1..dd8c5aaf 100644
--- a/LoTAS-Fabric/src/main/resources/lotas.accesswidener
+++ b/LoTAS-Fabric/src/main/resources/lotas.accesswidener
@@ -7,4 +7,4 @@ mutable field net/minecraft/client/Timer msPerTick F
mutable field net/minecraft/client/Options keyMappings [Lnet/minecraft/client/KeyMapping;
mutable field net/minecraft/world/entity/Mob armorDropChances [F
mutable field net/minecraft/world/entity/Mob handDropChances [F
-##endif
\ No newline at end of file
+##endif
diff --git a/LoTAS-Fabric/src/main/resources/lotas.mixin.json b/LoTAS-Fabric/src/main/resources/lotas.mixin.json
index 7834abeb..b2a277a3 100644
--- a/LoTAS-Fabric/src/main/resources/lotas.mixin.json
+++ b/LoTAS-Fabric/src/main/resources/lotas.mixin.json
@@ -8,6 +8,9 @@
"accessors.AccessorDimensionTypes",
"accessors.AccessorLevelStorage",
"patches.MixinSheepPatch",
+ //#if MC<11601
+ "patches.MixinLevelStorage",
+ //#endif
"patches.MixinInaccuracyPatch"
],
"client": [
diff --git a/LoTAS-Fabric/versions2/1.19.0/build.gradle b/LoTAS-Fabric/versions2/1.19.0/build.gradle
index df15efd6..e2cdc327 100644
--- a/LoTAS-Fabric/versions2/1.19.0/build.gradle
+++ b/LoTAS-Fabric/versions2/1.19.0/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id 'fabric-loom' version '0.12-SNAPSHOT'
+ id 'fabric-loom' version '1.0-SNAPSHOT'
}
sourceCompatibility = JavaVersion.VERSION_17
diff --git a/LoTAS-Fabric/versions2/1.19.2/build.gradle b/LoTAS-Fabric/versions2/1.19.2/build.gradle
index 521d0701..e57c5613 100644
--- a/LoTAS-Fabric/versions2/1.19.2/build.gradle
+++ b/LoTAS-Fabric/versions2/1.19.2/build.gradle
@@ -1,7 +1,6 @@
plugins {
- id 'fabric-loom' version '0.12-SNAPSHOT'
+ id 'fabric-loom' version '1.0-SNAPSHOT'
}
-
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
@@ -15,5 +14,5 @@ loom {
dependencies {
minecraft "com.mojang:minecraft:1.19.2"
mappings loom.officialMojangMappings()
- modImplementation "net.fabricmc:fabric-loader:0.14.8"
+ modImplementation "net.fabricmc:fabric-loader:0.14.11"
}
\ No newline at end of file
diff --git a/LoTAS-Fabric/versions2/1.19.3/build.gradle b/LoTAS-Fabric/versions2/1.19.3/build.gradle
new file mode 100644
index 00000000..d054c95a
--- /dev/null
+++ b/LoTAS-Fabric/versions2/1.19.3/build.gradle
@@ -0,0 +1,18 @@
+plugins {
+ id 'fabric-loom' version '1.0-SNAPSHOT'
+}
+
+sourceCompatibility = JavaVersion.VERSION_17
+targetCompatibility = JavaVersion.VERSION_17
+
+apply from: '../common.gradle'
+archivesBaseName = "LoTAS1.19.3"
+
+loom {
+ accessWidenerPath = file("../../src/main/resources/lotas.accesswidener")
+}
+
+dependencies {
+ minecraft "com.mojang:minecraft:1.19.3"
+ mappings loom.officialMojangMappings()
+}
\ No newline at end of file
diff --git a/LoTAS-Fabric/versions2/common.gradle b/LoTAS-Fabric/versions2/common.gradle
index 4a059683..243591c6 100644
--- a/LoTAS-Fabric/versions2/common.gradle
+++ b/LoTAS-Fabric/versions2/common.gradle
@@ -1,7 +1,7 @@
sourceCompatibility = 1.8
targetCompatibility = 1.8
-version = "2.0.4"
+version = "2.1.0"
group = "de.pfannekuchen.lotas"
archivesBaseName = "lotas"
diff --git a/LoTAS-Fabric/versions2/fabric/Run_Fabric.launch b/LoTAS-Fabric/versions2/fabric/Run_Fabric.launch
index 526b7f2d..91489620 100644
--- a/LoTAS-Fabric/versions2/fabric/Run_Fabric.launch
+++ b/LoTAS-Fabric/versions2/fabric/Run_Fabric.launch
@@ -13,6 +13,6 @@
-
+
diff --git a/LoTAS-Fabric/versions2/fabric/build.gradle b/LoTAS-Fabric/versions2/fabric/build.gradle
index a5f3ab31..f3b6cca3 100644
--- a/LoTAS-Fabric/versions2/fabric/build.gradle
+++ b/LoTAS-Fabric/versions2/fabric/build.gradle
@@ -1,6 +1,6 @@
plugins {
//#if MC>=11900
-//$$ id 'fabric-loom' version '0.12-SNAPSHOT'
+//$$ id 'fabric-loom' version '1.0-SNAPSHOT'
//#else
//#if MC>=11801
//$$ id 'fabric-loom' version '0.10-SNAPSHOT'
@@ -22,9 +22,13 @@ sourceSets {
}
dependencies {
+ //#if MC>=11903
+//$$ minecraft "com.mojang:minecraft:1.19.3"
+//$$ modImplementation "net.fabricmc:fabric-loader:0.14.10"
+ //#else
//#if MC>=11902
-//$$ minecraft "com.mojang:minecraft:1.19.2"
-//$$ modImplementation "net.fabricmc:fabric-loader:0.14.8"
+//$$ minecraft "com.mojang:minecraft:1.19.2"
+//$$ modImplementation "net.fabricmc:fabric-loader:0.14.8"
//#else
//#if MC>=11900
//$$ minecraft "com.mojang:minecraft:1.19"
@@ -56,6 +60,7 @@ dependencies {
//#endif
//#endif
//#endif
+ //#endif
//#if MC>=11900
//$$ mappings loom.officialMojangMappings()
diff --git a/LoTAS-Forge/build.gradle b/LoTAS-Forge/build.gradle
index d2ebcaff..9b589e22 100644
--- a/LoTAS-Forge/build.gradle
+++ b/LoTAS-Forge/build.gradle
@@ -1,6 +1,6 @@
import groovy.json.JsonOutput
-version = "2.0.4"
+version = "2.1.0"
group= "de.pfannekuchen.lotas"
subprojects {
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/core/LoTASModContainer.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/core/LoTASModContainer.java
index fcd50ccc..be608669 100644
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/core/LoTASModContainer.java
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/core/LoTASModContainer.java
@@ -5,20 +5,14 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
-import java.net.URLConnection;
-import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import javax.net.ssl.HttpsURLConnection;
-import org.apache.commons.io.FileUtils;
-
import de.pfannekuchen.lotas.core.utils.ConfigUtils;
import de.pfannekuchen.lotas.core.utils.EventUtils;
import de.pfannekuchen.lotas.core.utils.KeybindsUtils;
-import de.pfannekuchen.lotas.gui.GuiSeedList.SeedListExtended;
-import de.pfannekuchen.lotas.gui.GuiSeedList.SeedListExtended.SeedEntry;
import de.pfannekuchen.lotas.gui.InfoHud;
import de.pfannekuchen.lotas.mods.TickrateChangerMod;
import de.pfannekuchen.lotas.taschallenges.ChallengeMap;
@@ -82,13 +76,6 @@ public void onPreInit(FMLPreInitializationEvent e) {
// Load configuration with suggested config file
ConfigUtils.init(new Configuration(e.getSuggestedConfigurationFile()));
- // Load all seeds for the seeds gui
- try {
- loadSeeds();
- } catch (Exception e1) {
- e1.printStackTrace();
- }
-
// Load the tickrate if it's supposed to be saved
if (ConfigUtils.getBoolean("tools", "saveTickrate")) {
TickrateChangerMod.index = ConfigUtils.getInt("hidden", "tickrate");
@@ -225,40 +212,4 @@ public java.awt.image.BufferedImage parseUserSkin(java.awt.image.BufferedImage i
LoTASModContainer.shield = new ResourceLocation("lotas", "misc/bottleshield.png");
// #endif
}
-
- /**
- * Method that loads the seeds file from the server
- *
- * @throws Exception Throws whenever something fails horribly
- */
- public void loadSeeds() throws Exception {
- // Load the file
- File file = new File("seeddata.txt");
- try {
- URL url = new URL("https://data.mgnet.work/lotas/seeds/" + version + ".txt");
- URLConnection conn = url.openConnection();
- conn.setReadTimeout(5000);
- file.createNewFile();
- FileUtils.copyInputStreamToFile(conn.getInputStream(), file);
- } catch (Exception e) {
- e.printStackTrace();
- }
- // Parse the file
- List strings = Files.readAllLines(file.toPath());
- int c = 0;
- for (String line : strings) {
- String seed = line.split(":")[0]; // seed is before first :
- String name = line.split(":")[1]; // etc...
- String description = line.split(":")[2];
- SeedEntry entry = new SeedEntry(name, description, seed, c);
- // load icon and add seed to list
- new Thread(() -> {
- entry.loc = new ResourceLocation("seeds", seed);
- ThreadDownloadImageData dw = new ThreadDownloadImageData((File) null, "https://data.mgnet.work/lotas/seeds/images/" + seed + ".png", null, new ImageBufferDownload());
- Minecraft.getMinecraft().getTextureManager().loadTexture(entry.loc, dw);
- }).start();
- SeedListExtended.seeds.add(entry);
- c++;
- }
- }
}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiAcceptTracking.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiAcceptTracking.java
deleted file mode 100644
index b29af962..00000000
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiAcceptTracking.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package de.pfannekuchen.lotas.gui;
-
-import java.io.IOException;
-
-import de.pfannekuchen.lotas.core.MCVer;
-import de.pfannekuchen.lotas.core.utils.ConfigUtils;
-import net.minecraft.client.gui.GuiButton;
-import net.minecraft.client.gui.GuiMainMenu;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.common.FMLCommonHandler;
-
-public class GuiAcceptTracking extends GuiScreen {
-
- private static final ResourceLocation DEMO_BACKGROUND_LOCATION = new ResourceLocation("textures/gui/demo_background.png");
-
- public void initGui() {
- this.buttonList.clear();
- this.buttonList.add(new GuiButton(1, this.width / 2 - 116, this.height / 2 + 62 + -16, 114, 20, "Accept"));
- this.buttonList.add(new GuiButton(2, this.width / 2 + 2, this.height / 2 + 62 + -16, 114, 20, "Decline"));
- }
-
- protected void actionPerformed(GuiButton button) throws IOException {
- switch (button.id) {
- case 1:
- ConfigUtils.setBoolean("hidden", "acceptedDataSending", true);
- ConfigUtils.save();
- this.mc.displayGuiScreen(new GuiMainMenu());
- break;
- case 2:
- FMLCommonHandler.instance().exitJava(29, true);
- }
- }
-
- public void drawDefaultBackground() {
- super.drawDefaultBackground();
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- this.mc.getTextureManager().bindTexture(DEMO_BACKGROUND_LOCATION);
- int i = (this.width - 248) / 2;
- int j = (this.height - 166) / 2;
- this.drawTexturedModalRect(i, j, 0, 0, 248, 166);
- }
-
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- this.drawDefaultBackground();
- int i = (this.width - 248) / 2 + 10;
- int j = (this.height - 166) / 2 + 8;
- MCVer.getFontRenderer(mc).drawString("LoTAS Cheat prevention", i, j, 2039583);
- j += 12;
- MCVer.getFontRenderer(mc).drawString("This mod collects a bit of data", i, j, 5197647);
- MCVer.getFontRenderer(mc).drawString("to prevent cheating.", i, j + 12, 5197647);
- MCVer.getFontRenderer(mc).drawString("Your data will be hashed and encrypted.", i, j + 24, 5197647);
- MCVer.getFontRenderer(mc).drawString("\u00A7cYour Data is unreadable to anyone!", i, j + 36, 5197647);
- MCVer.getFontRenderer(mc).drawSplitString("If you are confused or worried, pm me on discord: MCPfannkuchenYT#9745.", i, j + 68, 218, 2039583);
- super.drawScreen(mouseX, mouseY, partialTicks);
- }
-
-}
\ No newline at end of file
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiChallengeIngameMenu.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiChallengeIngameMenu.java
deleted file mode 100644
index 551954bd..00000000
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiChallengeIngameMenu.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package de.pfannekuchen.lotas.gui;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-
-import com.google.common.base.Predicates;
-
-import de.pfannekuchen.lotas.core.MCVer;
-import de.pfannekuchen.lotas.core.utils.ConfigUtils;
-import de.pfannekuchen.lotas.mods.DupeMod;
-import de.pfannekuchen.lotas.mods.TickrateChangerMod;
-import de.pfannekuchen.lotas.taschallenges.ChallengeLoader;
-import de.pfannekuchen.lotas.taschallenges.ChallengeMap;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiButton;
-import net.minecraft.client.gui.GuiIngameMenu;
-import net.minecraft.client.gui.GuiMainMenu;
-import net.minecraft.client.gui.GuiOptions;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.multiplayer.WorldClient;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.entity.boss.EntityDragon;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.world.chunk.storage.AnvilSaveConverter;
-import net.minecraftforge.fml.client.config.GuiCheckBox;
-
-public class GuiChallengeIngameMenu extends GuiIngameMenu {
-
- @Override
- public void initGui() {
- double pX = MCVer.player(Minecraft.getMinecraft()).posX;
- double pY = MCVer.player(Minecraft.getMinecraft()).posY;
- double pZ = MCVer.player(Minecraft.getMinecraft()).posZ;
- DupeMod.trackedObjects = new ArrayList();
- for (EntityItem item : MCVer.world(Minecraft.getMinecraft().getIntegratedServer(), MCVer.player(Minecraft.getMinecraft()).dimension).getEntitiesWithinAABB(EntityItem.class, MCVer.aabb(pX - 16, pY - 16, pZ - 16, pX + 16, pY + 16, pZ + 16))) {
- DupeMod.trackedObjects.add(item);
- }
-
- this.buttonList.clear();
- this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 - 16, I18n.format("menu.returnToMenu")));
-
- this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + -16, I18n.format("menu.returnToGame")));
- this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 48 + -16, I18n.format("menu.options")));
-
- this.buttonList.add(new GuiButton(31, this.width / 2 - 100, this.height / 4 + 72 + -16, I18n.format("Leaderboard")));
- this.buttonList.add(new GuiButton(32, this.width / 2 - 100, this.height / 4 + 96 + -16, I18n.format("Restart")));
-
- this.buttonList.add(new GuiButton(17, 5, 55, 98, 20, I18n.format("Save Items")));
- this.buttonList.add(new GuiButton(18, 5, 75, 98, 20, I18n.format("Load Items")));
-
-
- this.buttonList.add(new GuiButton(19, (width / 4) * 0 + 1, height - 20, width / 4 - 2, 20, I18n.format("Manipulate Drops")));
- try {
- this.buttonList.add(new GuiButton(20, (width / 4) * 1 + 2, height - 20, width / 4 - 2, 20, I18n.format("Manipulate Dragon")));
- this.buttonList.get(this.buttonList.size() - 1).enabled = MCVer.world(Minecraft.getMinecraft().getIntegratedServer(), MCVer.player(Minecraft.getMinecraft()).dimension).getEntities(EntityDragon.class, Predicates.alwaysTrue()).size() != 0;
- } catch (Exception e) {
- System.out.println("No Enderdragon found.");
- }
- this.buttonList.add(new GuiButton(15, 5, 15, 48, 20, I18n.format("+")));
- this.buttonList.add(new GuiButton(16, 55, 15, 48, 20, I18n.format("-")));
-
- this.buttonList.add(new GuiButton(21, (width / 4) * 2 + 3, height - 20, width / 4 - 2, 20, I18n.format("Manipulate Spawning")));
-
- this.buttonList.add(new GuiCheckBox(22, 2, height - 20 - 15, I18n.format("Avoid taking damage"), !ConfigUtils.getBoolean("tools", "takeDamage")));
- this.buttonList.add(new GuiButton(23, 37, 115, 66, 20, I18n.format("Jump ticks")));
- this.buttonList.add(new GuiButton(24, 5, 115, 30, 20, I18n.format(((int) TickrateChangerMod.ticks[TickrateChangerMod.ji]) + "t")));
- this.buttonList.add(new GuiCheckBox(26, 2, height - 32 - 15, I18n.format("Drop towards me"), ConfigUtils.getBoolean("tools", "manipulateVelocityTowards")));
- this.buttonList.add(new GuiCheckBox(27, 2, height - 44 - 15, I18n.format("Drop away from me"), ConfigUtils.getBoolean("tools", "manipulateVelocityAway")));
- this.buttonList.add(new GuiCheckBox(28, 2, height - 56 - 15, I18n.format("Optimize Explosions"), ConfigUtils.getBoolean("tools", "manipulateExplosionDropChance")));
- this.buttonList.add(new GuiCheckBox(30, 2, height - 68 - 15, I18n.format("Toggle R Auto Clicker"), ConfigUtils.getBoolean("tools", "lAutoClicker")));
-
- this.buttonList.add(new GuiButton(29, (width / 4) * 3 + 4, height - 20, width / 4 - 4, 20, I18n.format("Rig AI")));
- }
-
- @Override
- protected void actionPerformed(GuiButton button) throws IOException {
- switch (button.id) {
- case 0:
- this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
- break;
- case 1:
- ChallengeLoader.backupSession();
- button.enabled = false;
- MCVer.world(Minecraft.getMinecraft()).sendQuittingDisconnectingPacket();
- this.mc.loadWorld((WorldClient)null);
-
- ChallengeMap.currentMap = null;
- try {
- Field h = Minecraft.getMinecraft().getClass().getDeclaredField("field_71469_aa");
- h.setAccessible(true);
- //#if MC>=10900
- h.set(Minecraft.getMinecraft(), new AnvilSaveConverter(new File(mc.mcDataDir, "saves"), Minecraft.getMinecraft().getDataFixer()));
- //#else
- //$$ h.set(Minecraft.getMinecraft(), new AnvilSaveConverter(new File(mc.mcDataDir, "saves")));
- //#endif
- } catch (Exception e) {
- e.printStackTrace();
- }
- this.mc.displayGuiScreen(new GuiMainMenu());
- break;
- case 4:
- this.mc.displayGuiScreen((GuiScreen)null);
- this.mc.setIngameFocus();
- break;
- }
-
- // For Tickrate + and - call super, so we can access the tickrateField which is only in the mixin
- if (button.id == 15) {
- super.actionPerformed(button);
- } else if (button.id == 16) {
- super.actionPerformed(button);
- } else if (button.id == 17) {
- DupeMod.saveItems();
- DupeMod.saveChests();
- button.enabled = false;
- } else if (button.id == 18) {
- DupeMod.loadItems();
- DupeMod.loadChests();
- button.enabled = false;
- } else if (button.id == 19) {
- Minecraft.getMinecraft().displayGuiScreen(new GuiDropChanceManipulation((GuiIngameMenu) (Object) this));
- } else if (button.id == 20) {
- //#if MC>=10900
- Minecraft.getMinecraft().displayGuiScreen(new GuiDragonManipulation(this));
- //#else
-//$$ button.enabled=false;
-//$$ GuiDragonManipulation.chargePlayer();
- //#endif
- } else if (button.id == 21) {
- Minecraft.getMinecraft().displayGuiScreen(new GuiEntitySpawnManipulation());
- } else if (button.id == 22) {
- ConfigUtils.setBoolean("tools", "takeDamage", !((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- } else if (button.id == 23) {
- TickrateChangerMod.ticksToJump = (int) TickrateChangerMod.ticks[TickrateChangerMod.ji];
- button.enabled = false;
- button.displayString = "Jumping...";
- } else if (button.id == 24) {
- TickrateChangerMod.ji++;
- if (TickrateChangerMod.ji > 11) TickrateChangerMod.ji = 2;
- buttonList.clear();
- initGui();
- } else if (button.id == 26) {
- if (((GuiCheckBox) button).isChecked()) {
- ConfigUtils.setBoolean("tools", "manipulateVelocityAway", false);
- ConfigUtils.save();
- ((GuiCheckBox) this.buttonList.get(16)).setIsChecked(false);
- }
- ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", ((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- } else if (button.id == 27) {
- if (((GuiCheckBox) button).isChecked()) {
- ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", false);
- ConfigUtils.save();
- ((GuiCheckBox) this.buttonList.get(15)).setIsChecked(false);
- }
- ConfigUtils.setBoolean("tools", "manipulateVelocityAway", ((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- } else if (button.id == 28) {
- ConfigUtils.setBoolean("tools", "manipulateExplosionDropChance", ((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- } else if (button.id == 29) {
- Minecraft.getMinecraft().displayGuiScreen(new GuiAiManipulation());
- } else if (button.id == 30) {
- ConfigUtils.setBoolean("tools", "lAutoClicker", ((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- } else if (button.id == 31) {
- mc.displayGuiScreen(new GuiChallengeLeaderboard());
- } else if (button.id == 32) {
- ChallengeLoader.reload();
- }
- }
-
-}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiChallengeLeaderboard.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiChallengeLeaderboard.java
deleted file mode 100644
index 629a14a1..00000000
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiChallengeLeaderboard.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package de.pfannekuchen.lotas.gui;
-
-import java.time.Duration;
-
-import de.pfannekuchen.lotas.core.MCVer;
-import de.pfannekuchen.lotas.core.utils.EventUtils.Timer;
-import de.pfannekuchen.lotas.gui.widgets.ButtonWidget;
-import de.pfannekuchen.lotas.taschallenges.ChallengeMap;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiMainMenu;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.gui.GuiSlot;
-
-public class GuiChallengeLeaderboard extends GuiScreen {
-
- ChallengeMap map;
-
- public GuiChallengeLeaderboard() {}
-
- public GuiChallengeLeaderboard(ChallengeMap map) {
- this.map = map;
- }
-
- private GuiChallengeSlot slot;
-
- @Override
- public void initGui() {
- slot = new GuiChallengeSlot();
- this.buttonList.add(new ButtonWidget(width / 2 - 100, height - 22, 200, 20, "Done", b -> {
- if (map == null) Minecraft.getMinecraft().displayGuiScreen(new GuiChallengeIngameMenu());
- //#if MC>=10900
- else Minecraft.getMinecraft().displayGuiScreen(new net.minecraft.client.gui.GuiWorldSelection(new GuiMainMenu()));
- //#endif
- }));
- super.initGui();
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- slot.drawScreen(mouseX, mouseY, partialTicks);
- drawCenteredString(MCVer.getFontRenderer(mc), "Leaderboard for " + (map == null ? ChallengeMap.currentMap.displayName : map.displayName), width / 2, 15, 0xFFFFFF);
- super.drawScreen(mouseX, mouseY, partialTicks);
- }
-
- private class GuiChallengeSlot extends GuiSlot {
-
- public GuiChallengeSlot() {
- super(Minecraft.getMinecraft(), GuiChallengeLeaderboard.this.width, GuiChallengeLeaderboard.this.height, 32, GuiChallengeLeaderboard.this.height - 24, 10);
- this.setShowSelectionBox(false);
- }
-
- @Override
- protected int getSize() {
- return map == null ? ChallengeMap.currentMap.leaderboard.length : map.leaderboard.length;
- }
-
- @Override
- protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY) {
-
- }
-
- @Override
- protected boolean isSelected(int slotIndex) {
- return false;
- }
-
- @Override
- protected void drawBackground() {
- GuiChallengeLeaderboard.this.drawDefaultBackground();
- }
-
- @Override
- //#if MC>=11200
- protected void drawSlot(int slotIndex, int xPos, int yPos, int heightIn, int mouseXIn, int mouseYIn, float partialTicks) {
- //#else
-//$$ protected void drawSlot(int slotIndex, int xPos, int yPos, int insideSlotHeight, int mouseXIn, int mouseYIn) {
- //#endif
- String runner = map == null ? ChallengeMap.currentMap.leaderboard[slotIndex].split(";")[0] : map.leaderboard[slotIndex].split(";")[0];
- GuiChallengeLeaderboard.this.drawString(MCVer.getFontRenderer(Minecraft.getMinecraft()), runner, xPos + 2, yPos + 1, slotIndex % 2 == 0 ? 16777215 : 9474192);
- String time = Timer.getDuration(Duration.ofMillis(Integer.parseInt(map == null ? ChallengeMap.currentMap.leaderboard[slotIndex].split(";")[1] : map.leaderboard[slotIndex].split(";")[1])));
- GuiChallengeLeaderboard.this.drawString(MCVer.getFontRenderer(Minecraft.getMinecraft()), time, xPos + 2 + 213 - MCVer.getFontRenderer(Minecraft.getMinecraft()).getStringWidth(time), yPos + 1, slotIndex % 2 == 0 ? 16777215 : 9474192);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiDropChanceManipulation.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiDropChanceManipulation.java
index 44c1d4ad..4630b273 100644
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiDropChanceManipulation.java
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiDropChanceManipulation.java
@@ -64,7 +64,7 @@ public void initGui() {
man.update();
}
this.buttonList.add(new ButtonWidget((int) (width / 3.5f + 24), this.height - 40, 200, 20, "Done", b -> {
- Minecraft.getMinecraft().displayGuiScreen(ChallengeMap.currentMap == null ? new GuiIngameMenu() : new GuiChallengeIngameMenu());
+ Minecraft.getMinecraft().displayGuiScreen(new GuiIngameMenu());
}));
super.initGui();
}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiSeedList.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiSeedList.java
deleted file mode 100644
index 8d9a263a..00000000
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/GuiSeedList.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package de.pfannekuchen.lotas.gui;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.StringUtils;
-
-import de.pfannekuchen.lotas.core.MCVer;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.GuiButton;
-import net.minecraft.client.gui.GuiCreateWorld;
-import net.minecraft.client.gui.GuiListExtended;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.util.ResourceLocation;
-//#if MC>=11000
-import net.minecraft.world.GameType;
-//#else
-//$$ import net.minecraft.world.WorldSettings.GameType;
-//#endif
-import net.minecraft.world.WorldSettings;
-import net.minecraft.world.storage.WorldInfo;
-
-public class GuiSeedList extends GuiScreen {
-
- SeedListExtended list;
-
- @Override
- public void initGui() {
- this.buttonList.add(new GuiButton(1, this.width / 2 - 154, this.height - 28, 304, 20, I18n.format("selectWorld.create")));
- list = new SeedListExtended(width, height, 32, height - 64, 36);
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- list.mouseClicked(mouseX, mouseY, mouseButton);
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
- list.handleMouseInput();
- }
-
- public void mouseReleased(int mouseX, int mouseY, int state) {
- super.mouseReleased(mouseX, mouseY, state);
- list.mouseReleased(mouseX, mouseY, state);
- }
-
- @Override
- protected void actionPerformed(GuiButton button) throws IOException {
- if (button.id == 1 && SeedListExtended.selectedIndex != -1) {
- GuiCreateWorld guicreateworld = new GuiCreateWorld(this);
- SeedListExtended.SeedEntry et = SeedListExtended.seeds.get(SeedListExtended.selectedIndex);
- WorldSettings set = new WorldSettings(Long.parseLong(et.seed), GameType.SURVIVAL, true, false, net.minecraft.world.WorldType.DEFAULT);
- set = set.enableCommands();
- guicreateworld.recreateFromExistingWorld(new WorldInfo(set, et.name));
- Minecraft.getMinecraft().displayGuiScreen(guicreateworld);
- }
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- this.drawDefaultBackground();
- list.drawScreen(mouseX, mouseY, partialTicks);
- this.drawCenteredString(MCVer.getFontRenderer(Minecraft.getMinecraft()), "Seeds", this.width / 2, 20, 16777215);
- super.drawScreen(mouseX, mouseY, partialTicks);
- }
-
- public static class SeedListExtended extends GuiListExtended {
-
- public SeedListExtended(int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn) {
- super(Minecraft.getMinecraft(), widthIn, heightIn, topIn, bottomIn, slotHeightIn);
- }
-
- public static int selectedSeed = 1234;
- public static int selectedIndex = -1;
- public static List seeds = new ArrayList();
-
- public static class SeedEntry implements Serializable, IGuiListEntry {
-
- private static final long serialVersionUID = 4428898479076411871L;
- public String name;
- public String description;
- public String seed;
- private int index;
- public ResourceLocation loc = null;
-
- public SeedEntry(String name, String description, String seed, int index) {
- this.name = name;
- this.description = description;
- this.seed = seed;
- this.index = index;
- }
-
-
-
- //#if MC>=11200
- @Override
- public void updatePosition(int p_192633_1_, int p_192633_2_, int p_192633_3_, float p_192633_4_) { }
- @Override public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks) {
- //#else
-//$$ @Override
-//$$ public void setSelected(int p_178011_1_, int p_178011_2_, int p_178011_3_) { }
-//$$ @Override public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) {
- //#endif
- String s = name;
- String s1 = description;
- String s2 = seed;
-
- if (StringUtils.isEmpty(s)) {
- s = I18n.format("selectWorld.world") + " " + (slotIndex + 1);
- }
-
- s2 = "Seed: " + s2;
-
- MCVer.getFontRenderer(Minecraft.getMinecraft()).drawString(s, x + 32 + 3, y + 1, 16777215);
- MCVer.getFontRenderer(Minecraft.getMinecraft()).drawString(s1, x + 32 + 3, y + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + 3, 8421504);
- MCVer.getFontRenderer(Minecraft.getMinecraft()).drawString(s2, x + 32 + 3, y + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + 3, 8421504);
-
- if (loc != null) {
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.enableBlend();
- Minecraft.getMinecraft().getTextureManager().bindTexture(loc);
- Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, 0.0F, 32, 32, 32.0F, 32.0F);
- GlStateManager.disableBlend();
- }
- }
-
- public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) {
- selectedIndex = index;
- return false;
- }
-
- @Override
- public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) {
-
- }
-
- }
-
- @Override
- protected boolean isSelected(int slotIndex) {
- return selectedIndex == slotIndex;
- }
-
- @Override
- public boolean mouseClicked(int mouseX, int mouseY, int mouseEvent) {
- return super.mouseClicked(mouseX, mouseY, mouseEvent);
- }
-
- @Override
- public IGuiListEntry getListEntry(int index) {
- return seeds.get(index);
- }
-
- @Override
- protected int getSize() {
- return seeds.size();
- }
- }
-
-}
\ No newline at end of file
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/InfoHud.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/InfoHud.java
index d252a30e..3da02693 100644
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/InfoHud.java
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/InfoHud.java
@@ -10,6 +10,7 @@
import java.util.Properties;
import java.util.concurrent.Callable;
+import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@@ -120,6 +121,11 @@ public void identify(int mouseX, int mouseY) {
try {
x = Integer.parseInt(configuration.getProperty(label.displayName + "_x"));
y = Integer.parseInt(configuration.getProperty(label.displayName + "_y"));
+
+ Pair newPos = getScreenOffset(x, y, label);
+
+ x = newPos.getLeft();
+ y = newPos.getRight();
} catch (NumberFormatException e) {
configuration.setProperty(label.displayName + "_x", "0");
configuration.setProperty(label.displayName + "_y", "0");
@@ -355,20 +361,10 @@ public void drawHud() {
int lx = label.x;
int ly = label.y;
- int marginX = 5;
- int marginY = 5;
-
- ScaledResolution scaled = new ScaledResolution(Minecraft.getMinecraft());
-
- if (getBBRight(lx, label.renderText) > scaled.getScaledWidth()) {
- int offset = getBBRight(lx, label.renderText);
- lx = lx - (offset - scaled.getScaledWidth()) - marginX;
- }
-
- if (getBBDown(ly) > scaled.getScaledHeight()) {
- int offset = getBBDown(ly);
- ly = ly - (offset - scaled.getScaledHeight()) - marginY;
- }
+ Pair newPos = getScreenOffset(lx, ly, label);
+
+ lx = newPos.getLeft();
+ ly = newPos.getRight();
if (label.visible) {
drawRectWithText(label.renderText, lx, ly, label.renderRect);
@@ -406,6 +402,25 @@ private void drawRectWithText(String text, int x, int y, boolean rect) {
MCVer.getFontRenderer(Minecraft.getMinecraft()).drawStringWithShadow(text, x + 2, y + 3, 0xFFFFFF);
GL11.glEnable(3042 /* GL_BLEND */);
}
+
+ private Pair getScreenOffset(int x, int y, InfoLabel label){
+ ScaledResolution scaled = new ScaledResolution(Minecraft.getMinecraft());
+
+ int marginX = 5;
+ int marginY = 5;
+
+ if (getBBRight(x, label.renderText) > scaled.getScaledWidth()) {
+ int offset = getBBRight(x, label.renderText);
+ x = x - (offset - scaled.getScaledWidth()) - marginX;
+ }
+
+ if (getBBDown(y) > scaled.getScaledHeight()) {
+ int offset = getBBDown(y);
+ y = y - (offset - scaled.getScaledHeight()) - marginY;
+ }
+
+ return Pair.of(x, y);
+ }
private int getBBRight(int x, String text) {
return x + MCVer.getFontRenderer(Minecraft.getMinecraft()).getStringWidth(text) + 4;
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/LoTASGuiIngameMenu.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/LoTASGuiIngameMenu.java
new file mode 100644
index 00000000..11d8c095
--- /dev/null
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/LoTASGuiIngameMenu.java
@@ -0,0 +1,533 @@
+package de.pfannekuchen.lotas.gui;
+
+import java.awt.Color;
+import java.time.Duration;
+import java.util.List;
+
+import org.lwjgl.input.Keyboard;
+
+import com.google.common.base.Predicates;
+
+import de.pfannekuchen.lotas.core.MCVer;
+import de.pfannekuchen.lotas.core.utils.ConfigUtils;
+import de.pfannekuchen.lotas.core.utils.EventUtils.Timer;
+import de.pfannekuchen.lotas.mixin.accessors.AccessorGuiScreen;
+import de.pfannekuchen.lotas.mods.AIManipMod;
+import de.pfannekuchen.lotas.mods.DupeMod;
+import de.pfannekuchen.lotas.mods.SavestateMod;
+import de.pfannekuchen.lotas.mods.TickrateChangerMod;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiIngameMenu;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.resources.I18n;
+import net.minecraft.entity.boss.EntityDragon;
+import net.minecraftforge.fml.client.config.GuiCheckBox;
+
+/**
+ * The LoTAS pause screen
+ *
+ * @author Scribble
+ * @since 2.0.5
+ */
+public class LoTASGuiIngameMenu {
+
+ private GuiTextField savestateNameField;
+ private GuiTextField tickrateField;
+
+ // =============== BUTTONS
+ private Button savestateButton;
+ private Button loadstateButton;
+
+ private Button tickrateIncreaseButton;
+ private Button tickrateDecreaseButton;
+
+ private Button dropButton;
+ private Button dragonButton;
+ private Button spawningButton;
+ private Button aiButton;
+
+ private Button saveItemsButton;
+ private Button loadItemsButton;
+
+ private Button jumpTicksButton;
+ private Button tickDisplayButton;
+
+ private CheckBox avoidDamageCheckbox;
+
+ private CheckBox dropAwayCheckbox;
+ private CheckBox dropTowardsMeCheckbox;
+
+ private CheckBox optimizeExplosionsCheckbox;
+
+ private CheckBox rightAutoClickerCheckbox;
+
+ private Button timerButton;
+
+ // =============== STUFF
+
+ GuiScreen parentScreen;
+
+ FontRenderer fontRenderer;
+
+ /**
+ * Whether a small tutorial should be displayed on how to use the tickJump
+ */
+ private static boolean tickjumpText = true;
+
+ private boolean tickrateFail = false;
+
+ /**
+ * Constructs new buttons for LoTAS' gui
+ * @param screen The current screen
+ */
+ public LoTASGuiIngameMenu(GuiScreen screen) {
+
+ this.parentScreen = screen;
+
+ Minecraft mc = Minecraft.getMinecraft();
+
+ this.fontRenderer = MCVer.getFontRenderer(mc);
+
+ int width = screen.width;
+ int height = screen.height;
+
+ // =============== SAVESTATE
+
+ savestateButton = new Button(-1, width / 2 - 100, height / 4 + 96 + -16, 98, 20, "Savestate", btn->{
+ if (GuiScreen.isShiftKeyDown()) {
+ activateSavestateField(true);
+ } else SavestateMod.savestate(null);
+ });
+
+ loadstateButton = new Button(-2, width / 2 + 2, height / 4 + 96 + -16, 98, 20, "Loadstate", btn ->{
+ if (GuiScreen.isShiftKeyDown()) mc.displayGuiScreen(new GuiLoadstateMenu());
+ else SavestateMod.loadstate(-1);
+ });
+
+ // =============== TICKRATE
+
+ tickrateIncreaseButton = new Button(-3, 5, 15, 48, 20, "+", btn ->{
+ if (GuiScreen.isShiftKeyDown()) {
+ activateTickrateField(true);
+ } else {
+ TickrateChangerMod.index++;
+ TickrateChangerMod.index = MCVer.clamp(TickrateChangerMod.index, 0, 11);
+ TickrateChangerMod.updateTickrate(TickrateChangerMod.ticks[TickrateChangerMod.index]);
+ }
+ });
+
+ tickrateDecreaseButton = new Button(-4, 55, 15, 48, 20, "-", btn ->{
+ if (GuiScreen.isShiftKeyDown()) {
+ activateTickrateField(true);
+ } else {
+ TickrateChangerMod.index--;
+ TickrateChangerMod.index = MCVer.clamp(TickrateChangerMod.index, 0, 11);
+ TickrateChangerMod.updateTickrate(TickrateChangerMod.ticks[TickrateChangerMod.index]);
+ }
+ });
+
+ // =============== MANIPULATION
+
+ dropButton = new Button(-5, (width / 4) * 0 + 1, height - 20, width / 4 - 2, 20, "Manipulate Drops", btn->{
+ Minecraft.getMinecraft().displayGuiScreen(new GuiDropChanceManipulation((GuiIngameMenu) parentScreen));
+ });
+
+ dragonButton = new Button(-6, (width / 4) * 1 + 2, height - 20, width / 4 - 2, 20, "Manipulate Dragon", btn->{
+ //#if MC>=10900
+ Minecraft.getMinecraft().displayGuiScreen(new GuiDragonManipulation((GuiIngameMenu) parentScreen));
+ //#else
+//$$ btn.enabled=false;
+//$$ GuiDragonManipulation.chargePlayer();
+ //#endif
+ });
+
+ spawningButton = new Button(-7, (width / 4) * 2 + 3, height - 20, width / 4 - 2, 20, "Manipulate Spawning", btn->{
+ Minecraft.getMinecraft().displayGuiScreen(new GuiEntitySpawnManipulation());
+ });
+
+ aiButton = new Button(-8, (width / 4) * 3 + 4, height - 20, width / 4 - 4, 20, "Manipulate AI", btn ->{
+ Minecraft.getMinecraft().displayGuiScreen(new GuiAiManipulation());
+ });
+
+ // =============== DUPEMOD
+
+ saveItemsButton = new Button(-9, 5, 55, 98, 20, "Save Items", btn->{
+ DupeMod.saveItems();
+ DupeMod.saveChests();
+ btn.enabled = false;
+ });
+
+ loadItemsButton = new Button(-10, 5, 77, 98, 20, "Load Items", btn->{
+ DupeMod.loadItems();
+ DupeMod.loadChests();
+ btn.enabled = false;
+ });
+
+ // =============== JUMP TICKS
+
+ jumpTicksButton = new Button(-11, 37, 115, 66, 20, "Jump ticks", btn->{
+ TickrateChangerMod.ticksToJump = (int) TickrateChangerMod.ticks[TickrateChangerMod.ji];
+ btn.enabled = false;
+ btn.displayString = "Jumping...";
+ });
+
+ tickDisplayButton = new Button(-12, 5, 115, 30, 20, ((int) TickrateChangerMod.ticks[TickrateChangerMod.ji] + "t"), btn ->{
+ if (GuiIngameMenu.isShiftKeyDown()) {
+ TickrateChangerMod.ji--;
+ } else {
+ TickrateChangerMod.ji++;
+ }
+
+ int upper = 9;
+ int lower = 2;
+
+ if (TickrateChangerMod.ji > upper)
+ TickrateChangerMod.ji = lower;
+
+ else if (TickrateChangerMod.ji < lower)
+ TickrateChangerMod.ji = upper;
+ });
+
+ // =============== CHECKBOXES
+
+ avoidDamageCheckbox = new CheckBox(22, 2, height - 20 - 15, "Avoid taking damage", !ConfigUtils.getBoolean("tools", "takeDamage"), btn->{
+ ConfigUtils.setBoolean("tools", "takeDamage", !((GuiCheckBox) btn).isChecked());
+ ConfigUtils.save();
+ });
+
+ dropTowardsMeCheckbox = new CheckBox(26, 2, height - 32 - 15, "Drop towards me", ConfigUtils.getBoolean("tools", "manipulateVelocityTowards"), btn ->{
+ if (btn.isChecked()) {
+ ConfigUtils.setBoolean("tools", "manipulateVelocityAway", false);
+ ConfigUtils.save();
+ dropAwayCheckbox.setIsChecked(false);
+ }
+ ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", ((GuiCheckBox) btn).isChecked());
+ ConfigUtils.save();
+ });
+
+ dropAwayCheckbox = new CheckBox(27, 2, height - 44 - 15, "Drop away from me", ConfigUtils.getBoolean("tools", "manipulateVelocityAway"), btn ->{
+ if (btn.isChecked()) {
+ ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", false);
+ ConfigUtils.save();
+ dropTowardsMeCheckbox.setIsChecked(false);
+ }
+ ConfigUtils.setBoolean("tools", "manipulateVelocityAway", btn.isChecked());
+ ConfigUtils.save();
+ });
+
+ optimizeExplosionsCheckbox = new CheckBox(28, 2, height - 56 - 15, "Optimize Explosions", ConfigUtils.getBoolean("tools", "manipulateExplosionDropChance"), btn ->{
+ ConfigUtils.setBoolean("tools", "manipulateExplosionDropChance", btn.isChecked());
+ ConfigUtils.save();
+ });
+
+ rightAutoClickerCheckbox = new CheckBox(30, 2, height - 68 - 15, "Toggle R Auto Clicker", ConfigUtils.getBoolean("tools", "lAutoClicker"), btn ->{
+ ConfigUtils.setBoolean("tools", "lAutoClicker", btn.isChecked());
+ ConfigUtils.save();
+ });
+
+ // =============== TIMER
+
+ timerButton = new Button(-12, width / 2 - 100, height / 4 + 144 + -16, "Reset Timer", btn ->{
+ Timer.ticks = -1;
+ Timer.startTime = Duration.ofMillis(System.currentTimeMillis());
+ });
+ }
+
+ public void addButtons() {
+
+ Minecraft mc = Minecraft.getMinecraft();
+
+ dragonButton.enabled = MCVer.world(mc.getIntegratedServer(), MCVer.player(mc).dimension).getEntities(EntityDragon.class, Predicates.alwaysTrue()).size() >= 1;
+
+ aiButton.enabled = AIManipMod.isEntityInRange();
+
+ loadstateButton.enabled = SavestateMod.hasSavestate();
+
+ List buttonList = ((AccessorGuiScreen)parentScreen).getButtonList();
+
+ buttonList.add(savestateButton);
+ buttonList.add(loadstateButton);
+
+ buttonList.add(tickrateIncreaseButton);
+ buttonList.add(tickrateDecreaseButton);
+
+ buttonList.add(dropButton);
+ buttonList.add(dragonButton);
+ buttonList.add(spawningButton);
+ buttonList.add(aiButton);
+
+ buttonList.add(saveItemsButton);
+ buttonList.add(loadItemsButton);
+
+ buttonList.add(jumpTicksButton);
+ buttonList.add(tickDisplayButton);
+
+ buttonList.add(avoidDamageCheckbox);
+ buttonList.add(dropTowardsMeCheckbox);
+ buttonList.add(dropAwayCheckbox);
+ buttonList.add(optimizeExplosionsCheckbox);
+ buttonList.add(rightAutoClickerCheckbox);
+
+ buttonList.add(timerButton);
+ }
+
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+
+ Minecraft mc = Minecraft.getMinecraft();
+
+ FontRenderer fontRenderer = MCVer.getFontRenderer(mc);
+
+ // Tickratechanger text
+ fontRenderer.drawString("Tickrate Changer (" + TickrateChangerMod.tickrate + ")", 5, 5, 0xFFFFFF);
+
+ // Duping text
+ fontRenderer.drawStringWithShadow("Duping", 10, 45, 0xFFFFFF);
+
+ // Tickjump stuff
+ fontRenderer.drawStringWithShadow("Tickjump", 10, 105, 0xFFFFFF);
+ if(jumpTicksButton.enabled==false) {
+ fontRenderer.drawStringWithShadow("Tickjump is ready,", 8, 137, 0xFFFFFF);
+ fontRenderer.drawStringWithShadow("press ESC to continue", 8, 147, 0xFFFFFF);
+ }
+
+ boolean isShiftDown = GuiScreen.isShiftKeyDown();
+
+ // Show Tickjump number
+ String color = isShiftDown ? "\u00A76" : "";
+
+ tickDisplayButton.displayString = color + TickrateChangerMod.ticks[TickrateChangerMod.ji] + "t";
+
+ if (isShiftDown && tickjumpText) {
+ parentScreen.drawCenteredString(fontRenderer, "\u00A7a^^^^^^^^", 70, 139, 0xFFFFFF);
+ parentScreen.drawCenteredString(fontRenderer, String.format("\u00A7aReopens the Game Menu"), 70, 145, 0xFFFFFF);
+ parentScreen.drawCenteredString(fontRenderer, String.format("\u00A7aafter %s ticks", TickrateChangerMod.ticks[TickrateChangerMod.ji]), 70, 155, 0xFFFFFF);
+ }
+
+ // Draw shift tooltip
+ if (isShiftDown) {
+ savestateButton.displayString = "\u00A76Name Savestate";
+ loadstateButton.displayString = "\u00A76Choose State";
+ tickrateIncreaseButton.displayString = "\u00A76Custom";
+ tickrateDecreaseButton.displayString = "\u00A76Tickrate";
+ } else {
+ savestateButton.displayString = "Savestate";
+ loadstateButton.displayString = "Loadstate";
+ tickrateIncreaseButton.displayString = "+";
+ tickrateDecreaseButton.displayString = "-";
+ }
+
+ int width = parentScreen.width;
+ int height = parentScreen.height;
+
+ // Render Hint
+ parentScreen.drawCenteredString(fontRenderer, "Hold Shift to access more features", width / 2, height / 4 + 150, 0xFFFFFF);
+
+ // Render Edit boxes
+ if (savestateNameField != null) {
+ savestateNameField.drawTextBox();
+ if (savestateNameField.getText().isEmpty()) {
+ parentScreen.drawCenteredString(fontRenderer, "Press \u2936 to apply", x(savestateNameField) + 47, y(savestateNameField) + 4, 0x777777);
+ }
+ }
+ if (tickrateField != null) {
+ tickrateField.drawTextBox();
+ if (tickrateField.getText().isEmpty()) {
+ parentScreen.drawCenteredString(fontRenderer, "Press \u2936 to apply", x(tickrateField) + 47, y(tickrateField) + 4, 0x777777);
+ }
+ }
+
+ // Render Savestate text
+ if (SavestateMod.showSavestateDone) {
+ long timeSince = System.currentTimeMillis() - SavestateMod.timeTitle;
+ if (timeSince >= 1800) {
+ SavestateMod.showSavestateDone = false;
+ loadstateButton.enabled=SavestateMod.hasSavestate();
+ return;
+ }
+ parentScreen.drawCenteredString(fontRenderer, "\u00A76Savestate successful...", width / 2, 40, new Color(1F, 1F, 1F, 1F - (timeSince / 2000F)).getRGB());
+ } else if (SavestateMod.showLoadstateDone) {
+ long timeSince = System.currentTimeMillis() - SavestateMod.timeTitle;
+ if (timeSince >= 1800) {
+ SavestateMod.showLoadstateDone = false;
+ return;
+ }
+ parentScreen.drawCenteredString(fontRenderer, "\u00A76Loadstate successful...", width / 2, 40, new Color(1F, 1F, 1F, 1F - (timeSince / 2000F)).getRGB());
+ }
+
+ // Render tickrate fail
+ if (tickrateFail) {
+ parentScreen.drawCenteredString(fontRenderer, "\u00A7cPlease enter a number!", 170, 22, 0xFFFFFF);
+ }
+ }
+
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ if (savestateNameField != null) {
+ if (!isMouseOver(savestateNameField, mouseX, mouseY)) {
+ activateSavestateField(false);
+ } else {
+ savestateNameField.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+ }
+ if (tickrateField != null) {
+ if(!isMouseOver(tickrateField, mouseY, mouseButton)) {
+ activateTickrateField(false);
+ }else {
+ tickrateField.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+ }
+ }
+
+ public void keyTyped(char typedChar, int keyCode) {
+
+ if (savestateNameField != null) {
+ boolean focused = savestateNameField.isFocused();
+ savestateNameField.textboxKeyTyped(typedChar, keyCode);
+
+ if (keyCode == Keyboard.KEY_RETURN && focused) {
+ if (savestateNameField.getText().isEmpty()) {
+ SavestateMod.savestate(null);
+ } else {
+ SavestateMod.savestate(savestateNameField.getText());
+ }
+
+ activateSavestateField(false);
+ }
+ }
+
+ if (tickrateField != null) {
+ boolean focused = tickrateField.isFocused();
+ tickrateField.textboxKeyTyped(typedChar, keyCode);
+ if (keyCode == Keyboard.KEY_RETURN && focused) {
+ if (!tickrateField.getText().isEmpty()) {
+ try {
+ TickrateChangerMod.updateTickrate(Float.parseFloat(tickrateField.getText()));
+ activateTickrateField(false);
+ } catch (NumberFormatException e) {
+ tickrateFail = true;
+ }
+ }
+ }
+ }
+
+ }
+
+ public void actionPerformed(GuiButton button) {
+ List buttonList = ((AccessorGuiScreen)parentScreen).getButtonList();
+ buttonList.forEach(clickables ->{
+ if(clickables.equals(button)) {
+ if(clickables instanceof CustomClickable) {
+ ((CustomClickable)clickables).press();
+ }
+ }
+ });
+ }
+
+ private void activateTickrateField(boolean activate) {
+
+ if (activate) {
+ tickrateField = new GuiTextField(-30, fontRenderer, 7, 17, 94, 16);
+ tickrateIncreaseButton.enabled = false;
+ tickrateDecreaseButton.enabled = false;
+ tickrateIncreaseButton.visible = false;
+ tickrateDecreaseButton.visible = false;
+ tickrateField.setFocused(true);
+ } else {
+ tickrateField = null;
+ tickrateFail = false;
+ tickrateIncreaseButton.enabled = true;
+ tickrateDecreaseButton.enabled = true;
+ tickrateIncreaseButton.visible = true;
+ tickrateDecreaseButton.visible = true;
+ }
+ }
+
+ private void activateSavestateField(boolean activate) {
+
+ if (activate) {
+ savestateNameField = new GuiTextField(-31, fontRenderer, parentScreen.width / 2 - 98, parentScreen.height / 4 + 82, 94, 16);
+ savestateButton.enabled = false;
+ savestateButton.visible = false;
+ savestateNameField.setFocused(true);
+ } else {
+ savestateNameField = null;
+ savestateButton.enabled = true;
+ savestateButton.visible = true;
+ }
+ }
+
+ private boolean isMouseOver(GuiTextField button, double d, double e) {
+ return button.getVisible() &&
+ d >= (double) x(button) &&
+ d < (double) (x(button) + button.width) &&
+ e >= (double) y(button) &&
+ e < (double) (y(button) + button.height);
+ }
+
+ private int x(GuiTextField field) {
+ //#if MC>=11202
+ return field.x;
+ //#else
+//$$ return field.xPosition;
+ //#endif
+ }
+
+ private int y(GuiTextField field) {
+ //#if MC>=11202
+ return field.y;
+ //#else
+//$$ return field.yPosition;
+ //#endif
+ }
+
+ public class Button extends GuiButton implements CustomClickable{
+
+ private OnPress press;
+
+ public Button(int buttonId, int x, int y, String buttonText, OnPress onPress) {
+ this(buttonId, x, y, 200, 20, buttonText, onPress);
+ }
+
+ public Button(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText, OnPress onPress) {
+ super(buttonId, x, y, widthIn, heightIn, I18n.format(buttonText));
+ this.press = onPress;
+ }
+
+ @Override
+ public void press() {
+ press.call(this);
+ }
+ }
+
+ public class CheckBox extends GuiCheckBox implements CustomClickable {
+
+ private OnPress2 press;
+
+ public CheckBox(int id, int xPos, int yPos, String displayString, boolean isChecked, OnPress2 press) {
+ super(id, xPos, yPos, I18n.format(displayString), isChecked);
+
+ this.press = press;
+ }
+
+ @Override
+ public void press() {
+ press.call(this);
+ }
+ }
+
+ @FunctionalInterface
+ public interface OnPress{
+ public void call(Button button);
+ }
+
+ @FunctionalInterface
+ private interface OnPress2{
+ public void call(CheckBox button);
+ }
+
+ private interface CustomClickable{
+ public void press();
+ }
+}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/widgets/ChallengeMapEntryWidget.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/widgets/ChallengeMapEntryWidget.java
deleted file mode 100644
index 8287bb5e..00000000
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/gui/widgets/ChallengeMapEntryWidget.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package de.pfannekuchen.lotas.gui.widgets;
-
-import java.io.IOException;
-import java.time.Duration;
-
-import de.pfannekuchen.lotas.core.MCVer;
-import de.pfannekuchen.lotas.core.utils.EventUtils.Timer;
-import de.pfannekuchen.lotas.gui.GuiChallengeLeaderboard;
-import de.pfannekuchen.lotas.taschallenges.ChallengeLoader;
-import de.pfannekuchen.lotas.taschallenges.ChallengeMap;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.Gui;
-
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.ResourceLocation;
-
-//#if MC>=10900
-public class ChallengeMapEntryWidget extends net.minecraft.client.gui.GuiListWorldSelectionEntry {
-//#else
-//$$ public class ChallengeMapEntryWidget extends net.minecraft.client.gui.GuiSelectWorld.List {
-//#endif
-
-
- public ResourceLocation loc = null;
- int width;
-
- // Different to 1.8, instead of having a single instance per element, this is just a full list.
- //#if MC>=10900
- public ChallengeMap map;
- public ChallengeMapEntryWidget(net.minecraft.client.gui.GuiListWorldSelection listWorldSelIn, ChallengeMap map, int width) {
- super(listWorldSelIn, map.getSummary(), map.getSaveLoader());
- this.map = map;
- this.width = width;
- //#else
-//$$ public ChallengeMapEntryWidget(net.minecraft.client.gui.GuiSelectWorld guiSelectWorld, int width) {
-//$$ guiSelectWorld.super(Minecraft.getMinecraft());
-//$$ this.width = width;
- //#endif
- }
-
- public void deleteWorld() {}
- public void editWorld() {}
- public void recreateWorld() {}
-
- public void joinWorld() {
- //#if MC>=10900
- ChallengeMap.currentMap = map;
- //#else
-//$$ ChallengeMap.currentMap = de.pfannekuchen.lotas.core.LoTASModContainer.maps.get(selectedElement);
- //#endif
- try {
- ChallengeLoader.load(true);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- //#if MC<=10809
-//$$ @Override
-//$$ protected int getSize() {
-//$$ return de.pfannekuchen.lotas.core.LoTASModContainer.maps.size();
-//$$ }
-//$$
-//$$ @Override
-//$$ protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY) {
-//$$ selectedElement = slotIndex;
-//$$ if (isDoubleClick) {
-//$$ joinWorld();
-//$$ }
-//$$ }
- //#else
- @Override
- public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) {
- int posX = width - x - 80;
- int posY = y + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + 3;
-
- if (mouseX > posX && mouseX < (posX + 80) && mouseY > posY && mouseY < (posY + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT)) {
- Minecraft.getMinecraft().displayGuiScreen(new GuiChallengeLeaderboard(map));
- }
- return super.mousePressed(slotIndex, mouseX, mouseY, mouseEvent, relativeX, relativeY);
- }
- //#endif
-
- int x;
- int y;
-
- @Override
- //#if MC>=11200
- public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float partialTicks) {
- //#else
- //#if MC>=10900
-//$$ public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) {
- //#else
-//$$ public void drawSlot(int slotIndex, int x, int y, int p_180791_4_, int mouseXIn, int mouseYIn) {
- //#endif
- //#endif
-
- //#if MC>=10900
- this.x = x;
- this.y = y;
- String s = "\u00A76TAS Challenge Map - \u00A7f" + map.displayName;
- String s1 = map.description;
- String s2 = "WR: " + map.leaderboard[0].split(";")[0] + " - " + Timer.getDuration(Duration.ofMillis(Integer.parseInt(map.leaderboard[0].split(";")[1])));
- //#else
- //$$ String s = "\u00A76TAS Challenge Map - \u00A7f" + de.pfannekuchen.lotas.core.LoTASModContainer.maps.get(selectedElement).displayName;
- //$$ String s1 = de.pfannekuchen.lotas.core.LoTASModContainer.maps.get(selectedElement).description;
- //$$ String s2 = "WR: " + de.pfannekuchen.lotas.core.LoTASModContainer.maps.get(selectedElement).leaderboard[0].split(";")[0] + " - " + Timer.getDuration(Duration.ofMillis(Integer.parseInt(de.pfannekuchen.lotas.core.LoTASModContainer.maps.get(selectedElement).leaderboard[0].split(";")[1])));
- //$$
- //#endif
-
- MCVer.getFontRenderer(Minecraft.getMinecraft()).drawString(s, x + 32 + 3, y + 1, 16777215);
- MCVer.getFontRenderer(Minecraft.getMinecraft()).drawString(s1, x + 32 + 3, y + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + 3, 8421504);
- MCVer.getFontRenderer(Minecraft.getMinecraft()).drawString(s2, x + 32 + 3, y + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + 3, 8421504);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
-
- //#if MC>=10900
- GlStateManager.enableBlend();
- Minecraft.getMinecraft().getTextureManager().bindTexture(loc);
- Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, 32, 32, 32.0F, 32.0F);
- GlStateManager.disableBlend();
- if (Minecraft.getMinecraft().gameSettings.touchscreen || isSelected) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/world_selection.png"));
- Gui.drawRect(x, y, x + 32, y + 32, -1601138544);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- int j = mouseX - x;
- int i = j < 32 ? 32 : 0;
-
- Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0F, (float)i, 32, 32, 256.0F, 256.0F);
- }
- //#else
- //$$ if (Minecraft.getMinecraft().gameSettings.touchscreen || isSelected(slotIndex)) {
- //$$ Gui.drawRect(x, y, x + 32, y + 32, -1601138544);
- //$$ }
- //#endif
-
- boolean hover = false;
- int posX = width - x - 80;
- int posY = y + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT + 3;
-
- if (mouseX > posX && mouseX < (posX + 80) && mouseY > posY && mouseY < (posY + MCVer.getFontRenderer(Minecraft.getMinecraft()).FONT_HEIGHT)) {
- hover = true;
- }
-
- MCVer.getFontRenderer(Minecraft.getMinecraft()).drawString((hover ? "\u00A7l" : "") + "Leaderboard >", posX, posY, 0xadadad);
-
- }
-
-}
\ No newline at end of file
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraft.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraft.java
index ace97213..91acae2b 100644
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraft.java
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraft.java
@@ -20,7 +20,6 @@
import de.pfannekuchen.lotas.core.utils.ConfigUtils;
import de.pfannekuchen.lotas.core.utils.EventUtils;
import de.pfannekuchen.lotas.core.utils.KeybindsUtils;
-import de.pfannekuchen.lotas.gui.GuiChallengeIngameMenu;
import de.pfannekuchen.lotas.mixin.accessors.AccessorEntityPlayerMP;
import de.pfannekuchen.lotas.mods.AIManipMod;
import de.pfannekuchen.lotas.mods.DupeMod;
@@ -52,8 +51,6 @@ public class MixinMinecraft {
@Shadow
public GuiScreen currentScreen;
- private int save = 6;
-
private boolean isLoadingWorld;
@Shadow
@@ -147,12 +144,9 @@ public void injectrunGameLoop(CallbackInfo ci) throws IOException {
@ModifyVariable(method = "displayGuiScreen", at = @At("STORE"), index = 1, ordinal = 0)
public GuiScreen changeGuiScreen(GuiScreen screenIn) {
- if (ChallengeMap.currentMap != null && screenIn != null) {
- if (screenIn instanceof GuiIngameMenu) return new GuiChallengeIngameMenu();
- }
if (isLoadingWorld && screenIn == null) {
isLoadingWorld = false;
- return ChallengeMap.currentMap == null ? new GuiIngameMenu() : new GuiChallengeIngameMenu();
+ return new GuiIngameMenu();
}
return screenIn;
}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraftServer.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraftServer.java
index fea9c412..13c43520 100644
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraftServer.java
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/MixinMinecraftServer.java
@@ -44,7 +44,7 @@ public void redoServerWait(long millis) throws InterruptedException {
public WorldServer[] fixCrashDuringLoadstate(MinecraftServer server) {
if(MCVer.getWorlds(server).length==0) {
System.out.println("Prevented a forge crash. You are welcome!");
- return null;
+ return new WorldServer[] {};
}
return MCVer.getWorlds(server);
}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorGuiScreen.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorGuiScreen.java
new file mode 100644
index 00000000..ad92a1dd
--- /dev/null
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/accessors/AccessorGuiScreen.java
@@ -0,0 +1,16 @@
+package de.pfannekuchen.lotas.mixin.accessors;
+
+import java.util.List;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiScreen;
+
+@Mixin(GuiScreen.class)
+public interface AccessorGuiScreen {
+
+ @Accessor
+ public List getButtonList();
+}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinSaveHandler.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinSaveHandler.java
new file mode 100644
index 00000000..0c9c3588
--- /dev/null
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/patches/MixinSaveHandler.java
@@ -0,0 +1,53 @@
+package de.pfannekuchen.lotas.mixin.patches;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import de.pfannekuchen.lotas.mods.SavestateMod;
+import net.minecraft.world.storage.SaveHandler;
+
+@Mixin(SaveHandler.class)
+/**
+ * On rare occasions, savestating fails due to the level.dat being
+ *
+ * @author Scribble
+ *
+ */
+public class MixinSaveHandler {
+ @Inject(method = "saveWorldInfoWithPlayer", at = @At(value = "INVOKE", target = "Ljava/io/File;exists()Z", ordinal = 0), cancellable = true)
+ public void cancelLevelDataCreation(CallbackInfo ci) {
+ if(SavestateMod.isLoading) {
+ ci.cancel();
+ }
+ }
+
+// @Shadow
+// private File worldDirectory;
+//
+// @Redirect(method = "saveWorldInfoWithPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompressedStreamTools;writeCompressed(Lnet/minecraft/nbt/NBTTagCompound;Ljava/io/OutputStream;)V"))
+// public void redirect_saveWorldInfoWithPlayer(NBTTagCompound compound, OutputStream outputStream) {
+// if (SavestateMod.isSaving) {
+// File file = new File(this.worldDirectory, "level.dat");
+// if (file.exists()) {
+// file.delete();
+// }
+// try {
+// outputStream = new FileOutputStream(file);
+// } catch (FileNotFoundException e) {
+// e.printStackTrace();
+// }
+// }
+// if(!SavestateMod.isLoading) {
+// System.out.println("Writing");
+// try {
+// CompressedStreamTools.writeCompressed(compound, outputStream);
+// } catch (FileNotFoundException e) {
+// e.printStackTrace();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+// }
+}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiCreateWorld.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiCreateWorld.java
index d95b9702..f7d39e5f 100644
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiCreateWorld.java
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiCreateWorld.java
@@ -38,8 +38,8 @@ public void onKeyTyped(char key, int code, CallbackInfo ci) {
offsetX.textboxKeyTyped(key, code);
offsetZ.textboxKeyTyped(key, code);
try {
- LoTASModContainer.offsetX = MCVer.clamp(Integer.parseInt(offsetX.getText()), -9, 9);
- LoTASModContainer.offsetZ = MCVer.clamp(Integer.parseInt(offsetZ.getText()), -9, 9);
+ LoTASModContainer.offsetX = MCVer.clamp(Integer.parseInt(offsetX.getText()), -9, 9)*-1;
+ LoTASModContainer.offsetZ = MCVer.clamp(Integer.parseInt(offsetZ.getText()), -9, 9)*-1;
} catch (Exception e) {
// Lazyness wins. (This is actually fine)
}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiIngameMenu.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiIngameMenu.java
index fa2ef674..6c4cf50e 100644
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiIngameMenu.java
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiIngameMenu.java
@@ -1,33 +1,17 @@
package de.pfannekuchen.lotas.mixin.render.gui;
-import java.awt.Color;
import java.io.IOException;
-import java.time.Duration;
import java.util.ArrayList;
-import org.lwjgl.input.Keyboard;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
-import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-
import de.pfannekuchen.lotas.core.MCVer;
-import de.pfannekuchen.lotas.core.utils.ConfigUtils;
-import de.pfannekuchen.lotas.core.utils.EventUtils.Timer;
-import de.pfannekuchen.lotas.gui.GuiAiManipulation;
-import de.pfannekuchen.lotas.gui.GuiDragonManipulation;
-import de.pfannekuchen.lotas.gui.GuiDropChanceManipulation;
-import de.pfannekuchen.lotas.gui.GuiEntitySpawnManipulation;
-import de.pfannekuchen.lotas.gui.GuiLoadstateMenu;
-import de.pfannekuchen.lotas.mods.AIManipMod;
+import de.pfannekuchen.lotas.gui.LoTASGuiIngameMenu;
import de.pfannekuchen.lotas.mods.DupeMod;
-import de.pfannekuchen.lotas.mods.SavestateMod;
-import de.pfannekuchen.lotas.mods.TickrateChangerMod;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.GuiButton;
@@ -35,9 +19,7 @@
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
-import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.item.EntityItem;
-import net.minecraftforge.fml.client.config.GuiCheckBox;
@Mixin(GuiIngameMenu.class)
public abstract class MixinGuiIngameMenu extends GuiScreen {
@@ -46,14 +28,11 @@ public abstract class MixinGuiIngameMenu extends GuiScreen {
* Adds a few utility buttons
*/
- @Unique
- private static ImmutableList glitchedButtons = ImmutableList.of(17, 18, 22);
- @Unique
- private static ImmutableList advancedButtons = ImmutableList.of(21, 22, 23, 24, 26, 27, 28, 29, 30);
-
public GuiTextField savestateName;
public GuiTextField tickrateField;
+ private LoTASGuiIngameMenu lotasGui;
+
@Inject(method = "initGui", at = @At("RETURN"))
public void injectinitGui(CallbackInfo ci) {
this.buttonList.set(1, new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + -16, I18n.format("menu.returnToGame")) {
@@ -82,36 +61,9 @@ public void playPressSound(SoundHandler soundHandlerIn) {
//#else
//$$ buttonList.get(0).yPosition += 24;
//#endif
- this.buttonList.add(new GuiButton(13, this.width / 2 - 100, this.height / 4 + 96 + -16, 98, 20, I18n.format("Savestate")));
-
- GuiButton loadstate = new GuiButton(14, this.width / 2 + 2, this.height / 4 + 96 + -16, 98, 20, I18n.format("Loadstate"));
- loadstate.enabled = SavestateMod.hasSavestate();
- this.buttonList.add(loadstate);
- this.buttonList.add(new GuiButton(15, 5, 15, 48, 20, I18n.format("+")));
- this.buttonList.add(new GuiButton(16, 55, 15, 48, 20, I18n.format("-")));
- this.buttonList.add(new GuiButton(17, 5, 55, 98, 20, I18n.format("Save Items")));
- this.buttonList.add(new GuiButton(18, 5, 75, 98, 20, I18n.format("Load Items")));
-
- this.buttonList.add(new GuiButton(19, (width / 4) * 0 + 1, height - 20, width / 4 - 2, 20, I18n.format("Manipulate Drops")));
- try {
- this.buttonList.add(new GuiButton(20, (width / 4) * 1 + 2, height - 20, width / 4 - 2, 20, I18n.format("Manipulate Dragon")));
- this.buttonList.get(this.buttonList.size() - 1).enabled = MCVer.world(Minecraft.getMinecraft().getIntegratedServer(), MCVer.player(mc).dimension).getEntities(EntityDragon.class, Predicates.alwaysTrue()).size() >= 1;
- } catch (Exception e) {
- System.out.println("No Enderdragon found.");
- }
- this.buttonList.add(new GuiButton(21, (width / 4) * 2 + 3, height - 20, width / 4 - 2, 20, I18n.format("Manipulate Spawning")));
-
- this.buttonList.add(new GuiCheckBox(22, 2, height - 20 - 15, I18n.format("Avoid taking damage"), !ConfigUtils.getBoolean("tools", "takeDamage")));
- this.buttonList.add(new GuiButton(23, 37, 115, 66, 20, I18n.format("Jump ticks")));
- this.buttonList.add(new GuiButton(24, 5, 115, 30, 20, I18n.format(((int) TickrateChangerMod.ticks[TickrateChangerMod.ji]) + "t")));
- this.buttonList.add(new GuiButton(25, this.width / 2 - 100, this.height / 4 + 144 + -16, I18n.format("Reset Timer")));
- this.buttonList.add(new GuiCheckBox(26, 2, height - 32 - 15, I18n.format("Drop towards me"), ConfigUtils.getBoolean("tools", "manipulateVelocityTowards")));
- this.buttonList.add(new GuiCheckBox(27, 2, height - 44 - 15, I18n.format("Drop away from me"), ConfigUtils.getBoolean("tools", "manipulateVelocityAway")));
- this.buttonList.add(new GuiCheckBox(28, 2, height - 56 - 15, I18n.format("Optimize Explosions"), ConfigUtils.getBoolean("tools", "manipulateExplosionDropChance")));
- this.buttonList.add(new GuiCheckBox(30, 2, height - 68 - 15, I18n.format("Toggle R Auto Clicker"), ConfigUtils.getBoolean("tools", "lAutoClicker")));
- this.buttonList.add(new GuiButton(29, (width / 4) * 3 + 4, height - 20, width / 4 - 4, 20, I18n.format("Manipulate AI")));
- this.buttonList.get(this.buttonList.size() - 1).enabled = AIManipMod.isEntityInRange();
+ lotasGui = new LoTASGuiIngameMenu((GuiIngameMenu)(Object)this);
+ lotasGui.addButtons();
}
/**
@@ -125,198 +77,25 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawCenteredString(MCVer.getFontRenderer(mc), I18n.format("menu.game"), this.width / 2, 15, 16777215);
super.drawScreen(mouseX, mouseY, partialTicks);
-
- if (getClass().getSimpleName().contains("GuiIngameMenu")) {
- if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- this.buttonList.get(7).displayString = "\u00A76Name Savestate";
- this.buttonList.get(8).displayString = "\u00A76Choose State";
- } else {
- this.buttonList.get(7).displayString = "Savestate";
- this.buttonList.get(8).displayString = "Loadstate";
- }
- }
- if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- this.buttonList.get(9).displayString = "\u00A76Custom";
- this.buttonList.get(10).displayString = "\u00A76Tickrate";
- } else {
- this.buttonList.get(9).displayString = "+";
- this.buttonList.get(10).displayString = "-";
- }
-
- drawString(MCVer.getFontRenderer(mc), "Tickrate Changer (" + TickrateChangerMod.tickrate + ")", 5, 5, 0xFFFFFF);
- drawCenteredString(MCVer.getFontRenderer(mc), "Hold Shift to access more features", width / 2, this.height / 4 + 150, 0xFFFFFF);
+ lotasGui.drawScreen(mouseX, mouseY, partialTicks);
- if (savestateName != null) savestateName.drawTextBox();
- if (tickrateField != null) tickrateField.drawTextBox();
-
- if (SavestateMod.showSavestateDone) {
- long timeSince = System.currentTimeMillis() - SavestateMod.timeTitle;
- if (timeSince >= 1800) {
- SavestateMod.showSavestateDone = false;
- buttonList.get(8).enabled=SavestateMod.hasSavestate();
- return;
- }
- drawCenteredString(MCVer.getFontRenderer(mc), "\u00A76Savestate successful...", width / 2, 40, new Color(1F, 1F, 1F, 1F - (timeSince / 2000F)).getRGB());
- } else if (SavestateMod.showLoadstateDone) {
- long timeSince = System.currentTimeMillis() - SavestateMod.timeTitle;
- if (timeSince >= 1800) {
- SavestateMod.showLoadstateDone = false;
- return;
- }
- drawCenteredString(MCVer.getFontRenderer(mc), "\u00A76Loadstate successful...", width / 2, 40, new Color(1F, 1F, 1F, 1F - (timeSince / 2000F)).getRGB());
- }
-
- MCVer.getFontRenderer(mc).drawStringWithShadow("Tickjump", 10, 105, 0xFFFFFF);
- if(buttonList.get(17).enabled==false) {
- MCVer.getFontRenderer(mc).drawStringWithShadow("Tickjump is ready,", 8, 137, 0xFFFFFF);
- MCVer.getFontRenderer(mc).drawStringWithShadow("press ESC to continue", 8, 147, 0xFFFFFF);
- }
- MCVer.getFontRenderer(mc).drawStringWithShadow("Duping", 10, 45, 0xFFFFFF);
- int w = width - 5;
- MCVer.getFontRenderer(mc).drawStringWithShadow("Tracked Items Delay: ", w - MCVer.getFontRenderer(mc).getStringWidth("Tracked Items Delay: ") - 1, 10, 0xFFFFFFFF);
- /*int h = 22;
- for (EntityItem item : DupeMod.trackedObjects) {
-
- Temporary removed as to Mixin Bug, that is patched in 0.8, but 0.8 doesn't work with 1.8
- //#if MC>=11200
- MCVer.getFontRenderer(mc).drawStringWithShadow(((AccessorEntityItem) item).pickupDelay() + "t " + item.getItem().getDisplayName(), w - MCVer.getFontRenderer(mc).getStringWidth("Tracked Items Delay: "), h, 0xFFFFFFFF);
- //#else
-//$$ MCVer.getFontRenderer(mc).drawStringWithShadow(((AccessorEntityItem) item).pickupDelay() + "t " + item.getEntityItem().getDisplayName(), w - MCVer.getFontRenderer(mc).getStringWidth("Tracked Items Delay: "), h, 0xFFFFFFFF);
- //#endif
-
- h += 10;
- }*/
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- if (savestateName != null) {
- savestateName.mouseClicked(mouseX, mouseY, mouseButton);
- }
- if (tickrateField != null) {
- tickrateField.mouseClicked(mouseX, mouseY, mouseButton);
- }
+ lotasGui.mouseClicked(mouseX, mouseY, mouseButton);
super.mouseClicked(mouseX, mouseY, mouseButton);
}
-
-
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
- if (savestateName != null) {
- boolean focused = savestateName.isFocused();
- savestateName.textboxKeyTyped(typedChar, keyCode);
- if (keyCode == Keyboard.KEY_RETURN && focused) {
- if (savestateName.getText().isEmpty()) {
- SavestateMod.savestate(null);
- } else {
- SavestateMod.savestate(savestateName.getText());
- }
- }
- }
- if (tickrateField != null) {
- boolean focused = tickrateField.isFocused();
- tickrateField.textboxKeyTyped(typedChar, keyCode);
- if (keyCode == Keyboard.KEY_RETURN && focused) {
- if (!tickrateField.getText().isEmpty()) {
- TickrateChangerMod.updateTickrate(Float.parseFloat(tickrateField.getText()));
- }
- }
- }
- // new GuiTextField(0, MCVer.getFontRenderer(Minecraft.getMinecraft()), 4, 15, 103, 20)
+ lotasGui.keyTyped(typedChar, keyCode);
super.keyTyped(typedChar, keyCode);
}
@Inject(method = "actionPerformed", at = @At("HEAD"))
public void redoactionPerformed(GuiButton button, CallbackInfo ci) {
- if (button.id == 13) {
- if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- savestateName = new GuiTextField(93, MCVer.getFontRenderer(mc), this.width / 2 - 100, this.height / 4 + 96 + -16, 98, 20);
- button.enabled = false;
- savestateName.setFocused(true);
- } else SavestateMod.savestate(null);
- } else if (button.id == 14) {
- if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) mc.displayGuiScreen(new GuiLoadstateMenu());
- else SavestateMod.loadstate(-1);
- } else if (button.id == 15) {
- if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- tickrateField = new GuiTextField(0, MCVer.getFontRenderer(Minecraft.getMinecraft()), 4, 15, 103, 20);
- button.enabled = false;
- tickrateField.setFocused(true);
- } else {
- TickrateChangerMod.index++;
- TickrateChangerMod.index = MCVer.clamp(TickrateChangerMod.index, 0, 11);
- TickrateChangerMod.updateTickrate(TickrateChangerMod.ticks[TickrateChangerMod.index]);
- }
- } else if (button.id == 16) {
- if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- tickrateField = new GuiTextField(0, MCVer.getFontRenderer(Minecraft.getMinecraft()), 4, 15, 103, 20);
- button.enabled = false;
- tickrateField.setFocused(true);
- } else {
- TickrateChangerMod.index--;
- TickrateChangerMod.index = MCVer.clamp(TickrateChangerMod.index, 0, 11);
- TickrateChangerMod.updateTickrate(TickrateChangerMod.ticks[TickrateChangerMod.index]);
- }
- } else if (button.id == 17) {
- DupeMod.saveItems();
- DupeMod.saveChests();
- button.enabled = false;
- } else if (button.id == 18) {
- DupeMod.loadItems();
- DupeMod.loadChests();
- button.enabled = false;
- } else if (button.id == 19) {
- Minecraft.getMinecraft().displayGuiScreen(new GuiDropChanceManipulation((GuiIngameMenu) (Object) this));
- } else if (button.id == 20) {
- //#if MC>=10900
- Minecraft.getMinecraft().displayGuiScreen(new GuiDragonManipulation(this));
- //#else
-//$$ button.enabled=false;
-//$$ GuiDragonManipulation.chargePlayer();
- //#endif
- } else if (button.id == 21) {
- Minecraft.getMinecraft().displayGuiScreen(new GuiEntitySpawnManipulation());
- } else if (button.id == 22) {
- ConfigUtils.setBoolean("tools", "takeDamage", !((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- } else if (button.id == 23) {
- TickrateChangerMod.ticksToJump = (int) TickrateChangerMod.ticks[TickrateChangerMod.ji];
- button.enabled = false;
- button.displayString = "Jumping...";
- } else if (button.id == 24) {
- TickrateChangerMod.ji++;
- if (TickrateChangerMod.ji > 11) TickrateChangerMod.ji = 2;
- buttonList.clear();
- initGui();
- } else if (button.id == 25) {
- Timer.ticks = -1;
- Timer.startTime = Duration.ofMillis(System.currentTimeMillis());
- } else if (button.id == 26) {
- if (((GuiCheckBox) button).isChecked()) {
- ConfigUtils.setBoolean("tools", "manipulateVelocityAway", false);
- ConfigUtils.save();
- ((GuiCheckBox) this.buttonList.get(21)).setIsChecked(false);
- }
- ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", ((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- } else if (button.id == 27) {
- if (((GuiCheckBox) button).isChecked()) {
- ConfigUtils.setBoolean("tools", "manipulateVelocityTowards", false);
- ConfigUtils.save();
- ((GuiCheckBox) this.buttonList.get(20)).setIsChecked(false);
- }
- ConfigUtils.setBoolean("tools", "manipulateVelocityAway", ((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- } else if (button.id == 28) {
- ConfigUtils.setBoolean("tools", "manipulateExplosionDropChance", ((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- } else if (button.id == 29) {
- Minecraft.getMinecraft().displayGuiScreen(new GuiAiManipulation());
- } else if (button.id == 30) {
- ConfigUtils.setBoolean("tools", "lAutoClicker", ((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- }
+ lotasGui.actionPerformed(button);
}
}
\ No newline at end of file
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiWorldSelection.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiWorldSelection.java
index 250d8493..0c1d5ec8 100644
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiWorldSelection.java
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mixin/render/gui/MixinGuiWorldSelection.java
@@ -1,38 +1,27 @@
package de.pfannekuchen.lotas.mixin.render.gui;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import de.pfannekuchen.lotas.core.LoTASModContainer;
import de.pfannekuchen.lotas.core.MCVer;
import de.pfannekuchen.lotas.core.utils.ConfigUtils;
-import de.pfannekuchen.lotas.gui.GuiSeedList;
-import de.pfannekuchen.lotas.gui.widgets.ChallengeMapEntryWidget;
-import de.pfannekuchen.lotas.taschallenges.ChallengeMap;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
-
import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.fml.client.config.GuiCheckBox;
-
//#if MC>=10900
import net.minecraft.client.gui.GuiListWorldSelection;
-import net.minecraft.client.gui.GuiListWorldSelectionEntry;
+import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiWorldSelection;
+import net.minecraftforge.fml.client.config.GuiCheckBox;
@Mixin(GuiWorldSelection.class)
public abstract class MixinGuiWorldSelection extends GuiScreen {
@Shadow
private GuiListWorldSelection selectionList;
//#else
//$$ import net.minecraft.world.storage.SaveFormatComparator;
+//$$ import net.minecraftforge.fml.client.config.GuiCheckBox;
//$$ import net.minecraft.client.gui.GuiSelectWorld;
//$$ @Mixin(GuiSelectWorld.class)
//$$ public abstract class MixinGuiWorldSelection extends GuiScreen {
@@ -44,98 +33,19 @@ public abstract class MixinGuiWorldSelection extends GuiScreen {
//$$ private java.util.List field_146639_s;
//#endif
- @Inject(at = @At("RETURN"), method = "initGui")
- public void injectinitGui2(CallbackInfo ci) {
- if (!ConfigUtils.getBoolean("tools", "hideMaps")) {
- //#if MC>=10900
- for (ChallengeMap map : LoTASModContainer.maps) {
- ChallengeMapEntryWidget entry = new ChallengeMapEntryWidget(selectionList, map, width);
- entry.loc = new ResourceLocation("maps", map.resourceLoc);
- try {
- @SuppressWarnings("unchecked")
- java.util.List i = (java.util.List) getFinal(selectionList, GuiListWorldSelection.class.getDeclaredField("field_186799_w"));
- i.add(entry);
- setFinal(selectionList, GuiListWorldSelection.class.getDeclaredField("field_186799_w"), i);
- } catch (Exception e) { }
- }
- //#else
-//$$ field_146638_t = ((GuiSelectWorld) (Object) this).new List(mc);
- //#endif
- }
- }
-
@Inject(at = @At("HEAD"), method = "initGui")
public void injectinitGui(CallbackInfo ci) {
- this.buttonList.add(new GuiButton(16, 5, 5, 98, 20, "Seeds"));
this.buttonList.add(new GuiCheckBox(17, width - 17 - MCVer.getFontRenderer(mc).getStringWidth("Open ESC when joining world"), 4, "Open ESC when joining world", ConfigUtils.getBoolean("tools", "hitEscape")));
- this.buttonList.add(new GuiCheckBox(18, width - 17 - MCVer.getFontRenderer(mc).getStringWidth("Open ESC when joining world"), 16, "Show TAS Challenge Maps", ConfigUtils.getBoolean("tools", "hideMaps")));
}
- // Workaround cuz of Mixin
- @Unique private static void setFinal(Object instance, Field field, Object newValue) {
- try {
- field.setAccessible(true);
-
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
-
- field.set(instance, newValue);
- } catch (Exception e) { }
- }
- // 2. Workaround
- @Unique private static Object getFinal(Object instance, Field field) {
- try {
- field.setAccessible(true);
- return field.get(instance);
- } catch (Exception e) { }
- return null;
- }
-
-
- @SuppressWarnings("unchecked")
@Inject(at = @At("HEAD"), method = "actionPerformed")
public void injectactionPerformed(GuiButton button, CallbackInfo ci) {
switch (button.id) {
- case 16:
- Minecraft.getMinecraft().displayGuiScreen(new GuiSeedList());
- break;
case 17:
ConfigUtils.setBoolean("tools", "hitEscape", ((GuiCheckBox) button).isChecked());
ConfigUtils.save();
break;
- case 18:
- ConfigUtils.setBoolean("tools", "hideMaps", ((GuiCheckBox) button).isChecked());
- ConfigUtils.save();
- //#if MC>=10900
- try {
- java.util.List i = (java.util.List) getFinal(selectionList, GuiListWorldSelection.class.getDeclaredField("field_186799_w"));
- i.clear();
- setFinal(selectionList, GuiListWorldSelection.class.getDeclaredField("field_186799_w"), i);
- if (((GuiCheckBox) button).isChecked()) {
- selectionList.refreshList();
- for (ChallengeMap map : LoTASModContainer.maps) {
- ChallengeMapEntryWidget entry = new ChallengeMapEntryWidget(selectionList, map, width);
- entry.loc = new ResourceLocation("maps", map.resourceLoc);
- i = (java.util.List) getFinal(selectionList, GuiListWorldSelection.class.getDeclaredField("field_186799_w"));
- i.add(entry);
- setFinal(selectionList, GuiListWorldSelection.class.getDeclaredField("field_186799_w"), i);
- }
- } else {
- selectionList.refreshList();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- //#else
-//$$ if (((GuiCheckBox) button).isChecked()) {
-//$$ field_146638_t = new ChallengeMapEntryWidget((GuiSelectWorld) (Object) this, width);
-//$$ } else {
-//$$ field_146638_t = ((GuiSelectWorld) (Object) this).new List(mc);
-//$$ }
- //#endif
default:
-
break;
}
}
diff --git a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mods/SavestateMod.java b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mods/SavestateMod.java
index 0de2321a..276c432b 100644
--- a/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mods/SavestateMod.java
+++ b/LoTAS-Forge/src/main/java/de/pfannekuchen/lotas/mods/SavestateMod.java
@@ -15,14 +15,15 @@
import de.pfannekuchen.lotas.core.MCVer;
import de.pfannekuchen.lotas.core.utils.EventUtils.Timer;
import de.pfannekuchen.lotas.mixin.accessors.AccessorAnvilChunkLoader;
+import de.pfannekuchen.lotas.mixin.render.gui.MixinGuiIngameMenu;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.world.MinecraftException;
import net.minecraft.world.WorldServer;
-import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
+import net.minecraft.world.gen.ChunkProviderServer;
/**
* Saves the player velocity and makes a copy of the world in a seperate folder.
@@ -48,6 +49,8 @@ public class SavestateMod {
/** Turns off rendering to fake loadless savestates */
public static boolean isLoading;
+
+ public static boolean isSaving;
/**
* Returns the motion of the player, and the current time of the timer as a string
@@ -65,6 +68,8 @@ public static final String generateSavestateFile() {
public static void savestate(String name) {
final String data = generateSavestateFile();
final Minecraft mc = Minecraft.getMinecraft();
+
+ isSaving = true;
final MinecraftServer server = mc.getIntegratedServer();
@@ -101,13 +106,13 @@ public static void savestate(String name) {
// create a new thread that copies the world
new Thread(() -> {
// find next savestate directory
- final String worldName = server.getFolderName();
- final File worldDir = new File(mc.mcDataDir, "saves/" + worldName);
- final File savestatesDir = new File(mc.mcDataDir, "saves/savestates/");
+ String worldName = server.getFolderName();
+ File worldDir = new File(mc.mcDataDir, "saves/" + worldName);
+ File savestatesDir = new File(mc.mcDataDir, "saves/savestates/");
if (!savestatesDir.exists()) savestatesDir.mkdir();
- final int existingSavestates = savestatesDir.listFiles((d, s) -> {
+ int existingSavestates = savestatesDir.listFiles((d, s) -> {
return s.startsWith(worldName + "-Savestate");
}).length;
@@ -138,6 +143,7 @@ public static void savestate(String name) {
// show the label, that the savestates is done.
showSavestateDone = true;
timeTitle = System.currentTimeMillis();
+ isSaving = false;
System.gc();
TickrateChangerMod.updateTickrate(tickratesaved);
@@ -148,7 +154,8 @@ public static void savestate(String name) {
* @throws IOException Throws when the World was locked
*/
public static void loadstate(int number) {
- if (!hasSavestate()) return; // check for a savestates
+ if (!hasSavestate())
+ return; // check for a savestates
// save mouse coordinates to avoid mouse madness when not in fullscreen
int x = Mouse.getX();
@@ -156,21 +163,22 @@ public static void loadstate(int number) {
isLoading = true; // turn off rendering
+ // Store the tickrate before the loadstate
float tickratesaved=TickrateChangerMod.tickrateServer;
TickrateChangerMod.updateTickrate(20);
// stop the server without saving the world
- final Minecraft mc = Minecraft.getMinecraft();
- final IntegratedServer server = mc.getIntegratedServer();
+ Minecraft mc = Minecraft.getMinecraft();
+ IntegratedServer server = mc.getIntegratedServer();
for (WorldServer worldserver : MCVer.getWorlds(server)) {
worldserver.disableLevelSaving = true;
}
Minecraft.stopIntegratedServer();
// load the world
- final String worldName = server.getFolderName();
- final File worldDir = new File(mc.mcDataDir, "saves/" + worldName);
- final File savestatesDir = new File(mc.mcDataDir, "saves/savestates/");
+ String worldName = server.getFolderName();
+ File worldDir = new File(mc.mcDataDir, "saves/" + worldName);
+ File savestatesDir = new File(mc.mcDataDir, "saves/savestates/");
int existingSavestates = savestatesDir.listFiles((d, s) -> {
return s.startsWith(worldName + "-Savestate");
@@ -178,22 +186,55 @@ public static void loadstate(int number) {
if (number != -1) existingSavestates = number;
- final File savestateDir = new File(savestatesDir, worldName + "-Savestate" + (existingSavestates));
+ // Deleting the savestate dir
+ File savestateDir = new File(savestatesDir, worldName + "-Savestate" + (existingSavestates));
try {
- final String data = new String(com.google.common.io.Files.toByteArray(new File(savestateDir, "savestate.dat")));
FileUtils.deleteDirectory(worldDir);
+ } catch (IOException e) {
+ System.out.println("Failed to delete the current world. Trying to salvage it...");
+ e.printStackTrace();
+ try {
+ Thread.sleep(20L);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ try {
+ FileUtils.copyDirectory(savestateDir, worldDir);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ // Copying savestates
+ try {
FileUtils.copyDirectory(savestateDir, worldDir);
-
- // re apply the velocity to make a seamless transition
- motionX = Double.parseDouble(data.split(":")[0]);
- motionY = Double.parseDouble(data.split(":")[1]);
- motionZ = Double.parseDouble(data.split(":")[2]);
- Timer.ticks = Integer.parseInt(data.split(":")[3]);
- applyVelocity = true;
- TrackerFile.increaseLoadstates(savestatesDir, worldName);
- } catch (NumberFormatException | IOException e) {
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+
+ File savestateFile = new File(savestateDir, "savestate.dat");
+
+ // Load savestate data
+
+ String data= "";
+ try {
+ if(savestateFile.exists())
+ data = new String(com.google.common.io.Files.toByteArray(savestateFile));
+
+ if(!data.isEmpty()) {
+ // re apply the velocity to make a seamless transition
+ motionX = Double.parseDouble(data.split(":")[0]);
+ motionY = Double.parseDouble(data.split(":")[1]);
+ motionZ = Double.parseDouble(data.split(":")[2]);
+ Timer.ticks = Integer.parseInt(data.split(":")[3]);
+ applyVelocity = true;
+ TrackerFile.increaseLoadstates(savestatesDir, worldName);
+ }
+ } catch(Exception e){
+ System.out.println("Failed to read savestate data:");
e.printStackTrace();
}
+
// clear chat messages because of leftover messages
//#if MC>=11100
mc.ingameGUI.getChatGUI().clearChatMessages(true);
diff --git a/LoTAS-Forge/src/main/resources/lotas.mixin.json b/LoTAS-Forge/src/main/resources/lotas.mixin.json
index 424c2d2e..6f32e1ff 100644
--- a/LoTAS-Forge/src/main/resources/lotas.mixin.json
+++ b/LoTAS-Forge/src/main/resources/lotas.mixin.json
@@ -23,7 +23,8 @@
"patches.MixinWorldProviderPatch",
"patches.MixinEntitySheepPatch",
"MixinMinecraftServer",
- "patches.MixinInaccuracyPatch"
+ "patches.MixinInaccuracyPatch",
+ "patches.MixinSaveHandler"
],
"client": [
"accessors.AccessorMinecraftClient",
@@ -32,6 +33,7 @@
"accessors.AccessorTimer",
"accessors.AccessFocused",
"accessors.AccessorSoundManager",
+ "accessors.AccessorGuiScreen",
"render.gui.MixinGuiScreenWorking",
"render.gui.MixinGuiGameOver",
"render.gui.MixinGuiMainMenu",
diff --git a/LoTAS-Forge/versions/common.gradle b/LoTAS-Forge/versions/common.gradle
index 14720162..58830e24 100644
--- a/LoTAS-Forge/versions/common.gradle
+++ b/LoTAS-Forge/versions/common.gradle
@@ -15,7 +15,7 @@ apply plugin: 'org.spongepowered.mixin'
sourceCompatibility = 1.8
targetCompatibility = 1.8
-version = "2.0.4"
+version = "2.1.0"
group= "de.pfannekuchen.lotas"
archivesBaseName = "LoTAS"