Skip to content

Commit 4b3a4ef

Browse files
committed
Hide enchantment cracking
1 parent 13486d4 commit 4b3a4ef

File tree

4 files changed

+28
-51
lines changed

4 files changed

+28
-51
lines changed

README.txt

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -78,49 +78,10 @@ Common problems with setup:
7878
/csimgen (deprecated) - simulated the generation of a world generator.
7979
/ctemprule - get and set variables which affect the workings of clientcommands. TempRules reset
8080
when you log out of a world.
81-
/cenchant - manipulate the XP seed so that you can get the specified enchantments in an
82-
enchantment table. This only works if the enchantment seed is cracked (see below).
83-
First you specify the type of item you want to enchant, and then zero or more
84-
enchantment specifications. There are two types of enchantment specifications:
85-
`with` - This enchantment should be included in the enchantments on the item.
86-
`without` - This enchantment should not be included in the enchantments on
87-
the item.
88-
In addition to the enchantment, you also specify the level of the enchantment
89-
you would like. This level can either be an exact number, or a range in the
90-
format min..max (e.g. `1..5`).
91-
Once you run the command, the enchantment cracker may automatically throw items
92-
onto the ground beneath you. Do not look anywhere else while this is happening,
93-
as you may not be able to pick the items back up again. Once this is done,
94-
follow the instructions the command gives you.
95-
Examples:
96-
`/cenchant diamond_sword with looting 3 without smite 1..5 without bane_of_arthropods 1..5`
97-
`/cenchant fishing_rod with lure 3 with luck_of_the_sea 3`
9881
/ctime - queries or changes the time client-side. All subcommands except `mock` and `unmock`
9982
only query the time. Using `/ctime mock <daytime> [doDaylightCycle]` starts mocking
10083
the time, and `/ctime unmock` stops mocking the time. Mocking the time means
10184
making it appear to be a certain time on the client-side only, while the server-
10285
side time (which is the time that matters for mob spawning etc.) is unaffected.
10386
`/ctime mock` is intended for builders to inspect their builds at different times of
10487
day.
105-
106-
===== ENCHANTING PREDICTION =====
107-
WARNING: enchanting prediction is very cheaty and could get you banned from a server if an
108-
operator finds out. However, given its client-side-only nature it's very difficult
109-
to detect. There is also a chance it may be patched.
110-
111-
Enchanting prediction can be used to see all items you would get on an enchantment in an
112-
enchantment table before you actually enchant the item. To use enchanting prediction,
113-
you must follow the following steps at the start of every enchanting session:
114-
1) run `/ctemprule set enchantingPrediction true`
115-
2) waste your first enchantment (enchant a cheap item)
116-
3) place another cheap item into the enchantment table (don't enchant it)
117-
4) block some more bookshelves with a torch
118-
5) repeat steps 3 and 4 until you're in state CRACKED_ENCH_SEED
119-
6) enchant the item (you can remove the torches now)
120-
7) repeat steps 3-6 once or twice more, until you're in state CRACKED
121-
8) there are certain common actions which will reset the process; clientcommands will
122-
notify you when this happens. You just have to avoid doing these actions.
123-
124-
Once you are in state CRACKED, you will be able to see all enchantments before you enchant
125-
the item. You will stay in state CRACKED for the duration of the enchantment session unless
126-
you do one of the actions from step 8. If this happens, you have to start from step 2 again.

src/main/java/net/earthcomputer/clientcommands/TempRules.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,16 @@ public class TempRules {
2020
private static Map<String, Rule<?>> rules = new HashMap<>();
2121

2222
public static final Rule<Boolean> ENCHANTING_PREDICTION = registerRule("enchantingPrediction", DataType.BOOLEAN,
23-
Boolean.FALSE);
23+
Boolean.FALSE).setHidden();
2424
public static final Rule<EnchantmentCracker.EnumCrackState> ENCHANTING_CRACK_STATE = registerRule(
2525
"enchantingCrackState", EnumDataType.of(EnchantmentCracker.EnumCrackState.class),
26-
EnchantmentCracker.EnumCrackState.UNCRACKED);
26+
EnchantmentCracker.EnumCrackState.UNCRACKED).setReadOnly().setHidden();
2727
public static final Rule<Double> BLOCK_REACH_DISTANCE = registerRule("blockReachDistance", DataType.DOUBLE.min(0),
2828
5.0);
2929
public static final Rule<Boolean> TOOL_BREAK_PROTECTION = registerRule("toolBreakProtection", DataType.BOOLEAN,
3030
Boolean.FALSE);
31-
public static final Rule<Boolean> MOCKING_TIME = registerRule("mockingTime", DataType.BOOLEAN, Boolean.FALSE);
32-
33-
static {
34-
ENCHANTING_CRACK_STATE.setReadOnly();
35-
MOCKING_TIME.setReadOnly();
36-
}
31+
public static final Rule<Boolean> MOCKING_TIME = registerRule("mockingTime", DataType.BOOLEAN, Boolean.FALSE)
32+
.setReadOnly();
3733

3834
public static boolean hasRule(String name) {
3935
return rules.containsKey(name);
@@ -67,6 +63,7 @@ public static class Rule<T> {
6763
private T defaultValue;
6864
private T value;
6965
private boolean readOnly = false;
66+
private boolean hidden = false;
7067
private List<Consumer<ValueChangeEvent<T>>> listeners = new ArrayList<>();
7168

7269
private Rule(String name, DataType<T> dataType, T defaultValue) {
@@ -111,8 +108,18 @@ public boolean isReadOnly() {
111108
return readOnly;
112109
}
113110

114-
public void setReadOnly() {
111+
public Rule<T> setReadOnly() {
115112
readOnly = true;
113+
return this;
114+
}
115+
116+
public boolean isHidden() {
117+
return hidden;
118+
}
119+
120+
public Rule<T> setHidden() {
121+
hidden = true;
122+
return this;
116123
}
117124

118125
public void addValueChangeListener(Consumer<ValueChangeEvent<T>> listener) {

src/main/java/net/earthcomputer/clientcommands/command/CommandCEnchant.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import net.earthcomputer.clientcommands.EnchantmentCracker;
1010
import net.earthcomputer.clientcommands.EnchantmentCracker.EnchantManipulationStatus;
11+
import net.earthcomputer.clientcommands.TempRules;
1112
import net.earthcomputer.clientcommands.task.TaskManager;
1213
import net.minecraft.command.CommandException;
1314
import net.minecraft.command.ICommandSender;
@@ -34,6 +35,11 @@ public String getUsage(ICommandSender sender) {
3435
return "commands.cenchant.usage";
3536
}
3637

38+
@Override
39+
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
40+
return TempRules.ENCHANTING_CRACK_STATE.getValue() == EnchantmentCracker.EnumCrackState.CRACKED;
41+
}
42+
3743
@Override
3844
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
3945
if (args.length < 4) {

src/main/java/net/earthcomputer/clientcommands/command/CommandTempRule.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ public List<String> getTabCompletions(MinecraftServer server, ICommandSender sen
9898
return getListOfStringsMatchingLastWord(args, "get", "set", "reset", "list");
9999
} else if (args.length == 2 && !"list".equals(args[0])) {
100100
if ("get".equals(args[0])) {
101-
return getListOfStringsMatchingLastWord(args, TempRules.getRuleNames());
102-
} else {
103101
return getListOfStringsMatchingLastWord(args,
104-
TempRules.getRules().stream().filter(rule -> !rule.isReadOnly()).map(TempRules.Rule::getName)
102+
TempRules.getRules().stream().filter(rule -> !rule.isHidden()).map(TempRules.Rule::getName)
105103
.sorted().collect(Collectors.toList()));
104+
} else {
105+
return getListOfStringsMatchingLastWord(args,
106+
TempRules.getRules().stream().filter(rule -> !rule.isReadOnly())
107+
.filter(rule -> !rule.isHidden()).map(TempRules.Rule::getName).sorted()
108+
.collect(Collectors.toList()));
106109
}
107110
} else if (args.length == 3 && "set".equals(args[0]) && TempRules.hasRule(args[1])) {
108111
TempRules.Rule<?> rule = TempRules.getRule(args[1]);

0 commit comments

Comments
 (0)