From 76530963d9e5abdbbe2e291e14e8c6f7d8f94a9d Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Fri, 3 Dec 2021 13:27:06 +0800 Subject: [PATCH] Initial update to 1.18 Not booting yet, required record related updates from modlauncher --- .github/workflows/gradle.yml | 4 +- README.md | 4 +- appveyor-17.yml => appveyor-18.yml | 4 +- arclight-common/build.gradle | 9 +- .../entity/AreaEffectCloudEntityBridge.java | 7 -- .../entity/projectile/ArrowEntityBridge.java | 7 -- .../bridge/core/world/TeleporterBridge.java | 6 +- .../common/bridge/core/world/WorldBridge.java | 4 +- .../core/world/chunk/ChunkAccessBridge.java | 8 ++ .../world/chunk/LevelChunkSectionBridge.java | 8 ++ .../level/levelgen/ChunkGeneratorBridge.java | 3 - .../core/world/server/ChunkMapBridge.java | 2 - .../spawner/WorldEntitySpawnerBridge.java | 3 +- .../world/storage/DerivedWorldInfoBridge.java | 4 +- ...dge.java => LevelStorageSourceBridge.java} | 9 +- .../common/mixin/bukkit/CraftWorldMixin.java | 2 +- .../mixin/bukkit/LibraryLoaderMixin.java | 4 +- .../mixin/core/commands/CommandsMixin.java | 2 +- .../ServerHandshakeNetHandlerMixin.java | 2 +- .../network/ServerPlayNetHandlerMixin.java | 69 +++++------ .../network/ServerStatusNetHandlerMixin.java | 18 ++- .../game/CChatMessagePacketMixin.java | 2 +- .../handshake/CHandshakePacketMixin.java | 8 +- .../core/server/MinecraftServerMixin.java | 13 ++- .../core/server/level/ChunkMapMixin.java | 14 +-- ...erMixin.java => DistanceManagerMixin.java} | 2 +- .../server/level/ServerChunkCacheMixin.java | 9 -- .../core/server/level/ServerLevelMixin.java | 29 +++-- .../ServerLevel_EntityCallbacksMixin.java | 8 +- .../server/management/PlayerListMixin.java | 37 +++--- ...ReaderMixin.java => BlockGetterMixin.java} | 14 +-- .../mixin/core/world/IServerWorldMixin.java | 4 +- .../mixin/core/world/IWorldWriterMixin.java | 2 +- .../entity/AreaEffectCloudEntityMixin.java | 7 +- .../mixin/core/world/entity/EntityMixin.java | 32 ++--- .../core/world/entity/EntityTypeMixin.java | 4 +- .../core/world/entity/LivingEntityMixin.java | 8 +- .../mixin/core/world/entity/MobMixin.java | 6 +- .../ai/behavior/HarvestFarmlandMixin.java | 2 +- .../ai/behavior/ResetProfessionMixin.java | 2 +- .../entity/decoration/ArmorStandMixin.java | 2 +- .../entity/decoration/PaintingMixin.java | 28 ----- .../world/entity/item/ItemEntityMixin.java | 4 +- .../world/entity/monster/EnderManMixin.java | 4 +- .../entity/monster/ZombieVillagerMixin.java | 2 +- .../core/world/entity/player/PlayerMixin.java | 6 +- .../entity/player/ServerPlayerMixin.java | 37 +++--- .../entity/projectile/ArrowEntityMixin.java | 7 +- .../core/world/entity/vehicle/BoatMixin.java | 2 +- .../core/world/gen/WorldGenRegionMixin.java | 25 +--- .../feature/structure/SwampHutPieceMixin.java | 19 ++- .../inventory/AbstractContainerMenuMixin.java | 4 +- .../core/world/item/BucketItemMixin.java | 2 +- .../item/crafting/RecipeManagerMixin.java | 11 +- .../FrostWalkerEnchantmentMixin.java | 2 +- .../mixin/core/world/level/LevelMixin.java | 23 +--- .../world/level/block/BaseFireBlockMixin.java | 13 +++ .../level/block/CarvedPumpkinBlockMixin.java | 4 +- .../world/level/block/ChestBlockMixin.java | 2 +- .../world/level/block/CommandBlockMixin.java | 2 +- .../level/block/ComposterBlockMixin.java | 16 +-- .../level/block/ConcretePowderBlockMixin.java | 5 +- .../world/level/block/CropBlockMixin.java | 25 ++++ .../level/block/DragonEggBlockMixin.java | 5 +- .../world/level/block/FireBlockMixin.java | 2 +- .../world/level/block/GrassBlockMixin.java | 19 --- .../block/PointedDripstoneBlockMixin.java | 37 ++++++ ...alSizeMixin.java => PortalShapeMixin.java} | 14 +-- .../core/world/level/block/TntBlockMixin.java | 2 +- .../world/level/block/TripWireBlockMixin.java | 2 +- .../level/block/WitherSkullBlockMixin.java | 4 +- .../AbstractFurnaceBlockEntityMixin.java | 4 +- .../block/entity/BeehiveBlockEntityMixin.java | 5 +- .../level/block/entity/BlockEntityMixin.java | 6 +- .../world/level/chunk/ChunkAccessMixin.java | 82 +++++++++++++ .../level/chunk/ChunkBiomeContainerMixin.java | 28 ----- .../world/level/chunk/LevelChunkMixin.java | 49 +++----- .../level/chunk/LevelChunkSectionMixin.java | 24 ++++ .../level/chunk/storage/ChunkLoaderMixin.java | 8 +- .../chunk/storage/ChunkSerializerMixin.java | 38 ++++++ .../chunk/storage/RegionFileCacheMixin.java | 13 +++ .../level/levelgen/ChunkGeneratorMixin.java | 23 ++-- .../NoiseBasedChunkGeneratorMixin.java | 53 --------- .../world/level/portal/PortalForcerMixin.java | 11 +- ... MapItemSavedData_HoldingPlayerMixin.java} | 4 +- ...pawnerMixin.java => BaseSpawnerMixin.java} | 33 ++++-- .../spawner/WorldEntitySpawnerMixin.java | 2 +- ...titySpawner_EntityDensityManagerMixin.java | 7 +- .../world/storage/DerivedWorldInfoMixin.java | 16 +-- ...ixin.java => LevelStorageSourceMixin.java} | 21 ++-- ...torageSource_LevelStorageAccessMixin.java} | 19 +-- .../forge/FMLWorldPersistenceHookMixin.java | 5 +- .../common/mixin/forge/NetworkHooksMixin.java | 4 +- .../mixin/forge/PacketDistributorMixin.java | 2 +- .../mixin/optimization/dfu/MainMixin_DFU.java | 22 ++++ .../dfu/MinecraftServerMixin_DFU.java | 21 ---- .../stream/GoalSelectorMixin.java | 109 ------------------ .../stream/ITaskQueue_PriorityMixin.java | 30 ----- .../common/mod/ArclightConnector.java | 3 - .../arclight/common/mod/ArclightMod.java | 4 +- .../common/mod/server/ArclightServer.java | 12 +- .../common/mod/server/BukkitRegistry.java | 18 +-- .../mod/util/ArclightBlockSnapshot.java | 2 +- .../mod/util/ArclightSpecialRecipe.java | 2 +- .../resources/META-INF/accesstransformer.cfg | 35 +++++- .../main/resources/mixins.arclight.core.json | 22 ++-- ....arclight.impl.forge.optimization.dfu.json | 2 +- ...clight.impl.forge.optimization.stream.json | 11 -- arclight-forge/build.gradle | 16 +-- .../io/izzel/arclight/server/Launcher.java | 4 +- .../boot/mod/ArclightLocator_Forge.java | 15 ++- build.gradle | 12 +- .../forgeinstaller/ForgeInstaller.java | 3 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../arclight/i18n/conf/OptimizationSpec.java | 7 -- 115 files changed, 741 insertions(+), 780 deletions(-) rename appveyor-17.yml => appveyor-18.yml (93%) create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/chunk/ChunkAccessBridge.java create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/chunk/LevelChunkSectionBridge.java rename arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/{SaveFormatBridge.java => LevelStorageSourceBridge.java} (76%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/{TicketManagerMixin.java => DistanceManagerMixin.java} (98%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/{IBlockReaderMixin.java => BlockGetterMixin.java} (91%) delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/PaintingMixin.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/GrassBlockMixin.java create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PointedDripstoneBlockMixin.java rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/{PortalSizeMixin.java => PortalShapeMixin.java} (90%) create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkAccessMixin.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkBiomeContainerMixin.java create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/LevelChunkSectionMixin.java create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/ChunkSerializerMixin.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/NoiseBasedChunkGeneratorMixin.java rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/saveddata/maps/{MapData_MapInfoMixin.java => MapItemSavedData_HoldingPlayerMixin.java} (93%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/{AbstractSpawnerMixin.java => BaseSpawnerMixin.java} (77%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/{SaveFormatMixin.java => LevelStorageSourceMixin.java} (63%) rename arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/{SaveFormat_LevelSaveMixin.java => LevelStorageSource_LevelStorageAccessMixin.java} (82%) create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/dfu/MainMixin_DFU.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/dfu/MinecraftServerMixin_DFU.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/stream/GoalSelectorMixin.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/stream/ITaskQueue_PriorityMixin.java delete mode 100644 arclight-common/src/main/resources/mixins.arclight.impl.forge.optimization.stream.json diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 863def9f..290e591e 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -18,10 +18,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 16 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: '16' + java-version: '17' - name: Cache Gradle User Files uses: actions/cache@v1 with: diff --git a/README.md b/README.md index 752f319a..1775e5e8 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ A Bukkit server implementation utilizing Mixin. | Minecraft | Forge | Status | Build | | :----: | :----: | :---: | :---: | -| 1.18.x | 38.0.4 | - | - | -| 1.17.x | 37.1.0 | LEGACY | [![1.17 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-17?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-17) | +| 1.18.x | 38.0.12 | ACTIVE | [![1.18 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-18?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-18) | +| 1.17.x | 37.1.0 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.17/1.0.1) | [![1.17 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-17?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-17) | | 1.16.x | 36.2.0 | ACTIVE | [![1.16 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-16?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-16) | | 1.15.x | 31.2.48 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.15/1.0.19) | [![1.15 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-15?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-15) | | 1.14.x | 28.2.0 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.0.6) | [![1.14 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight) | diff --git a/appveyor-17.yml b/appveyor-18.yml similarity index 93% rename from appveyor-17.yml rename to appveyor-18.yml index 24506a52..d002ea94 100644 --- a/appveyor-17.yml +++ b/appveyor-18.yml @@ -1,9 +1,9 @@ version: '{branch}-{build}' image: - - 'Visual Studio 2019' + - 'Visual Studio 2022' branches: only: - - 1.17 + - 1.18 environment: JAVA_HOME: C:\Program Files\Java\jdk16 cache: diff --git a/arclight-common/build.gradle b/arclight-common/build.gradle index dc2f4bbe..99265f44 100644 --- a/arclight-common/build.gradle +++ b/arclight-common/build.gradle @@ -24,7 +24,7 @@ apply plugin: 'io.izzel.arclight' arclight { mcVersion = minecraftVersion forgeVersion = project.ext.forgeVersion - bukkitVersion = 'v1_17_R1' + bukkitVersion = 'v1_18_R1' wipeVersion = true reobfVersion = true accessTransformer = project.file('bukkit.at') @@ -35,10 +35,11 @@ configurations { embed } -java.toolchain.languageVersion = JavaLanguageVersion.of(16) +java.toolchain.languageVersion = JavaLanguageVersion.of(17) minecraft { - mappings channel: 'parchment', version: "2021.08.22-$minecraftVersion" + //mappings channel: 'parchment', version: "2021.08.22-$minecraftVersion" + mappings channel: 'official', version: '1.18' accessTransformer = project.file('src/main/resources/META-INF/accesstransformer.cfg') } @@ -54,7 +55,7 @@ repositories { dependencies { minecraft "net.minecraftforge:forge:$minecraftVersion-$forgeVersion" implementation "org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT@jar" - implementation 'org.jetbrains:annotations:19.0.0' + implementation 'org.jetbrains:annotations:22.0.0' implementation "org.spongepowered:mixin:$mixinVersion" annotationProcessor 'org.spongepowered:mixin:0.8.3:processor' diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/entity/AreaEffectCloudEntityBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/entity/AreaEffectCloudEntityBridge.java index a6b6c5ce..964581e2 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/entity/AreaEffectCloudEntityBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/entity/AreaEffectCloudEntityBridge.java @@ -3,11 +3,4 @@ package io.izzel.arclight.common.bridge.core.entity; public interface AreaEffectCloudEntityBridge { void bridge$refreshEffects(); - - interface Hack { - - String getType(); - - void setType(final String string); - } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/entity/projectile/ArrowEntityBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/entity/projectile/ArrowEntityBridge.java index 045d25e2..5eaa54fd 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/entity/projectile/ArrowEntityBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/entity/projectile/ArrowEntityBridge.java @@ -7,11 +7,4 @@ public interface ArrowEntityBridge extends EntityBridge { void bridge$refreshEffects(); boolean bridge$isTipped(); - - interface Hack { - - String getType(); - - void setType(final String string); - } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/TeleporterBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/TeleporterBridge.java index 5e8b8dec..ab2c171e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/TeleporterBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/TeleporterBridge.java @@ -1,14 +1,16 @@ package io.izzel.arclight.common.bridge.core.world; -import java.util.Optional; import net.minecraft.BlockUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.border.WorldBorder; + +import java.util.Optional; public interface TeleporterBridge { - Optional bridge$findPortal(BlockPos pos, int searchRadius); + Optional bridge$findPortal(BlockPos pos, WorldBorder worldborder, int searchRadius); Optional bridge$createPortal(BlockPos pos, Direction.Axis axis, Entity entity, int createRadius); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/WorldBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/WorldBridge.java index 2b7e3b87..9b13b644 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/WorldBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/WorldBridge.java @@ -3,7 +3,7 @@ package io.izzel.arclight.common.bridge.core.world; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.dimension.LevelStem; import org.bukkit.craftbukkit.v.CraftServer; import org.bukkit.craftbukkit.v.CraftWorld; import org.bukkit.generator.ChunkGenerator; @@ -41,5 +41,5 @@ public interface WorldBridge extends IWorldWriterBridge, IWorldBridge { long bridge$ticksPerWaterUndergroundSpawns(); - ResourceKey bridge$getTypeKey(); + ResourceKey bridge$getTypeKey(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/chunk/ChunkAccessBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/chunk/ChunkAccessBridge.java new file mode 100644 index 00000000..ec6b2e29 --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/chunk/ChunkAccessBridge.java @@ -0,0 +1,8 @@ +package io.izzel.arclight.common.bridge.core.world.chunk; + +import org.bukkit.persistence.PersistentDataContainer; + +public interface ChunkAccessBridge { + + PersistentDataContainer bridge$getPersistentDataContainer(); +} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/chunk/LevelChunkSectionBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/chunk/LevelChunkSectionBridge.java new file mode 100644 index 00000000..3bcd140b --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/chunk/LevelChunkSectionBridge.java @@ -0,0 +1,8 @@ +package io.izzel.arclight.common.bridge.core.world.chunk; + +import net.minecraft.world.level.biome.Biome; + +public interface LevelChunkSectionBridge { + + void bridge$setBiome(int x, int y, int z, Biome biome); +} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/level/levelgen/ChunkGeneratorBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/level/levelgen/ChunkGeneratorBridge.java index 2f251287..a305325f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/level/levelgen/ChunkGeneratorBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/level/levelgen/ChunkGeneratorBridge.java @@ -1,7 +1,6 @@ package io.izzel.arclight.common.bridge.core.world.level.levelgen; import net.minecraft.server.level.WorldGenRegion; -import net.minecraft.world.level.StructureFeatureManager; import net.minecraft.world.level.biome.BiomeSource; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.levelgen.WorldgenRandom; @@ -10,8 +9,6 @@ import java.util.Random; public interface ChunkGeneratorBridge { - void bridge$addDecorations(WorldGenRegion region, StructureFeatureManager structureManager, boolean vanilla); - void bridge$buildBedrock(ChunkAccess chunkAccess, Random random); WorldgenRandom bridge$buildSurface(WorldGenRegion region, ChunkAccess chunkAccess); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/server/ChunkMapBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/server/ChunkMapBridge.java index 6ded102a..a0f75f97 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/server/ChunkMapBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/server/ChunkMapBridge.java @@ -13,8 +13,6 @@ public interface ChunkMapBridge { Iterable bridge$getLoadedChunksIterable(); - boolean bridge$isOutsideSpawningRadius(ChunkPos chunkPosIn); - void bridge$tickEntityTracker(); ArclightCallbackExecutor bridge$getCallbackExecutor(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/spawner/WorldEntitySpawnerBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/spawner/WorldEntitySpawnerBridge.java index 6855d964..48f77080 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/spawner/WorldEntitySpawnerBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/spawner/WorldEntitySpawnerBridge.java @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.ChunkAccess; public interface WorldEntitySpawnerBridge { @@ -12,7 +13,7 @@ public interface WorldEntitySpawnerBridge { void bridge$updateDensity(Mob mobEntity, ChunkAccess chunk); - boolean bridge$canSpawn(MobCategory classification, int limit); + boolean bridge$canSpawn(MobCategory classification, ChunkPos pos, int limit); boolean bridge$canSpawn(EntityType entityType, BlockPos pos, ChunkAccess chunk); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/DerivedWorldInfoBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/DerivedWorldInfoBridge.java index 8eedf866..c63dd1c9 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/DerivedWorldInfoBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/DerivedWorldInfoBridge.java @@ -1,12 +1,12 @@ package io.izzel.arclight.common.bridge.core.world.storage; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.storage.ServerLevelData; public interface DerivedWorldInfoBridge { ServerLevelData bridge$getDelegate(); - void bridge$setDimType(ResourceKey typeKey); + void bridge$setDimType(ResourceKey typeKey); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/SaveFormatBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/LevelStorageSourceBridge.java similarity index 76% rename from arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/SaveFormatBridge.java rename to arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/LevelStorageSourceBridge.java index 1b48697f..b7ad26ed 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/SaveFormatBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/LevelStorageSourceBridge.java @@ -1,16 +1,19 @@ package io.izzel.arclight.common.bridge.core.world.storage; -import java.io.IOException; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.storage.LevelStorageSource; -public interface SaveFormatBridge { +import java.io.IOException; + +public interface LevelStorageSourceBridge { LevelStorageSource.LevelStorageAccess bridge$getLevelSave(String saveName, ResourceKey world) throws IOException; - interface LevelSaveBridge { + interface LevelStorageAccessBridge { void bridge$setDimType(ResourceKey typeKey); + + ResourceKey bridge$getTypeKey(); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftWorldMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftWorldMixin.java index efa635d6..b50a64dc 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftWorldMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftWorldMixin.java @@ -23,6 +23,6 @@ public abstract class CraftWorldMixin { */ @Overwrite public File getWorldFolder() { - return ((ServerWorldBridge) this.world).bridge$getConvertable().getDimensionPath(this.world.dimension()); + return ((ServerWorldBridge) this.world).bridge$getConvertable().getDimensionPath(this.world.dimension()).toFile(); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/LibraryLoaderMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/LibraryLoaderMixin.java index 452dd534..b4d00008 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/LibraryLoaderMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/LibraryLoaderMixin.java @@ -12,7 +12,7 @@ import java.net.URLClassLoader; public class LibraryLoaderMixin { @Redirect(method = "createLoader", at = @At(value = "NEW", target = "java/net/URLClassLoader")) - private URLClassLoader arclight$useRemapped(URL[] urls) { - return new RemappingURLClassLoader(urls); + private URLClassLoader arclight$useRemapped(URL[] urls, ClassLoader loader) { + return new RemappingURLClassLoader(urls, loader); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandsMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandsMixin.java index fd92f7df..1b100580 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandsMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandsMixin.java @@ -41,7 +41,7 @@ public abstract class CommandsMixin { this.dispatcher.setConsumer((context, b, i) -> context.getSource().onCommandComplete(context, b, i)); } - public int a(CommandSourceStack source, String command, String label, boolean strip) { + public int performCommand(CommandSourceStack source, String command, String label, boolean strip) { return this.performCommand(source, command); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerHandshakeNetHandlerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerHandshakeNetHandlerMixin.java index 236f8cda..cf8e1833 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerHandshakeNetHandlerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerHandshakeNetHandlerMixin.java @@ -16,7 +16,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerHandshakePacketListenerImpl; import net.minecraft.server.network.ServerLoginPacketListenerImpl; import net.minecraft.server.network.ServerStatusPacketListenerImpl; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraftforge.server.ServerLifecycleHooks; import org.apache.logging.log4j.LogManager; import org.bukkit.Bukkit; import org.spigotmc.SpigotConfig; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java index a3206c2f..4d97d97d 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java @@ -198,7 +198,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB private boolean justTeleported; private boolean hasMoved; - public CraftPlayer getPlayer() { + public CraftPlayer getCraftPlayer() { return (this.player == null) ? null : ((ServerPlayerEntityBridge) this.player).bridge$getBukkitEntity(); } @@ -234,7 +234,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB return; } String leaveMessage = ChatFormatting.YELLOW + this.player.getScoreboardName() + " left the game."; - PlayerKickEvent event = new PlayerKickEvent(getPlayer(), s, leaveMessage); + PlayerKickEvent event = new PlayerKickEvent(getCraftPlayer(), s, leaveMessage); if (this.cserver.getServer().isRunning()) { this.cserver.getPluginManager().callEvent(event); } @@ -324,7 +324,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB flag2 = true; LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", entity.getName().getString(), this.player.getName().getString(), Math.sqrt(d11)); } - Location curPos = this.getPlayer().getLocation(); + Location curPos = this.getCraftPlayer().getLocation(); entity.absMoveTo(d4, d5, d6, f, f2); this.player.absMoveTo(d4, d5, d6, this.player.getYRot(), this.player.getXRot()); boolean flag3 = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625)); @@ -334,7 +334,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB this.connection.send(new ClientboundMoveVehiclePacket(entity)); return; } - Player player = this.getPlayer(); + Player player = this.getCraftPlayer(); if (!hasMoved) { lastPosX = curPos.getX(); lastPosY = curPos.getY(); @@ -370,7 +370,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB ((ServerPlayerEntityBridge) this.player).bridge$getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); return; } - if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) { + if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { this.justTeleported = false; return; } @@ -407,7 +407,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB CraftEventFactory.callTradeSelectEvent(this.player, i, (MerchantMenu) container); } - @Inject(method = "handleEditBook", cancellable = true, at = @At("HEAD")) + @Inject(method = "handleEditBook", at = @At("HEAD")) private void arclight$editBookSpam(ServerboundEditBookPacket packetIn, CallbackInfo ci) { if (this.lastBookTick == 0) { this.lastBookTick = ArclightConstants.currentTick - 20; @@ -589,7 +589,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB this.teleport(d3, d4, d5, f, f1); } else { this.player.absMoveTo(prevX, prevY, prevZ, prevYaw, prevPitch); - CraftPlayer player = this.getPlayer(); + CraftPlayer player = this.getCraftPlayer(); Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); Location to = player.getLocation().clone(); if (packetplayinflying.hasPos) { @@ -618,10 +618,10 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB return; } if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { - getPlayer().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); + getCraftPlayer().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); return; } - if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) { + if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { this.justTeleported = false; return; } @@ -670,7 +670,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND); CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack); CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(InteractionHand.MAIN_HAND)); - PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(this.getPlayer(), mainHand.clone(), offHand.clone()); + PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(this.getCraftPlayer(), mainHand.clone(), offHand.clone()); this.cserver.getPluginManager().callEvent(swapItemsEvent); if (swapItemsEvent.isCancelled()) { return; @@ -823,7 +823,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB @Inject(method = "handleResourcePackResponse", at = @At("RETURN")) private void arclight$handleResourcePackStatus(ServerboundResourcePackPacket packetIn, CallbackInfo ci) { - this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetIn.action.ordinal()])); + this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetIn.action.ordinal()])); } @Inject(method = "onDisconnect", cancellable = true, at = @At("HEAD")) @@ -855,7 +855,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB return; } if (packetIn instanceof ClientboundSetDefaultSpawnPositionPacket packet6) { - ((ServerPlayerEntityBridge) this.player).bridge$setCompassTarget(new Location(this.getPlayer().getWorld(), packet6.pos.getX(), packet6.pos.getY(), packet6.pos.getZ())); + ((ServerPlayerEntityBridge) this.player).bridge$setCompassTarget(new Location(this.getCraftPlayer().getWorld(), packet6.pos.getX(), packet6.pos.getY(), packet6.pos.getZ())); } } @@ -870,7 +870,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB return; } if (packet.getSlot() >= 0 && packet.getSlot() < net.minecraft.world.entity.player.Inventory.getSelectionSize()) { - PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.getInventory().selected, packet.getSlot()); + PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getCraftPlayer(), this.player.getInventory().selected, packet.getSlot()); this.cserver.getPluginManager().callEvent(event); if (event.isCancelled()) { this.send(new ClientboundSetCarriedItemPacket(this.player.getInventory().selected)); @@ -926,9 +926,9 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } } else if (s.isEmpty()) { LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message"); - } else if (this.getPlayer().isConversing()) { + } else if (this.getCraftPlayer().isConversing()) { String conversationInput = s; - ((MinecraftServerBridge) this.server).bridge$queuedProcess(() -> this.getPlayer().acceptConversationInput(conversationInput)); + ((MinecraftServerBridge) this.server).bridge$queuedProcess(() -> this.getCraftPlayer().acceptConversationInput(conversationInput)); } else if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) { this.send(new ClientboundChatPacket((new TranslatableComponent("chat.cannotSend")).withStyle(ChatFormatting.RED), ChatType.SYSTEM, Util.NIL_UUID)); } else { @@ -979,7 +979,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB if (!async && s.startsWith("/")) { this.handleCommand(s); } else if (this.player.getChatVisibility() != ChatVisiblity.SYSTEM) { - Player thisPlayer = this.getPlayer(); + Player thisPlayer = this.getCraftPlayer(); AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, thisPlayer, s, new LazyPlayerSet(this.server)); this.cserver.getPluginManager().callEvent(event); if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) { @@ -1068,7 +1068,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB if (SpigotConfig.logCommands) { LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s); } - CraftPlayer player = this.getPlayer(); + CraftPlayer player = this.getCraftPlayer(); PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet(this.server)); this.cserver.getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -1111,7 +1111,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB if (result == null || result.getType() != HitResult.Type.BLOCK) { CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); } - PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer()); + PlayerAnimationEvent event = new PlayerAnimationEvent(this.getCraftPlayer()); this.cserver.getPluginManager().callEvent(event); if (event.isCancelled()) { return; @@ -1126,13 +1126,13 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB return; } if (packetIn.getAction() == ServerboundPlayerCommandPacket.Action.PRESS_SHIFT_KEY || packetIn.getAction() == ServerboundPlayerCommandPacket.Action.RELEASE_SHIFT_KEY) { - PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetIn.getAction() == ServerboundPlayerCommandPacket.Action.PRESS_SHIFT_KEY); + PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getCraftPlayer(), packetIn.getAction() == ServerboundPlayerCommandPacket.Action.PRESS_SHIFT_KEY); this.cserver.getPluginManager().callEvent(event); if (event.isCancelled()) { ci.cancel(); } } else if (packetIn.getAction() == ServerboundPlayerCommandPacket.Action.START_SPRINTING || packetIn.getAction() == ServerboundPlayerCommandPacket.Action.STOP_SPRINTING) { - PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getPlayer(), packetIn.getAction() == ServerboundPlayerCommandPacket.Action.START_SPRINTING); + PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getCraftPlayer(), packetIn.getAction() == ServerboundPlayerCommandPacket.Action.START_SPRINTING); this.cserver.getPluginManager().callEvent(e2); if (e2.isCancelled()) { ci.cancel(); @@ -1159,6 +1159,9 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB this.player.resetLastActionTime(); this.player.setShiftKeyDown(packetIn.isUsingSecondaryAction()); if (entity != null) { + if (!world.getWorldBorder().isWithinBounds(entity.blockPosition())) { + return; + } double d0 = 36.0D; if (this.player.distanceToSqr(entity) < 36.0D) { class Handler implements ServerboundInteractPacket.Handler { @@ -1214,14 +1217,14 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB @Override public void onInteraction(InteractionHand hand) { this.performInteraction(hand, net.minecraft.world.entity.player.Player::interactOn, - new PlayerInteractEntityEvent(getPlayer(), ((EntityBridge) entity).bridge$getBukkitEntity(), + new PlayerInteractEntityEvent(getCraftPlayer(), ((EntityBridge) entity).bridge$getBukkitEntity(), (hand == InteractionHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); } @Override public void onInteraction(InteractionHand hand, Vec3 vec) { this.performInteraction(hand, (player, e, h) -> e.interactAt(player, vec, h), - new PlayerInteractAtEntityEvent(getPlayer(), ((EntityBridge) entity).bridge$getBukkitEntity(), + new PlayerInteractAtEntityEvent(getCraftPlayer(), ((EntityBridge) entity).bridge$getBukkitEntity(), new org.bukkit.util.Vector(vec.x, vec.y, vec.z), (hand == InteractionHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); } @@ -1648,10 +1651,10 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB private Component[] arclight$lines; - @Inject(method = "updateSignText", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/entity/SignBlockEntity;isEditable()Z")) + @Inject(method = "updateSignText", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/entity/SignBlockEntity;isEditable()Z")) public void arclight$onSignChangePre(ServerboundSignUpdatePacket p_244542_1_, List p_244542_2_, CallbackInfo ci) { String[] lines = p_244542_2_.toArray(new String[0]); - Player player = getPlayer(); + Player player = getCraftPlayer(); CraftBlock block = CraftBlock.at(this.player.level, p_244542_1_.getPos()); String[] bukkitLines = new String[lines.length]; for (int i = 0; i < lines.length; i++) { @@ -1696,7 +1699,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); if (this.player.getAbilities().mayfly && this.player.getAbilities().flying != packet.isFlying()) { - PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(getPlayer(), packet.isFlying()); + PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(getCraftPlayer(), packet.isFlying()); this.cserver.getPluginManager().callEvent(event); if (!event.isCancelled()) { this.player.getAbilities().flying = packet.isFlying(); @@ -1709,14 +1712,14 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register"); private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister"); - @Inject(method = "handleCustomPayload", cancellable = true, at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraftforge/fmllegacy/network/NetworkHooks;onCustomPayload(Lnet/minecraftforge/fmllegacy/network/ICustomPacket;Lnet/minecraft/network/Connection;)Z")) + @Inject(method = "handleCustomPayload", cancellable = true, at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraftforge/network/NetworkHooks;onCustomPayload(Lnet/minecraftforge/network/ICustomPacket;Lnet/minecraft/network/Connection;)Z")) private void arclight$customPayload(ServerboundCustomPayloadPacket packet, CallbackInfo ci) { if (packet.identifier.equals(CUSTOM_REGISTER)) { try { String channels = packet.data.toString(Charsets.UTF_8); for (String channel : channels.split("\0")) { if (!StringUtil.isNullOrEmpty(channel)) { - this.getPlayer().addChannel(channel); + this.getCraftPlayer().addChannel(channel); } } } catch (Exception ex) { @@ -1729,7 +1732,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB final String channels = packet.data.toString(Charsets.UTF_8); for (String channel : channels.split("\0")) { if (!StringUtil.isNullOrEmpty(channel)) { - this.getPlayer().removeChannel(channel); + this.getCraftPlayer().removeChannel(channel); } } } catch (Exception ex) { @@ -1769,9 +1772,9 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB public void teleport(double x, double y, double z, float yaw, float pitch, Set relativeSet) { PlayerTeleportEvent.TeleportCause cause = arclight$cause == null ? PlayerTeleportEvent.TeleportCause.UNKNOWN : arclight$cause; arclight$cause = null; - Player player = this.getPlayer(); + Player player = this.getCraftPlayer(); Location from = player.getLocation(); - Location to = new Location(this.getPlayer().getWorld(), x, y, z, yaw, pitch); + Location to = new Location(this.getCraftPlayer().getWorld(), x, y, z, yaw, pitch); if (!from.equals(to)) { PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause); this.cserver.getPluginManager().callEvent(event); @@ -1795,11 +1798,11 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB this.internalTeleport(x, y, z, yaw, pitch, relativeSet, false); } - public void a(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { - this.a(d0, d1, d2, f, f1, Collections.emptySet(), cause); + public void teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { + this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), cause); } - public void a(double d0, double d1, double d2, float f, float f1, Set set, PlayerTeleportEvent.TeleportCause cause) { + public void teleport(double d0, double d1, double d2, float f, float f1, Set set, PlayerTeleportEvent.TeleportCause cause) { bridge$pushTeleportCause(cause); this.teleport(d0, d1, d2, f, f1, set); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerStatusNetHandlerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerStatusNetHandlerMixin.java index f983eb3d..920d65e8 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerStatusNetHandlerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerStatusNetHandlerMixin.java @@ -36,17 +36,23 @@ public class ServerStatusNetHandlerMixin { List profiles = new ArrayList<>(players.length); Object[] array; for (int length = (array = players).length, i = 0; i < length; ++i) { - Object player = array[i]; + ServerPlayer player = (ServerPlayer) array[i]; if (player != null) { - profiles.add(((ServerPlayer) player).getGameProfile()); + if (player.allowsListing()) { + profiles.add(player.getGameProfile()); + } else { + profiles.add(MinecraftServer.ANONYMOUS_PLAYER_PROFILE); + } } } ServerStatus.Players playerSample = new ServerStatus.Players(event.getMaxPlayers(), profiles.size()); - if (!profiles.isEmpty()) { - Collections.shuffle(profiles); - profiles = profiles.subList(0, Math.min(profiles.size(), SpigotConfig.playerSample)); + if (!this.server.hidesOnlinePlayers()) { + if (!profiles.isEmpty()) { + Collections.shuffle(profiles); + profiles = profiles.subList(0, Math.min(profiles.size(), SpigotConfig.playerSample)); + } + playerSample.setSample(profiles.toArray(new GameProfile[0])); } - playerSample.setSample(profiles.toArray(new GameProfile[0])); ServerStatus ping = new ServerStatus(); ping.setFavicon(event.icon.value); ping.setDescription(CraftChatMessage.fromString(event.getMotd(), true)[0]); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/game/CChatMessagePacketMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/game/CChatMessagePacketMixin.java index 87dfc791..ca6d4504 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/game/CChatMessagePacketMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/game/CChatMessagePacketMixin.java @@ -22,7 +22,7 @@ public class CChatMessagePacketMixin { new ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").build() ); - @Inject(method = "handle", cancellable = true, at = @At("HEAD")) + @Inject(method = "handle(Lnet/minecraft/network/protocol/game/ServerGamePacketListener;)V", cancellable = true, at = @At("HEAD")) private void arclight$asyncChat(ServerGamePacketListener handler, CallbackInfo ci) { if (!this.message.startsWith("/")) { executors.submit(() -> handler.handleChat((ServerboundChatPacket) (Object) this)); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/handshake/CHandshakePacketMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/handshake/CHandshakePacketMixin.java index 1a9e1205..688c8b2f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/handshake/CHandshakePacketMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/handshake/CHandshakePacketMixin.java @@ -4,8 +4,8 @@ import com.google.gson.Gson; import com.mojang.authlib.properties.Property; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.handshake.ClientIntentionPacket; -import net.minecraftforge.fmllegacy.network.FMLNetworkConstants; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkConstants; +import net.minecraftforge.network.NetworkHooks; import org.spigotmc.SpigotConfig; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -24,10 +24,10 @@ public class CHandshakePacketMixin { return packetBuffer.readUtf(Short.MAX_VALUE); } - @Redirect(method = "(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraftforge/fmllegacy/network/NetworkHooks;getFMLVersion(Ljava/lang/String;)Ljava/lang/String;")) + @Redirect(method = "(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraftforge/network/NetworkHooks;getFMLVersion(Ljava/lang/String;)Ljava/lang/String;")) private String arclight$readFromProfile(String ip) { String fmlVersion = NetworkHooks.getFMLVersion(ip); - if (SpigotConfig.bungee && !Objects.equals(fmlVersion, FMLNetworkConstants.NETVERSION)) { + if (SpigotConfig.bungee && !Objects.equals(fmlVersion, NetworkConstants.NETVERSION)) { String[] split = ip.split("\0"); if (split.length == 4) { Property[] properties = GSON.fromJson(split[3], Property[].class); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/MinecraftServerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/MinecraftServerMixin.java index cb541bff..8c17e942 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/MinecraftServerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/MinecraftServerMixin.java @@ -38,6 +38,7 @@ import net.minecraft.server.packs.repository.PackRepository; import net.minecraft.server.players.GameProfileCache; import net.minecraft.util.Unit; import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.util.profiling.jfr.JvmProfiler; import net.minecraft.util.thread.ReentrantBlockableEventLoop; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.DataPackConfig; @@ -50,8 +51,8 @@ import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.WorldData; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.world.StructureSpawnManager; -import net.minecraftforge.fmllegacy.BrandingControl; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraftforge.internal.BrandingControl; +import net.minecraftforge.server.ServerLifecycleHooks; import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -124,6 +125,8 @@ public abstract class MinecraftServerMixin extends ReentrantBlockableEventLoop getChunks(); - @Shadow abstract boolean noPlayersCloseForSpawning(ChunkPos chunkPosIn); @Shadow protected abstract void tick(); - @Shadow @Final @Mutable public ChunkGenerator generator; + @Shadow @Mutable public ChunkGenerator generator; @Invoker("tick") public abstract void bridge$tick(BooleanSupplier hasMoreTime); @Invoker("setViewDistance") public abstract void bridge$setViewDistance(int i); // @formatter:on @Redirect(method = "readChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;dimension()Lnet/minecraft/resources/ResourceKey;")) - private ResourceKey arclight$useTypeKey(ServerLevel serverWorld) { + private ResourceKey arclight$useTypeKey(ServerLevel serverWorld) { return ((WorldBridge) serverWorld).bridge$getTypeKey(); } @@ -56,11 +53,6 @@ public abstract class ChunkMapMixin implements ChunkMapBridge { return this.getChunks(); } - @Override - public boolean bridge$isOutsideSpawningRadius(ChunkPos chunkPosIn) { - return this.noPlayersCloseForSpawning(chunkPosIn); - } - @Override public void bridge$tickEntityTracker() { this.tick(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/TicketManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/DistanceManagerMixin.java similarity index 98% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/TicketManagerMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/DistanceManagerMixin.java index a935b59f..08b6fcb2 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/TicketManagerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/DistanceManagerMixin.java @@ -23,7 +23,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.Iterator; @Mixin(DistanceManager.class) -public abstract class TicketManagerMixin implements TicketManagerBridge { +public abstract class DistanceManagerMixin implements TicketManagerBridge { // @formatter:off @Shadow private long ticketTickCounter; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerChunkCacheMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerChunkCacheMixin.java index 2108baa9..f4d979e5 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerChunkCacheMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerChunkCacheMixin.java @@ -18,7 +18,6 @@ import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.storage.LevelData; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; @@ -28,7 +27,6 @@ import org.spongepowered.asm.mixin.injection.Redirect; import javax.annotation.Nullable; import java.io.IOException; -import java.util.function.Consumer; @Mixin(ServerChunkCache.class) public abstract class ServerChunkCacheMixin implements ServerChunkProviderBridge { @@ -41,12 +39,6 @@ public abstract class ServerChunkCacheMixin implements ServerChunkProviderBridge @Shadow @Final private DistanceManager distanceManager; @Shadow protected abstract void clearCache(); @Shadow @Nullable protected abstract ChunkHolder getVisibleChunkIfPresent(long chunkPosIn); - @Shadow abstract boolean runDistanceManagerUpdates(); - @Shadow protected abstract boolean chunkAbsent(@Nullable ChunkHolder chunkHolderIn, int p_217224_2_); - @Shadow public boolean spawnEnemies; - @Shadow public boolean spawnFriendlies; - @Shadow protected abstract void getFullChunk(long p_241098_1_, Consumer p_241098_3_); - @Shadow @Final @Mutable public ChunkGenerator generator; @Invoker("runDistanceManagerUpdates") public abstract boolean bridge$tickDistanceManager(); @Accessor("lightEngine") public abstract ThreadedLevelLightEngine bridge$getLightManager(); // @formatter:on @@ -71,7 +63,6 @@ public abstract class ServerChunkCacheMixin implements ServerChunkProviderBridge @Override public void bridge$setChunkGenerator(ChunkGenerator chunkGenerator) { - this.generator = chunkGenerator; ((ChunkMapBridge) this.chunkMap).bridge$setChunkGenerator(chunkGenerator); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerLevelMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerLevelMixin.java index 73a3d4b8..2859a8f6 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerLevelMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerLevelMixin.java @@ -9,6 +9,7 @@ import io.izzel.arclight.common.bridge.core.world.WorldBridge; import io.izzel.arclight.common.bridge.core.world.server.ServerChunkProviderBridge; import io.izzel.arclight.common.bridge.core.world.server.ServerWorldBridge; import io.izzel.arclight.common.bridge.core.world.storage.DerivedWorldInfoBridge; +import io.izzel.arclight.common.bridge.core.world.storage.LevelStorageSourceBridge; import io.izzel.arclight.common.bridge.core.world.storage.MapDataBridge; import io.izzel.arclight.common.bridge.core.world.storage.WorldInfoBridge; import io.izzel.arclight.common.mixin.core.world.level.LevelMixin; @@ -41,6 +42,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.entity.PersistentEntitySectionManager; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; import net.minecraft.world.level.storage.DerivedLevelData; @@ -104,6 +106,11 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld public LevelStorageSource.LevelStorageAccess convertable; public UUID uuid; + @Override + public ResourceKey getTypeKey() { + return ((LevelStorageSourceBridge.LevelStorageAccessBridge) this.convertable).bridge$getTypeKey(); + } + public void arclight$constructor(MinecraftServer server, Executor backgroundExecutor, LevelStorageSource.LevelStorageAccess levelSave, ServerLevelData serverWorldInfo, ResourceKey dimension, DimensionType dimensionType, ChunkProgressListener statusListener, ChunkGenerator chunkGenerator, boolean isDebug, long seed, List specialSpawners, boolean shouldBeTicking) { throw new RuntimeException(); } @@ -124,7 +131,7 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld private void arclight$init(MinecraftServer minecraftServer, Executor backgroundExecutor, LevelStorageSource.LevelStorageAccess levelSave, ServerLevelData worldInfo, ResourceKey dimension, DimensionType dimensionType, ChunkProgressListener statusListener, ChunkGenerator chunkGenerator, boolean isDebug, long seed, List specialSpawners, boolean shouldBeTicking, CallbackInfo ci) { this.pvpMode = minecraftServer.isPvpAllowed(); this.convertable = levelSave; - this.uuid = WorldUUID.getUUID(levelSave.getDimensionPath(this.dimension())); + this.uuid = WorldUUID.getUUID(levelSave.getDimensionPath(this.dimension()).toFile()); if (worldInfo instanceof PrimaryLevelData) { this.$$worldDataServer = (PrimaryLevelData) worldInfo; } else if (worldInfo instanceof DerivedLevelData) { @@ -132,7 +139,7 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld this.$$worldDataServer = DelegateWorldInfo.wrap(((DerivedLevelData) worldInfo)); ((DerivedWorldInfoBridge) worldInfo).bridge$setDimType(this.getTypeKey()); if (ArclightConfig.spec().getCompat().isSymlinkWorld()) { - WorldSymlink.create((DerivedLevelData) worldInfo, levelSave.getDimensionPath(this.dimension())); + WorldSymlink.create((DerivedLevelData) worldInfo, levelSave.getDimensionPath(this.dimension()).toFile()); } } ((ServerChunkProviderBridge) this.chunkSource).bridge$setViewDistance(spigotConfig.viewDistance); @@ -284,31 +291,31 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld return this.arclight$reason; } - public boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { + public boolean addFreshEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { bridge$pushAddEntityReason(reason); return addFreshEntity(entity); } @Override public boolean bridge$addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { - return addEntity(entity, reason); + return addFreshEntity(entity, reason); } - public boolean addEntitySerialized(Entity entity, CreatureSpawnEvent.SpawnReason reason) { + public boolean addWithUUID(Entity entity, CreatureSpawnEvent.SpawnReason reason) { bridge$pushAddEntityReason(reason); return addWithUUID(entity); } - public void addEntityTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) { - addEntity(entity, reason); + public void addDuringTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) { + addFreshEntity(entity, reason); } @Override public boolean bridge$addEntitySerialized(Entity entity, CreatureSpawnEvent.SpawnReason reason) { - return addEntitySerialized(entity, reason); + return addWithUUID(entity, reason); } - public boolean addAllEntitiesSafely(Entity entity, CreatureSpawnEvent.SpawnReason reason) { + public boolean tryAddFreshEntityWithPassengers(Entity entity, CreatureSpawnEvent.SpawnReason reason) { if (entity.getSelfAndPassengers().map(Entity::getUUID).anyMatch(this.entityManager::isLoaded)) { return false; } @@ -317,7 +324,7 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld @Override public boolean bridge$addAllEntitiesSafely(Entity entity, CreatureSpawnEvent.SpawnReason reason) { - return addAllEntitiesSafely(entity, reason); + return tryAddFreshEntityWithPassengers(entity, reason); } @Inject(method = "explode", cancellable = true, at = @At(value = "INVOKE", shift = At.Shift.AFTER, @@ -359,7 +366,7 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld } @Override - public BlockEntity getTileEntity(BlockPos pos, boolean validate) { + public BlockEntity getBlockEntity(BlockPos pos, boolean validate) { return this.getBlockEntity(pos); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerLevel_EntityCallbacksMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerLevel_EntityCallbacksMixin.java index 32478d98..855490b4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerLevel_EntityCallbacksMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerLevel_EntityCallbacksMixin.java @@ -8,7 +8,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.saveddata.maps.MapItemSavedData; import net.minecraft.world.level.storage.DimensionDataStorage; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraftforge.server.ServerLifecycleHooks; import org.bukkit.inventory.InventoryHolder; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -18,12 +18,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(targets = "net/minecraft/server/level/ServerLevel$EntityCallbacks") public class ServerLevel_EntityCallbacksMixin { - @Inject(method = "onTrackingStart", at = @At("RETURN")) + @Inject(method = "onTrackingStart(Lnet/minecraft/world/entity/Entity;)V", at = @At("RETURN")) private void arclight$valid(Entity entity, CallbackInfo ci) { ((EntityBridge) entity).bridge$setValid(true); } - @Inject(method = "onTrackingEnd", at = @At("HEAD")) + @Inject(method = "onTrackingEnd(Lnet/minecraft/world/entity/Entity;)V", at = @At("HEAD")) private void arclight$entityCleanup(Entity entity, CallbackInfo ci) { if (entity instanceof Player player) { for (ServerLevel serverLevel : ServerLifecycleHooks.getCurrentServer().levels.values()) { @@ -43,7 +43,7 @@ public class ServerLevel_EntityCallbacksMixin { } } - @Inject(method = "onTrackingEnd", at = @At("RETURN")) + @Inject(method = "onTrackingEnd(Lnet/minecraft/world/entity/Entity;)V", at = @At("RETURN")) private void arclight$invalid(Entity entity, CallbackInfo ci) { ((EntityBridge) entity).bridge$setValid(true); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerListMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerListMixin.java index efb418f9..291ed3f0 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerListMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/PlayerListMixin.java @@ -30,6 +30,7 @@ import net.minecraft.network.protocol.game.ClientboundRespawnPacket; import net.minecraft.network.protocol.game.ClientboundSetChunkCacheRadiusPacket; import net.minecraft.network.protocol.game.ClientboundSetDefaultSpawnPositionPacket; import net.minecraft.network.protocol.game.ClientboundSetExperiencePacket; +import net.minecraft.network.protocol.game.ClientboundSetSimulationDistancePacket; import net.minecraft.network.protocol.game.ClientboundSoundPacket; import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket; import net.minecraft.resources.ResourceKey; @@ -60,7 +61,7 @@ import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.level.storage.LevelResource; import net.minecraft.world.level.storage.PlayerDataStorage; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.fmllegacy.hooks.BasicEventHooks; +import net.minecraftforge.event.ForgeEventFactory; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v.CraftServer; @@ -154,6 +155,11 @@ public abstract class PlayerListMixin implements PlayerListBridge { return ((WorldBridge) playerIn.getLevel()).bridge$spigotConfig().viewDistance; } + @Redirect(method = "placeNewPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/server/players/PlayerList;simulationDistance:I")) + private int arclight$spigotSimDistance(PlayerList instance, Connection netManager, ServerPlayer playerIn) { + return ((WorldBridge) playerIn.getLevel()).bridge$spigotConfig().simulationDistance; + } + @Eject(method = "placeNewPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V")) private void arclight$playerJoin(PlayerList playerList, Component component, ChatType chatType, UUID uuid, CallbackInfo ci, Connection netManager, ServerPlayer playerIn) { PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(((ServerPlayerEntityBridge) playerIn).bridge$getBukkitEntity(), CraftChatMessage.fromComponent(component)); @@ -173,13 +179,6 @@ public abstract class PlayerListMixin implements PlayerListBridge { } } - @Inject(method = "setLevel", cancellable = true, at = @At("HEAD")) - private void arclight$returnIfSet(ServerLevel world, CallbackInfo ci) { - if (this.playerIo != null) { - ci.cancel(); - } - } - @Inject(method = "save", cancellable = true, at = @At("HEAD")) private void arclight$returnIfNotPersist(ServerPlayer playerIn, CallbackInfo ci) { if (!((ServerPlayerEntityBridge) playerIn).bridge$isPersist()) { @@ -250,7 +249,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { } // todo check these two - public ServerPlayer moveToWorld(ServerPlayer playerIn, ServerLevel worldIn, boolean flag, Location location, boolean avoidSuffocation) { + public ServerPlayer respawn(ServerPlayer playerIn, ServerLevel worldIn, boolean flag, Location location, boolean avoidSuffocation) { playerIn.stopRiding(); this.removePlayer(playerIn); playerIn.getLevel().removePlayerImmediately(playerIn, Entity.RemovalReason.DISCARDED); @@ -327,6 +326,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { LevelData worlddata = serverWorld.getLevelData(); playerIn.connection.send(new ClientboundRespawnPacket(serverWorld.dimensionType(), serverWorld.dimension(), BiomeManager.obfuscateSeed(serverWorld.getSeed()), playerIn.gameMode.getGameModeForPlayer(), playerIn.gameMode.getPreviousGameModeForPlayer(), serverWorld.isDebug(), serverWorld.isFlat(), flag)); playerIn.connection.send(new ClientboundSetChunkCacheRadiusPacket(((WorldBridge) serverWorld).bridge$spigotConfig().viewDistance)); + playerIn.connection.send(new ClientboundSetSimulationDistancePacket(((WorldBridge) serverWorld).bridge$spigotConfig().simulationDistance)); playerIn.setLevel(serverWorld); ((ServerPlayNetHandlerBridge) playerIn.connection).bridge$teleport(new Location(((WorldBridge) serverWorld).bridge$getWorld(), playerIn.getX(), playerIn.getY(), playerIn.getZ(), playerIn.getYRot(), playerIn.getXRot())); playerIn.setShiftKeyDown(false); @@ -341,7 +341,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { this.playersByUUID.put(playerIn.getUUID(), playerIn); } playerIn.setHealth(playerIn.getHealth()); - BasicEventHooks.firePlayerChangedDimensionEvent(playerIn, ((CraftWorld) fromWorld).getHandle().dimension, serverWorld.dimension); + ForgeEventFactory.firePlayerChangedDimensionEvent(playerIn, ((CraftWorld) fromWorld).getHandle().dimension, serverWorld.dimension); if (flag3) { playerIn.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, pos.getX(), pos.getY(), pos.getZ(), 1.0f, 1.0f)); } @@ -469,6 +469,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { LevelData iworldinfo = serverplayerentity.level.getLevelData(); serverplayerentity.connection.send(new ClientboundRespawnPacket(serverplayerentity.level.dimensionType(), serverplayerentity.level.dimension(), BiomeManager.obfuscateSeed(serverplayerentity.getLevel().getSeed()), serverplayerentity.gameMode.getGameModeForPlayer(), serverplayerentity.gameMode.getPreviousGameModeForPlayer(), serverplayerentity.getLevel().isDebug(), serverplayerentity.getLevel().isFlat(), conqueredEnd)); serverplayerentity.connection.send(new ClientboundSetChunkCacheRadiusPacket(((WorldBridge) serverWorld).bridge$spigotConfig().viewDistance)); + serverplayerentity.connection.send(new ClientboundSetSimulationDistancePacket(((WorldBridge) serverWorld).bridge$spigotConfig().simulationDistance)); serverplayerentity.setLevel(serverWorld); ((ServerPlayNetHandlerBridge) serverplayerentity.connection).bridge$teleport(new Location(((WorldBridge) serverWorld).bridge$getWorld(), serverplayerentity.getX(), serverplayerentity.getY(), serverplayerentity.getZ(), serverplayerentity.getYRot(), serverplayerentity.getXRot())); serverplayerentity.setShiftKeyDown(false); @@ -484,7 +485,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { } serverplayerentity.initInventoryMenu(); serverplayerentity.setHealth(serverplayerentity.getHealth()); - BasicEventHooks.firePlayerRespawnEvent(serverplayerentity, conqueredEnd); + ForgeEventFactory.firePlayerRespawnEvent(serverplayerentity, conqueredEnd); if (flag2) { serverplayerentity.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), 1.0F, 1.0F)); } @@ -505,7 +506,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { return serverplayerentity; } - public void sendAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) { + public void broadcastAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) { for (ServerPlayer entityplayer : this.players) { if (!(entityhuman instanceof ServerPlayer) || ((ServerPlayerEntityBridge) entityplayer).bridge$getBukkitEntity().canSee(((ServerPlayerEntityBridge) entityhuman).bridge$getBukkitEntity())) { entityplayer.connection.send(packet); @@ -513,7 +514,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { } } - public void sendAll(Packet packet, Level world) { + public void broadcastAll(Packet packet, Level world) { for (int i = 0; i < world.players().size(); ++i) { ((ServerPlayer) world.players().get(i)).connection.send(packet); } @@ -535,7 +536,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { } } - public void sendMessage(Component[] components) { + public void broadcastMessage(Component[] components) { for (Component component : components) { this.broadcastMessage(component, ChatType.SYSTEM, Util.NIL_UUID); } @@ -543,15 +544,15 @@ public abstract class PlayerListMixin implements PlayerListBridge { @Override public void bridge$sendMessage(Component[] components) { - this.sendMessage(components); + this.broadcastMessage(components); } - public ServerStatsCounter getStatisticManager(ServerPlayer entityhuman) { + public ServerStatsCounter getPlayerStats(ServerPlayer entityhuman) { ServerStatsCounter serverstatisticmanager = entityhuman.getStats(); - return serverstatisticmanager == null ? this.getStatisticManager(entityhuman.getUUID(), entityhuman.getName().getString()) : serverstatisticmanager; + return serverstatisticmanager == null ? this.getPlayerStats(entityhuman.getUUID(), entityhuman.getName().getString()) : serverstatisticmanager; } - public ServerStatsCounter getStatisticManager(UUID uuid, String displayName) { + public ServerStatsCounter getPlayerStats(UUID uuid, String displayName) { ServerStatsCounter serverstatisticmanager; ServerPlayer entityhuman = this.getPlayer(uuid); ServerStatsCounter serverStatisticsManager = serverstatisticmanager = entityhuman == null ? null : entityhuman.getStats(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IBlockReaderMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/BlockGetterMixin.java similarity index 91% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IBlockReaderMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/BlockGetterMixin.java index b73a9545..6c1ef0b5 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IBlockReaderMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/BlockGetterMixin.java @@ -1,10 +1,6 @@ package io.izzel.arclight.common.mixin.core.world; import io.izzel.arclight.common.bridge.core.world.IBlockReaderBridge; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import javax.annotation.Nullable; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.ClipContext; @@ -13,9 +9,13 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import javax.annotation.Nullable; @Mixin(BlockGetter.class) -public interface IBlockReaderMixin extends IBlockReaderBridge { +public interface BlockGetterMixin extends IBlockReaderBridge { // @formatter:off @Shadow BlockState getBlockState(BlockPos pos); @@ -23,7 +23,7 @@ public interface IBlockReaderMixin extends IBlockReaderBridge { @Shadow @Nullable BlockHitResult clipWithInteractionOverride(Vec3 startVec, Vec3 endVec, BlockPos pos, VoxelShape shape, BlockState state); // @formatter:on - default BlockHitResult rayTraceBlock(ClipContext context, BlockPos pos) { + default BlockHitResult clip(ClipContext context, BlockPos pos) { BlockState blockstate = this.getBlockState(pos); FluidState ifluidstate = this.getFluidState(pos); Vec3 vec3d = context.getFrom(); @@ -39,6 +39,6 @@ public interface IBlockReaderMixin extends IBlockReaderBridge { @Override default BlockHitResult bridge$rayTraceBlock(ClipContext context, BlockPos pos) { - return rayTraceBlock(context, pos); + return clip(context, pos); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IServerWorldMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IServerWorldMixin.java index f705c2f1..fe06df14 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IServerWorldMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IServerWorldMixin.java @@ -39,7 +39,7 @@ public interface IServerWorldMixin extends LevelAccessor, ServerWorldBridge { } } - default boolean addAllEntities(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + default boolean addFreshEntityWithPassengers(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { Iterator iterator = entity.getSelfAndPassengers().iterator(); while (iterator.hasNext()) { Entity next = iterator.next(); @@ -51,6 +51,6 @@ public interface IServerWorldMixin extends LevelAccessor, ServerWorldBridge { @Override default boolean bridge$addAllEntities(Entity entity, CreatureSpawnEvent.SpawnReason reason) { - return this.addAllEntities(entity, reason); + return this.addFreshEntityWithPassengers(entity, reason); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IWorldWriterMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IWorldWriterMixin.java index d3b6a399..4bcf8d66 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IWorldWriterMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/IWorldWriterMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.Mixin; @Mixin(LevelWriter.class) public interface IWorldWriterMixin extends IWorldWriterBridge { - default boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { + default boolean addFreshEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { return bridge$addEntity(entity, reason); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/AreaEffectCloudEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/AreaEffectCloudEntityMixin.java index 8f9d77ae..b82ca897 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/AreaEffectCloudEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/AreaEffectCloudEntityMixin.java @@ -19,8 +19,6 @@ import org.bukkit.craftbukkit.v.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.event.entity.AreaEffectCloudApplyEvent; import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Implements; -import org.spongepowered.asm.mixin.Interface; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @@ -30,7 +28,6 @@ import java.util.List; import java.util.Map; @Mixin(AreaEffectCloud.class) -@Implements(@Interface(iface = AreaEffectCloudEntityBridge.Hack.class, prefix = "hack$")) public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements AreaEffectCloudEntityBridge { // @formatter:off @@ -210,11 +207,11 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements } } - public String hack$getType() { + public String getPotionType() { return Registry.POTION.getKey(this.potion).toString(); } - public void hack$setType(final String string) { + public void setPotionType(final String string) { this.setPotion(Registry.POTION.get(new ResourceLocation(string))); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityMixin.java index 0aa7a7a6..b6a404f4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityMixin.java @@ -42,6 +42,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.border.WorldBorder; import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.portal.PortalInfo; @@ -189,7 +190,6 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, @Shadow(remap = false) public abstract void revive(); @Shadow public abstract boolean isPushable(); @Shadow protected abstract void removeAfterChangingDimensions(); - @Shadow protected abstract Optional getExitPortal(ServerLevel p_241830_1_, BlockPos p_241830_2_, boolean p_241830_3_); @Shadow protected BlockPos portalEntrancePos; @Shadow protected abstract Vec3 getRelativePortalPosition(Direction.Axis axis, BlockUtil.FoundRectangle result); @Shadow public abstract EntityDimensions getDimensions(Pose poseIn); @@ -387,7 +387,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, } } - public void setOnFire(int seconds, boolean callEvent) { + public void setSecondsOnFire(int seconds, boolean callEvent) { if (callEvent) { EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), seconds); Bukkit.getPluginManager().callEvent(event); @@ -401,7 +401,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, @Override public void bridge$setOnFire(int tick, boolean callEvent) { - setOnFire(tick, callEvent); + setSecondsOnFire(tick, callEvent); } @ModifyArg(method = "move", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;stepOn(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/Entity;)V")) @@ -835,7 +835,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, entity.moveTo(portalinfo.pos.x, portalinfo.pos.y, portalinfo.pos.z, portalinfo.yRot, entity.getXRot()); entity.setDeltaMovement(portalinfo.speed); world.addDuringTeleport(entity); - if (((WorldBridge) world).bridge$getTypeKey() == DimensionType.END_LOCATION) { + if (((WorldBridge) world).bridge$getTypeKey() == LevelStem.END) { ArclightCaptures.captureEndPortalEntity((Entity) (Object) this, spawnPortal); ServerLevel.makeObsidianPlatform(world); } @@ -874,20 +874,16 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, if (world == null) { return null; } - boolean flag = ((WorldBridge) this.level).bridge$getTypeKey() == DimensionType.END_LOCATION && ((WorldBridge) world).bridge$getTypeKey() == DimensionType.OVERWORLD_LOCATION; - boolean flag1 = ((WorldBridge) world).bridge$getTypeKey() == DimensionType.END_LOCATION; + boolean flag = ((WorldBridge) this.level).bridge$getTypeKey() == LevelStem.END && ((WorldBridge) world).bridge$getTypeKey() == LevelStem.OVERWORLD; + boolean flag1 = ((WorldBridge) world).bridge$getTypeKey() == LevelStem.END; if (!flag && !flag1) { - boolean flag2 = ((WorldBridge) world).bridge$getTypeKey() == DimensionType.NETHER_LOCATION; + boolean flag2 = ((WorldBridge) world).bridge$getTypeKey() == LevelStem.NETHER; if (this.level.dimension() != Level.NETHER && !flag2) { return null; } else { WorldBorder worldborder = world.getWorldBorder(); - double d0 = Math.max(-2.9999872E7D, worldborder.getMinX() + 16.0D); - double d1 = Math.max(-2.9999872E7D, worldborder.getMinZ() + 16.0D); - double d2 = Math.min(2.9999872E7D, worldborder.getMaxX() - 16.0D); - double d3 = Math.min(2.9999872E7D, worldborder.getMaxZ() - 16.0D); - double d4 = DimensionType.getTeleportationScale(this.level.dimensionType(), world.dimensionType()); - BlockPos blockpos1 = new BlockPos(Mth.clamp(this.getX() * d4, d0, d2), this.getY(), Mth.clamp(this.getZ() * d4, d1, d3)); + double d0 = DimensionType.getTeleportationScale(this.level.dimensionType(), world.dimensionType()); + BlockPos blockpos1 = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0); CraftPortalEvent event = this.callPortalEvent((Entity) (Object) this, world, blockpos1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); if (event == null) { @@ -896,7 +892,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, ServerLevel worldFinal = world = ((CraftWorld) event.getTo().getWorld()).getHandle(); blockpos1 = new BlockPos(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); - return this.findOrCreatePortal(world, blockpos1, flag2, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((result) -> { + return this.getExitPortal(world, blockpos1, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((result) -> { BlockState blockstate = this.level.getBlockState(this.portalEntrancePos); Direction.Axis direction$axis; Vec3 vector3d; @@ -948,11 +944,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, return new CraftPortalEvent(event); } - protected Optional a(ServerLevel serverWorld, BlockPos pos, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) { - return findOrCreatePortal(serverWorld, pos, flag, searchRadius, canCreatePortal, createRadius); - } - - protected Optional findOrCreatePortal(ServerLevel serverWorld, BlockPos pos, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) { - return ((TeleporterBridge) serverWorld.getPortalForcer()).bridge$findPortal(pos, searchRadius); + protected Optional getExitPortal(ServerLevel serverWorld, BlockPos pos, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { + return ((TeleporterBridge) serverWorld.getPortalForcer()).bridge$findPortal(pos, worldborder, searchRadius); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityTypeMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityTypeMixin.java index 38ebcfa0..5a9f55be 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityTypeMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityTypeMixin.java @@ -46,7 +46,7 @@ public abstract class EntityTypeMixin implements EntityTypeBri } } - public T spawnCreature(ServerLevel worldIn, @Nullable CompoundTag compound, @Nullable Component customName, @Nullable Player playerIn, BlockPos pos, MobSpawnType reason, boolean p_220342_7_, boolean p_220342_8_, CreatureSpawnEvent.SpawnReason spawnReason) { + public T spawn(ServerLevel worldIn, @Nullable CompoundTag compound, @Nullable Component customName, @Nullable Player playerIn, BlockPos pos, MobSpawnType reason, boolean p_220342_7_, boolean p_220342_8_, CreatureSpawnEvent.SpawnReason spawnReason) { T t = this.create(worldIn, compound, customName, playerIn, pos, reason, p_220342_7_, p_220342_8_); if (t != null) { if (t instanceof net.minecraft.world.entity.Mob && net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn((net.minecraft.world.entity.Mob) t, worldIn, pos.getX(), pos.getY(), pos.getZ(), null, reason)) @@ -60,6 +60,6 @@ public abstract class EntityTypeMixin implements EntityTypeBri @Override public T bridge$spawnCreature(ServerLevel worldIn, @Nullable CompoundTag compound, @Nullable Component customName, @Nullable Player playerIn, BlockPos pos, MobSpawnType reason, boolean flag, boolean flag1, CreatureSpawnEvent.SpawnReason spawnReason) { - return spawnCreature(worldIn, compound, customName, playerIn, pos, reason, flag, flag1, spawnReason); + return spawn(worldIn, compound, customName, playerIn, pos, reason, flag, flag1, spawnReason); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/LivingEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/LivingEntityMixin.java index 22a37d4e..858e43fd 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/LivingEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/LivingEntityMixin.java @@ -1081,16 +1081,16 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt return CraftEventFactory.callArrowBodyCountChangeEvent((LivingEntity) (Object) this, this.getArrowCount(), newCount, reset).isCancelled(); } - public void setSlot(EquipmentSlot slotIn, ItemStack stack, boolean silent) { + public void setItemSlot(EquipmentSlot slotIn, ItemStack stack, boolean silent) { this.setItemSlot(slotIn, stack); } @Override public void bridge$setSlot(EquipmentSlot slotIn, ItemStack stack, boolean silent) { - this.setSlot(slotIn, stack, silent); + this.setItemSlot(slotIn, stack, silent); } - protected void playEquipSound(ItemStack stack, boolean silent) { + protected void equipEventAndSound(ItemStack stack, boolean silent) { if (!silent) { this.equipEventAndSound(stack); } @@ -1098,6 +1098,6 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt @Override public void bridge$playEquipSound(ItemStack stack, boolean silent) { - this.playEquipSound(stack, silent); + this.equipEventAndSound(stack, silent); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/MobMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/MobMixin.java index dbc7ae77..0bee8677 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/MobMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/MobMixin.java @@ -142,7 +142,7 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri arclight$targetSuccess = true; } - public boolean setGoalTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent) { + public boolean setTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent) { bridge$pushGoalTargetReason(reason, fireEvent); setTarget(livingEntity); return arclight$targetSuccess; @@ -155,7 +155,7 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri @Override public boolean bridge$setGoalTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent) { - return setGoalTarget(livingEntity, reason, fireEvent); + return setTarget(livingEntity, reason, fireEvent); } @Override @@ -306,7 +306,7 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri this.arclight$transform = null; } - public T a(EntityType entityType, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { + public T convertTo(EntityType entityType, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ((WorldBridge) this.level).bridge$pushAddEntityReason(spawnReason); bridge$pushTransformReason(transformReason); return this.convertTo(entityType, flag); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/HarvestFarmlandMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/HarvestFarmlandMixin.java index 18cb591a..7d26c04e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/HarvestFarmlandMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/HarvestFarmlandMixin.java @@ -12,7 +12,7 @@ import net.minecraft.world.entity.npc.Villager; @Mixin(HarvestFarmland.class) public abstract class HarvestFarmlandMixin { - @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) + @Inject(method = "tick(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/npc/Villager;J)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) private void on(ServerLevel worldIn, Villager owner, long gameTime, CallbackInfo ci) { ArclightCaptures.captureEntityChangeBlock(owner); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/ResetProfessionMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/ResetProfessionMixin.java index 52ad0d79..e3cb1212 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/ResetProfessionMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/ResetProfessionMixin.java @@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ResetProfession.class) public class ResetProfessionMixin { - @Redirect(method = "start", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/npc/Villager;setVillagerData(Lnet/minecraft/world/entity/npc/VillagerData;)V")) + @Redirect(method = "start(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/npc/Villager;J)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/npc/Villager;setVillagerData(Lnet/minecraft/world/entity/npc/VillagerData;)V")) private void arclight$careerChangeHook(Villager villagerEntity, VillagerData villagerData) { VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(villagerEntity, CraftVillager.nmsToBukkitProfession(VillagerProfession.NONE), diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/ArmorStandMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/ArmorStandMixin.java index 55c86bb1..94613e87 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/ArmorStandMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/ArmorStandMixin.java @@ -160,7 +160,7 @@ public abstract class ArmorStandMixin extends LivingEntityMixin { } @Override - public void setSlot(net.minecraft.world.entity.EquipmentSlot slotIn, ItemStack stack, boolean silent) { + public void setItemSlot(net.minecraft.world.entity.EquipmentSlot slotIn, ItemStack stack, boolean silent) { switch (slotIn.getType()) { case HAND -> { this.bridge$playEquipSound(stack, silent); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/PaintingMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/PaintingMixin.java deleted file mode 100644 index 801e5cdd..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/PaintingMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.izzel.arclight.common.mixin.core.world.entity.decoration; - -import com.google.common.collect.Lists; -import io.izzel.arclight.common.mixin.core.world.entity.item.HangingEntityMixin; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.decoration.Motive; -import net.minecraft.world.entity.decoration.Painting; -import net.minecraft.world.level.Level; -import net.minecraftforge.registries.ForgeRegistries; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.List; - -@Mixin(Painting.class) -public abstract class PaintingMixin extends HangingEntityMixin { - - @Shadow public Motive motive; - - @Inject(method = "(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", at = @At("RETURN")) - private void arclight$init(EntityType type, Level worldIn, CallbackInfo ci) { - final List list = Lists.newArrayList(ForgeRegistries.PAINTING_TYPES.getValues()); - this.motive = list.get(this.random.nextInt(list.size())); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/ItemEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/ItemEntityMixin.java index 6100d0a5..253f6b47 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/ItemEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/ItemEntityMixin.java @@ -14,7 +14,7 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.AABB; -import net.minecraftforge.fmllegacy.hooks.BasicEventHooks; +import net.minecraftforge.event.ForgeEventFactory; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.entity.Item; @@ -82,7 +82,7 @@ public abstract class ItemEntityMixin extends EntityMixin { if (this.pickupDelay <= 0 && (hook == 1 || canHold > 0)) { copy.setCount(canHold); - BasicEventHooks.firePlayerItemPickupEvent(entity, (ItemEntity) (Object) this, copy); + ForgeEventFactory.firePlayerItemPickupEvent(entity, (ItemEntity) (Object) this, copy); itemstack.setCount(canHold); final PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent(((ServerPlayerEntityBridge) entity).bridge$getBukkitEntity(), (Item) this.getBukkitEntity(), remaining); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/EnderManMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/EnderManMixin.java index 318d6a6d..ec85df72 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/EnderManMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/EnderManMixin.java @@ -44,8 +44,8 @@ public abstract class EnderManMixin extends PathfinderMobMixin implements Enderm } @Override - public boolean setGoalTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent) { - if (!super.setGoalTarget(livingEntity, reason, fireEvent)) { + public boolean setTarget(LivingEntity livingEntity, EntityTargetEvent.TargetReason reason, boolean fireEvent) { + if (!super.setTarget(livingEntity, reason, fireEvent)) { return false; } bridge$updateTarget(getTarget()); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombieVillagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombieVillagerMixin.java index adfef6ab..9ebc3b0d 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombieVillagerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombieVillagerMixin.java @@ -32,7 +32,7 @@ public abstract class ZombieVillagerMixin extends ZombieMixin { @Eject(method = "finishConversion", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/monster/ZombieVillager;convertTo(Lnet/minecraft/world/entity/EntityType;Z)Lnet/minecraft/world/entity/Mob;")) private T arclight$cure(net.minecraft.world.entity.monster.ZombieVillager zombieVillagerEntity, EntityType entityType, boolean flag, CallbackInfo ci) { - T t = this.a(entityType, flag, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED); + T t = this.convertTo(entityType, flag, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED); if (t == null) { ((ZombieVillager) this.bridge$getBukkitEntity()).setConversionTime(-1); ci.cancel(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/player/PlayerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/player/PlayerMixin.java index dd1ba391..d609c7c2 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/player/PlayerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/player/PlayerMixin.java @@ -415,14 +415,14 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt protected transient boolean arclight$forceSleep; - public Either sleep(BlockPos at, boolean force) { + public Either startSleepInBed(BlockPos at, boolean force) { this.arclight$forceSleep = force; return this.startSleepInBed(at); } @Override public Either bridge$trySleep(BlockPos at, boolean force) { - return sleep(at, force); + return startSleepInBed(at, force); } @Inject(method = "stopSleepInBed", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/player/Player;sleepCounter:I")) @@ -544,7 +544,7 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt } @Override - public void setSlot(EquipmentSlot slotIn, ItemStack stack, boolean silent) { + public void setItemSlot(EquipmentSlot slotIn, ItemStack stack, boolean silent) { if (slotIn == EquipmentSlot.MAINHAND) { this.bridge$playEquipSound(stack, silent); this.inventory.items.set(this.inventory.selected, stack); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/player/ServerPlayerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/player/ServerPlayerMixin.java index d9d017a4..1cb16315 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/player/ServerPlayerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/player/ServerPlayerMixin.java @@ -66,7 +66,8 @@ import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.block.NetherPortalBlock; -import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.border.WorldBorder; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.portal.PortalInfo; import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.phys.AABB; @@ -77,8 +78,8 @@ import net.minecraft.world.scores.Team; import net.minecraft.world.scores.criteria.ObjectiveCriteria; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.ITeleporter; -import net.minecraftforge.fmllegacy.hooks.BasicEventHooks; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.server.ServerLifecycleHooks; import org.apache.logging.log4j.Logger; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -215,7 +216,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla int i2 = (k1 + j1 * l1) % i1; int j2 = i2 % (i * 2 + 1); int k2 = i2 / (i * 2 + 1); - BlockPos blockposition1 = PlayerRespawnLogic.getOverworldRespawnPos(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i, false); + BlockPos blockposition1 = PlayerRespawnLogic.getOverworldRespawnPos(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i); if (blockposition1 == null) continue; return blockposition1; } @@ -430,7 +431,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla @Overwrite protected PortalInfo findDimensionEntryPoint(ServerLevel p_241829_1_) { PortalInfo portalinfo = super.findDimensionEntryPoint(p_241829_1_); - if (portalinfo != null && ((WorldBridge) this.level).bridge$getTypeKey() == DimensionType.OVERWORLD_LOCATION && ((WorldBridge) p_241829_1_).bridge$getTypeKey() == DimensionType.END_LOCATION) { + if (portalinfo != null && ((WorldBridge) this.level).bridge$getTypeKey() == LevelStem.OVERWORLD && ((WorldBridge) p_241829_1_).bridge$getTypeKey() == LevelStem.END) { Vec3 vector3d = portalinfo.pos.add(0.0D, -1.0D, 0.0D); PortalInfo newInfo = new PortalInfo(vector3d, Vec3.ZERO, 90.0F, 0.0F); ((PortalInfoBridge) newInfo).bridge$setWorld(p_241829_1_); @@ -466,8 +467,8 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla // this.invulnerableDimensionChange = true; ServerLevel serverworld = this.getLevel(); - ResourceKey registrykey = ((WorldBridge) serverworld).bridge$getTypeKey(); - if (registrykey == DimensionType.END_LOCATION && ((WorldBridge) server).bridge$getTypeKey() == DimensionType.OVERWORLD_LOCATION && teleporter.isVanilla()) { //Forge: Fix non-vanilla teleporters triggering end credits + ResourceKey registrykey = ((WorldBridge) serverworld).bridge$getTypeKey(); + if (registrykey == LevelStem.END && ((WorldBridge) server).bridge$getTypeKey() == LevelStem.OVERWORLD && teleporter.isVanilla()) { //Forge: Fix non-vanilla teleporters triggering end credits this.isChangingDimension = true; this.unRide(); this.getLevel().removePlayer((ServerPlayer) (Object) this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom @@ -496,9 +497,9 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla exitWorld[0] = ((PortalInfoBridge) portalinfo).bridge$getWorld(); } if (exitWorld[0] != null) { - if (registrykey == DimensionType.OVERWORLD_LOCATION && ((WorldBridge) exitWorld[0]).bridge$getTypeKey() == DimensionType.NETHER_LOCATION) { + if (registrykey ==LevelStem.OVERWORLD&& ((WorldBridge) exitWorld[0]).bridge$getTypeKey() == LevelStem.NETHER) { this.enteredNetherPosition = this.position(); - } else if (spawnPortal && ((WorldBridge) exitWorld[0]).bridge$getTypeKey() == DimensionType.END_LOCATION + } else if (spawnPortal && ((WorldBridge) exitWorld[0]).bridge$getTypeKey() == LevelStem.END && (((PortalInfoBridge) portalinfo).bridge$getPortalEventInfo() == null || ((PortalInfoBridge) portalinfo).bridge$getPortalEventInfo().getCanCreatePortal())) { this.createEndPlatform(exitWorld[0], new BlockPos(portalinfo.pos)); } @@ -557,7 +558,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; - BasicEventHooks.firePlayerChangedDimensionEvent((ServerPlayer) (Object) this, serverworld.dimension(), exitWorld[0].dimension()); + ForgeEventFactory.firePlayerChangedDimensionEvent((ServerPlayer) (Object) this, serverworld.dimension(), exitWorld[0].dimension()); PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), ((WorldBridge) serverworld).bridge$getWorld()); Bukkit.getPluginManager().callEvent(changeEvent); } @@ -579,8 +580,8 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla } @Override - protected Optional findOrCreatePortal(ServerLevel worldserver, BlockPos blockposition, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) { - Optional optional = super.findOrCreatePortal(worldserver, blockposition, flag, searchRadius, canCreatePortal, createRadius); + protected Optional getExitPortal(ServerLevel worldserver, BlockPos blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { + Optional optional = super.getExitPortal(worldserver, blockposition, flag, worldborder, searchRadius, canCreatePortal, createRadius); if (optional.isPresent() || !canCreatePortal) { return optional; } @@ -758,16 +759,16 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla @Inject(method = "updateOptions", at = @At("HEAD")) private void arclight$settingChange(ServerboundClientInformationPacket packetIn, CallbackInfo ci) { - if (this.getMainArm() != packetIn.getMainHand()) { + if (this.getMainArm() != packetIn.mainHand()) { PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), (this.getMainArm() == HumanoidArm.LEFT) ? MainHand.LEFT : MainHand.RIGHT); Bukkit.getPluginManager().callEvent(event); } - if (!this.language.equals(packetIn.getLanguage())) { - PlayerLocaleChangeEvent event2 = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packetIn.getLanguage()); + if (!this.language.equals(packetIn.language())) { + PlayerLocaleChangeEvent event2 = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packetIn.language()); Bukkit.getPluginManager().callEvent(event2); } - this.locale = packetIn.getLanguage(); - this.clientViewDistance = packetIn.viewDistance; + this.locale = packetIn.language(); + this.clientViewDistance = packetIn.viewDistance(); } @Inject(method = "setCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;teleportTo(DDD)V")) @@ -800,7 +801,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla ci.cancel(); } - public void a(ServerLevel worldserver, double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { + public void teleportTo(ServerLevel worldserver, double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { bridge$pushChangeDimensionCause(cause); teleportTo(worldserver, d0, d1, d2, f, f1); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ArrowEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ArrowEntityMixin.java index 26e577d2..23a18b48 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ArrowEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ArrowEntityMixin.java @@ -13,8 +13,6 @@ import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.alchemy.Potions; import org.bukkit.event.entity.EntityPotionEffectEvent; import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Implements; -import org.spongepowered.asm.mixin.Interface; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -24,7 +22,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Set; @Mixin(Arrow.class) -@Implements(@Interface(iface = ArrowEntityBridge.Hack.class, prefix = "hack$")) public abstract class ArrowEntityMixin extends AbstractArrowMixin implements ArrowEntityBridge { // @formatter:off @@ -47,11 +44,11 @@ public abstract class ArrowEntityMixin extends AbstractArrowMixin implements Arr refreshEffects(); } - public String hack$getType() { + public String getPotionType() { return Registry.POTION.getKey(this.potion).toString(); } - public void hack$setType(final String string) { + public void setPotionType(final String string) { this.potion = Registry.POTION.get(new ResourceLocation(string)); this.getEntityData().set(ID_EFFECT_COLOR, PotionUtils.getColor(PotionUtils.getAllEffects(this.potion, this.effects))); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/vehicle/BoatMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/vehicle/BoatMixin.java index b8f5f791..4f245bca 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/vehicle/BoatMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/vehicle/BoatMixin.java @@ -77,7 +77,7 @@ public abstract class BoatMixin extends EntityMixin { } } - @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/vehicle/Boat;tickBubbleColumn()V")) + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/vehicle/Boat;tickBubbleColumn()V")) private void arclight$updateVehicle(CallbackInfo ci) { final org.bukkit.World bworld = ((WorldBridge) this.level).bridge$getWorld(); final Location to = new Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/WorldGenRegionMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/WorldGenRegionMixin.java index 94ebf7a8..21093cc4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/WorldGenRegionMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/WorldGenRegionMixin.java @@ -1,21 +1,15 @@ package io.izzel.arclight.common.mixin.core.world.gen; import io.izzel.arclight.common.bridge.core.world.WorldBridge; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.WorldGenRegion; +import net.minecraft.world.entity.Entity; import org.bukkit.craftbukkit.v.CraftWorld; import org.bukkit.event.entity.CreatureSpawnEvent; 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 java.util.stream.Stream; -import net.minecraft.core.SectionPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.WorldGenRegion; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.levelgen.feature.StructureFeature; -import net.minecraft.world.level.levelgen.structure.StructureStart; - @Mixin(WorldGenRegion.class) public abstract class WorldGenRegionMixin implements WorldBridge { @@ -24,13 +18,13 @@ public abstract class WorldGenRegionMixin implements WorldBridge { @Shadow @Final private ServerLevel level; // @formatter:on - public boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { + public boolean addFreshEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { return this.addFreshEntity(entity); } @Override public boolean bridge$addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { - return addEntity(entity, reason); + return addFreshEntity(entity, reason); } @Override @@ -46,13 +40,4 @@ public abstract class WorldGenRegionMixin implements WorldBridge { public CreatureSpawnEvent.SpawnReason bridge$getAddEntityReason() { return CreatureSpawnEvent.SpawnReason.DEFAULT; } - - /** - * @author IzzelAliz - * @reason MC-199487 - */ - @Overwrite - public Stream> startsForFeature(SectionPos p_241827_1_, StructureFeature p_241827_2_) { - return this.level.structureFeatureManager().forWorldGenRegion((WorldGenRegion) (Object) this).startsForFeature(p_241827_1_, p_241827_2_); - } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/feature/structure/SwampHutPieceMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/feature/structure/SwampHutPieceMixin.java index 1d04c350..13a92384 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/feature/structure/SwampHutPieceMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/gen/feature/structure/SwampHutPieceMixin.java @@ -1,14 +1,6 @@ package io.izzel.arclight.common.mixin.core.world.gen.feature.structure; import io.izzel.arclight.common.bridge.core.world.IWorldWriterBridge; -import org.bukkit.event.entity.CreatureSpawnEvent; -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.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ServerLevelAccessor; @@ -17,13 +9,20 @@ import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.structure.SwamplandHutPiece; +import org.bukkit.event.entity.CreatureSpawnEvent; +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.callback.CallbackInfo; + +import java.util.Random; @Mixin(SwamplandHutPiece.class) public class SwampHutPieceMixin { @Inject(method = "postProcess", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/WorldGenLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V")) - private void arclight$spawnReason1(WorldGenLevel worldIn, StructureFeatureManager p_230383_2_, ChunkGenerator p_230383_3_, Random p_230383_4_, BoundingBox p_230383_5_, ChunkPos p_230383_6_, BlockPos p_230383_7_, CallbackInfoReturnable cir) { - ((IWorldWriterBridge) worldIn).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.CHUNK_GEN); + private void arclight$spawnReason1(WorldGenLevel level, StructureFeatureManager p_192667_, ChunkGenerator p_192668_, Random p_192669_, BoundingBox p_192670_, ChunkPos p_192671_, BlockPos p_192672_, CallbackInfo ci) { + ((IWorldWriterBridge) level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.CHUNK_GEN); } @Inject(method = "spawnCat", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/ServerLevelAccessor;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V")) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/AbstractContainerMenuMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/AbstractContainerMenuMixin.java index 8362e969..43e4b3ff 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/AbstractContainerMenuMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/AbstractContainerMenuMixin.java @@ -312,8 +312,8 @@ public abstract class AbstractContainerMenuMixin implements ContainerBridge { if (itemstack4.getCount() > l1) { slot2.set(itemstack4.split(l1)); } else { - slot2.set(itemstack4); inventory.setItem(dragType, ItemStack.EMPTY); + slot2.set(itemstack4); } } } else if (slot2.mayPickup(player) && slot2.mayPlace(itemstack4)) { @@ -325,8 +325,8 @@ public abstract class AbstractContainerMenuMixin implements ContainerBridge { player.drop(itemstack7, true); } } else { - slot2.set(itemstack4); inventory.setItem(dragType, itemstack7); + slot2.set(itemstack4); slot2.onTake(player, itemstack7); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/BucketItemMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/BucketItemMixin.java index 2d61748d..aa8e5193 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/BucketItemMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/BucketItemMixin.java @@ -74,7 +74,7 @@ public abstract class BucketItemMixin { return arclight$captureItem == null ? itemStack : CraftItemStack.asNMSCopy(arclight$captureItem); } - public boolean a(Player entity, Level world, BlockPos pos, @Nullable BlockHitResult result, Direction direction, BlockPos clicked, ItemStack itemstack) { + public boolean emptyContents(Player entity, Level world, BlockPos pos, @Nullable BlockHitResult result, Direction direction, BlockPos clicked, ItemStack itemstack) { arclight$direction = direction; arclight$click = clicked; arclight$stack = itemstack; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/RecipeManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/RecipeManagerMixin.java index 036ea6e2..9e517610 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/RecipeManagerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/RecipeManagerMixin.java @@ -39,6 +39,7 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge { @Shadow private boolean hasErrors; @Shadow @Final private static Logger LOGGER; @Shadow public static Recipe fromJson(ResourceLocation recipeId, JsonObject json) { return null; } + @Shadow private Map> byName; // @formatter:on /** @@ -55,6 +56,7 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge { map.put(type, new Object2ObjectLinkedOpenHashMap<>()); } + ImmutableMap.Builder> builder = ImmutableMap.builder(); for (Map.Entry entry : objectIn.entrySet()) { ResourceLocation resourcelocation = entry.getKey(); if (resourcelocation.getPath().startsWith("_")) @@ -72,12 +74,14 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge { } map.computeIfAbsent(irecipe.getType(), (recipeType) -> new Object2ObjectLinkedOpenHashMap<>()) .putAndMoveToFirst(resourcelocation, irecipe); + builder.put(resourcelocation, irecipe); } catch (IllegalArgumentException | JsonParseException jsonparseexception) { LOGGER.error("Parsing error loading recipe {}", resourcelocation, jsonparseexception); } } this.recipes = (Map) map; + this.byName = Maps.newHashMap(builder.build()); LOGGER.info("Loaded {} recipes", map.size()); } @@ -98,6 +102,9 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge { if (this.recipes instanceof ImmutableMap) { this.recipes = new HashMap<>(recipes); } + if (this.byName instanceof ImmutableMap) { + this.byName = new HashMap<>(byName); + } Map> original = this.recipes.get(recipe.getType()); Object2ObjectLinkedOpenHashMap> map; if (!(original instanceof Object2ObjectLinkedOpenHashMap)) { @@ -109,10 +116,11 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge { map = ((Object2ObjectLinkedOpenHashMap>) original); } - if (map.containsKey(recipe.getId())) { + if (this.byName.containsKey(recipe.getId()) || map.containsKey(recipe.getId())) { throw new IllegalStateException("Duplicate recipe ignored with ID " + recipe.getId()); } else { map.putAndMoveToFirst(recipe.getId(), recipe); + this.byName.put(recipe.getId(), recipe); } } @@ -126,6 +134,7 @@ public abstract class RecipeManagerMixin implements RecipeManagerBridge { for (RecipeType type : Registry.RECIPE_TYPE) { this.recipes.put(type, new Object2ObjectLinkedOpenHashMap<>()); } + this.byName = new HashMap<>(); } @Override diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/enchantment/FrostWalkerEnchantmentMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/enchantment/FrostWalkerEnchantmentMixin.java index 621633d5..a730be9e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/enchantment/FrostWalkerEnchantmentMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/enchantment/FrostWalkerEnchantmentMixin.java @@ -37,7 +37,7 @@ public class FrostWalkerEnchantmentMixin { boolean isFull = blockstate2.getBlock() == Blocks.WATER && blockstate2.getValue(LiquidBlock.LEVEL) == 0; //TODO: Forge, modded waters? if (blockstate2.getMaterial() == Material.WATER && isFull && blockstate.canSurvive(worldIn, blockpos) && worldIn.isUnobstructed(blockstate, blockpos, CollisionContext.empty()) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(living, net.minecraftforge.common.util.BlockSnapshot.create(worldIn.dimension(), worldIn, blockpos), net.minecraft.core.Direction.UP)) { if (CraftEventFactory.handleBlockFormEvent(worldIn, blockpos, blockstate, living)) { - worldIn.getBlockTicks().scheduleTick(blockpos, Blocks.FROSTED_ICE, Mth.nextInt(living.getRandom(), 60, 120)); + worldIn.scheduleTick(blockpos, Blocks.FROSTED_ICE, Mth.nextInt(living.getRandom(), 60, 120)); } } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/LevelMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/LevelMixin.java index 699767da..0ee78f34 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/LevelMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/LevelMixin.java @@ -6,7 +6,6 @@ import io.izzel.arclight.common.bridge.core.world.border.WorldBorderBridge; import io.izzel.arclight.common.bridge.core.world.level.levelgen.ChunkGeneratorBridge; import io.izzel.arclight.common.bridge.core.world.server.ServerChunkProviderBridge; import io.izzel.arclight.common.bridge.core.world.server.ServerWorldBridge; -import io.izzel.arclight.common.mod.ArclightMod; import io.izzel.arclight.common.mod.server.ArclightServer; import io.izzel.arclight.common.mod.server.world.WrappedWorlds; import io.izzel.arclight.common.mod.util.ArclightCaptures; @@ -27,6 +26,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.border.WorldBorder; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.level.storage.ServerLevelData; @@ -78,7 +78,6 @@ public abstract class LevelMixin implements WorldBridge, LevelWriter { @Accessor("thread") public abstract Thread arclight$getMainThread(); // @formatter:on - private ResourceKey typeKey; protected CraftWorld world; public boolean pvpMode; public boolean keepSpawnInMemory = true; @@ -119,14 +118,6 @@ public abstract class LevelMixin implements WorldBridge, LevelWriter { this.ticksPerWaterAmbientSpawns = this.getCraftServer().getTicksPerWaterAmbientSpawns(); this.ticksPerWaterUndergroundCreatureSpawns = this.getCraftServer().getTicksPerWaterUndergroundCreatureSpawns(); this.ticksPerAmbientSpawns = this.getCraftServer().getTicksPerAmbientSpawns(); - this.typeKey = this.getCraftServer().getHandle().getServer().registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY) - .getResourceKey(dimensionType) - .orElseGet(() -> { - Registry registry = this.getCraftServer().getHandle().getServer().registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); - ResourceKey typeRegistryKey = ResourceKey.create(registry.key(), dimension.location()); - ArclightMod.LOGGER.warn("Assign {} to unknown dimension type {} as {}", typeRegistryKey, dimType); - return typeRegistryKey; - }); } @Override @@ -159,12 +150,10 @@ public abstract class LevelMixin implements WorldBridge, LevelWriter { return ticksPerWaterUndergroundCreatureSpawns; } - public ResourceKey getTypeKey() { - return this.typeKey; - } + public abstract ResourceKey getTypeKey(); @Override - public ResourceKey bridge$getTypeKey() { + public ResourceKey bridge$getTypeKey() { return getTypeKey(); } @@ -255,7 +244,7 @@ public abstract class LevelMixin implements WorldBridge, LevelWriter { } } if (environment == null) { - environment = ArclightServer.getEnvironment(this.typeKey); + environment = ArclightServer.getEnvironment(this.getTypeKey()); } if (generator == null) { generator = getCraftServer().getGenerator(((ServerLevelData) this.getLevelData()).getLevelName()); @@ -280,13 +269,13 @@ public abstract class LevelMixin implements WorldBridge, LevelWriter { return this.world; } - public BlockEntity getTileEntity(BlockPos pos, boolean validate) { + public BlockEntity getBlockEntity(BlockPos pos, boolean validate) { return getBlockEntity(pos); } @Override public BlockEntity bridge$getTileEntity(BlockPos pos, boolean validate) { - return getTileEntity(pos, validate); + return getBlockEntity(pos, validate); } @Override diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/BaseFireBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/BaseFireBlockMixin.java index a6fdb3b7..6571d5e1 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/BaseFireBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/BaseFireBlockMixin.java @@ -1,11 +1,14 @@ package io.izzel.arclight.common.mixin.core.world.level.block; +import io.izzel.arclight.common.bridge.core.world.WorldBridge; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BaseFireBlock; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.dimension.LevelStem; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -19,4 +22,14 @@ public class BaseFireBlockMixin { } return false; } + + /** + * @author IzzelAliz + * @reason + */ + @Overwrite + private static boolean inPortalDimension(Level level) { + var typeKey = ((WorldBridge) level).bridge$getTypeKey(); + return typeKey == LevelStem.NETHER || typeKey == LevelStem.OVERWORLD; + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CarvedPumpkinBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CarvedPumpkinBlockMixin.java index c59a3172..7bc51639 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CarvedPumpkinBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CarvedPumpkinBlockMixin.java @@ -6,8 +6,8 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.CarvedPumpkinBlock; +import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.common.util.Constants; import org.bukkit.craftbukkit.v.util.BlockStateListPopulator; import org.bukkit.event.entity.CreatureSpawnEvent; import org.spongepowered.asm.mixin.Mixin; @@ -40,7 +40,7 @@ public class CarvedPumpkinBlockMixin { if (arclight$success) { if (arclight$populator != null) { for (BlockPos pos : arclight$populator.getBlocks()) { - world.levelEvent(Constants.WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getId(world.getBlockState(pos))); + world.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(world.getBlockState(pos))); } arclight$populator.updateList(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ChestBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ChestBlockMixin.java index d51a1665..a31aba40 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ChestBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ChestBlockMixin.java @@ -23,7 +23,7 @@ public abstract class ChestBlockMixin { // @formatter:on @Nullable - public MenuProvider getInventory(BlockState state, Level level, BlockPos pos, boolean ignoreObstructions) { + public MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos, boolean ignoreObstructions) { return this.combine(state, level, pos, ignoreObstructions).apply(MENU_PROVIDER_COMBINER).orElse(null); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CommandBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CommandBlockMixin.java index 6511b4e4..3e926cae 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CommandBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CommandBlockMixin.java @@ -39,7 +39,7 @@ public abstract class CommandBlockMixin { if (!flag1 && !commandblocktileentity.isAutomatic() && commandblocktileentity.getMode() != CommandBlockEntity.Mode.SEQUENCE) { if (flag) { commandblocktileentity.markConditionMet(); - worldIn.getBlockTicks().scheduleTick(pos, (CommandBlock) (Object) this, 1); + worldIn.scheduleTick(pos, (CommandBlock) (Object) this, 1); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ComposterBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ComposterBlockMixin.java index e02fe86d..21cee277 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ComposterBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ComposterBlockMixin.java @@ -35,7 +35,7 @@ public abstract class ComposterBlockMixin { @Shadow public static BlockState extractProduce(BlockState state, Level world, BlockPos pos) { return null; } // @formatter:on - @SuppressWarnings("UnresolvedMixinReference") + @SuppressWarnings({"InvalidMemberReference", "UnresolvedMixinReference", "MixinAnnotationTarget", "InvalidInjectorMethodSignature"}) @Redirect(method = "getContainer", at = @At(value = "NEW", target = "()Lnet/minecraft/world/level/block/ComposterBlock$EmptyContainer;")) public ComposterBlock.EmptyContainer arclight$newEmpty(BlockState blockState, LevelAccessor world, BlockPos blockPos) { ComposterBlock.EmptyContainer inventory = new ComposterBlock.EmptyContainer(); @@ -52,13 +52,13 @@ public abstract class ComposterBlockMixin { int i = state.getValue(LEVEL); if (i < 7 && COMPOSTABLES.containsKey(stack.getItem())) { double rand = world.random.nextDouble(); - BlockState state1 = attemptCompost(state, DummyGeneratorAccess.INSTANCE, pos, stack, rand); + BlockState state1 = addItem(state, DummyGeneratorAccess.INSTANCE, pos, stack, rand); if (state == state1 || CraftEventFactory.callEntityChangeBlockEvent(ArclightCaptures.getEntityChangeBlock(), pos, state1).isCancelled()) { return state; } - state1 = attemptCompost(state, world, pos, stack, rand); + state1 = addItem(state, world, pos, stack, rand); stack.shrink(1); return state1; } else { @@ -77,16 +77,12 @@ public abstract class ComposterBlockMixin { } } - private static BlockState d(BlockState state, Level world, BlockPos pos, Entity entity) { + private static BlockState extractProduce(BlockState state, Level world, BlockPos pos, Entity entity) { ArclightCaptures.captureEntityChangeBlock(entity); return extractProduce(state, world, pos); } - private static BlockState b(BlockState state, LevelAccessor world, BlockPos pos, ItemStack stack, double rand) { - return attemptCompost(state, world, pos, stack, rand); - } - - private static BlockState attemptCompost(BlockState state, LevelAccessor world, BlockPos pos, ItemStack stack, double rand) { + private static BlockState addItem(BlockState state, LevelAccessor world, BlockPos pos, ItemStack stack, double rand) { int i = state.getValue(LEVEL); float f = COMPOSTABLES.getFloat(stack.getItem()); if ((i != 0 || !(f > 0.0F)) && !(rand < (double) f)) { @@ -96,7 +92,7 @@ public abstract class ComposterBlockMixin { BlockState blockstate = state.setValue(LEVEL, j); world.setBlock(pos, blockstate, 3); if (j == 7) { - world.getBlockTicks().scheduleTick(pos, state.getBlock(), 20); + world.scheduleTick(pos, state.getBlock(), 20); } return blockstate; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ConcretePowderBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ConcretePowderBlockMixin.java index 082a3a8a..b2a5f526 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ConcretePowderBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/ConcretePowderBlockMixin.java @@ -16,7 +16,6 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ConcretePowderBlock.class) @@ -32,7 +31,7 @@ public abstract class ConcretePowderBlockMixin extends FallingBlockMixin { } @Redirect(method = "getStateForPlacement", at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/ConcretePowderBlock;concrete:Lnet/minecraft/world/level/block/state/BlockState;")) - public BlockState arclight$blockForm(@Coerce ConcretePowderBlockMixin block, BlockPlaceContext context) { + public BlockState arclight$blockForm(ConcretePowderBlock instance, BlockPlaceContext context) { Level world = context.getLevel(); BlockPos blockPos = context.getClickedPos(); CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockPos); @@ -46,7 +45,7 @@ public abstract class ConcretePowderBlockMixin extends FallingBlockMixin { } @Redirect(method = "updateShape", at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/ConcretePowderBlock;concrete:Lnet/minecraft/world/level/block/state/BlockState;")) - public BlockState arclight$blockForm(@Coerce ConcretePowderBlockMixin block, BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { + public BlockState arclight$blockForm(ConcretePowderBlock instance, BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) { if (!(worldIn instanceof Level)) { return this.concrete; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CropBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CropBlockMixin.java index 6e9f3e75..4bea43a3 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CropBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/CropBlockMixin.java @@ -1,9 +1,13 @@ package io.izzel.arclight.common.mixin.core.world.level.block; +import io.izzel.arclight.common.bridge.core.world.WorldBridge; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.CropBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.event.ForgeEventFactory; @@ -11,7 +15,9 @@ import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.event.entity.EntityChangeBlockEvent; 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; @Mixin(CropBlock.class) public class CropBlockMixin { @@ -33,4 +39,23 @@ public class CropBlockMixin { public boolean arclight$blockGrowTick(ServerLevel world, BlockPos pos, BlockState newState, int flags) { return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags); } + + @Inject(method = "getGrowthSpeed", at = @At("RETURN")) + private static void arclight$spigotModifier(Block block, BlockGetter blockGetter, BlockPos pos, CallbackInfoReturnable cir) { + if (blockGetter instanceof WorldBridge bridge) { + int modifier; + if (block == Blocks.BEETROOTS) { + modifier = bridge.bridge$spigotConfig().beetrootModifier; + } else if (block ==Blocks.CARROTS) { + modifier = bridge.bridge$spigotConfig().carrotModifier; + } else if (block == Blocks.POTATOES) { + modifier = bridge.bridge$spigotConfig().potatoModifier; + } else { + modifier = bridge.bridge$spigotConfig().wheatModifier; + } + var f = cir.getReturnValueF(); + f /= (100F / modifier); + cir.setReturnValue(f); + } + } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/DragonEggBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/DragonEggBlockMixin.java index f151983f..a97ef2e7 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/DragonEggBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/DragonEggBlockMixin.java @@ -4,6 +4,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.DragonEggBlock; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.border.WorldBorder; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.block.CraftBlock; import org.bukkit.event.block.BlockFromToEvent; @@ -21,7 +22,7 @@ public class DragonEggBlockMixin { @Inject(method = "teleport", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "FIELD", target = "Lnet/minecraft/world/level/Level;isClientSide:Z")) public void arclight$blockFromTo(BlockState blockState, Level world, BlockPos blockPos, CallbackInfo ci, - int i, BlockPos pos) { + WorldBorder wb, int i, BlockPos pos) { org.bukkit.block.Block from = CraftBlock.at(world, blockPos); org.bukkit.block.Block to = CraftBlock.at(world, pos); BlockFromToEvent event = new BlockFromToEvent(from, to); @@ -35,7 +36,7 @@ public class DragonEggBlockMixin { private transient BlockPos arclight$toBlock; - @ModifyVariable(method = "teleport", index = 5, name = "blockpos", at = @At(value = "JUMP", opcode = Opcodes.IFEQ, ordinal = 1)) + @ModifyVariable(method = "teleport", index = 6, name = "blockpos", at = @At(value = "JUMP", opcode = Opcodes.IFEQ, ordinal = 1)) public BlockPos arclight$setPos(BlockPos pos) { return arclight$toBlock; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/FireBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/FireBlockMixin.java index 45233569..521783b4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/FireBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/FireBlockMixin.java @@ -30,7 +30,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Random; @Mixin(FireBlock.class) -public abstract class FireBlockMixin implements FireBlockBridge { +public abstract class FireBlockMixin extends BaseFireBlockMixin implements FireBlockBridge { // @formatter:off @Shadow protected abstract BlockState getStateForPlacement(BlockGetter blockReader, BlockPos pos); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/GrassBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/GrassBlockMixin.java deleted file mode 100644 index bf85e05d..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/GrassBlockMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.izzel.arclight.common.mixin.core.world.level.block; - -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.block.GrassBlock; -import net.minecraft.world.level.block.state.BlockState; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(GrassBlock.class) -public class GrassBlockMixin { - - @Redirect(method = "performBonemeal", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) - public boolean arclight$blockGrow(ServerLevel world, BlockPos pos, BlockState newState, int flags) { - return CraftEventFactory.handleBlockGrowEvent(world, pos, newState, flags); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PointedDripstoneBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PointedDripstoneBlockMixin.java new file mode 100644 index 00000000..a40f4269 --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PointedDripstoneBlockMixin.java @@ -0,0 +1,37 @@ +package io.izzel.arclight.common.mixin.core.world.level.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.PointedDripstoneBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.DripstoneThickness; +import net.minecraft.world.level.material.Fluids; +import org.bukkit.craftbukkit.v.event.CraftEventFactory; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +import static net.minecraft.world.level.block.PointedDripstoneBlock.THICKNESS; +import static net.minecraft.world.level.block.PointedDripstoneBlock.TIP_DIRECTION; +import static net.minecraft.world.level.block.PointedDripstoneBlock.WATERLOGGED; + +@Mixin(PointedDripstoneBlock.class) +public class PointedDripstoneBlockMixin { + + @Redirect(method = "createMergedTips", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/PointedDripstoneBlock;createDripstone(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;Lnet/minecraft/world/level/block/state/properties/DripstoneThickness;)V")) + private static void arclight$changeBlock1(LevelAccessor level, BlockPos pos, Direction direction, DripstoneThickness thickness, + BlockState p_154231_, LevelAccessor p_154232_, BlockPos source) { + var state = Blocks.POINTED_DRIPSTONE.defaultBlockState().setValue(TIP_DIRECTION, direction).setValue(THICKNESS, thickness).setValue(WATERLOGGED, level.getFluidState(pos).getType() == Fluids.WATER); + CraftEventFactory.handleBlockSpreadEvent(level, source, pos, state, 3); + } + + @Redirect(method = "grow", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/PointedDripstoneBlock;createDripstone(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;Lnet/minecraft/world/level/block/state/properties/DripstoneThickness;)V")) + private static void arclight$changeBlock2(LevelAccessor level, BlockPos pos, Direction direction, DripstoneThickness thickness, + ServerLevel p_154036_, BlockPos source, Direction p_154038_) { + var state = Blocks.POINTED_DRIPSTONE.defaultBlockState().setValue(TIP_DIRECTION, direction).setValue(THICKNESS, thickness).setValue(WATERLOGGED, level.getFluidState(pos).getType() == Fluids.WATER); + CraftEventFactory.handleBlockSpreadEvent(level, source, pos, state, 3); + } +} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PortalSizeMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PortalShapeMixin.java similarity index 90% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PortalSizeMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PortalShapeMixin.java index 5bbf77ae..e0550340 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PortalSizeMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PortalShapeMixin.java @@ -39,16 +39,16 @@ import java.util.ArrayList; import java.util.List; @Mixin(PortalShape.class) -public abstract class PortalSizeMixin implements PortalSizeBridge { +public abstract class PortalShapeMixin implements PortalSizeBridge { // @formatter:off @Shadow @Final private LevelAccessor level; - @Shadow public abstract void createPortalBlocks(); + @Shadow public abstract void shadow$createPortalBlocks(); @Shadow @Final private Direction.Axis axis; @Shadow @Nullable private BlockPos bottomLeft; @Shadow private int height; @Shadow @Final private Direction rightDir; - @Shadow private int width; + @Shadow @Final private int width; @Shadow public static PortalInfo createPortalInfo(ServerLevel world, BlockUtil.FoundRectangle result, Direction.Axis axis, Vec3 offsetVector, EntityDimensions size, Vec3 motion, float rotationYaw, float rotationPitch) { return null; } // @formatter:on @@ -82,14 +82,14 @@ public abstract class PortalSizeMixin implements PortalSizeBridge { private transient boolean arclight$ret; - public boolean createPortal() { - this.createPortalBlocks(); + public boolean createPortalBlocks() { + this.shadow$createPortalBlocks(); return arclight$ret; } @Override public boolean bridge$createPortal() { - return createPortal(); + return createPortalBlocks(); } @SuppressWarnings("ConstantConditions") @@ -101,7 +101,7 @@ public abstract class PortalSizeMixin implements PortalSizeBridge { return portalInfo; } - private static PortalInfo a(ServerLevel world, BlockUtil.FoundRectangle result, Direction.Axis axis, Vec3 offsetVector, EntityDimensions size, Vec3 motion, float rotationYaw, float rotationPitch, CraftPortalEvent event) { + private static PortalInfo createPortalInfo(ServerLevel world, BlockUtil.FoundRectangle result, Direction.Axis axis, Vec3 offsetVector, EntityDimensions size, Vec3 motion, float rotationYaw, float rotationPitch, CraftPortalEvent event) { ArclightCaptures.captureCraftPortalEvent(event); return createPortalInfo(world, result, axis, offsetVector, size, motion, rotationYaw, rotationPitch); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/TntBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/TntBlockMixin.java index b730eb3e..37df3798 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/TntBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/TntBlockMixin.java @@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(TntBlock.class) public class TntBlockMixin { - @Inject(method = "onProjectileHit", cancellable = true, at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraft/world/level/block/TntBlock;catchFire(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;Lnet/minecraft/world/entity/LivingEntity;)V")) + @Inject(method = "onProjectileHit", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/TntBlock;onCaughtFire(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;Lnet/minecraft/world/entity/LivingEntity;)V")) public void arclight$entityChangeBlock(Level worldIn, BlockState state, BlockHitResult hit, Projectile projectile, CallbackInfo ci) { if (CraftEventFactory.callEntityChangeBlockEvent(projectile, hit.getBlockPos(), Blocks.AIR.defaultBlockState()).isCancelled()) { ci.cancel(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/TripWireBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/TripWireBlockMixin.java index 1de5f2ee..c42a6188 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/TripWireBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/TripWireBlockMixin.java @@ -86,7 +86,7 @@ public abstract class TripWireBlockMixin extends BlockMixin { } if (flag1) { - worldIn.getBlockTicks().scheduleTick(new BlockPos(pos), (Block) (Object) this, 10); + worldIn.scheduleTick(new BlockPos(pos), (Block) (Object) this, 10); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/WitherSkullBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/WitherSkullBlockMixin.java index 944661d4..bc725fb7 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/WitherSkullBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/WitherSkullBlockMixin.java @@ -5,10 +5,10 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.WitherSkullBlock; import net.minecraft.world.level.block.entity.SkullBlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.common.util.Constants; import org.bukkit.craftbukkit.v.util.BlockStateListPopulator; import org.bukkit.event.entity.CreatureSpawnEvent; import org.spongepowered.asm.mixin.Mixin; @@ -41,7 +41,7 @@ public class WitherSkullBlockMixin { if (arclight$success) { if (arclight$populator != null) { for (BlockPos pos : arclight$populator.getBlocks()) { - worldIn.levelEvent(Constants.WorldEvents.BREAK_BLOCK_EFFECTS, pos, Block.getId(worldIn.getBlockState(pos))); + worldIn.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(worldIn.getBlockState(pos))); } arclight$populator.updateList(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin.java index a2dd0b6b..f3f743b7 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/AbstractFurnaceBlockEntityMixin.java @@ -141,7 +141,7 @@ public abstract class AbstractFurnaceBlockEntityMixin extends LockableBlockEntit private static ItemStack arclight$item; private static int arclight$captureAmount; - public List> a(ServerLevel world, Vec3 vec, BlockPos pos, Player entity, ItemStack itemStack, int amount) { + public List> getRecipesToAwardAndPopExperience(ServerLevel world, Vec3 vec, BlockPos pos, Player entity, ItemStack itemStack, int amount) { try { arclight$item = itemStack; arclight$captureAmount = amount; @@ -161,7 +161,7 @@ public abstract class AbstractFurnaceBlockEntityMixin extends LockableBlockEntit @Override public List> bridge$dropExp(ServerPlayer entity, ItemStack itemStack, int amount) { - return a(entity.getLevel(), entity.position(), this.worldPosition, entity, itemStack, amount); + return getRecipesToAwardAndPopExperience(entity.getLevel(), entity.position(), this.worldPosition, entity, itemStack, amount); } @Redirect(method = "createExperience", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ExperienceOrb;award(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/phys/Vec3;I)V")) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/BeehiveBlockEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/BeehiveBlockEntityMixin.java index f8b32d05..491ccbff 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/BeehiveBlockEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/BeehiveBlockEntityMixin.java @@ -27,7 +27,6 @@ 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.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import javax.annotation.Nullable; import java.util.List; @@ -125,8 +124,8 @@ public abstract class BeehiveBlockEntityMixin extends BlockEntityMixin { } } - @Inject(method = "save", at = @At("RETURN")) - private void arclight$writeMax(CompoundTag compound, CallbackInfoReturnable cir) { + @Inject(method = "saveAdditional", at = @At("RETURN")) + private void arclight$writeMax(CompoundTag compound, CallbackInfo ci) { compound.putInt("Bukkit.MaxEntities", this.maxBees); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/BlockEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/BlockEntityMixin.java index 5cbd4866..8061e266 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/BlockEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/BlockEntityMixin.java @@ -46,10 +46,10 @@ public abstract class BlockEntityMixin implements TileEntityBridge { } } - @Inject(method = "saveMetadata", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/CompoundTag;putString(Ljava/lang/String;Ljava/lang/String;)V")) - public void arclight$savePersistent(CompoundTag compound, CallbackInfoReturnable cir) { + @Inject(method = "saveWithoutMetadata", at = @At("RETURN")) + private void arclight$savePersistent(CallbackInfoReturnable cir) { if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) { - compound.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound()); + cir.getReturnValue().put("PublicBukkitValues", this.persistentDataContainer.toTagCompound()); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkAccessMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkAccessMixin.java new file mode 100644 index 00000000..188c5ca7 --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkAccessMixin.java @@ -0,0 +1,82 @@ +package io.izzel.arclight.common.mixin.core.world.level.chunk; + +import io.izzel.arclight.common.bridge.core.world.chunk.ChunkAccessBridge; +import io.izzel.arclight.common.bridge.core.world.chunk.LevelChunkSectionBridge; +import net.minecraft.CrashReport; +import net.minecraft.CrashReportCategory; +import net.minecraft.ReportedException; +import net.minecraft.core.BlockPos; +import net.minecraft.core.QuartPos; +import net.minecraft.core.Registry; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.util.Mth; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.LevelHeightAccessor; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.biome.BiomeManager; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.FeatureAccess; +import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.chunk.UpgradeData; +import net.minecraft.world.level.levelgen.blending.BlendingData; +import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataContainer; +import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataTypeRegistry; +import org.bukkit.persistence.PersistentDataContainer; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Map; + +@Mixin(ChunkAccess.class) +public abstract class ChunkAccessMixin implements BlockGetter, BiomeManager.NoiseBiomeSource, FeatureAccess, ChunkAccessBridge { + + // @formatter:off + @Shadow public abstract void setUnsaved(boolean p_62094_); + @Shadow public abstract int getMinBuildHeight(); + @Shadow public abstract int getHeight(); + @Shadow public boolean isUnsaved() { return false; } + @Shadow @Final protected LevelChunkSection[] sections; + @Shadow @Final protected Map pendingBlockEntities; + @Shadow @Final protected ChunkPos chunkPos; + // @formatter:on + + + private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); + public CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY); + public Registry biomeRegistry; + + @Inject(method = "", at = @At("RETURN")) + private void arclight$init(ChunkPos p_187621_, UpgradeData p_187622_, LevelHeightAccessor p_187623_, Registry registry, long p_187625_, LevelChunkSection[] p_187626_, BlendingData p_187627_, CallbackInfo ci) { + this.biomeRegistry = registry; + this.persistentDataContainer.setCallback(() -> this.setUnsaved(true)); + } + + @Override + public PersistentDataContainer bridge$getPersistentDataContainer() { + return this.persistentDataContainer; + } + + public void setBiome(int i, int j, int k, Biome biome) { + try { + int l = QuartPos.fromBlock(this.getMinBuildHeight()); + int i1 = l + QuartPos.fromBlock(this.getHeight()) - 1; + int j1 = Mth.clamp(j, l, i1); + int k1 = this.getSectionIndex(QuartPos.toBlock(j1)); + + ((LevelChunkSectionBridge) this.sections[k1]).bridge$setBiome(i & 3, j1 & 3, k & 3, biome); + } catch (Throwable throwable) { + CrashReport crashreport = CrashReport.forThrowable(throwable, "Setting biome"); + CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Biome being set"); + + crashreportsystemdetails.setDetail("Location", () -> { + return CrashReportCategory.formatLocation(this, i, j, k); + }); + throw new ReportedException(crashreport); + } + } +} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkBiomeContainerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkBiomeContainerMixin.java deleted file mode 100644 index eb935767..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkBiomeContainerMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.izzel.arclight.common.mixin.core.world.level.chunk; - -import net.minecraft.util.Mth; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.chunk.ChunkBiomeContainer; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(ChunkBiomeContainer.class) -public class ChunkBiomeContainerMixin { - - // @formatter:off - @Shadow @Final private Biome[] biomes; - @Shadow @Final private static int WIDTH_BITS; - @Shadow @Final private static int HORIZONTAL_MASK; - @Shadow @Final private int quartMinY; - @Shadow @Final private int quartHeight; - // @formatter:on - - public void setBiome(int i, int j, int k, Biome biome) { - int l = i & HORIZONTAL_MASK; - int i1 = Mth.clamp(j - this.quartMinY, 0, this.quartHeight); - int j1 = k & HORIZONTAL_MASK; - - this.biomes[i1 << WIDTH_BITS + WIDTH_BITS | j1 << WIDTH_BITS | l] = biome; - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/LevelChunkMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/LevelChunkMixin.java index 3db13692..3db006bc 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/LevelChunkMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/LevelChunkMixin.java @@ -1,29 +1,27 @@ package io.izzel.arclight.common.mixin.core.world.level.chunk; import io.izzel.arclight.common.bridge.core.world.WorldBridge; +import io.izzel.arclight.common.bridge.core.world.chunk.ChunkAccessBridge; import io.izzel.arclight.common.bridge.core.world.chunk.ChunkBridge; import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; -import net.minecraft.world.level.TickList; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.ChunkBiomeContainer; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.chunk.UpgradeData; +import net.minecraft.world.level.levelgen.blending.BlendingData; import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.ticks.LevelChunkTicks; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.CraftChunk; import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataContainer; -import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataTypeRegistry; import org.bukkit.event.world.ChunkLoadEvent; 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.Inject; @@ -31,18 +29,13 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import javax.annotation.Nullable; -import java.util.Map; -import java.util.function.Consumer; @Mixin(LevelChunk.class) -public abstract class LevelChunkMixin implements ChunkBridge { +public abstract class LevelChunkMixin extends ChunkAccessMixin implements ChunkBridge { // @formatter:off @Shadow @Nullable public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving); @Shadow @Final public Level level; - @Shadow @Final private ChunkPos chunkPos; - @Shadow private volatile boolean unsaved; - @Shadow @Final private Map pendingBlockEntities; // @formatter:on public org.bukkit.Chunk bukkitChunk; @@ -51,18 +44,16 @@ public abstract class LevelChunkMixin implements ChunkBridge { private transient boolean arclight$doPlace; public ServerLevel $$level; - private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); - public final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY); - - @Inject(method = "(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/ChunkBiomeContainer;Lnet/minecraft/world/level/chunk/UpgradeData;Lnet/minecraft/world/level/TickList;Lnet/minecraft/world/level/TickList;J[Lnet/minecraft/world/level/chunk/LevelChunkSection;Ljava/util/function/Consumer;)V", at = @At("RETURN")) - private void arclight$init(Level worldIn, ChunkPos chunkPosIn, ChunkBiomeContainer biomeContainerIn, UpgradeData upgradeDataIn, TickList tickBlocksIn, TickList tickFluidsIn, long inhabitedTimeIn, LevelChunkSection[] sectionsIn, Consumer postLoadConsumerIn, CallbackInfo ci) { + @Inject(method = "(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/chunk/UpgradeData;Lnet/minecraft/world/ticks/LevelChunkTicks;Lnet/minecraft/world/ticks/LevelChunkTicks;J[Lnet/minecraft/world/level/chunk/LevelChunkSection;Lnet/minecraft/world/level/chunk/LevelChunk$PostLoadProcessor;Lnet/minecraft/world/level/levelgen/blending/BlendingData;)V", at = @At("RETURN")) + private void arclight$init(Level worldIn, ChunkPos p_196855_, UpgradeData p_196856_, LevelChunkTicks p_196857_, LevelChunkTicks p_196858_, long p_196859_, @Nullable LevelChunkSection[] p_196860_, @Nullable LevelChunk.PostLoadProcessor p_196861_, @Nullable BlendingData p_196862_, CallbackInfo ci) { this.$$level = ((ServerLevel) worldIn); - bridge$setBukkitChunk(new CraftChunk((LevelChunk) (Object) this)); + this.bukkitChunk = new CraftChunk((LevelChunk) (Object) this); } - @Inject(method = "(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ProtoChunk;Ljava/util/function/Consumer;)V", at = @At("RETURN")) - private void arclight$init(ServerLevel p_156365_, ProtoChunk p_156366_, Consumer p_156367_, CallbackInfo ci) { + @Inject(method = "(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/chunk/ProtoChunk;Lnet/minecraft/world/level/chunk/LevelChunk$PostLoadProcessor;)V", at = @At("RETURN")) + private void arclight$init(ServerLevel p_196850_, ProtoChunk protoChunk, @Nullable LevelChunk.PostLoadProcessor p_196852_, CallbackInfo ci) { this.needsDecoration = true; + this.persistentDataContainer = (CraftPersistentDataContainer) ((ChunkAccessBridge) protoChunk).bridge$getPersistentDataContainer(); } @Inject(method = "removeBlockEntity", at = @At(value = "INVOKE_ASSIGN", remap = false, target = "Ljava/util/Map;remove(Ljava/lang/Object;)Ljava/lang/Object;")) @@ -91,12 +82,7 @@ public abstract class LevelChunkMixin implements ChunkBridge { this.bukkitChunk = chunk; } - public BlockState setType(BlockPos pos, BlockState state, boolean isMoving, boolean doPlace) { - return this.bridge$setType(pos, state, isMoving, doPlace); - } - - @Override - public BlockState bridge$setType(BlockPos pos, BlockState state, boolean isMoving, boolean doPlace) { + public BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving, boolean doPlace) { this.arclight$doPlace = doPlace; try { return this.setBlockState(pos, state, isMoving); @@ -105,6 +91,11 @@ public abstract class LevelChunkMixin implements ChunkBridge { } } + @Override + public BlockState bridge$setType(BlockPos pos, BlockState state, boolean isMoving, boolean doPlace) { + return this.setBlockState(pos, state, isMoving, doPlace); + } + @Override public boolean bridge$isMustNotSave() { return this.mustNotSave; @@ -177,12 +168,8 @@ public abstract class LevelChunkMixin implements ChunkBridge { return world.isClientSide && this.arclight$doPlace; } - /** - * @author IzzelAliz - * @reason - */ - @Overwrite + @Override public boolean isUnsaved() { - return !this.mustNotSave && this.unsaved; + return super.isUnsaved() && !this.mustNotSave; } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/LevelChunkSectionMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/LevelChunkSectionMixin.java new file mode 100644 index 00000000..fefbdf45 --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/LevelChunkSectionMixin.java @@ -0,0 +1,24 @@ +package io.izzel.arclight.common.mixin.core.world.level.chunk; + +import io.izzel.arclight.common.bridge.core.world.chunk.LevelChunkSectionBridge; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.chunk.PalettedContainer; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(LevelChunkSection.class) +public class LevelChunkSectionMixin implements LevelChunkSectionBridge { + + @Shadow @Final private PalettedContainer biomes; + + public void setBiome(int i, int j, int k, Biome biome) { + this.biomes.set(i, j, k, biome); + } + + @Override + public void bridge$setBiome(int x, int y, int z, Biome biome) { + this.setBiome(x, y, z, biome); + } +} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/ChunkLoaderMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/ChunkLoaderMixin.java index 4f525f77..f9aff9a3 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/ChunkLoaderMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/ChunkLoaderMixin.java @@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableList; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; import net.minecraft.world.level.chunk.storage.ChunkStorage; -import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.levelgen.structure.LegacyStructureDataHandler; import net.minecraft.world.level.storage.DimensionDataStorage; import org.spongepowered.asm.mixin.Mixin; @@ -26,12 +26,12 @@ public abstract class ChunkLoaderMixin { * From {@link LegacyStructureDataHandler#getLegacyStructureHandler(ResourceKey, DimensionDataStorage)} */ private static LegacyStructureDataHandler legacyDataOf(ResourceKey typeKey, @Nullable DimensionDataStorage dataManager) { - if (typeKey == DimensionType.OVERWORLD_LOCATION || typeKey == Level.OVERWORLD) { + if (typeKey == LevelStem.OVERWORLD || typeKey == Level.OVERWORLD) { return new LegacyStructureDataHandler(dataManager, ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument")); - } else if (typeKey == DimensionType.NETHER_LOCATION || typeKey == Level.NETHER) { + } else if (typeKey == LevelStem.NETHER || typeKey == Level.NETHER) { List list1 = ImmutableList.of("Fortress"); return new LegacyStructureDataHandler(dataManager, list1, list1); - } else if (typeKey == DimensionType.END_LOCATION || typeKey == Level.END) { + } else if (typeKey == LevelStem.END || typeKey == Level.END) { List list = ImmutableList.of("EndCity"); return new LegacyStructureDataHandler(dataManager, list, list); } else { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/ChunkSerializerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/ChunkSerializerMixin.java new file mode 100644 index 00000000..e84433ff --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/ChunkSerializerMixin.java @@ -0,0 +1,38 @@ +package io.izzel.arclight.common.mixin.core.world.level.chunk.storage; + +import io.izzel.arclight.common.bridge.core.world.chunk.ChunkAccessBridge; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.ai.village.poi.PoiManager; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ProtoChunk; +import net.minecraft.world.level.chunk.storage.ChunkSerializer; +import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataContainer; +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; + +@Mixin(ChunkSerializer.class) +public class ChunkSerializerMixin { + + @Redirect(method = "read", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/ChunkAccess;setLightCorrect(Z)V")) + private static void arclight$loadPersistent(ChunkAccess instance, boolean correct, ServerLevel level, PoiManager poiManager, ChunkPos pos, CompoundTag tag, CallbackInfoReturnable cir) { + net.minecraft.nbt.Tag persistentBase = tag.get("ChunkBukkitValues"); + if (persistentBase instanceof CompoundTag) { + ((CraftPersistentDataContainer) ((ChunkAccessBridge) instance).bridge$getPersistentDataContainer()).putAll((CompoundTag) persistentBase); + } + instance.setLightCorrect(correct); + } + + + @Inject(method = "write", at = @At("RETURN")) + private static void arclight$savePersistent(ServerLevel level, ChunkAccess chunkAccess, CallbackInfoReturnable cir) { + var container = (CraftPersistentDataContainer) ((ChunkAccessBridge) chunkAccess).bridge$getPersistentDataContainer(); + if (!container.isEmpty()) { + cir.getReturnValue().put("ChunkBukkitValues", container.toTagCompound()); + } + } +} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/RegionFileCacheMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/RegionFileCacheMixin.java index a814b35d..a4dd0d02 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/RegionFileCacheMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/storage/RegionFileCacheMixin.java @@ -2,6 +2,7 @@ package io.izzel.arclight.common.mixin.core.world.level.chunk.storage; import io.izzel.arclight.common.bridge.core.world.chunk.storage.RegionFileCacheBridge; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.StreamTagVisitor; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.storage.RegionFile; import net.minecraft.world.level.chunk.storage.RegionFileStorage; @@ -53,6 +54,18 @@ public abstract class RegionFileCacheMixin implements RegionFileCacheBridge { this.arclight$existOnly = false; } + @Inject(method = "scanChunk", at = @At("HEAD")) + private void arclight$scan(CallbackInfo ci) { + this.arclight$existOnly = true; + } + + @Inject(method = "scanChunk", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/storage/RegionFile;getChunkDataInputStream(Lnet/minecraft/world/level/ChunkPos;)Ljava/io/DataInputStream;")) + private void arclight$retIfNotFound(ChunkPos p_196957_, StreamTagVisitor p_196958_, CallbackInfo ci, RegionFile rf) { + if (rf == null) { + ci.cancel(); + } + } + public boolean chunkExists(ChunkPos pos) throws IOException { RegionFile regionFile = loadFile(pos, true); return regionFile != null && regionFile.hasChunk(pos); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/ChunkGeneratorMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/ChunkGeneratorMixin.java index 44def114..b7fd2d35 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/ChunkGeneratorMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/ChunkGeneratorMixin.java @@ -5,9 +5,11 @@ import io.izzel.arclight.common.bridge.core.world.WorldBridge; import io.izzel.arclight.common.bridge.core.world.level.levelgen.ChunkGeneratorBridge; import net.minecraft.server.level.WorldGenRegion; import net.minecraft.world.level.StructureFeatureManager; +import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.biome.BiomeSource; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.LegacyRandomSource; import net.minecraft.world.level.levelgen.WorldgenRandom; import org.bukkit.craftbukkit.v.generator.CraftLimitedRegion; import org.bukkit.generator.BlockPopulator; @@ -22,23 +24,23 @@ import java.util.Random; public abstract class ChunkGeneratorMixin implements ChunkGeneratorBridge { // @formatter:off - @Shadow public abstract void applyBiomeDecoration(WorldGenRegion p_62168_, StructureFeatureManager p_62169_); + @Shadow public abstract void applyBiomeDecoration(WorldGenLevel p_187712_, ChunkAccess p_187713_, StructureFeatureManager p_187714_); @Shadow @Final @Mutable protected BiomeSource biomeSource; @Shadow @Final @Mutable protected BiomeSource runtimeBiomeSource; // @formatter:on - public void addDecorations(WorldGenRegion region, StructureFeatureManager structureManager, boolean vanilla) { + public void addDecorations(WorldGenLevel region, ChunkAccess chunk, StructureFeatureManager structureManager, boolean vanilla) { if (vanilla) { - this.applyBiomeDecoration(region, structureManager); + this.applyBiomeDecoration(region, chunk, structureManager); } org.bukkit.World world = ((WorldBridge) ((IWorldBridge) region).bridge$getMinecraftWorld()).bridge$getWorld(); // only call when a populator is present (prevents unnecessary entity conversion) - if (world.getPopulators().size() != 0) { - CraftLimitedRegion limitedRegion = new CraftLimitedRegion(region); - int x = region.getCenter().x; - int z = region.getCenter().z; + if (!world.getPopulators().isEmpty()) { + CraftLimitedRegion limitedRegion = new CraftLimitedRegion(region, chunk.getPos()); + int x = chunk.getPos().x; + int z = chunk.getPos().z; for (BlockPopulator populator : world.getPopulators()) { - WorldgenRandom random = new WorldgenRandom(); + WorldgenRandom random = new WorldgenRandom(new LegacyRandomSource(region.getSeed())); random.setDecorationSeed(region.getSeed(), x, z); populator.populate(world, random, x, z, limitedRegion); } @@ -55,11 +57,6 @@ public abstract class ChunkGeneratorMixin implements ChunkGeneratorBridge { throw new UnsupportedOperationException("Methode not overridden"); } - @Override - public void bridge$addDecorations(WorldGenRegion region, StructureFeatureManager structureManager, boolean vanilla) { - addDecorations(region, structureManager, vanilla); - } - @Override public void bridge$buildBedrock(ChunkAccess chunkAccess, Random random) { buildBedrock(chunkAccess, random); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/NoiseBasedChunkGeneratorMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/NoiseBasedChunkGeneratorMixin.java deleted file mode 100644 index 0f86c14d..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/levelgen/NoiseBasedChunkGeneratorMixin.java +++ /dev/null @@ -1,53 +0,0 @@ -package io.izzel.arclight.common.mixin.core.world.level.levelgen; - -import net.minecraft.server.level.WorldGenRegion; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; -import net.minecraft.world.level.levelgen.WorldgenRandom; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import java.util.Random; - -@Mixin(NoiseBasedChunkGenerator.class) -public abstract class NoiseBasedChunkGeneratorMixin extends ChunkGeneratorMixin { - - // @formatter:off - @Shadow public abstract void buildSurfaceAndBedrock(WorldGenRegion p_64381_, ChunkAccess p_64382_); - @Shadow protected abstract void setBedrock(ChunkAccess pChunk, Random pRandom); - // @formatter:on - - private transient boolean arclight$skipBedrock; - private transient WorldgenRandom arclight$random; - - @Inject(method = "buildSurfaceAndBedrock", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/NoiseBasedChunkGenerator;setBedrock(Lnet/minecraft/world/level/chunk/ChunkAccess;Ljava/util/Random;)V")) - private void arclight$skipAndReturn(WorldGenRegion region, ChunkAccess chunkAccess, CallbackInfo ci, ChunkPos chunkPos, int i, int j, WorldgenRandom random) { - if (arclight$skipBedrock) { - arclight$random = random; - ci.cancel(); - } - } - - @Override - public WorldgenRandom buildSurface(WorldGenRegion region, ChunkAccess chunkAccess) { - try { - arclight$skipBedrock = true; - this.buildSurfaceAndBedrock(region, chunkAccess); - return arclight$random; - } finally { - arclight$random = null; - arclight$skipBedrock = false; - } - } - - @Override - public void buildBedrock(ChunkAccess chunkAccess, Random random) { - this.setBedrock(chunkAccess, random); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/portal/PortalForcerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/portal/PortalForcerMixin.java index ba7ee9b0..3868f9fb 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/portal/PortalForcerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/portal/PortalForcerMixin.java @@ -9,6 +9,7 @@ import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.border.WorldBorder; import net.minecraft.world.level.portal.PortalForcer; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.CraftWorld; @@ -34,7 +35,7 @@ public abstract class PortalForcerMixin implements TeleporterBridge { // @formatter:off @Shadow public abstract Optional createPortal(BlockPos pos, Direction.Axis axis); @Shadow @Final protected ServerLevel level; - @Shadow public abstract Optional findPortalAround(BlockPos pos, boolean isNether); + @Shadow public abstract Optional findPortalAround(BlockPos p_192986_, boolean p_192987_, WorldBorder p_192988_); // @formatter:on @ModifyVariable(method = "findPortalAround", index = 4, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/village/poi/PoiManager;ensureLoadedAndValid(Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;I)V")) @@ -44,18 +45,18 @@ public abstract class PortalForcerMixin implements TeleporterBridge { private transient int arclight$searchRadius = -1; - public Optional findPortal(BlockPos pos, int searchRadius) { + public Optional findPortalAround(BlockPos pos, WorldBorder worldBorder, int searchRadius) { this.arclight$searchRadius = searchRadius; try { - return this.findPortalAround(pos, false); + return this.findPortalAround(pos, false, worldBorder); } finally { this.arclight$searchRadius = -1; } } @Override - public Optional bridge$findPortal(BlockPos pos, int searchRadius) { - return findPortal(pos, searchRadius); + public Optional bridge$findPortal(BlockPos pos, WorldBorder worldborder, int searchRadius) { + return findPortalAround(pos, worldborder, searchRadius); } @ModifyArg(method = "createPortal", index = 1, at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos;spiralAround(Lnet/minecraft/core/BlockPos;ILnet/minecraft/core/Direction;Lnet/minecraft/core/Direction;)Ljava/lang/Iterable;")) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/saveddata/maps/MapData_MapInfoMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/saveddata/maps/MapItemSavedData_HoldingPlayerMixin.java similarity index 93% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/saveddata/maps/MapData_MapInfoMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/saveddata/maps/MapItemSavedData_HoldingPlayerMixin.java index 52bd97f6..09d465c0 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/saveddata/maps/MapData_MapInfoMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/saveddata/maps/MapItemSavedData_HoldingPlayerMixin.java @@ -20,10 +20,10 @@ import java.util.ArrayList; import java.util.Collection; @Mixin(MapItemSavedData.HoldingPlayer.class) -public abstract class MapData_MapInfoMixin { +public abstract class MapItemSavedData_HoldingPlayerMixin { // @formatter:off - @SuppressWarnings("target") @Shadow(aliases = {"this$0", "field_176107_c"}, remap = false) private MapItemSavedData outerThis; + @SuppressWarnings("target") @Shadow(aliases = {"this$0", "f_77961_"}, remap = false) private MapItemSavedData outerThis; @Shadow private boolean dirtyData; @Shadow private int minDirtyX; @Shadow private int minDirtyY; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/AbstractSpawnerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/BaseSpawnerMixin.java similarity index 77% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/AbstractSpawnerMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/BaseSpawnerMixin.java index 4930feca..f2475263 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/AbstractSpawnerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/BaseSpawnerMixin.java @@ -7,7 +7,8 @@ import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.random.WeightedRandomList; +import net.minecraft.util.random.SimpleWeightedRandomList; +import net.minecraft.world.Difficulty; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; @@ -15,6 +16,7 @@ import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.SpawnData; import net.minecraft.world.phys.AABB; import net.minecraftforge.event.ForgeEventFactory; @@ -30,23 +32,22 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Optional; @Mixin(BaseSpawner.class) -public abstract class AbstractSpawnerMixin { +public abstract class BaseSpawnerMixin { // @formatter:off - @Shadow public WeightedRandomList spawnPotentials; + @Shadow public SimpleWeightedRandomList spawnPotentials; @Shadow public int spawnDelay; @Shadow public int spawnCount; @Shadow public SpawnData nextSpawnData; @Shadow public int spawnRange; @Shadow public int maxNearbyEntities; - @Shadow private static WeightedRandomList EMPTY_POTENTIALS; @Shadow protected abstract boolean isNearPlayer(Level p_151344_, BlockPos p_151345_); @Shadow protected abstract void delay(Level p_151351_, BlockPos p_151352_); // @formatter:on @Inject(method = "setEntityId", at = @At("RETURN")) public void arclight$clearMobs(EntityType type, CallbackInfo ci) { - this.spawnPotentials = EMPTY_POTENTIALS; + this.spawnPotentials = SimpleWeightedRandomList.empty(); } /** @@ -66,7 +67,7 @@ public abstract class AbstractSpawnerMixin { boolean flag = false; for (int i = 0; i < this.spawnCount; ++i) { - CompoundTag compoundtag = this.nextSpawnData.getTag(); + CompoundTag compoundtag = this.nextSpawnData.getEntityToSpawn(); Optional> optional = EntityType.by(compoundtag); if (optional.isEmpty()) { this.delay(level, pos); @@ -78,7 +79,21 @@ public abstract class AbstractSpawnerMixin { double d0 = j >= 1 ? listtag.getDouble(0) : (double) pos.getX() + (level.random.nextDouble() - level.random.nextDouble()) * (double) this.spawnRange + 0.5D; double d1 = j >= 2 ? listtag.getDouble(1) : (double) (pos.getY() + level.random.nextInt(3) - 1); double d2 = j >= 3 ? listtag.getDouble(2) : (double) pos.getZ() + (level.random.nextDouble() - level.random.nextDouble()) * (double) this.spawnRange + 0.5D; - if (level.noCollision(optional.get().getAABB(d0, d1, d2)) && SpawnPlacements.checkSpawnRules(optional.get(), level, MobSpawnType.SPAWNER, new BlockPos(d0, d1, d2), level.getRandom())) { + if (level.noCollision(optional.get().getAABB(d0, d1, d2))) { + BlockPos blockpos = new BlockPos(d0, d1, d2); + if (this.nextSpawnData.getCustomSpawnRules().isPresent()) { + if (!optional.get().getCategory().isFriendly() && level.getDifficulty() == Difficulty.PEACEFUL) { + continue; + } + + SpawnData.CustomSpawnRules spawndata$customspawnrules = this.nextSpawnData.getCustomSpawnRules().get(); + if (!spawndata$customspawnrules.blockLightLimit().isValueInRange(level.getBrightness(LightLayer.BLOCK, blockpos)) || !spawndata$customspawnrules.skyLightLimit().isValueInRange(level.getBrightness(LightLayer.SKY, blockpos))) { + continue; + } + } else if (!SpawnPlacements.checkSpawnRules(optional.get(), level, MobSpawnType.SPAWNER, blockpos, level.getRandom())) { + continue; + } + Entity entity = EntityType.loadEntityRecursive(compoundtag, level, (p_151310_) -> { p_151310_.moveTo(d0, d1, d2, p_151310_.getYRot(), p_151310_.getXRot()); return p_151310_; @@ -96,11 +111,11 @@ public abstract class AbstractSpawnerMixin { entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), level.random.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob mob) { - if (!ForgeEventFactory.canEntitySpawnSpawner(mob, level, (float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), (BaseSpawner) (Object) this)) { + if (this.nextSpawnData.getCustomSpawnRules().isEmpty() && !ForgeEventFactory.canEntitySpawnSpawner(mob, level, (float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), (BaseSpawner) (Object) this)) { continue; } - if (this.nextSpawnData.getTag().size() == 1 && this.nextSpawnData.getTag().contains("id", 8)) { + if (this.nextSpawnData.getEntityToSpawn().size() == 1 && this.nextSpawnData.getEntityToSpawn().contains("id", 8)) { if (!ForgeEventFactory.doSpecialSpawn(mob, level, (float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), (BaseSpawner) (Object) this, MobSpawnType.SPAWNER)) ((Mob) entity).finalizeSpawn(level, level.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, null, null); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawnerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawnerMixin.java index 4745dd33..692441df 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawnerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawnerMixin.java @@ -91,7 +91,7 @@ public abstract class WorldEntitySpawnerMixin { if (spawnThisTick) { if (limit != 0) { if ((flag || !classification.isFriendly()) && (flag1 || classification.isFriendly()) && (flag2 || !classification.isPersistent()) - && ((WorldEntitySpawnerBridge.EntityDensityManagerBridge) manager).bridge$canSpawn(classification, limit)) { + && ((WorldEntitySpawnerBridge.EntityDensityManagerBridge) manager).bridge$canSpawn(classification, chunk.getPos(), limit)) { spawnCategoryForChunk(classification, world, chunk, ((WorldEntitySpawnerBridge.EntityDensityManagerBridge) manager)::bridge$canSpawn, ((WorldEntitySpawnerBridge.EntityDensityManagerBridge) manager)::bridge$updateDensity); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawner_EntityDensityManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawner_EntityDensityManagerMixin.java index db01b512..f4a45106 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawner_EntityDensityManagerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/WorldEntitySpawner_EntityDensityManagerMixin.java @@ -6,6 +6,8 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.LocalMobCapCalculator; import net.minecraft.world.level.NaturalSpawner; import net.minecraft.world.level.chunk.ChunkAccess; import org.spongepowered.asm.mixin.Final; @@ -20,6 +22,7 @@ public abstract class WorldEntitySpawner_EntityDensityManagerMixin implements Wo @Shadow @Final private int spawnableChunkCount; @Shadow @Final private Object2IntOpenHashMap mobCategoryCounts; @Shadow protected abstract boolean canSpawn(EntityType p_234989_1_, BlockPos p_234989_2_, ChunkAccess p_234989_3_); + @Shadow @Final private LocalMobCapCalculator localMobCapCalculator; // @formatter:on @Override @@ -33,8 +36,8 @@ public abstract class WorldEntitySpawner_EntityDensityManagerMixin implements Wo } @Override - public boolean bridge$canSpawn(MobCategory classification, int limit) { + public boolean bridge$canSpawn(MobCategory classification, ChunkPos pos, int limit) { int i = limit * this.spawnableChunkCount / 289; - return this.mobCategoryCounts.getInt(classification) < i; + return this.mobCategoryCounts.getInt(classification) >= i ? false : this.localMobCapCalculator.canSpawn(classification, pos); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/DerivedWorldInfoMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/DerivedWorldInfoMixin.java index 76c3e8f2..4d57ae4e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/DerivedWorldInfoMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/DerivedWorldInfoMixin.java @@ -3,7 +3,7 @@ package io.izzel.arclight.common.mixin.core.world.storage; import io.izzel.arclight.common.bridge.core.world.storage.DerivedWorldInfoBridge; import io.izzel.arclight.i18n.ArclightConfig; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.storage.DerivedLevelData; import net.minecraft.world.level.storage.ServerLevelData; import org.spongepowered.asm.mixin.Final; @@ -16,7 +16,7 @@ public class DerivedWorldInfoMixin implements DerivedWorldInfoBridge { @Shadow @Final private ServerLevelData wrapped; - private ResourceKey typeKey; + private ResourceKey typeKey; /** * @author IzzelAliz @@ -24,15 +24,15 @@ public class DerivedWorldInfoMixin implements DerivedWorldInfoBridge { */ @Overwrite public String getLevelName() { - if (typeKey == null || typeKey == DimensionType.OVERWORLD_LOCATION) { + if (typeKey == null || typeKey == LevelStem.OVERWORLD) { return this.wrapped.getLevelName(); } else { if (ArclightConfig.spec().getCompat().isSymlinkWorld()) { String worldName = this.wrapped.getLevelName() + "_"; String suffix; - if (typeKey == DimensionType.NETHER_LOCATION) { + if (typeKey == LevelStem.NETHER) { suffix = "nether"; - } else if (typeKey == DimensionType.END_LOCATION) { + } else if (typeKey == LevelStem.END) { suffix = "the_end"; } else { suffix = (typeKey.location().getNamespace() + "_" + typeKey.location().getPath()).replace('/', '_'); @@ -41,9 +41,9 @@ public class DerivedWorldInfoMixin implements DerivedWorldInfoBridge { } else { String worldName = this.wrapped.getLevelName() + "/"; String suffix; - if (typeKey == DimensionType.END_LOCATION) { + if (typeKey == LevelStem.END) { suffix = "DIM1"; - } else if (typeKey == DimensionType.NETHER_LOCATION) { + } else if (typeKey == LevelStem.NETHER) { suffix = "DIM-1"; } else { suffix = typeKey.location().getNamespace() + "/" + typeKey.location().getPath(); @@ -59,7 +59,7 @@ public class DerivedWorldInfoMixin implements DerivedWorldInfoBridge { } @Override - public void bridge$setDimType(ResourceKey typeKey) { + public void bridge$setDimType(ResourceKey typeKey) { this.typeKey = typeKey; } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/SaveFormatMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSourceMixin.java similarity index 63% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/SaveFormatMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSourceMixin.java index f876d3b6..3e4c8e8a 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/SaveFormatMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSourceMixin.java @@ -1,34 +1,29 @@ package io.izzel.arclight.common.mixin.core.world.storage; -import io.izzel.arclight.common.bridge.core.world.storage.SaveFormatBridge; +import io.izzel.arclight.common.bridge.core.world.storage.LevelStorageSourceBridge; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.dimension.LevelStem; +import net.minecraft.world.level.storage.LevelStorageSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import java.io.IOException; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.storage.LevelStorageSource; @Mixin(LevelStorageSource.class) -public abstract class SaveFormatMixin implements SaveFormatBridge { +public abstract class LevelStorageSourceMixin implements LevelStorageSourceBridge { // @formatter:off @Shadow public abstract LevelStorageSource.LevelStorageAccess createAccess(String saveName) throws IOException; // @formatter:on - public LevelStorageSource.LevelStorageAccess getLevelSave(String saveName, ResourceKey world) throws IOException { + public LevelStorageSource.LevelStorageAccess createAccess(String saveName, ResourceKey world) throws IOException { LevelStorageSource.LevelStorageAccess save = createAccess(saveName); - ((LevelSaveBridge) save).bridge$setDimType(world); + ((LevelStorageAccessBridge) save).bridge$setDimType(world); return save; } - // mock - public LevelStorageSource.LevelStorageAccess c(String saveName, ResourceKey world) throws IOException { - return getLevelSave(saveName, world); - } - @Override public LevelStorageSource.LevelStorageAccess bridge$getLevelSave(String saveName, ResourceKey world) throws IOException { - return getLevelSave(saveName, world); + return createAccess(saveName, world); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/SaveFormat_LevelSaveMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSource_LevelStorageAccessMixin.java similarity index 82% rename from arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/SaveFormat_LevelSaveMixin.java rename to arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSource_LevelStorageAccessMixin.java index 23076d37..db0cf2b2 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/SaveFormat_LevelSaveMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSource_LevelStorageAccessMixin.java @@ -1,6 +1,10 @@ package io.izzel.arclight.common.mixin.core.world.storage; -import io.izzel.arclight.common.bridge.core.world.storage.SaveFormatBridge; +import io.izzel.arclight.common.bridge.core.world.storage.LevelStorageSourceBridge; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.dimension.LevelStem; +import net.minecraft.world.level.storage.LevelStorageSource; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -10,17 +14,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.io.File; import java.nio.file.Path; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.storage.LevelStorageSource; @Mixin(LevelStorageSource.LevelStorageAccess.class) -public class SaveFormat_LevelSaveMixin implements SaveFormatBridge.LevelSaveBridge { +public class LevelStorageSource_LevelStorageAccessMixin implements LevelStorageSourceBridge.LevelStorageAccessBridge { @Shadow @Final public Path levelPath; - private ResourceKey dimensionType; + public ResourceKey dimensionType; public void arclight$constructor(LevelStorageSource saveFormat, String saveName) { throw new RuntimeException(); @@ -36,6 +36,11 @@ public class SaveFormat_LevelSaveMixin implements SaveFormatBridge.LevelSaveBrid this.dimensionType = typeKey; } + @Override + public ResourceKey bridge$getTypeKey() { + return this.dimensionType; + } + @Inject(method = "getDimensionPath", cancellable = true, at = @At("HEAD")) private void arclight$useActualType(ResourceKey dimensionKey, CallbackInfoReturnable cir) { if (dimensionType == LevelStem.OVERWORLD) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/FMLWorldPersistenceHookMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/FMLWorldPersistenceHookMixin.java index c025fa41..9c24bcf0 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/FMLWorldPersistenceHookMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/FMLWorldPersistenceHookMixin.java @@ -6,9 +6,8 @@ import net.minecraft.nbt.ListTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.WorldData; +import net.minecraftforge.common.util.MavenVersionStringHelper; import net.minecraftforge.fml.ModList; -import net.minecraftforge.fmllegacy.FMLWorldPersistenceHook; -import net.minecraftforge.fmllegacy.MavenVersionStringHelper; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.GameData; import net.minecraftforge.registries.RegistryManager; @@ -25,7 +24,7 @@ import java.nio.file.Path; import java.util.HashMap; import java.util.Map; -@Mixin(value = FMLWorldPersistenceHook.class, remap = false) +@Mixin(targets = "net.minecraftforge.common.ForgeMod$FMLWorldPersistenceHook", remap = false) public class FMLWorldPersistenceHookMixin { @Shadow @Final private static Logger LOGGER; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/NetworkHooksMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/NetworkHooksMixin.java index 5534ae1a..e523c997 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/NetworkHooksMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/NetworkHooksMixin.java @@ -9,7 +9,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.Container; import net.minecraft.world.MenuProvider; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.spongepowered.asm.mixin.Mixin; @@ -40,7 +40,7 @@ public class NetworkHooksMixin { } } - @Inject(method = "sendMCRegistryPackets", remap = false, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fmllegacy/network/FMLMCRegisterPacketHandler;addChannels(Ljava/util/Set;Lnet/minecraft/network/Connection;)V")) + @Inject(method = "sendMCRegistryPackets", remap = false, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraftforge/network/MCRegisterPacketHandler;addChannels(Ljava/util/Set;Lnet/minecraft/network/Connection;)V")) private static void arclight$withBukkitChannels(Connection manager, String direction, CallbackInfo ci, Set resourceLocations) { Bukkit.getMessenger().getIncomingChannels().stream().map(ResourceLocation::new).forEach(resourceLocations::add); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/PacketDistributorMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/PacketDistributorMixin.java index f752ad47..42737f22 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/PacketDistributorMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/forge/PacketDistributorMixin.java @@ -2,7 +2,7 @@ package io.izzel.arclight.common.mixin.forge; import net.minecraft.network.protocol.Packet; import net.minecraft.server.level.ServerPlayer; -import net.minecraftforge.fmllegacy.network.PacketDistributor; +import net.minecraftforge.network.PacketDistributor; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/dfu/MainMixin_DFU.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/dfu/MainMixin_DFU.java new file mode 100644 index 00000000..53cd0d67 --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/dfu/MainMixin_DFU.java @@ -0,0 +1,22 @@ +package io.izzel.arclight.common.mixin.optimization.dfu; + +import com.mojang.datafixers.DataFixer; +import io.izzel.arclight.i18n.ArclightLocale; +import net.minecraft.server.Main; +import net.minecraft.world.level.levelgen.WorldGenSettings; +import net.minecraft.world.level.storage.LevelStorageSource; +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.callback.CallbackInfo; + +import java.util.function.BooleanSupplier; + +@Mixin(Main.class) +public abstract class MainMixin_DFU { + + @Inject(method = "forceUpgrade", at = @At("HEAD")) + private static void arclight$skipConvert(LevelStorageSource.LevelStorageAccess levelSave, DataFixer dataFixer, boolean flag, BooleanSupplier b, WorldGenSettings settings, CallbackInfo ci) { + throw new RuntimeException(ArclightLocale.getInstance().get("dfu-disable.map-convert")); + } +} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/dfu/MinecraftServerMixin_DFU.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/dfu/MinecraftServerMixin_DFU.java deleted file mode 100644 index 6de3c878..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/dfu/MinecraftServerMixin_DFU.java +++ /dev/null @@ -1,21 +0,0 @@ -package io.izzel.arclight.common.mixin.optimization.dfu; - -import io.izzel.arclight.i18n.ArclightLocale; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.level.storage.LevelStorageSource; -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.callback.CallbackInfo; - -@Mixin(MinecraftServer.class) -public abstract class MinecraftServerMixin_DFU { - - @Inject(method = "convertFromRegionFormatIfNeeded", cancellable = true, at = @At("HEAD")) - private static void arclight$skipConvert(LevelStorageSource.LevelStorageAccess levelSave, CallbackInfo ci) { - if (levelSave.requiresConversion()) { - throw new RuntimeException(ArclightLocale.getInstance().get("dfu-disable.map-convert")); - } - ci.cancel(); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/stream/GoalSelectorMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/stream/GoalSelectorMixin.java deleted file mode 100644 index 63eec3d6..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/stream/GoalSelectorMixin.java +++ /dev/null @@ -1,109 +0,0 @@ -package io.izzel.arclight.common.mixin.optimization.stream; - -import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ai.goal.GoalSelector; -import net.minecraft.world.entity.ai.goal.WrappedGoal; -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 java.util.EnumSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.function.Supplier; - -@Mixin(GoalSelector.class) -public abstract class GoalSelectorMixin { - - // @formatter:off - @Shadow @Final private Set availableGoals; - @Shadow @Final private Supplier profiler; - @Shadow @Final private EnumSet disabledFlags; - @Shadow @Final private Map lockedFlags; - @Shadow @Final private static WrappedGoal NO_GOAL; - // @formatter:on - - /** - * @author IzzelAliz - * @reason optimization - */ - @Overwrite - public void removeGoal(Goal task) { - for (Iterator iterator = this.availableGoals.iterator(); iterator.hasNext(); ) { - WrappedGoal goal = iterator.next(); - if (goal.getGoal() == task) { - if (goal.isRunning()) { - goal.stop(); - } - iterator.remove(); - } - } - } - - /** - * @author IzzelAliz - * @reason optimization - */ - @Overwrite - public void tick() { - ProfilerFiller iprofiler = this.profiler.get(); - iprofiler.push("goalCleanup"); - for (WrappedGoal prioritizedGoal : this.availableGoals) { - if (prioritizedGoal.isRunning()) { - EnumSet flags = this.disabledFlags; - boolean b = false; - for (Goal.Flag flag : prioritizedGoal.getFlags()) { - if (flags.contains(flag)) { - b = true; - break; - } - } - if (!prioritizedGoal.isRunning() || b || !prioritizedGoal.canContinueToUse()) { - prioritizedGoal.stop(); - } - } - } - for (Iterator> iterator = this.lockedFlags.entrySet().iterator(); iterator.hasNext(); ) { - Map.Entry entry = iterator.next(); - WrappedGoal p_220885_2_ = entry.getValue(); - if (!p_220885_2_.isRunning()) { - iterator.remove(); - } - } - iprofiler.pop(); - iprofiler.push("goalUpdate"); - for (WrappedGoal goal : this.availableGoals) { - if (!goal.isRunning()) { - EnumSet flags = this.disabledFlags; - boolean b = true; - for (Goal.Flag flag1 : goal.getFlags()) { - if (flags.contains(flag1) || !this.lockedFlags.getOrDefault(flag1, NO_GOAL).canBeReplacedBy(goal)) { - b = false; - break; - } - } - if (b) { - if (goal.canUse()) { - for (Goal.Flag flag : goal.getFlags()) { - WrappedGoal prioritizedgoal = this.lockedFlags.getOrDefault(flag, NO_GOAL); - prioritizedgoal.stop(); - this.lockedFlags.put(flag, goal); - } - goal.start(); - } - } - } - } - iprofiler.pop(); - iprofiler.push("goalTick"); - for (WrappedGoal goal : this.availableGoals) { - if (goal.isRunning()) { - goal.tick(); - } - } - iprofiler.pop(); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/stream/ITaskQueue_PriorityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/stream/ITaskQueue_PriorityMixin.java deleted file mode 100644 index 4eff8da8..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/stream/ITaskQueue_PriorityMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.izzel.arclight.common.mixin.optimization.stream; - -import net.minecraft.util.thread.StrictQueue; -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 java.util.List; -import java.util.Queue; - -@Mixin(StrictQueue.FixedPriorityQueue.class) -public class ITaskQueue_PriorityMixin { - - @Shadow @Final private List> queueList; - - /** - * @author IzzelAliz - * @reason optimization - */ - @Overwrite - public boolean isEmpty() { - for (Queue queue : this.queueList) { - if (!queue.isEmpty()) { - return false; - } - } - return true; - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightConnector.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightConnector.java index fe28cce7..6951a608 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightConnector.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightConnector.java @@ -20,9 +20,6 @@ public class ArclightConnector implements IMixinConnector { Mixins.addConfiguration("mixins.arclight.forge.json"); LOGGER.info("mixin-load.core"); Mixins.addConfiguration("mixins.arclight.impl.forge.optimization.json"); - if (ArclightConfig.spec().getOptimization().isRemoveStream()) { - Mixins.addConfiguration("mixins.arclight.impl.forge.optimization.stream.json"); - } if (ArclightConfig.spec().getOptimization().isDisableDFU()) { Mixins.addConfiguration("mixins.arclight.impl.forge.optimization.dfu.json"); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightMod.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightMod.java index 36a4bccc..ae3e2af8 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightMod.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/ArclightMod.java @@ -6,7 +6,7 @@ import io.izzel.arclight.common.mod.util.log.ArclightI18nLogger; import net.minecraftforge.fml.IExtensionPoint; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fmllegacy.network.FMLNetworkConstants; +import net.minecraftforge.network.NetworkConstants; import net.minecraftforge.server.permission.PermissionAPI; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; @@ -28,7 +28,7 @@ public class ArclightMod { System.setErr(new LoggingPrintStream("STDERR", System.err, Level.ERROR)); ArclightEventDispatcherRegistry.registerAllEventDispatchers(); ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, - () -> new IExtensionPoint.DisplayTest(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true)); + () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true)); PermissionAPI.setPermissionHandler(ArclightPermissionHandler.INSTANCE); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/ArclightServer.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/ArclightServer.java index ce9e434a..f2567f5d 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/ArclightServer.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/ArclightServer.java @@ -9,8 +9,8 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.players.PlayerList; -import net.minecraft.world.level.dimension.DimensionType; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraft.world.level.dimension.LevelStem; +import net.minecraftforge.server.ServerLifecycleHooks; import org.bukkit.World; import org.bukkit.craftbukkit.v.CraftServer; import org.bukkit.craftbukkit.v.command.ColouredConsoleSender; @@ -78,11 +78,7 @@ public class ArclightServer { return mainThreadExecutor; } - public static World.Environment getEnvironment(ResourceKey key) { - return BukkitRegistry.DIM_MAP.get(key); - } - - public static ResourceKey getDimensionType(World.Environment environment) { - return BukkitRegistry.DIM_MAP.inverse().get(environment); + public static World.Environment getEnvironment(ResourceKey key) { + return BukkitRegistry.DIM_MAP.getOrDefault(key, World.Environment.CUSTOM); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/BukkitRegistry.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/BukkitRegistry.java index ec7e7c39..fccaa0f3 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/BukkitRegistry.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/BukkitRegistry.java @@ -28,7 +28,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.dimension.DimensionType; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraftforge.fml.CrashReportCallables; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistry; @@ -70,11 +70,11 @@ public class BukkitRegistry { private static final Map MATERIAL_BLOCK = Unsafe.getStatic(CraftMagicNumbers.class, "MATERIAL_BLOCK"); private static final Map ENTITY_NAME_MAP = Unsafe.getStatic(EntityType.class, "NAME_MAP"); private static final Map ENVIRONMENT_MAP = Unsafe.getStatic(World.Environment.class, "lookup"); - static final BiMap, World.Environment> DIM_MAP = - HashBiMap.create(ImmutableMap., World.Environment>builder() - .put(DimensionType.OVERWORLD_LOCATION, World.Environment.NORMAL) - .put(DimensionType.NETHER_LOCATION, World.Environment.NETHER) - .put(DimensionType.END_LOCATION, World.Environment.THE_END) + static final BiMap, World.Environment> DIM_MAP = + HashBiMap.create(ImmutableMap., World.Environment>builder() + .put(LevelStem.OVERWORLD, World.Environment.NORMAL) + .put(LevelStem.NETHER, World.Environment.NETHER) + .put(LevelStem.END, World.Environment.THE_END) .build()); private static final Map ART_BY_NAME = Unsafe.getStatic(Art.class, "BY_NAME"); private static final Map ART_BY_ID = Unsafe.getStatic(Art.class, "BY_ID"); @@ -209,9 +209,9 @@ public class BukkitRegistry { public static void registerEnvironments() { int i = World.Environment.values().length; List newTypes = new ArrayList<>(); - Registry registry = ArclightServer.getMinecraftServer().registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); - for (Map.Entry, DimensionType> entry : registry.entrySet()) { - ResourceKey key = entry.getKey(); + Registry registry = ArclightServer.getMinecraftServer().registryAccess().registryOrThrow(Registry.LEVEL_STEM_REGISTRY); + for (Map.Entry, LevelStem> entry : registry.entrySet()) { + ResourceKey key = entry.getKey(); World.Environment environment = DIM_MAP.get(key); if (environment == null) { String name = ResourceLocationUtil.standardize(key.location()); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/ArclightBlockSnapshot.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/ArclightBlockSnapshot.java index 1af9e9ae..ff5c5804 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/ArclightBlockSnapshot.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/ArclightBlockSnapshot.java @@ -9,7 +9,7 @@ public class ArclightBlockSnapshot extends CraftBlock { private final BlockState blockState; public ArclightBlockSnapshot(BlockSnapshot blockSnapshot, boolean current) { - super(blockSnapshot.getWorld(), blockSnapshot.getPos()); + super(blockSnapshot.getLevel(), blockSnapshot.getPos()); this.blockState = current ? blockSnapshot.getCurrentBlock() : blockSnapshot.getReplacedBlock(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/ArclightSpecialRecipe.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/ArclightSpecialRecipe.java index edb30f3b..0c711aa7 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/ArclightSpecialRecipe.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/util/ArclightSpecialRecipe.java @@ -2,7 +2,7 @@ package io.izzel.arclight.common.mod.util; import io.izzel.arclight.common.bridge.core.item.crafting.RecipeManagerBridge; import net.minecraft.world.item.crafting.Recipe; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraftforge.server.ServerLifecycleHooks; import org.bukkit.NamespacedKey; import org.bukkit.craftbukkit.v.inventory.CraftComplexRecipe; import org.bukkit.craftbukkit.v.inventory.CraftItemStack; diff --git a/arclight-common/src/main/resources/META-INF/accesstransformer.cfg b/arclight-common/src/main/resources/META-INF/accesstransformer.cfg index fcd54c79..bd95130f 100644 --- a/arclight-common/src/main/resources/META-INF/accesstransformer.cfg +++ b/arclight-common/src/main/resources/META-INF/accesstransformer.cfg @@ -1,3 +1,5 @@ +# Arclight 1.18 +public net.minecraft.server.level.PlayerRespawnLogic m_183928_(Lnet/minecraft/server/level/ServerLevel;II)Lnet/minecraft/core/BlockPos; # Arclight 1.17 public net.minecraft.world.entity.Entity f_19851_ public net.minecraft.world.entity.raid.Raider$HoldGroundAttackGoal @@ -33,8 +35,8 @@ public net.minecraft.world.entity.raid.Raids f_37951_ public net.minecraft.world.level.block.entity.BeehiveBlockEntity$BeeData public net.minecraft.world.level.block.entity.BeehiveBlockEntity$BeeData f_58782_ public net.minecraft.world.entity.projectile.Fireball m_37018_()Lnet/minecraft/world/item/ItemStack; -public net.minecraft.network.protocol.game.ServerboundClientInformationPacket f_133864_ -public net.minecraft.network.protocol.game.ServerboundClientInformationPacket f_133863_ +# public net.minecraft.network.protocol.game.ServerboundClientInformationPacket f_133864_ +# public net.minecraft.network.protocol.game.ServerboundClientInformationPacket f_133863_ public net.minecraft.world.SimpleContainer f_19147_ public net.minecraft.server.dedicated.Settings f_139798_ public net.minecraft.world.entity.vehicle.MinecartCommandBlock f_38503_ @@ -457,3 +459,32 @@ public net.minecraft.server.MinecraftServer f_129750_ public net.minecraft.util.datafix.fixes.BlockStateData m_14942_(ILjava/lang/String;[Ljava/lang/String;)V public net.minecraft.world.entity.monster.Skeleton f_149826_ public net.minecraft.world.scores.criteria.ObjectiveCriteria f_166108_ +# Bukkit 1.18 +public net.minecraft.world.level.Level m_142425_(Lnet/minecraft/world/level/entity/EntityTypeTest;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;)Ljava/util/List; +public net.minecraft.server.Main m_195488_(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lcom/mojang/datafixers/DataFixer;ZLjava/util/function/BooleanSupplier;Lnet/minecraft/world/level/levelgen/WorldGenSettings;)V +public net.minecraft.server.MinecraftServer m_6681_(Ljava/lang/Runnable;)Ljava/lang/Runnable; +public net.minecraft.util.datafix.fixes.BlockStateData m_14942_(ILjava/lang/String;[Ljava/lang/String;)V +public net.minecraft.world.entity.monster.Guardian m_32817_(I)V +public net.minecraft.world.inventory.CraftingMenu f_39348_ +public net.minecraft.world.inventory.CraftingMenu f_39349_ +# public net.minecraft.world.item.BucketItem f_40687_ +public net.minecraft.world.level.biome.Biome m_47505_(Lnet/minecraft/core/BlockPos;)F +public net.minecraft.world.level.chunk.ChunkGenerator f_62140_ +public net.minecraft.world.level.chunk.PalettedContainer f_63071_ +public net.minecraft.world.level.chunk.ChunkAccess f_187610_ +public net.minecraft.world.level.chunk.ChunkAccess f_187608_ +public net.minecraft.world.level.chunk.storage.ChunkSerializer f_188227_ +public net.minecraft.world.level.chunk.storage.EntityStorage f_182485_ +public net.minecraft.world.level.chunk.storage.EntityStorage f_156538_ +public net.minecraft.world.level.entity.PersistentEntitySectionManager f_157493_ +public net.minecraft.world.level.entity.PersistentEntitySectionManager m_157555_(J)V +public net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_188604_ +public net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_64318_ +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate f_74483_ +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate f_74482_ +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager m_74348_(Lnet/minecraft/resources/ResourceLocation;Ljava/lang/String;)Ljava/nio/file/Path; +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager m_163776_(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/Optional; +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager m_74337_(Ljava/io/InputStream;)Lnet/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate; +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager m_163778_(Lnet/minecraft/resources/ResourceLocation;)Ljava/util/Optional; +public net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager f_74326_ +public net.minecraft.world.level.material.MaterialColor f_76387_ diff --git a/arclight-common/src/main/resources/mixins.arclight.core.json b/arclight-common/src/main/resources/mixins.arclight.core.json index 66f3b85a..aa8cfbe2 100644 --- a/arclight-common/src/main/resources/mixins.arclight.core.json +++ b/arclight-common/src/main/resources/mixins.arclight.core.json @@ -62,12 +62,12 @@ "server.level.ChunkHolderMixin", "server.level.ChunkMap_TrackedEntityMixin", "server.level.ChunkMapMixin", + "server.level.DistanceManagerMixin", "server.level.ServerChunkCache_MainThreadExecutorMixin", "server.level.ServerChunkCacheMixin", "server.level.ServerEntityMixin", "server.level.ServerLevel_EntityCallbacksMixin", "server.level.ServerLevelMixin", - "server.level.TicketManagerMixin", "server.level.TicketTypeMixin", "server.management.BanEntryMixin", "server.management.PlayerListMixin", @@ -77,7 +77,7 @@ "world.CompoundContainerMixin", "world.ContainerMixin", "world.ExplosionMixin", - "world.IBlockReaderMixin", + "world.BlockGetterMixin", "world.IServerWorldMixin", "world.IWorldMixin", "world.IWorldWriterMixin", @@ -159,7 +159,6 @@ "world.entity.decoration.ArmorStandMixin", "world.entity.decoration.ItemFrameMixin", "world.entity.decoration.LeashFenceKnotEntityMixin", - "world.entity.decoration.PaintingMixin", "world.entity.item.FallingBlockEntityMixin", "world.entity.item.HangingEntityMixin", "world.entity.item.ItemEntityMixin", @@ -355,7 +354,6 @@ "world.level.block.FenceGateBlockMixin", "world.level.block.FireBlockMixin", "world.level.block.FungusBlockMixin", - "world.level.block.GrassBlockMixin", "world.level.block.GrowingPlantHeadBlockMixin", "world.level.block.IceBlockMixin", "world.level.block.InfestedBlockMixin", @@ -373,8 +371,9 @@ "world.level.block.NoteBlockMixin", "world.level.block.ObserverBlockMixin", "world.level.block.PistonBlockMixin", + "world.level.block.PointedDripstoneBlockMixin", "world.level.block.PortalInfoMixin", - "world.level.block.PortalSizeMixin", + "world.level.block.PortalShapeMixin", "world.level.block.PoweredRailBlockMixin", "world.level.block.PressurePlateBlockMixin", "world.level.block.RedstoneLampBlockMixin", @@ -421,16 +420,17 @@ "world.level.block.state.BlockBehaviourMixin", "world.level.block.state.properties.IntegerPropertyMixin", "world.level.border.WorldBorderMixin", - "world.level.chunk.ChunkBiomeContainerMixin", + "world.level.chunk.ChunkAccessMixin", "world.level.chunk.LevelChunk_BoundTickingBlockEntityMixin", "world.level.chunk.LevelChunkMixin", + "world.level.chunk.LevelChunkSectionMixin", "world.level.chunk.storage.ChunkLoaderMixin", + "world.level.chunk.storage.ChunkSerializerMixin", "world.level.chunk.storage.RegionFileCacheMixin", "world.level.entity.PersistentEntitySectionManagerMixin", "world.level.levelgen.ChunkGeneratorMixin", - "world.level.levelgen.NoiseBasedChunkGeneratorMixin", "world.level.portal.PortalForcerMixin", - "world.level.saveddata.maps.MapData_MapInfoMixin", + "world.level.saveddata.maps.MapItemSavedData_HoldingPlayerMixin", "world.level.saveddata.maps.MapDataMixin", "world.level.storage.loot.LootTableManagerMixin", "world.level.storage.loot.LootTableMixin", @@ -439,16 +439,16 @@ "world.level.storage.loot.parameters.LootParametersMixin", "world.level.storage.loot.predicates.RandomChanceWithLootingMixin", "world.level.storage.loot.predicates.SurvivesExplosionMixin", - "world.spawner.AbstractSpawnerMixin", + "world.spawner.BaseSpawnerMixin", "world.spawner.PatrolSpawnerMixin", "world.spawner.PhantomSpawnerMixin", "world.spawner.WanderingTraderSpawnerMixin", "world.spawner.WorldEntitySpawner_EntityDensityManagerMixin", "world.spawner.WorldEntitySpawnerMixin", "world.storage.DerivedWorldInfoMixin", + "world.storage.LevelStorageSource_LevelStorageAccessMixin", + "world.storage.LevelStorageSourceMixin", "world.storage.PlayerDataMixin", - "world.storage.SaveFormat_LevelSaveMixin", - "world.storage.SaveFormatMixin", "world.storage.ServerWorldInfoMixin" ] } \ No newline at end of file diff --git a/arclight-common/src/main/resources/mixins.arclight.impl.forge.optimization.dfu.json b/arclight-common/src/main/resources/mixins.arclight.impl.forge.optimization.dfu.json index 8159e8fe..635496eb 100644 --- a/arclight-common/src/main/resources/mixins.arclight.impl.forge.optimization.dfu.json +++ b/arclight-common/src/main/resources/mixins.arclight.impl.forge.optimization.dfu.json @@ -9,6 +9,6 @@ "CraftMagicNumbersMixin_DFU", "DataFixesManagerMixin_DFU", "EntityType_BuilderMixin_DFU", - "MinecraftServerMixin_DFU" + "MainMixin_DFU" ] } \ No newline at end of file diff --git a/arclight-common/src/main/resources/mixins.arclight.impl.forge.optimization.stream.json b/arclight-common/src/main/resources/mixins.arclight.impl.forge.optimization.stream.json deleted file mode 100644 index bd00af1a..00000000 --- a/arclight-common/src/main/resources/mixins.arclight.impl.forge.optimization.stream.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "minVersion": "0.8", - "package": "io.izzel.arclight.common.mixin.optimization.stream", - "target": "@env(DEFAULT)", - "refmap": "mixins.arclight.refmap.json", - "compatibilityLevel": "JAVA_11", - "mixins": [ - "GoalSelectorMixin", - "ITaskQueue_PriorityMixin" - ] -} \ No newline at end of file diff --git a/arclight-forge/build.gradle b/arclight-forge/build.gradle index 8518850e..0e76a4cf 100644 --- a/arclight-forge/build.gradle +++ b/arclight-forge/build.gradle @@ -20,7 +20,7 @@ sourceSets { } } -java.toolchain.languageVersion = JavaLanguageVersion.of(16) +java.toolchain.languageVersion = JavaLanguageVersion.of(17) configurations { installer @@ -42,7 +42,7 @@ repositories { } def embedLibs = [/*"org.spongepowered:mixin:$mixinVersion", */ 'org.yaml:snakeyaml:1.28', - 'org.xerial:sqlite-jdbc:3.34.0', 'mysql:mysql-connector-java:5.1.49', + 'org.xerial:sqlite-jdbc:3.36.0.3', 'mysql:mysql-connector-java:8.0.27', /*'commons-lang:commons-lang:2.6',*/ 'com.googlecode.json-simple:json-simple:1.1.1', 'org.apache.logging.log4j:log4j-jul:2.14.1', 'net.md-5:SpecialSource:1.10.0', 'org.jline:jline-terminal-jansi:3.12.1', 'org.fusesource.jansi:jansi:1.18', @@ -61,16 +61,16 @@ def embedLibs = [/*"org.spongepowered:mixin:$mixinVersion", */ 'org.yaml:snakeya 'com.typesafe:config:1.3.1'] dependencies { - implementation 'com.google.guava:guava:21.0' - implementation 'org.ow2.asm:asm:9.1' - implementation 'org.ow2.asm:asm-tree:9.1' + implementation 'com.google.guava:guava:31.0.1-jre' + implementation 'org.ow2.asm:asm:9.2' + implementation 'org.ow2.asm:asm-tree:9.2' implementation 'cpw.mods:modlauncher:9.0.7' implementation 'cpw.mods:securejarhandler:0.9.45' implementation 'net.minecraftforge:forgespi:4.0.9' - gson 'com.google.code.gson:gson:2.8.8' + gson 'com.google.code.gson:gson:2.8.9' implementation 'org.apache.logging.log4j:log4j-api:2.14.1' implementation 'org.apache.logging.log4j:log4j-core:2.14.1' - implementation 'org.jetbrains:annotations:19.0.0' + implementation 'org.jetbrains:annotations:22.0.0' implementation 'org.spongepowered:mixin:0.8.3' implementation 'org.apache.logging.log4j:log4j-jul:2.14.1' for (def lib : embedLibs) { @@ -209,7 +209,7 @@ publishing { } publications { mavenJava(MavenPublication) { - artifactId = 'arclight-forge-1.17' + artifactId = 'arclight-forge-1.18' artifact project(':arclight-common').tasks.srgJar artifact project(':arclight-common').tasks.spigotJar //artifact sourceJar diff --git a/arclight-forge/src/applaunch/java/io/izzel/arclight/server/Launcher.java b/arclight-forge/src/applaunch/java/io/izzel/arclight/server/Launcher.java index 23434e65..c687d048 100644 --- a/arclight-forge/src/applaunch/java/io/izzel/arclight/server/Launcher.java +++ b/arclight-forge/src/applaunch/java/io/izzel/arclight/server/Launcher.java @@ -4,8 +4,8 @@ import io.izzel.arclight.boot.application.Main_Forge; public class Launcher { - private static final int MIN_CLASS_VERSION = 60; - private static final int MIN_JAVA_VERSION = 16; + private static final int MIN_CLASS_VERSION = 61; + private static final int MIN_JAVA_VERSION = 17; public static void main(String[] args) throws Throwable { int javaVersion = (int) Float.parseFloat(System.getProperty("java.class.version")); diff --git a/arclight-forge/src/main/java/io/izzel/arclight/boot/mod/ArclightLocator_Forge.java b/arclight-forge/src/main/java/io/izzel/arclight/boot/mod/ArclightLocator_Forge.java index cbe7bb73..11639aad 100644 --- a/arclight-forge/src/main/java/io/izzel/arclight/boot/mod/ArclightLocator_Forge.java +++ b/arclight-forge/src/main/java/io/izzel/arclight/boot/mod/ArclightLocator_Forge.java @@ -3,8 +3,10 @@ package io.izzel.arclight.boot.mod; import cpw.mods.jarhandling.JarMetadata; import cpw.mods.jarhandling.SecureJar; import cpw.mods.jarhandling.impl.SimpleJarMetadata; +import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.IModLocator; +import net.minecraftforge.forgespi.locating.ModFileFactory; import java.io.IOException; import java.lang.invoke.MethodHandles; @@ -63,10 +65,19 @@ public class ArclightLocator_Forge implements IModLocator { try { var cl = forName("net.minecraftforge.fml.loading.moddiscovery.ModFile"); var lookup = MethodHandles.lookup(); - var handle = lookup.findStatic(cl, "newFMLInstance", MethodType.methodType(cl, IModLocator.class, SecureJar.class)); + var handle = lookup.findConstructor(cl, MethodType.methodType(void.class, SecureJar.class, IModLocator.class, ModFileFactory.ModFileInfoParser.class)); var version = System.getProperty("arclight.version"); var path = Paths.get(".arclight", "mod_file", version + ".jar"); - return (IModFile) handle.invoke(this, SecureJar.from(it -> excludePackages(it, version), path)); + var parserCl = forName("net.minecraftforge.fml.loading.moddiscovery.ModFileParser"); + var modsToml = lookup.findStatic(parserCl, "modsTomlParser", MethodType.methodType(IModFileInfo.class, IModFile.class)); + ModFileFactory.ModFileInfoParser parser = modFile -> { + try { + return (IModFileInfo) modsToml.invoke(modFile); + } catch (Throwable e) { + throw new RuntimeException(e); + } + }; + return (IModFile) handle.invoke(SecureJar.from(it -> excludePackages(it, version), path), this, parser); } catch (Throwable e) { throw new RuntimeException(e); } diff --git a/build.gradle b/build.gradle index 1f65d92d..13869694 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ allprojects { group 'io.izzel.arclight' - version '1.0.1' + version '1.0.0-SNAPSHOT' def getGitHash = { -> def stdout = new ByteArrayOutputStream() @@ -12,12 +12,12 @@ allprojects { } ext { - agpVersion = '1.20' - minecraftVersion = '1.17.1' - forgeVersion = '37.1.0' - apiVersion = '1.1.+' + agpVersion = '1.21' + minecraftVersion = '1.18' + forgeVersion = '38.0.12' + apiVersion = '1.2.+' toolsVersion = '1.3.+' - mixinVersion = '0.8.4' + mixinVersion = '0.8.5' gitHash = getGitHash() } diff --git a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java index be9efa72..d10fb55e 100644 --- a/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java +++ b/forge-installer/src/main/java/io/izzel/arclight/forgeinstaller/ForgeInstaller.java @@ -58,7 +58,7 @@ public class ForgeInstaller { private static final String INSTALLER_URL = "https://arclight.mcxk.net/net/minecraftforge/forge/%s-%s/forge-%s-%s-installer.jar"; private static final String SERVER_URL = "https://arclight.mcxk.net/net/minecraft/server/minecraft_server.%s.jar"; private static final Map VERSION_HASH = Map.of( - "1.17.1", "A16D67E5807F57FC4E550299CF20226194497DC2" + "1.18", "3cf24a8694aca6267883b17d934efacc5e44440d" ); public static List modInstall(Consumer logger) throws Throwable { @@ -276,6 +276,7 @@ public class ForgeInstaller { return Map.entry(Objects.requireNonNull(mainClass, "No main class found"), userArgs); } + @SuppressWarnings("removal") public static void addToPath(Path path) { try { ClassLoader loader = ClassLoader.getPlatformClassLoader(); diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1f1a73e9..961ed731 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Sun Feb 09 15:27:43 CST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/i18n-config/src/main/java/io/izzel/arclight/i18n/conf/OptimizationSpec.java b/i18n-config/src/main/java/io/izzel/arclight/i18n/conf/OptimizationSpec.java index 400749d5..bd21c20f 100644 --- a/i18n-config/src/main/java/io/izzel/arclight/i18n/conf/OptimizationSpec.java +++ b/i18n-config/src/main/java/io/izzel/arclight/i18n/conf/OptimizationSpec.java @@ -6,19 +6,12 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class OptimizationSpec { - @Setting("remove-stream") - private boolean removeStream; - @Setting("cache-plugin-class") private boolean cachePluginClass; @Setting("disable-data-fixer") private boolean disableDFU; - public boolean isRemoveStream() { - return removeStream; - } - public boolean isCachePluginClass() { return cachePluginClass; }