diff --git a/src/main/java/carpettisaddition/helpers/rule/yeetUpdateSuppressionCrash/UpdateSuppressionExceptions.java b/src/main/java/carpettisaddition/helpers/rule/yeetUpdateSuppressionCrash/UpdateSuppressionExceptions.java index 7f5396f56..863a404fd 100644 --- a/src/main/java/carpettisaddition/helpers/rule/yeetUpdateSuppressionCrash/UpdateSuppressionExceptions.java +++ b/src/main/java/carpettisaddition/helpers/rule/yeetUpdateSuppressionCrash/UpdateSuppressionExceptions.java @@ -41,6 +41,10 @@ public static UpdateSuppressionException createWrapper(Throwable cause, World wo { return new OutOfMemorySuppression(cause, world, pos); } + if (cause instanceof IllegalArgumentException) + { + return new IllegalArgumentSuppression(cause, world, pos); + } return null; } @@ -51,6 +55,7 @@ public static void noop() StackOverflowSuppression.class.getClass(); ClassCastSuppression.class.getClass(); OutOfMemorySuppression.class.getClass(); + IllegalArgumentSuppression.class.getClass(); } public static class StackOverflowSuppression extends StackOverflowError implements UpdateSuppressionException @@ -118,4 +123,26 @@ public UpdateSuppressionContext getSuppressionContext() return this.context; } } + + public static class IllegalArgumentSuppression extends IllegalArgumentException implements UpdateSuppressionException + { + private final UpdateSuppressionContext context; + + public IllegalArgumentSuppression(Throwable cause, World world, BlockPos pos) + { + this.context = new UpdateSuppressionContext(cause, world, pos); + } + + @Override + public synchronized Throwable getCause() + { + return this.context.getCause(); + } + + @Override + public UpdateSuppressionContext getSuppressionContext() + { + return this.context; + } + } } \ No newline at end of file diff --git a/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/CalibratedSculkSensorBlockEntityCallBackMixin.java b/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/CalibratedSculkSensorBlockEntityCallBackMixin.java new file mode 100644 index 000000000..17d37a99f --- /dev/null +++ b/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/CalibratedSculkSensorBlockEntityCallBackMixin.java @@ -0,0 +1,30 @@ +/* + * This file is part of the Carpet TIS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * Carpet TIS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet TIS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet TIS Addition. If not, see . + */ + +package carpettisaddition.mixins.rule.yeetUpdateSuppressionCrash.mark; + +import carpettisaddition.utils.compat.DummyClass; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(DummyClass.class) +public abstract class CalibratedSculkSensorBlockEntityCallBackMixin +{ + // impl in mc1.20.1 subproject +} diff --git a/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/SculkSensorBlockEntityVibrationCallbackMixin.java b/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/SculkSensorBlockEntityVibrationCallbackMixin.java new file mode 100644 index 000000000..af8233c17 --- /dev/null +++ b/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/SculkSensorBlockEntityVibrationCallbackMixin.java @@ -0,0 +1,30 @@ +/* + * This file is part of the Carpet TIS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * Carpet TIS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet TIS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet TIS Addition. If not, see . + */ + +package carpettisaddition.mixins.rule.yeetUpdateSuppressionCrash.mark; + +import carpettisaddition.utils.compat.DummyClass; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(DummyClass.class) +public abstract class SculkSensorBlockEntityVibrationCallbackMixin +{ + // impl in mc1.18.2 subproject +} diff --git a/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/WorldMixin.java b/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/WorldMixin.java index 47764c3e2..cb5e3decd 100644 --- a/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/WorldMixin.java +++ b/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/WorldMixin.java @@ -46,7 +46,7 @@ public abstract class WorldMixin target = "Lnet/minecraft/util/crash/CrashReport;create(Ljava/lang/Throwable;Ljava/lang/String;)Lnet/minecraft/util/crash/CrashReport;" ) ) - private Throwable yeetUpdateSuppressionCrash_wrapSuppressionExceptions( + private Throwable yeetUpdateSuppressionCrash_wrapSoundSuppression( Throwable throwable, @Local(ordinal = 1, argsOnly = true) BlockPos neighborPos, @Local LocalRef ref diff --git a/src/main/resources/carpet-tis-addition.mixins.json b/src/main/resources/carpet-tis-addition.mixins.json index 631d0edee..4ac0fe77c 100644 --- a/src/main/resources/carpet-tis-addition.mixins.json +++ b/src/main/resources/carpet-tis-addition.mixins.json @@ -474,8 +474,10 @@ "rule.xpTrackingDistance.ExperienceOrbEntityMixin", "rule.yeetOutOfOrderChatKick.MessageVerifierImplMixin", "rule.yeetOutOfOrderChatKick.ServerPlayNetworkHandlerMixin", + "rule.yeetUpdateSuppressionCrash.mark.CalibratedSculkSensorBlockEntityCallBackMixin", "rule.yeetUpdateSuppressionCrash.mark.ChainRestrictedNeighborUpdaterSixWayEntryMixin", "rule.yeetUpdateSuppressionCrash.mark.NeighborUpdaterMixin", + "rule.yeetUpdateSuppressionCrash.mark.SculkSensorBlockEntityVibrationCallbackMixin", "rule.yeetUpdateSuppressionCrash.mark.WorldMixin", "rule.yeetUpdateSuppressionCrash.yeet.MinecraftServerMixin", "rule.yeetUpdateSuppressionCrash.yeet.ReentrantThreadExecutorMixin", diff --git a/versions/1.18.2/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/SculkSensorBlockEntityVibrationCallbackMixin.java b/versions/1.18.2/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/SculkSensorBlockEntityVibrationCallbackMixin.java new file mode 100644 index 000000000..218396caa --- /dev/null +++ b/versions/1.18.2/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/SculkSensorBlockEntityVibrationCallbackMixin.java @@ -0,0 +1,88 @@ +/* + * This file is part of the Carpet TIS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * Carpet TIS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet TIS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet TIS Addition. If not, see . + */ + +package carpettisaddition.mixins.rule.yeetUpdateSuppressionCrash.mark; + +import carpettisaddition.CarpetTISAdditionSettings; +import carpettisaddition.helpers.rule.yeetUpdateSuppressionCrash.UpdateSuppressionYeeter; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.SculkSensorBlockEntity; +import net.minecraft.util.math.BlockPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +//#if MC >= 11900 +//$$ import net.minecraft.server.world.ServerWorld; +//#else +import net.minecraft.world.World; +//#endif + +@Mixin( + //#if MC >= 12000 + //$$ SculkSensorBlockEntity.VibrationCallback.class + //#else + SculkSensorBlockEntity.class + //#endif +) +public abstract class SculkSensorBlockEntityVibrationCallbackMixin +{ + @WrapOperation( + method = {"accepts", "accept"}, + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/block/SculkSensorBlock;isInactive(Lnet/minecraft/block/BlockState;)Z" + ) + ) + private boolean yeetUpdateSuppressionCrash_wrapSoundSuppression( + BlockState instance, Operation original, + //#if MC >= 12000 + //$$ @Local(argsOnly = true) ServerWorld world, + //$$ @Local(argsOnly = true) BlockPos pos + //#elseif MC >= 11900 + //$$ @Local(argsOnly = true) ServerWorld world + //#else + @Local(argsOnly = true) World world + //#endif + ) throws Throwable + { + if (CarpetTISAdditionSettings.yeetUpdateSuppressionCrash) + { + try + { + return original.call(instance); + } + catch (Throwable throwable) + { + //#if MC < 12000 + BlockPos pos = ((SculkSensorBlockEntity)(Object)this).getPos(); + //#endif + throw UpdateSuppressionYeeter.tryReplaceWithWrapper(throwable, world, pos); + } + } + else + { + // vanilla + return original.call(instance); + } + } +} diff --git a/versions/1.20.1/carpet-tis-addition.accesswidener b/versions/1.20.1/carpet-tis-addition.accesswidener index f75d6a961..086cc2c12 100644 --- a/versions/1.20.1/carpet-tis-addition.accesswidener +++ b/versions/1.20.1/carpet-tis-addition.accesswidener @@ -4,3 +4,8 @@ accessible class net/minecraft/village/raid/Raid$Status accessible class net/minecraft/server/command/FillCommand$Mode accessible class net/minecraft/world/SpawnDensityCapper$DensityCap accessible class net/minecraft/world/block/ChainRestrictedNeighborUpdater$Entry + +# XXX: If without and use `targets = "xxxx"` instead, mixin will complain about "Mixin target xxxx is public and should be specified in value", +# even if they are actually protected classes +accessible class net/minecraft/block/entity/CalibratedSculkSensorBlockEntity$Callback +accessible class net/minecraft/block/entity/SculkSensorBlockEntity$VibrationCallback diff --git a/versions/1.20.1/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/CalibratedSculkSensorBlockEntityCallBackMixin.java b/versions/1.20.1/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/CalibratedSculkSensorBlockEntityCallBackMixin.java new file mode 100644 index 000000000..d8b791370 --- /dev/null +++ b/versions/1.20.1/src/main/java/carpettisaddition/mixins/rule/yeetUpdateSuppressionCrash/mark/CalibratedSculkSensorBlockEntityCallBackMixin.java @@ -0,0 +1,69 @@ +/* + * This file is part of the Carpet TIS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 Fallen_Breath and contributors + * + * Carpet TIS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet TIS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet TIS Addition. If not, see . + */ + +package carpettisaddition.mixins.rule.yeetUpdateSuppressionCrash.mark; + +import carpettisaddition.CarpetTISAdditionSettings; +import carpettisaddition.helpers.rule.yeetUpdateSuppressionCrash.UpdateSuppressionYeeter; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.CalibratedSculkSensorBlockEntity; +import net.minecraft.state.property.Property; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(CalibratedSculkSensorBlockEntity.Callback.class) +public abstract class CalibratedSculkSensorBlockEntityCallBackMixin +{ + @WrapOperation( + method = "getCalibrationFrequency", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/block/BlockState;get(Lnet/minecraft/state/property/Property;)Ljava/lang/Comparable;" + ) + ) + private > T yeetUpdateSuppressionCrash_wrapSoundSuppression( + BlockState instance, Property property, Operation original, + @Local(argsOnly = true) World world, + @Local(argsOnly = true) BlockPos pos + ) throws Throwable + { + if (CarpetTISAdditionSettings.yeetUpdateSuppressionCrash) + { + try + { + return original.call(instance, property); + } + catch (Throwable throwable) + { + throw UpdateSuppressionYeeter.tryReplaceWithWrapper(throwable, world, pos); + } + } + else + { + // vanilla + return original.call(instance, property); + } + } +} diff --git a/versions/1.20.2/carpet-tis-addition.accesswidener b/versions/1.20.2/carpet-tis-addition.accesswidener index f75d6a961..086cc2c12 100644 --- a/versions/1.20.2/carpet-tis-addition.accesswidener +++ b/versions/1.20.2/carpet-tis-addition.accesswidener @@ -4,3 +4,8 @@ accessible class net/minecraft/village/raid/Raid$Status accessible class net/minecraft/server/command/FillCommand$Mode accessible class net/minecraft/world/SpawnDensityCapper$DensityCap accessible class net/minecraft/world/block/ChainRestrictedNeighborUpdater$Entry + +# XXX: If without and use `targets = "xxxx"` instead, mixin will complain about "Mixin target xxxx is public and should be specified in value", +# even if they are actually protected classes +accessible class net/minecraft/block/entity/CalibratedSculkSensorBlockEntity$Callback +accessible class net/minecraft/block/entity/SculkSensorBlockEntity$VibrationCallback diff --git a/versions/1.20.4/carpet-tis-addition.accesswidener b/versions/1.20.4/carpet-tis-addition.accesswidener index f75d6a961..086cc2c12 100644 --- a/versions/1.20.4/carpet-tis-addition.accesswidener +++ b/versions/1.20.4/carpet-tis-addition.accesswidener @@ -4,3 +4,8 @@ accessible class net/minecraft/village/raid/Raid$Status accessible class net/minecraft/server/command/FillCommand$Mode accessible class net/minecraft/world/SpawnDensityCapper$DensityCap accessible class net/minecraft/world/block/ChainRestrictedNeighborUpdater$Entry + +# XXX: If without and use `targets = "xxxx"` instead, mixin will complain about "Mixin target xxxx is public and should be specified in value", +# even if they are actually protected classes +accessible class net/minecraft/block/entity/CalibratedSculkSensorBlockEntity$Callback +accessible class net/minecraft/block/entity/SculkSensorBlockEntity$VibrationCallback diff --git a/versions/1.20.6/carpet-tis-addition.accesswidener b/versions/1.20.6/carpet-tis-addition.accesswidener index f75d6a961..086cc2c12 100644 --- a/versions/1.20.6/carpet-tis-addition.accesswidener +++ b/versions/1.20.6/carpet-tis-addition.accesswidener @@ -4,3 +4,8 @@ accessible class net/minecraft/village/raid/Raid$Status accessible class net/minecraft/server/command/FillCommand$Mode accessible class net/minecraft/world/SpawnDensityCapper$DensityCap accessible class net/minecraft/world/block/ChainRestrictedNeighborUpdater$Entry + +# XXX: If without and use `targets = "xxxx"` instead, mixin will complain about "Mixin target xxxx is public and should be specified in value", +# even if they are actually protected classes +accessible class net/minecraft/block/entity/CalibratedSculkSensorBlockEntity$Callback +accessible class net/minecraft/block/entity/SculkSensorBlockEntity$VibrationCallback diff --git a/versions/1.21/carpet-tis-addition.accesswidener b/versions/1.21/carpet-tis-addition.accesswidener index f75d6a961..086cc2c12 100644 --- a/versions/1.21/carpet-tis-addition.accesswidener +++ b/versions/1.21/carpet-tis-addition.accesswidener @@ -4,3 +4,8 @@ accessible class net/minecraft/village/raid/Raid$Status accessible class net/minecraft/server/command/FillCommand$Mode accessible class net/minecraft/world/SpawnDensityCapper$DensityCap accessible class net/minecraft/world/block/ChainRestrictedNeighborUpdater$Entry + +# XXX: If without and use `targets = "xxxx"` instead, mixin will complain about "Mixin target xxxx is public and should be specified in value", +# even if they are actually protected classes +accessible class net/minecraft/block/entity/CalibratedSculkSensorBlockEntity$Callback +accessible class net/minecraft/block/entity/SculkSensorBlockEntity$VibrationCallback