mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2026-03-31 05:32:03 +00:00
Merge pull request 'feat: update to 26.1' (#22) from amy/chipmunkmod:26.1 into 1.21.11
Reviewed-on: https://code.chipmunk.land/ChomeNS/chipmunkmod/pulls/22
This commit is contained in:
commit
ebe6dcb708
7 changed files with 67 additions and 44 deletions
18
build.gradle
18
build.gradle
|
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'net.fabricmc.fabric-loom-remap' version "${loom_version}"
|
id 'net.fabricmc.fabric-loom' version "${loom_version}"
|
||||||
}
|
}
|
||||||
|
|
||||||
base.archivesName = project.archives_base_name
|
base.archivesName = project.archives_base_name
|
||||||
|
|
@ -11,7 +11,7 @@ repositories {
|
||||||
|
|
||||||
// adventure snapshots
|
// adventure snapshots
|
||||||
maven {
|
maven {
|
||||||
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
|
url = "https://central.sonatype.com/repository/maven-snapshots/"
|
||||||
mavenContent { snapshotsOnly() }
|
mavenContent { snapshotsOnly() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -19,11 +19,10 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
// To change the versions see the gradle.properties file
|
// To change the versions see the gradle.properties file
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings loom.officialMojangMappings()
|
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
|
||||||
|
|
||||||
// Fabric API
|
// Fabric API
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
// LuaJ
|
// LuaJ
|
||||||
include(implementation("org.luaj:luaj-jse:3.0.1"))
|
include(implementation("org.luaj:luaj-jse:3.0.1"))
|
||||||
|
|
@ -34,7 +33,7 @@ dependencies {
|
||||||
include(implementation("io.leangen.geantyref:geantyref:2.0.1"))
|
include(implementation("io.leangen.geantyref:geantyref:2.0.1"))
|
||||||
|
|
||||||
// Adventure
|
// Adventure
|
||||||
include(modImplementation("net.kyori:adventure-platform-fabric:6.8.0"))
|
include(implementation("net.kyori:adventure-platform-fabric:6.9.0-SNAPSHOT"))
|
||||||
include(implementation("net.kyori:adventure-text-serializer-gson:4.26.1"))
|
include(implementation("net.kyori:adventure-text-serializer-gson:4.26.1"))
|
||||||
include(implementation("net.kyori:adventure-text-serializer-legacy:4.26.1"))
|
include(implementation("net.kyori:adventure-text-serializer-legacy:4.26.1"))
|
||||||
}
|
}
|
||||||
|
|
@ -48,11 +47,10 @@ processResources {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
it.options.release = 25
|
||||||
it.options.release = 21
|
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_21
|
sourceCompatibility = JavaVersion.VERSION_25
|
||||||
targetCompatibility = JavaVersion.VERSION_21
|
targetCompatibility = JavaVersion.VERSION_25
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ 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.11
|
minecraft_version=26.1
|
||||||
loader_version=0.18.4
|
loader_version=0.18.5
|
||||||
loom_version=1.15-SNAPSHOT
|
loom_version=1.15-SNAPSHOT
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
|
|
@ -14,5 +14,5 @@ org.gradle.parallel=true
|
||||||
archives_base_name = chipmunkmod
|
archives_base_name = chipmunkmod
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.141.3+1.21.11
|
fabric_version=0.144.3+26.1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class ItemCommand {
|
||||||
|
|
||||||
if (player == null || connection == null) return Command.SINGLE_SUCCESS;
|
if (player == null || connection == null) return Command.SINGLE_SUCCESS;
|
||||||
|
|
||||||
final ItemStack stack = getItem(context, "item").createItemStack(count, false);
|
final ItemStack stack = getItem(context, "item").createItemStack(count);
|
||||||
|
|
||||||
final int slot = 36 + player.getInventory().getSelectedSlot();
|
final int slot = 36 + player.getInventory().getSelectedSlot();
|
||||||
connection.send(new ServerboundSetCreativeModeSlotPacket(slot, stack));
|
connection.send(new ServerboundSetCreativeModeSlotPacket(slot, stack));
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ public class CommandCore implements Listener {
|
||||||
final ClientPacketListener connection = client.getConnection();
|
final ClientPacketListener connection = client.getConnection();
|
||||||
if (player == null || connection == null) return;
|
if (player == null || connection == null) return;
|
||||||
|
|
||||||
final int distanceSquared = player.chunkPosition().distanceSquared(new ChunkPos(origin));
|
final int distanceSquared = player.chunkPosition().distanceSquared(ChunkPos.containing(origin));
|
||||||
final int distance = (int) Math.sqrt(Math.abs(distanceSquared));
|
final int distance = (int) Math.sqrt(Math.abs(distanceSquared));
|
||||||
|
|
||||||
final int simulationDistance = connection.getLevel().getServerSimulationDistance();
|
final int simulationDistance = connection.getLevel().getServerSimulationDistance();
|
||||||
|
|
|
||||||
|
|
@ -17,30 +17,33 @@ public class Instrument {
|
||||||
public static final Instrument BIT = new Instrument(13, "bit", 54);
|
public static final Instrument BIT = new Instrument(13, "bit", 54);
|
||||||
public static final Instrument BANJO = new Instrument(14, "banjo", 54);
|
public static final Instrument BANJO = new Instrument(14, "banjo", 54);
|
||||||
public static final Instrument PLING = new Instrument(15, "pling", 54);
|
public static final Instrument PLING = new Instrument(15, "pling", 54);
|
||||||
private static final Instrument[] VALUES = { HARP, BASEDRUM, SNARE, HAT, BASS, FLUTE, BELL, GUITAR, CHIME, XYLOPHONE, IRON_XYLOPHONE, COW_BELL, DIDGERIDOO, BIT, BANJO, PLING };
|
public static final Instrument TRUMPET = new Instrument(15, "trumpet", 54);
|
||||||
|
public static final Instrument TRUMPET_EXPOSED = new Instrument(16, "trumpet_exposed", 54);
|
||||||
|
public static final Instrument TRUMPET_WEATHERED = new Instrument(17, "trumpet_weathered", 54);
|
||||||
|
public static final Instrument TRUMPET_OXIDIZED = new Instrument(18, "trumpet_oxidized", 54);
|
||||||
|
private static final Instrument[] VALUES = {
|
||||||
|
HARP, BASEDRUM, SNARE, HAT, BASS, FLUTE, BELL, GUITAR, CHIME, XYLOPHONE, IRON_XYLOPHONE, COW_BELL, DIDGERIDOO,
|
||||||
|
BIT, BANJO, PLING, TRUMPET, TRUMPET_EXPOSED, TRUMPET_WEATHERED, TRUMPET_OXIDIZED
|
||||||
|
};
|
||||||
public final int id;
|
public final int id;
|
||||||
public final String name;
|
public final String name;
|
||||||
public final int offset;
|
public final int offset;
|
||||||
public final String sound;
|
public final String sound;
|
||||||
|
|
||||||
private Instrument (final int id, final String name, final int offset, final String sound) {
|
protected Instrument (final int id, final String name, final int offset, final String sound) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Instrument (final int id, final String name, final int offset) {
|
protected Instrument (final int id, final String name, final int offset) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
this.sound = "block.note_block." + name;
|
this.sound = "block.note_block." + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Instrument of (final String sound) {
|
|
||||||
return new Instrument(-1, null, 0, sound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Instrument fromId (final int id) {
|
public static Instrument fromId (final int id) {
|
||||||
return VALUES[id];
|
return VALUES[id];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
public class NBSConverter {
|
public class NBSConverter {
|
||||||
|
|
@ -24,6 +27,10 @@ public class NBSConverter {
|
||||||
Instrument.BIT,
|
Instrument.BIT,
|
||||||
Instrument.BANJO,
|
Instrument.BANJO,
|
||||||
Instrument.PLING,
|
Instrument.PLING,
|
||||||
|
Instrument.TRUMPET,
|
||||||
|
Instrument.TRUMPET_EXPOSED,
|
||||||
|
Instrument.TRUMPET_WEATHERED,
|
||||||
|
Instrument.TRUMPET_OXIDIZED,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Song getSongFromBytes (final byte[] bytes, final String fileName) throws IOException {
|
public static Song getSongFromBytes (final byte[] bytes, final String fileName) throws IOException {
|
||||||
|
|
@ -32,7 +39,7 @@ public class NBSConverter {
|
||||||
|
|
||||||
short songLength = 0;
|
short songLength = 0;
|
||||||
byte format = 0;
|
byte format = 0;
|
||||||
byte vanillaInstrumentCount = 0;
|
byte vanillaInstrumentCount = 10; // Before v1, we had 10 vanilla instruments
|
||||||
songLength = buffer.getShort(); // If it's not 0, then it uses the old format
|
songLength = buffer.getShort(); // If it's not 0, then it uses the old format
|
||||||
if (songLength == 0) {
|
if (songLength == 0) {
|
||||||
format = buffer.get();
|
format = buffer.get();
|
||||||
|
|
@ -71,9 +78,9 @@ public class NBSConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayList<NBSNote> nbsNotes = new ArrayList<>();
|
final ArrayList<NBSNote> nbsNotes = new ArrayList<>();
|
||||||
short tick = -1;
|
int tick = -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
final int tickJumps = buffer.getShort();
|
final int tickJumps = Short.toUnsignedInt(buffer.getShort());
|
||||||
if (tickJumps == 0) break;
|
if (tickJumps == 0) break;
|
||||||
tick += tickJumps;
|
tick += tickJumps;
|
||||||
|
|
||||||
|
|
@ -116,12 +123,12 @@ public class NBSConverter {
|
||||||
if (buffer.hasRemaining()) {
|
if (buffer.hasRemaining()) {
|
||||||
final byte customInstrumentCount = buffer.get();
|
final byte customInstrumentCount = buffer.get();
|
||||||
for (int i = 0; i < customInstrumentCount; i++) {
|
for (int i = 0; i < customInstrumentCount; i++) {
|
||||||
final NBSCustomInstrument customInstrument = new NBSCustomInstrument();
|
final String name = getString(buffer, bytes.length);
|
||||||
customInstrument.name = getString(buffer, bytes.length);
|
final String file = getString(buffer, bytes.length);
|
||||||
customInstrument.file = getString(buffer, bytes.length);
|
final byte pitch = buffer.get();
|
||||||
customInstrument.pitch = buffer.get();
|
final boolean visible = buffer.get() != 0; // "Press piano key"
|
||||||
customInstrument.key = buffer.get() != 0;
|
|
||||||
customInstruments.add(customInstrument);
|
customInstruments.add(new NBSCustomInstrument(name, file, pitch, visible));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,18 +141,17 @@ public class NBSConverter {
|
||||||
for (final NBSNote note : nbsNotes) {
|
for (final NBSNote note : nbsNotes) {
|
||||||
final Instrument instrument;
|
final Instrument instrument;
|
||||||
double key;
|
double key;
|
||||||
if (note.instrument < instrumentIndex.length) {
|
if (note.instrument < vanillaInstrumentCount) {
|
||||||
|
if (note.instrument >= instrumentIndex.length) continue;
|
||||||
instrument = instrumentIndex[note.instrument];
|
instrument = instrumentIndex[note.instrument];
|
||||||
|
|
||||||
key = (double) ((note.key * 100) + note.pitch) / 100;
|
key = (double) ((note.key * 100) + note.pitch) / 100;
|
||||||
} else {
|
} else {
|
||||||
final int index = note.instrument - instrumentIndex.length;
|
final int index = note.instrument - vanillaInstrumentCount;
|
||||||
|
|
||||||
if (index >= customInstruments.size()) continue;
|
if (index >= customInstruments.size()) continue;
|
||||||
|
|
||||||
final NBSCustomInstrument customInstrument = customInstruments.get(index);
|
final NBSCustomInstrument customInstrument = customInstruments.get(index);
|
||||||
instrument = Instrument.of(customInstrument.name);
|
|
||||||
|
|
||||||
|
instrument = customInstrument;
|
||||||
key = (note.key) + (customInstrument.pitch + (double) note.pitch / 100);
|
key = (note.key) + (customInstrument.pitch + (double) note.pitch / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -215,10 +221,26 @@ public class NBSConverter {
|
||||||
public byte stereo = 100;
|
public byte stereo = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NBSCustomInstrument {
|
private static class NBSCustomInstrument extends Instrument {
|
||||||
public String name;
|
public final byte pitch;
|
||||||
public String file;
|
public final boolean visible;
|
||||||
public byte pitch = 0;
|
|
||||||
public boolean key = false;
|
public NBSCustomInstrument(final String name, final String optionalPath, final byte pitch, final boolean visible) {
|
||||||
|
// some implementations straight up just don't save the path, so we perform conversions on name on those
|
||||||
|
final String path = optionalPath.isBlank() ? name : optionalPath;
|
||||||
|
String sound = Util.sanitizeName(path, Identifier::isAllowedInIdentifier)
|
||||||
|
.replaceFirst("\\.ogg$", "")
|
||||||
|
.replaceFirst("^minecraft/", "")
|
||||||
|
.replaceFirst("\\d+$", "")
|
||||||
|
.replace('/', '.');
|
||||||
|
|
||||||
|
// if there's no path, it's probably a note block sound
|
||||||
|
// this happens when you have trumpets saved in a v5 format NBS for example
|
||||||
|
if (!sound.contains(".")) sound = "block.note_block." + sound;
|
||||||
|
|
||||||
|
super(-1, name, 0, sound);
|
||||||
|
this.pitch = pitch;
|
||||||
|
this.visible = visible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.18.3",
|
"fabricloader": ">=0.18.5",
|
||||||
"fabric-api": "*",
|
"fabric-api": "*",
|
||||||
"minecraft": "1.21.11",
|
"minecraft": "~26.1",
|
||||||
"java": ">=21"
|
"java": ">=25"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue