Skip to content

Commit

Permalink
Fix containers remaining open by vanished player in certain conditions (
Browse files Browse the repository at this point in the history
#42)

* Fix containers remaining open by vanished player

* Add changelog

---------

Co-authored-by: Drex <[email protected]>
  • Loading branch information
XXMA16 and DrexHD authored Jun 21, 2024
1 parent 2e874d3 commit 092cbe8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Containers remaining open by vanished players in certain conditions

## [1.5.6] - 2024-06-20
### Added
- Prevent advancement progress config option
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/me/drex/vanish/mixin/ContainerOpenersCountMixin.java
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));
}
}
1 change: 1 addition & 0 deletions src/main/resources/vanish.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"mixins": [
"CommandSourceStackMixin",
"ContainerMixin",
"ContainerOpenersCountMixin",
"EntityGetterMixin",
"EntityMixin",
"EntitySelectorMixin",
Expand Down

0 comments on commit 092cbe8

Please sign in to comment.