-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add noise suppression support for rule
yeetUpdateSuppressionCrash
(#…
…165) * Add noise suppression support for rule `yeetUpdateSuppressionCrash` <3 JKM & Metacinnabar * make it actually work has not been tested in game yet --------- Co-authored-by: Fallen_Breath <[email protected]>
- Loading branch information
1 parent
015d09c
commit ca19e40
Showing
12 changed files
with
272 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...s/rule/yeetUpdateSuppressionCrash/mark/CalibratedSculkSensorBlockEntityCallBackMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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 | ||
} |
30 changes: 30 additions & 0 deletions
30
...ns/rule/yeetUpdateSuppressionCrash/mark/SculkSensorBlockEntityVibrationCallbackMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...ns/rule/yeetUpdateSuppressionCrash/mark/SculkSensorBlockEntityVibrationCallbackMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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<Boolean> 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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...s/rule/yeetUpdateSuppressionCrash/mark/CalibratedSculkSensorBlockEntityCallBackMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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 extends Comparable<T>> T yeetUpdateSuppressionCrash_wrapSoundSuppression( | ||
BlockState instance, Property<T> property, Operation<T> 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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters