diff --git a/gradle.properties b/gradle.properties index c0d02cc1..f6164e46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ org.gradle.jvmargs=-Xmx1G org.gradle.daemon=false -minecraft_version=1.19.4 -forge_version=1.19.4-45.0.44 +minecraft_version=1.20 +forge_version=1.20-46.0.14 mod_version=0.2.5 maven_group=com.abdelaziz.canary -archives_base_name=canary-mc1.19.4 +archives_base_name=canary-mc1.20(.1) mod_id=canary mod_author=AbdElAziz \ No newline at end of file diff --git a/src/main/java/com/abdelaziz/canary/common/config/CanaryConfig.java b/src/main/java/com/abdelaziz/canary/common/config/CanaryConfig.java index 87139221..cb1af5f0 100644 --- a/src/main/java/com/abdelaziz/canary/common/config/CanaryConfig.java +++ b/src/main/java/com/abdelaziz/canary/common/config/CanaryConfig.java @@ -29,7 +29,6 @@ public class CanaryConfig { private CanaryConfig() { // Defines the default rules which can be configured by the user or other mods. // You must manually add a rule for any new mixins not covered by an existing package rule. - this.addMixinRule("ai", true); this.addMixinRule("ai.goals", true); this.addMixinRule("ai.pathing", true); @@ -137,8 +136,6 @@ private CanaryConfig() { this.addMixinRule("gen.cached_generator_settings", false); this.addMixinRule("gen.chunk_region", true); - this.addMixinRule("item", true); - this.addMixinRule("math", true); this.addMixinRule("math.fast_blockpos", true); this.addMixinRule("math.fast_util", true); diff --git a/src/main/java/com/abdelaziz/canary/common/entity/CanaryEntityCollisions.java b/src/main/java/com/abdelaziz/canary/common/entity/CanaryEntityCollisions.java index 65c2a3e8..8ff259ce 100644 --- a/src/main/java/com/abdelaziz/canary/common/entity/CanaryEntityCollisions.java +++ b/src/main/java/com/abdelaziz/canary/common/entity/CanaryEntityCollisions.java @@ -113,7 +113,7 @@ protected VoxelShape computeNext() { //get the world border at the end if (includeWorldBorder && !this.consumedWorldBorder) { this.consumedWorldBorder = true; - WorldBorder worldBorder = entity.level.getWorldBorder(); + WorldBorder worldBorder = entity.level().getWorldBorder(); if (!isWithinWorldBorder(worldBorder, box) && isWithinWorldBorder(worldBorder, entity.getBoundingBox())) { return worldBorder.getCollisionShape(); } diff --git a/src/main/java/com/abdelaziz/canary/common/util/Distances.java b/src/main/java/com/abdelaziz/canary/common/util/Distances.java deleted file mode 100644 index 2d8c5d25..00000000 --- a/src/main/java/com/abdelaziz/canary/common/util/Distances.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.abdelaziz.canary.common.util; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.chunk.LevelChunkSection; - -public class Distances { - - public static double getMinChunkToBlockDistanceL2Sq(BlockPos origin, int chunkX, int chunkZ) { - int chunkMinX = LevelChunkSection.getBottomBlockY(chunkX); - int chunkMinZ = LevelChunkSection.getBottomBlockY(chunkZ); - - int xDistance = origin.getX() - chunkMinX; - if (xDistance > 0) { - xDistance = Math.max(0, xDistance - 15); - } - int zDistance = origin.getZ() - chunkMinZ; - if (zDistance > 0) { - zDistance = Math.max(0, zDistance - 15); - } - - return xDistance * xDistance + zDistance * zDistance; - } - - public static boolean isWithinSquareRadius(BlockPos origin, int radius, BlockPos pos) { - return Math.abs(pos.getX() - origin.getX()) <= radius && - Math.abs(pos.getZ() - origin.getZ()) <= radius; - } - - public static boolean isWithinCircleRadius(BlockPos origin, double radiusSq, BlockPos pos) { - return origin.distSqr(pos) <= radiusSq; - } -} diff --git a/src/main/java/com/abdelaziz/canary/mixin/alloc/enum_values/piston_block/PistonBaseBlockMixin.java b/src/main/java/com/abdelaziz/canary/mixin/alloc/enum_values/piston_block/PistonBaseBlockMixin.java index 052fa778..a9056721 100644 --- a/src/main/java/com/abdelaziz/canary/mixin/alloc/enum_values/piston_block/PistonBaseBlockMixin.java +++ b/src/main/java/com/abdelaziz/canary/mixin/alloc/enum_values/piston_block/PistonBaseBlockMixin.java @@ -11,7 +11,7 @@ public class PistonBaseBlockMixin { @Redirect( - method = "getNeighborSignal(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z", + method = "getNeighborSignal(Lnet/minecraft/world/level/SignalGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z", at = @At( value = "INVOKE", target = "Lnet/minecraft/core/Direction;values()[Lnet/minecraft/core/Direction;" diff --git a/src/main/java/com/abdelaziz/canary/mixin/entity/collisions/unpushable_cramming/LivingEntityMixin.java b/src/main/java/com/abdelaziz/canary/mixin/entity/collisions/unpushable_cramming/LivingEntityMixin.java index c0e8a174..afea3e25 100644 --- a/src/main/java/com/abdelaziz/canary/mixin/entity/collisions/unpushable_cramming/LivingEntityMixin.java +++ b/src/main/java/com/abdelaziz/canary/mixin/entity/collisions/unpushable_cramming/LivingEntityMixin.java @@ -75,7 +75,7 @@ public void canaryOnBlockCacheSet(BlockState newState) { } private void updateClimbingMobCachingSection(BlockState newState) { - EntitySectionStorage entityCacheOrNull = WorldHelper.getEntityCacheOrNull(this.level); + EntitySectionStorage entityCacheOrNull = WorldHelper.getEntityCacheOrNull(this.level()); if (entityCacheOrNull != null) { EntitySection trackingSection = entityCacheOrNull.getSection(SectionPos.asLong(this.blockPosition())); if (trackingSection != null) { diff --git a/src/main/java/com/abdelaziz/canary/mixin/entity/inactive_navigations/MobMixin.java b/src/main/java/com/abdelaziz/canary/mixin/entity/inactive_navigations/MobMixin.java index 712d374b..65e7bd35 100644 --- a/src/main/java/com/abdelaziz/canary/mixin/entity/inactive_navigations/MobMixin.java +++ b/src/main/java/com/abdelaziz/canary/mixin/entity/inactive_navigations/MobMixin.java @@ -63,11 +63,11 @@ public void updateNavigationRegistration() { if (this.isRegisteredToWorld()) { PathNavigation navigation = this.getNavigation(); if (this.registeredNavigation != navigation) { - ((ServerWorldExtended) this.level).setNavigationInactive((Mob) (Object) this); + ((ServerWorldExtended) this.level()).setNavigationInactive((Mob) (Object) this); this.registeredNavigation = navigation; if (navigation.getPath() != null) { - ((ServerWorldExtended) this.level).setNavigationActive((Mob) (Object) this); + ((ServerWorldExtended) this.level()).setNavigationActive((Mob) (Object) this); } } } diff --git a/src/main/java/com/abdelaziz/canary/mixin/entity/inactive_navigations/ServerLevelMixin.java b/src/main/java/com/abdelaziz/canary/mixin/entity/inactive_navigations/ServerLevelMixin.java index d5bf7402..5032d215 100644 --- a/src/main/java/com/abdelaziz/canary/mixin/entity/inactive_navigations/ServerLevelMixin.java +++ b/src/main/java/com/abdelaziz/canary/mixin/entity/inactive_navigations/ServerLevelMixin.java @@ -11,6 +11,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.RandomSequences; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.navigation.PathNavigation; import net.minecraft.world.level.Level; @@ -21,6 +22,7 @@ import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.WritableLevelData; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; @@ -84,7 +86,7 @@ private Iterator getActiveListeners(Set set) { @SuppressWarnings("rawtypes") @Inject(method = "", at = @At("TAIL")) - private void init(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey worldKey, LevelStem dimensionOptions, ChunkProgressListener worldGenerationProgressListener, boolean debugWorld, long seed, List spawners, boolean shouldTickTime, CallbackInfo ci) { + private void init(MinecraftServer server, Executor workerExecutor, LevelStorageSource.LevelStorageAccess session, ServerLevelData properties, ResourceKey worldKey, LevelStem dimensionOptions, ChunkProgressListener worldGenerationProgressListener, boolean debugWorld, long seed, List spawners, boolean shouldTickTime, @Nullable RandomSequences randomSequences, CallbackInfo ci) { this.navigatingMobs = new ReferenceOpenHashSet<>(this.navigatingMobs); this.activeNavigations = new ReferenceOpenHashSet<>(); } diff --git a/src/main/java/com/abdelaziz/canary/mixin/item/ItemStackMixin.java b/src/main/java/com/abdelaziz/canary/mixin/item/ItemStackMixin.java deleted file mode 100644 index e07df7f3..00000000 --- a/src/main/java/com/abdelaziz/canary/mixin/item/ItemStackMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.abdelaziz.canary.mixin.item; - -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(ItemStack.class) -public abstract class ItemStackMixin { - //Optimization: As ItemStack already caches whether it is empty, we only have to actually use the cached value. - @Shadow - private boolean emptyCacheFlag; - @Shadow - private int count; - @Shadow - @Final - private Item item; - - /** - * @author 2No2Name - * @reason use cached empty state - */ - @Overwrite - public boolean isEmpty() { - return this.emptyCacheFlag; - } - - @Redirect(method = "updateEmptyCacheFlag()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;isEmpty()Z")) - private boolean isEmptyRecalculate(ItemStack itemStack) { - return (this.item == null || this.item == Items.AIR || this.count <= 0); - } -} \ No newline at end of file diff --git a/src/main/java/com/abdelaziz/canary/mixin/world/block_entity_ticking/world_border/BoundTickingBlockEntityMixin.java b/src/main/java/com/abdelaziz/canary/mixin/world/block_entity_ticking/world_border/BoundTickingBlockEntityMixin.java index 799a834a..c2ddc306 100644 --- a/src/main/java/com/abdelaziz/canary/mixin/world/block_entity_ticking/world_border/BoundTickingBlockEntityMixin.java +++ b/src/main/java/com/abdelaziz/canary/mixin/world/block_entity_ticking/world_border/BoundTickingBlockEntityMixin.java @@ -2,7 +2,7 @@ import com.abdelaziz.canary.common.world.listeners.WorldBorderListenerOnce; import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ChunkHolder; +import net.minecraft.server.level.FullChunkStatus; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; @@ -38,7 +38,8 @@ private boolean cachedCanTickBlockEntity(LevelChunk instance, BlockPos pos) { if (this.isInsideWorldBorder()) { Level world = this.this$0.getLevel(); if (world instanceof ServerLevel serverWorld) { - return this.this$0.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING) && serverWorld.areEntitiesLoaded(ChunkPos.asLong(pos)); + return this.this$0.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING) + && serverWorld.areEntitiesLoaded(ChunkPos.asLong(pos)); } return true; } else { diff --git a/src/main/java/com/abdelaziz/canary/mixin/world/chunk_access/ServerChunkCacheMixin.java b/src/main/java/com/abdelaziz/canary/mixin/world/chunk_access/ServerChunkCacheMixin.java index 7d4b2d40..aa9479a0 100644 --- a/src/main/java/com/abdelaziz/canary/mixin/world/chunk_access/ServerChunkCacheMixin.java +++ b/src/main/java/com/abdelaziz/canary/mixin/world/chunk_access/ServerChunkCacheMixin.java @@ -178,7 +178,7 @@ private ChunkAccess getChunkBlocking(int x, int z, ChunkStatus status, boolean c // Create a future to load the chunk if none exists if (loadFuture == null) { - if (ChunkHolder.getStatus(holder.getTicketLevel()).isOrAfter(status)) { + if (ChunkLevel.generationStatus(holder.getTicketLevel()).isOrAfter(status)) { // Create a new future which upgrades the chunk from the previous status level to the desired one CompletableFuture> mergedFuture = this.chunkMap.schedule(holder, status); diff --git a/src/main/java/com/abdelaziz/canary/mixin/world/player_chunk_tick/ChunkMapMixin.java b/src/main/java/com/abdelaziz/canary/mixin/world/player_chunk_tick/ChunkMapMixin.java index 45dee9c0..b0ecfb49 100644 --- a/src/main/java/com/abdelaziz/canary/mixin/world/player_chunk_tick/ChunkMapMixin.java +++ b/src/main/java/com/abdelaziz/canary/mixin/world/player_chunk_tick/ChunkMapMixin.java @@ -76,7 +76,7 @@ public void move(ServerPlayer player) { // We can only send chunks if the world matches. This hoists a check that // would otherwise be performed every time we try to send a chunk over. - if (player.level == this.level) { + if (player.level() == this.level) { this.sendChunks(oldPos, player); } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 1074d540..7a5404a7 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader = "javafml" -loaderVersion = "[45,)" +loaderVersion = "[46,)" license = "LGPL-3.0-only" issueTrackerURL = "https://github.com/AbdElAziz333/Canary/issues" [[mods]] @@ -20,13 +20,13 @@ Canary is a free and open-source optimization mod for Minecraft which makes a wi [[dependencies.canary]] modId = "forge" mandatory = true -versionRange = "[45,)" +versionRange = "[46,)" ordering = "NONE" side = "BOTH" [[dependencies.canary]] modId = "minecraft" mandatory = true -versionRange = "[1.19.4,1.20)" +versionRange = "[1.20,1.21)" ordering = "NONE" side = "BOTH" \ No newline at end of file diff --git a/src/main/resources/canary.mixins.json b/src/main/resources/canary.mixins.json index 3548f51e..7c974b64 100644 --- a/src/main/resources/canary.mixins.json +++ b/src/main/resources/canary.mixins.json @@ -120,7 +120,6 @@ "entity.skip_fire_check.EntityMixin", "gen.cached_generator_settings.NoiseBasedChunkGeneratorMixin", "gen.chunk_region.WorldGenRegionMixin", - "item.ItemStackMixin", "math.fast_blockpos.BlockPosMixin", "math.fast_blockpos.DirectionMixin", "math.fast_util.AABBMixin",