-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix end portals not being affected by the portals rule type
Fixes #309
- Loading branch information
1 parent
ba8769b
commit 1ddb491
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/xyz/nucleoid/plasmid/mixin/game/rule/BlockPatternMixin.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,32 @@ | ||
package xyz.nucleoid.plasmid.mixin.game.rule; | ||
|
||
import net.minecraft.block.EndPortalFrameBlock; | ||
import net.minecraft.block.pattern.BlockPattern; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.WorldView; | ||
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 xyz.nucleoid.plasmid.impl.game.manager.GameSpaceManagerImpl; | ||
import xyz.nucleoid.plasmid.api.game.rule.GameRuleType; | ||
import xyz.nucleoid.stimuli.event.EventResult; | ||
|
||
@Mixin(BlockPattern.class) | ||
public class BlockPatternMixin { | ||
@Inject( | ||
method = "searchAround", | ||
at = @At("HEAD") | ||
) | ||
private void applyPortalsRuleToEndPortals(WorldView worldView, BlockPos pos, CallbackInfoReturnable<BlockPattern.Result> ci) { | ||
if (!(worldView instanceof World world) || ((BlockPattern) (Object) this) != EndPortalFrameBlock.getCompletedFramePattern()) { | ||
return; | ||
} | ||
|
||
var gameSpace = GameSpaceManagerImpl.get().byWorld(world); | ||
if (gameSpace != null && gameSpace.getBehavior().testRule(GameRuleType.PORTALS) == EventResult.DENY) { | ||
ci.setReturnValue(null); | ||
} | ||
} | ||
} |
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