From 1ac616f09751ed329e4dcc7b6504a5020775e139 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Thu, 8 Jun 2023 17:11:01 +0800 Subject: [PATCH] Update to Trials (Minecraft 1.20) Also update Gradle to 8.1.1 --- arclight-common/build.gradle | 5 +- .../core/command/CommandSourceBridge.java | 3 + .../core/tileentity/SignTileEntityBridge.java | 1 - .../world/storage/loot/LootTableBridge.java | 4 - .../mixin/bukkit/CraftEventFactoryMixin.java | 4 +- .../commands/CommandSourceStackMixin.java | 10 +- .../mixin/core/fluid/LavaFluidMixin.java | 2 +- .../network/ServerPlayNetHandlerMixin.java | 194 +++++------------- ...ntboundSectionBlocksUpdatePacketMixin.java | 4 +- .../core/server/MinecraftServerMixin.java | 4 - .../core/server/level/ChunkHolderMixin.java | 12 +- .../server/level/ServerChunkCacheMixin.java | 13 +- .../core/server/level/ServerEntityMixin.java | 44 +--- .../core/server/level/ServerLevelMixin.java | 17 +- .../ServerLevel_EntityCallbacksMixin.java | 2 +- .../server/management/PlayerListMixin.java | 28 +-- .../management/ServerPlayerGameModeMixin.java | 4 +- .../mixin/core/world/ExplosionMixin.java | 4 +- .../entity/AreaEffectCloudEntityMixin.java | 6 +- .../mixin/core/world/entity/EntityMixin.java | 75 +++---- .../core/world/entity/LivingEntityMixin.java | 34 +-- .../mixin/core/world/entity/MobMixin.java | 7 +- .../ai/behavior/GoToWantedItemMixin.java | 2 +- .../ai/behavior/InteractWithDoorMixin.java | 2 +- .../ai/behavior/StartAttackingMixin.java | 1 - .../StopAttackingIfTargetInvalidMixin.java | 2 +- .../entity/ai/goal/SkeletonTrapGoalMixin.java | 4 +- .../core/world/entity/animal/AnimalMixin.java | 73 +++---- .../core/world/entity/animal/BeeMixin.java | 2 +- .../entity/animal/Bee_GrowCropGoalMixin.java | 4 +- .../world/entity/animal/BucketableMixin.java | 2 +- .../core/world/entity/animal/CowMixin.java | 4 +- .../world/entity/animal/MushroomCowMixin.java | 6 +- .../core/world/entity/animal/PigMixin.java | 2 +- .../world/entity/animal/SnifferMixin.java | 18 +- .../entity/animal/Turtle_LayEggGoalMixin.java | 2 +- .../world/entity/animal/goat/GoatMixin.java | 2 +- .../boss/enderdragon/EnderCrystalMixin.java | 2 +- .../boss/enderdragon/EnderDragonMixin.java | 31 ++- .../phases/EnderDragonPhaseManagerMixin.java | 4 +- .../entity/boss/wither/WitherBossMixin.java | 20 +- .../entity/decoration/ItemFrameMixin.java | 2 +- .../decoration/LeashFenceKnotEntityMixin.java | 4 +- .../world/entity/item/HangingEntityMixin.java | 5 +- .../world/entity/item/ItemEntityMixin.java | 4 +- .../world/entity/item/PrimedTntMixin.java | 8 +- .../world/entity/monster/CreeperMixin.java | 6 +- .../world/entity/monster/ShulkerMixin.java | 8 +- .../Silverfish_WakeUpFriendsGoalMixin.java | 2 +- .../core/world/entity/monster/SlimeMixin.java | 8 +- .../world/entity/monster/ZombieMixin.java | 8 +- .../entity/monster/ZombifiedPiglinMixin.java | 4 +- .../core/world/entity/player/PlayerMixin.java | 46 ++--- .../entity/player/ServerPlayerMixin.java | 58 +++--- .../entity/projectile/AbstractArrowMixin.java | 4 +- .../entity/projectile/FishingHookMixin.java | 18 +- .../entity/projectile/LargeFireballMixin.java | 2 +- .../entity/projectile/SmallFireballMixin.java | 4 +- .../ThrowableItemProjectileMixin.java | 22 -- .../entity/projectile/ThrownEggMixin.java | 10 +- .../projectile/ThrownEnderpearlMixin.java | 2 +- .../ThrownExperienceBottleMixin.java | 8 +- .../entity/projectile/ThrownPotionMixin.java | 4 +- .../entity/projectile/ThrownTridentMixin.java | 2 +- .../entity/projectile/WitherSkullMixin.java | 2 +- .../entity/vehicle/AbstractMinecartMixin.java | 22 +- .../core/world/entity/vehicle/BoatMixin.java | 2 +- .../inventory/AbstractContainerMenuMixin.java | 27 +-- .../inventory/CraftingInventoryMixin.java | 4 +- .../inventory/LegacySmithingMenuMixin.java | 34 --- .../world/inventory/RepairContainerMixin.java | 12 +- .../core/world/item/MerchantOfferMixin.java | 2 +- .../world/item/crafting/IngredientMixin.java | 2 +- .../item/crafting/SmithingRecipeMixin.java | 36 ---- .../FrostWalkerEnchantmentMixin.java | 8 +- .../block/BasePressurePlateBlockMixin.java | 1 + .../level/block/PressurePlateBlockMixin.java | 57 ++--- .../level/block/SculkSensorBlockMixin.java | 6 +- .../world/level/block/SpongeBlockMixin.java | 127 ++++++------ .../WeightedPressurePlateBlockMixin.java | 23 ++- .../AbstractFurnaceBlockEntityMixin.java | 2 +- .../block/entity/SignBlockEntityMixin.java | 81 +++++++- .../level/chunk/ChunkGeneratorMixin.java | 2 +- .../world/level/chunk/LevelChunkMixin.java | 4 +- .../vibrations/VibrationListenerMixin.java | 27 ++- .../storage/loot/LootDataManagerMixin.java | 31 +++ .../storage/loot/LootTableManagerMixin.java | 34 --- .../level/storage/loot/LootTableMixin.java | 16 +- .../core/world/spawner/BaseSpawnerMixin.java | 2 +- .../storage/LevelStorageSourceMixin.java | 20 ++ .../EntityMixin_ActivationRange.java | 2 +- ...workRocketEntityMixin_ActivationRange.java | 2 +- .../ItemEntityMixin_ActivationRange.java | 10 +- .../VillagerEntityMixin_ActivationRange.java | 2 +- .../server/event/EntityEventDispatcher.java | 2 +- .../resources/META-INF/accesstransformer.cfg | 43 +++- .../main/resources/mixins.arclight.core.json | 4 +- arclight-forge/build.gradle | 5 +- .../arclight/boot/AbstractBootstrap.java | 2 +- .../application/ApplicationBootstrap.java | 5 + .../application/ArclightLaunchHandler.java | 17 ++ ...mods.modlauncher.api.ILaunchHandlerService | 1 + build.gradle | 10 +- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../main/resources/META-INF/i18n/en_us.conf | 1 + .../main/resources/META-INF/i18n/zh_cn.conf | 1 + 107 files changed, 763 insertions(+), 831 deletions(-) delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/LegacySmithingMenuMixin.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/SmithingRecipeMixin.java create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootDataManagerMixin.java delete mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableManagerMixin.java create mode 100644 arclight-forge/src/main/java/io/izzel/arclight/boot/application/ArclightLaunchHandler.java create mode 100644 arclight-forge/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService diff --git a/arclight-common/build.gradle b/arclight-common/build.gradle index bbcefc3a..6cb70daf 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_19_R3' + bukkitVersion = 'v1_20_R1' wipeVersion = true reobfVersion = true accessTransformer = project.file('bukkit.at') @@ -40,6 +40,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17) minecraft { //mappings channel: 'parchment', version: "2021.08.22-$minecraftVersion" mappings channel: 'official', version: minecraftVersion + copyIdeResources = true accessTransformer = project.file('src/main/resources/META-INF/accesstransformer.cfg') } @@ -69,7 +70,7 @@ dependencies { implementation 'org.apache.logging.log4j:log4j-jul:2.15.0' implementation 'net.md-5:bungeecord-chat:1.16-R0.4' implementation 'mysql:mysql-connector-java:5.1.49' - implementation 'org.yaml:snakeyaml:1.30' + implementation 'org.yaml:snakeyaml:2.0' implementation "io.izzel:tools:$toolsVersion" implementation "io.izzel.arclight:arclight-api:$apiVersion" implementation project(':i18n-config') diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/command/CommandSourceBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/command/CommandSourceBridge.java index 5895904c..3367a8e1 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/command/CommandSourceBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/command/CommandSourceBridge.java @@ -1,10 +1,13 @@ package io.izzel.arclight.common.bridge.core.command; import com.mojang.brigadier.tree.CommandNode; +import net.minecraft.commands.CommandSource; import org.bukkit.command.CommandSender; public interface CommandSourceBridge { + void bridge$setSource(CommandSource source); + CommandNode bridge$getCurrentCommand(); void bridge$setCurrentCommand(CommandNode node); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/tileentity/SignTileEntityBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/tileentity/SignTileEntityBridge.java index b5e3173e..e70d85e1 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/tileentity/SignTileEntityBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/tileentity/SignTileEntityBridge.java @@ -2,5 +2,4 @@ package io.izzel.arclight.common.bridge.core.tileentity; public interface SignTileEntityBridge { - void bridge$setEditable(boolean editable); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/loot/LootTableBridge.java b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/loot/LootTableBridge.java index 9b3dab8f..c6ec750c 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/loot/LootTableBridge.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/bridge/core/world/storage/loot/LootTableBridge.java @@ -1,9 +1,5 @@ package io.izzel.arclight.common.bridge.core.world.storage.loot; -import net.minecraft.world.Container; -import net.minecraft.world.level.storage.loot.LootContext; - public interface LootTableBridge { - void bridge$fillInventory(Container inv, LootContext context, boolean plugin); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftEventFactoryMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftEventFactoryMixin.java index f09cdf91..b497aced 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftEventFactoryMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftEventFactoryMixin.java @@ -199,11 +199,11 @@ public class CraftEventFactoryMixin { */ @Overwrite public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPos position, net.minecraft.world.level.block.state.BlockState newBlock, boolean cancelled) { - Block block = CraftBlock.at(entity.level, position); + Block block = CraftBlock.at(entity.level(), position); EntityChangeBlockEvent event = new EntityChangeBlockEvent(((EntityBridge) entity).bridge$getBukkitEntity(), block, CraftBlockData.fromData(newBlock)); event.setCancelled(cancelled); // Suppress during worldgen - if (DistValidate.isValid(entity.level)) { + if (DistValidate.isValid(entity.level())) { Bukkit.getPluginManager().callEvent(event); } return event; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandSourceStackMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandSourceStackMixin.java index d1694d32..9f155664 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandSourceStackMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandSourceStackMixin.java @@ -9,15 +9,14 @@ import io.izzel.arclight.common.mod.compat.CommandNodeHooks; import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; -import net.minecraftforge.common.util.FakePlayer; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.v.CraftServer; import org.bukkit.craftbukkit.v.command.VanillaCommandWrapper; 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.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -28,11 +27,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public abstract class CommandSourceStackMixin implements CommandSourceBridge { // @formatter:off - @Shadow @Final public CommandSource source; + @Shadow @Final @Mutable public CommandSource source; @Shadow public abstract ServerLevel getLevel(); @Shadow @Final private int permissionLevel; // @formatter:on + @Override + public void bridge$setSource(CommandSource source) { + this.source = source; + } + public CommandNode currentCommand; @SuppressWarnings({"rawtypes", "unchecked"}) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/fluid/LavaFluidMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/fluid/LavaFluidMixin.java index 606db720..30847d83 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/fluid/LavaFluidMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/fluid/LavaFluidMixin.java @@ -58,7 +58,7 @@ public abstract class LavaFluidMixin { world.setBlockAndUpdate(blockpos, ForgeEventFactory.fireFluidPlaceBlockEvent(world, blockpos, pos, Blocks.FIRE.defaultBlockState())); return; } - } else if (blockstate.getMaterial().blocksMotion()) { + } else if (blockstate.blocksMotion()) { return; } } 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 8ad33bc1..6c4466b3 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 @@ -26,13 +26,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.StringTag; import net.minecraft.network.Connection; import net.minecraft.network.PacketSendListener; -import net.minecraft.network.chat.ChatType; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.LastSeenMessages; -import net.minecraft.network.chat.OutgoingChatMessage; -import net.minecraft.network.chat.PlayerChatMessage; -import net.minecraft.network.chat.SignableCommand; -import net.minecraft.network.chat.SignedMessageChain; +import net.minecraft.network.chat.*; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketUtils; import net.minecraft.network.protocol.game.*; @@ -49,12 +43,7 @@ import net.minecraft.util.StringUtil; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.ExperienceOrb; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MoverType; -import net.minecraft.world.entity.RelativeMovement; +import net.minecraft.world.entity.*; import net.minecraft.world.entity.animal.Bucketable; import net.minecraft.world.entity.animal.allay.Allay; import net.minecraft.world.entity.item.ItemEntity; @@ -73,8 +62,6 @@ import net.minecraft.world.level.GameType; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.SignBlockEntity; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; @@ -85,7 +72,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.craftbukkit.v.CraftServer; -import org.bukkit.craftbukkit.v.block.CraftSign; import org.bukkit.craftbukkit.v.entity.CraftPlayer; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.craftbukkit.v.inventory.CraftItemStack; @@ -96,42 +82,15 @@ import org.bukkit.craftbukkit.v.util.Waitable; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.block.Action; -import org.bukkit.event.block.SignChangeEvent; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.CraftItemEvent; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCreativeEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.inventory.SmithItemEvent; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerAnimationEvent; -import org.bukkit.event.player.PlayerAnimationType; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.event.player.PlayerKickEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerResourcePackStatusEvent; -import org.bukkit.event.player.PlayerSwapHandItemsEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.player.PlayerToggleFlightEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.event.player.PlayerToggleSprintEvent; +import org.bukkit.event.inventory.*; +import org.bukkit.event.player.*; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.SmithingInventory; import org.slf4j.Logger; import org.spigotmc.SpigotConfig; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; @@ -142,12 +101,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.nio.charset.StandardCharsets; import java.time.Instant; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.function.UnaryOperator; @@ -191,7 +145,6 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB @Shadow private int chatSpamTickCount; @Shadow private int dropSpamTickCount; @Shadow protected abstract boolean noBlocksAround(Entity p_241162_1_); - @Shadow protected abstract boolean isPlayerCollidingWithAnythingNew(LevelReader p_241163_1_, AABB p_241163_2_); @Shadow private static double clampHorizontal(double p_143610_) { return 0; } @Shadow private static double clampVertical(double p_143654_) { return 0; } @Shadow private static boolean containsInvalidValues(double p_143664_, double p_143665_, double p_143666_, float p_143667_, float p_143668_) { return false; } @@ -206,6 +159,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB @Shadow protected abstract PlayerChatMessage getSignedMessage(ServerboundChatPacket p_251061_, LastSeenMessages p_250566_) throws SignedMessageChain.DecodeException; @Shadow protected abstract void handleMessageDecodeFailure(SignedMessageChain.DecodeException p_252068_); @Shadow protected abstract Map collectSignedArguments(ServerboundChatCommandPacket p_249441_, SignableCommand p_250039_, LastSeenMessages p_249207_) throws SignedMessageChain.DecodeException; + @Shadow protected abstract boolean isPlayerCollidingWithAnythingNew(LevelReader p_289008_, AABB p_288986_, double p_288990_, double p_288991_, double p_288967_); // @formatter:on private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 6 * 6; @@ -309,13 +263,13 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handleMoveVehicle(final ServerboundMoveVehiclePacket packetplayinvehiclemove) { - PacketUtils.ensureRunningOnSameThread(packetplayinvehiclemove, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packetplayinvehiclemove, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (containsInvalidValues(packetplayinvehiclemove.getX(), packetplayinvehiclemove.getY(), packetplayinvehiclemove.getZ(), packetplayinvehiclemove.getYRot(), packetplayinvehiclemove.getXRot())) { this.disconnect(Component.translatable("multiplayer.disconnect.invalid_vehicle_movement")); } else { Entity entity = this.player.getRootVehicle(); if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { - ServerLevel worldserver = this.player.getLevel(); + ServerLevel worldserver = this.player.serverLevel(); double d0 = entity.getX(); double d2 = entity.getY(); double d3 = entity.getZ(); @@ -359,6 +313,14 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB d7 = d4 - this.vehicleLastGoodX; d8 = d5 - this.vehicleLastGoodY - 1.0E-6; d9 = d6 - this.vehicleLastGoodZ; + boolean flag1 = entity.verticalCollisionBelow; + + if (entity instanceof LivingEntity entityliving) { + if (entityliving.onClimbable()) { + entityliving.resetFallDistance(); + } + } + entity.move(MoverType.PLAYER, new Vec3(d7, d8, d9)); double d12 = d8; d7 = d4 - entity.getX(); @@ -425,9 +387,9 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } } } - this.player.getLevel().getChunkSource().move(this.player); + this.player.serverLevel().getChunkSource().move(this.player); this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d2, this.player.getZ() - d3); - this.clientVehicleIsFloating = d12 >= -0.03125 && !this.server.isFlightAllowed() && this.noBlocksAround(entity); + this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity); this.vehicleLastGoodX = entity.getX(); this.vehicleLastGoodY = entity.getY(); this.vehicleLastGoodZ = entity.getZ(); @@ -440,7 +402,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;isChangingDimension()Z"))) private void arclight$updateLoc(ServerboundAcceptTeleportationPacket packetIn, CallbackInfo ci) { if (((ServerPlayerEntityBridge) this.player).bridge$isValid()) { - this.player.getLevel().getChunkSource().move(this.player); + this.player.serverLevel().getChunkSource().move(this.player); } } @@ -519,11 +481,11 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handleMovePlayer(ServerboundMovePlayerPacket packetplayinflying) { - PacketUtils.ensureRunningOnSameThread(packetplayinflying, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packetplayinflying, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (containsInvalidValues(packetplayinflying.getX(0.0D), packetplayinflying.getY(0.0D), packetplayinflying.getZ(0.0D), packetplayinflying.getYRot(0.0F), packetplayinflying.getXRot(0.0F))) { this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement")); } else { - ServerLevel worldserver = this.player.getLevel(); + ServerLevel worldserver = this.player.serverLevel(); if (!this.player.wonGame && !((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { if (this.tickCount == 0) { this.resetPosition(); @@ -544,7 +506,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB if (this.player.isPassenger()) { this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); - this.player.getLevel().getChunkSource().move(this.player); + this.player.serverLevel().getChunkSource().move(this.player); this.allowedPlayerTicks = 20; // CraftBukkit } else { // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify @@ -595,7 +557,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB speed = player.getAbilities().walkingSpeed * 10f; } - if (!this.player.isChangingDimension() && (!this.player.getLevel().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isFallFlying())) { + if (!this.player.isChangingDimension() && (!this.player.serverLevel().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isFallFlying())) { float f2 = this.player.isFallFlying() ? 300.0F : 100.0F; if (d11 - d10 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { @@ -613,7 +575,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB d9 = d2 - this.lastGoodZ; boolean flag = d8 > 0.0D; - if (this.player.isOnGround() && !packetplayinflying.isOnGround() && flag) { + if (this.player.onGround() && !packetplayinflying.isOnGround() && flag) { this.player.jumpFromGround(); } @@ -636,12 +598,10 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB LOGGER.warn("{} moved wrongly!", this.player.getName().getString()); } - this.player.absMoveTo(d0, d1, d2, f, f1); - if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew((LevelReader) worldserver, axisalignedbb))) { + if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) { this.internalTeleport(d3, d4, d5, f, f1, Collections.emptySet()); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet. - this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround()); + this.player.doCheckFallDamage(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5, packetplayinflying.isOnGround()); } else { - this.player.absMoveTo(prevX, prevY, prevZ, prevYaw, prevPitch); 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(); @@ -680,14 +640,13 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } } } - this.player.absMoveTo(d0, d1, d2, f, f1); // Copied from above - // MC-135989, SPIGOT-5564: isRiptiding + this.player.absMoveTo(d0, d1, d2, f, f1); // Copied from above this.clientIsFloating = d12 >= -0.03125D && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && this.noBlocksAround((Entity) this.player) && !this.player.isAutoSpinAttack(); // CraftBukkit end - this.player.getLevel().getChunkSource().move(this.player); - this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround()); - this.player.setOnGround(packetplayinflying.isOnGround()); + this.player.serverLevel().getChunkSource().move(this.player); + this.player.doCheckFallDamage(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5, packetplayinflying.isOnGround()); + this.player.setOnGroundWithKnownMovement(packetplayinflying.isOnGround(), new Vec3(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5)); if (flag) { this.player.resetFallDistance(); } @@ -710,7 +669,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handlePlayerAction(ServerboundPlayerActionPacket packetplayinblockdig) { - PacketUtils.ensureRunningOnSameThread(packetplayinblockdig, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packetplayinblockdig, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { return; } @@ -772,7 +731,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB case START_DESTROY_BLOCK: case ABORT_DESTROY_BLOCK: case STOP_DESTROY_BLOCK: { - this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packetplayinblockdig.getDirection(), this.player.level.getMaxBuildHeight(), packetplayinblockdig.getSequence()); + this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packetplayinblockdig.getDirection(), this.player.level().getMaxBuildHeight(), packetplayinblockdig.getSequence()); this.player.connection.ackBlockChangesUpTo(packetplayinblockdig.getSequence()); return; } @@ -782,7 +741,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } } - @Inject(method = "handleUseItemOn", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/server/level/ServerPlayer;getLevel()Lnet/minecraft/server/level/ServerLevel;")) + @Inject(method = "handleUseItemOn", cancellable = true, at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/server/level/ServerPlayer;serverLevel()Lnet/minecraft/server/level/ServerLevel;")) private void arclight$frozenUseItem(ServerboundUseItemOnPacket packetIn, CallbackInfo ci) { if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { ci.cancel(); @@ -821,7 +780,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handleUseItem(ServerboundUseItemPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { return; } @@ -829,7 +788,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB return; } this.ackBlockChangesUpTo(packet.getSequence()); - ServerLevel worldserver = this.player.getLevel(); + ServerLevel worldserver = this.player.serverLevel(); InteractionHand enumhand = packet.getHand(); ItemStack itemstack = this.player.getItemInHand(enumhand); this.player.resetLastActionTime(); @@ -848,7 +807,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB float f8 = f3 * f5; double d4 = (this.player.gameMode.getGameModeForPlayer() == GameType.CREATIVE) ? 5.0 : 4.5; Vec3 vec3d2 = vec3d.add(f7 * d4, f6 * d4, f8 * d4); - BlockHitResult movingobjectposition = this.player.level.clip(new ClipContext(vec3d, vec3d2, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player)); + BlockHitResult movingobjectposition = this.player.level().clip(new ClipContext(vec3d, vec3d2, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player)); boolean cancelled; if (movingobjectposition == null || movingobjectposition.getType() != HitResult.Type.BLOCK) { PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand); @@ -857,6 +816,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB ((PlayerInteractionManagerBridge) this.player.gameMode).bridge$setFiredInteract(false); cancelled = ((PlayerInteractionManagerBridge) this.player.gameMode).bridge$getInteractResult(); } else { + // TODO 1.20 update this BlockHitResult movingobjectpositionblock = movingobjectposition; PlayerInteractEvent event2 = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand); cancelled = (event2.useItemInHand() == Event.Result.DENY); @@ -925,7 +885,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { return; } @@ -1167,7 +1127,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handleAnimate(ServerboundSwingPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { return; } @@ -1186,7 +1146,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB float f8 = f3 * f5; double d4 = this.player.getBlockReach(); Vec3 vec3d2 = vec3d.add(f7 * d4, f6 * d4, f8 * d4); - HitResult result = this.player.level.clip(new ClipContext(vec3d, vec3d2, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player)); + HitResult result = this.player.level().clip(new ClipContext(vec3d, vec3d2, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player)); if (result == null || result.getType() != HitResult.Type.BLOCK) { CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); } @@ -1225,11 +1185,11 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handleInteract(final ServerboundInteractPacket packetIn) { - PacketUtils.ensureRunningOnSameThread(packetIn, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packetIn, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { return; } - final ServerLevel world = this.player.getLevel(); + final ServerLevel world = this.player.serverLevel(); final Entity entity = packetIn.getTarget(world); if (entity == player && !player.isSpectator()) { disconnect("Cannot interact with self!"); @@ -1351,7 +1311,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handleContainerClick(ServerboundContainerClickPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (((ServerPlayerEntityBridge) this.player).bridge$isMovementBlocked()) { return; } @@ -1410,7 +1370,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB if (cursor.isEmpty()) { action = packet.getButtonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; } else if (slot.mayPlace(cursor)) { - if (clickedItem.sameItem(cursor) && ItemStack.tagMatches(clickedItem, cursor)) { + if (ItemStack.isSameItemSameTags(clickedItem, cursor)) { int toPlace = packet.getButtonNum() == 0 ? cursor.getCount() : 1; toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); @@ -1426,7 +1386,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } else if (cursor.getCount() <= slot.getMaxStackSize()) { action = InventoryAction.SWAP_WITH_CURSOR; } - } else if (cursor.getItem() == clickedItem.getItem() && ItemStack.tagMatches(cursor, clickedItem)) { + } else if (ItemStack.isSameItemSameTags(cursor, clickedItem)) { if (clickedItem.getCount() >= 0) { if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) { // As of 1.5, this is result slots only @@ -1675,15 +1635,15 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handleSetCreativeModeSlot(final ServerboundSetCreativeModeSlotPacket packetplayinsetcreativeslot) { - PacketUtils.ensureRunningOnSameThread(packetplayinsetcreativeslot, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packetplayinsetcreativeslot, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (this.player.gameMode.isCreative()) { final boolean flag = packetplayinsetcreativeslot.getSlotNum() < 0; ItemStack itemstack = packetplayinsetcreativeslot.getItem(); final CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack); if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z")) { BlockPos blockpos = BlockEntity.getPosFromTag(nbttagcompound); - if (this.player.level.isLoaded(blockpos)) { - BlockEntity blockentity = this.player.level.getBlockEntity(blockpos); + if (this.player.level().isLoaded(blockpos)) { + BlockEntity blockentity = this.player.level().getBlockEntity(blockpos); if (blockentity != null) { blockentity.saveToItem(itemstack); } @@ -1733,58 +1693,10 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB } } - /** - * @author IzzelAliz - * @reason - */ - @Overwrite - private void updateSignText(ServerboundSignUpdatePacket packet, List list) { + @Inject(method = "updateSignText", cancellable = true, at = @At("HEAD")) + private void arclight$updateSignText(ServerboundSignUpdatePacket p_9923_, List p_9924_, CallbackInfo ci) { if (((ServerPlayerEntityBridge) player).bridge$isMovementBlocked()) { - return; - } - this.player.resetLastActionTime(); - ServerLevel serverlevel = this.player.getLevel(); - BlockPos blockpos = packet.getPos(); - if (serverlevel.hasChunkAt(blockpos)) { - BlockState blockstate = serverlevel.getBlockState(blockpos); - BlockEntity blockentity = serverlevel.getBlockEntity(blockpos); - if (!(blockentity instanceof SignBlockEntity signblockentity)) { - return; - } - - if (!signblockentity.isEditable() || !this.player.getUUID().equals(signblockentity.getPlayerWhoMayEdit())) { - LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString()); - this.send(blockentity.getUpdatePacket()); - return; - } - - Player player = ((ServerPlayerEntityBridge) this.player).bridge$getBukkitEntity(); - int x = packet.getPos().getX(); - int y = packet.getPos().getY(); - int z = packet.getPos().getZ(); - String[] lines = new String[4]; - - for (int i = 0; i < list.size(); ++i) { - FilteredText text = list.get(i); - - if (this.player.isTextFilteringEnabled()) { - lines[i] = ChatFormatting.stripFormatting(text.filteredOrEmpty()); - } else { - lines[i] = ChatFormatting.stripFormatting(text.raw()); - } - } - SignChangeEvent event = new SignChangeEvent(player.getWorld().getBlockAt(x, y, z), player, lines); - Bukkit.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - Component[] components = CraftSign.sanitizeLines(event.getLines()); - for (int i = 0; i < components.length; i++) { - signblockentity.setMessage(i, components[i]); - } - signblockentity.isEditable = false; - } - - signblockentity.setChanged(); - serverlevel.sendBlockUpdated(blockpos, blockstate, blockstate, 3); + ci.cancel(); } } @@ -1794,7 +1706,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB */ @Overwrite public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packet, (ServerGamePacketListenerImpl) (Object) this, this.player.serverLevel()); if (this.player.getAbilities().mayfly && this.player.getAbilities().flying != packet.isFlying()) { PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(getCraftPlayer(), packet.isFlying()); this.cserver.getPluginManager().callEvent(event); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/game/ClientboundSectionBlocksUpdatePacketMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/game/ClientboundSectionBlocksUpdatePacketMixin.java index f1673c07..5867b4d7 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/game/ClientboundSectionBlocksUpdatePacketMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/protocol/game/ClientboundSectionBlocksUpdatePacketMixin.java @@ -13,13 +13,11 @@ import org.spongepowered.asm.mixin.Shadow; public class ClientboundSectionBlocksUpdatePacketMixin { @Shadow @Final @Mutable private SectionPos sectionPos; - @Shadow @Final @Mutable private boolean suppressLightUpdates; @Shadow @Final @Mutable private short[] positions; @Shadow @Final @Mutable private BlockState[] states; - public void arclight$constructor(SectionPos sectionposition, ShortSet shortset, BlockState[] states, boolean flag) { + public void arclight$constructor(SectionPos sectionposition, ShortSet shortset, BlockState[] states) { this.sectionPos = sectionposition; - this.suppressLightUpdates = flag; this.positions = shortset.toShortArray(); this.states = states; } 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 0f00c608..a022ead2 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 @@ -368,7 +368,6 @@ public abstract class MinecraftServerMixin extends ReentrantBlockableEventLoop { LevelChunk chunk = (LevelChunk) either.left().orElse(null); if (chunk != null) { @@ -96,8 +98,8 @@ public abstract class ChunkHolderMixin implements ChunkHolderBridge { @Inject(method = "updateFutures", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD) public void arclight$onChunkLoad(ChunkMap chunkManager, Executor executor, CallbackInfo ci, ChunkStatus chunkStatus, ChunkStatus chunkStatus1, boolean flag, boolean flag1, - ChunkHolder.FullChunkStatus locationType, ChunkHolder.FullChunkStatus locationType1) { - if (!locationType.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && locationType1.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) { + FullChunkStatus locationType, FullChunkStatus locationType1) { + if (!locationType.isOrAfter(FullChunkStatus.FULL) && locationType1.isOrAfter(FullChunkStatus.FULL)) { this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> { LevelChunk chunk = (LevelChunk) either.left().orElse(null); if (chunk != null) { 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 8aba88b3..c9517460 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 @@ -5,12 +5,7 @@ import io.izzel.arclight.common.bridge.core.world.server.ChunkHolderBridge; import io.izzel.arclight.common.bridge.core.world.server.ChunkMapBridge; import io.izzel.arclight.common.bridge.core.world.server.ServerChunkProviderBridge; import io.izzel.arclight.common.bridge.core.world.server.TicketManagerBridge; -import net.minecraft.server.level.ChunkHolder; -import net.minecraft.server.level.ChunkMap; -import net.minecraft.server.level.DistanceManager; -import net.minecraft.server.level.ServerChunkCache; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ThreadedLevelLightEngine; +import net.minecraft.server.level.*; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.chunk.ChunkGenerator; @@ -77,9 +72,9 @@ public abstract class ServerChunkCacheMixin implements ServerChunkProviderBridge if (flag) { ChunkHolder chunkholder = this.getVisibleChunkIfPresent(ChunkPos.asLong(chunkX, chunkZ)); if (chunkholder != null) { - ChunkHolder.FullChunkStatus chunkStatus = ChunkHolder.getFullChunkStatus(((ChunkHolderBridge) chunkholder).bridge$getOldTicketLevel()); - ChunkHolder.FullChunkStatus currentStatus = ChunkHolder.getFullChunkStatus(chunkholder.getTicketLevel()); - return !chunkStatus.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) || currentStatus.isOrAfter(ChunkHolder.FullChunkStatus.BORDER); + FullChunkStatus chunkStatus = ChunkLevel.fullStatus(((ChunkHolderBridge) chunkholder).bridge$getOldTicketLevel()); + FullChunkStatus currentStatus = ChunkLevel.fullStatus(chunkholder.getTicketLevel()); + return !chunkStatus.isOrAfter(FullChunkStatus.FULL) || currentStatus.isOrAfter(FullChunkStatus.FULL); } else { return true; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerEntityMixin.java index 17887aa5..493b9bd9 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/level/ServerEntityMixin.java @@ -80,7 +80,7 @@ public abstract class ServerEntityMixin implements ServerEntityBridge { @Shadow private int yHeadRotp; @Shadow protected abstract void broadcastAndSend(Packet packet); @Shadow @Nullable private List> trackedDataValues; - @Shadow protected abstract Stream changedPassengers(List p_275537_, List p_275682_); + @Shadow private static Stream removedPassengers(List p_277592_, List p_277658_) { return null; } // @formatter:on private Set trackedPlayers; @@ -118,11 +118,9 @@ public abstract class ServerEntityMixin implements ServerEntityBridge { if (!list.equals(this.lastPassengers)) { this.lastPassengers = list; this.broadcastAndSend(new ClientboundSetPassengersPacket(this.entity)); - this.changedPassengers(list, this.lastPassengers).forEach((p_275907_) -> { - if (p_275907_ instanceof ServerPlayer serverplayer1) { - if (!list.contains(serverplayer1)) { - serverplayer1.connection.teleport(serverplayer1.getX(), serverplayer1.getY(), serverplayer1.getZ(), serverplayer1.getYRot(), serverplayer1.getXRot()); - } + removedPassengers(list, this.lastPassengers).forEach((p_289307_) -> { + if (p_289307_ instanceof ServerPlayer serverplayer1) { + serverplayer1.connection.teleport(serverplayer1.getX(), serverplayer1.getY(), serverplayer1.getZ(), serverplayer1.getYRot(), serverplayer1.getXRot()); } }); } @@ -154,7 +152,7 @@ public abstract class ServerEntityMixin implements ServerEntityBridge { int l1 = Mth.floor(this.entity.getXRot() * 256.0F / 360.0F); boolean flag2 = Math.abs(i1 - this.yRotp) >= 1 || Math.abs(l1 - this.xRotp) >= 1; if (flag2) { - this.broadcast.accept(new ClientboundMoveEntityPacket.Rot(this.entity.getId(), (byte) i1, (byte) l1, this.entity.isOnGround())); + this.broadcast.accept(new ClientboundMoveEntityPacket.Rot(this.entity.getId(), (byte) i1, (byte) l1, this.entity.onGround())); this.yRotp = i1; this.xRotp = l1; } @@ -177,21 +175,21 @@ public abstract class ServerEntityMixin implements ServerEntityBridge { long j = this.positionCodec.encodeY(vector3d); long k = this.positionCodec.encodeZ(vector3d); boolean flag1 = i < -32768L || i > 32767L || j < -32768L || j > 32767L || k < -32768L || k > 32767L; - if (!flag1 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround()) { + if (!flag1 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) { if ((!flag4 || !flag) && !(this.entity instanceof AbstractArrow)) { if (flag4) { - ipacket1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), this.entity.isOnGround()); + ipacket1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), this.entity.onGround()); pos = true; } else if (flag) { - ipacket1 = new ClientboundMoveEntityPacket.Rot(this.entity.getId(), (byte) l, (byte) k1, this.entity.isOnGround()); + ipacket1 = new ClientboundMoveEntityPacket.Rot(this.entity.getId(), (byte) l, (byte) k1, this.entity.onGround()); rot = true; } } else { - ipacket1 = new ClientboundMoveEntityPacket.PosRot(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), (byte) l, (byte) k1, this.entity.isOnGround()); + ipacket1 = new ClientboundMoveEntityPacket.PosRot(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), (byte) l, (byte) k1, this.entity.onGround()); pos = rot = true; } } else { - this.wasOnGround = this.entity.isOnGround(); + this.wasOnGround = this.entity.onGround(); this.teleportDelay = 0; ipacket1 = new ClientboundTeleportEntityPacket(this.entity); pos = rot = true; @@ -249,26 +247,12 @@ public abstract class ServerEntityMixin implements ServerEntityBridge { } } - @Inject(method = "addPairing", at = @At("HEAD")) - private void arclight$addPlayer(ServerPlayer player, CallbackInfo ci) { - this.arclight$player = player; - } - - private transient ServerPlayer arclight$player; - - public void a(final Consumer> consumer, ServerPlayer playerEntity) { - this.arclight$player = playerEntity; - this.sendPairingData(consumer); - } - /** * @author IzzelAliz * @reason */ @Overwrite - public void sendPairingData(final Consumer> consumer) { - ServerPlayer player = arclight$player; - arclight$player = null; + public void sendPairingData(ServerPlayer player, final Consumer> consumer) { Mob entityinsentient; if (this.entity.isRemoved()) { return; @@ -309,12 +293,6 @@ public abstract class ServerEntityMixin implements ServerEntityBridge { } this.yHeadRotp = Mth.floor(this.entity.getYHeadRot() * 256.0f / 360.0f); consumer.accept(new ClientboundRotateHeadPacket(this.entity, (byte) this.yHeadRotp)); - if (this.entity instanceof LivingEntity livingEntity) { - for (MobEffectInstance mobeffect : livingEntity.getActiveEffects()) { - consumer.accept(new ClientboundUpdateMobEffectPacket(this.entity.getId(), mobeffect)); - } - livingEntity.detectEquipmentUpdates(); - } if (!this.entity.getPassengers().isEmpty()) { consumer.accept(new ClientboundSetPassengersPacket(this.entity)); } 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 8a2348c5..90e852b7 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 @@ -34,6 +34,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.util.ProgressListener; import net.minecraft.world.Container; +import net.minecraft.world.RandomSequences; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LightningBolt; @@ -115,7 +116,7 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld // @formatter:on @SuppressWarnings({"FieldCanBeLocal", "unused"}) - public PrimaryLevelData J; // TODO f_8549_ check on update + public PrimaryLevelData K; // TODO f_8549_ check on update public LevelStorageSource.LevelStorageAccess convertable; public UUID uuid; public ResourceKey typeKey; @@ -125,12 +126,12 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld return this.typeKey; } - public void arclight$constructor(MinecraftServer minecraftServer, Executor backgroundExecutor, LevelStorageSource.LevelStorageAccess levelSave, ServerLevelData worldInfo, ResourceKey dimension, LevelStem levelStem, ChunkProgressListener statusListener, boolean isDebug, long seed, List specialSpawners, boolean shouldBeTicking) { + public void arclight$constructor(MinecraftServer minecraftServer, Executor backgroundExecutor, LevelStorageSource.LevelStorageAccess levelSave, ServerLevelData worldInfo, ResourceKey dimension, LevelStem levelStem, ChunkProgressListener statusListener, boolean isDebug, long seed, List specialSpawners, boolean shouldBeTicking, RandomSequences seq) { throw new RuntimeException(); } - public void arclight$constructor(MinecraftServer minecraftServer, Executor backgroundExecutor, LevelStorageSource.LevelStorageAccess levelSave, PrimaryLevelData worldInfo, ResourceKey dimension, LevelStem levelStem, ChunkProgressListener statusListener, boolean isDebug, long seed, List specialSpawners, boolean shouldBeTicking, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { - arclight$constructor(minecraftServer, backgroundExecutor, levelSave, worldInfo, dimension, levelStem, statusListener, isDebug, seed, specialSpawners, shouldBeTicking); + public void arclight$constructor(MinecraftServer minecraftServer, Executor backgroundExecutor, LevelStorageSource.LevelStorageAccess levelSave, PrimaryLevelData worldInfo, ResourceKey dimension, LevelStem levelStem, ChunkProgressListener statusListener, boolean isDebug, long seed, List specialSpawners, boolean shouldBeTicking, RandomSequences seq, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { + arclight$constructor(minecraftServer, backgroundExecutor, levelSave, worldInfo, dimension, levelStem, statusListener, isDebug, seed, specialSpawners, shouldBeTicking, seq); this.generator = gen; this.environment = env; this.biomeProvider = biomeProvider; @@ -142,7 +143,7 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld } @Inject(method = "", at = @At("RETURN")) - private void arclight$init(MinecraftServer minecraftServer, Executor backgroundExecutor, LevelStorageSource.LevelStorageAccess levelSave, ServerLevelData worldInfo, ResourceKey dimension, LevelStem levelStem, ChunkProgressListener statusListener, boolean isDebug, long seed, List specialSpawners, boolean shouldBeTicking, CallbackInfo ci) { + private void arclight$init(MinecraftServer minecraftServer, Executor backgroundExecutor, LevelStorageSource.LevelStorageAccess levelSave, ServerLevelData worldInfo, ResourceKey dimension, LevelStem levelStem, ChunkProgressListener statusListener, boolean isDebug, long seed, List specialSpawners, boolean shouldBeTicking, RandomSequences seq, CallbackInfo ci) { this.pvpMode = minecraftServer.isPvpAllowed(); this.convertable = levelSave; var typeKey = ((LevelStorageSourceBridge.LevelStorageAccessBridge) levelSave).bridge$getTypeKey(); @@ -159,10 +160,10 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld } } if (worldInfo instanceof PrimaryLevelData) { - this.J = (PrimaryLevelData) worldInfo; + this.K = (PrimaryLevelData) worldInfo; } else if (worldInfo instanceof DerivedLevelData) { // damn spigot again - this.J = DelegateWorldInfo.wrap(((DerivedLevelData) worldInfo)); + this.K = DelegateWorldInfo.wrap(((DerivedLevelData) worldInfo)); ((DerivedWorldInfoBridge) worldInfo).bridge$setDimType(this.getTypeKey()); if (ArclightConfig.spec().getCompat().isSymlinkWorld()) { WorldSymlink.create((DerivedLevelData) worldInfo, levelSave.getDimensionPath(this.dimension()).toFile()); @@ -171,7 +172,7 @@ public abstract class ServerLevelMixin extends LevelMixin implements ServerWorld this.spigotConfig = new SpigotWorldConfig(worldInfo.getLevelName()); this.uuid = WorldUUID.getUUID(levelSave.getDimensionPath(this.dimension()).toFile()); ((ServerChunkProviderBridge) this.chunkSource).bridge$setViewDistance(spigotConfig.viewDistance); - ((WorldInfoBridge) this.J).bridge$setWorld((ServerLevel) (Object) this); + ((WorldInfoBridge) this.K).bridge$setWorld((ServerLevel) (Object) this); var data = this.getDataStorage().computeIfAbsent(LevelPersistentData::new, () -> new LevelPersistentData(null), "bukkit_pdc"); this.bridge$getWorld().readBukkitValues(data.getTag()); } 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 504b0e34..17352f03 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 @@ -31,7 +31,7 @@ public class ServerLevel_EntityCallbacksMixin { @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()) { + for (ServerLevel serverLevel : ServerLifecycleHooks.getCurrentServer().getAllLevels()) { DimensionDataStorage worldData = serverLevel.getDataStorage(); for (Object o : worldData.cache.values()) { if (o instanceof MapItemSavedData map) { 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 1421040b..1ef6962e 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 @@ -137,19 +137,19 @@ public abstract class PlayerListMixin implements PlayerListBridge { cserver.getPluginManager().callEvent(event); Location loc = event.getSpawnLocation(); ServerLevel world = ((CraftWorld) loc.getWorld()).getHandle(); - playerIn.setLevel(world); + playerIn.setServerLevel(world); playerIn.absMoveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); return world; } @Redirect(method = "placeNewPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/server/players/PlayerList;viewDistance:I")) private int arclight$spigotViewDistance(PlayerList playerList, Connection netManager, ServerPlayer playerIn) { - return ((WorldBridge) playerIn.getLevel()).bridge$spigotConfig().viewDistance; + return ((WorldBridge) playerIn.serverLevel()).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; + return ((WorldBridge) playerIn.serverLevel()).bridge$spigotConfig().simulationDistance; } @Eject(method = "placeNewPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastSystemMessage(Lnet/minecraft/network/chat/Component;Z)V")) @@ -173,14 +173,14 @@ public abstract class PlayerListMixin implements PlayerListBridge { @Redirect(method = "placeNewPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addNewPlayer(Lnet/minecraft/server/level/ServerPlayer;)V")) private void arclight$addNewPlayer(ServerLevel instance, ServerPlayer player) { - if (player.level == instance && !instance.players().contains(player)) { + if (player.level() == instance && !instance.players().contains(player)) { instance.addNewPlayer(player); } } @ModifyVariable(method = "placeNewPlayer", ordinal = 1, at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/server/level/ServerLevel;addNewPlayer(Lnet/minecraft/server/level/ServerPlayer;)V")) private ServerLevel arclight$handleWorldChanges(ServerLevel value, Connection connection, ServerPlayer player) { - return player.getLevel(); + return player.serverLevel(); } @Inject(method = "save", cancellable = true, at = @At("HEAD")) @@ -256,7 +256,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { public ServerPlayer respawn(ServerPlayer playerIn, ServerLevel worldIn, boolean flag, Location location, boolean avoidSuffocation, PlayerRespawnEvent.RespawnReason respawnReason) { playerIn.stopRiding(); this.players.remove(playerIn); - playerIn.getLevel().removePlayerImmediately(playerIn, Entity.RemovalReason.DISCARDED); + playerIn.serverLevel().removePlayerImmediately(playerIn, Entity.RemovalReason.DISCARDED); playerIn.revive(); BlockPos pos = playerIn.getRespawnPosition(); float f = playerIn.getRespawnAngle(); @@ -329,10 +329,10 @@ public abstract class PlayerListMixin implements PlayerListBridge { playerIn.setPos(playerIn.getX(), playerIn.getY() + 1.0, playerIn.getZ()); } LevelData worlddata = serverWorld.getLevelData(); - playerIn.connection.send(new ClientboundRespawnPacket(serverWorld.dimensionTypeId(), serverWorld.dimension(), BiomeManager.obfuscateSeed(serverWorld.getSeed()), playerIn.gameMode.getGameModeForPlayer(), playerIn.gameMode.getPreviousGameModeForPlayer(), serverWorld.isDebug(), serverWorld.isFlat(), (byte) (flag ? 1 : 0), playerIn.getLastDeathLocation())); + playerIn.connection.send(new ClientboundRespawnPacket(serverWorld.dimensionTypeId(), serverWorld.dimension(), BiomeManager.obfuscateSeed(serverWorld.getSeed()), playerIn.gameMode.getGameModeForPlayer(), playerIn.gameMode.getPreviousGameModeForPlayer(), serverWorld.isDebug(), serverWorld.isFlat(), (byte) (flag ? 1 : 0), playerIn.getLastDeathLocation(), playerIn.getPortalCooldown())); playerIn.connection.send(new ClientboundSetChunkCacheRadiusPacket(((WorldBridge) serverWorld).bridge$spigotConfig().viewDistance)); playerIn.connection.send(new ClientboundSetSimulationDistancePacket(((WorldBridge) serverWorld).bridge$spigotConfig().simulationDistance)); - playerIn.setLevel(serverWorld); + playerIn.setServerLevel(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); playerIn.connection.send(new ClientboundSetDefaultSpawnPositionPacket(serverWorld.getSharedSpawnPos(), serverWorld.getSharedSpawnAngle())); @@ -385,7 +385,7 @@ public abstract class PlayerListMixin implements PlayerListBridge { arclight$respawnReason = null; playerIn.stopRiding(); this.players.remove(playerIn); - playerIn.getLevel().removePlayerImmediately(playerIn, Entity.RemovalReason.DISCARDED); + playerIn.serverLevel().removePlayerImmediately(playerIn, Entity.RemovalReason.DISCARDED); BlockPos pos = playerIn.getRespawnPosition(); float f = playerIn.getRespawnAngle(); boolean flag2 = playerIn.isRespawnForced(); @@ -478,11 +478,11 @@ public abstract class PlayerListMixin implements PlayerListBridge { serverplayerentity.setPos(serverplayerentity.getX(), serverplayerentity.getY() + 1.0D, serverplayerentity.getZ()); } - LevelData iworldinfo = serverplayerentity.level.getLevelData(); - serverplayerentity.connection.send(new ClientboundRespawnPacket(serverplayerentity.level.dimensionTypeId(), serverplayerentity.level.dimension(), BiomeManager.obfuscateSeed(serverplayerentity.getLevel().getSeed()), serverplayerentity.gameMode.getGameModeForPlayer(), serverplayerentity.gameMode.getPreviousGameModeForPlayer(), serverplayerentity.getLevel().isDebug(), serverplayerentity.getLevel().isFlat(), (byte) (conqueredEnd ? 1 : 0), serverplayerentity.getLastDeathLocation())); + LevelData iworldinfo = serverplayerentity.level().getLevelData(); + serverplayerentity.connection.send(new ClientboundRespawnPacket(serverplayerentity.level().dimensionTypeId(), serverplayerentity.level().dimension(), BiomeManager.obfuscateSeed(serverplayerentity.serverLevel().getSeed()), serverplayerentity.gameMode.getGameModeForPlayer(), serverplayerentity.gameMode.getPreviousGameModeForPlayer(), serverplayerentity.serverLevel().isDebug(), serverplayerentity.serverLevel().isFlat(), (byte) (conqueredEnd ? 1 : 0), serverplayerentity.getLastDeathLocation(), serverplayerentity.getPortalCooldown())); serverplayerentity.connection.send(new ClientboundSetChunkCacheRadiusPacket(((WorldBridge) serverWorld).bridge$spigotConfig().viewDistance)); serverplayerentity.connection.send(new ClientboundSetSimulationDistancePacket(((WorldBridge) serverWorld).bridge$spigotConfig().simulationDistance)); - serverplayerentity.setLevel(serverWorld); + serverplayerentity.setServerLevel(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); serverplayerentity.connection.send(new ClientboundSetDefaultSpawnPositionPacket(serverWorld.getSharedSpawnPos(), serverWorld.getSharedSpawnAngle())); @@ -541,9 +541,9 @@ public abstract class PlayerListMixin implements PlayerListBridge { private void arclight$useScaledHealth(ServerPlayer playerEntity) { ((ServerPlayerEntityBridge) playerEntity).bridge$getBukkitEntity().updateScaledHealth(); ((SynchedEntityDataBridge) playerEntity.getEntityData()).bridge$refresh(playerEntity); - int i = playerEntity.level.getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; + int i = playerEntity.level().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; playerEntity.connection.send(new ClientboundEntityEventPacket(playerEntity, (byte) i)); - float immediateRespawn = playerEntity.level.getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0f : 0.0f; + float immediateRespawn = playerEntity.level().getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0f : 0.0f; playerEntity.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, immediateRespawn)); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/ServerPlayerGameModeMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/ServerPlayerGameModeMixin.java index c23e69d2..9cdb82b9 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/ServerPlayerGameModeMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/management/ServerPlayerGameModeMixin.java @@ -155,7 +155,7 @@ public abstract class ServerPlayerGameModeMixin implements PlayerInteractionMana if (forgeEvent.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY) { iblockdata.attack(this.level, blockPos, this.player); } - f = iblockdata.getDestroyProgress(this.player, this.player.level, blockPos); + f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockPos); } if (event.useItemInHand() == Event.Result.DENY) { if (f > 1.0f) { @@ -191,7 +191,7 @@ public abstract class ServerPlayerGameModeMixin implements PlayerInteractionMana int k = this.gameTicks - this.destroyProgressStart; BlockState iblockdata = this.level.getBlockState(blockPos); if (!iblockdata.isAir()) { - float f2 = iblockdata.getDestroyProgress(this.player, this.player.level, blockPos) * (k + 1); + float f2 = iblockdata.getDestroyProgress(this.player, this.player.level(), blockPos) * (k + 1); if (f2 >= 0.7f) { this.isDestroyingBlock = false; this.level.destroyBlockProgress(this.player.getId(), blockPos, -1); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/ExplosionMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/ExplosionMixin.java index e6c6cf3d..a6166e44 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/ExplosionMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/ExplosionMixin.java @@ -32,7 +32,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -285,7 +285,7 @@ public abstract class ExplosionMixin implements ExplosionBridge { this.level.getProfiler().push("explosion_blocks"); if (blockstate.canDropFromExplosion(this.level, blockpos, (Explosion) (Object) this) && this.level instanceof ServerLevel serverLevel) { BlockEntity tileentity = blockstate.hasBlockEntity() ? this.level.getBlockEntity(blockpos) : null; - LootContext.Builder lootcontext$builder = new LootContext.Builder(serverLevel).withRandom(this.level.random).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockpos)).withParameter(LootContextParams.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParams.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParams.THIS_ENTITY, this.source); + LootParams.Builder lootcontext$builder = new LootParams.Builder(serverLevel).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockpos)).withParameter(LootContextParams.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParams.BLOCK_ENTITY, tileentity).withOptionalParameter(LootContextParams.THIS_ENTITY, this.source); if (yield < 1.0F) { lootcontext$builder.withParameter(LootContextParams.EXPLOSION_RADIUS, 1.0F / yield); } 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 359f1008..b71481cc 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 @@ -61,7 +61,7 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements super.tick(); boolean flag = this.isWaiting(); float f = this.getRadius(); - if (this.level.isClientSide) { + if (this.level().isClientSide) { if (flag && this.random.nextBoolean()) { return; } @@ -103,7 +103,7 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements d7 = (float) (k & 255) / 255.0F; } - this.level.addAlwaysVisibleParticle(particleoptions, d0, d2, d4, d5, d6, d7); + this.level().addAlwaysVisibleParticle(particleoptions, d0, d2, d4, d5, d6, d7); } } else { if (this.tickCount >= this.waitTime + this.duration) { @@ -144,7 +144,7 @@ public abstract class AreaEffectCloudEntityMixin extends EntityMixin implements if (list.isEmpty()) { this.victims.clear(); } else { - List list1 = this.level.getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); + List list1 = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); if (!list1.isEmpty()) { List entities = new java.util.ArrayList(); // CraftBukkit for (LivingEntity livingentity : list1) { 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 53c4b71d..f17313b6 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 @@ -90,10 +90,7 @@ 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; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @@ -111,7 +108,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, // @formatter:off @Shadow private float yRot; - @Shadow public Level level; + @Shadow public abstract Level level(); @Shadow protected int boardingCooldown; @Shadow private float xRot; @Shadow public abstract float getYRot(); @@ -166,7 +163,6 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, @Shadow protected abstract void markHurt(); @Shadow public abstract void ejectPassengers(); @Shadow public abstract boolean hasCustomName(); - @Shadow protected abstract void outOfWorld(); @Shadow public abstract void setPos(double x, double y, double z); @Shadow protected abstract void setRot(float yaw, float pitch); @Shadow public double xo; @@ -228,8 +224,12 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, @Shadow public abstract boolean teleportTo(ServerLevel p_265257_, double p_265407_, double p_265727_, double p_265410_, Set p_265083_, float p_265573_, float p_265094_); @Shadow public abstract boolean isSpectator(); @Shadow public abstract SoundSource getSoundSource(); + @Shadow public abstract int getPortalCooldown(); + @Shadow public abstract void checkBelowWorld(); // @formatter:on + @Shadow protected abstract void setLevel(Level p_285201_); + private static final int CURRENT_LEVEL = 2; public boolean persist = true; public boolean generation; @@ -280,7 +280,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, } public boolean isChunkLoaded() { - return level.hasChunk((int) Math.floor(getX()) >> 4, (int) Math.floor(getZ()) >> 4); + return level().hasChunk((int) Math.floor(getX()) >> 4, (int) Math.floor(getZ()) >> 4); } @Override @@ -433,7 +433,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, @Redirect(method = "lavaHurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setSecondsOnFire(I)V")) public void arclight$setOnFireFromLava$bukkitEvent(Entity entity, int seconds) { - var damager = (lastLavaContact == null) ? null : CraftBlock.at(level, lastLavaContact); + var damager = (lastLavaContact == null) ? null : CraftBlock.at(level(), lastLavaContact); CraftEventFactory.blockDamage = damager; if ((Object) this instanceof LivingEntity && remainingFireTicks <= 0) { var damagee = this.getBukkitEntity(); @@ -482,10 +482,11 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, ArclightCaptures.captureDamageEventBlock(null); } - @Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity$MovementEmission;emitsAnything()Z")) + @Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;onGround()Z"), + slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;updateEntityAfterFallOn(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/world/entity/Entity;)V"))) private void arclight$move$blockCollide(MoverType typeIn, Vec3 pos, CallbackInfo ci) { if (horizontalCollision && this.bridge$getBukkitEntity() instanceof Vehicle vehicle) { - org.bukkit.block.Block block = ((WorldBridge) this.level).bridge$getWorld().getBlockAt(Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ())); + org.bukkit.block.Block block = ((WorldBridge) this.level()).bridge$getWorld().getBlockAt(Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ())); Vec3 vec3d = this.collide(pos); if (pos.x > vec3d.x) { block = block.getRelative(BlockFace.EAST); @@ -507,7 +508,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, @Inject(method = "absMoveTo(DDDFF)V", at = @At("RETURN")) private void arclight$loadChunk(double x, double y, double z, float yaw, float pitch, CallbackInfo ci) { if (this.valid) - this.level.getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); + this.level().getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); } public boolean canCollideWith(Entity entity) { @@ -539,8 +540,8 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, @Inject(method = "saveWithoutId", at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 0, target = "Lnet/minecraft/nbt/CompoundTag;putUUID(Ljava/lang/String;Ljava/util/UUID;)V")) public void arclight$writeWithoutTypeId$CraftBukkitNBT(CompoundTag compound, CallbackInfoReturnable cir) { - compound.putLong("WorldUUIDLeast", ((WorldBridge) this.level).bridge$getWorld().getUID().getLeastSignificantBits()); - compound.putLong("WorldUUIDMost", ((WorldBridge) this.level).bridge$getWorld().getUID().getMostSignificantBits()); + compound.putLong("WorldUUIDLeast", ((WorldBridge) this.level()).bridge$getWorld().getUID().getLeastSignificantBits()); + compound.putLong("WorldUUIDMost", ((WorldBridge) this.level()).bridge$getWorld().getUID().getMostSignificantBits()); compound.putInt("Bukkit.updateLevel", CURRENT_LEVEL); compound.putInt("Spigot.ticksLived", this.tickCount); if (!this.persist) { @@ -596,7 +597,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, bworld = ((WorldBridge) ((CraftServer) server).getServer().getLevel(Level.OVERWORLD)).bridge$getWorld(); } - ((ServerPlayer) (Object) this).setLevel(bworld == null ? null : ((CraftWorld) bworld).getHandle()); + ((ServerPlayer) (Object) this).setServerLevel(bworld == null ? null : ((CraftWorld) bworld).getHandle()); } this.getBukkitEntity().readBukkitValues(compound); if (compound.contains("Bukkit.invisible")) { @@ -627,8 +628,8 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, } @Inject(method = "spawnAtLocation(Lnet/minecraft/world/item/ItemStack;F)Lnet/minecraft/world/entity/item/ItemEntity;", - cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) + cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) public void arclight$entityDropItem(ItemStack stack, float offsetY, CallbackInfoReturnable cir, ItemEntity itementity) { EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) ((EntityBridge) itementity).bridge$getBukkitEntity()); Bukkit.getPluginManager().callEvent(event); @@ -672,8 +673,8 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, Entity orig = craft == null ? null : craft.getHandle(); if (getBukkitEntity() instanceof Vehicle && ((EntityBridge) entity).bridge$getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { VehicleEnterEvent event = new VehicleEnterEvent( - (Vehicle) getBukkitEntity(), - ((EntityBridge) entity).bridge$getBukkitEntity() + (Vehicle) getBukkitEntity(), + ((EntityBridge) entity).bridge$getBukkitEntity() ); // Suppress during worldgen if (this.valid) { @@ -701,7 +702,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, } else { List list = Lists.newArrayList(this.passengers); - if (!this.level.isClientSide && entity instanceof Player && !(this.getFirstPassenger() instanceof Player)) { + if (!this.level().isClientSide && entity instanceof Player && !(this.getFirstPassenger() instanceof Player)) { list.add(0, entity); } else { list.add(entity); @@ -729,8 +730,8 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, Entity orig = craft == null ? null : craft.getHandle(); if (getBukkitEntity() instanceof Vehicle && ((EntityBridge) entity).bridge$getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { VehicleExitEvent event = new VehicleExitEvent( - (Vehicle) getBukkitEntity(), - (org.bukkit.entity.LivingEntity) ((EntityBridge) entity).bridge$getBukkitEntity() + (Vehicle) getBukkitEntity(), + (org.bukkit.entity.LivingEntity) ((EntityBridge) entity).bridge$getBukkitEntity() ); // Suppress during worldgen if (this.valid) { @@ -757,7 +758,7 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, this.passengers = ImmutableList.of(); } else { this.passengers = this.passengers.stream().filter((entity1) -> entity1 != entity) - .collect(ImmutableList.toImmutableList()); + .collect(ImmutableList.toImmutableList()); } entity.boardingCooldown = 60; @@ -875,28 +876,28 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, public Entity changeDimension(ServerLevel server, net.minecraftforge.common.util.ITeleporter teleporter) { if (!ForgeHooks.onTravelToDimension((Entity) (Object) this, server.dimension())) return null; - if (this.level instanceof ServerLevel && !this.isRemoved()) { - this.level.getProfiler().push("changeDimension"); + if (this.level() instanceof ServerLevel && !this.isRemoved()) { + this.level().getProfiler().push("changeDimension"); if (server == null) { return null; } - this.level.getProfiler().push("reposition"); + this.level().getProfiler().push("reposition"); var bukkitPos = arclight$tpPos; arclight$tpPos = null; PortalInfo portalinfo = bukkitPos == null ? teleporter.getPortalInfo((Entity) (Object) this, server, this::findDimensionEntryPoint) - : new PortalInfo(new Vec3(bukkitPos.x(), bukkitPos.y(), bukkitPos.z()), Vec3.ZERO, this.yRot, this.xRot); + : new PortalInfo(new Vec3(bukkitPos.x(), bukkitPos.y(), bukkitPos.z()), Vec3.ZERO, this.yRot, this.xRot); if (portalinfo == null) { return null; } else { ServerLevel world = ((PortalInfoBridge) portalinfo).bridge$getWorld() == null ? server : ((PortalInfoBridge) portalinfo).bridge$getWorld(); - if (world == this.level) { + if (world == this.level()) { this.moveTo(portalinfo.pos.x, portalinfo.pos.y, portalinfo.pos.z, portalinfo.yRot, this.getXRot()); this.setDeltaMovement(portalinfo.speed); return (Entity) (Object) this; } this.unRide(); - Entity transportedEntity = teleporter.placeEntity((Entity) (Object) this, (ServerLevel) this.level, world, this.getYRot(), spawnPortal -> { //Forge: Start vanilla logic - this.level.getProfiler().popPush("reloading"); + Entity transportedEntity = teleporter.placeEntity((Entity) (Object) this, (ServerLevel) this.level(), world, this.getYRot(), spawnPortal -> { //Forge: Start vanilla logic + this.level().getProfiler().popPush("reloading"); Entity entity = this.getType().create(world); if (entity != null) { entity.restoreFrom((Entity) (Object) this); @@ -912,10 +913,10 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, }); //Forge: End vanilla logic this.removeAfterChangingDimensions(); - this.level.getProfiler().pop(); - ((ServerLevel) this.level).resetEmptyTime(); + this.level().getProfiler().pop(); + ((ServerLevel) this.level()).resetEmptyTime(); world.resetEmptyTime(); - this.level.getProfiler().pop(); + this.level().getProfiler().pop(); return transportedEntity; } } else { @@ -942,15 +943,15 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, if (world == null) { return null; } - boolean flag = ((WorldBridge) this.level).bridge$getTypeKey() == LevelStem.END && ((WorldBridge) world).bridge$getTypeKey() == LevelStem.OVERWORLD; + 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() == LevelStem.NETHER; - if (this.level.dimension() != Level.NETHER && !flag2) { + if (this.level().dimension() != Level.NETHER && !flag2) { return null; } else { WorldBorder worldborder = world.getWorldBorder(); - double d0 = DimensionType.getTeleportationScale(this.level.dimensionType(), world.dimensionType()); + 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, new PositionImpl(blockpos1.getX(), blockpos1.getY(), blockpos1.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); @@ -961,13 +962,13 @@ public abstract class EntityMixin implements InternalEntityBridge, EntityBridge, blockpos1 = worldFinal.getWorldBorder().clampToBounds(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); return this.getExitPortal(world, blockpos1, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((result) -> { - BlockState blockstate = this.level.getBlockState(this.portalEntrancePos); + BlockState blockstate = this.level().getBlockState(this.portalEntrancePos); Direction.Axis direction$axis; Vec3 vector3d; if (blockstate.hasProperty(BlockStateProperties.HORIZONTAL_AXIS)) { direction$axis = blockstate.getValue(BlockStateProperties.HORIZONTAL_AXIS); BlockUtil.FoundRectangle teleportationrepositioner$result = BlockUtil.getLargestRectangleAround(this.portalEntrancePos, direction$axis, 21, Direction.Axis.Y, 21, (pos) -> { - return this.level.getBlockState(pos) == blockstate; + return this.level().getBlockState(pos) == blockstate; }); vector3d = this.getRelativePortalPosition(direction$axis, teleportationrepositioner$result); } else { 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 1616ad34..3f9a67cb 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 @@ -254,7 +254,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt // if (!this.world.isRemote && (this.isPlayer() || this.recentlyHit > 0 && this.canDropLoot() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT))) { if (!((Object) this instanceof EnderDragon)) { int reward = ForgeEventFactory.getExperienceDrop((LivingEntity) (Object) this, this.lastHurtByPlayer, this.expToDrop); - ExperienceOrb.award((ServerLevel) this.level, this.position(), reward); + ExperienceOrb.award((ServerLevel) this.level(), this.position(), reward); bridge$setExpToDrop(0); } } @@ -278,7 +278,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt if (!effectinstance.tick((LivingEntity) (Object) this, () -> { onEffectUpdated(effectinstance, true, null); })) { - if (!this.level.isClientSide && !MinecraftForge.EVENT_BUS.post(new MobEffectEvent.Expired((LivingEntity) (Object) this, effectinstance))) { + if (!this.level().isClientSide && !MinecraftForge.EVENT_BUS.post(new MobEffectEvent.Expired((LivingEntity) (Object) this, effectinstance))) { EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent((LivingEntity) (Object) this, effectinstance, null, EntityPotionEffectEvent.Cause.EXPIRATION); if (event.isCancelled()) { @@ -309,7 +309,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt effectsToProcess.clear(); if (this.effectsDirty) { - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { this.updateInvisibilityStatus(); } @@ -334,7 +334,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt double d0 = (double) (i >> 16 & 255) / 255.0D; double d1 = (double) (i >> 8 & 255) / 255.0D; double d2 = (double) (i >> 0 & 255) / 255.0D; - this.level.addParticle(flag1 ? ParticleTypes.AMBIENT_ENTITY_EFFECT : ParticleTypes.ENTITY_EFFECT, this.getX() + (this.random.nextDouble() - 0.5D) * (double) this.getBbWidth(), this.getY() + this.random.nextDouble() * (double) this.getBbHeight(), this.getZ() + (this.random.nextDouble() - 0.5D) * (double) this.getBbWidth(), d0, d1, d2); + this.level().addParticle(flag1 ? ParticleTypes.AMBIENT_ENTITY_EFFECT : ParticleTypes.ENTITY_EFFECT, this.getX() + (this.random.nextDouble() - 0.5D) * (double) this.getBbWidth(), this.getY() + this.random.nextDouble() * (double) this.getBbHeight(), this.getZ() + (this.random.nextDouble() - 0.5D) * (double) this.getBbWidth(), d0, d1, d2); } } } @@ -419,7 +419,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt } public int getExpReward() { - if (this.level instanceof ServerLevel && !this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { + if (this.level() instanceof ServerLevel && !this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { int exp = this.getExperienceReward(); return ForgeEventFactory.getExperienceDrop((LivingEntity) (Object) this, this.lastHurtByPlayer, exp); } else { @@ -514,14 +514,14 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt if (!ForgeHooks.onLivingAttack((LivingEntity) (Object) this, source, amount)) return false; if (this.isInvulnerableTo(source)) { return false; - } else if (this.level.isClientSide) { + } else if (this.level().isClientSide) { return false; } else if (this.dead || this.isRemoved() || this.getHealth() <= 0.0F) { return false; } else if (source.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; } else { - if (this.isSleeping() && !this.level.isClientSide) { + if (this.isSleeping() && !this.level().isClientSide) { this.stopSleeping(); } @@ -602,9 +602,9 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt if (flag1) { if (flag) { - this.level.broadcastEntityEvent((LivingEntity) (Object) this, (byte) 29); + this.level().broadcastEntityEvent((LivingEntity) (Object) this, (byte) 29); } else { - this.level.broadcastDamageEvent((LivingEntity) (Object) this, source); + this.level().broadcastDamageEvent((LivingEntity) (Object) this, source); } if (!source.is(DamageTypeTags.NO_IMPACT) && (!flag || amount > 0.0F)) { @@ -642,7 +642,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt boolean flag2 = !flag || amount > 0.0F; if (flag2) { this.lastDamageSource = source; - this.lastDamageStamp = this.level.getGameTime(); + this.lastDamageStamp = this.level().getGameTime(); } if ((Object) this instanceof ServerPlayer) { @@ -759,7 +759,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt // Apply blocking code // PAIL: steal from above if (event.getDamage(EntityDamageEvent.DamageModifier.BLOCKING) < 0) { - this.level.broadcastEntityEvent((Entity) (Object) this, (byte) 29); // SPIGOT-4635 - shield damage sound + this.level().broadcastEntityEvent((Entity) (Object) this, (byte) 29); // SPIGOT-4635 - shield damage sound if (shieldTakesDamage) { this.hurtCurrentlyUsedShield((float) -event.getDamage(EntityDamageEvent.DamageModifier.BLOCKING)); } @@ -795,7 +795,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt // CraftBukkit end float f3 = this.getHealth(); - this.getCombatTracker().recordDamage(damagesource, f3, f); + this.getCombatTracker().recordDamage(damagesource, f); this.setHealth(f3 - f); // Forge: moved to fix MC-121048 // CraftBukkit start if (!human) { @@ -934,7 +934,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt bridge$pushEffectCause(EntityPotionEffectEvent.Cause.TOTEM); this.addEffect(new MobEffectInstance(MobEffects.ABSORPTION, 100, 1), EntityPotionEffectEvent.Cause.TOTEM); this.addEffect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 800, 1), EntityPotionEffectEvent.Cause.TOTEM); - this.level.broadcastEntityEvent((Entity) (Object) this, (byte) 35); + this.level().broadcastEntityEvent((Entity) (Object) this, (byte) 35); } return !event.isCancelled(); } @@ -1033,8 +1033,8 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt @Eject(method = "randomTeleport", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/entity/LivingEntity;teleportTo(DDD)V")) private void arclight$entityTeleport(LivingEntity entity, double x, double y, double z, CallbackInfoReturnable< Boolean> cir) { - EntityTeleportEvent event = new EntityTeleportEvent(getBukkitEntity(), new Location(((WorldBridge) this.level).bridge$getWorld(), this.getX(), this.getY(), this.getZ()), - new Location(((WorldBridge) this.level).bridge$getWorld(), x, y, z)); + EntityTeleportEvent event = new EntityTeleportEvent(getBukkitEntity(), new Location(((WorldBridge) this.level()).bridge$getWorld(), this.getX(), this.getY(), this.getZ()), + new Location(((WorldBridge) this.level()).bridge$getWorld(), x, y, z)); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { this.teleportTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); @@ -1129,8 +1129,8 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt if (!flag && !ItemStack.isSameItemSameTags(oldItem, newItem) && !this.firstTick) { Equipable equipable = Equipable.get(newItem); if (equipable != null && !this.isSpectator() && equipable.getEquipmentSlot() == slot) { - if (!this.level.isClientSide() && !this.isSilent() && !silent) { - this.level.playSound(null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F); + if (!this.level().isClientSide() && !this.isSilent() && !silent) { + this.level().playSound(null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F); } if (this.doesEmitEquipEvent(slot)) { 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 2d4cf076..53b1cf91 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 @@ -147,7 +147,6 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri livingEntity = changeTargetEvent.getNewTarget(); } this.target = livingEntity; - ForgeHooks.onLivingSetAttackTarget((Mob) (Object) this, this.target); arclight$targetSuccess = true; } @@ -229,7 +228,7 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri if (equipmentslottype.isArmor() && !flag) { equipmentslottype = EquipmentSlot.MAINHAND; itemstack = this.getItemBySlot(equipmentslottype); - flag = this.canReplaceCurrentItem(stack, itemstack); + flag = itemstack.isEmpty(); } boolean canPickup = flag && this.canHoldItem(stack); @@ -323,12 +322,12 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri @Inject(method = "convertTo", at = @At("RETURN")) private void arclight$cleanReason(EntityType p_233656_1_, boolean p_233656_2_, CallbackInfoReturnable cir) { - ((WorldBridge) this.level).bridge$pushAddEntityReason(null); + ((WorldBridge) this.level()).bridge$pushAddEntityReason(null); this.arclight$transform = null; } public T convertTo(EntityType entityType, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { - ((WorldBridge) this.level).bridge$pushAddEntityReason(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/GoToWantedItemMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/GoToWantedItemMixin.java index 3f1ccaf1..f546cc23 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/GoToWantedItemMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/GoToWantedItemMixin.java @@ -32,7 +32,7 @@ public abstract class GoToWantedItemMixin { return p_258371_.group(p_258371_.registered(MemoryModuleType.LOOK_TARGET), behaviorbuilder, p_258371_.present(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM), p_258371_.registered(MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS)).apply(p_258371_, (p_258387_, p_258388_, p_258389_, p_258390_) -> { return (p_258380_, p_258381_, p_258382_) -> { ItemEntity itementity = p_258371_.get(p_258389_); - if (p_258371_.tryGet(p_258390_).isEmpty() && p_259490_.test(p_258381_) && itementity.closerThan(p_258381_, (double) p_259054_) && p_258381_.level.getWorldBorder().isWithinBounds(itementity.blockPosition())) { + if (p_258371_.tryGet(p_258390_).isEmpty() && p_259490_.test(p_258381_) && itementity.closerThan(p_258381_, (double) p_259054_) && p_258381_.level().getWorldBorder().isWithinBounds(itementity.blockPosition())) { // CraftBukkit start if (p_258381_ instanceof net.minecraft.world.entity.animal.allay.Allay) { var event = CraftEventFactory.callEntityTargetEvent(p_258381_, itementity, EntityTargetEvent.TargetReason.CLOSEST_ENTITY); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/InteractWithDoorMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/InteractWithDoorMixin.java index 48aa627e..301065b4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/InteractWithDoorMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/InteractWithDoorMixin.java @@ -20,7 +20,7 @@ public abstract class InteractWithDoorMixin { @Eject(method = "desc=/Z$/", require = 2, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/DoorBlock;setOpen(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Z)V")) private static void arclight$openDoor1(DoorBlock instance, Entity entity, Level p_153167_, BlockState p_153168_, BlockPos pos, boolean p_153170_, CallbackInfoReturnable cir) { - var event = new EntityInteractEvent(((EntityBridge) entity).bridge$getBukkitEntity(), CraftBlock.at(entity.getLevel(), pos)); + var event = new EntityInteractEvent(((EntityBridge) entity).bridge$getBukkitEntity(), CraftBlock.at(entity.level(), pos)); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { cir.setReturnValue(false); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/StartAttackingMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/StartAttackingMixin.java index f317096c..323cce86 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/StartAttackingMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/StartAttackingMixin.java @@ -58,7 +58,6 @@ public class StartAttackingMixin { // CraftBukkit end p_258778_.set(changeTargetEvent.getNewTarget()); p_258779_.erase(); - ForgeHooks.onLivingSetAttackTarget(p_258774_, changeTargetEvent.getNewTarget(), LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); // TODO: Remove in 1.20 return true; } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/StopAttackingIfTargetInvalidMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/StopAttackingIfTargetInvalidMixin.java index c9e0a40e..7cbee8b1 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/StopAttackingIfTargetInvalidMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/behavior/StopAttackingIfTargetInvalidMixin.java @@ -34,7 +34,7 @@ public abstract class StopAttackingIfTargetInvalidMixin { return p_258801_.group(p_258801_.present(MemoryModuleType.ATTACK_TARGET), p_258801_.registered(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE)).apply(p_258801_, (p_258787_, p_258788_) -> { return (p_258795_, p_258796_, p_258797_) -> { LivingEntity livingentity = p_258801_.get(p_258787_); - if (p_258796_.canAttack(livingentity) && (!p_260319_ || !isTiredOfTryingToReachTarget(p_258796_, p_258801_.tryGet(p_258788_))) && livingentity.isAlive() && livingentity.level == p_258796_.level && !p_260357_.test(livingentity)) { + if (p_258796_.canAttack(livingentity) && (!p_260319_ || !isTiredOfTryingToReachTarget(p_258796_, p_258801_.tryGet(p_258788_))) && livingentity.isAlive() && livingentity.level() == p_258796_.level() && !p_260357_.test(livingentity)) { return true; } else { // CraftBukkit start diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/goal/SkeletonTrapGoalMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/goal/SkeletonTrapGoalMixin.java index de8120d4..13fbabe5 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/goal/SkeletonTrapGoalMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/ai/goal/SkeletonTrapGoalMixin.java @@ -28,7 +28,7 @@ public class SkeletonTrapGoalMixin { @Inject(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"), slice = @Slice(to = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/horse/SkeletonTrapGoal;createHorse(Lnet/minecraft/world/DifficultyInstance;)Lnet/minecraft/world/entity/animal/horse/AbstractHorse;"))) private void arclight$thunder(CallbackInfo ci) { - ((WorldBridge) this.horse.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.TRAP); + ((WorldBridge) this.horse.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.TRAP); } @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) @@ -40,6 +40,6 @@ public class SkeletonTrapGoalMixin { @Inject(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V"), slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/horse/SkeletonTrapGoal;createHorse(Lnet/minecraft/world/DifficultyInstance;)Lnet/minecraft/world/entity/animal/horse/AbstractHorse;"))) private void arclight$jockey(CallbackInfo ci) { - ((WorldBridge) this.horse.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.JOCKEY); + ((WorldBridge) this.horse.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.JOCKEY); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/AnimalMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/AnimalMixin.java index 028b12a3..f9b63ca4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/AnimalMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/AnimalMixin.java @@ -29,6 +29,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import javax.annotation.Nullable; +import java.util.Optional; @Mixin(Animal.class) public abstract class AnimalMixin extends AgeableMobMixin implements AnimalEntityBridge { @@ -76,57 +77,43 @@ public abstract class AnimalMixin extends AgeableMobMixin implements AnimalEntit return breedItem; } + @Inject(method = "spawnChildFromBreeding", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntityWithPassengers(Lnet/minecraft/world/entity/Entity;)V")) + private void arclight$reason(ServerLevel level, Animal p_27565_, CallbackInfo ci) { + ((WorldBridge) level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.BREEDING); + } + /** * @author IzzelAliz * @reason */ @Overwrite - public void spawnChildFromBreeding(ServerLevel world, Animal animalEntity) { - AgeableMob child = this.getBreedOffspring(world, animalEntity); - final BabyEntitySpawnEvent event = new BabyEntitySpawnEvent((Animal) (Object) this, animalEntity, child); - final boolean cancelled = MinecraftForge.EVENT_BUS.post(event); - child = event.getChild(); - if (cancelled) { - //Reset the "inLove" state for the animals - this.setAge(6000); - animalEntity.setAge(6000); - this.resetLove(); - animalEntity.resetLove(); + public void finalizeSpawnChildFromBreeding(ServerLevel worldserver, Animal entityanimal, @Nullable AgeableMob entityageable) { + // CraftBukkit start - call EntityBreedEvent + Optional cause = Optional.ofNullable(this.getLoveCause()).or(() -> { + return Optional.ofNullable(entityanimal.getLoveCause()); + }); + int experience = this.getRandom().nextInt(7) + 1; + org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = CraftEventFactory.callEntityBreedEvent(entityageable, (Animal) (Object) this, entityanimal, cause.orElse(null), this.breedItem, experience); + if (entityBreedEvent.isCancelled()) { return; } - if (child != null) { - ServerPlayer serverplayerentity = this.getLoveCause(); - if (serverplayerentity == null && animalEntity.getLoveCause() != null) { - serverplayerentity = animalEntity.getLoveCause(); + experience = entityBreedEvent.getExperience(); + cause.ifPresent((entityplayer) -> { + // CraftBukkit end + entityplayer.awardStat(Stats.ANIMALS_BRED); + CriteriaTriggers.BRED_ANIMALS.trigger(entityplayer, (Animal) (Object) this, entityanimal, entityageable); + }); + this.setAge(6000); + entityanimal.setAge(6000); + this.resetLove(); + entityanimal.resetLove(); + worldserver.broadcastEntityEvent((Animal) (Object) this, (byte) 18); + if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + // CraftBukkit start - use event experience + if (experience > 0) { + worldserver.addFreshEntity(new ExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience)); } - - int experience = this.getRandom().nextInt(7) + 1; - org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = CraftEventFactory.callEntityBreedEvent(child, (Animal) (Object) this, animalEntity, serverplayerentity, this.breedItem, experience); - if (entityBreedEvent.isCancelled()) { - return; - } - experience = entityBreedEvent.getExperience(); - - if (serverplayerentity != null) { - serverplayerentity.awardStat(Stats.ANIMALS_BRED); - CriteriaTriggers.BRED_ANIMALS.trigger(serverplayerentity, (Animal) (Object) this, animalEntity, child); - } - - this.setAge(6000); - animalEntity.setAge(6000); - this.resetLove(); - animalEntity.resetLove(); - child.setBaby(true); - child.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); - ((WorldBridge) world).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.BREEDING); - world.addFreshEntityWithPassengers(child); - world.broadcastEntityEvent((Animal) (Object) this, (byte) 18); - if (world.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - if (experience > 0) { - world.addFreshEntity(new ExperienceOrb(world, this.getX(), this.getY(), this.getZ(), experience)); - } - } - + // CraftBukkit end } } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/BeeMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/BeeMixin.java index c99a56b6..c9266c10 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/BeeMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/BeeMixin.java @@ -35,7 +35,7 @@ public abstract class BeeMixin extends AnimalMixin { } else { Entity entity = source.getEntity(); boolean ret = super.hurt(source, amount); - if (ret && !this.level.isClientSide) { + if (ret && !this.level().isClientSide) { this.beePollinateGoal.stopPollinating(); } return ret; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/Bee_GrowCropGoalMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/Bee_GrowCropGoalMixin.java index a32a267b..993a525d 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/Bee_GrowCropGoalMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/Bee_GrowCropGoalMixin.java @@ -20,8 +20,8 @@ public class Bee_GrowCropGoalMixin { private Bee outerThis; @Inject(method = "tick", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;levelEvent(ILnet/minecraft/core/BlockPos;I)V")) - private void arclight$entityChangeBlock(CallbackInfo ci, int i, BlockPos blockPos, BlockState blockState, Block block, boolean flag, IntegerProperty property) { - if (CraftEventFactory.callEntityChangeBlockEvent(outerThis, blockPos, blockState.setValue(property, blockState.getValue(property) + 1)).isCancelled()) { + private void arclight$entityChangeBlock(CallbackInfo ci, int i, BlockPos blockPos, BlockState blockState, Block block, BlockState state) { + if (CraftEventFactory.callEntityChangeBlockEvent(outerThis, blockPos, state).isCancelled()) { ci.cancel(); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/BucketableMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/BucketableMixin.java index 7a39c2ce..a194ac84 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/BucketableMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/BucketableMixin.java @@ -48,7 +48,7 @@ public interface BucketableMixin { entity.playSound(entity.getPickupSound(), 1.0F, 1.0F); ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, player, itemstack1, false); player.setItemInHand(hand, itemstack2); - Level level = entity.level; + Level level = entity.level(); if (!level.isClientSide) { CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer) player, itemstack1); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/CowMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/CowMixin.java index 4d203b15..684cc967 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/CowMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/CowMixin.java @@ -26,14 +26,14 @@ public abstract class CowMixin extends AnimalMixin { ItemStack itemstack = playerEntity.getItemInHand(hand); if (itemstack.getItem() == Items.BUCKET && !this.isBaby()) { playerEntity.playSound(SoundEvents.COW_MILK, 1.0F, 1.0F); - org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) playerEntity.level, playerEntity, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, hand); + org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) playerEntity.level(), playerEntity, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, hand); if (event.isCancelled()) { return InteractionResult.PASS; } ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, playerEntity, CraftItemStack.asNMSCopy(event.getItemStack())); playerEntity.setItemInHand(hand, itemstack1); - return InteractionResult.sidedSuccess(this.level.isClientSide); + return InteractionResult.sidedSuccess(this.level().isClientSide); } else { return super.mobInteract(playerEntity, hand); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/MushroomCowMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/MushroomCowMixin.java index 02eb2b01..fcc07dd2 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/MushroomCowMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/MushroomCowMixin.java @@ -40,7 +40,7 @@ public abstract class MushroomCowMixin extends AnimalMixin { if (CraftEventFactory.callEntityTransformEvent((MushroomCow) (Object) this, cowEntity, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { cir.setReturnValue(Collections.emptyList()); } else { - ((WorldBridge) this.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SHEARED); + ((WorldBridge) this.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SHEARED); this.discard(); } } @@ -52,13 +52,13 @@ public abstract class MushroomCowMixin extends AnimalMixin { @Overwrite public void shear(SoundSource pCategory) { for (ItemStack s : shearInternal(pCategory)) { - var itemEntity = new ItemEntity(this.level, this.getX(), this.getY(1.0D), this.getZ(), s); + var itemEntity = new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), s); EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) ((EntityBridge) itemEntity).bridge$getBukkitEntity()); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { continue; } - this.level.addFreshEntity(itemEntity); + this.level().addFreshEntity(itemEntity); } } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/PigMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/PigMixin.java index ecc78a5e..ec688ca6 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/PigMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/PigMixin.java @@ -22,7 +22,7 @@ public abstract class PigMixin extends AnimalMixin { if (CraftEventFactory.callPigZapEvent((Pig) (Object) this, lightningBolt, piglin).isCancelled()) { ci.cancel(); } else { - ((WorldBridge) this.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.LIGHTNING); + ((WorldBridge) this.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.LIGHTNING); } } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/SnifferMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/SnifferMixin.java index b30b4fc2..573af30e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/SnifferMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/SnifferMixin.java @@ -1,28 +1,26 @@ package io.izzel.arclight.common.mixin.core.world.entity.animal; import io.izzel.arclight.common.bridge.core.entity.EntityBridge; -import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.animal.sniffer.Sniffer; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.item.ItemStack; import org.bukkit.Bukkit; import org.bukkit.entity.Item; import org.bukkit.event.entity.EntityDropItemEvent; 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.LocalCapture; +import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(Sniffer.class) public abstract class SnifferMixin extends AnimalMixin { - @Inject(method = "dropSeed", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/item/ItemEntity;setDefaultPickUpDelay()V")) - private void arclight$dropSeed(CallbackInfo ci, ItemStack stack, BlockPos pos, ItemEntity itemEntity) { - var event = new EntityDropItemEvent(this.getBukkitEntity(), (Item) ((EntityBridge) itemEntity).bridge$getBukkitEntity()); + @Redirect(method = "dropSeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) + private boolean arclight$dropSeed(ServerLevel instance, Entity entity) { + var event = new EntityDropItemEvent(this.getBukkitEntity(), (Item) ((EntityBridge) entity).bridge$getBukkitEntity()); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { - ci.cancel(); + return false; } + return instance.addFreshEntity(entity); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/Turtle_LayEggGoalMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/Turtle_LayEggGoalMixin.java index 8b81f9bd..ce00e246 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/Turtle_LayEggGoalMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/Turtle_LayEggGoalMixin.java @@ -37,7 +37,7 @@ public abstract class Turtle_LayEggGoalMixin extends MoveToBlockGoal { if (((TurtleEntityBridge) this.turtle).bridge$getDigging() < 1) { ((TurtleEntityBridge) this.turtle).bridge$setDigging(true); } else if (((TurtleEntityBridge) this.turtle).bridge$getDigging() > 200) { - Level world = this.turtle.level; + Level world = this.turtle.level(); if (!CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (Blocks.TURTLE_EGG.defaultBlockState()).setValue(TurtleEggBlock.EGGS, this.turtle.getRandom().nextInt(4) + 1)).isCancelled()) { BlockPos blockpos1 = this.blockPos.above(); BlockState blockstate = Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.getRandom().nextInt(4) + 1); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/goat/GoatMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/goat/GoatMixin.java index 1a19fb71..9223ad3d 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/goat/GoatMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/goat/GoatMixin.java @@ -21,7 +21,7 @@ public abstract class GoatMixin extends AnimalMixin { @Eject(method = "mobInteract", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemUtils;createFilledResult(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/item/ItemStack;")) private ItemStack arclight$bucketFill(ItemStack handItem, Player player, ItemStack p_41816_, CallbackInfoReturnable cir, Player p_149379_, InteractionHand hand) { - var event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level, player, this.blockPosition(), this.blockPosition(), null, handItem, Items.MILK_BUCKET, hand); + var event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level(), player, this.blockPosition(), this.blockPosition(), null, handItem, Items.MILK_BUCKET, hand); if (event.isCancelled()) { cir.setReturnValue(InteractionResult.PASS); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/EnderCrystalMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/EnderCrystalMixin.java index 47086b82..03552847 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/EnderCrystalMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/EnderCrystalMixin.java @@ -22,7 +22,7 @@ public abstract class EnderCrystalMixin extends EntityMixin { @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z")) private void arclight$blockIgnite(CallbackInfo ci) { - if (CraftEventFactory.callBlockIgniteEvent(this.level, this.blockPosition(), (EndCrystal) (Object) this).isCancelled()) { + if (CraftEventFactory.callBlockIgniteEvent(this.level(), this.blockPosition(), (EndCrystal) (Object) this).isCancelled()) { ci.cancel(); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/EnderDragonMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/EnderDragonMixin.java index c616d3f7..3db1c07c 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/EnderDragonMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/EnderDragonMixin.java @@ -15,7 +15,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.dimension.end.EndDragonFight; -import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -23,7 +23,6 @@ import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.block.CraftBlock; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @@ -37,9 +36,9 @@ import java.util.List; @Mixin(EnderDragon.class) public abstract class EnderDragonMixin extends MobMixin { - @Shadow @Final @Nullable private EndDragonFight dragonFight; + @Shadow @Nullable private EndDragonFight dragonFight; - private final Explosion explosionSource = new Explosion(this.level, (EnderDragon) (Object) this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); + private final Explosion explosionSource = new Explosion(this.level(), (EnderDragon) (Object) this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); @Redirect(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/boss/enderdragon/phases/DragonPhaseInstance;getFlyTargetLocation()Lnet/minecraft/world/phys/Vec3;")) private Vec3 arclight$noMoveHovering(DragonPhaseInstance phase) { @@ -76,11 +75,11 @@ public abstract class EnderDragonMixin extends MobMixin { for (int l2 = j; l2 <= i2; ++l2) { for (int i3 = k; i3 <= j2; ++i3) { final BlockPos blockposition = new BlockPos(k2, l2, i3); - final BlockState iblockdata = this.level.getBlockState(blockposition); + final BlockState iblockdata = this.level().getBlockState(blockposition); if (!iblockdata.isAir() && !iblockdata.is(BlockTags.DRAGON_TRANSPARENT)) { - if (net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.level, blockposition, (EnderDragon) (Object) this) && !iblockdata.is(BlockTags.DRAGON_IMMUNE)) { + if (net.minecraftforge.common.ForgeHooks.canEntityDestroy(this.level(), blockposition, (EnderDragon) (Object) this) && !iblockdata.is(BlockTags.DRAGON_IMMUNE)) { flag2 = true; - destroyedBlocks.add(CraftBlock.at(this.level, blockposition)); + destroyedBlocks.add(CraftBlock.at(this.level(), blockposition)); } else { flag = true; } @@ -99,7 +98,7 @@ public abstract class EnderDragonMixin extends MobMixin { } if (event.getYield() == 0.0f) { for (final org.bukkit.block.Block block2 : event.blockList()) { - this.level.removeBlock(new BlockPos(block2.getX(), block2.getY(), block2.getZ()), false); + this.level().removeBlock(new BlockPos(block2.getX(), block2.getY(), block2.getZ()), false); } } else { for (final org.bukkit.block.Block block2 : event.blockList()) { @@ -111,21 +110,21 @@ public abstract class EnderDragonMixin extends MobMixin { final BlockPos blockposition2 = craftBlock.getPosition(); final net.minecraft.world.level.block.Block nmsBlock = craftBlock.getNMS().getBlock(); if (nmsBlock.dropFromExplosion(this.explosionSource)) { - BlockEntity tileentity = craftBlock.getNMS().hasBlockEntity() ? this.level.getBlockEntity(blockposition2) : null; - LootContext.Builder loottableinfo_builder = new LootContext.Builder((ServerLevel) this.level).withRandom(this.level.random).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockposition2)).withParameter(LootContextParams.TOOL, ItemStack.EMPTY).withParameter(LootContextParams.EXPLOSION_RADIUS, 1.0f / event.getYield()).withOptionalParameter(LootContextParams.BLOCK_ENTITY, tileentity); + BlockEntity tileentity = craftBlock.getNMS().hasBlockEntity() ? this.level().getBlockEntity(blockposition2) : null; + LootParams.Builder loottableinfo_builder = new LootParams.Builder((ServerLevel) this.level()).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockposition2)).withParameter(LootContextParams.TOOL, ItemStack.EMPTY).withParameter(LootContextParams.EXPLOSION_RADIUS, 1.0f / event.getYield()).withOptionalParameter(LootContextParams.BLOCK_ENTITY, tileentity); for (ItemStack stack : craftBlock.getNMS().getDrops(loottableinfo_builder)) { - Block.popResource(this.level, blockposition2, stack); + Block.popResource(this.level(), blockposition2, stack); } - craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level, blockposition2, ItemStack.EMPTY, false); + craftBlock.getNMS().spawnAfterBreak((ServerLevel) this.level(), blockposition2, ItemStack.EMPTY, false); // net.minecraft.block.Block.spawnDrops(craftBlock.getNMS(), loottableinfo_builder); } - nmsBlock.wasExploded(this.level, blockposition2, this.explosionSource); - this.level.removeBlock(blockposition2, false); + nmsBlock.wasExploded(this.level(), blockposition2, this.explosionSource); + this.level().removeBlock(blockposition2, false); } } if (flag2) { final BlockPos blockposition3 = new BlockPos(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i2 - j + 1), k + this.random.nextInt(j2 - k + 1)); - this.level.levelEvent(2008, blockposition3, 0); + this.level().levelEvent(2008, blockposition3, 0); } return flag; } @@ -134,7 +133,7 @@ public abstract class EnderDragonMixin extends MobMixin { @Override public int getExpReward() { // CraftBukkit - Moved from #tickDeath method - boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); + boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); short short0 = 500; if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/phases/EnderDragonPhaseManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/phases/EnderDragonPhaseManagerMixin.java index 78adb861..6d079847 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/phases/EnderDragonPhaseManagerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/enderdragon/phases/EnderDragonPhaseManagerMixin.java @@ -47,11 +47,11 @@ public abstract class EnderDragonPhaseManagerMixin { phaseIn = CraftEnderDragon.getMinecraftPhase(event.getNewPhase()); this.currentPhase = this.getPhase(phaseIn); - if (!this.dragon.level.isClientSide) { + if (!this.dragon.level().isClientSide) { this.dragon.getEntityData().set(EnderDragon.DATA_PHASE, phaseIn.getId()); } - LOGGER.debug("Dragon is now in phase {} on the {}", phaseIn, this.dragon.level.isClientSide ? "client" : "server"); + LOGGER.debug("Dragon is now in phase {} on the {}", phaseIn, this.dragon.level().isClientSide ? "client" : "server"); this.currentPhase.begin(); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/wither/WitherBossMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/wither/WitherBossMixin.java index a680a7d0..96b89d67 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/wither/WitherBossMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/boss/wither/WitherBossMixin.java @@ -54,10 +54,10 @@ public abstract class WitherBossMixin extends PathfinderMobMixin { ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.level.explode((WitherBoss) (Object) this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); + this.level().explode((WitherBoss) (Object) this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); } if (!this.isSilent()) { - this.level.globalLevelEvent(1023, this.blockPosition(), 0); + this.level().globalLevelEvent(1023, this.blockPosition(), 0); } } @@ -73,7 +73,7 @@ public abstract class WitherBossMixin extends PathfinderMobMixin { for (int i = 1; i < 3; ++i) { if (this.tickCount >= this.nextHeadUpdate[i - 1]) { this.nextHeadUpdate[i - 1] = this.tickCount + 10 + this.random.nextInt(10); - if (this.level.getDifficulty() == Difficulty.NORMAL || this.level.getDifficulty() == Difficulty.HARD) { + if (this.level().getDifficulty() == Difficulty.NORMAL || this.level().getDifficulty() == Difficulty.HARD) { int i3 = i - 1; int j3 = this.idleHeadUpdates[i - 1]; this.idleHeadUpdates[i3] = this.idleHeadUpdates[i - 1] + 1; @@ -88,7 +88,7 @@ public abstract class WitherBossMixin extends PathfinderMobMixin { int l1 = this.getAlternativeTarget(i); if (l1 > 0) { - LivingEntity livingentity = (LivingEntity) this.level.getEntity(l1); + LivingEntity livingentity = (LivingEntity) this.level().getEntity(l1); if (livingentity != null && this.canAttack(livingentity) && !(this.distanceToSqr(livingentity) > 900.0D) && this.hasLineOfSight(livingentity)) { this.performRangedAttack(i + 1, livingentity); this.nextHeadUpdate[i - 1] = this.tickCount + 40 + this.random.nextInt(20); @@ -99,7 +99,7 @@ public abstract class WitherBossMixin extends PathfinderMobMixin { this.setAlternativeTarget(i, 0); } } else { - List list = this.level.getNearbyEntities(LivingEntity.class, TARGETING_CONDITIONS, (WitherBoss) (Object) this, this.getBoundingBox().inflate(20.0D, 8.0D, 20.0D)); + List list = this.level().getNearbyEntities(LivingEntity.class, TARGETING_CONDITIONS, (WitherBoss) (Object) this, this.getBoundingBox().inflate(20.0D, 8.0D, 20.0D)); if (!list.isEmpty()) { LivingEntity livingentity1 = list.get(this.random.nextInt(list.size())); if (CraftEventFactory.callEntityTargetLivingEvent((WitherBoss) (Object) this, livingentity1, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled()) @@ -118,7 +118,7 @@ public abstract class WitherBossMixin extends PathfinderMobMixin { if (this.destroyBlocksTick > 0) { --this.destroyBlocksTick; - if (this.destroyBlocksTick == 0 && ForgeEventFactory.getMobGriefingEvent(this.level, (WitherBoss) (Object) this)) { + if (this.destroyBlocksTick == 0 && ForgeEventFactory.getMobGriefingEvent(this.level(), (WitherBoss) (Object) this)) { int j1 = Mth.floor(this.getY()); int i2 = Mth.floor(this.getX()); int j2 = Mth.floor(this.getZ()); @@ -131,19 +131,19 @@ public abstract class WitherBossMixin extends PathfinderMobMixin { int l = j1 + k; int i1 = j2 + k2; BlockPos blockpos = new BlockPos(l2, l, i1); - BlockState blockstate = this.level.getBlockState(blockpos); - if (blockstate.canEntityDestroy(this.level, blockpos, (WitherBoss) (Object) this) && ForgeEventFactory.onEntityDestroyBlock((WitherBoss) (Object) this, blockpos, blockstate)) { + BlockState blockstate = this.level().getBlockState(blockpos); + if (blockstate.canEntityDestroy(this.level(), blockpos, (WitherBoss) (Object) this) && ForgeEventFactory.onEntityDestroyBlock((WitherBoss) (Object) this, blockpos, blockstate)) { if (CraftEventFactory.callEntityChangeBlockEvent((WitherBoss) (Object) this, blockpos, Blocks.AIR.defaultBlockState()).isCancelled()) { continue; } - flag = this.level.destroyBlock(blockpos, true, (WitherBoss) (Object) this) || flag; + flag = this.level().destroyBlock(blockpos, true, (WitherBoss) (Object) this) || flag; } } } } if (flag) { - this.level.levelEvent(null, 1022, this.blockPosition(), 0); + this.level().levelEvent(null, 1022, this.blockPosition(), 0); } } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/ItemFrameMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/ItemFrameMixin.java index 8752829b..20d2abff 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/ItemFrameMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/ItemFrameMixin.java @@ -45,7 +45,7 @@ public abstract class ItemFrameMixin extends HangingEntityMixin { this.playSound(SoundEvents.ITEM_FRAME_ADD_ITEM, 1.0f, 1.0f); } if (flag && this.pos != null) { - this.level.updateNeighbourForOutputSignal(this.pos, Blocks.AIR); + this.level().updateNeighbourForOutputSignal(this.pos, Blocks.AIR); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/LeashFenceKnotEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/LeashFenceKnotEntityMixin.java index 4b0d14b7..1a8ad532 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/LeashFenceKnotEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/decoration/LeashFenceKnotEntityMixin.java @@ -26,12 +26,12 @@ public abstract class LeashFenceKnotEntityMixin extends HangingEntityMixin { @SuppressWarnings("ConstantConditions") @Overwrite public InteractionResult interact(final Player entityhuman, final InteractionHand enumhand) { - if (this.level.isClientSide) { + if (this.level().isClientSide) { return InteractionResult.SUCCESS; } boolean flag = false; final double d0 = 7.0; - final List list = this.level.getEntitiesOfClass(Mob.class, new AABB(this.getX() - 7.0, this.getY() - 7.0, this.getZ() - 7.0, this.getX() + 7.0, this.getY() + 7.0, this.getZ() + 7.0)); + final List list = this.level().getEntitiesOfClass(Mob.class, new AABB(this.getX() - 7.0, this.getY() - 7.0, this.getZ() - 7.0, this.getX() + 7.0, this.getY() + 7.0, this.getZ() + 7.0)); for (final Mob entityinsentient : list) { if (entityinsentient.getLeashHolder() == entityhuman) { if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, (LeashFenceKnotEntity) (Object) this, entityhuman, enumhand).isCancelled()) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/HangingEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/HangingEntityMixin.java index 3566cba0..e3a79f07 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/HangingEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/HangingEntityMixin.java @@ -9,7 +9,6 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.decoration.HangingEntity; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import org.bukkit.Bukkit; @@ -32,9 +31,9 @@ public abstract class HangingEntityMixin extends EntityMixin { @Inject(method = "tick", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/decoration/HangingEntity;discard()V")) private void arclight$hangingBreak(CallbackInfo ci) { - Material material = this.level.getBlockState(new BlockPos(this.blockPosition())).getMaterial(); + var state = this.level().getBlockState(new BlockPos(this.blockPosition())); HangingBreakEvent.RemoveCause cause; - if (!material.equals(Material.AIR)) { + if (!state.isAir()) { cause = HangingBreakEvent.RemoveCause.OBSTRUCTION; } else { cause = HangingBreakEvent.RemoveCause.PHYSICS; 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 ff7a2bc9..a9b26752 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 @@ -62,7 +62,7 @@ public abstract class ItemEntityMixin extends EntityMixin { */ @Overwrite public void playerTouch(final Player entity) { - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { if (this.pickupDelay > 0) return; ItemStack itemstack = this.getItem(); int i = itemstack.getCount(); @@ -134,7 +134,7 @@ public abstract class ItemEntityMixin extends EntityMixin { @Redirect(method = "mergeWithNeighbours", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;inflate(DDD)Lnet/minecraft/world/phys/AABB;")) private AABB arclight$mergeRadius(AABB instance, double pX, double pY, double pZ) { - double radius = ((WorldBridge) level).bridge$spigotConfig().itemMerge; + double radius = ((WorldBridge) level()).bridge$spigotConfig().itemMerge; return instance.inflate(radius); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/PrimedTntMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/PrimedTntMixin.java index cc9276b2..bdff60e3 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/PrimedTntMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/item/PrimedTntMixin.java @@ -60,14 +60,14 @@ public abstract class PrimedTntMixin extends EntityMixin { this.setFuse(i); if (i <= 0) { - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { this.explode(); } this.discard(); } else { this.updateInWaterStateAndDoFluidPushing(); - if (this.level.isClientSide) { - this.level.addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D); + if (this.level().isClientSide) { + this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D); } } @@ -82,7 +82,7 @@ public abstract class PrimedTntMixin extends EntityMixin { ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) this.getBukkitEntity()); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.level.explode((PrimedTnt) (Object) this, this.getX(), this.getY(0.0625), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT); + this.level().explode((PrimedTnt) (Object) this, this.getX(), this.getY(0.0625), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT); } } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/CreeperMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/CreeperMixin.java index 3fd47320..7ff0575b 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/CreeperMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/CreeperMixin.java @@ -50,13 +50,13 @@ public abstract class CreeperMixin extends PathfinderMobMixin implements Creeper */ @Overwrite public void explodeCreeper() { - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { final float f = this.isPowered() ? 2.0f : 1.0f; final ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { this.dead = true; - this.level.explode((Creeper) (Object) this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); + this.level().explode((Creeper) (Object) this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); this.discard(); this.spawnLingeringCloud(); } else { @@ -68,7 +68,7 @@ public abstract class CreeperMixin extends PathfinderMobMixin implements Creeper @Inject(method = "spawnLingeringCloud", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) private void arclight$creeperCloud(CallbackInfo ci, Collection collection, AreaEffectCloud areaeffectcloudentity) { areaeffectcloudentity.setOwner((Creeper) (Object) this); - ((WorldBridge) this.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EXPLOSION); + ((WorldBridge) this.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EXPLOSION); } public void setPowered(boolean power) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ShulkerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ShulkerMixin.java index 27997d5c..04240bc9 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ShulkerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ShulkerMixin.java @@ -46,7 +46,7 @@ public abstract class ShulkerMixin extends PathfinderMobMixin { for (int i = 0; i < 5; ++i) { BlockPos blockpos1 = blockpos.offset(Mth.randomBetweenInclusive(this.random, -8, 8), Mth.randomBetweenInclusive(this.random, -8, 8), Mth.randomBetweenInclusive(this.random, -8, 8)); - if (blockpos1.getY() > this.level.getMinBuildHeight() && this.level.isEmptyBlock(blockpos1) && this.level.getWorldBorder().isWithinBounds(blockpos1) && this.level.noCollision((Shulker) (Object) this, (new AABB(blockpos1)).deflate(1.0E-6D))) { + if (blockpos1.getY() > this.level().getMinBuildHeight() && this.level().isEmptyBlock(blockpos1) && this.level().getWorldBorder().isWithinBounds(blockpos1) && this.level().noCollision((Shulker) (Object) this, (new AABB(blockpos1)).deflate(1.0E-6D))) { Direction direction = this.findAttachableSurface(blockpos1); if (direction != null) { var event = ForgeEventFactory.onEnderTeleport((Shulker) (Object) this, blockpos1.getX(), blockpos1.getY(), blockpos1.getZ()); @@ -54,7 +54,7 @@ public abstract class ShulkerMixin extends PathfinderMobMixin { blockpos1 = BlockPos.containing(event.getTargetX(), event.getTargetY(), event.getTargetZ()); } if (direction != null) { - EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(((WorldBridge) this.level).bridge$getWorld(), blockpos1.getX(), blockpos1.getY(), blockpos1.getZ())); + EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(((WorldBridge) this.level()).bridge$getWorld(), blockpos1.getX(), blockpos1.getY(), blockpos1.getZ())); Bukkit.getPluginManager().callEvent(teleport); if (!teleport.isCancelled()) { Location to = teleport.getTo(); @@ -66,7 +66,7 @@ public abstract class ShulkerMixin extends PathfinderMobMixin { this.setAttachFace(direction); this.playSound(SoundEvents.SHULKER_TELEPORT, 1.0F, 1.0F); this.setPos((double) blockpos1.getX() + 0.5D, blockpos1.getY(), (double) blockpos1.getZ() + 0.5D); - this.level.gameEvent(GameEvent.TELEPORT, blockpos, GameEvent.Context.of((Entity) (Object) this)); + this.level().gameEvent(GameEvent.TELEPORT, blockpos, GameEvent.Context.of((Entity) (Object) this)); this.entityData.set(DATA_PEEK_ID, (byte) 0); this.setTarget(null); return true; @@ -82,6 +82,6 @@ public abstract class ShulkerMixin extends PathfinderMobMixin { @Inject(method = "hitByShulkerBullet", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) private void arclight$breedCause(CallbackInfo ci) { - ((WorldBridge) this.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.BREEDING); + ((WorldBridge) this.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.BREEDING); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/Silverfish_WakeUpFriendsGoalMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/Silverfish_WakeUpFriendsGoalMixin.java index f3e024cb..9f22fc91 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/Silverfish_WakeUpFriendsGoalMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/Silverfish_WakeUpFriendsGoalMixin.java @@ -31,7 +31,7 @@ public abstract class Silverfish_WakeUpFriendsGoalMixin extends Goal { public void tick() { --this.lookForFriends; if (this.lookForFriends <= 0) { - Level world = this.silverfish.level; + Level world = this.silverfish.level(); RandomSource random = this.silverfish.getRandom(); BlockPos blockpos = this.silverfish.blockPosition(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/SlimeMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/SlimeMixin.java index 4fab83d3..564fb147 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/SlimeMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/SlimeMixin.java @@ -35,7 +35,7 @@ public abstract class SlimeMixin extends MobMixin { @Override public void remove(Entity.RemovalReason p_149847_) { int i = this.getSize(); - if (!this.level.isClientSide && i > 1 && this.isDeadOrDying()) { + if (!this.level().isClientSide && i > 1 && this.isDeadOrDying()) { Component itextcomponent = this.getCustomName(); boolean flag = this.isNoAi(); float f = (float) i / 4.0F; @@ -54,7 +54,7 @@ public abstract class SlimeMixin extends MobMixin { for (int l = 0; l < k; ++l) { float f1 = ((float) (l % 2) - 0.5F) * f; float f2 = ((float) (l / 2) - 0.5F) * f; - net.minecraft.world.entity.monster.Slime slimeentity = this.getType().create(this.level); + net.minecraft.world.entity.monster.Slime slimeentity = this.getType().create(this.level()); if (slimeentity == null) continue; if (this.isPersistenceRequired()) { slimeentity.setPersistenceRequired(); @@ -72,8 +72,8 @@ public abstract class SlimeMixin extends MobMixin { return; } for (LivingEntity living : slimes) { - ((WorldBridge) this.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); - this.level.addFreshEntity(living); + ((WorldBridge) this.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); + this.level().addFreshEntity(living); } } super.remove(p_149847_); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombieMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombieMixin.java index 4a579606..84c64e12 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombieMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombieMixin.java @@ -41,7 +41,7 @@ public abstract class ZombieMixin extends PathfinderMobMixin { @Inject(method = "convertToZombieType", at = @At("HEAD")) private void arclight$transformReason(EntityType entityType, CallbackInfo ci) { this.bridge$pushTransformReason(EntityTransformEvent.TransformReason.DROWNED); - ((WorldBridge) this.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.DROWNED); + ((WorldBridge) this.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.DROWNED); } @Inject(method = "convertToZombieType", locals = LocalCapture.CAPTURE_FAILHARD, at = @At("RETURN")) @@ -68,9 +68,9 @@ public abstract class ZombieMixin extends PathfinderMobMixin { } } - @Eject(method = "wasKilled", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/npc/Villager;convertTo(Lnet/minecraft/world/entity/EntityType;Z)Lnet/minecraft/world/entity/Mob;")) + @Eject(method = "killedEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/npc/Villager;convertTo(Lnet/minecraft/world/entity/EntityType;Z)Lnet/minecraft/world/entity/Mob;")) private T arclight$transform(Villager villagerEntity, EntityType entityType, boolean flag, CallbackInfoReturnable cir) { - ((WorldBridge) villagerEntity.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.INFECTION); + ((WorldBridge) villagerEntity.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.INFECTION); ((MobEntityBridge) villagerEntity).bridge$pushTransformReason(EntityTransformEvent.TransformReason.INFECTION); T t = villagerEntity.convertTo(entityType, flag); if (t == null) { @@ -85,7 +85,7 @@ public abstract class ZombieMixin extends PathfinderMobMixin { } private static ZombieVillager zombifyVillager(ServerLevel level, Villager villager, BlockPos blockPosition, boolean silent, CreatureSpawnEvent.SpawnReason spawnReason) { - ((WorldBridge) villager.level).bridge$pushAddEntityReason(spawnReason); + ((WorldBridge) villager.level()).bridge$pushAddEntityReason(spawnReason); ((MobEntityBridge) villager).bridge$pushTransformReason(EntityTransformEvent.TransformReason.INFECTION); ZombieVillager zombieVillager = villager.convertTo(EntityType.ZOMBIE_VILLAGER, false); if (zombieVillager != null) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombifiedPiglinMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombifiedPiglinMixin.java index a2732f7f..ac11547b 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombifiedPiglinMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/ZombifiedPiglinMixin.java @@ -35,7 +35,7 @@ public abstract class ZombifiedPiglinMixin extends ZombieMixin { private void alertOthers() { double d0 = this.getAttributeValue(Attributes.FOLLOW_RANGE); AABB axisalignedbb = AABB.unitCubeFromLowerCorner(this.position()).inflate(d0, 10.0D, d0); - for (ZombifiedPiglin piglinEntity : this.level.getEntitiesOfClass(ZombifiedPiglin.class, axisalignedbb)) { + for (ZombifiedPiglin piglinEntity : this.level().getEntitiesOfClass(ZombifiedPiglin.class, axisalignedbb)) { if (piglinEntity != (Object) this) { if (piglinEntity.getTarget() == null) { if (!piglinEntity.isAlliedTo(this.getTarget())) { @@ -49,7 +49,7 @@ public abstract class ZombifiedPiglinMixin extends ZombieMixin { @ModifyArg(method = "startPersistentAngerTimer", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/monster/ZombifiedPiglin;setRemainingPersistentAngerTime(I)V")) private int arclight$pigAngry(int time) { - Entity entity = ((ServerLevel) this.level).getEntity(this.getPersistentAngerTarget()); + Entity entity = ((ServerLevel) this.level()).getEntity(this.getPersistentAngerTarget()); PigZombieAngerEvent event = new PigZombieAngerEvent((PigZombie) this.getBukkitEntity(), entity == null ? null : ((EntityBridge) entity).bridge$getBukkitEntity(), time); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { 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 039d61c2..b120581e 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 @@ -202,16 +202,16 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt return false; } else { if (source.scalesWithDifficulty()) { - if (this.level.getDifficulty() == Difficulty.PEACEFUL) { + if (this.level().getDifficulty() == Difficulty.PEACEFUL) { // amount = 0.0F; return false; } - if (this.level.getDifficulty() == Difficulty.EASY) { + if (this.level().getDifficulty() == Difficulty.EASY) { amount = Math.min(amount / 2.0F + 1.0F, amount); } - if (this.level.getDifficulty() == Difficulty.HARD) { + if (this.level().getDifficulty() == Difficulty.HARD) { amount = amount * 3.0F / 2.0F; } } @@ -284,7 +284,7 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt float i = (float) this.getAttributeValue(Attributes.ATTACK_KNOCKBACK); // Forge: Initialize this value to the attack knockback attribute of the player, which is by default 0 i += EnchantmentHelper.getKnockbackBonus((net.minecraft.world.entity.player.Player) (Object) this); if (this.isSprinting() && flag) { - this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0f, 1.0f); + this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0f, 1.0f); ++i; flag2 = true; } @@ -330,14 +330,14 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt } if (flag4) { final float f5 = 1.0f + EnchantmentHelper.getSweepingDamageRatio((net.minecraft.world.entity.player.Player) (Object) this) * f; - final List list = this.level.getEntitiesOfClass(LivingEntity.class, this.getItemInHand(InteractionHand.MAIN_HAND).getSweepHitBox((net.minecraft.world.entity.player.Player) (Object) this, entity)); + final List list = this.level().getEntitiesOfClass(LivingEntity.class, this.getItemInHand(InteractionHand.MAIN_HAND).getSweepHitBox((net.minecraft.world.entity.player.Player) (Object) this, entity)); double entityReachSq = Mth.square(this.getEntityReach()); // Use entity reach instead of constant 9.0. Vanilla uses bottom center-to-center checks here, so don't update this to use canReach, since it uses closest-corner checks. for (final LivingEntity entityliving : list) { if (entityliving != (Object) this && entityliving != entity && !this.isAlliedTo(entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr(entityliving) < entityReachSq && entityliving.hurt(((DamageSourceBridge) this.damageSources().playerAttack((net.minecraft.world.entity.player.Player) (Object) this)).bridge$sweep(), f5)) { entityliving.knockback(0.4f, Mth.sin(this.getYRot() * 0.017453292f), -Mth.cos(this.getYRot() * 0.017453292f)); } } - this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0f, 1.0f); + this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0f, 1.0f); this.sweepAttack(); } if (entity instanceof ServerPlayer && entity.hurtMarked) { @@ -358,14 +358,14 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt } } if (flag3) { - this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0f, 1.0f); + this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0f, 1.0f); this.crit(entity); } if (!flag3 && !flag4) { if (flag) { - this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0f, 1.0f); + this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0f, 1.0f); } else { - this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0f, 1.0f); + this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0f, 1.0f); } } if (f2 > 0.0f) { @@ -381,7 +381,7 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt if (entity instanceof PartEntity) { object = ((PartEntity) entity).getParent(); } - if (!this.level.isClientSide && !itemstack2.isEmpty() && object instanceof LivingEntity) { + if (!this.level().isClientSide && !itemstack2.isEmpty() && object instanceof LivingEntity) { ItemStack copy = itemstack2.copy(); itemstack2.hurtEnemy((LivingEntity) object, (net.minecraft.world.entity.player.Player) (Object) this); if (itemstack2.isEmpty()) { @@ -399,15 +399,15 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt ((EntityBridge) entity).bridge$setOnFire(combustEvent2.getDuration(), false); } } - if (this.level instanceof ServerLevel && f6 > 2.0f) { + if (this.level() instanceof ServerLevel && f6 > 2.0f) { final int k = (int) (f6 * 0.5); - ((ServerLevel) this.level).sendParticles(ParticleTypes.DAMAGE_INDICATOR, entity.getX(), entity.getY() + entity.getBbHeight() * 0.5f, entity.getZ(), k, 0.1, 0.0, 0.1, 0.2); + ((ServerLevel) this.level()).sendParticles(ParticleTypes.DAMAGE_INDICATOR, entity.getX(), entity.getY() + entity.getBbHeight() * 0.5f, entity.getZ(), k, 0.1, 0.0, 0.1, 0.2); } } bridge$pushExhaustReason(EntityExhaustionEvent.ExhaustionReason.ATTACK); - this.causeFoodExhaustion(((WorldBridge) level).bridge$spigotConfig().combatExhaustion); + this.causeFoodExhaustion(((WorldBridge) level()).bridge$spigotConfig().combatExhaustion); } else { - this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0f, 1.0f); + this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0f, 1.0f); if (flag5) { entity.clearFire(); } @@ -441,9 +441,9 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt if (this.bridge$getBukkitEntity() instanceof Player player) { Block bed; if (blockPos != null) { - bed = CraftBlock.at(this.level, blockPos); + bed = CraftBlock.at(this.level(), blockPos); } else { - bed = ((WorldBridge) this.level).bridge$getWorld().getBlockAt(player.getLocation()); + bed = ((WorldBridge) this.level()).bridge$getWorld().getBlockAt(player.getLocation()); } PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true); Bukkit.getPluginManager().callEvent(event); @@ -452,7 +452,7 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt @ModifyArg(method = "jumpFromGround", index = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;causeFoodExhaustion(F)V")) private float arclight$exhaustInfo(float f) { - SpigotWorldConfig config = ((WorldBridge) level).bridge$spigotConfig(); + SpigotWorldConfig config = ((WorldBridge) level()).bridge$spigotConfig(); if (config != null) { if (this.isSprinting()) { f = config.jumpSprintExhaustion; @@ -524,23 +524,23 @@ public abstract class PlayerMixin extends LivingEntityMixin implements PlayerEnt */ @Overwrite protected void removeEntitiesOnShoulder() { - if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) { - if (this.spawnEntityFromShoulder(this.getShoulderEntityLeft())) { + if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { + if (this.respawnEntityOnShoulder(this.getShoulderEntityLeft())) { this.setShoulderEntityLeft(new CompoundTag()); } - if (this.spawnEntityFromShoulder(this.getShoulderEntityRight())) { + if (this.respawnEntityOnShoulder(this.getShoulderEntityRight())) { this.setShoulderEntityRight(new CompoundTag()); } } } - private boolean spawnEntityFromShoulder(final CompoundTag nbttagcompound) { - return this.level.isClientSide || nbttagcompound.isEmpty() || EntityType.create(nbttagcompound, this.level).map(entity -> { + private boolean respawnEntityOnShoulder(final CompoundTag nbttagcompound) { + return this.level().isClientSide || nbttagcompound.isEmpty() || EntityType.create(nbttagcompound, this.level()).map(entity -> { if (entity instanceof TamableAnimal) { ((TamableAnimal) entity).setOwnerUUID(this.uuid); } entity.setPos(this.getX(), this.getY() + 0.699999988079071, this.getZ()); - return ((ServerWorldBridge) this.level).bridge$addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); + return ((ServerWorldBridge) this.level()).bridge$addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); }).orElse(true); } 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 eb86b775..021544bc 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 @@ -137,7 +137,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla @Shadow public abstract void closeContainer(); @Shadow public abstract void setCamera(Entity entityToSpectate); @Shadow public boolean isChangingDimension; - @Shadow public abstract ServerLevel getLevel(); + @Shadow public abstract ServerLevel serverLevel(); @Shadow public boolean wonGame; @Shadow private boolean seenCredits; @Shadow @Nullable private Vec3 enteredNetherPosition; @@ -157,7 +157,6 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla @Shadow public abstract boolean isCreative(); @Shadow protected abstract boolean bedBlocked(BlockPos p_241156_1_, Direction p_241156_2_); @Shadow protected abstract boolean bedInRange(BlockPos p_241147_1_, Direction p_241147_2_); - @Shadow public abstract void setLevel(ServerLevel p_143426_); @Shadow(remap = false) private boolean hasTabListName; @Shadow(remap = false) private Component tabListDisplayName; @Shadow public abstract void resetFallDistance(); @@ -168,6 +167,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla @Shadow public abstract void sendSystemMessage(Component p_215097_); @Shadow private float respawnAngle; @Shadow private boolean respawnForced; + @Shadow public abstract void setServerLevel(ServerLevel p_284971_); // @formatter:on public String displayName; @@ -267,7 +267,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla } public void spawnIn(Level world) { - this.level = world; + this.setLevel(world); if (world == null) { this.revive(); Vec3 position = null; @@ -278,7 +278,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); position = Vec3.atCenterOf(((ServerLevel) world).getSharedSpawnPos()); } - this.level = world; + this.setLevel(world); this.setPos(position.x(), position.y(), position.z()); } this.gameMode.setLevel((ServerLevel) world); @@ -322,11 +322,11 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla this.gameEvent(GameEvent.ENTITY_DIE); if (net.minecraftforge.common.ForgeHooks.onLivingDeath((ServerPlayer) (Object) this, damagesource)) return; - boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); if (this.isRemoved()) { return; } - boolean keepInventory = this.level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); + boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); Inventory copyInv; if (keepInventory) { copyInv = this.getInventory(); @@ -362,13 +362,13 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla } else { itextcomponent = CraftChatMessage.fromStringOrNull(deathMessage); } - this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), itextcomponent), PacketSendListener.exceptionallySend(() -> { + this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), itextcomponent), PacketSendListener.exceptionallySend(() -> { String s = itextcomponent.getString(256); Component component1 = Component.translatable("death.attack.message_too_long", Component.literal(s).withStyle(ChatFormatting.YELLOW)); Component component2 = Component.translatable("death.attack.even_more_magic", this.getDisplayName()).withStyle((p_143420_) -> { return p_143420_.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, component1)); }); - return new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), component2); + return new ClientboundPlayerCombatKillPacket(this.getId(), component2); })); Team scoreboardteambase = this.getTeam(); if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != Team.Visibility.ALWAYS) { @@ -381,11 +381,11 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla this.server.getPlayerList().broadcastSystemMessage(itextcomponent, false); } } else { - this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), CommonComponents.EMPTY)); + this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), CommonComponents.EMPTY)); } this.removeEntitiesOnShoulder(); - if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { + if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } @@ -404,7 +404,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla this.createWitherRose(entityliving); } - this.level.broadcastEntityEvent((ServerPlayer) (Object) this, (byte) 3); + this.level().broadcastEntityEvent((ServerPlayer) (Object) this, (byte) 3); this.awardStat(Stats.DEATHS); this.resetStat(Stats.CUSTOM.get(Stats.TIME_SINCE_DEATH)); this.resetStat(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)); @@ -412,7 +412,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla this.setTicksFrozen(0); this.setSharedFlagOnFire(false); this.getCombatTracker().recheckStatus(); - this.setLastDeathLocation(Optional.of(GlobalPos.of(this.level.dimension(), this.blockPosition()))); + this.setLastDeathLocation(Optional.of(GlobalPos.of(this.level().dimension(), this.blockPosition()))); } @Redirect(method = "awardKillScore", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/scores/Scoreboard;forAllObjectives(Lnet/minecraft/world/scores/criteria/ObjectiveCriteria;Ljava/lang/String;Ljava/util/function/Consumer;)V")) @@ -427,7 +427,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla @Inject(method = "isPvpAllowed", cancellable = true, at = @At("HEAD")) private void arclight$pvpMode(CallbackInfoReturnable cir) { - cir.setReturnValue(((WorldBridge) this.level).bridge$isPvpMode()); + cir.setReturnValue(((WorldBridge) this.level()).bridge$isPvpMode()); } /** @@ -439,7 +439,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla protected PortalInfo findDimensionEntryPoint(ServerLevel level) { PortalInfo portalinfo = super.findDimensionEntryPoint(level); level = portalinfo == null || ((PortalInfoBridge) portalinfo).bridge$getWorld() == null ? level : ((PortalInfoBridge) portalinfo).bridge$getWorld(); - if (portalinfo != null && ((WorldBridge) this.level).bridge$getTypeKey() == LevelStem.OVERWORLD && ((WorldBridge) level).bridge$getTypeKey() == LevelStem.END) { + if (portalinfo != null && ((WorldBridge) this.level()).bridge$getTypeKey() == LevelStem.OVERWORLD && ((WorldBridge) level).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(level); @@ -486,12 +486,12 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla arclight$cause = null; // this.invulnerableDimensionChange = true; - ServerLevel serverworld = this.getLevel(); + ServerLevel serverworld = this.serverLevel(); 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().removePlayerImmediately((ServerPlayer) (Object) this, Entity.RemovalReason.CHANGED_DIMENSION); + this.serverLevel().removePlayerImmediately((ServerPlayer) (Object) this, Entity.RemovalReason.CHANGED_DIMENSION); if (!this.wonGame) { this.wonGame = true; this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.WIN_GAME, this.seenCredits ? 0.0F : 1.0F)); @@ -507,11 +507,11 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla } ServerLevel[] exitWorld = new ServerLevel[]{server}; LevelData iworldinfo = server.getLevelData(); - this.connection.send(new ClientboundRespawnPacket(server.dimensionTypeId(), server.dimension(), BiomeManager.obfuscateSeed(server.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), server.isDebug(), server.isFlat(), (byte) 3, this.getLastDeathLocation())); + this.connection.send(new ClientboundRespawnPacket(server.dimensionTypeId(), server.dimension(), BiomeManager.obfuscateSeed(server.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), server.isDebug(), server.isFlat(), (byte) 3, this.getLastDeathLocation(), this.getPortalCooldown())); this.connection.send(new ClientboundChangeDifficultyPacket(iworldinfo.getDifficulty(), iworldinfo.isDifficultyLocked())); PlayerList playerlist = this.server.getPlayerList(); playerlist.sendPlayerPermissionLevel((ServerPlayer) (Object) this); - this.getLevel().removePlayerImmediately((ServerPlayer) (Object) this, Entity.RemovalReason.CHANGED_DIMENSION); + this.serverLevel().removePlayerImmediately((ServerPlayer) (Object) this, Entity.RemovalReason.CHANGED_DIMENSION); this.revive(); Entity e = teleporter.placeEntity((ServerPlayer) (Object) this, serverworld, exitWorld[0], this.getYRot(), spawnPortal -> {//Forge: Start vanilla logic serverworld.getProfiler().push("moving"); @@ -541,11 +541,11 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla if (newWorld != exitWorld[0]) { exitWorld[0] = newWorld; LevelData newWorldInfo = exitWorld[0].getLevelData(); - this.connection.send(new ClientboundRespawnPacket(exitWorld[0].dimensionTypeId(), exitWorld[0].dimension(), BiomeManager.obfuscateSeed(exitWorld[0].getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), exitWorld[0].isDebug(), exitWorld[0].isFlat(), (byte) 3, this.getLastDeathLocation())); + this.connection.send(new ClientboundRespawnPacket(exitWorld[0].dimensionTypeId(), exitWorld[0].dimension(), BiomeManager.obfuscateSeed(exitWorld[0].getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), exitWorld[0].isDebug(), exitWorld[0].isFlat(), (byte) 3, this.getLastDeathLocation(), this.getPortalCooldown())); this.connection.send(new ClientboundChangeDifficultyPacket(newWorldInfo.getDifficulty(), newWorldInfo.isDifficultyLocked())); } - this.setLevel(exitWorld[0]); + this.setServerLevel(exitWorld[0]); exitWorld[0].addDuringPortalTeleport((ServerPlayer) (Object) this); ((ServerPlayNetHandlerBridge) this.connection).bridge$teleport(exit); @@ -604,7 +604,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla if (optional.isPresent() || !canCreatePortal) { return optional; } - Direction.Axis enumdirection_enumaxis = this.level.getBlockState(this.portalEntrancePos).getOptionalValue(NetherPortalBlock.AXIS).orElse(Direction.Axis.X); + Direction.Axis enumdirection_enumaxis = this.level().getBlockState(this.portalEntrancePos).getOptionalValue(NetherPortalBlock.AXIS).orElse(Direction.Axis.X); Optional optional1 = ((TeleporterBridge) worldserver.getPortalForcer()).bridge$createPortal(blockposition, enumdirection_enumaxis, (ServerPlayer) (Object) this, createRadius); if (!optional1.isPresent()) { // LOGGER.error("Unable to create a portal, likely target out of worldborder"); @@ -637,7 +637,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla private Either getBedResult(BlockPos blockposition, Direction enumdirection) { if (!this.isSleeping() && this.isAlive()) { - if (!this.level.dimensionType().natural() || !this.level.dimensionType().bedWorks()) { + if (!this.level().dimensionType().natural() || !this.level().dimensionType().bedWorks()) { return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_HERE); } if (!this.bedInRange(blockposition, enumdirection)) { @@ -646,15 +646,15 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla if (this.bedBlocked(blockposition, enumdirection)) { return Either.left(Player.BedSleepingProblem.OBSTRUCTED); } - this.setRespawnPosition(this.level.dimension(), blockposition, this.getYRot(), false, true, PlayerSpawnChangeEvent.Cause.BED); - if (this.level.isDay()) { + this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true, PlayerSpawnChangeEvent.Cause.BED); + if (this.level().isDay()) { return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); } if (!this.isCreative()) { double d0 = 8.0; double d1 = 5.0; Vec3 vec3d = Vec3.atBottomCenterOf(blockposition); - List list = this.level.getEntitiesOfClass(Monster.class, new AABB(vec3d.x() - 8.0, vec3d.y() - 5.0, vec3d.z() - 8.0, vec3d.x() + 8.0, vec3d.y() + 5.0, vec3d.z() + 8.0), entitymonster -> entitymonster.isPreventingPlayerRest((ServerPlayer) (Object) this)); + List list = this.level().getEntitiesOfClass(Monster.class, new AABB(vec3d.x() - 8.0, vec3d.y() - 5.0, vec3d.z() - 8.0, vec3d.x() + 8.0, vec3d.y() + 5.0, vec3d.z() + 8.0), entitymonster -> entitymonster.isPreventingPlayerRest((ServerPlayer) (Object) this)); if (!list.isEmpty()) { return Either.left(Player.BedSleepingProblem.NOT_SAFE); } @@ -704,7 +704,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla org.bukkit.block.Block bed; if (bedPosition != null) { - bed = CraftBlock.at(this.level, bedPosition); + bed = CraftBlock.at(this.level(), bedPosition); } else { bed = player.getLocation().getBlock(); } @@ -878,9 +878,9 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla public long getPlayerTime() { if (this.relativeTime) { - return this.level.getDayTime() + this.timeOffset; + return this.level().getDayTime() + this.timeOffset; } - return this.level.getDayTime() - this.level.getDayTime() % 24000L + this.timeOffset; + return this.level().getDayTime() - this.level().getDayTime() % 24000L + this.timeOffset; } public WeatherType getPlayerWeather() { @@ -933,7 +933,7 @@ public abstract class ServerPlayerMixin extends PlayerMixin implements ServerPla public void resetPlayerWeather() { this.weather = null; - this.setPlayerWeather(this.level.getLevelData().isRaining() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); + this.setPlayerWeather(this.level().getLevelData().isRaining() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false); } @Override diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/AbstractArrowMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/AbstractArrowMixin.java index 6ee610b6..970953b7 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/AbstractArrowMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/AbstractArrowMixin.java @@ -56,10 +56,10 @@ public abstract class AbstractArrowMixin extends ProjectileMixin { */ @Overwrite public void playerTouch(Player playerEntity) { - if (!this.level.isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) { + if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) { ItemStack itemstack = this.getPickupItem(); if (this.pickup == net.minecraft.world.entity.projectile.AbstractArrow.Pickup.ALLOWED && !itemstack.isEmpty() && ((PlayerInventoryBridge) playerEntity.getInventory()).bridge$canHold(itemstack) > 0) { - ItemEntity item = new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), itemstack); + ItemEntity item = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack); PlayerPickupArrowEvent event = new PlayerPickupArrowEvent(((ServerPlayerEntityBridge) playerEntity).bridge$getBukkitEntity(), new CraftItem(((CraftServer) Bukkit.getServer()), (net.minecraft.world.entity.projectile.AbstractArrow) (Object) this, item), (AbstractArrow) this.getBukkitEntity()); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/FishingHookMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/FishingHookMixin.java index 627c83d8..efb01c11 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/FishingHookMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/FishingHookMixin.java @@ -18,7 +18,7 @@ import net.minecraft.world.entity.projectile.FishingHook; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.storage.loot.BuiltInLootTables; -import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; @@ -119,7 +119,7 @@ public abstract class FishingHookMixin extends ProjectileMixin { @Overwrite public int retrieve(ItemStack stack) { Player playerentity = this.getPlayerOwner(); - if (!this.level.isClientSide && playerentity != null) { + if (!this.level().isClientSide && playerentity != null) { int i = 0; ItemFishedEvent event = null; if (this.hookedIn != null) { @@ -130,12 +130,12 @@ public abstract class FishingHookMixin extends ProjectileMixin { } this.pullEntity(this.hookedIn); CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer) playerentity, stack, (FishingHook) (Object) this, Collections.emptyList()); - this.level.broadcastEntityEvent((FishingHook) (Object) this, (byte) 31); + this.level().broadcastEntityEvent((FishingHook) (Object) this, (byte) 31); i = this.hookedIn instanceof ItemEntity ? 3 : 5; } else if (this.nibble > 0) { - LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel) this.level)).withParameter(LootContextParams.ORIGIN, this.position()).withParameter(LootContextParams.TOOL, stack).withParameter(LootContextParams.THIS_ENTITY, (FishingHook) (Object) this).withRandom(this.random).withLuck((float) this.luck + playerentity.getLuck()); - LootTable loottable = this.level.getServer().getLootTables().get(BuiltInLootTables.FISHING); - List list = loottable.getRandomItems(lootcontext$builder.create(LootContextParamSets.FISHING)); + LootParams params = (new LootParams.Builder((ServerLevel) this.level())).withParameter(LootContextParams.ORIGIN, this.position()).withParameter(LootContextParams.TOOL, stack).withParameter(LootContextParams.THIS_ENTITY, (FishingHook) (Object) this).withLuck((float) this.luck + playerentity.getLuck()).create(LootContextParamSets.FISHING); + LootTable loottable = this.level().getServer().getLootData().getLootTable(BuiltInLootTables.FISHING); + List list = loottable.getRandomItems(params); event = new ItemFishedEvent(list, this.onGround ? 2 : 1, (FishingHook) (Object) this); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { @@ -145,7 +145,7 @@ public abstract class FishingHookMixin extends ProjectileMixin { CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer) playerentity, stack, (FishingHook) (Object) this, list); for (ItemStack itemstack : list) { - ItemEntity itementity = new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), itemstack); + ItemEntity itementity = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack); PlayerFishEvent playerFishEvent = new PlayerFishEvent(((ServerPlayerEntityBridge) playerentity).bridge$getBukkitEntity(), ((EntityBridge) itementity).bridge$getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1); Bukkit.getPluginManager().callEvent(playerFishEvent); @@ -158,9 +158,9 @@ public abstract class FishingHookMixin extends ProjectileMixin { double d2 = playerentity.getZ() - this.getZ(); double d3 = 0.1D; itementity.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); - this.level.addFreshEntity(itementity); + this.level().addFreshEntity(itementity); if (playerFishEvent.getExpToDrop() > 0) { - playerentity.level.addFreshEntity(new ExperienceOrb(playerentity.level, playerentity.getX(), playerentity.getY() + 0.5D, playerentity.getZ() + 0.5D, playerFishEvent.getExpToDrop())); + playerentity.level().addFreshEntity(new ExperienceOrb(playerentity.level(), playerentity.getX(), playerentity.getY() + 0.5D, playerentity.getZ() + 0.5D, playerFishEvent.getExpToDrop())); } if (itemstack.is(ItemTags.FISHES)) { playerentity.awardStat(Stats.FISH_CAUGHT, 1); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/LargeFireballMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/LargeFireballMixin.java index 3194e96a..92025201 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/LargeFireballMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/LargeFireballMixin.java @@ -37,7 +37,7 @@ public abstract class LargeFireballMixin extends AbstractHurtingProjectileMixin Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { - return this.level.explode((LargeFireball) (Object) this, xIn, yIn, zIn, event.getRadius(), event.getFire(), interaction); + return this.level().explode((LargeFireball) (Object) this, xIn, yIn, zIn, event.getRadius(), event.getFire(), interaction); } else { return null; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/SmallFireballMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/SmallFireballMixin.java index 0bccf207..54987110 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/SmallFireballMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/SmallFireballMixin.java @@ -25,7 +25,7 @@ public abstract class SmallFireballMixin extends FireballMixin { @Inject(method = "(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;DDD)V", at = @At("RETURN")) private void arclight$init(Level worldIn, LivingEntity shooter, double accelX, double accelY, double accelZ, CallbackInfo ci) { if (this.getOwner() != null && this.getOwner() instanceof Mob) { - this.isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); + this.isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); } } @@ -44,7 +44,7 @@ public abstract class SmallFireballMixin extends FireballMixin { @Inject(method = "onHitBlock", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z")) private void arclight$burnBlock(BlockHitResult result, CallbackInfo ci, Entity entity, BlockPos pos) { - if (!this.isIncendiary || CraftEventFactory.callBlockIgniteEvent(this.level, pos, (SmallFireball) (Object) this).isCancelled()) { + if (!this.isIncendiary || CraftEventFactory.callBlockIgniteEvent(this.level(), pos, (SmallFireball) (Object) this).isCancelled()) { ci.cancel(); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrowableItemProjectileMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrowableItemProjectileMixin.java index ee4aa535..ee72a9e4 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrowableItemProjectileMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrowableItemProjectileMixin.java @@ -1,13 +1,8 @@ package io.izzel.arclight.common.mixin.core.world.entity.projectile; -import net.minecraft.Util; -import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.world.entity.projectile.ThrowableItemProjectile; import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; @Mixin(ThrowableItemProjectile.class) @@ -15,25 +10,8 @@ public abstract class ThrowableItemProjectileMixin extends ThrowableProjectileMi // @formatter:off @Shadow protected abstract Item getDefaultItem(); - @Shadow @Final private static EntityDataAccessor DATA_ITEM_STACK; // @formatter:on - /** - * @author IzzelAliz - * @reason - */ - @Overwrite - public void setItem(ItemStack stack) { - if (stack.getItem() != this.getDefaultItem() || stack.hasTag()) { - this.getEntityData().set(DATA_ITEM_STACK, Util.make(stack.copy(), (itemStack) -> { - if (!itemStack.isEmpty()) { - itemStack.setCount(1); - } - })); - } - - } - public Item getDefaultItemPublic() { return this.getDefaultItem(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownEggMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownEggMixin.java index b378d570..1546c8fe 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownEggMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownEggMixin.java @@ -26,7 +26,7 @@ public abstract class ThrownEggMixin extends ThrowableProjectileMixin { @Overwrite protected void onHit(final HitResult result) { super.onHit(result); - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { boolean hatching = this.random.nextInt(8) == 0; byte b0 = 1; if (this.random.nextInt(32) == 0) { @@ -46,17 +46,17 @@ public abstract class ThrownEggMixin extends ThrowableProjectileMixin { } if (hatching) { for (int i = 0; i < b0; ++i) { - Entity entity = ((WorldBridge) this.level).bridge$getWorld().createEntity(new Location(((WorldBridge) this.level).bridge$getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0f), hatchingType.getEntityClass()); + Entity entity = ((WorldBridge) this.level()).bridge$getWorld().createEntity(new Location(((WorldBridge) this.level()).bridge$getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0f), hatchingType.getEntityClass()); if (entity != null) { if (((EntityBridge) entity).bridge$getBukkitEntity() instanceof Ageable) { ((Ageable) ((EntityBridge) entity).bridge$getBukkitEntity()).setBaby(); } - ((WorldBridge) this.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EGG); - this.level.addFreshEntity(entity); + ((WorldBridge) this.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.EGG); + this.level().addFreshEntity(entity); } } } - this.level.broadcastEntityEvent((ThrownEgg) (Object) this, (byte) 3); + this.level().broadcastEntityEvent((ThrownEgg) (Object) this, (byte) 3); this.discard(); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownEnderpearlMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownEnderpearlMixin.java index 163c7ab3..d6cccebd 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownEnderpearlMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownEnderpearlMixin.java @@ -15,7 +15,7 @@ public abstract class ThrownEnderpearlMixin extends ThrowableProjectileMixin { @Inject(method = "onHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) private void arclight$spawnEndermite(HitResult result, CallbackInfo ci) { - ((WorldBridge) this.level).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.ENDER_PEARL); + ((WorldBridge) this.level()).bridge$pushAddEntityReason(CreatureSpawnEvent.SpawnReason.ENDER_PEARL); } @Inject(method = "onHit", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;hurt(Lnet/minecraft/world/damagesource/DamageSource;F)Z")) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownExperienceBottleMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownExperienceBottleMixin.java index 8560e097..19a38ce1 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownExperienceBottleMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownExperienceBottleMixin.java @@ -21,14 +21,14 @@ public abstract class ThrownExperienceBottleMixin extends ThrowableItemProjectil @Overwrite protected void onHit(HitResult result) { super.onHit(result); - if (!this.level.isClientSide) { - int i = 3 + this.level.random.nextInt(5) + this.level.random.nextInt(5); + if (!this.level().isClientSide) { + int i = 3 + this.level().random.nextInt(5) + this.level().random.nextInt(5); ExpBottleEvent event = CraftEventFactory.callExpBottleEvent((ThrownExperienceBottle) (Object) this, i); i = event.getExperience(); if (event.getShowEffect()) { - this.level.levelEvent(2002, this.blockPosition(), PotionUtils.getColor(Potions.WATER)); + this.level().levelEvent(2002, this.blockPosition(), PotionUtils.getColor(Potions.WATER)); } - ExperienceOrb.award((ServerLevel) this.level, this.position(), i); + ExperienceOrb.award((ServerLevel) this.level(), this.position(), i); this.discard(); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownPotionMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownPotionMixin.java index a0332e72..4e3e27d1 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownPotionMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownPotionMixin.java @@ -50,7 +50,7 @@ public abstract class ThrownPotionMixin extends ThrowableItemProjectileMixin { @Overwrite private void applySplash(List list, @Nullable Entity entity) { AABB axisalignedbb = this.getBoundingBox().inflate(4.0, 2.0, 4.0); - List list2 = this.level.getEntitiesOfClass(LivingEntity.class, axisalignedbb); + List list2 = this.level().getEntitiesOfClass(LivingEntity.class, axisalignedbb); Map affected = new HashMap<>(); if (!list2.isEmpty()) { for (LivingEntity entityliving : list2) { @@ -77,7 +77,7 @@ public abstract class ThrownPotionMixin extends ThrowableItemProjectileMixin { double d2 = event.getIntensity(victim); for (MobEffectInstance mobeffect : list) { MobEffect mobeffectlist = mobeffect.getEffect(); - if (!((WorldBridge) this.level).bridge$isPvpMode() && this.getOwner() instanceof ServerPlayer && entityliving2 instanceof ServerPlayer && entityliving2 != this.getOwner()) { + if (!((WorldBridge) this.level()).bridge$isPvpMode() && this.getOwner() instanceof ServerPlayer && entityliving2 instanceof ServerPlayer && entityliving2 != this.getOwner()) { int i = MobEffect.getId(mobeffectlist); if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18) { continue; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownTridentMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownTridentMixin.java index 32719c08..57bc355a 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownTridentMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/ThrownTridentMixin.java @@ -20,7 +20,7 @@ public abstract class ThrownTridentMixin extends AbstractArrowMixin implements T @Redirect(method = "onHitEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) private boolean arclight$lightning(Level world, Entity entityIn) { - ((ServerWorldBridge) this.level).bridge$strikeLightning((LightningBolt) entityIn, LightningStrikeEvent.Cause.TRIDENT); + ((ServerWorldBridge) this.level()).bridge$strikeLightning((LightningBolt) entityIn, LightningStrikeEvent.Cause.TRIDENT); return true; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/WitherSkullMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/WitherSkullMixin.java index 4ba19836..6e21861e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/WitherSkullMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/projectile/WitherSkullMixin.java @@ -34,7 +34,7 @@ public abstract class WitherSkullMixin extends AbstractHurtingProjectileMixin { ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), explosionRadius, causesFire); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { - return this.level.explode((WitherSkull) (Object) this, xIn, yIn, zIn, event.getRadius(), event.getFire(), interaction); + return this.level().explode((WitherSkull) (Object) this, xIn, yIn, zIn, event.getRadius(), event.getFire(), interaction); } return null; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/vehicle/AbstractMinecartMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/vehicle/AbstractMinecartMixin.java index 2d26502b..f36d7e91 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/vehicle/AbstractMinecartMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/vehicle/AbstractMinecartMixin.java @@ -63,6 +63,7 @@ public abstract class AbstractMinecartMixin extends EntityMixin { @Shadow(remap = false) public abstract boolean canUseRail(); // @formatter:on + @Shadow private boolean onRails; public boolean slowWhenEmpty = true; private double derailedX = 0.5; private double derailedY = 0.5; @@ -90,7 +91,7 @@ public abstract class AbstractMinecartMixin extends EntityMixin { */ @Overwrite public boolean hurt(DamageSource source, float amount) { - if (this.level.isClientSide || this.isRemoved()) { + if (this.level().isClientSide || this.isRemoved()) { return true; } if (this.isInvulnerableTo(source)) { @@ -144,10 +145,8 @@ public abstract class AbstractMinecartMixin extends EntityMixin { if (this.getDamage() > 0.0f) { this.setDamage(this.getDamage() - 1.0f); } - if (this.getY() < -64.0) { - this.outOfWorld(); - } - if (this.level.isClientSide) { + this.checkBelowWorld(); + if (this.level().isClientSide) { if (this.lSteps > 0) { double d0 = this.getX() + (this.lx - this.getX()) / this.lSteps; double d2 = this.getY() + (this.ly - this.getY()) / this.lSteps; @@ -174,12 +173,13 @@ public abstract class AbstractMinecartMixin extends EntityMixin { int i = Mth.floor(this.getX()); int j = Mth.floor(this.getY()); int k = Mth.floor(this.getZ()); - if (this.level.getBlockState(new BlockPos(i, j - 1, k)).is(BlockTags.RAILS)) { + if (this.level().getBlockState(new BlockPos(i, j - 1, k)).is(BlockTags.RAILS)) { --j; } BlockPos blockposition = new BlockPos(i, j, k); - BlockState blockstate = this.level.getBlockState(blockposition); - if (this.canUseRail() && BaseRailBlock.isRail(blockstate)) { + BlockState blockstate = this.level().getBlockState(blockposition); + this.onRails = BaseRailBlock.isRail(blockstate); + if (this.canUseRail() && this.onRails) { this.moveAlongTrack(blockposition, blockstate); if (blockstate.getBlock() instanceof PoweredRailBlock && ((PoweredRailBlock) blockstate.getBlock()).isActivatorRail()) { this.activateMinecart(i, j, k, blockstate.getValue(PoweredRailBlock.POWERED)); @@ -203,7 +203,7 @@ public abstract class AbstractMinecartMixin extends EntityMixin { this.flipped = !this.flipped; } this.setRot(this.getYRot(), this.getXRot()); - org.bukkit.World bworld = ((WorldBridge) this.level).bridge$getWorld(); + org.bukkit.World bworld = ((WorldBridge) this.level()).bridge$getWorld(); Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch); Location to = new Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); Vehicle vehicle = (Vehicle) this.getBukkitEntity(); @@ -212,7 +212,7 @@ public abstract class AbstractMinecartMixin extends EntityMixin { Bukkit.getPluginManager().callEvent(new VehicleMoveEvent(vehicle, from, to)); } if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01) { - List list = this.level.getEntities((AbstractMinecart) (Object) this, this.getBoundingBox().inflate(0.20000000298023224, 0.0, 0.20000000298023224), EntitySelector.pushableBy((AbstractMinecart) (Object) this)); + List list = this.level().getEntities((AbstractMinecart) (Object) this, this.getBoundingBox().inflate(0.20000000298023224, 0.0, 0.20000000298023224), EntitySelector.pushableBy((AbstractMinecart) (Object) this)); if (!list.isEmpty()) { for (Entity entity : list) { if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) { @@ -234,7 +234,7 @@ public abstract class AbstractMinecartMixin extends EntityMixin { } } } else { - for (Entity entity2 : this.level.getEntities((AbstractMinecart) (Object) this, this.getBoundingBox().inflate(0.20000000298023224, 0.0, 0.20000000298023224))) { + for (Entity entity2 : this.level().getEntities((AbstractMinecart) (Object) this, this.getBoundingBox().inflate(0.20000000298023224, 0.0, 0.20000000298023224))) { if (!this.hasPassenger(entity2) && entity2.isPushable() && entity2 instanceof AbstractMinecart) { VehicleEntityCollisionEvent collisionEvent2 = new VehicleEntityCollisionEvent(vehicle, ((EntityBridge) entity2).bridge$getBukkitEntity()); Bukkit.getPluginManager().callEvent(collisionEvent2); 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 4f245bca..27672619 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 @@ -79,7 +79,7 @@ public abstract class BoatMixin extends EntityMixin { @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 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()); final Vehicle vehicle = (Vehicle) this.getBukkitEntity(); Bukkit.getPluginManager().callEvent(new VehicleUpdateEvent(vehicle)); 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 05ac6d52..030c257b 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 @@ -38,6 +38,8 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import static net.minecraft.world.inventory.AbstractContainerMenu.getQuickCraftPlaceCount; + @Mixin(AbstractContainerMenu.class) public abstract class AbstractContainerMenuMixin implements ContainerBridge { @@ -56,7 +58,6 @@ public abstract class AbstractContainerMenuMixin implements ContainerBridge { @Shadow public static int getQuickcraftType(int eventButton) { return 0; } @Shadow public static boolean isValidQuickcraftType(int dragModeIn, Player player) { return false; } @Shadow public static boolean canItemQuickReplace(@Nullable Slot slotIn, ItemStack stack, boolean stackSizeMatters) { return false; } - @Shadow public static void getQuickCraftSlotCount(Set dragSlotsIn, int dragModeIn, ItemStack stack, int slotStackSize) { } @Shadow protected abstract boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection); @Shadow @Final @javax.annotation.Nullable private MenuType menuType; @Shadow private ItemStack remoteCarried; @@ -156,6 +157,11 @@ public abstract class AbstractContainerMenuMixin implements ContainerBridge { return; } ItemStack itemstack9 = this.getCarried().copy(); + if (itemstack9.isEmpty()) { + this.resetQuickCraft(); + return; + } + int k1 = this.getCarried().getCount(); Map draggedSlots = new HashMap<>(); @@ -163,17 +169,13 @@ public abstract class AbstractContainerMenuMixin implements ContainerBridge { for (Slot slot8 : this.quickcraftSlots) { ItemStack itemstack13 = this.getCarried(); if (slot8 != null && canItemQuickReplace(slot8, itemstack13, true) && slot8.mayPlace(itemstack13) && (this.quickcraftType == 2 || itemstack13.getCount() >= this.quickcraftSlots.size()) && this.canDragTo(slot8)) { - ItemStack itemstack14 = itemstack9.copy(); int j3 = slot8.hasItem() ? slot8.getItem().getCount() : 0; - getQuickCraftSlotCount(this.quickcraftSlots, this.quickcraftType, itemstack14, j3); - int k3 = Math.min(itemstack14.getMaxStackSize(), slot8.getMaxStackSize(itemstack14)); - if (itemstack14.getCount() > k3) { - itemstack14.setCount(k3); - } + int k3 = Math.min(itemstack9.getMaxStackSize(), slot8.getMaxStackSize(itemstack9)); + int l3 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack9) + j3, k3); - k1 -= itemstack14.getCount() - j3; + k1 -= l3 - j3; // slot8.set(itemstack14); - draggedSlots.put(slot8.index, itemstack14); + draggedSlots.put(slot8.index, itemstack9.copyWithCount(l3)); } } @@ -232,7 +234,7 @@ public abstract class AbstractContainerMenuMixin implements ContainerBridge { return; } - for (ItemStack itemstack9 = this.quickMoveStack(player, slotId); !itemstack9.isEmpty() && ItemStack.isSame(slot6.getItem(), itemstack9); itemstack9 = this.quickMoveStack(player, slotId)) { + for (ItemStack itemstack9 = this.quickMoveStack(player, slotId); !itemstack9.isEmpty() && ItemStack.isSameItem(slot6.getItem(), itemstack9); itemstack9 = this.quickMoveStack(player, slotId)) { } } else { if (slotId < 0) { @@ -325,9 +327,8 @@ public abstract class AbstractContainerMenuMixin implements ContainerBridge { } else if (clickType == ClickType.CLONE && player.getAbilities().instabuild && this.getCarried().isEmpty() && slotId >= 0) { Slot slot5 = this.slots.get(slotId); if (slot5.hasItem()) { - ItemStack itemstack6 = slot5.getItem().copy(); - itemstack6.setCount(itemstack6.getMaxStackSize()); - this.setCarried(itemstack6); + ItemStack itemstack6 = slot5.getItem(); + this.setCarried(itemstack6.copyWithCount(itemstack6.getMaxStackSize())); } } else if (clickType == ClickType.THROW && this.getCarried().isEmpty() && slotId >= 0) { Slot slot4 = this.slots.get(slotId); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/CraftingInventoryMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/CraftingInventoryMixin.java index 1a70bb16..ea39cea5 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/CraftingInventoryMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/CraftingInventoryMixin.java @@ -8,7 +8,7 @@ import net.minecraft.core.NonNullList; import net.minecraft.world.Container; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.inventory.TransientCraftingContainer; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; import org.bukkit.Location; @@ -23,7 +23,7 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.ArrayList; import java.util.List; -@Mixin(CraftingContainer.class) +@Mixin(TransientCraftingContainer.class) public abstract class CraftingInventoryMixin implements CraftingInventoryBridge, Container { // @formatter:off diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/LegacySmithingMenuMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/LegacySmithingMenuMixin.java deleted file mode 100644 index a3db9744..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/LegacySmithingMenuMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.izzel.arclight.common.mixin.core.world.inventory; - -import io.izzel.arclight.common.bridge.core.entity.player.PlayerEntityBridge; -import io.izzel.arclight.common.bridge.core.util.IWorldPosCallableBridge; -import net.minecraft.world.inventory.LegacySmithingMenu; -import net.minecraft.world.inventory.ResultContainer; -import net.minecraft.world.item.ItemStack; -import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.bukkit.craftbukkit.v.inventory.CraftInventory; -import org.bukkit.craftbukkit.v.inventory.CraftInventorySmithing; -import org.bukkit.craftbukkit.v.inventory.CraftInventoryView; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(LegacySmithingMenu.class) -public abstract class LegacySmithingMenuMixin extends ItemCombinerMixin { - - private CraftInventoryView bukkitEntity; - - @Redirect(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/ResultContainer;setItem(ILnet/minecraft/world/item/ItemStack;)V")) - private void arclight$prepareSmithing(ResultContainer craftResultInventory, int index, ItemStack stack) { - CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), stack); - } - - @Override - public CraftInventoryView getBukkitView() { - if (this.bukkitEntity != null) { - return this.bukkitEntity; - } - CraftInventory inventory = new CraftInventorySmithing(((IWorldPosCallableBridge) this.access).bridge$getLocation(), this.inputSlots, this.resultSlots); - return this.bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.player).bridge$getBukkitEntity(), inventory, (LegacySmithingMenu) (Object) this); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/RepairContainerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/RepairContainerMixin.java index c0c79d70..f5e279e2 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/RepairContainerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/inventory/RepairContainerMixin.java @@ -2,6 +2,7 @@ package io.izzel.arclight.common.mixin.core.world.inventory; import io.izzel.arclight.common.bridge.core.entity.player.PlayerEntityBridge; import io.izzel.arclight.common.bridge.core.util.IWorldPosCallableBridge; +import net.minecraft.Util; import net.minecraft.network.chat.Component; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.AnvilMenu; @@ -12,7 +13,6 @@ import net.minecraft.world.item.Items; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraftforge.common.ForgeHooks; -import org.apache.commons.lang3.StringUtils; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.craftbukkit.v.inventory.CraftInventory; import org.bukkit.craftbukkit.v.inventory.CraftInventoryAnvil; @@ -182,16 +182,16 @@ public abstract class RepairContainerMixin extends ItemCombinerMixin { } } - if (StringUtils.isBlank(this.itemName)) { - if (itemstack.hasCustomHoverName()) { + if (this.itemName != null && !Util.isBlank(this.itemName)) { + if (!this.itemName.equals(itemstack.getHoverName().getString())) { k = 1; i += k; - itemstack1.resetHoverName(); + itemstack1.setHoverName(Component.literal(this.itemName)); } - } else if (!this.itemName.equals(itemstack.getHoverName().getString())) { + } else if (itemstack.hasCustomHoverName()) { k = 1; i += k; - itemstack1.setHoverName(Component.literal(this.itemName)); + itemstack1.resetHoverName(); } if (flag && !itemstack1.isBookEnchantable(itemstack2)) itemstack1 = ItemStack.EMPTY; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/MerchantOfferMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/MerchantOfferMixin.java index 5c2627df..51a3eb8f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/MerchantOfferMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/MerchantOfferMixin.java @@ -15,9 +15,9 @@ public class MerchantOfferMixin implements MerchantOfferBridge { // @formatter:off @Shadow public ItemStack baseCostA; + @Shadow private int demand; // @formatter:on - @Shadow private int demand; private CraftMerchantRecipe bukkitHandle; public CraftMerchantRecipe asBukkit() { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/IngredientMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/IngredientMixin.java index 27dd2d5f..18388f69 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/IngredientMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/IngredientMixin.java @@ -34,7 +34,7 @@ public abstract class IngredientMixin implements IngredientBridge { for (ItemStack stack : items) { // CraftBukkit start if (exact) { - if (stack.getItem() == itemstack.getItem() && ItemStack.tagMatches(itemstack, stack)) { + if (ItemStack.isSameItemSameTags(itemstack, stack)) { return true; } continue; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/SmithingRecipeMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/SmithingRecipeMixin.java deleted file mode 100644 index 91a9c49b..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/crafting/SmithingRecipeMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.izzel.arclight.common.mixin.core.world.item.crafting; - -import io.izzel.arclight.common.bridge.core.item.crafting.IRecipeBridge; -import io.izzel.arclight.common.mod.util.ArclightSpecialRecipe; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.LegacyUpgradeRecipe; -import org.bukkit.craftbukkit.v.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v.inventory.CraftRecipe; -import org.bukkit.craftbukkit.v.inventory.CraftSmithingRecipe; -import org.bukkit.craftbukkit.v.util.CraftNamespacedKey; -import org.bukkit.inventory.Recipe; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(LegacyUpgradeRecipe.class) -public class SmithingRecipeMixin implements IRecipeBridge { - - // @formatter:off - @Shadow @Final ItemStack result; - @Shadow @Final private ResourceLocation id; - @Shadow @Final Ingredient base; - @Shadow @Final Ingredient addition; - // @formatter:on - - @Override - public Recipe bridge$toBukkitRecipe() { - if (this.result.isEmpty()) { - return new ArclightSpecialRecipe((LegacyUpgradeRecipe) (Object) this); - } - CraftItemStack result = CraftItemStack.asCraftMirror(this.result); - return new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); - } -} 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 970accf1..6e10504d 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 @@ -6,9 +6,8 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.enchantment.FrostWalkerEnchantment; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.FrostedIceBlock; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.shapes.CollisionContext; import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.spongepowered.asm.mixin.Mixin; @@ -23,7 +22,7 @@ public class FrostWalkerEnchantmentMixin { */ @Overwrite public static void onEntityMoved(LivingEntity living, Level worldIn, BlockPos pos, int level) { - if (living.isOnGround()) { + if (living.onGround()) { BlockState blockstate = Blocks.FROSTED_ICE.defaultBlockState(); int f = Math.min(16, 2 + level); BlockPos.MutableBlockPos blockpos$mutable = new BlockPos.MutableBlockPos(); @@ -34,8 +33,7 @@ public class FrostWalkerEnchantmentMixin { BlockState blockstate1 = worldIn.getBlockState(blockpos$mutable); if (blockstate1.isAir()) { BlockState blockstate2 = worldIn.getBlockState(blockpos); - 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 (blockstate2 == FrostedIceBlock.meltsInto() && 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.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/block/BasePressurePlateBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/BasePressurePlateBlockMixin.java index d1d1bc54..662e1e6a 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/BasePressurePlateBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/BasePressurePlateBlockMixin.java @@ -3,6 +3,7 @@ package io.izzel.arclight.common.mixin.core.world.level.block; import io.izzel.arclight.common.mod.util.DistValidate; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySelector; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BasePressurePlateBlock; import net.minecraft.world.level.block.state.BlockState; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PressurePlateBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PressurePlateBlockMixin.java index 058df6ef..60ec8f38 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PressurePlateBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/PressurePlateBlockMixin.java @@ -1,8 +1,10 @@ package io.izzel.arclight.common.mixin.core.world.level.block; import io.izzel.arclight.common.bridge.core.entity.EntityBridge; +import io.izzel.arclight.common.bridge.core.world.WorldBridge; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySelector; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; @@ -10,9 +12,7 @@ import net.minecraft.world.level.block.PressurePlateBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v.block.CraftBlock; import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.bukkit.event.Cancellable; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityInteractEvent; import org.spongepowered.asm.mixin.Final; @@ -20,8 +20,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import java.util.List; - @Mixin(PressurePlateBlock.class) public abstract class PressurePlateBlockMixin extends BasePressurePlateBlockMixin { @@ -30,46 +28,53 @@ public abstract class PressurePlateBlockMixin extends BasePressurePlateBlockMixi @Shadow protected abstract int getSignalForState(BlockState state); // @formatter:on + private static java.util.List getEntities(Level world, AABB axisalignedbb, Class oclass) { + return world.getEntitiesOfClass(oclass, axisalignedbb, EntitySelector.NO_SPECTATORS.and((entity) -> { + return !entity.isIgnoringBlockTriggers(); + })); + } + /** * @author IzzelAliz * @reason */ @Overwrite - protected int getSignalStrength(Level worldIn, BlockPos pos) { - AABB axisalignedbb = TOUCH_AABB.move(pos); - List list; + protected int getSignalStrength(Level world, BlockPos blockposition) { + Class oclass; // CraftBukkit + switch (this.sensitivity) { case EVERYTHING: - list = worldIn.getEntities(null, axisalignedbb); + oclass = Entity.class; break; case MOBS: - list = worldIn.getEntitiesOfClass(LivingEntity.class, axisalignedbb); + oclass = LivingEntity.class; break; default: - return 0; + throw new IncompatibleClassChangeError(); } - if (!list.isEmpty()) { - for (Entity entity : list) { - if (this.getSignalForState(worldIn.getBlockState(pos)) == 0) { - Cancellable cancellable; + Class oclass1 = oclass; - if (entity instanceof Player) { - cancellable = CraftEventFactory.callPlayerInteractEvent((Player) entity, Action.PHYSICAL, pos, null, null, null); - } else { - cancellable = new EntityInteractEvent(((EntityBridge) entity).bridge$getBukkitEntity(), CraftBlock.at(worldIn, pos)); - Bukkit.getPluginManager().callEvent((EntityInteractEvent) cancellable); - } + // CraftBukkit start - Call interact event when turning on a pressure plate + for (Entity entity : getEntities(world, TOUCH_AABB.move(blockposition), oclass)) { + if (this.getSignalForState(world.getBlockState(blockposition)) == 0) { + org.bukkit.World bworld = ((WorldBridge) world).bridge$getWorld(); + org.bukkit.plugin.PluginManager manager = Bukkit.getPluginManager(); + org.bukkit.event.Cancellable cancellable; - // We only want to block turning the plate on if all events are cancelled - if (cancellable.isCancelled()) { - continue; - } + if (entity instanceof Player) { + cancellable = CraftEventFactory.callPlayerInteractEvent((Player) entity, Action.PHYSICAL, blockposition, null, null, null); + } else { + cancellable = new EntityInteractEvent(((EntityBridge) entity).bridge$getBukkitEntity(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + manager.callEvent((EntityInteractEvent) cancellable); } - if (!entity.isIgnoringBlockTriggers()) { - return 15; + // We only want to block turning the plate on if all events are cancelled + if (cancellable.isCancelled()) { + continue; } } + + return 15; } return 0; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/SculkSensorBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/SculkSensorBlockMixin.java index d2285324..1a9a9323 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/SculkSensorBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/SculkSensorBlockMixin.java @@ -46,10 +46,10 @@ public class SculkSensorBlockMixin { } } - @Unique private static int newCurrent; + @Unique private int newCurrent; @Inject(method = "activate", cancellable = true, at = @At("HEAD")) - private static void arclight$activate(Entity p_222126_, Level level, BlockPos pos, BlockState state, int i, CallbackInfo ci) { + private void arclight$activate(Entity p_222126_, Level level, BlockPos pos, BlockState state, int i, int j, CallbackInfo ci) { BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(level, pos), state.getValue(SculkSensorBlock.POWER), i); Bukkit.getPluginManager().callEvent(eventRedstone); if (eventRedstone.getNewCurrent() <= 0) { @@ -59,7 +59,7 @@ public class SculkSensorBlockMixin { } @ModifyVariable(method = "activate", ordinal = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z"), argsOnly = true) - private static int arclight$updateCurrent(int old) { + private int arclight$updateCurrent(int old) { return newCurrent; } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/SpongeBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/SpongeBlockMixin.java index 6354c9c7..b23a955e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/SpongeBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/SpongeBlockMixin.java @@ -1,88 +1,95 @@ package io.izzel.arclight.common.mixin.core.world.level.block; -import com.google.common.collect.Lists; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.tags.FluidTags; -import net.minecraft.util.Tuple; 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.BucketPickup; -import net.minecraft.world.level.block.LiquidBlock; -import net.minecraft.world.level.block.SpongeBlock; +import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Material; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.block.CraftBlock; import org.bukkit.craftbukkit.v.block.CraftBlockState; import org.bukkit.craftbukkit.v.util.BlockStateListPopulator; import org.bukkit.event.block.SpongeAbsorbEvent; +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; + +import static net.minecraft.world.level.block.Block.dropResources; @Mixin(SpongeBlock.class) public class SpongeBlockMixin { + @Shadow @Final private static Direction[] ALL_DIRECTIONS; + /** * @author IzzelAliz * @reason */ @SuppressWarnings("unchecked") @Overwrite - private boolean removeWaterBreadthFirstSearch(Level worldIn, BlockPos pos) { - Queue> queue = Lists.newLinkedList(); - queue.add(new Tuple<>(pos, 0)); - int i = 0; - BlockStateListPopulator blockList = new BlockStateListPopulator(worldIn); + private boolean removeWaterBreadthFirstSearch(Level world, BlockPos blockposition) { + BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator + BlockPos.breadthFirstTraversal(blockposition, 6, 65, (blockposition1, consumer) -> { + Direction[] aenumdirection = ALL_DIRECTIONS; + int i = aenumdirection.length; - while (!queue.isEmpty()) { - Tuple tuple = queue.poll(); - BlockPos blockpos = tuple.getA(); - int j = tuple.getB(); + for (int j = 0; j < i; ++j) { + Direction enumdirection = aenumdirection[j]; - for (Direction direction : Direction.values()) { - BlockPos blockpos1 = blockpos.relative(direction); - BlockState blockstate = blockList.getBlockState(blockpos1); - FluidState ifluidstate = blockList.getFluidState(blockpos1); - Material material = blockstate.getMaterial(); - if (ifluidstate.is(FluidTags.WATER)) { - if (blockstate.getBlock() instanceof BucketPickup && !((BucketPickup) blockstate.getBlock()).pickupBlock(worldIn, blockpos1, blockstate).isEmpty()) { - ++i; - if (j < 6) { - queue.add(new Tuple<>(blockpos1, j + 1)); - } - } else if (blockstate.getBlock() instanceof LiquidBlock) { - worldIn.setBlock(blockpos1, Blocks.AIR.defaultBlockState(), 3); - ++i; - if (j < 6) { - queue.add(new Tuple<>(blockpos1, j + 1)); - } - } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { - //TileEntity tileentity = blockstate.getBlock().hasTileEntity() ? worldIn.getTileEntity(blockpos1) : null; - // Block.spawnDrops(blockstate, worldIn, blockpos1, tileentity); - blockList.setBlock(blockpos1, Blocks.AIR.defaultBlockState(), 3); - ++i; - if (j < 6) { - queue.add(new Tuple<>(blockpos1, j + 1)); + consumer.accept(blockposition1.relative(enumdirection)); + } + + }, (blockposition1) -> { + if (blockposition1.equals(blockposition)) { + return true; + } else { + // CraftBukkit start + BlockState iblockdata = blockList.getBlockState(blockposition1); + FluidState fluid = blockList.getFluidState(blockposition1); + // CraftBukkit end + + if (!fluid.is(FluidTags.WATER)) { + return false; + } else { + Block block = iblockdata.getBlock(); + + if (block instanceof BucketPickup) { + BucketPickup ifluidsource = (BucketPickup) block; + + if (!ifluidsource.pickupBlock(blockList, blockposition1, iblockdata).isEmpty()) { // CraftBukkit + return true; } } + + if (iblockdata.getBlock() instanceof LiquidBlock) { + blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit + } else { + if (!iblockdata.is(Blocks.KELP) && !iblockdata.is(Blocks.KELP_PLANT) && !iblockdata.is(Blocks.SEAGRASS) && !iblockdata.is(Blocks.TALL_SEAGRASS)) { + return false; + } + + // CraftBukkit start + // TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null; + + // dropResources(iblockdata, world, blockposition1, tileentity); + blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); + // CraftBukkit end + } + + return true; } } - - if (i > 64) { - break; - } - } - + }); + // CraftBukkit start List blocks = blockList.getList(); // Is a clone if (!blocks.isEmpty()) { - final org.bukkit.block.Block bblock = CraftBlock.at(worldIn, pos); + final org.bukkit.block.Block bblock = CraftBlock.at(world, blockposition); SpongeAbsorbEvent event = new SpongeAbsorbEvent(bblock, (List) (List) blocks); Bukkit.getPluginManager().callEvent(event); @@ -92,25 +99,27 @@ public class SpongeBlockMixin { } for (CraftBlockState block : blocks) { - BlockPos blockposition2 = block.getPosition(); - BlockState iblockdata = worldIn.getBlockState(blockposition2); - FluidState fluid = worldIn.getFluidState(blockposition2); - Material material = iblockdata.getMaterial(); + BlockPos blockposition1 = block.getPosition(); + BlockState iblockdata = world.getBlockState(blockposition1); + FluidState fluid = world.getFluidState(blockposition1); if (fluid.is(FluidTags.WATER)) { - if (iblockdata.getBlock() instanceof BucketPickup && !((BucketPickup) iblockdata.getBlock()).pickupBlock(blockList, blockposition2, iblockdata).isEmpty()) { + if (iblockdata.getBlock() instanceof BucketPickup && !((BucketPickup) iblockdata.getBlock()).pickupBlock(blockList, blockposition1, iblockdata).isEmpty()) { // NOP } else if (iblockdata.getBlock() instanceof LiquidBlock) { // NOP - } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { - BlockEntity tileentity = iblockdata.hasBlockEntity() ? worldIn.getBlockEntity(blockposition2) : null; + } else if (iblockdata.is(Blocks.KELP) || iblockdata.is(Blocks.KELP_PLANT) || iblockdata.is(Blocks.SEAGRASS) || iblockdata.is(Blocks.TALL_SEAGRASS)) { + BlockEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null; - Block.dropResources(iblockdata, worldIn, blockposition2, tileentity); + dropResources(iblockdata, world, blockposition1, tileentity); } } - worldIn.setBlock(blockposition2, block.getHandle(), block.getFlag()); + world.setBlock(blockposition1, block.getHandle(), block.getFlag()); } + + return true; } - return i > 0; + return false; + // CraftBukkit end } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/WeightedPressurePlateBlockMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/WeightedPressurePlateBlockMixin.java index 498c6074..81a3688b 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/WeightedPressurePlateBlockMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/WeightedPressurePlateBlockMixin.java @@ -3,34 +3,39 @@ package io.izzel.arclight.common.mixin.core.world.level.block; import io.izzel.arclight.common.bridge.core.entity.EntityBridge; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySelector; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.WeightedPressurePlateBlock; +import net.minecraft.world.phys.AABB; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.block.CraftBlock; import org.bukkit.craftbukkit.v.event.CraftEventFactory; -import org.bukkit.event.Cancellable; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityInteractEvent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import java.util.List; - @Mixin(WeightedPressurePlateBlock.class) -public class WeightedPressurePlateBlockMixin { +public abstract class WeightedPressurePlateBlockMixin extends BasePressurePlateBlockMixin { - @Redirect(method = "getSignalStrength", at = @At(value = "INVOKE", remap = false, target = "Ljava/util/List;size()I")) - public int arclight$entityInteract(List list, Level worldIn, BlockPos pos) { + private static java.util.List getEntities(Level world, AABB axisalignedbb, Class oclass) { + return world.getEntitiesOfClass(oclass, axisalignedbb, EntitySelector.NO_SPECTATORS.and((entity) -> { + return !entity.isIgnoringBlockTriggers(); + })); + } + + @Redirect(method = "getSignalStrength", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/WeightedPressurePlateBlock;getEntityCount(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/phys/AABB;Ljava/lang/Class;)I")) + public int arclight$entityInteract(Level level, AABB aabb, Class aClass, Level world, BlockPos pos) { int i = 0; - for (Entity entity : list) { - Cancellable cancellable; + for (Entity entity : getEntities(level, aabb, aClass)) { + org.bukkit.event.Cancellable cancellable; if (entity instanceof Player) { cancellable = CraftEventFactory.callPlayerInteractEvent((Player) entity, Action.PHYSICAL, pos, null, null, null); } else { - cancellable = new EntityInteractEvent(((EntityBridge) entity).bridge$getBukkitEntity(), CraftBlock.at(worldIn, pos)); + cancellable = new EntityInteractEvent(((EntityBridge) entity).bridge$getBukkitEntity(), CraftBlock.at(world, pos)); Bukkit.getPluginManager().callEvent((EntityInteractEvent) cancellable); } 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 6a497510..5d36b98b 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 @@ -162,7 +162,7 @@ public abstract class AbstractFurnaceBlockEntityMixin extends LockableBlockEntit @Override public List> bridge$dropExp(ServerPlayer entity, ItemStack itemStack, int amount) { - return getRecipesToAwardAndPopExperience(entity.getLevel(), entity.position(), this.worldPosition, entity, itemStack, amount); + return getRecipesToAwardAndPopExperience(entity.serverLevel(), 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/SignBlockEntityMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/SignBlockEntityMixin.java index 983b529b..1fd78efd 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/SignBlockEntityMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/block/entity/SignBlockEntityMixin.java @@ -1,40 +1,99 @@ package io.izzel.arclight.common.mixin.core.world.level.block.entity; +import io.izzel.arclight.common.bridge.core.command.CommandSourceBridge; import io.izzel.arclight.common.bridge.core.command.ICommandSourceBridge; import io.izzel.arclight.common.bridge.core.entity.EntityBridge; +import io.izzel.arclight.common.bridge.core.entity.player.ServerPlayerEntityBridge; import io.izzel.arclight.common.bridge.core.tileentity.SignTileEntityBridge; import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; +import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.Entity; +import net.minecraft.network.chat.Style; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.network.FilteredText; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.SignBlockEntity; -import net.minecraft.world.phys.Vec2; -import net.minecraft.world.phys.Vec3; +import net.minecraft.world.level.block.entity.SignText; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.v.block.CraftBlock; +import org.bukkit.craftbukkit.v.block.CraftSign; import org.bukkit.craftbukkit.v.command.CraftBlockCommandSender; +import org.bukkit.craftbukkit.v.util.CraftChatMessage; +import org.bukkit.event.block.SignChangeEvent; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; +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; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import javax.annotation.Nullable; +import java.util.List; @Mixin(SignBlockEntity.class) public abstract class SignBlockEntityMixin extends BlockEntityMixin implements SignTileEntityBridge, CommandSource, ICommandSourceBridge { // @formatter:off - @Override @Accessor("isEditable") public abstract void bridge$setEditable(boolean editable); + @Shadow public abstract ClientboundBlockEntityDataPacket getUpdatePacket(); + @Shadow private static CommandSourceStack createCommandSourceStack(@Nullable Player p_279428_, Level p_279359_, BlockPos p_279430_) { return null; } // @formatter:on - @Redirect(method = "createCommandSourceStack", at = @At(value = "NEW", target = "net/minecraft/commands/CommandSourceStack")) - private CommandSourceStack arclight$source(CommandSource source, Vec3 vec3d, Vec2 vec2f, ServerLevel world, int i, String s, Component component, MinecraftServer server, @Nullable Entity entity) { - return new CommandSourceStack(this, vec3d, vec2f, world, i, s, component, server, entity); + @Inject(method = "updateSignText", at = @At(value = "INVOKE", remap = false, target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V")) + private void arclight$updatePacket(Player player, boolean p_278103_, List p_277990_, CallbackInfo ci) { + ((ServerPlayer) player).connection.send(this.getUpdatePacket()); + } + + /** + * @author IzzelAliz + * @reason + */ + @Overwrite + private SignText setMessages(net.minecraft.world.entity.player.Player entityhuman, List list, SignText signtext) { + for (int i = 0; i < list.size(); ++i) { + FilteredText filteredtext = list.get(i); + Style chatmodifier = signtext.getMessage(i, entityhuman.isTextFilteringEnabled()).getStyle(); + + if (entityhuman.isTextFilteringEnabled()) { + signtext = signtext.setMessage(i, Component.literal(filteredtext.filteredOrEmpty()).setStyle(chatmodifier)); + } else { + signtext = signtext.setMessage(i, Component.literal(filteredtext.raw()).setStyle(chatmodifier), Component.literal(filteredtext.filteredOrEmpty()).setStyle(chatmodifier)); + } + + // CraftBukkit start + org.bukkit.entity.Player player = ((ServerPlayerEntityBridge) entityhuman).bridge$getBukkitEntity(); + String[] lines = new String[4]; + + for (int j = 0; j < list.size(); ++j) { + lines[j] = CraftChatMessage.fromComponent(signtext.getMessage(j, entityhuman.isTextFilteringEnabled())); + } + + SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.level, this.worldPosition), player, lines); + Bukkit.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + Component[] components = CraftSign.sanitizeLines(event.getLines()); + for (int j = 0; j < components.length; j++) { + signtext = signtext.setMessage(j, components[j]); + } + } + // CraftBukkit end + } + + return signtext; + } + + @Redirect(method = "executeClickCommandsIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/entity/SignBlockEntity;createCommandSourceStack(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/commands/CommandSourceStack;")) + private CommandSourceStack arclight$setSource(Player p_279428_, Level p_279359_, BlockPos p_279430_) { + var stack = createCommandSourceStack(p_279428_, p_279359_, p_279430_); + ((CommandSourceBridge) stack).bridge$setSource(this); + return stack; } @Inject(method = "markUpdated", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;sendBlockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;I)V")) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkGeneratorMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkGeneratorMixin.java index 24ff2366..3c24325b 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkGeneratorMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/chunk/ChunkGeneratorMixin.java @@ -23,7 +23,7 @@ import net.minecraft.world.level.levelgen.structure.StructureStart; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.generator.CraftLimitedRegion; -import org.bukkit.craftbukkit.v.generator.strucutre.CraftStructure; +import org.bukkit.craftbukkit.v.generator.structure.CraftStructure; import org.bukkit.craftbukkit.v.util.RandomSourceWrapper; import org.bukkit.generator.BlockPopulator; import org.spongepowered.asm.mixin.Final; 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 1927f487..2e321a2c 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 @@ -43,12 +43,12 @@ public abstract class LevelChunkMixin extends ChunkAccessMixin implements ChunkB public boolean mustNotSave; public boolean needsDecoration; private transient boolean arclight$doPlace; - public ServerLevel q; // TODO f_62776_ check on update + public ServerLevel r; // TODO f_62776_ check on update @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) { if (DistValidate.isValid(worldIn)) { - this.q = ((ServerLevel) worldIn); + this.r = ((ServerLevel) worldIn); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/gameevent/vibrations/VibrationListenerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/gameevent/vibrations/VibrationListenerMixin.java index 520036ab..de7d1cc5 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/gameevent/vibrations/VibrationListenerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/gameevent/vibrations/VibrationListenerMixin.java @@ -7,9 +7,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.gameevent.GameEvent; -import net.minecraft.world.level.gameevent.PositionSource; -import net.minecraft.world.level.gameevent.vibrations.VibrationInfo; -import net.minecraft.world.level.gameevent.vibrations.VibrationListener; +import net.minecraft.world.level.gameevent.vibrations.VibrationSystem; import net.minecraft.world.phys.Vec3; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.block.CraftBlock; @@ -20,18 +18,15 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import javax.annotation.Nullable; import java.util.Optional; -@Mixin(VibrationListener.class) +@Mixin(VibrationSystem.Listener.class) public abstract class VibrationListenerMixin { // @formatter:off - @Shadow @Final protected VibrationListener.VibrationListenerConfig config; - @Shadow @Final protected PositionSource listenerSource; @Shadow private static boolean isOccluded(Level p_223776_, Vec3 p_223777_, Vec3 p_223778_) { return false; } - @Shadow @Nullable protected VibrationInfo currentVibration; - @Shadow public abstract void scheduleVibration(ServerLevel p_250210_, GameEvent p_251063_, GameEvent.Context p_249354_, Vec3 p_250310_, Vec3 p_249553_); + @Shadow @Final private VibrationSystem system; + @Shadow protected abstract void scheduleVibration(ServerLevel p_282037_, VibrationSystem.Data p_283229_, GameEvent p_281778_, GameEvent.Context p_283344_, Vec3 p_281758_, Vec3 p_282990_); // @formatter:on /** @@ -40,20 +35,22 @@ public abstract class VibrationListenerMixin { */ @Overwrite public boolean handleGameEvent(ServerLevel worldserver, GameEvent gameevent, GameEvent.Context gameevent_a, Vec3 vec3d) { - if (this.currentVibration != null) { + VibrationSystem.Data vibrationsystem_a = this.system.getVibrationData(); + VibrationSystem.User vibrationsystem_d = this.system.getVibrationUser(); + + if (vibrationsystem_a.getCurrentVibration() != null) { return false; - } else if (!this.config.isValidVibration(gameevent, gameevent_a)) { + } else if (!vibrationsystem_d.isValidVibration(gameevent, gameevent_a)) { return false; } else { - Optional optional = this.listenerSource.getPosition(worldserver); + Optional optional = vibrationsystem_d.getPositionSource().getPosition(worldserver); if (optional.isEmpty()) { return false; } else { Vec3 vec3d1 = optional.get(); - // CraftBukkit start - boolean defaultCancel = !this.config.shouldListen(worldserver, (VibrationListener) (Object) this, BlockPos.containing(vec3d), gameevent, gameevent_a); + boolean defaultCancel = !vibrationsystem_d.canReceiveVibration(worldserver, BlockPos.containing(vec3d), gameevent, gameevent_a); Entity entity = gameevent_a.sourceEntity(); BlockReceiveGameEvent event = new BlockReceiveGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), CraftBlock.at(worldserver, BlockPos.containing(vec3d1)), (entity == null) ? null : ((EntityBridge) entity).bridge$getBukkitEntity()); event.setCancelled(defaultCancel); @@ -64,7 +61,7 @@ public abstract class VibrationListenerMixin { } else if (isOccluded(worldserver, vec3d, vec3d1)) { return false; } else { - this.scheduleVibration(worldserver, gameevent, gameevent_a, vec3d, vec3d1); + this.scheduleVibration(worldserver, vibrationsystem_a, gameevent, gameevent_a, vec3d, vec3d1); return true; } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootDataManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootDataManagerMixin.java new file mode 100644 index 00000000..1fcff84b --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootDataManagerMixin.java @@ -0,0 +1,31 @@ +package io.izzel.arclight.common.mixin.core.world.level.storage.loot; + +import com.google.common.collect.ImmutableMap; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.storage.loot.LootDataId; +import net.minecraft.world.level.storage.loot.LootDataManager; +import net.minecraft.world.level.storage.loot.LootDataType; +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(LootDataManager.class) +public class LootDataManagerMixin { + + // @formatter:off + @Shadow private Map, ?> elements; + // @formatter:on + + public Map lootTableToKey = ImmutableMap.of(); + + @Inject(method = "apply", at = @At("RETURN")) + private void arclight$buildRev(Map, Map> p_279426_, CallbackInfo ci) { + ImmutableMap.Builder lootTableToKeyBuilder = ImmutableMap.builder(); + this.elements.forEach((key, lootTable) -> lootTableToKeyBuilder.put(lootTable, key.location())); + this.lootTableToKey = lootTableToKeyBuilder.build(); + } +} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableManagerMixin.java deleted file mode 100644 index 525d6191..00000000 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableManagerMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.izzel.arclight.common.mixin.core.world.level.storage.loot; - -import com.google.common.collect.ImmutableMap; -import com.google.gson.JsonObject; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraft.world.level.storage.loot.LootTable; -import net.minecraft.world.level.storage.loot.LootTables; -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.HashMap; -import java.util.Map; - -@Mixin(LootTables.class) -public class LootTableManagerMixin { - - // @formatter:off - @Shadow private Map tables; - // @formatter:on - - public Map lootTableToKey = ImmutableMap.of(); - - @Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("RETURN")) - private void arclight$buildRev(Map objectIn, ResourceManager resourceManagerIn, ProfilerFiller profilerIn, CallbackInfo ci) { - Map lootTableToKeyBuilder = new HashMap<>(); - this.tables.forEach((lootTable, key) -> lootTableToKeyBuilder.put(key, lootTable)); - this.lootTableToKey = ImmutableMap.copyOf(lootTableToKeyBuilder); - } -} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableMixin.java index c756224a..69bd4778 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableMixin.java @@ -3,10 +3,12 @@ package io.izzel.arclight.common.mixin.core.world.level.storage.loot; import io.izzel.arclight.common.bridge.core.world.storage.loot.LootTableBridge; import io.izzel.arclight.mixin.Eject; import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import org.bukkit.craftbukkit.v.event.CraftEventFactory; @@ -19,21 +21,23 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import javax.annotation.Nullable; import java.util.List; @Mixin(LootTable.class) public abstract class LootTableMixin implements LootTableBridge { // @formatter:off + @Shadow @Final @Nullable private ResourceLocation randomSequence; @Shadow @Final static Logger LOGGER; - @Shadow public abstract ObjectArrayList getRandomItems(LootContext p_230923_); + @Shadow protected abstract ObjectArrayList getRandomItems(LootContext p_230923_); @Shadow protected abstract List getAvailableSlots(Container p_230920_, RandomSource p_230921_); @Shadow protected abstract void shuffleAndSplitItems(ObjectArrayList p_230925_, int p_230926_, RandomSource p_230927_); // @formatter:on @Eject(method = "fill", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/storage/loot/LootTable;getRandomItems(Lnet/minecraft/world/level/storage/loot/LootContext;)Lit/unimi/dsi/fastutil/objects/ObjectArrayList;")) private ObjectArrayList arclight$nonPluginEvent(LootTable lootTable, LootContext context, CallbackInfo ci, Container inv) { - ObjectArrayList list = lootTable.getRandomItems(context); + ObjectArrayList list = this.getRandomItems(context); if (!context.hasParam(LootContextParams.ORIGIN) && !context.hasParam(LootContextParams.THIS_ENTITY)) { return list; } @@ -46,7 +50,8 @@ public abstract class LootTableMixin implements LootTableBridge { } } - public void fillInventory(Container inv, LootContext context, boolean plugin) { + public void fillInventory(Container inv, LootParams lootparams, long i, boolean plugin) { + LootContext context = (new LootContext.Builder(lootparams)).withOptionalRandomSeed(i).create(this.randomSequence); ObjectArrayList objectarraylist = this.getRandomItems(context); RandomSource randomsource = context.getRandom(); LootGenerateEvent event = CraftEventFactory.callLootGenerateEvent(inv, (LootTable) (Object) this, context, objectarraylist, plugin); @@ -71,9 +76,4 @@ public abstract class LootTableMixin implements LootTableBridge { } } } - - @Override - public void bridge$fillInventory(Container inv, LootContext context, boolean plugin) { - this.fillInventory(inv, context, plugin); - } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/BaseSpawnerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/BaseSpawnerMixin.java index 665e867d..96b2d505 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/BaseSpawnerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/spawner/BaseSpawnerMixin.java @@ -123,7 +123,7 @@ public abstract class BaseSpawnerMixin { if (event != null && spawnData.getEntityToSpawn().size() == 1 && spawnData.getEntityToSpawn().contains("id", 8)) { ((Mob) entity).finalizeSpawn(level, event.getDifficulty(), event.getSpawnType(), event.getSpawnData(), event.getSpawnTag()); } - if (((WorldBridge) mob.level).bridge$spigotConfig().nerfSpawnerMobs) { + if (((WorldBridge) mob.level()).bridge$spigotConfig().nerfSpawnerMobs) { ((MobEntityBridge) mob).bridge$setAware(false); } } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSourceMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSourceMixin.java index 583c9bab..8703004f 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSourceMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/storage/LevelStorageSourceMixin.java @@ -4,10 +4,16 @@ import io.izzel.arclight.common.bridge.core.world.storage.LevelStorageSourceBrid import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.storage.LevelStorageSource; +import net.minecraft.world.level.validation.ContentValidationException; +import net.minecraft.world.level.validation.DirectoryValidator; +import net.minecraft.world.level.validation.ForbiddenSymlinkInfo; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import java.io.IOException; +import java.nio.file.Path; +import java.util.List; @Mixin(LevelStorageSource.class) public abstract class LevelStorageSourceMixin implements LevelStorageSourceBridge { @@ -16,8 +22,22 @@ public abstract class LevelStorageSourceMixin implements LevelStorageSourceBridg // @formatter:off @Shadow public abstract LevelStorageSource.LevelStorageAccess createAccess(String saveName) throws IOException; + @Shadow protected abstract Path getLevelPath(String p_289974_); + @Shadow @Final private DirectoryValidator worldDirValidator; // @formatter:on + public LevelStorageSource.LevelStorageAccess validateAndCreateAccess(String s, ResourceKey dimensionType) throws IOException, ContentValidationException { + Path path = this.getLevelPath(s); + List list = this.worldDirValidator.validateSave(path, true); + if (!list.isEmpty()) { + throw new ContentValidationException(path, list); + } else { + LevelStorageSource.LevelStorageAccess save = createAccess(s); + ((LevelStorageAccessBridge) save).bridge$setDimType(dimensionType); + return save; + } + } + public LevelStorageSource.LevelStorageAccess createAccess(String saveName, ResourceKey world) throws IOException { LevelStorageSource.LevelStorageAccess save = createAccess(saveName); ((LevelStorageAccessBridge) save).bridge$setDimType(world); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/EntityMixin_ActivationRange.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/EntityMixin_ActivationRange.java index 862f0032..4635fb91 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/EntityMixin_ActivationRange.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/EntityMixin_ActivationRange.java @@ -21,7 +21,7 @@ public abstract class EntityMixin_ActivationRange implements EntityBridge_Activa // @formatter:off @Shadow public abstract void refreshDimensions(); @Shadow public int tickCount; - @Shadow public Level level; + @Shadow public abstract Level level(); @Shadow public abstract AABB getBoundingBox(); @Shadow public abstract void discard(); // @formatter:on diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/FireworkRocketEntityMixin_ActivationRange.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/FireworkRocketEntityMixin_ActivationRange.java index 38fe485f..b2d6282e 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/FireworkRocketEntityMixin_ActivationRange.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/FireworkRocketEntityMixin_ActivationRange.java @@ -19,7 +19,7 @@ public abstract class FireworkRocketEntityMixin_ActivationRange extends EntityMi public void inactiveTick() { super.inactiveTick(); ++this.life; - if (!this.level.isClientSide && this.life > this.lifetime) { + if (!this.level().isClientSide && this.life > this.lifetime) { if (!CraftEventFactory.callFireworkExplodeEvent((FireworkRocketEntity)(Object) this).isCancelled()) { this.explode(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/ItemEntityMixin_ActivationRange.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/ItemEntityMixin_ActivationRange.java index dd43f53b..d626f577 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/ItemEntityMixin_ActivationRange.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/ItemEntityMixin_ActivationRange.java @@ -27,15 +27,15 @@ public abstract class ItemEntityMixin_ActivationRange extends EntityMixin_Activa @Inject(method = "(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", at = @At("RETURN")) private void activationRange$init(EntityType entityType, Level world, CallbackInfo ci) { - if (DistValidate.isValid(this.level)) { - this.lifespan = ((WorldBridge) this.level).bridge$spigotConfig().itemDespawnRate; + if (DistValidate.isValid(this.level())) { + this.lifespan = ((WorldBridge) this.level()).bridge$spigotConfig().itemDespawnRate; } } @Inject(method = "(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN")) private void activationRange$init(Level worldIn, double x, double y, double z, ItemStack stack, CallbackInfo ci) { - if (DistValidate.isValid(this.level) && this.lifespan == 6000) { - this.lifespan = ((WorldBridge) this.level).bridge$spigotConfig().itemDespawnRate; + if (DistValidate.isValid(this.level()) && this.lifespan == 6000) { + this.lifespan = ((WorldBridge) this.level()).bridge$spigotConfig().itemDespawnRate; } } @@ -49,7 +49,7 @@ public abstract class ItemEntityMixin_ActivationRange extends EntityMixin_Activa if (this.age != -32768) this.age += elapsedTicks; this.lastTick = ArclightConstants.currentTick; - if (!this.level.isClientSide && this.age >= this.lifespan) { + if (!this.level().isClientSide && this.age >= this.lifespan) { int hook = ForgeEventFactory.onItemExpire((ItemEntity) (Object) this, this.getItem()); if (hook < 0) this.discard(); else this.lifespan += hook; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/VillagerEntityMixin_ActivationRange.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/VillagerEntityMixin_ActivationRange.java index efd89da8..3b188511 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/VillagerEntityMixin_ActivationRange.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/optimization/general/activationrange/entity/VillagerEntityMixin_ActivationRange.java @@ -15,7 +15,7 @@ public abstract class VillagerEntityMixin_ActivationRange extends EntityMixin_Ac @Override public void inactiveTick() { - if (((WorldBridge) this.level).bridge$spigotConfig().tickInactiveVillagers + if (((WorldBridge) this.level()).bridge$spigotConfig().tickInactiveVillagers && ((Villager) (Object) this).isEffectiveAi()) { this.customServerAiStep(); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/event/EntityEventDispatcher.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/event/EntityEventDispatcher.java index 56d176e9..1aa4a241 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/event/EntityEventDispatcher.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/event/EntityEventDispatcher.java @@ -36,7 +36,7 @@ public class EntityEventDispatcher { List itemStackList = XmapList.create((List) drops, ItemStack.class, (ItemEntity entity) -> CraftItemStack.asCraftMirror(entity.getItem()), itemStack -> { - ItemEntity itemEntity = new ItemEntity(livingEntity.level, livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), CraftItemStack.asNMSCopy(itemStack)); + ItemEntity itemEntity = new ItemEntity(livingEntity.level(), livingEntity.getX(), livingEntity.getY(), livingEntity.getZ(), CraftItemStack.asNMSCopy(itemStack)); itemEntity.setDefaultPickUpDelay(); return itemEntity; }); diff --git a/arclight-common/src/main/resources/META-INF/accesstransformer.cfg b/arclight-common/src/main/resources/META-INF/accesstransformer.cfg index e2f448ca..5c3e7401 100644 --- a/arclight-common/src/main/resources/META-INF/accesstransformer.cfg +++ b/arclight-common/src/main/resources/META-INF/accesstransformer.cfg @@ -267,7 +267,6 @@ public-f net.minecraft.server.MinecraftServer f_129744_ public net.minecraft.server.MinecraftServer f_129738_ protected-f net.minecraft.server.MinecraftServer f_129749_ public net.minecraft.server.MinecraftServer f_129759_ -public net.minecraft.server.MinecraftServer f_129762_ public net.minecraft.server.MinecraftServer f_129740_ public net.minecraft.server.MinecraftServer m_129940_(Lnet/minecraft/server/level/progress/ChunkProgressListener;)V public net.minecraft.world.level.chunk.storage.RegionFileStorage f_63699_ @@ -622,3 +621,45 @@ public net.minecraft.world.entity.monster.Guardian$GuardianAttackGoal f_32868_ public net.minecraft.world.level.block.entity.SuspiciousSandBlockEntity f_271119_ public net.minecraft.world.level.block.entity.SuspiciousSandBlockEntity f_271461_ public net.minecraft.world.level.block.entity.SuspiciousSandBlockEntity f_271354_ +# Bukkit 1.20 +public net.minecraft.server.level.ServerLevel m_260813_(Lnet/minecraft/world/level/entity/EntityTypeTest;Ljava/util/function/Predicate;Ljava/util/List;)V +public net.minecraft.server.packs.repository.Pack f_244124_ +public net.minecraft.util.datafix.fixes.BlockStateData m_14942_(ILjava/lang/String;[Ljava/lang/String;)V +public net.minecraft.world.entity.Display$BlockDisplay m_269134_()Lnet/minecraft/world/level/block/state/BlockState; +public net.minecraft.world.entity.Display$BlockDisplay m_269329_(Lnet/minecraft/world/level/block/state/BlockState;)V +public net.minecraft.world.entity.Display$ItemDisplay m_269568_()Lnet/minecraft/world/item/ItemStack; +public net.minecraft.world.entity.Display$ItemDisplay m_269386_()Lnet/minecraft/world/item/ItemDisplayContext; +public net.minecraft.world.entity.Display$TextDisplay m_269375_()I +public net.minecraft.world.entity.Display$TextDisplay m_269327_()B +public net.minecraft.world.entity.Display$TextDisplay m_269517_()I +public net.minecraft.world.entity.Display$TextDisplay m_269000_()Lnet/minecraft/network/chat/Component; +public net.minecraft.world.entity.Display m_269218_()Lnet/minecraft/world/entity/Display$BillboardConstraints; +public net.minecraft.world.entity.Display m_269155_()F +public net.minecraft.world.entity.animal.sniffer.Sniffer m_271905_()Ljava/util/Optional; +public net.minecraft.world.entity.animal.sniffer.Sniffer m_272270_()Z +public net.minecraft.world.entity.animal.sniffer.Sniffer m_272217_()Ljava/util/stream/Stream; +public net.minecraft.world.entity.animal.sniffer.Sniffer m_271917_()Lnet/minecraft/world/entity/animal/sniffer/Sniffer$State; +public net.minecraft.world.entity.animal.sniffer.Sniffer m_271874_(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/entity/animal/sniffer/Sniffer; +public net.minecraft.world.entity.item.FallingBlockEntity f_31940_ +public net.minecraft.world.entity.item.FallingBlockEntity f_149641_ +public net.minecraft.world.entity.player.Player f_36081_ +public net.minecraft.world.entity.vehicle.MinecartTNT m_38688_(D)V +public net.minecraft.world.entity.vehicle.MinecartTNT f_38647_ +public net.minecraft.world.flag.FeatureFlag f_244012_ +public net.minecraft.world.flag.FeatureFlag f_243952_ +public net.minecraft.world.flag.FeatureFlagRegistry f_244560_ +public net.minecraft.world.item.DebugStickItem m_150802_(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;ZLnet/minecraft/world/item/ItemStack;)Z +public net.minecraft.world.level.StructureManager f_220460_ +public net.minecraft.world.level.block.entity.BrushableBlockEntity f_276563_ +public net.minecraft.world.level.block.entity.BrushableBlockEntity f_276466_ +public net.minecraft.world.level.block.entity.BrushableBlockEntity f_276487_ +public net.minecraft.world.level.block.entity.DecoratedPotBlockEntity f_283890_ +public net.minecraft.world.level.block.entity.BellBlockEntity f_58818_ +public net.minecraft.world.level.block.entity.BellBlockEntity f_58819_ +public net.minecraft.world.level.block.entity.JukeboxBlockEntity f_238637_ +public net.minecraft.world.level.block.entity.JukeboxBlockEntity f_238572_ +public net.minecraft.world.level.block.entity.JukeboxBlockEntity f_238695_ +public net.minecraft.world.level.block.entity.SignBlockEntity f_59722_ +public net.minecraft.world.level.block.entity.SkullBlockEntity f_262250_ +public net.minecraft.world.level.material.MapColor f_283862_ +private-f net.minecraft.server.MinecraftServer f_129762_ diff --git a/arclight-common/src/main/resources/mixins.arclight.core.json b/arclight-common/src/main/resources/mixins.arclight.core.json index 21a504ee..7e19ab01 100644 --- a/arclight-common/src/main/resources/mixins.arclight.core.json +++ b/arclight-common/src/main/resources/mixins.arclight.core.json @@ -272,7 +272,6 @@ "world.inventory.HorseInventoryContainerMixin", "world.inventory.ItemCombinerMixin", "world.inventory.LecternContainerMixin", - "world.inventory.LegacySmithingMenuMixin", "world.inventory.LoomContainer1Mixin", "world.inventory.LoomContainer2Mixin", "world.inventory.LoomContainerMixin", @@ -324,7 +323,6 @@ "world.item.crafting.ShapedRecipeMixin", "world.item.crafting.ShapelessRecipeMixin", "world.item.crafting.SmeltingRecipeMixin", - "world.item.crafting.SmithingRecipeMixin", "world.item.crafting.SmithingTransformRecipeMixin", "world.item.crafting.SmithingTrimRecipeMixin", "world.item.crafting.SmokingRecipeMixin", @@ -479,7 +477,7 @@ "world.level.redstone.NeighborUpdaterMixin", "world.level.saveddata.maps.MapDataMixin", "world.level.saveddata.maps.MapItemSavedData_HoldingPlayerMixin", - "world.level.storage.loot.LootTableManagerMixin", + "world.level.storage.loot.LootDataManagerMixin", "world.level.storage.loot.LootTableMixin", "world.level.storage.loot.entries.LootEntry_SerializerMixin", "world.level.storage.loot.functions.LootingEnchantBonusMixin", diff --git a/arclight-forge/build.gradle b/arclight-forge/build.gradle index 479873ea..117616cd 100644 --- a/arclight-forge/build.gradle +++ b/arclight-forge/build.gradle @@ -42,8 +42,8 @@ repositories { mavenCentral() } -def embedLibs = [/*"org.spongepowered:mixin:$mixinVersion", */ 'org.yaml:snakeyaml:1.33', - 'org.xerial:sqlite-jdbc:3.41.2.2', 'com.mysql:mysql-connector-j:8.0.32', +def embedLibs = [/*"org.spongepowered:mixin:$mixinVersion", */ 'org.yaml:snakeyaml:2.0', + 'org.xerial:sqlite-jdbc:3.42.0.0', 'com.mysql:mysql-connector-j:8.0.33', /*'commons-lang:commons-lang:2.6',*/ 'com.googlecode.json-simple:json-simple:1.1.1', 'org.apache.logging.log4j:log4j-jul:2.17.2', 'net.md-5:SpecialSource:1.11.0', 'org.jline:jline-terminal-jansi:3.12.1', 'org.fusesource.jansi:jansi:1.18', @@ -74,6 +74,7 @@ dependencies { implementation 'org.jetbrains:annotations:23.0.0' implementation 'org.spongepowered:mixin:0.8.3' implementation 'org.apache.logging.log4j:log4j-jul:2.17.2' + implementation "net.minecraftforge:fmlloader:${minecraftVersion}-${forgeVersion}" for (def lib : embedLibs) { installer lib } diff --git a/arclight-forge/src/main/java/io/izzel/arclight/boot/AbstractBootstrap.java b/arclight-forge/src/main/java/io/izzel/arclight/boot/AbstractBootstrap.java index 4f5692bd..1e2e76ad 100644 --- a/arclight-forge/src/main/java/io/izzel/arclight/boot/AbstractBootstrap.java +++ b/arclight-forge/src/main/java/io/izzel/arclight/boot/AbstractBootstrap.java @@ -90,7 +90,7 @@ public class AbstractBootstrap { } protected void setupMod() throws Exception { - ArclightVersion.setVersion(ArclightVersion.EXECUTIONS); + ArclightVersion.setVersion(ArclightVersion.TRIALS); try (InputStream stream = getClass().getModule().getResourceAsStream("/META-INF/MANIFEST.MF")) { Manifest manifest = new Manifest(stream); Attributes attributes = manifest.getMainAttributes(); diff --git a/arclight-forge/src/main/java/io/izzel/arclight/boot/application/ApplicationBootstrap.java b/arclight-forge/src/main/java/io/izzel/arclight/boot/application/ApplicationBootstrap.java index 45e19751..80362068 100644 --- a/arclight-forge/src/main/java/io/izzel/arclight/boot/application/ApplicationBootstrap.java +++ b/arclight-forge/src/main/java/io/izzel/arclight/boot/application/ApplicationBootstrap.java @@ -6,6 +6,7 @@ import io.izzel.arclight.boot.AbstractBootstrap; import io.izzel.arclight.i18n.ArclightConfig; import io.izzel.arclight.i18n.ArclightLocale; +import java.util.Arrays; import java.util.ServiceLoader; import java.util.function.Consumer; @@ -36,6 +37,10 @@ public class ApplicationBootstrap extends AbstractBootstrap implements Consumer< try { this.setupMod(); this.dirtyHacks(); + int targetIndex = Arrays.asList(args).indexOf("--launchTarget"); + if (targetIndex >= 0 && targetIndex < args.length - 1) { + args[targetIndex + 1] = "arclightserver"; + } ServiceLoader.load(getClass().getModule().getLayer(), Consumer.class).stream() .filter(it -> !it.type().getName().contains("arclight")) .findFirst().orElseThrow().get().accept(args); diff --git a/arclight-forge/src/main/java/io/izzel/arclight/boot/application/ArclightLaunchHandler.java b/arclight-forge/src/main/java/io/izzel/arclight/boot/application/ArclightLaunchHandler.java new file mode 100644 index 00000000..288c914b --- /dev/null +++ b/arclight-forge/src/main/java/io/izzel/arclight/boot/application/ArclightLaunchHandler.java @@ -0,0 +1,17 @@ +package io.izzel.arclight.boot.application; + +import net.minecraftforge.fml.loading.targets.ForgeServerLaunchHandler; + +public class ArclightLaunchHandler extends ForgeServerLaunchHandler { + + @Override + public String name() { + return "arclightserver"; + } + + @Override + protected String[] preLaunch(String[] arguments, ModuleLayer layer) { + // skip the log4j configuration reloading + return arguments; + } +} diff --git a/arclight-forge/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService b/arclight-forge/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService new file mode 100644 index 00000000..9f8cb380 --- /dev/null +++ b/arclight-forge/src/main/resources/META-INF/services/cpw.mods.modlauncher.api.ILaunchHandlerService @@ -0,0 +1 @@ +io.izzel.arclight.boot.application.ArclightLaunchHandler \ No newline at end of file diff --git a/build.gradle b/build.gradle index c3d87fb1..24f21197 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ allprojects { group 'io.izzel.arclight' - version '1.0.5' + version '1.0.0-SNAPSHOT' def getGitHash = { -> def stdout = new ByteArrayOutputStream() @@ -13,12 +13,12 @@ allprojects { ext { agpVersion = '1.23' - minecraftVersion = '1.19.4' - forgeVersion = '45.1.0' - apiVersion = '1.5.2' + minecraftVersion = '1.20' + forgeVersion = '46.0.1' + apiVersion = '1.5.4' toolsVersion = '1.3.0' mixinVersion = '0.8.5' - versionName = 'executions' + versionName = 'trails' gitHash = getGitHash() } diff --git a/gradle.properties b/gradle.properties index effc1594..80bdfea3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ org.gradle.jvmargs=-Xmx4g -Dfile.encoding=utf-8 -forge_gradle_version=5.1.+ \ No newline at end of file +forge_gradle_version=[6.0,6.2) \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ed8bcb48..2391bb84 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.6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/i18n-config/src/main/resources/META-INF/i18n/en_us.conf b/i18n-config/src/main/resources/META-INF/i18n/en_us.conf index 3b4b70fa..e6676b8c 100644 --- a/i18n-config/src/main/resources/META-INF/i18n/en_us.conf +++ b/i18n-config/src/main/resources/META-INF/i18n/en_us.conf @@ -18,6 +18,7 @@ release-name { Horn = "角 (Horn)" GreatHorn = "大角 (Great Horn)" Executions = "折威 (Executions)" + Trials = "顿顽 (Trials)" } java { deprecated = [ diff --git a/i18n-config/src/main/resources/META-INF/i18n/zh_cn.conf b/i18n-config/src/main/resources/META-INF/i18n/zh_cn.conf index b257a1ed..712f4595 100644 --- a/i18n-config/src/main/resources/META-INF/i18n/zh_cn.conf +++ b/i18n-config/src/main/resources/META-INF/i18n/zh_cn.conf @@ -16,6 +16,7 @@ release-name { Horn = "角" GreatHorn = "大角" Executions = "折威" + Trials = "顿顽" } java { deprecated = [