Skip to content

Commit

Permalink
Release 2.1.0 for LoTAS 1.7.10 to 1.19.3
Browse files Browse the repository at this point in the history
## Major changes:
* Added 1.19.3
* Made savestates more reliable, preventing corruption
* Reworked the entire Pause Screen
  * Added small gap between Save Items and Load items
  * Changed position of text boxes to match the buttons
  * Added hint text in checkboxes to tell the user to press enter to apply
  * Added hint text for Jump Ticks when holding shift
  * Holding shift and clicking on jump ticks counter will decrease the counter
  * Disabled ticks counter when jump ticks is pressed
  * Fixed crash when entering non numerical values into custom tickrate box and added hint
  * Unselecting a custom tickrate box will close that box and the original button will appear
## Fixes
* [♾-snapshot] Fixed crash when opening the creative inventory
* Fixed hitbox of labels in InfoGui being unclickable when resizing the window to something smaller
* Fixed `fixedCrashDuringLoadstate` not fixing crash during loadstate
* [Forge] Create world spawn location was inverted
## Removed
* TAS-Challenge Maps (did you even know this existed?)
* SeedList Screen
* [Fabric] Possible fix for memory leak when loadstating
  • Loading branch information
PancakeTAS authored Dec 9, 2022
2 parents 6bc3e19 + f08d05c commit 187e89c
Show file tree
Hide file tree
Showing 69 changed files with 1,842 additions and 1,715 deletions.
2 changes: 1 addition & 1 deletion LoTAS-Fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 2 additions & 1 deletion LoTAS-Fabric/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand All @@ -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 <a href="http://mgnet.work/seeds/">mgnet.work/seeds/seedsX.XX.X.txt</a> 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<String> 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));
}
}

}
67 changes: 49 additions & 18 deletions LoTAS-Fabric/src/main/java/de/pfannekuchen/lotas/core/MCVer.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

/**
Expand All @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -446,29 +460,45 @@ public static BlockEntityRenderDispatcher getBlockEntityDispatcher() {
}
//#endif

// =============================================== 1.16.5 | 1.17 BUTTONS =========================================
// =============================================== 1.19.3 BUTTONS ================================================
//#if MC>=11903
//$$ public static <T extends net.minecraft.client.gui.components.events.GuiEventListener & net.minecraft.client.gui.components.Renderable & net.minecraft.client.gui.narration.NarratableEntry> 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 extends net.minecraft.client.gui.components.events.GuiEventListener & net.minecraft.client.gui.components.Widget & net.minecraft.client.gui.narration.NarratableEntry> T addButton(Screen screen, T button) {
//$$ ((de.pfannekuchen.lotas.core.utils.AccessorScreen2)screen).addRenderableWidget(button);
//$$ return button;
//$$ }
//#else
public static <T extends AbstractWidget> 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
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();
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package de.pfannekuchen.lotas.core.utils;


//#if MC>=11800
//$$ public interface AccessorScreen2 {
//#if MC>=11903
//$$ public <T extends net.minecraft.client.gui.components.events.GuiEventListener & net.minecraft.client.gui.components.Renderable & net.minecraft.client.gui.narration.NarratableEntry> T addRenderableWidget(T widget);
//#else
//$$ public <T extends net.minecraft.client.gui.components.events.GuiEventListener & net.minecraft.client.gui.components.Widget & net.minecraft.client.gui.narration.NarratableEntry> T addRenderableWidget(T widget);
//#endif
//#else
//#if MC>=11700
//$$ public interface AccessorScreen2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public List<ItemStack> 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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public List<ItemStack> 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;

Expand All @@ -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);
Expand Down
Loading

0 comments on commit 187e89c

Please sign in to comment.