-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openFakePlayerEnderChest 添加设定值 ender_chest
- Loading branch information
Showing
5 changed files
with
50 additions
and
7 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
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,23 @@ | ||
package dev.dubhe.gugle.carpet; | ||
|
||
import carpet.api.settings.CarpetRule; | ||
import carpet.api.settings.Validator; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
|
||
public class GcaValidators { | ||
public static class EnderChest extends Validator<String> { | ||
public static final List<String> OPTIONS = List.of("true", "false", "ender_chest"); | ||
|
||
@Override | ||
public String validate(@Nullable CommandSourceStack commandSourceStack, CarpetRule<String> carpetRule, String newValue, String userString) { | ||
return !OPTIONS.contains(newValue) ? null : newValue; | ||
} | ||
|
||
public String description() { | ||
return "Can be limited to 'ender_chest' for use EnderChest open only, true/false for open directly/unable"; | ||
} | ||
} | ||
} |
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
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
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,16 @@ | ||
package dev.dubhe.gugle.carpet.tools; | ||
|
||
import dev.dubhe.gugle.carpet.GcaSetting; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Items; | ||
|
||
public class GcaUtils { | ||
public static boolean openFakePlayerEnderChest(Player player) { | ||
if ("true".equals(GcaSetting.openFakePlayerEnderChest)) return true; | ||
return "ender_chest".equals(GcaSetting.openFakePlayerEnderChest) && | ||
( | ||
player.getMainHandItem().is(Items.ENDER_CHEST) || | ||
player.getOffhandItem().is(Items.ENDER_CHEST) | ||
); | ||
} | ||
} |