Compare commits

..

No commits in common. "master" and "1.21.2" have entirely different histories.

9 changed files with 38 additions and 48 deletions

View File

@ -4,17 +4,17 @@ org.gradle.parallel=true
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/develop # check these on https://fabricmc.net/develop
minecraft_version=1.21.6 minecraft_version=1.21.2
yarn_mappings=1.21.6+build.1 yarn_mappings=1.21.2+build.1
loader_version=0.16.14 loader_version=0.16.14
loom_version=1.10-SNAPSHOT loom_version=1.10-SNAPSHOT
# Fabric API # Fabric API
fabric_version=0.127.0+1.21.6 fabric_version=0.106.1+1.21.2
# Mod Properties # Mod Properties
mod_version = 1.1.2+1.21.6 mod_version = 1.1.2+1.21.2
maven_group = ru.themixray maven_group = ru.themixray
archives_base_name = repeating-mod archives_base_name = repeating-mod
# Compatible with: 1.21.6 # Compatible with: 1.21.2, ?

View File

@ -51,7 +51,7 @@ public class RepeatingScreen extends Screen {
@Override @Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) { public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// renderBackground(context, mouseX, mouseY, delta); renderBackground(context, mouseX, mouseY, delta);
for (RenderListener l : render_listeners) { for (RenderListener l : render_listeners) {
if (l.beforeRender()) { if (l.beforeRender()) {

View File

@ -19,7 +19,7 @@ public class BlockInteractEvent extends RecordEvent {
Double.parseDouble(a[0]), Double.parseDouble(a[0]),
Double.parseDouble(a[1]), Double.parseDouble(a[1]),
Double.parseDouble(a[2])), Double.parseDouble(a[2])),
Direction.byIndex(Integer.parseInt(a[4])), Direction.byId(Integer.parseInt(a[4])),
new BlockPos( new BlockPos(
Integer.parseInt(a[0]), Integer.parseInt(a[0]),
Integer.parseInt(a[1]), Integer.parseInt(a[1]),
@ -44,7 +44,7 @@ public class BlockInteractEvent extends RecordEvent {
String.valueOf(hitResult.getBlockPos().getY()), String.valueOf(hitResult.getBlockPos().getY()),
String.valueOf(hitResult.getBlockPos().getZ()), String.valueOf(hitResult.getBlockPos().getZ()),
(hitResult.isInsideBlock() ? "1" : "0"), (hitResult.isInsideBlock() ? "1" : "0"),
String.valueOf(hitResult.getSide().getIndex()), String.valueOf(hitResult.getSide().getId()),
hand.name() hand.name()
}; };
} }

View File

@ -1,13 +1,9 @@
package ru.themixray.repeating_mod.event.events; package ru.themixray.repeating_mod.event.events;
import net.minecraft.client.input.Input;
import net.minecraft.util.PlayerInput; import net.minecraft.util.PlayerInput;
import net.minecraft.util.math.Vec2f;
import ru.themixray.repeating_mod.Main; import ru.themixray.repeating_mod.Main;
import ru.themixray.repeating_mod.event.RecordEvent; import ru.themixray.repeating_mod.event.RecordEvent;
import java.lang.reflect.Field;
public class InputEvent extends RecordEvent { public class InputEvent extends RecordEvent {
public Boolean forward; public Boolean forward;
public Boolean backward; public Boolean backward;
@ -40,8 +36,8 @@ public class InputEvent extends RecordEvent {
Main.client.player.getPitch(), Main.client.player.getPitch(),
Main.client.player.getYaw(), Main.client.player.getYaw(),
Main.client.player.getMovementSpeed(), Main.client.player.getMovementSpeed(),
Main.client.player.input.getMovementInput().y, Main.client.player.input.movementForward,
Main.client.player.input.getMovementInput().x Main.client.player.input.movementSideways
); );
} }
@ -172,13 +168,8 @@ public class InputEvent extends RecordEvent {
if (Main.client.player.getMovementSpeed() != speed) if (Main.client.player.getMovementSpeed() != speed)
Main.client.player.setMovementSpeed(speed); Main.client.player.setMovementSpeed(speed);
try { Main.client.player.input.movementSideways = movementSideways;
Field field = Input.class.getDeclaredField("movementVector"); Main.client.player.input.movementForward = movementForward;
field.setAccessible(true);
field.set(Main.client.player.input, new Vec2f(movementSideways, movementForward));
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
PlayerInput input = Main.client.player.input.playerInput; PlayerInput input = Main.client.player.input.playerInput;
Main.client.player.input.playerInput = new PlayerInput( Main.client.player.input.playerInput = new PlayerInput(

View File

@ -10,7 +10,7 @@ import ru.themixray.repeating_mod.Main;
@Mixin(KeyboardInput.class) @Mixin(KeyboardInput.class)
public abstract class InputMixin { public abstract class InputMixin {
@Inject(at = @At(value = "TAIL"), method = "tick") @Inject(at = @At(value = "TAIL"), method = "tick")
private void onTickTail(CallbackInfo ci) { private void onTickTail(boolean slowDown, float f, CallbackInfo ci) {
if (Main.me.is_replaying) { if (Main.me.is_replaying) {
if (Main.input_replay != null) { if (Main.input_replay != null) {
Main.input_replay.inputCallback(); Main.input_replay.inputCallback();

View File

@ -1,6 +1,6 @@
package ru.themixray.repeating_mod.render.shader; package ru.themixray.repeating_mod.render.shader;
import com.mojang.blaze3d.opengl.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.TextureUtil; import com.mojang.blaze3d.platform.TextureUtil;
import lombok.Getter; import lombok.Getter;
import lombok.SneakyThrows; import lombok.SneakyThrows;

View File

@ -26,40 +26,27 @@ public class RecordListWidget extends ScrollableWidget {
return res; return res;
} }
@Override
protected int getContentsHeightWithPadding() {
return !widgets.isEmpty() ? widgets.size() * 55 + (widgets.size() - 1) * 2 : 0;
}
@Override @Override
protected double getDeltaYPerScroll() { protected double getDeltaYPerScroll() {
return 10; return 10;
} }
@Override @Override
protected void renderWidget(DrawContext ctx, int mouseX, int mouseY, float delta) { protected void renderContents(DrawContext ctx, int mouseX, int mouseY, float delta) {
ctx.fill(this.getX(), this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), 0xff000000); int y = 0;
ctx.enableScissor(this.getX(), this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight());
int y = (int) -this.getScrollY();
for (RecordWidget wid: widgets) { for (RecordWidget wid: widgets) {
wid.setY(y); wid.setY(y);
wid.render(ctx, mouseX, (int) (mouseY), delta); wid.render(ctx, mouseX, (int) (mouseY + this.getScrollY()), delta);
y += wid.getHeight(); y += wid.getHeight();
y += 2; y += 2;
} }
ctx.disableScissor();
this.drawScrollbar(ctx);
} }
public void addWidget(RecordState record) { public void addWidget(RecordState record) {
RecordWidget widget = new RecordWidget(0, 0, width - 6, 55, record, this); RecordWidget widget = new RecordWidget(0, 0, width, 55, record, this);
widget.init(null); widget.init(null);
widgets.addFirst(widget); widgets.add(0, widget);
} }
public void removeWidget(RecordState record) { public void removeWidget(RecordState record) {
@ -76,6 +63,11 @@ public class RecordListWidget extends ScrollableWidget {
return focused; return focused;
} }
@Override
protected int getContentsHeight() {
return !widgets.isEmpty() ? widgets.size() * 55 + (widgets.size() - 1) * 2 : 0;
}
public void init(RepeatingScreen screen) { public void init(RepeatingScreen screen) {
for (RecordWidget widget : widgets) { for (RecordWidget widget : widgets) {
widget.init(screen); widget.init(screen);
@ -133,7 +125,7 @@ public class RecordListWidget extends ScrollableWidget {
@Override @Override
public boolean mouseClicked(double mouseX, double mouseY, int button) { public boolean mouseClicked(double mouseX, double mouseY, int button) {
return checkTransportNF(mouseX, mouseY, button) || super.checkScrollbarDragged(mouseX, mouseY, button); return checkTransportNF(mouseX, mouseY + getScrollY(), button) || super.mouseClicked(mouseX, mouseY, button);
} }
@Override @Override

View File

@ -1,6 +1,5 @@
package ru.themixray.repeating_mod.widget; package ru.themixray.repeating_mod.widget;
import lombok.Getter;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable; import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.tooltip.Tooltip;
@ -19,7 +18,6 @@ import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
public class RecordWidget implements Drawable, Widget { public class RecordWidget implements Drawable, Widget {
@Getter
private RecordState record; private RecordState record;
private List<ClickableWidget> children; private List<ClickableWidget> children;
@ -152,13 +150,22 @@ public class RecordWidget implements Drawable, Widget {
children.add(replay_button); children.add(replay_button);
} }
public void drawText(int x, int y, DrawContext ctx, List<Text> lines, int line_height, boolean shadow) { public RecordState getRecord() {
return record;
}
public void drawText(int x, int y, DrawContext ctx, List<Text> lines, float size, int line_height, boolean shadow) {
ctx.getMatrices().push();
ctx.getMatrices().scale(size, size, size);
int now_y = y; int now_y = y;
for (Text line : lines) { for (Text line : lines) {
ctx.drawText(Main.client.textRenderer, line, x, now_y, 0xff000000 + line.getStyle().getColor().getRgb(), shadow); ctx.drawText(Main.client.textRenderer, line, (int) (x / size), (int) (now_y / size), line.getStyle().getColor().getRgb(), shadow);
now_y += line_height; now_y += line_height;
} }
ctx.getMatrices().pop();
} }
@Override @Override
@ -183,7 +190,7 @@ public class RecordWidget implements Drawable, Widget {
.append(": ") .append(": ")
.styled((s) -> s.withColor(0xbbbbbb)), .styled((s) -> s.withColor(0xbbbbbb)),
Text.literal(record.getAuthor()).styled((s) -> s.withColor(0xffffff)) Text.literal(record.getAuthor()).styled((s) -> s.withColor(0xffffff))
), ), 1,
9, 9,
false); false);

View File

@ -29,7 +29,7 @@
"depends": { "depends": {
"fabricloader": ">=0.14.14", "fabricloader": ">=0.14.14",
"fabric-api": "*", "fabric-api": "*",
"minecraft": ">=1.21.4", "minecraft": ">=1.21.2",
"java": ">=17" "java": ">=17"
}, },
"suggests": { "suggests": {