From 9eda89a376020804831e88aaefd5472d9911c3a5 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Sat, 28 Sep 2024 03:37:09 +0800 Subject: [PATCH] 24w39a --- .../CarpetLoggerRestriction.java | 13 ++++++-- .../loggerRestriction/RestrictiveLogger.java | 2 +- .../LifeTimeStandardCarpetHUDLogger.java | 5 +-- .../tweaks/loggerRestriction/LoggerMixin.java | 4 +-- .../deathdamage/ExperienceOrbEntityMixin.java | 3 +- .../lifetime/deathdamage/ItemEntityMixin.java | 5 ++- .../removal/mobpickup/DolphinEntityMixin.java | 3 +- .../removal/mobpickup/FoxEntityMixin.java | 3 +- .../removal/mobpickup/ItemEntityMixin.java | 6 ++-- .../removal/mobpickup/MobEntityMixin.java | 3 +- .../breeding/FoxEntityMateGoalMixin.java | 4 +++ .../spawning/mobdrop/EntityMixin.java | 19 ++++++----- .../commandblock/CommandBlockMixin.java | 15 ++++++++- .../LivingEntityAndPlayerEntityMixins.java | 23 ++++++++++--- .../logger/damage/LivingEntityMixin.java | 9 ++--- .../logger/damage/PlayerEntityMixin.java | 7 ++-- .../damage/ServerPlayerEntityMixin.java | 7 ++-- .../mixins/logger/item/ItemEntityMixin.java | 13 ++++---- .../xporb/ExperienceOrbEntityMixin.java | 13 ++++---- .../FarmLandBlockMixin.java | 33 ++++++++++++------- .../EnderDragonEntityMixin.java | 14 ++++++-- .../renewableElytra/PhantomEntityMixin.java | 26 +++++++++++++-- .../voidDamageAmount/LivingEntityMixin.java | 4 +++ .../WitherEntityMixin.java | 17 ++++++++-- .../carpettisaddition/utils/Messenger.java | 7 +++- .../utils/entityfilter/EntityFilter.java | 13 +++++--- .../mobpickup/InventoryOwnerMixin.java | 3 +- .../removeentity/ChestBoatEntityMixin.java | 15 +++++++-- .../deathdamage/VehicleEntityMixin.java | 4 +++ .../InfestedStatusEffectMixin.java | 6 +++- versions/future/gradle.properties | 10 +++--- 31 files changed, 227 insertions(+), 82 deletions(-) diff --git a/src/main/java/carpettisaddition/helpers/carpet/loggerRestriction/CarpetLoggerRestriction.java b/src/main/java/carpettisaddition/helpers/carpet/loggerRestriction/CarpetLoggerRestriction.java index 57396a8b6..ffe5aaa50 100644 --- a/src/main/java/carpettisaddition/helpers/carpet/loggerRestriction/CarpetLoggerRestriction.java +++ b/src/main/java/carpettisaddition/helpers/carpet/loggerRestriction/CarpetLoggerRestriction.java @@ -21,10 +21,12 @@ package carpettisaddition.helpers.carpet.loggerRestriction; import carpet.logging.Logger; +import carpettisaddition.CarpetTISAdditionMod; import carpettisaddition.translations.Translator; import carpettisaddition.utils.CarpetModUtil; import carpettisaddition.utils.Messenger; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.BaseText; import net.minecraft.text.ClickEvent; @@ -51,7 +53,14 @@ public static void addLoggerRuleSwitch(Logger logger, String ruleName, Supplier< translator.tr("permission_denied", logger.getLogName()), translator.tr("rule_hint", ruleName) ); - if (CarpetModUtil.canUseCarpetCommand(player.getCommandSource())) + if (!(player instanceof ServerPlayerEntity)) + { + CarpetTISAdditionMod.LOGGER.warn("subscriptionChecker receives a player {} that is not a ServerPlayerEntity", player); + return RestrictionCheckResult.ok(); + } + + ServerPlayerEntity serverPlayer = (ServerPlayerEntity)player; // for mc1.21.2+, where getCommandSource requires being on the server-side + if (CarpetModUtil.canUseCarpetCommand(serverPlayer.getCommandSource())) { Messenger.click( message, @@ -59,7 +68,7 @@ public static void addLoggerRuleSwitch(Logger logger, String ruleName, Supplier< ); } return RestrictionCheckResult.bool( - CarpetModUtil.canUseCommand(player.getCommandSource(), ruleValueProvider.get()), + CarpetModUtil.canUseCommand(serverPlayer.getCommandSource(), ruleValueProvider.get()), message ); }); diff --git a/src/main/java/carpettisaddition/helpers/carpet/loggerRestriction/RestrictiveLogger.java b/src/main/java/carpettisaddition/helpers/carpet/loggerRestriction/RestrictiveLogger.java index fb73dc142..2b669d7fd 100644 --- a/src/main/java/carpettisaddition/helpers/carpet/loggerRestriction/RestrictiveLogger.java +++ b/src/main/java/carpettisaddition/helpers/carpet/loggerRestriction/RestrictiveLogger.java @@ -25,7 +25,7 @@ public interface RestrictiveLogger { - void addSubscriptionRestriction(SubscriptionChecker subscriptionValidator); + void addSubscriptionRestriction(SubscriptionChecker subscriptionChecker); RestrictionCheckResult canPlayerSubscribe(PlayerEntity player, @Nullable String option); } diff --git a/src/main/java/carpettisaddition/logging/loggers/lifetime/LifeTimeStandardCarpetHUDLogger.java b/src/main/java/carpettisaddition/logging/loggers/lifetime/LifeTimeStandardCarpetHUDLogger.java index 5c9da3e63..8d5312805 100644 --- a/src/main/java/carpettisaddition/logging/loggers/lifetime/LifeTimeStandardCarpetHUDLogger.java +++ b/src/main/java/carpettisaddition/logging/loggers/lifetime/LifeTimeStandardCarpetHUDLogger.java @@ -30,6 +30,7 @@ import carpettisaddition.commands.lifetime.utils.LifeTimeTrackerUtil; import carpettisaddition.logging.TISAdditionLoggerRegistry; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.network.ServerPlayerEntity; public class LifeTimeStandardCarpetHUDLogger extends //#if MC >= 11500 @@ -52,8 +53,8 @@ public LifeTimeStandardCarpetHUDLogger() public void addPlayer(String playerName, String option) { super.addPlayer(playerName, option); - PlayerEntity player = this.playerFromName(playerName); - if (player != null) + ServerPlayerEntity player = this.playerFromName(playerName); + if (player instanceof ServerPlayerEntity) { if (!LifeTimeTrackerUtil.getEntityTypeFromName(option).isPresent()) { diff --git a/src/main/java/carpettisaddition/mixins/carpet/tweaks/loggerRestriction/LoggerMixin.java b/src/main/java/carpettisaddition/mixins/carpet/tweaks/loggerRestriction/LoggerMixin.java index 39df1fa72..62e357142 100644 --- a/src/main/java/carpettisaddition/mixins/carpet/tweaks/loggerRestriction/LoggerMixin.java +++ b/src/main/java/carpettisaddition/mixins/carpet/tweaks/loggerRestriction/LoggerMixin.java @@ -36,9 +36,9 @@ public abstract class LoggerMixin implements RestrictiveLogger { private final List subscriptionCheckers = Lists.newArrayList(); - public void addSubscriptionRestriction(SubscriptionChecker subscriptionValidator) + public void addSubscriptionRestriction(SubscriptionChecker subscriptionChecker) { - this.subscriptionCheckers.add(subscriptionValidator); + this.subscriptionCheckers.add(subscriptionChecker); } @Override diff --git a/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/ExperienceOrbEntityMixin.java b/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/ExperienceOrbEntityMixin.java index 3c8be11e8..18c66c62e 100644 --- a/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/ExperienceOrbEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/ExperienceOrbEntityMixin.java @@ -21,6 +21,7 @@ package carpettisaddition.mixins.command.lifetime.deathdamage; import carpettisaddition.commands.lifetime.interfaces.DamageableEntity; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.ExperienceOrbEntity; import net.minecraft.entity.damage.DamageSource; import org.spongepowered.asm.mixin.Mixin; @@ -44,7 +45,7 @@ public abstract class ExperienceOrbEntityMixin implements DamageableEntity //#endif ) ) - private void lifetimeTracker_recordDeathDamageSource_xpOrb(DamageSource source, float amount, CallbackInfoReturnable cir) + private void lifetimeTracker_recordDeathDamageSource_xpOrb(CallbackInfoReturnable cir, @Local(argsOnly = true) DamageSource source) { this.deathDamageSource = source; } diff --git a/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/ItemEntityMixin.java b/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/ItemEntityMixin.java index 73aa810b1..53794637f 100644 --- a/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/ItemEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/ItemEntityMixin.java @@ -21,9 +21,11 @@ package carpettisaddition.mixins.command.lifetime.deathdamage; import carpettisaddition.commands.lifetime.interfaces.DamageableEntity; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.damage.DamageSource; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -31,6 +33,7 @@ @Mixin(ItemEntity.class) public abstract class ItemEntityMixin implements DamageableEntity { + @Unique private DamageSource deathDamageSource; @Inject( @@ -44,7 +47,7 @@ public abstract class ItemEntityMixin implements DamageableEntity //#endif ) ) - private void lifetimeTracker_recordDeathDamageSource_item(DamageSource source, float amount, CallbackInfoReturnable cir) + private void lifetimeTracker_recordDeathDamageSource_item(CallbackInfoReturnable cir, @Local(argsOnly = true) DamageSource source) { this.deathDamageSource = source; } diff --git a/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/DolphinEntityMixin.java b/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/DolphinEntityMixin.java index 92968120e..641f767a1 100644 --- a/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/DolphinEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/DolphinEntityMixin.java @@ -22,6 +22,7 @@ import carpettisaddition.commands.lifetime.interfaces.LifetimeTrackerTarget; import carpettisaddition.commands.lifetime.removal.MobPickupRemovalReason; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; @@ -47,7 +48,7 @@ public DolphinEntityMixin(EntityType type, World world) target = "Lnet/minecraft/entity/passive/DolphinEntity;sendPickup(Lnet/minecraft/entity/Entity;I)V" ) ) - private void lifetimeTracker_recordRemoval_mobPickup_dolphinPickupItem(ItemEntity item, CallbackInfo ci) + private void lifetimeTracker_recordRemoval_mobPickup_dolphinPickupItem(CallbackInfo ci, @Local(argsOnly = true) ItemEntity item) { ((LifetimeTrackerTarget)item).recordRemoval(new MobPickupRemovalReason(this.getType())); } diff --git a/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/FoxEntityMixin.java b/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/FoxEntityMixin.java index a56012fd1..bb590dba1 100644 --- a/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/FoxEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/FoxEntityMixin.java @@ -22,6 +22,7 @@ import carpettisaddition.commands.lifetime.interfaces.LifetimeTrackerTarget; import carpettisaddition.commands.lifetime.removal.MobPickupRemovalReason; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; @@ -47,7 +48,7 @@ public FoxEntityMixin(EntityType type, World world) target = "Lnet/minecraft/entity/passive/FoxEntity;sendPickup(Lnet/minecraft/entity/Entity;I)V" ) ) - private void lifetimeTracker_recordRemoval_mobPickup_foxPickupItem(ItemEntity item, CallbackInfo ci) + private void lifetimeTracker_recordRemoval_mobPickup_foxPickupItem(CallbackInfo ci, @Local(argsOnly = true) ItemEntity item) { ((LifetimeTrackerTarget)item).recordRemoval(new MobPickupRemovalReason(this.getType())); } diff --git a/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/ItemEntityMixin.java b/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/ItemEntityMixin.java index 05aa7d8f8..2ed096244 100644 --- a/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/ItemEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/ItemEntityMixin.java @@ -22,6 +22,7 @@ import carpettisaddition.commands.lifetime.interfaces.LifetimeTrackerTarget; import carpettisaddition.commands.lifetime.removal.MobPickupRemovalReason; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; @@ -44,10 +45,9 @@ public abstract class ItemEntityMixin //#else target = "Lnet/minecraft/entity/ItemEntity;remove()V" //#endif - ), - locals = LocalCapture.CAPTURE_FAILHARD + ) ) - private void lifetimeTracker_recordRemoval_mobPickup_playerPickupItem(PlayerEntity player, CallbackInfo ci, ItemStack itemStack, Item item, int i) + private void lifetimeTracker_recordRemoval_mobPickup_playerPickupItem(PlayerEntity player, CallbackInfo ci, @Local ItemStack itemStack, @Local int i) { int stackCount = itemStack.getCount(); itemStack.setCount(i); diff --git a/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/MobEntityMixin.java b/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/MobEntityMixin.java index 931640cf8..52ed4fd4e 100644 --- a/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/MobEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/MobEntityMixin.java @@ -22,6 +22,7 @@ import carpettisaddition.commands.lifetime.interfaces.LifetimeTrackerTarget; import carpettisaddition.commands.lifetime.removal.MobPickupRemovalReason; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; @@ -51,7 +52,7 @@ protected MobEntityMixin(EntityType type, World world) //#endif ) ) - private void lifetimeTracker_recordRemoval_mobPickup_mobEntityPickupItem(ItemEntity item, CallbackInfo ci) + private void lifetimeTracker_recordRemoval_mobPickup_mobEntityPickupItem(CallbackInfo ci, @Local(argsOnly = true) ItemEntity item) { ((LifetimeTrackerTarget)item).recordRemoval(new MobPickupRemovalReason(this.getType())); } diff --git a/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/breeding/FoxEntityMateGoalMixin.java b/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/breeding/FoxEntityMateGoalMixin.java index f5358f65f..38d97ba0f 100644 --- a/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/breeding/FoxEntityMateGoalMixin.java +++ b/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/breeding/FoxEntityMateGoalMixin.java @@ -34,8 +34,12 @@ public abstract class FoxEntityMateGoalMixin method = "breed", at = @At( value = "INVOKE", + //#if MC >= 11600 + //$$ target = "Lnet/minecraft/server/world/ServerWorld;spawnEntityAndPassengers(Lnet/minecraft/entity/Entity;)V" + //#else target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z", ordinal = 0 + //#endif ) ) private Entity lifetimeTracker_recordSpawning_breeding_foxMateGoal(Entity entity) diff --git a/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/mobdrop/EntityMixin.java b/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/mobdrop/EntityMixin.java index b12f40b21..504030d3b 100644 --- a/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/mobdrop/EntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/mobdrop/EntityMixin.java @@ -22,30 +22,33 @@ import carpettisaddition.commands.lifetime.interfaces.LifetimeTrackerTarget; import carpettisaddition.commands.lifetime.spawning.MobDropSpawningReason; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.ItemEntity; -import net.minecraft.world.World; 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(Entity.class) public abstract class EntityMixin { - @Shadow public World world; - @Shadow public abstract EntityType getType(); - @Inject(method = "dropStack(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/ItemEntity;", at = @At("RETURN")) - private void lifetimeTracker_recordSpawning_mobDrop_common(CallbackInfoReturnable cir) + @ModifyReturnValue( + //#if MC >= 12102 + //$$ method = "dropStack(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/ItemEntity;", + //#else + method = "dropStack(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/ItemEntity;", + //#endif + at = @At("RETURN") + ) + private ItemEntity lifetimeTracker_recordSpawning_mobDrop_common(ItemEntity itemEntity) { - ItemEntity itemEntity = cir.getReturnValue(); if (itemEntity != null) { ((LifetimeTrackerTarget)itemEntity).recordSpawning(new MobDropSpawningReason(this.getType())); } + return itemEntity; } } diff --git a/src/main/java/carpettisaddition/mixins/logger/commandblock/CommandBlockMixin.java b/src/main/java/carpettisaddition/mixins/logger/commandblock/CommandBlockMixin.java index dd50ae5f7..1c853a7e8 100644 --- a/src/main/java/carpettisaddition/mixins/logger/commandblock/CommandBlockMixin.java +++ b/src/main/java/carpettisaddition/mixins/logger/commandblock/CommandBlockMixin.java @@ -31,6 +31,10 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +//#if MC >= 12102 +//$$ import net.minecraft.server.world.ServerWorld; +//#endif + @Mixin(CommandBlock.class) public abstract class CommandBlockMixin { @@ -42,7 +46,16 @@ public abstract class CommandBlockMixin shift = At.Shift.AFTER ) ) - private void onCommandBlockExecutedCommandBlockLogger(BlockState state, World world, BlockPos pos, CommandBlockExecutor executor, boolean hasCommand, CallbackInfo ci) + private void onCommandBlockExecutedCommandBlockLogger( + BlockState state, + //#if MC >= 12102 + //$$ ServerWorld world, + //#else + World world, + //#endif + BlockPos pos, CommandBlockExecutor executor, boolean hasCommand, + CallbackInfo ci + ) { CommandBlockLogger.getInstance().onCommandBlockActivated(world, pos, state, executor); } diff --git a/src/main/java/carpettisaddition/mixins/logger/damage/LivingEntityAndPlayerEntityMixins.java b/src/main/java/carpettisaddition/mixins/logger/damage/LivingEntityAndPlayerEntityMixins.java index ea04f76d9..23c114020 100644 --- a/src/main/java/carpettisaddition/mixins/logger/damage/LivingEntityAndPlayerEntityMixins.java +++ b/src/main/java/carpettisaddition/mixins/logger/damage/LivingEntityAndPlayerEntityMixins.java @@ -24,6 +24,7 @@ import carpettisaddition.logging.loggers.damage.interfaces.DamageLoggerTarget; import carpettisaddition.logging.loggers.damage.modifyreasons.ModifyReason; import carpettisaddition.logging.loggers.damage.modifyreasons.StatusEffectModifyReason; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.effect.StatusEffects; @@ -37,6 +38,10 @@ import java.util.Optional; +//#if MC >= 12102 +//$$ import net.minecraft.server.world.ServerWorld; +//#endif + // some same mixins public abstract class LivingEntityAndPlayerEntityMixins { @@ -50,7 +55,7 @@ public static class ApplyDamageMixin target = "Ljava/lang/Math;max(FF)F" ) ) - private void onAbsorptionReducedDamage(DamageSource source, float amount, CallbackInfo ci) + private void onAbsorptionReducedDamage(CallbackInfo ci, @Local(argsOnly = true) float amount) { ((DamageLoggerTarget) this).getDamageTracker().ifPresent(tracker -> tracker.modifyDamage( amount, new StatusEffectModifyReason(StatusEffects.ABSORPTION) @@ -59,13 +64,23 @@ amount, new StatusEffectModifyReason(StatusEffects.ABSORPTION) // at the end of damage calculation @Inject(method = "applyDamage", at = @At("RETURN")) - private void onDamageApplyDone(DamageSource source, float amount, CallbackInfo ci) + private void onDamageApplyDone( + CallbackInfo ci, @Local(argsOnly = true) DamageSource source, @Local(argsOnly = true) float amount + //#if MC >= 12102 + //$$ , @Local(argsOnly = true) ServerWorld serverWorld + //#endif + ) { if (DamageLogger.isLoggerActivated()) { LivingEntity entity = (LivingEntity) (Object) this; Optional logger = ((DamageLoggerTarget) this).getDamageTracker(); - if (entity.isInvulnerableTo(source)) + if (entity.isInvulnerableTo( + //#if MC >= 12102 + //$$ serverWorld, + //#endif + source + )) { amount = 0.0F; logger.ifPresent(tracker -> tracker.modifyDamage(0.0F, ModifyReason.IMMUNE)); @@ -80,7 +95,7 @@ private void onDamageApplyDone(DamageSource source, float amount, CallbackInfo c public static class DamageMixin { @Inject(method = "damage", at = @At(value = "RETURN")) - private void onDamageEnded(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onDamageEnded(CallbackInfoReturnable cir, @Local(argsOnly = true) float amount) { if (DamageLogger.isLoggerActivated()) { diff --git a/src/main/java/carpettisaddition/mixins/logger/damage/LivingEntityMixin.java b/src/main/java/carpettisaddition/mixins/logger/damage/LivingEntityMixin.java index bb3f6965a..01d9c9c55 100644 --- a/src/main/java/carpettisaddition/mixins/logger/damage/LivingEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/logger/damage/LivingEntityMixin.java @@ -26,6 +26,7 @@ import carpettisaddition.logging.loggers.damage.modifyreasons.EnchantmentModifyReason; import carpettisaddition.logging.loggers.damage.modifyreasons.ModifyReason; import carpettisaddition.logging.loggers.damage.modifyreasons.StatusEffectModifyReason; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; @@ -95,7 +96,7 @@ public void setDamageTracker(@Nullable DamageLogger.Tracker tracker) target = "Lnet/minecraft/entity/LivingEntity;isSleeping()Z" ) ) - private void onDamageStarted(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onDamageStarted(CallbackInfoReturnable cir, @Local(argsOnly = true) DamageSource source, @Local(argsOnly = true) float amount) { DamageLogger.create((LivingEntity)(Object)this, source, amount); } @@ -107,7 +108,7 @@ private void onDamageStarted(DamageSource source, float amount, CallbackInfoRetu args = "floatValue=0.75F" ) ) - private void onHelmetReducedAnvilDamage(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onHelmetReducedAnvilDamage(CallbackInfoReturnable cir, @Local(argsOnly = true) float amount) { this.getDamageTracker().ifPresent(tracker -> tracker.modifyDamage(amount * 0.75F, ModifyReason.HELMET)); } @@ -131,7 +132,7 @@ private void onHelmetReducedAnvilDamage(DamageSource source, float amount, Callb ordinal = 0 ) ) - private void onShieldReducedDamage(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onShieldReducedDamage(CallbackInfoReturnable cir, @Local(argsOnly = true) float amount) { this.getDamageTracker().ifPresent(tracker -> tracker.modifyDamage(amount, ModifyReason.SHIELD)); } @@ -148,7 +149,7 @@ private void onShieldReducedDamage(DamageSource source, float amount, CallbackIn ordinal = 0 ) ) - private void onRecentHintReducedDamage(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onRecentHintReducedDamage(CallbackInfoReturnable cir, @Local(argsOnly = true) float amount) { final float last = //#if MC >= 11500 diff --git a/src/main/java/carpettisaddition/mixins/logger/damage/PlayerEntityMixin.java b/src/main/java/carpettisaddition/mixins/logger/damage/PlayerEntityMixin.java index 428149fa1..b750827e5 100644 --- a/src/main/java/carpettisaddition/mixins/logger/damage/PlayerEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/logger/damage/PlayerEntityMixin.java @@ -23,6 +23,7 @@ import carpettisaddition.logging.loggers.damage.DamageLogger; import carpettisaddition.logging.loggers.damage.interfaces.DamageLoggerTarget; import carpettisaddition.logging.loggers.damage.modifyreasons.ModifyReason; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; @@ -50,7 +51,7 @@ protected PlayerEntityMixin(EntityType type, World world target = "Lnet/minecraft/entity/player/PlayerEntity;dropShoulderEntities()V" ) ) - private void onDamageStarted(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onDamageStarted(CallbackInfoReturnable cir, @Local(argsOnly = true) DamageSource source, @Local(argsOnly = true) float amount) { DamageLogger.create(this, source, amount); } @@ -69,7 +70,7 @@ private void onDamageStarted(DamageSource source, float amount, CallbackInfoRetu ordinal = 0 ) ) - private void onInvulnerableAbilityCancelledDamage(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onInvulnerableAbilityCancelledDamage(CallbackInfoReturnable cir) { ((DamageLoggerTarget)this).getDamageTracker().ifPresent(tracker -> tracker.modifyDamage(0.0F, ModifyReason.INVULNERABLE)); } @@ -88,7 +89,7 @@ private void onInvulnerableAbilityCancelledDamage(DamageSource source, float amo ordinal = 0 ) ) - private void onDifficultyModifiedDamage(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onDifficultyModifiedDamage(CallbackInfoReturnable cir, @Local(argsOnly = true) float amount) { ((DamageLoggerTarget)this).getDamageTracker().ifPresent(tracker -> tracker.modifyDamage(amount, ModifyReason.DIFFICULTY)); } diff --git a/src/main/java/carpettisaddition/mixins/logger/damage/ServerPlayerEntityMixin.java b/src/main/java/carpettisaddition/mixins/logger/damage/ServerPlayerEntityMixin.java index 2d707aca1..9aada3ff0 100644 --- a/src/main/java/carpettisaddition/mixins/logger/damage/ServerPlayerEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/logger/damage/ServerPlayerEntityMixin.java @@ -23,6 +23,7 @@ import carpettisaddition.logging.loggers.damage.DamageLogger; import carpettisaddition.logging.loggers.damage.interfaces.DamageLoggerTarget; import carpettisaddition.logging.loggers.damage.modifyreasons.ModifyReason; +import com.llamalad7.mixinextras.sugar.Local; import com.mojang.authlib.GameProfile; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; @@ -76,7 +77,7 @@ public ServerPlayerEntityMixin(World world, GameProfile profile) target = "Lnet/minecraft/server/MinecraftServer;isDedicated()Z" ) ) - private void onDamageStarted(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onDamageStarted(CallbackInfoReturnable cir, @Local(argsOnly = true) DamageSource source, @Local(argsOnly = true) float amount) { DamageLogger.create(this, source, amount); } @@ -91,7 +92,7 @@ private void onDamageStarted(DamageSource source, float amount, CallbackInfoRetu ), at = @At(value = "RETURN", ordinal = 0, shift = At.Shift.BEFORE) // before onDamageEnded in LivingEntityAndPlayerEntityMixins$DamageMixin ) - private void onRespawnProtectionCancelledDamage(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onRespawnProtectionCancelledDamage(CallbackInfoReturnable cir) { ((DamageLoggerTarget)this).getDamageTracker().ifPresent(tracker -> tracker.modifyDamage( 0.0F, ModifyReason.RESPAWN_PROTECTION @@ -113,7 +114,7 @@ private void onRespawnProtectionCancelledDamage(DamageSource source, float amoun @At(value = "RETURN", ordinal = 1, shift = At.Shift.BEFORE) } ) - private void onPVPDisabledCancelledDamage(DamageSource source, float amount, CallbackInfoReturnable cir) + private void onPVPDisabledCancelledDamage(CallbackInfoReturnable cir) { ((DamageLoggerTarget)this).getDamageTracker().ifPresent(tracker -> tracker.modifyDamage( 0.0F, ModifyReason.PVP_DISABLED diff --git a/src/main/java/carpettisaddition/mixins/logger/item/ItemEntityMixin.java b/src/main/java/carpettisaddition/mixins/logger/item/ItemEntityMixin.java index 3ff8246e2..567757563 100644 --- a/src/main/java/carpettisaddition/mixins/logger/item/ItemEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/logger/item/ItemEntityMixin.java @@ -21,24 +21,25 @@ package carpettisaddition.mixins.logger.item; import carpettisaddition.logging.loggers.entity.ItemLogger; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.damage.DamageSource; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - @Mixin(ItemEntity.class) public abstract class ItemEntityMixin { - private boolean flagDied = false; - private boolean flagDespawned = false; + @Unique private boolean flagDied = false; + @Unique private boolean flagDespawned = false; @Inject(method = "(Lnet/minecraft/world/World;DDDLnet/minecraft/item/ItemStack;)V", at = @At("TAIL")) - private void onCreated(CallbackInfo ci) + private void itemLogger_onCreated(CallbackInfo ci) { ItemLogger.getInstance().onEntityCreated((ItemEntity)(Object)this); } @@ -60,7 +61,7 @@ private void onCreated(CallbackInfo ci) //#endif ) ) - void onDespawned(CallbackInfo ci) + private void itemLogger_onDespawned(CallbackInfo ci) { if (!this.flagDespawned) { @@ -80,7 +81,7 @@ void onDespawned(CallbackInfo ci) //#endif ) ) - void onDied(DamageSource source, float amount, CallbackInfoReturnable cir) + private void itemLogger_onDied(CallbackInfoReturnable cir, @Local(argsOnly = true) DamageSource source, @Local(argsOnly = true) float amount) { if (!this.flagDied) { diff --git a/src/main/java/carpettisaddition/mixins/logger/xporb/ExperienceOrbEntityMixin.java b/src/main/java/carpettisaddition/mixins/logger/xporb/ExperienceOrbEntityMixin.java index de328098b..47ab7e617 100644 --- a/src/main/java/carpettisaddition/mixins/logger/xporb/ExperienceOrbEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/logger/xporb/ExperienceOrbEntityMixin.java @@ -21,24 +21,25 @@ package carpettisaddition.mixins.logger.xporb; import carpettisaddition.logging.loggers.entity.XPOrbLogger; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.ExperienceOrbEntity; import net.minecraft.entity.damage.DamageSource; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - @Mixin(ExperienceOrbEntity.class) public abstract class ExperienceOrbEntityMixin { - private boolean flagDied = false; - private boolean flagDespawned = false; + @Unique private boolean flagDied = false; + @Unique private boolean flagDespawned = false; @Inject(method = "(Lnet/minecraft/world/World;DDDI)V", at = @At("TAIL")) - private void onCreated(CallbackInfo ci) + private void xpOrbLogger_onCreated(CallbackInfo ci) { XPOrbLogger.getInstance().onEntityCreated((ExperienceOrbEntity)(Object)this); } @@ -60,7 +61,7 @@ private void onCreated(CallbackInfo ci) //#endif ) ) - void onDespawned(CallbackInfo ci) + private void xpOrbLogger_onDespawned(CallbackInfo ci) { if (!this.flagDespawned) { @@ -80,7 +81,7 @@ void onDespawned(CallbackInfo ci) //#endif ) ) - void onDied(DamageSource source, float amount, CallbackInfoReturnable cir) + private void xpOrbLogger_onDied(CallbackInfoReturnable cir, @Local(argsOnly = true) DamageSource source, @Local(argsOnly = true) float amount) { if (!this.flagDied) { diff --git a/src/main/java/carpettisaddition/mixins/rule/farmlandTrampledDisabled/FarmLandBlockMixin.java b/src/main/java/carpettisaddition/mixins/rule/farmlandTrampledDisabled/FarmLandBlockMixin.java index c1fe5f11a..5f746eb87 100644 --- a/src/main/java/carpettisaddition/mixins/rule/farmlandTrampledDisabled/FarmLandBlockMixin.java +++ b/src/main/java/carpettisaddition/mixins/rule/farmlandTrampledDisabled/FarmLandBlockMixin.java @@ -21,28 +21,39 @@ package carpettisaddition.mixins.rule.farmlandTrampledDisabled; import carpettisaddition.CarpetTISAdditionSettings; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import net.minecraft.block.BlockState; import net.minecraft.block.FarmlandBlock; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +//#if MC >= 11900 +//$$ import net.minecraft.entity.Entity; +//#endif + @Mixin(FarmlandBlock.class) public abstract class FarmLandBlockMixin { - @ModifyExpressionValue( + @WrapWithCondition( method = "onLandedUpon", at = @At( - value = "FIELD", - target = "Lnet/minecraft/world/World;isClient:Z" + value = "INVOKE", + //#if MC >= 11900 + //$$ target = "Lnet/minecraft/block/FarmlandBlock;setToDirt(Lnet/minecraft/entity/Entity;Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V" + //#else + target = "Lnet/minecraft/block/FarmlandBlock;setToDirt(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)V" + //#endif ) ) - private boolean farmlandTrampledDisabled_cancelIfStatement(boolean isClient) + private boolean farmlandTrampledDisabled_cancel( + //#if MC >= 11900 + //$$ Entity entity, + //#endif + BlockState state, World world, BlockPos pos + ) { - if (CarpetTISAdditionSettings.farmlandTrampledDisabled) - { - // world.isClient returning true -> if predicate fails -> farmland protected - isClient = true; - } - return isClient; + return !CarpetTISAdditionSettings.farmlandTrampledDisabled; } } diff --git a/src/main/java/carpettisaddition/mixins/rule/renewableDragonHead/EnderDragonEntityMixin.java b/src/main/java/carpettisaddition/mixins/rule/renewableDragonHead/EnderDragonEntityMixin.java index 5283f4ea5..fccd5e15e 100644 --- a/src/main/java/carpettisaddition/mixins/rule/renewableDragonHead/EnderDragonEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/rule/renewableDragonHead/EnderDragonEntityMixin.java @@ -21,10 +21,10 @@ package carpettisaddition.mixins.rule.renewableDragonHead; import carpettisaddition.CarpetTISAdditionSettings; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.boss.dragon.EnderDragonEntity; -import net.minecraft.entity.boss.dragon.EnderDragonPart; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.mob.CreeperEntity; import net.minecraft.entity.mob.MobEntity; @@ -38,6 +38,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//#if MC >= 12102 +//$$ import net.minecraft.server.world.ServerWorld; +//#endif @Mixin(EnderDragonEntity.class) public abstract class EnderDragonEntityMixin extends MobEntity implements Monster @@ -71,10 +74,17 @@ private void onConstructed(EntityType entityType, W ) private void dropHead(CallbackInfo ci) { + //#if MC >= 12102 + //$$ if (this.flagDropHead && this.getWorld() instanceof ServerWorld serverWorld) + //$$ { + //$$ this.dropStack(serverWorld, new ItemStack(Items.DRAGON_HEAD)); + //$$ } + //#else if (this.flagDropHead) { this.dropStack(new ItemStack(Items.DRAGON_HEAD)); } + //#endif } @Inject( @@ -84,7 +94,7 @@ private void dropHead(CallbackInfo ci) target = "Lnet/minecraft/entity/boss/dragon/EnderDragonEntity;setHealth(F)V" ) ) - private void onTakingDeathDamage(EnderDragonPart enderDragonPart, DamageSource damageSource, float f, CallbackInfoReturnable cir) + private void onTakingDeathDamage(CallbackInfoReturnable cir, @Local(argsOnly = true) DamageSource damageSource) { if (CarpetTISAdditionSettings.renewableDragonHead) { diff --git a/src/main/java/carpettisaddition/mixins/rule/renewableElytra/PhantomEntityMixin.java b/src/main/java/carpettisaddition/mixins/rule/renewableElytra/PhantomEntityMixin.java index 7cec20068..4dedb6027 100644 --- a/src/main/java/carpettisaddition/mixins/rule/renewableElytra/PhantomEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/rule/renewableElytra/PhantomEntityMixin.java @@ -29,8 +29,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Intrinsic; import org.spongepowered.asm.mixin.Mixin; +//#if MC >= 12102 +//$$ import net.minecraft.server.world.ServerWorld; +//#endif @Mixin(PhantomEntity.class) public abstract class PhantomEntityMixin extends FlyingEntity @@ -40,15 +44,31 @@ public PhantomEntityMixin(EntityType entityType, World super(entityType, world); } + @Intrinsic @Override - protected void dropLoot(DamageSource source, boolean causedByPlayer) + protected void dropLoot( + //#if MC >= 12102 + //$$ ServerWorld world, + //#endif + DamageSource source, boolean causedByPlayer + ) { - super.dropLoot(source, causedByPlayer); + super.dropLoot( + //#if MC >= 12102 + //$$ world, + //#endif + source, causedByPlayer + ); if (CarpetTISAdditionSettings.renewableElytra > 0.0D) { if (source.getAttacker() instanceof ShulkerEntity && this.random.nextDouble() < CarpetTISAdditionSettings.renewableElytra) { - this.dropStack(new ItemStack(Items.ELYTRA)); + this.dropStack( + //#if MC >= 12102 + //$$ world, + //#endif + new ItemStack(Items.ELYTRA) + ); } } } diff --git a/src/main/java/carpettisaddition/mixins/rule/voidDamageAmount/LivingEntityMixin.java b/src/main/java/carpettisaddition/mixins/rule/voidDamageAmount/LivingEntityMixin.java index e435a5ad3..005ab47e7 100644 --- a/src/main/java/carpettisaddition/mixins/rule/voidDamageAmount/LivingEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/rule/voidDamageAmount/LivingEntityMixin.java @@ -33,7 +33,11 @@ public abstract class LivingEntityMixin method = "destroy", at = @At( value = "INVOKE", + //#if MC >= 12102 + //$$ target = "Lnet/minecraft/entity/LivingEntity;serverDamage(Lnet/minecraft/entity/damage/DamageSource;F)V" + //#else target = "Lnet/minecraft/entity/LivingEntity;damage(Lnet/minecraft/entity/damage/DamageSource;F)Z" + //#endif ) ) private float voidDamageAmount(float amount) diff --git a/src/main/java/carpettisaddition/mixins/rule/witherSpawnedSoundDisabled/WitherEntityMixin.java b/src/main/java/carpettisaddition/mixins/rule/witherSpawnedSoundDisabled/WitherEntityMixin.java index bc38a4994..f97ff8f54 100644 --- a/src/main/java/carpettisaddition/mixins/rule/witherSpawnedSoundDisabled/WitherEntityMixin.java +++ b/src/main/java/carpettisaddition/mixins/rule/witherSpawnedSoundDisabled/WitherEntityMixin.java @@ -28,6 +28,10 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +//#if MC >= 12102 +//$$ import net.minecraft.server.world.ServerWorld; +//#endif + @Mixin(WitherEntity.class) public abstract class WitherEntityMixin { @@ -35,14 +39,23 @@ public abstract class WitherEntityMixin method = "mobTick", at = @At( value = "INVOKE", - //#if MC >= 11600 + //#if MC >= 12102 + //$$ target = "Lnet/minecraft/server/world/ServerWorld;syncGlobalEvent(ILnet/minecraft/util/math/BlockPos;I)V" + //#elseif MC >= 11600 //$$ target = "Lnet/minecraft/world/World;syncGlobalEvent(ILnet/minecraft/util/math/BlockPos;I)V" //#else target = "Lnet/minecraft/world/World;playGlobalEvent(ILnet/minecraft/util/math/BlockPos;I)V" //#endif ) ) - private boolean witherSpawnedSoundDisabled_conditionCheck(World instance, int type, BlockPos blockPos, int data) + private boolean witherSpawnedSoundDisabled_conditionCheck( + //#if MC >= 12102 + //$$ ServerWorld instance, + //#else + World instance, + //#endif + int type, BlockPos blockPos, int data + ) { return !CarpetTISAdditionSettings.witherSpawnedSoundDisabled; } diff --git a/src/main/java/carpettisaddition/utils/Messenger.java b/src/main/java/carpettisaddition/utils/Messenger.java index 316fe392f..cece7052e 100644 --- a/src/main/java/carpettisaddition/utils/Messenger.java +++ b/src/main/java/carpettisaddition/utils/Messenger.java @@ -39,6 +39,7 @@ import net.minecraft.fluid.FluidState; import net.minecraft.item.Item; import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.state.property.Property; import net.minecraft.text.*; import net.minecraft.util.DyeColor; @@ -651,7 +652,11 @@ public static void tell(ServerCommandSource source, BaseText text, boolean broad } public static void tell(PlayerEntity player, BaseText text, boolean broadcastToOps) { - tell(player.getCommandSource(), text, broadcastToOps); + if (player instanceof ServerPlayerEntity) + { + ServerPlayerEntity serverPlayer = (ServerPlayerEntity)player; // for mc1.21.2+, where getCommandSource requires being on the server-side + tell(serverPlayer.getCommandSource(), text, broadcastToOps); + } } public static void tell(ServerCommandSource source, BaseText text) { diff --git a/src/main/java/carpettisaddition/utils/entityfilter/EntityFilter.java b/src/main/java/carpettisaddition/utils/entityfilter/EntityFilter.java index cb92f20fa..8abe492af 100644 --- a/src/main/java/carpettisaddition/utils/entityfilter/EntityFilter.java +++ b/src/main/java/carpettisaddition/utils/entityfilter/EntityFilter.java @@ -29,6 +29,7 @@ import net.minecraft.command.EntitySelector; import net.minecraft.command.EntitySelectorReader; import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -54,18 +55,22 @@ public EntityFilter(@NotNull ServerCommandSource serverCommandSource, @NotNull E this.serverCommandSource = serverCommandSource; } - public static EntityFilter create(Entity entity, String filterDescriptor) throws CommandSyntaxException + public static EntityFilter create(ServerPlayerEntity player, String filterDescriptor) throws CommandSyntaxException { - ServerCommandSource source = entity.getCommandSource(); + ServerCommandSource source = player.getCommandSource(); EntitySelectorReader reader = new EntitySelectorReader(new StringReader(filterDescriptor), source.hasPermissionLevel(2)); return new EntityFilter(source, reader.read()); } - public static Optional createOptional(Entity entity, String filterDescriptor) + public static Optional createOptional(PlayerEntity player, String filterDescriptor) { + if (!(player instanceof ServerPlayerEntity)) + { + return Optional.empty(); + } try { - return Optional.of(create(entity, filterDescriptor)); + return Optional.of(create((ServerPlayerEntity)player, filterDescriptor)); } catch (CommandSyntaxException e) { diff --git a/versions/1.19.4/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/InventoryOwnerMixin.java b/versions/1.19.4/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/InventoryOwnerMixin.java index d2a6a1901..0a3862caa 100644 --- a/versions/1.19.4/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/InventoryOwnerMixin.java +++ b/versions/1.19.4/src/main/java/carpettisaddition/mixins/command/lifetime/removal/mobpickup/InventoryOwnerMixin.java @@ -23,6 +23,7 @@ import carpettisaddition.commands.lifetime.interfaces.LifetimeTrackerTarget; import carpettisaddition.commands.lifetime.removal.MobPickupRemovalReason; import carpettisaddition.utils.ModIds; +import com.llamalad7.mixinextras.sugar.Local; import me.fallenbreath.conditionalmixin.api.annotation.Condition; import me.fallenbreath.conditionalmixin.api.annotation.Restriction; import net.minecraft.entity.InventoryOwner; @@ -45,7 +46,7 @@ public interface InventoryOwnerMixin target = "Lnet/minecraft/entity/ItemEntity;discard()V" ) ) - private static void lifetimeTracker_recordRemoval_mobPickup_inventoryOwnerItem(MobEntity mobEntity, InventoryOwner inventoryOwner, ItemEntity itemEntity, CallbackInfo ci) + private static void lifetimeTracker_recordRemoval_mobPickup_inventoryOwnerItem(CallbackInfo ci, @Local(argsOnly = true) MobEntity mobEntity, @Local(argsOnly = true) ItemEntity itemEntity) { ((LifetimeTrackerTarget)itemEntity).recordRemoval(new MobPickupRemovalReason(mobEntity.getType())); } diff --git a/versions/1.19.4/src/main/java/carpettisaddition/mixins/command/removeentity/ChestBoatEntityMixin.java b/versions/1.19.4/src/main/java/carpettisaddition/mixins/command/removeentity/ChestBoatEntityMixin.java index 83d910699..948019871 100644 --- a/versions/1.19.4/src/main/java/carpettisaddition/mixins/command/removeentity/ChestBoatEntityMixin.java +++ b/versions/1.19.4/src/main/java/carpettisaddition/mixins/command/removeentity/ChestBoatEntityMixin.java @@ -25,12 +25,23 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import me.fallenbreath.conditionalmixin.api.annotation.Condition; import me.fallenbreath.conditionalmixin.api.annotation.Restriction; -import net.minecraft.entity.vehicle.ChestBoatEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +//#if MC >= 12102 +//$$ import net.minecraft.entity.vehicle.AbstractChestBoatEntity; +//#else +import net.minecraft.entity.vehicle.ChestBoatEntity; +//#endif + @Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = ">=1.19")) -@Mixin(ChestBoatEntity.class) +@Mixin( + //#if MC >= 12102 + //$$ AbstractChestBoatEntity.class + //#else + ChestBoatEntity.class + //#endif +) public abstract class ChestBoatEntityMixin implements EntityToBeCleanlyRemoved { private boolean toBeCleanlyRemoved$TISCM = false; diff --git a/versions/1.20.4/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/VehicleEntityMixin.java b/versions/1.20.4/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/VehicleEntityMixin.java index f966a6def..b97a82b28 100644 --- a/versions/1.20.4/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/VehicleEntityMixin.java +++ b/versions/1.20.4/src/main/java/carpettisaddition/mixins/command/lifetime/deathdamage/VehicleEntityMixin.java @@ -54,7 +54,11 @@ private DamageSource lifetimeTracker_recordDeathDamageSource_vehicle1(DamageSour method = "damage", at =@At( value = "INVOKE", + //#if MC >= 12102 + //$$ target = "Lnet/minecraft/entity/vehicle/VehicleEntity;killAndDropSelf(Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/damage/DamageSource;)V" + //#else target = "Lnet/minecraft/entity/vehicle/VehicleEntity;killAndDropSelf(Lnet/minecraft/entity/damage/DamageSource;)V" + //#endif ), argsOnly = true ) diff --git a/versions/1.20.6/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/statuseffect/InfestedStatusEffectMixin.java b/versions/1.20.6/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/statuseffect/InfestedStatusEffectMixin.java index 40af23464..6576c621e 100644 --- a/versions/1.20.6/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/statuseffect/InfestedStatusEffectMixin.java +++ b/versions/1.20.6/src/main/java/carpettisaddition/mixins/command/lifetime/spawning/statuseffect/InfestedStatusEffectMixin.java @@ -35,10 +35,14 @@ public abstract class InfestedStatusEffectMixin method = "spawnSilverfish", at = @At( value = "INVOKE", + //#if MC >= 12102 + //$$ target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z" + //#else target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z" + //#endif ) ) - private Entity lifetimeTracker_recordSpawning_statusEffect_oozing(Entity entity) + private Entity lifetimeTracker_recordSpawning_statusEffect_infested(Entity entity) { ((LifetimeTrackerTarget)entity).recordSpawning(new StatusEffectSpawningReason((StatusEffect)(Object)this)); return entity; diff --git a/versions/future/gradle.properties b/versions/future/gradle.properties index 91c115fdd..63c853ef6 100644 --- a/versions/future/gradle.properties +++ b/versions/future/gradle.properties @@ -1,7 +1,7 @@ # Fabric Properties - # check these on https://fallen-breath.github.io/fabric-versions/?&version=24w38a - minecraft_version=24w38a - yarn_mappings=24w38a+build.5 + # check these on https://fallen-breath.github.io/fabric-versions/?&version=24w39a + minecraft_version=24w39a + yarn_mappings=24w39a+build.6 # Fabric Mod Metadata carpet_dependency=>=1.4.147 @@ -10,12 +10,12 @@ # Build Information # The target mc versions for the mod during mod publishing, separated with \n - game_versions=24w38a + game_versions=24w39a # Mod Dependency # check available versions on maven for the given minecraft version you are using # https://masa.dy.fi/maven/carpet/fabric-carpet/ - carpet_core_version=24w38a-1.4.153+v240918 + carpet_core_version=24w39a-1.4.154+v240925 # Lithium mc1.21.1-0.13.0 # https://www.curseforge.com/minecraft/mc-mods/lithium/files/5618760