Skip to content

Commit

Permalink
Fix end portals not being affected by the portals rule type
Browse files Browse the repository at this point in the history
Fixes #309
  • Loading branch information
haykam821 authored and ashhhleyyy committed Jan 30, 2025
1 parent ba8769b commit 1ddb491
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
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);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/plasmid.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"chat.ServerPlayerEntityMixin",
"game.portal.EntityMixin",
"game.portal.SignBlockEntityMixin",
"game.rule.BlockPatternMixin",
"game.rule.EquippableComponentMixin",
"game.rule.HungerManagerMixin",
"game.rule.LootTableMixin",
Expand Down

0 comments on commit 1ddb491

Please sign in to comment.