Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
QPCrummer committed Jun 22, 2024
1 parent cf470e2 commit 6de638c
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 73 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -29,9 +29,9 @@ dependencies {

//modCompileOnly("com.github.CaffeineMC:lithium-fabric:mc1.20.4-0.12.1")

include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:0.3.5")))
include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.1.2-beta.5")))
include(implementation("com.moulberry:mixinconstraints:1.0.0"))
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:0.3.6")))
include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.2.0-beta.3")))
include(implementation("com.moulberry:mixinconstraints:1.0.1"))
}

processResources {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11

# Mod Properties
Expand All @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G

# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.97.8+1.20.6
fabric_version=0.100.3+1.21
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
@Mixin(BakedQuadFactory.class)
public class FastRoundingQuadsMixin {
@Redirect(
method = "uvLock(Lnet/minecraft/client/render/model/json/ModelElementTexture;Lnet/minecraft/util/math/"+
"Direction;Lnet/minecraft/util/math/AffineTransformation;Lnet/minecraft/util/Identifier;)"+
"Lnet/minecraft/client/render/model/json/ModelElementTexture;",
method = "uvLock",
require = 0,
at = @At(value = "INVOKE", target = "Ljava/lang/Math;round(D)J"))
private static long fasterRound(double value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
package com.github.tatercertified.potatoptimize.mixin.logic.recipe_manager;

import net.minecraft.inventory.Inventory;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.recipe.RecipeType;
import net.minecraft.util.Identifier;
import net.minecraft.recipe.input.RecipeInput;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@Mixin(RecipeManager.class)
public abstract class RecipeManagerMixin {

@Shadow protected abstract <C extends Inventory, T extends Recipe<C>> Collection<RecipeEntry<T>> getAllOfType(RecipeType<T> type);

@Shadow protected abstract <I extends RecipeInput, T extends Recipe<I>> Collection<RecipeEntry<T>> getAllOfType(RecipeType<T> type);

/**
* @author QPCrummer & Leaf Patch #0023
* @reason Optimize RecipeManager List Creation
*/
@Overwrite
public <C extends Inventory, T extends Recipe<C>> List<RecipeEntry<T>> listAllOfType(RecipeType<T> type) {
public <I extends RecipeInput, T extends Recipe<I>> List<RecipeEntry<T>> listAllOfType(RecipeType<T> type) {
return new ArrayList<>(this.getAllOfType(type));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static int getMaxBackgroundThreads() {
* @reason Optimize worker threads
*/
@Overwrite
public static ExecutorService createWorker(String name) {
private static ExecutorService createWorker(String name) {
int i = MathHelper.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, getMaxBackgroundThreads());
ExecutorService executorService;
if (i <= 0) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class ServerPlayerEntityRandomMixin {

@Shadow public abstract ServerWorld getServerWorld();

@Redirect(method = "moveToSpawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/random/Random;create()Lnet/minecraft/util/math/random/Random;"))
@Redirect(method = "getWorldSpawnPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/random/Random;create()Lnet/minecraft/util/math/random/Random;"))
private Random redirectCreatedRandom() {
return getServerWorld().random;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import net.minecraft.network.NetworkPhase;
import net.minecraft.network.packet.PacketType;
import net.minecraft.registry.RegistryKey;
import net.minecraft.util.function.Finishable;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.profiling.jfr.Finishable;
import net.minecraft.util.profiling.jfr.InstanceType;
import net.minecraft.util.profiling.jfr.JfrProfiler;
import net.minecraft.util.profiling.jfr.event.NetworkSummaryEvent;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.github.tatercertified.potatoptimize.mixin.unstream.recipe_manager;

import com.github.tatercertified.potatoptimize.utils.interfaces.StreamlessRecipeManagerInterface;
import com.mojang.datafixers.util.Pair;
import net.minecraft.inventory.Inventory;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.input.RecipeInput;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -24,36 +23,36 @@ public abstract class StreamRecipeManagerMixin implements StreamlessRecipeManage

@Shadow private Map<Identifier, RecipeEntry<?>> recipesById;

@Shadow protected abstract <C extends Inventory, T extends Recipe<C>> Collection<RecipeEntry<T>> getAllOfType(RecipeType<T> type);
@Shadow protected abstract <I extends RecipeInput, T extends Recipe<I>> Collection<RecipeEntry<T>> getAllOfType(RecipeType<T> type);

/**
* @author QPCrummer
* @reason Remove Stream API
*/
@Overwrite
public <C extends Inventory, T extends Recipe<C>> Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, C inventory, World world) {
public <I extends RecipeInput, T extends Recipe<I>> Optional<RecipeEntry<T>> getFirstMatch(RecipeType<T> type, I input, World world) {
for(RecipeEntry<T> recipe : this.getAllOfType(type)) {
if (recipe.value().matches(inventory, world)) {
if (recipe.value().matches(input, world)) {
return Optional.of(recipe);
}
}
return Optional.empty();
}

@Inject(method = "getFirstMatch(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/inventory/Inventory;Lnet/minecraft/world/World;Lnet/minecraft/util/Identifier;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/recipe/RecipeManager;getAllOfType(Lnet/minecraft/recipe/RecipeType;)Ljava/util/Collection;", shift = At.Shift.BEFORE), cancellable = true)
private <C extends Inventory, T extends Recipe<C>> void injectToRemoveStream(RecipeType<T> type, C inventory, World world, Identifier id, CallbackInfoReturnable<Optional<RecipeEntry<T>>> cir) {
cir.setReturnValue(getFirstMatch(type, inventory, world));
@Inject(method = "getFirstMatch(Lnet/minecraft/recipe/RecipeType;Lnet/minecraft/recipe/input/RecipeInput;Lnet/minecraft/world/World;Lnet/minecraft/recipe/RecipeEntry;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/recipe/RecipeManager;getAllOfType(Lnet/minecraft/recipe/RecipeType;)Ljava/util/Collection;", shift = At.Shift.BEFORE), cancellable = true)
private <I extends RecipeInput, T extends Recipe<I>> void injectToRemoveStream(RecipeType<T> type, I input, World world, RecipeEntry<T> recipe, CallbackInfoReturnable<Optional<RecipeEntry<T>>> cir) {
cir.setReturnValue(getFirstMatch(type, input, world));
}

/**
* @author QPCrummer
* @reason Remove StreamAPI
*/
@Overwrite
public <C extends Inventory, T extends Recipe<C>> List<RecipeEntry<T>> getAllMatches(RecipeType<T> type, C inventory, World world) {
public <I extends RecipeInput, T extends Recipe<I>> List<RecipeEntry<T>> getAllMatches(RecipeType<T> type, I input, World world) {
List<RecipeEntry<T>> matches = new ArrayList<>();
for(RecipeEntry<T> recipe : this.getAllOfType(type)) {
if (recipe.value().matches(inventory, world)) {
if (recipe.value().matches(input, world)) {
matches.add(recipe);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.tatercertified.potatoptimize.mixin.unstream.tacs;

import net.minecraft.entity.Entity;
import net.minecraft.server.world.ThreadedAnvilChunkStorage;
import net.minecraft.server.world.ServerChunkLoadingManager;
import org.spongepowered.asm.mixin.*;

import java.util.List;

@Mixin(ThreadedAnvilChunkStorage.EntityTracker.class)
@Mixin(ServerChunkLoadingManager.EntityTracker.class)
public abstract class ThreadedAnvilUnstreamMixin {
@Shadow protected abstract int adjustTrackingDistance(int initialDistance);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public Random split(String seed) {
return new SplittableRandomImpl((long)i ^ this.seed);
}

@Override
public Random split(long seed) {
return new SplittableRandomImpl(seed ^ this.seed);
}

@Override
public Random split(int x, int y, int z) {
long l = MathHelper.hashCode(x, y, z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public Random split(String seed) {
return new ThreadLocalRandomImpl((long)i ^ this.seed);
}

@Override
public Random split(long seed) {
return new ThreadLocalRandomImpl(seed ^ this.seed);
}

@Override
public Random split(int x, int y, int z) {
long l = MathHelper.hashCode(x, y, z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ mixin.random.math = true
mixin.random.unsafe = false
mixin.random.world = true
mixin.remove.profiler = false
mixin.startup.dfu = true
mixin.threading.client_tick = true
mixin.threading.entity_ticking = false
mixin.threading.explosions = false
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"depends": {
"fabricloader": ">=${loader_version}",
"fabric": "*",
"minecraft": ">=1.20.5"
"minecraft": ">=1.21"
},
"custom": {
"lithium:options": {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/potatoptimize.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ accessible method net/minecraft/world/chunk/PalettedContainer$PaletteProvider ge
accessible class net/minecraft/world/chunk/PaletteResizeListener
accessible class net/minecraft/server/rcon/QueryResponseHandler$Query
accessible class net/minecraft/world/chunk/PalettedContainer$Data
accessible class net/minecraft/server/world/ThreadedAnvilChunkStorage$EntityTracker
accessible class net/minecraft/server/world/ServerChunkLoadingManager$EntityTracker
accessible class net/minecraft/block/ComposterBlock$ComposterInventory
accessible class net/minecraft/block/ComposterBlock$DummyInventory
accessible class net/minecraft/block/ComposterBlock$FullComposterInventory
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/potatoptimize.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
"memory.reduce_alloc.NbtLongArrayMixin",
"memory.reduce_alloc.PacketEncryptionManagerMixin",
"memory.reduce_alloc.ServerConfigListMixin",
"memory.reduce_alloc.ZombieVillagerMixin",
"memory.reduce_random.RandomCreationMixin",
"networking.block_breaking.CacheBlockBreakPacketMixin",
"random.creation.QueryResponseHandlerMixin",
Expand All @@ -87,7 +86,6 @@
"remove.profiler.JFRCommandMixin",
"remove.profiler.JFRMixin",
"remove.profiler.ProfilerSystemMixin",
"startup.dfu.DFUMixin",
"threading.entity_ticking.EntityListMixin",
"threading.entity_ticking.EntityServerThreadingMixin",
"threading.explosions.AsyncExplosionMixin",
Expand Down

0 comments on commit 6de638c

Please sign in to comment.