Skip to content

Commit e961441

Browse files
committed
Update to v1.0.0
1 parent a41a2a5 commit e961441

File tree

9 files changed

+38
-50
lines changed

9 files changed

+38
-50
lines changed

gradle.properties

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,22 @@ org.gradle.parallel=true
66
org.gradle.daemon=false
77

88
# Mod Menu
9-
modmenu_version=14.0.0-rc.2
9+
modmenu_version=13.0.3
1010

1111
# Fabric Properties
1212
# check these on https://fabricmc.net/develop
13-
minecraft_version=1.21.5
14-
yarn_mappings=1.21.5+build.1
15-
loader_version=0.16.12
13+
minecraft_version=1.21.4
14+
yarn_mappings=1.21.4+build.8
15+
loader_version=0.16.14
16+
loom_version=1.10-SNAPSHOT
1617

1718
# Mod Properties
18-
mod_version=v1.0.0+1.21.5
19+
mod_version=v1.0.0+1.21.4
1920
maven_group=net.jasper.mod
2021
archives_base_name=playerautoma
2122

2223
# Dependencies
23-
fabric_version=0.119.9+1.21.5
24+
fabric_version=0.119.2+1.21.4
2425

2526
# Other dependencies
2627
lombok_version=1.18.38

src/main/java/net/jasper/mod/ModMenuApiImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ public class ModMenuApiImpl implements ModMenuApi {
1010
public ConfigScreenFactory<?> getModConfigScreenFactory() {
1111
return (ConfigScreenFactory<PlayerautomaOptionsScreen>) PlayerautomaOptionsScreen::new;
1212
}
13-
1413
}

src/main/java/net/jasper/mod/automation/InventoryAutomation.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import net.minecraft.screen.slot.SlotActionType;
1515
import net.minecraft.util.ActionResult;
1616
import net.minecraft.util.Hand;
17-
import net.minecraft.world.GameMode;
1817

1918
/**
2019
* This class is responsible for re-stacking items in the inventory when replaying
@@ -29,10 +28,6 @@ public class InventoryAutomation {
2928
public static void register() {
3029
inventoryTasks.register("inventoryTasks");
3130
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
32-
if (GameMode.CREATIVE.equals(player.getGameMode())) {
33-
return ActionResult.PASS;
34-
}
35-
3631
// If is disabled in settings do nothing
3732
if (Boolean.FALSE.equals(PlayerautomaOptionsScreen.restackBlocksOption.getValue())) {
3833
return ActionResult.PASS;
@@ -44,7 +39,7 @@ public static void register() {
4439
return ActionResult.PASS;
4540
}
4641

47-
ItemStack currentItem = inventory.getStack(inventory.getSelectedSlot());
42+
ItemStack currentItem = inventory.getStack(inventory.selectedSlot);
4843
// Check if item is a placeable item in the world
4944
if (Block.getBlockFromItem(currentItem.getItem()) == Block.getBlockFromItem(Items.AIR)) {
5045
return ActionResult.PASS;
@@ -60,8 +55,8 @@ public static void register() {
6055
}
6156

6257
// Check if another Stack of the item in mainHand is in the Inventory
63-
int exceptedSlot = inventory.getEmptySlot();
64-
for (int i = 0; i < inventory.getMainStacks().size(); i++) { //NOSONAR
58+
int exceptedSlot = inventory.selectedSlot;
59+
for (int i = 0; i < inventory.main.size(); i++) { // NOSONAR
6560
ItemStack item = inventory.getStack(i);
6661
if (i == exceptedSlot || item.getItem() != currentItem.getItem()) {
6762
continue;
@@ -85,7 +80,7 @@ public static void register() {
8580
client.interactionManager.clickSlot(
8681
screen.getScreenHandler().syncId,
8782
fromSlot,
88-
inventory.getSelectedSlot(),
83+
inventory.selectedSlot,
8984
SlotActionType.SWAP,
9085
client.player
9186
);

src/main/java/net/jasper/mod/automation/PlayerRecorder.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
import net.jasper.mod.util.IOHelpers;
1212
import net.jasper.mod.util.Textures;
1313
import net.jasper.mod.util.ThumbnailHelpers;
14-
import net.jasper.mod.util.data.LookingDirection;
15-
import net.jasper.mod.util.data.Recording;
16-
import net.jasper.mod.util.data.SlotClick;
17-
import net.jasper.mod.util.data.TaskQueue;
14+
import net.jasper.mod.util.data.*;
1815
import net.jasper.mod.util.keybinds.Constants;
1916
import net.minecraft.client.MinecraftClient;
2017
import net.minecraft.client.gui.screen.Screen;
@@ -113,7 +110,7 @@ public static void register() {
113110
timesPressed,
114111
modifiers,
115112
new LookingDirection(client.player.getYaw(), client.player.getPitch()),
116-
client.player.getInventory().getSelectedSlot(),
113+
client.player.getInventory().selectedSlot,
117114
lastSlotClicked.poll(),
118115
client.currentScreen == null ? null : client.currentScreen.getClass(),
119116
lastCommandUsed.poll(),
@@ -151,16 +148,14 @@ public static void startRecord() {
151148
clearRecord();
152149

153150
if (Boolean.TRUE.equals(PlayerautomaOptionsScreen.saveThumbnailsWithRecording.getValue())) {
154-
ThumbnailHelpers.create((thumbnail, nativeImage) -> {
155-
if (thumbnail != null) {
156-
recording.thumbnail = thumbnail;
157-
thumbnailTexture = new NativeImageBackedTexture(() -> "test", nativeImage);
158-
// Destroy old texture and register new
159-
MinecraftClient.getInstance().getTextureManager().destroyTexture(THUMBNAIL_TEXTURE_IDENTIFIER);
160-
MinecraftClient.getInstance().getTextureManager().registerTexture(THUMBNAIL_TEXTURE_IDENTIFIER, thumbnailTexture);
161-
162-
}
163-
});
151+
RecordingThumbnail screenshot = ThumbnailHelpers.create();
152+
if (screenshot != null) {
153+
recording.thumbnail = screenshot;
154+
thumbnailTexture = new NativeImageBackedTexture(screenshot.toNativeImage());
155+
// Destroy old texture and register new
156+
MinecraftClient.getInstance().getTextureManager().destroyTexture(THUMBNAIL_TEXTURE_IDENTIFIER);
157+
MinecraftClient.getInstance().getTextureManager().registerTexture(THUMBNAIL_TEXTURE_IDENTIFIER, thumbnailTexture);
158+
}
164159
}
165160

166161
if (Boolean.TRUE.equals(PlayerautomaOptionsScreen.resetKeyBindingsOnRecordingOption.getValue())) {
@@ -512,7 +507,7 @@ public static void loadRecord(File selected) {
512507
// Destroy old texture, register new one if present
513508
MinecraftClient.getInstance().getTextureManager().destroyTexture(THUMBNAIL_TEXTURE_IDENTIFIER);
514509
if (r.thumbnail != null) {
515-
thumbnailTexture = new NativeImageBackedTexture(selected::getName, r.thumbnail.toNativeImage());
510+
thumbnailTexture = new NativeImageBackedTexture(r.thumbnail.toNativeImage());
516511
MinecraftClient.getInstance().getTextureManager().registerTexture(THUMBNAIL_TEXTURE_IDENTIFIER, thumbnailTexture);
517512
}
518513

src/main/java/net/jasper/mod/automation/QuickSlots.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private static void store(int slot, Recording recording) {
5555
}
5656

5757
SLOTS[slot] = recording;
58-
NativeImageBackedTexture texture = recording.thumbnail != null ? new NativeImageBackedTexture(() -> SLOT_FILE_NAMES[slot], recording.thumbnail.toNativeImage()) : null;
58+
NativeImageBackedTexture texture = recording.thumbnail != null ? new NativeImageBackedTexture(recording.thumbnail.toNativeImage()) : null;
5959
updateQuickSlotTexture(slot, texture);
6060
// I assume that this doesn't fail, and therefore I don't check a return value i created to check this fails ...
6161
IOHelpers.storeRecordingFile(SLOTS[slot], new File(PLAYERAUTOMA_QUICKSLOT_PATH), SLOT_FILE_NAMES[slot], IOHelpers.RecordingFileTypes.REC, true);
@@ -165,7 +165,7 @@ public static void loadRecording(int slot) {
165165
// Destroy old texture, register new one if present
166166
MinecraftClient.getInstance().getTextureManager().destroyTexture(PlayerRecorder.THUMBNAIL_TEXTURE_IDENTIFIER);
167167
if (r.thumbnail != null) {
168-
PlayerRecorder.thumbnailTexture = new NativeImageBackedTexture(() -> SLOT_FILE_NAMES[slot], r.thumbnail.toNativeImage());
168+
PlayerRecorder.thumbnailTexture = new NativeImageBackedTexture(r.thumbnail.toNativeImage());
169169
MinecraftClient.getInstance().getTextureManager().registerTexture(PlayerRecorder.THUMBNAIL_TEXTURE_IDENTIFIER, PlayerRecorder.thumbnailTexture);
170170
}
171171

@@ -198,8 +198,7 @@ public static void register() {
198198
Recording r = IOHelpers.loadRecordingFile(new File(PLAYERAUTOMA_QUICKSLOT_PATH), new File(SLOT_FILE_NAMES[i]));
199199
SLOTS[i] = r;
200200
if (r.thumbnail != null) {
201-
int finalI = i;
202-
MinecraftClient.getInstance().getTextureManager().registerTexture(THUMBNAIL_IDENTIFIER[i], new NativeImageBackedTexture(() -> SLOT_FILE_NAMES[finalI], r.thumbnail.toNativeImage()));
201+
MinecraftClient.getInstance().getTextureManager().registerTexture(THUMBNAIL_IDENTIFIER[i], new NativeImageBackedTexture(r.thumbnail.toNativeImage()));
203202
}
204203
}
205204

src/main/java/net/jasper/mod/gui/RecordingSelectorScreen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static void loadThumbnails() {
6868
thumbnails.put(file.getName(), r.thumbnail);
6969
try {
7070
Identifier id = Identifier.of(PlayerautomaClient.MOD_ID, String.valueOf(file.getName().hashCode()));
71-
MinecraftClient.getInstance().getTextureManager().registerTexture(id, new NativeImageBackedTexture(file::getName, r.thumbnail.toNativeImage()));
71+
MinecraftClient.getInstance().getTextureManager().registerTexture(id, new NativeImageBackedTexture(r.thumbnail.toNativeImage()));
7272
} catch (InvalidIdentifierException e) {
7373
PlayerautomaClient.LOGGER.warn("Failed to load thumbnail for {}", file.getName());
7474
}
@@ -248,7 +248,7 @@ public RecordingEntry(String fileName, File file, RecordingThumbnail thumbnail)
248248
this.file = file;
249249
if (thumbnail != null) {
250250
try {
251-
this.texture = new NativeImageBackedTexture(file::getName, thumbnail.toNativeImage());
251+
this.texture = new NativeImageBackedTexture(thumbnail.toNativeImage());
252252
this.textureIdentifier = Identifier.of(PlayerautomaClient.MOD_ID, String.valueOf(fileName.hashCode()));
253253
MinecraftClient.getInstance().getTextureManager().registerTexture(textureIdentifier, texture);
254254
} catch (Exception exception) {

src/main/java/net/jasper/mod/gui/components/FilteredTextFieldWidget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private void renderErrorMessage(DrawContext context, RenderTickCounter tickCount
4040
return;
4141
}
4242

43-
float f = this.errorRemaining - tickCounter.getTickProgress(false);
43+
float f = this.errorRemaining - tickCounter.getTickDelta(false);
4444
int i = (int) (f * 255.0f / 20.0f);
4545
if (i > 255) {
4646
i = 255;

src/main/java/net/jasper/mod/util/PlayerautomaExceptionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void handleException(Exception exception) {
6262
File errorFile = Path.of(PlayerautomaClient.PLAYERAUTOMA_FOLDER_PATH, fileName).toFile();
6363
Text fileNameText = Text.literal(fileName)
6464
.formatted(Formatting.UNDERLINE)
65-
.styled(style -> style.withClickEvent(new ClickEvent.OpenFile(errorFile.getAbsolutePath())));
65+
.styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, errorFile.getAbsolutePath())));
6666

6767
Text message = Text.translatable("playerautoma.messages.error.unknownException", fileNameText);
6868

src/main/java/net/jasper/mod/util/ThumbnailHelpers.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import net.minecraft.client.util.ScreenshotRecorder;
1212
import net.minecraft.util.math.ColorHelper;
1313

14-
import java.util.function.BiConsumer;
15-
1614
@NoArgsConstructor(access = AccessLevel.PRIVATE)
1715
public class ThumbnailHelpers {
1816

@@ -95,30 +93,31 @@ private static void await(Long millis) {
9593
/**
9694
* Mostly copied from MinecraftClient.takePanorama
9795
*/
98-
public static void create(BiConsumer<RecordingThumbnail, NativeImage> thumbnailConsumer) {
96+
public static RecordingThumbnail create() {
9997
MinecraftClient client = MinecraftClient.getInstance();
10098
if (client.player == null) {
101-
return;
99+
return null;
102100
}
103101
Framebuffer framebuffer = client.getFramebuffer();
102+
NativeImage screenshot;
104103

105104
try {
106105
client.gameRenderer.setBlockOutlineEnabled(false);
107106
client.gameRenderer.setRenderingPanorama(true);
107+
framebuffer.beginWrite(true);
108108
client.gameRenderer.renderWorld(RenderTickCounter.ONE);
109109
await(10L);
110-
111-
ScreenshotRecorder.takeScreenshot(framebuffer, nativeImage -> {
112-
RecordingThumbnail thumbnail = RecordingThumbnail.createFromNativeImage(scaleDownImage(nativeImage, WIDTH, HEIGHT));
113-
thumbnailConsumer.accept(thumbnail, nativeImage);
114-
});
110+
screenshot = ScreenshotRecorder.takeScreenshot(framebuffer);
115111
} catch (Exception exception) {
116-
PlayerautomaExceptionHandler.handleException(exception);
117112
PlayerautomaClient.LOGGER.error("Couldn't save temporary screenshot image", exception);
113+
return null;
118114
} finally {
119115
client.gameRenderer.setBlockOutlineEnabled(true);
120116
client.gameRenderer.setRenderingPanorama(false);
117+
framebuffer.beginWrite(true);
121118
}
119+
120+
return RecordingThumbnail.createFromNativeImage(scaleDownImage(screenshot, WIDTH, HEIGHT));
122121
}
123122

124123
}

0 commit comments

Comments
 (0)