Skip to content

Commit

Permalink
Minecraft 1.17-pre1
Browse files Browse the repository at this point in the history
  • Loading branch information
astei committed May 28, 2021
1 parent de85c46 commit 134bb75
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 48 deletions.
26 changes: 7 additions & 19 deletions build.gradle
@@ -1,7 +1,7 @@
plugins {
id 'fabric-loom' version '0.6-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
id "com.github.johnrengelman.shadow" version "6.1.0"
id "com.github.johnrengelman.shadow" version "7.0.0"
}

repositories {
Expand All @@ -10,8 +10,8 @@ repositories {
}
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand All @@ -26,11 +26,7 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

implementation "com.velocitypowered:velocity-native:1.1.0-SNAPSHOT"
shade("com.velocitypowered:velocity-native:1.1.0-SNAPSHOT") {
transitive = false
}
modImplementation include("com.velocitypowered:velocity-native:1.1.0-SNAPSHOT")
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}
Expand All @@ -43,14 +39,9 @@ shadowJar {
processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
Expand Down Expand Up @@ -95,7 +86,4 @@ publishing {

minecraft {
accessWidener "src/main/resources/krypton.accesswidener"
}

tasks.remapJar.dependsOn(shadowJar)
(tasks.remapJar.input as FileSystemLocationProperty<? extends FileSystemLocation>).set(shadowJar.archivePath)
}
6 changes: 3 additions & 3 deletions gradle.properties
Expand Up @@ -2,9 +2,9 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.1
loader_version=0.10.6+build.214
minecraft_version=1.17-pre1
yarn_mappings=1.17-pre1+build.1
loader_version=0.11.3
# Mod Properties
mod_version=0.1.3-SNAPSHOT
maven_group=me.steinborn
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion settings.gradle
@@ -1,6 +1,5 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
Expand Down
Expand Up @@ -36,7 +36,7 @@ public abstract class ThreadedAnvilChunkStorageMixin {

@Shadow protected abstract boolean doesNotGenerateChunks(ServerPlayerEntity player);

@Shadow protected abstract ChunkSectionPos method_20726(ServerPlayerEntity serverPlayerEntity);
@Shadow protected abstract ChunkSectionPos updateWatchedSection(ServerPlayerEntity serverPlayerEntity);

@Shadow
private static int getChebyshevDistance(ChunkPos pos, int x, int z) {
Expand All @@ -52,23 +52,23 @@ private static int getChebyshevDistance(ChunkPos pos, int x, int z) {
* @reason Add support for flush consolidation
*/
@Overwrite
public void updateCameraPosition(ServerPlayerEntity player) {
public void updatePosition(ServerPlayerEntity player) {
for (ThreadedAnvilChunkStorage.EntityTracker entityTracker : this.entityTrackers.values()) {
if (entityTracker.entity == player) {
entityTracker.updateCameraPosition(this.world.getPlayers());
entityTracker.updateTrackedStatus(this.world.getPlayers());
} else {
entityTracker.updateCameraPosition(player);
entityTracker.updateTrackedStatus(player);
}
}

ChunkSectionPos oldPos = player.getCameraPosition();
ChunkSectionPos oldPos = player.getWatchedSection();
ChunkSectionPos newPos = ChunkSectionPos.from(player);
boolean isWatchingWorld = this.playerChunkWatchingManager.isWatchDisabled(player);
boolean noChunkGen = this.doesNotGenerateChunks(player);
boolean movedSections = !oldPos.equals(newPos);

if (movedSections || isWatchingWorld != noChunkGen) {
this.method_20726(player);
this.updateWatchedSection(player);

if (!isWatchingWorld) {
this.ticketManager.handleChunkLeave(oldPos, player);
Expand Down Expand Up @@ -159,14 +159,14 @@ protected void sendPacketsForChunk(ServerPlayerEntity player, ChunkPos pos, Pack
}
}

@Inject(method = "tickPlayerMovement", at = @At("HEAD"))
@Inject(method = "tickEntityMovement", at = @At("HEAD"))
public void disableAutoFlushForEntityTracking(CallbackInfo info) {
for (ServerPlayerEntity player : world.getPlayers()) {
AutoFlushUtil.setAutoFlush(player, false);
}
}

@Inject(method = "tickPlayerMovement", at = @At("RETURN"))
@Inject(method = "tickEntityMovement", at = @At("RETURN"))
public void enableAutoFlushForEntityTracking(CallbackInfo info) {
for (ServerPlayerEntity player : world.getPlayers()) {
AutoFlushUtil.setAutoFlush(player, true);
Expand Down
Expand Up @@ -20,11 +20,13 @@ public class ClientConnectionMixin implements ClientConnectionEncryptionExtensio

@Override
public void setupEncryption(SecretKey key) throws GeneralSecurityException {
VelocityCipher decryption = Natives.cipher.get().forDecryption(key);
VelocityCipher encryption = Natives.cipher.get().forEncryption(key);
if (!this.encrypted) {
VelocityCipher decryption = Natives.cipher.get().forDecryption(key);
VelocityCipher encryption = Natives.cipher.get().forEncryption(key);

this.encrypted = true;
this.channel.pipeline().addBefore("splitter", "decrypt", new MinecraftCipherDecoder(decryption));
this.channel.pipeline().addBefore("prepender", "encrypt", new MinecraftCipherEncoder(encryption));
this.encrypted = true;
this.channel.pipeline().addBefore("splitter", "decrypt", new MinecraftCipherDecoder(decryption));
this.channel.pipeline().addBefore("prepender", "encrypt", new MinecraftCipherEncoder(encryption));
}
}
}
Expand Up @@ -19,17 +19,13 @@

@Mixin(ServerLoginNetworkHandler.class)
public class ServerLoginNetworkHandlerMixin {
@Shadow private SecretKey secretKey;

@Shadow @Final public ClientConnection connection;

@Inject(method = "onKey", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerLoginNetworkHandler;secretKey:Ljavax/crypto/SecretKey;", ordinal = 1))
public void onKey$initializeVelocityCipher(LoginKeyC2SPacket packet, CallbackInfo info) throws GeneralSecurityException {
((ClientConnectionEncryptionExtension) this.connection).setupEncryption(this.secretKey);
}
@Redirect(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/encryption/NetworkEncryptionUtils;cipherFromKey(ILjava/security/Key;)Ljavax/crypto/Cipher;"))
private Cipher onKey$initializeVelocityCipher(int ignored1, Key secretKey) throws GeneralSecurityException {
// Hijack this portion of the cipher initialization and set up our own encryption handler.
((ClientConnectionEncryptionExtension) this.connection).setupEncryption((SecretKey) secretKey);

@Redirect(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkEncryptionUtils;cipherFromKey(ILjava/security/Key;)Ljavax/crypto/Cipher;"))
private Cipher onKey$ignoreJavaCipherInitialization(int ignored1, Key ignored2) {
// Turn the operation into a no-op.
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Expand Up @@ -30,8 +30,8 @@
],
"accessWidener": "krypton.accesswidener",
"depends": {
"fabricloader": ">=0.10.6+build.214",
"minecraft": ">=1.16.2"
"fabricloader": ">=0.11.3",
"minecraft": "1.17.x"
},

"custom": {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/krypton.mixins.json
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "me.steinborn.krypton.mixin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_16",
"mixins": [
"network.shared.flushconsolidation.ClientConnectionMixin",
"network.shared.flushconsolidation.EntityTrackerMixin",
Expand Down

0 comments on commit 134bb75

Please sign in to comment.