From ee68f941e0871904da4d31f03a05a01aff294055 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Sun, 7 Jul 2024 13:18:37 +0800 Subject: [PATCH] Update upstream --- .../core/world/entity/animal/WolfMixin.java | 10 +++++++ .../boss/enderdragon/EnderDragonMixin.java | 5 ++-- .../world/entity/monster/BoggedMixin.java | 30 +++++++++++++++++++ .../core/world/level/ExplosionMixin.java | 8 ++--- .../common/mod/server/BukkitRegistry.java | 28 ----------------- .../src/main/resources/arclight.accesswidener | 5 ++++ .../main/resources/mixins.arclight.core.json | 1 + .../arclight/boot/asm/EnumDefinalizer.java | 1 - buildSrc/build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 10 files changed, 53 insertions(+), 39 deletions(-) create mode 100644 arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/BoggedMixin.java diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/WolfMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/WolfMixin.java index 6ab9aad93..4e59a6f9d 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/WolfMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/animal/WolfMixin.java @@ -43,4 +43,14 @@ public abstract class WolfMixin extends TameableAnimalMixin { var ret = instance.nextInt(i); return ret == 0 && this.bridge$common$animalTameEvent(player) ? ret : 1; } + + @Inject(method = "mobInteract", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/Wolf;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;")) + private void arclight$forceDropPre(Player player, InteractionHand interactionHand, CallbackInfoReturnable cir) { + this.forceDrops = true; + } + + @Inject(method = "mobInteract", at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/entity/animal/Wolf;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;")) + private void arclight$forceDropPost(Player player, InteractionHand interactionHand, CallbackInfoReturnable cir) { + this.forceDrops = false; + } } 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 47ce80cbb..f01145ff7 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 @@ -24,6 +24,7 @@ import net.minecraft.world.phys.Vec3; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v.block.CraftBlock; +import org.bukkit.craftbukkit.v.event.CraftEventFactory; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRemoveEvent; @@ -106,9 +107,7 @@ private boolean checkWalls(final AABB axisalignedbb) { if (!flag2) { return flag; } - final org.bukkit.entity.Entity bukkitEntity = this.getBukkitEntity(); - final EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0.0f); - bukkitEntity.getServer().getPluginManager().callEvent(event); + final EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent((EnderDragon) (Object) this, destroyedBlocks, 0.0f, explosionSource.getBlockInteraction()); if (event.isCancelled()) { return flag; } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/BoggedMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/BoggedMixin.java new file mode 100644 index 000000000..55a059fed --- /dev/null +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/monster/BoggedMixin.java @@ -0,0 +1,30 @@ +package io.izzel.arclight.common.mixin.core.world.entity.monster; + +import io.izzel.arclight.common.bridge.core.network.datasync.SynchedEntityDataBridge; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.monster.Bogged; +import net.minecraft.world.entity.player.Player; +import org.bukkit.craftbukkit.v.event.CraftEventFactory; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Bogged.class) +public abstract class BoggedMixin extends AbstractSkeletonMixin { + + @Shadow @Final private static EntityDataAccessor DATA_SHEARED; + + @Inject(method = "mobInteract", cancellable = true, require = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/monster/Bogged;shear(Lnet/minecraft/sounds/SoundSource;)V")) + private void arclight$shearEvent(Player player, InteractionHand interactionHand, CallbackInfoReturnable cir) { + if (!CraftEventFactory.handlePlayerShearEntityEvent(player, (Entity) (Object) this, player.getItemInHand(interactionHand), interactionHand)) { + ((SynchedEntityDataBridge) this.getEntityData()).bridge$markDirty(DATA_SHEARED); + cir.setReturnValue(InteractionResult.PASS); + } + } +} diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/ExplosionMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/ExplosionMixin.java index ac18a5434..1b4821265 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/ExplosionMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/ExplosionMixin.java @@ -20,7 +20,6 @@ import net.minecraft.world.level.block.TntBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.craftbukkit.v.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v.event.CraftEventFactory; @@ -60,6 +59,7 @@ public abstract class ExplosionMixin implements ExplosionBridge { @Accessor("radius") public abstract void bridge$setSize(float size); @Accessor("blockInteraction") public abstract Explosion.BlockInteraction bridge$getMode(); @Shadow @Final @Mutable private DamageSource damageSource; + @Shadow public abstract Explosion.BlockInteraction getBlockInteraction(); // @formatter:on public float yield; @@ -191,16 +191,14 @@ private boolean callBlockExplodeEvent() { List bukkitBlocks; if (exploder != null) { - EntityExplodeEvent event = new EntityExplodeEvent(exploder, location, blockList, this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F); - Bukkit.getPluginManager().callEvent(event); + EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blockList, this.yield, this.getBlockInteraction()); cancelled = event.isCancelled(); bukkitBlocks = event.blockList(); this.yield = event.getYield(); } else { org.bukkit.block.Block block = location.getBlock(); org.bukkit.block.BlockState blockState = (((DamageSourceBridge) damageSource).bridge$directBlockState() != null) ? ((DamageSourceBridge) damageSource).bridge$directBlockState() : block.getState(); - BlockExplodeEvent event = new BlockExplodeEvent(block, blockState, blockList, this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F); - Bukkit.getPluginManager().callEvent(event); + BlockExplodeEvent event = CraftEventFactory.callBlockExplodeEvent(block, blockState, blockList, this.yield, this.getBlockInteraction()); cancelled = event.isCancelled(); bukkitBlocks = event.blockList(); this.yield = event.getYield(); diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/BukkitRegistry.java b/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/BukkitRegistry.java index 7eae3a80e..343bfeab8 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/BukkitRegistry.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mod/server/BukkitRegistry.java @@ -24,7 +24,6 @@ import net.minecraft.stats.Stats; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase; -import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.CookingBookCategory; @@ -48,7 +47,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Pose; import org.bukkit.entity.SpawnCategory; -import org.bukkit.entity.Villager; import org.bukkit.potion.PotionType; import java.lang.reflect.Field; @@ -87,7 +85,6 @@ public static void registerAll(DedicatedServer console) { loadPotions(); loadEnchantmentTargets(); loadEntities(); - loadVillagerProfessions(); loadBiomes(console); loadArts(console); loadStats(); @@ -264,31 +261,6 @@ private static void loadBiomes(DedicatedServer console) { ArclightServer.LOGGER.info("registry.biome", newTypes.size()); } - private static void loadVillagerProfessions() { - int i = Villager.Profession.values().length; - List newTypes = new ArrayList<>(); - Field key = Arrays.stream(Villager.Profession.class.getDeclaredFields()).filter(it -> it.getName().equals("key")).findAny().orElse(null); - long keyOffset = Unsafe.objectFieldOffset(key); - for (VillagerProfession villagerProfession : BuiltInRegistries.VILLAGER_PROFESSION) { - var location = BuiltInRegistries.VILLAGER_PROFESSION.getKey(villagerProfession); - String name = ResourceLocationUtil.standardize(location); - Villager.Profession profession; - try { - profession = Villager.Profession.valueOf(name); - } catch (Throwable t) { - profession = null; - } - if (profession == null) { - profession = EnumHelper.makeEnum(Villager.Profession.class, name, i++, ImmutableList.of(), ImmutableList.of()); - newTypes.add(profession); - Unsafe.putObject(profession, keyOffset, CraftNamespacedKey.fromMinecraft(location)); - ArclightServer.LOGGER.debug("Registered {} as villager profession {}", location, profession); - } - } - EnumHelper.addEnums(Villager.Profession.class, newTypes); - ArclightServer.LOGGER.info("registry.villager-profession", newTypes.size()); - } - public static void registerEnvironments(Registry registry) { int i = World.Environment.values().length; List newTypes = new ArrayList<>(); diff --git a/arclight-common/src/main/resources/arclight.accesswidener b/arclight-common/src/main/resources/arclight.accesswidener index 517195cfa..ae0a10ae2 100644 --- a/arclight-common/src/main/resources/arclight.accesswidener +++ b/arclight-common/src/main/resources/arclight.accesswidener @@ -4,6 +4,11 @@ accessible field net/minecraft/core/component/DataComponentPatch map Lit/unimi/d accessible field net/minecraft/core/component/DataComponentPatch$Builder map Lit/unimi/dsi/fastutil/objects/Reference2ObjectMap; accessible field net/minecraft/world/level/block/entity/HopperBlockEntity facing Lnet/minecraft/core/Direction; accessible field net/minecraft/world/item/JukeboxSongPlayer ticksSinceSongStarted J +accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner normalConfig Lnet/minecraft/world/level/block/entity/trialspawner/TrialSpawnerConfig; +accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner ominousConfig Lnet/minecraft/world/level/block/entity/trialspawner/TrialSpawnerConfig; +accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner requiredPlayerRange I +accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner targetCooldownLength I +accessible field net/minecraft/world/level/block/entity/trialspawner/TrialSpawner isOminous Z # Arclight 1.20.4 accessible method net/minecraft/world/level/block/entity/HopperBlockEntity setCooldown (I)V accessible class net/minecraft/world/inventory/MenuType$MenuSupplier diff --git a/arclight-common/src/main/resources/mixins.arclight.core.json b/arclight-common/src/main/resources/mixins.arclight.core.json index 8617e2934..4ca365c11 100644 --- a/arclight-common/src/main/resources/mixins.arclight.core.json +++ b/arclight-common/src/main/resources/mixins.arclight.core.json @@ -209,6 +209,7 @@ "world.entity.item.ItemEntityMixin", "world.entity.item.PrimedTntMixin", "world.entity.monster.AbstractSkeletonMixin", + "world.entity.monster.BoggedMixin", "world.entity.monster.CaveSpiderMixin", "world.entity.monster.CreeperMixin", "world.entity.monster.ElderGuardianMixin", diff --git a/bootstrap/src/main/java/io/izzel/arclight/boot/asm/EnumDefinalizer.java b/bootstrap/src/main/java/io/izzel/arclight/boot/asm/EnumDefinalizer.java index 15af212d0..d88698099 100644 --- a/bootstrap/src/main/java/io/izzel/arclight/boot/asm/EnumDefinalizer.java +++ b/bootstrap/src/main/java/io/izzel/arclight/boot/asm/EnumDefinalizer.java @@ -13,7 +13,6 @@ public class EnumDefinalizer implements Implementer { "org/bukkit/Material", "org/bukkit/potion/PotionType", "org/bukkit/entity/EntityType", - "org/bukkit/entity/Villager$Profession", "org/bukkit/block/Biome", "org/bukkit/Art", "org/bukkit/Statistic", diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 9f7c0b9e5..742ef5613 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -24,5 +24,5 @@ dependencies { implementation 'org.cadixdev:lorenz:0.5.8' implementation 'org.cadixdev:at:0.1.0-rc1' implementation 'net.fabricmc:lorenz-tiny:4.0.2' - implementation "dev.architectury:architectury-loom:1.6-SNAPSHOT" + implementation "dev.architectury:architectury-loom:1.7-SNAPSHOT" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 30a7cf93a..e16e18e25 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-8.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists