-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix containers remaining open by vanished player in certain conditions (
#42) * Fix containers remaining open by vanished player * Add changelog --------- Co-authored-by: Drex <[email protected]>
- Loading branch information
Showing
3 changed files
with
28 additions
and
0 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
24 changes: 24 additions & 0 deletions
24
src/main/java/me/drex/vanish/mixin/ContainerOpenersCountMixin.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,24 @@ | ||
package me.drex.vanish.mixin; | ||
|
||
import me.drex.vanish.api.VanishAPI; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.block.entity.ContainerOpenersCounter; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
import java.util.function.Predicate; | ||
|
||
@Mixin(ContainerOpenersCounter.class) | ||
public class ContainerOpenersCountMixin { | ||
@ModifyArg( | ||
method = "getPlayersWithContainerOpen", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/world/level/Level;getEntities(Lnet/minecraft/world/level/entity/EntityTypeTest;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;)Ljava/util/List;"), | ||
index = 2 | ||
) | ||
private Predicate<Player> vanish_excludeVanished(Predicate<Player> predicate) { | ||
return predicate.and(player -> !VanishAPI.isVanished(player)); | ||
} | ||
} |
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