Skip to content

Commit

Permalink
Fix #3 prevent dummies from getting the beacon advancement
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Sep 27, 2024
1 parent cefd92f commit 43e4d0c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.github.misode.packtest.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
import io.github.misode.packtest.dummy.Dummy;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BeaconBlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import java.util.List;

/**
* Prevents dummies from receiving the "Bring Home the Beacon" advancement
* due to the beacons used as part of the test status indicator
*/
@Mixin(BeaconBlockEntity.class)
public class BeaconBlockEntityMixin {

@ModifyExpressionValue(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntitiesOfClass(Ljava/lang/Class;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;"))
private static <T> List<T> preventBeaconAdvancement(List<T> entities, @Local(argsOnly = true) Level level, @Local(argsOnly = true, ordinal = 0) BlockPos pos) {
BlockPos structurePos = pos.east().south().above(2);
if (level.getBlockState(structurePos).is(Blocks.STRUCTURE_BLOCK)) {
return entities.stream().filter(e -> !(e instanceof Dummy)).toList();
}
return entities;
}
}
1 change: 1 addition & 0 deletions src/main/resources/packtest.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_21",
"mixins": [
"ArgumentTypeInfosMixin",
"BeaconBlockEntityMixin",
"BlockPredicateArgumentBlockMixin",
"BlockPredicateArgumentMixin",
"BlockPredicateArgumentTagMixin",
Expand Down

0 comments on commit 43e4d0c

Please sign in to comment.