Skip to content

Commit

Permalink
Update to 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
QPCrummer committed May 11, 2024
1 parent 36675aa commit 5dd619c
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 181 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ processResources {
}
}

def targetJavaVersion = 17
def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
// 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
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G

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

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

# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.96.11+1.20.4
fabric_version=0.97.8+1.20.6
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected SkeletonEntityMixin(EntityType<? extends HostileEntity> entityType, Wo
}

@Inject(method = "initialize", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/AbstractSkeletonEntity;setCanPickUpLoot(Z)V", shift = At.Shift.AFTER), cancellable = true)
private void optimizedCheckHalloween(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityNbt, CallbackInfoReturnable<EntityData> cir) {
private void optimizedCheckHalloween(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, CallbackInfoReturnable<EntityData> cir) {
if (((IsHalloweenInterface)this.getServer()).isHalloween() && random.nextFloat() < 0.25f) {
this.equipStack(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1f ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN));
this.armorDropChances[EquipmentSlot.HEAD.getEntitySlotId()] = 0.0f;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.github.tatercertified.potatoptimize.mixin.entity.villager;

import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.brain.task.SleepTask;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

/**
* Credit to PaperMC patch #0326
Expand All @@ -21,11 +17,4 @@ public class VillagerNoChunkLoadingMixin {
private BlockState noChunkLoading(ServerWorld instance, BlockPos pos) {
return instance.isChunkLoaded(pos) ? instance.getBlockState(pos) : null;
}

@Inject(method = "shouldRun", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/GlobalPos;getPos()Lnet/minecraft/util/math/BlockPos;", ordinal = 1), cancellable = true)
private void checkForNull(ServerWorld world, LivingEntity entity, CallbackInfoReturnable<Boolean> cir, @Local(ordinal = 0) BlockState blockState) {
if (blockState == null) {
cir.setReturnValue(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand All @@ -10,19 +11,21 @@
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>> Map<Identifier, T> getAllOfType(RecipeType<T> type);

@Shadow protected abstract <C extends Inventory, T extends Recipe<C>> 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<T> listAllOfType(RecipeType<T> type) {
return new ArrayList<>(this.getAllOfType(type).values());
public <C extends Inventory, T extends Recipe<C>> List<RecipeEntry<T>> listAllOfType(RecipeType<T> type) {
return new ArrayList<>(this.getAllOfType(type));
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.tatercertified.potatoptimize.mixin.remove.profiler;

import net.minecraft.network.NetworkPhase;
import net.minecraft.network.packet.PacketType;
import net.minecraft.registry.RegistryKey;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.profiling.jfr.Finishable;
Expand Down Expand Up @@ -86,15 +88,15 @@ public void onTick(float tickTime) {
* @reason Removal
*/
@Overwrite
public void onPacketReceived(int protocolId, int packetId, SocketAddress remoteAddress, int bytes) {
public void onPacketReceived(NetworkPhase state, PacketType<?> type, SocketAddress remoteAddress, int bytes) {
}

/**
* @author QPCrummer
* @reason Removal
*/
@Overwrite
public void onPacketSent(int protocolId, int packetId, SocketAddress remoteAddress, int bytes) {
public void onPacketSent(NetworkPhase state, PacketType<?> type, SocketAddress remoteAddress, int bytes) {
}

/**
Expand Down

This file was deleted.

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

import com.github.tatercertified.potatoptimize.utils.interfaces.StreamlessRecipeManagerInterface;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.datafixers.util.Pair;
import net.minecraft.inventory.Inventory;
import net.minecraft.recipe.Recipe;
Expand All @@ -23,34 +22,31 @@
public abstract class StreamRecipeManagerMixin implements StreamlessRecipeManagerInterface {


@Shadow protected abstract <C extends Inventory, T extends Recipe<C>> Map<Identifier, RecipeEntry<T>> getAllOfType(RecipeType<T> type);
@Shadow private Map<Identifier, RecipeEntry<?>> recipesById;

@Shadow private Map<RecipeType<?>, Map<Identifier, RecipeEntry<?>>> recipes;
@Shadow protected abstract <C extends Inventory, T extends Recipe<C>> 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) {
for(RecipeEntry<T> recipe : this.getAllOfType(type).values()) {
for(RecipeEntry<T> recipe : this.getAllOfType(type)) {
if (recipe.value().matches(inventory, 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 = "Ljava/util/Map;entrySet()Ljava/util/Set;", 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<Pair<Identifier, RecipeEntry<T>>>> cir, @Local(ordinal = 0) Map<Identifier, RecipeEntry<T>> map) {
for (Map.Entry<Identifier, RecipeEntry<T>> entry : map.entrySet()) {
if (entry.getValue().value().matches(inventory, world)) {
Identifier key = entry.getKey();
RecipeEntry<T> value = entry.getValue();
cir.setReturnValue(Optional.of(Pair.of(key, value)));
@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<Pair<Identifier, RecipeEntry<T>>>> cir) {
for (RecipeEntry<T> entry : this.getAllOfType(type)) {
if (entry.value().matches(inventory, world)) {
cir.setReturnValue(Optional.of(Pair.of(entry.id(), entry)));
}
}

cir.setReturnValue(Optional.empty());
}

Expand All @@ -61,7 +57,7 @@ private <C extends Inventory, T extends Recipe<C>> void injectToRemoveStream(Rec
@Overwrite
public <C extends Inventory, T extends Recipe<C>> List<RecipeEntry<T>> getAllMatches(RecipeType<T> type, C inventory, World world) {
List<RecipeEntry<T>> matches = new ArrayList<>();
for(RecipeEntry<T> recipe : this.getAllOfType(type).values()) {
for(RecipeEntry<T> recipe : this.getAllOfType(type)) {
if (recipe.value().matches(inventory, world)) {
matches.add(recipe);
}
Expand All @@ -72,19 +68,11 @@ public <C extends Inventory, T extends Recipe<C>> List<RecipeEntry<T>> getAllMat

@Override
public List<RecipeEntry<?>> values() {
List<RecipeEntry<?>> allRecipes = new ArrayList<>();
for (Map<Identifier, RecipeEntry<?>> innerMap : this.recipes.values()) {
allRecipes.addAll(innerMap.values());
}
return allRecipes;
return new ArrayList<>(this.recipesById.values());
}

@Override
public List<Identifier> keys() {
List<Identifier> allRecipes = new ArrayList<>();
for (Map<Identifier, RecipeEntry<?>> innerMap : this.recipes.values()) {
allRecipes.addAll(innerMap.keySet());
}
return allRecipes;
return new ArrayList<>(this.recipesById.keySet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper;
import net.minecraft.nbt.NbtIo;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.util.Util;
import net.minecraft.world.PersistentState;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -18,7 +19,7 @@
@Mixin(PersistentState.class)
public abstract class DataIOSavingMixin implements AsyncChunkSaveInterface {

@Shadow public abstract NbtCompound writeNbt(NbtCompound nbt);
@Shadow public abstract NbtCompound writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup);

@Shadow public abstract boolean isDirty();

Expand All @@ -29,15 +30,15 @@ public abstract class DataIOSavingMixin implements AsyncChunkSaveInterface {
* @reason Make async
*/
@Overwrite
public void save(File file) {
save(file, false);
public void save(File file, RegistryWrapper.WrapperLookup registryLookup) {
save(file, false, registryLookup);
}

@Override
public void save(File file, boolean async) {
public void save(File file, boolean async, RegistryWrapper.WrapperLookup registryLookup) {
if (this.isDirty()) {
NbtCompound compoundTag = new NbtCompound();
compoundTag.put("data", this.writeNbt(new NbtCompound()));
compoundTag.put("data", this.writeNbt(new NbtCompound(), registryLookup));
NbtHelper.putDataVersion(compoundTag);

Runnable writeRunnable = () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.tatercertified.potatoptimize.utils.interfaces.AsyncChunkManagerInterface;
import com.github.tatercertified.potatoptimize.utils.interfaces.AsyncChunkSaveInterface;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.world.PersistentState;
import net.minecraft.world.PersistentStateManager;
import org.spongepowered.asm.mixin.*;
Expand All @@ -15,12 +16,14 @@ public abstract class PersistentStateManagerMixin implements AsyncChunkManagerIn

@Shadow protected abstract File getFile(String id);

@Shadow @Final private RegistryWrapper.WrapperLookup registryLookup;

@Unique
@Override
public void save(boolean async) {
this.loadedStates.forEach((id, state) -> {
if (state != null) {
((AsyncChunkSaveInterface)state).save(this.getFile(id), async);
((AsyncChunkSaveInterface)state).save(this.getFile(id), async, this.registryLookup);
}

});
Expand Down
Loading

0 comments on commit 5dd619c

Please sign in to comment.