generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In four mixins, ModifyReturnValue doesn't work properly, so we need Inject + CallbackInfoReturnable instead In one mixin, ModifyExpressionValue doesn't work properly, so we need Redirect
- Loading branch information
1 parent
9206bc9
commit 09b34b3
Showing
6 changed files
with
25 additions
and
28 deletions.
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
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
10 changes: 6 additions & 4 deletions
10
src/main/java/uk/debb/vanilla_disable/mixin/mobs/MixinDragonStrafePlayerPhase.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 |
---|---|---|
@@ -1,24 +1,26 @@ | ||
package uk.debb.vanilla_disable.mixin.mobs; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.boss.enderdragon.phases.DragonStrafePlayerPhase; | ||
import net.minecraft.world.level.Level; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import uk.debb.vanilla_disable.util.gamerules.Gamerules; | ||
|
||
@Mixin(DragonStrafePlayerPhase.class) | ||
public abstract class MixinDragonStrafePlayerPhase { | ||
@ModifyExpressionValue( | ||
@Redirect( | ||
method = "doServerTick", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z" | ||
) | ||
) | ||
private boolean spawnFreshEntity(boolean original) { | ||
private boolean spawnFreshEntity(Level instance, Entity entity) { | ||
if (!Gamerules.DRAGON_FIREBALLS.getBool()) { | ||
return false; | ||
} | ||
return original; | ||
return instance.addFreshEntity(entity); | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
src/main/java/uk/debb/vanilla_disable/mixin/redstone/MixinPistonBaseBlock.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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package uk.debb.vanilla_disable.mixin.redstone; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyReturnValue; | ||
import net.minecraft.world.level.block.piston.PistonBaseBlock; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import uk.debb.vanilla_disable.util.gamerules.Gamerules; | ||
|
||
@Mixin(PistonBaseBlock.class) | ||
public abstract class MixinPistonBaseBlock { | ||
@ModifyReturnValue(method = "triggerEvent", at = @At("RETURN")) | ||
private boolean cancelTriggeringEvent(boolean original) { | ||
@Inject(method = "triggerEvent", at = @At("HEAD"), cancellable = true) | ||
private void cancelTriggeringEvent(CallbackInfoReturnable<Boolean> cir) { | ||
if (!Gamerules.PISTON_ENABLED.getBool()) { | ||
return false; | ||
cir.setReturnValue(false); | ||
} | ||
return original; | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
src/main/java/uk/debb/vanilla_disable/mixin/worldgen/MixinStructureCheck.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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package uk.debb.vanilla_disable.mixin.worldgen; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyReturnValue; | ||
import net.minecraft.world.level.ChunkPos; | ||
import net.minecraft.world.level.levelgen.structure.Structure; | ||
import net.minecraft.world.level.levelgen.structure.StructureCheck; | ||
import net.minecraft.world.level.levelgen.structure.StructureCheckResult; | ||
import net.minecraft.world.level.levelgen.structure.structures.JigsawStructure; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import uk.debb.vanilla_disable.util.gamerules.Gamerules; | ||
import uk.debb.vanilla_disable.util.maps.Maps; | ||
|
||
@Mixin(StructureCheck.class) | ||
public abstract class MixinStructureCheck implements Maps { | ||
@ModifyReturnValue(method = "checkStart", at = @At("RETURN")) | ||
private StructureCheckResult cancelCheckingStart(StructureCheckResult original, ChunkPos chunkPos, Structure structure, boolean bl) { | ||
@Inject(method = "checkStart", at = @At("HEAD"), cancellable = true) | ||
private void cancelCheckingStart(ChunkPos chunkPos, Structure structure, boolean bl, CallbackInfoReturnable<StructureCheckResult> cir) { | ||
Gamerules gameRule; | ||
if (structure instanceof JigsawStructure jigsawStructure) { | ||
gameRule = structureCheckStringMap.get(jigsawStructure.startPool.unwrap().orThrow().location().toString()); | ||
} else { | ||
gameRule = structureCheckStructureTypeMap.get(structure.type()); | ||
} | ||
if (gameRule != null && !gameRule.getBool()) { | ||
return StructureCheckResult.START_NOT_PRESENT; | ||
cir.setReturnValue(StructureCheckResult.START_NOT_PRESENT); | ||
} | ||
return original; | ||
} | ||
} |
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