generated from FabricMC/fabric-example-mod
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #3 prevent dummies from getting the beacon advancement
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/java/io/github/misode/packtest/mixin/BeaconBlockEntityMixin.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 @@ | ||
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; | ||
} | ||
} |
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