Update to Minecraft 1.20.5, switch to java 21, and a couple general code improvements
This commit is contained in:
parent
f0145d093d
commit
620f06930d
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.11-SNAPSHOT'
|
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,11 +20,11 @@ dependencies {
|
|||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
include modApi("me.shedaniel.cloth:cloth-config-fabric:13.0.121") {
|
include modApi("me.shedaniel.cloth:cloth-config-fabric:14.0.125") {
|
||||||
exclude(group: "net.fabricmc.fabric-api")
|
exclude(group: "net.fabricmc.fabric-api")
|
||||||
}
|
}
|
||||||
|
|
||||||
modCompileOnly("com.terraformersmc:modmenu:9.0.0")
|
modCompileOnly("com.terraformersmc:modmenu:10.0.0-beta.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
@ -36,7 +36,7 @@ processResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def targetJavaVersion = 8
|
def targetJavaVersion = 21
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||||
// this fixes some edge cases with special characters not displaying correctly
|
// this fixes some edge cases with special characters not displaying correctly
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
minecraft_version=1.20.4
|
minecraft_version=1.20.5
|
||||||
yarn_mappings=1.20.4+build.1
|
yarn_mappings=1.20.5+build.1
|
||||||
loader_version=0.15.0
|
loader_version=0.15.10
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.4.0
|
mod_version=1.5.0
|
||||||
maven_group=semmiedev
|
maven_group=semmiedev
|
||||||
archives_base_name=disc_jockey
|
archives_base_name=disc_jockey
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# check this on https://modmuss50.me/fabric.html
|
# check this on https://modmuss50.me/fabric.html
|
||||||
fabric_version=0.91.1+1.20.4
|
fabric_version=0.97.6+1.20.5
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -15,7 +15,7 @@ public class BinaryReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int readInt() throws IOException {
|
public int readInt() throws IOException {
|
||||||
return ((ByteBuffer)((ByteBuffer)buffer.clear()).put(readBytes(Integer.BYTES)).rewind()).getInt();
|
return buffer.clear().put(readBytes(Integer.BYTES)).rewind().getInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long readUInt() throws IOException {
|
public long readUInt() throws IOException {
|
||||||
@ -27,7 +27,7 @@ public class BinaryReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public short readShort() throws IOException {
|
public short readShort() throws IOException {
|
||||||
return ((ByteBuffer)((ByteBuffer)buffer.clear()).put(readBytes(Short.BYTES)).rewind()).getShort();
|
return buffer.clear().put(readBytes(Short.BYTES)).rewind().getShort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readString() throws IOException {
|
public String readString() throws IOException {
|
||||||
@ -35,7 +35,7 @@ public class BinaryReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float readFloat() throws IOException {
|
public float readFloat() throws IOException {
|
||||||
return ((ByteBuffer)((ByteBuffer)buffer.clear()).put(readBytes(Float.BYTES)).rewind()).getFloat();
|
return buffer.clear().put(readBytes(Float.BYTES)).rewind().getFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private int getStringLength() throws IOException {
|
/*private int getStringLength() throws IOException {
|
||||||
|
@ -6,7 +6,7 @@ import net.minecraft.block.enums.Instrument;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Note {
|
public record Note(Instrument instrument, byte note) {
|
||||||
public static final HashMap<Instrument, Block> INSTRUMENT_BLOCKS = new HashMap<>();
|
public static final HashMap<Instrument, Block> INSTRUMENT_BLOCKS = new HashMap<>();
|
||||||
|
|
||||||
public static final byte LAYER_SHIFT = Short.SIZE;
|
public static final byte LAYER_SHIFT = Short.SIZE;
|
||||||
@ -50,21 +50,4 @@ public class Note {
|
|||||||
INSTRUMENT_BLOCKS.put(Instrument.BANJO, Blocks.HAY_BLOCK);
|
INSTRUMENT_BLOCKS.put(Instrument.BANJO, Blocks.HAY_BLOCK);
|
||||||
INSTRUMENT_BLOCKS.put(Instrument.PLING, Blocks.GLOWSTONE);
|
INSTRUMENT_BLOCKS.put(Instrument.PLING, Blocks.GLOWSTONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Instrument instrument;
|
|
||||||
public final byte note;
|
|
||||||
|
|
||||||
public Note(Instrument instrument, byte note) {
|
|
||||||
this.instrument = instrument;
|
|
||||||
this.note = note;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj instanceof Note) {
|
|
||||||
Note note = (Note)obj;
|
|
||||||
return note.note == this.note && note.instrument == instrument;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class SongLoader {
|
|||||||
try {
|
try {
|
||||||
song = loadSong(file);
|
song = loadSong(file);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
Main.LOGGER.error("Unable to read or parse song " + file.getName(), exception);
|
Main.LOGGER.error("Unable to read or parse song {}", file.getName(), exception);
|
||||||
}
|
}
|
||||||
if (song != null) SONGS.add(song);
|
if (song != null) SONGS.add(song);
|
||||||
}
|
}
|
||||||
|
@ -297,17 +297,17 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
|||||||
// Find fitting noteblocks with the least amount of adjustments required (to reduce tuning time)
|
// Find fitting noteblocks with the least amount of adjustments required (to reduce tuning time)
|
||||||
ArrayList<Note> capturedNotes = new ArrayList<>();
|
ArrayList<Note> capturedNotes = new ArrayList<>();
|
||||||
for(Note note : song.uniqueNotes) {
|
for(Note note : song.uniqueNotes) {
|
||||||
ArrayList<BlockPos> availableBlocks = noteblocksForInstrument.get(note.instrument);
|
ArrayList<BlockPos> availableBlocks = noteblocksForInstrument.get(note.instrument());
|
||||||
if(availableBlocks == null) {
|
if(availableBlocks == null) {
|
||||||
// Note was mapped to "nothing". Pretend it got captured, but just ignore it
|
// Note was mapped to "nothing". Pretend it got captured, but just ignore it
|
||||||
capturedNotes.add(note);
|
capturedNotes.add(note);
|
||||||
getNotes(note.instrument).put(note.note, null);
|
getNotes(note.instrument()).put(note.note(), null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BlockPos bestBlockPos = null;
|
BlockPos bestBlockPos = null;
|
||||||
int bestBlockTuningSteps = Integer.MAX_VALUE;
|
int bestBlockTuningSteps = Integer.MAX_VALUE;
|
||||||
for(BlockPos blockPos : availableBlocks) {
|
for(BlockPos blockPos : availableBlocks) {
|
||||||
int wantedNote = note.note;
|
int wantedNote = note.note();
|
||||||
int currentNote = client.world.getBlockState(blockPos).get(Properties.NOTE);
|
int currentNote = client.world.getBlockState(blockPos).get(Properties.NOTE);
|
||||||
int tuningSteps = wantedNote >= currentNote ? wantedNote - currentNote : (25 - currentNote) + wantedNote;
|
int tuningSteps = wantedNote >= currentNote ? wantedNote - currentNote : (25 - currentNote) + wantedNote;
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
|||||||
if(bestBlockPos != null) {
|
if(bestBlockPos != null) {
|
||||||
capturedNotes.add(note);
|
capturedNotes.add(note);
|
||||||
availableBlocks.remove(bestBlockPos);
|
availableBlocks.remove(bestBlockPos);
|
||||||
getNotes(note.instrument).put(note.note, bestBlockPos);
|
getNotes(note.instrument()).put(note.note(), bestBlockPos);
|
||||||
} // else will be a missing note
|
} // else will be a missing note
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
|||||||
|
|
||||||
HashMap<Block, Integer> missing = new HashMap<>();
|
HashMap<Block, Integer> missing = new HashMap<>();
|
||||||
for (Note note : missingNotes) {
|
for (Note note : missingNotes) {
|
||||||
Instrument mappedInstrument = instrumentMap.getOrDefault(note.instrument, note.instrument);
|
Instrument mappedInstrument = instrumentMap.getOrDefault(note.instrument(), note.instrument());
|
||||||
if(mappedInstrument == null) continue; // Ignore if mapped to nothing
|
if(mappedInstrument == null) continue; // Ignore if mapped to nothing
|
||||||
Block block = Note.INSTRUMENT_BLOCKS.get(mappedInstrument);
|
Block block = Note.INSTRUMENT_BLOCKS.get(mappedInstrument);
|
||||||
Integer got = missing.get(block);
|
Integer got = missing.get(block);
|
||||||
@ -356,7 +356,7 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
|||||||
|
|
||||||
if(lastInteractAt != -1L) {
|
if(lastInteractAt != -1L) {
|
||||||
// Paper allows 8 interacts per 300 ms (actually 9 it turns out, but lets keep it a bit lower anyway)
|
// Paper allows 8 interacts per 300 ms (actually 9 it turns out, but lets keep it a bit lower anyway)
|
||||||
availableInteracts += ((System.currentTimeMillis() - lastInteractAt) / (310.0 / 8.0));
|
availableInteracts += ((System.currentTimeMillis() - lastInteractAt) / (310.0f / 8.0f));
|
||||||
availableInteracts = Math.min(8f, Math.max(0f, availableInteracts));
|
availableInteracts = Math.min(8f, Math.max(0f, availableInteracts));
|
||||||
}else {
|
}else {
|
||||||
availableInteracts = 8f;
|
availableInteracts = 8f;
|
||||||
@ -366,17 +366,17 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
|||||||
int fullyTunedBlocks = 0;
|
int fullyTunedBlocks = 0;
|
||||||
HashMap<BlockPos, Integer> untunedNotes = new HashMap<>();
|
HashMap<BlockPos, Integer> untunedNotes = new HashMap<>();
|
||||||
for (Note note : song.uniqueNotes) {
|
for (Note note : song.uniqueNotes) {
|
||||||
if(noteBlocks == null || noteBlocks.get(note.instrument) == null)
|
if(noteBlocks == null || noteBlocks.get(note.instrument()) == null)
|
||||||
continue;
|
continue;
|
||||||
BlockPos blockPos = noteBlocks.get(note.instrument).get(note.note);
|
BlockPos blockPos = noteBlocks.get(note.instrument()).get(note.note());
|
||||||
if(blockPos == null) continue;
|
if(blockPos == null) continue;
|
||||||
BlockState blockState = world.getBlockState(blockPos);
|
BlockState blockState = world.getBlockState(blockPos);
|
||||||
int assumedNote = notePredictions.containsKey(blockPos) ? notePredictions.get(blockPos).getLeft() : blockState.get(Properties.NOTE);
|
int assumedNote = notePredictions.containsKey(blockPos) ? notePredictions.get(blockPos).getLeft() : blockState.get(Properties.NOTE);
|
||||||
|
|
||||||
if (blockState.contains(Properties.NOTE)) {
|
if (blockState.contains(Properties.NOTE)) {
|
||||||
if(assumedNote == note.note && blockState.get(Properties.NOTE) == note.note)
|
if(assumedNote == note.note() && blockState.get(Properties.NOTE) == note.note())
|
||||||
fullyTunedBlocks++;
|
fullyTunedBlocks++;
|
||||||
if (assumedNote != note.note) {
|
if (assumedNote != note.note()) {
|
||||||
if (!canInteractWith(client.player, blockPos)) {
|
if (!canInteractWith(client.player, blockPos)) {
|
||||||
stop();
|
stop();
|
||||||
client.inGameHud.getChatHud().addMessage(Text.translatable(Main.MOD_ID+".player.to_far").formatted(Formatting.RED));
|
client.inGameHud.getChatHud().addMessage(Text.translatable(Main.MOD_ID+".player.to_far").formatted(Formatting.RED));
|
||||||
@ -395,7 +395,7 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
|||||||
|
|
||||||
int existingUniqueNotesCount = 0;
|
int existingUniqueNotesCount = 0;
|
||||||
for(Note n : song.uniqueNotes) {
|
for(Note n : song.uniqueNotes) {
|
||||||
if(noteBlocks.get(n.instrument).get(n.note) != null)
|
if(noteBlocks.get(n.instrument()).get(n.note()) != null)
|
||||||
existingUniqueNotesCount++;
|
existingUniqueNotesCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ public class SongPlayer implements ClientTickEvents.StartWorldTick {
|
|||||||
lastTunedNote = untunedNotes.get(blockPos);
|
lastTunedNote = untunedNotes.get(blockPos);
|
||||||
untunedNotes.remove(blockPos);
|
untunedNotes.remove(blockPos);
|
||||||
int assumedNote = notePredictions.containsKey(blockPos) ? notePredictions.get(blockPos).getLeft() : client.world.getBlockState(blockPos).get(Properties.NOTE);
|
int assumedNote = notePredictions.containsKey(blockPos) ? notePredictions.get(blockPos).getLeft() : client.world.getBlockState(blockPos).get(Properties.NOTE);
|
||||||
notePredictions.put(blockPos, new Pair((assumedNote + 1) % 25, System.currentTimeMillis() + ping * 2 + 100));
|
notePredictions.put(blockPos, new Pair<>((assumedNote + 1) % 25, System.currentTimeMillis() + ping * 2 + 100));
|
||||||
client.interactionManager.interactBlock(client.player, Hand.MAIN_HAND, new BlockHitResult(Vec3d.of(blockPos), Direction.UP, blockPos, false));
|
client.interactionManager.interactBlock(client.player, Hand.MAIN_HAND, new BlockHitResult(Vec3d.of(blockPos), Direction.UP, blockPos, false));
|
||||||
lastInteractAt = System.currentTimeMillis();
|
lastInteractAt = System.currentTimeMillis();
|
||||||
availableInteracts -= 1f;
|
availableInteracts -= 1f;
|
||||||
|
@ -22,7 +22,7 @@ public class SongListWidget extends EntryListWidget<SongListWidget.SongEntry> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getScrollbarPositionX() {
|
protected int getScrollbarX() {
|
||||||
return width - 12;
|
return width - 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public class DiscJockeyScreen extends Screen {
|
|||||||
BlocksOverlay.amountOfNoteBlocks = entry.song.uniqueNotes.size();
|
BlocksOverlay.amountOfNoteBlocks = entry.song.uniqueNotes.size();
|
||||||
|
|
||||||
for (Note note : entry.song.uniqueNotes) {
|
for (Note note : entry.song.uniqueNotes) {
|
||||||
ItemStack itemStack = Note.INSTRUMENT_BLOCKS.get(note.instrument).asItem().getDefaultStack();
|
ItemStack itemStack = Note.INSTRUMENT_BLOCKS.get(note.instrument()).asItem().getDefaultStack();
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
for (int i = 0; i < BlocksOverlay.itemStacks.length; i++) {
|
for (int i = 0; i < BlocksOverlay.itemStacks.length; i++) {
|
||||||
@ -136,11 +136,6 @@ public class DiscJockeyScreen extends Screen {
|
|||||||
context.drawCenteredTextWithShadow(textRenderer, SELECT_SONG, width / 2, 20, 0xFFFFFF);
|
context.drawCenteredTextWithShadow(textRenderer, SELECT_SONG, width / 2, 20, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) {
|
|
||||||
renderBackgroundTexture(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
previewButton.setMessage(Main.PREVIEWER.running ? PREVIEW_STOP : PREVIEW);
|
previewButton.setMessage(Main.PREVIEWER.running ? PREVIEW_STOP : PREVIEW);
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "1.20.*",
|
"minecraft": "1.20.5",
|
||||||
"cloth-config": "*"
|
"cloth-config": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user