Skip to content

Commit b86b97c

Browse files
committed
Replace all occurrences of Text.of with Text.literal, since it's cheaper to execute
1 parent 5dd7241 commit b86b97c

8 files changed

Lines changed: 39 additions & 38 deletions

File tree

src/main/java/net/evmodder/KeyBound/Keybinds/ClickUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ record ClickEvent(int syncId, int slotId, int button, SlotActionType actionType)
1414
ClickEvent(int slotId, int button, SlotActionType actionType){this(0, slotId, button, actionType);}
1515
}
1616

17-
private final int MAX_CLICKS;
17+
public final int MAX_CLICKS;
1818
private final int[] tickDurationArr;
1919
private int tickDurIndex, sumClicksInDuration;
2020
private long lastTick;

src/main/java/net/evmodder/KeyBound/Keybinds/Keybind2b2tHighwayTravelHelper.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ private boolean selectBlocksInHotbar(String path){
132132
if(path == null || Registries.ITEM.getId(item).getPath().equals(path)) break;
133133
}
134134
if(i == 9){
135-
client.player.sendMessage(Text.of("(!) No blocks in hotbar"), true);
135+
client.player.sendMessage(Text.literal("(!) No blocks in hotbar"), true);
136136
return false;
137137
}
138138
client.player.getInventory().selectedSlot = i;
139139
client.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(i));
140-
client.player.sendMessage(Text.of("Selected hotbar blocks"), true);
140+
client.player.sendMessage(Text.literal("Selected hotbar blocks"), true);
141141
// Main.LOGGER.info("Selected hotbar blocks");
142142
return true;
143143
}
@@ -198,7 +198,7 @@ private boolean fillHighwayHole(String useBlock){
198198
if(!holdingBlock) selectBlocksInHotbar(useBlock);
199199
String path = Registries.ITEM.getId(client.player.getStackInHand(hand).getItem()).getPath();
200200
if(useBlock != null && !path.equals(useBlock)){
201-
client.player.sendMessage(Text.of("(!) Missing block: "+useBlock), true);
201+
client.player.sendMessage(Text.literal("(!) Missing block: "+useBlock), true);
202202
//return false;
203203
}
204204
return placeBlock(bp, hand);
@@ -258,12 +258,12 @@ private boolean selectPickaxeInHotbar(){
258258
int i=0;
259259
for(; i<9 && client.player.getInventory().getStack(i).getItem() instanceof PickaxeItem == false; ++i);
260260
if(i == 9){
261-
client.player.sendMessage(Text.of("(!) No pickaxe in hotbar"), true);
261+
client.player.sendMessage(Text.literal("(!) No pickaxe in hotbar"), true);
262262
return false;
263263
}
264264
client.player.getInventory().selectedSlot = i;
265265
client.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(i));
266-
client.player.sendMessage(Text.of("Selected hotbar pickaxe"), true);
266+
client.player.sendMessage(Text.literal("Selected hotbar pickaxe"), true);
267267
// Main.LOGGER.info("Selected hotbar pickaxe");
268268
return true;
269269
}
@@ -272,7 +272,7 @@ private boolean putOutFireAndMineObstacles(){
272272
BlockPos bp = client.player.getBlockPos();
273273
if(client.world.getBlockState(bp).getBlock() instanceof AbstractFireBlock){
274274
client.interactionManager.updateBlockBreakingProgress(bp, getBlockBreakingSide(bp));
275-
client.player.sendMessage(Text.of("Put out a fire"), true);
275+
client.player.sendMessage(Text.literal("Put out a fire"), true);
276276
// Main.LOGGER.info("Put out a fire");
277277
return true;
278278
}
@@ -318,7 +318,7 @@ private boolean putOutFireAndMineObstacles(){
318318
isMining = true;
319319
//if(client.player.getMainHandStack().getItem() instanceof PickaxeItem) return false;
320320
client.interactionManager.updateBlockBreakingProgress(bpDig, getBlockBreakingSide(bpDig));
321-
client.player.sendMessage(Text.of("Mining block: ").copy().append(client.world.getBlockState(bpDig).getBlock().getName())
321+
client.player.sendMessage(Text.literal("Mining block: ").copy().append(client.world.getBlockState(bpDig).getBlock().getName())
322322
// .append(" yaw:"+client.player.getYaw()+", dirX:"+dir.x+",dirZ:"+dir.z+", xyz: ")
323323
// .append(bp.getX()+","+bp.getY()+","+bp.getZ())
324324
, true);
@@ -338,7 +338,7 @@ private boolean barfTrash(KeybindEjectJunk ejectJunk){
338338
boolean didBarf = false;
339339
for(int i=9; i<36; ++i) if(ejectJunk.shouldEject(client.player.getInventory().getStack(i))){
340340
// if(!didBarf){
341-
// client.player.sendMessage(Text.of("Tossed item: ").copy().append(client.player.getInventory().getStack(i).getName()), true);
341+
// client.player.sendMessage(Text.literal("Tossed item: ").copy().append(client.player.getInventory().getStack(i).getName()), true);
342342
// Main.LOGGER.info("Tossed item: "+client.player.getInventory().getStack(i).getName().getLiteralString());
343343
// }
344344
client.interactionManager.clickSlot(0, i, 1, SlotActionType.THROW, client.player);
@@ -351,7 +351,7 @@ public Keybind2b2tHighwayTravelHelper(KeybindEjectJunk ejectJunk){
351351
client = MinecraftClient.getInstance();
352352
KeyBindingHelper.registerKeyBinding(new EvKeybind("ebounce_travel_helper", ()->{
353353
String status = "2b2t Travel Helper: "+((isEnabled=!isEnabled) ? "enabled" : "disabled");
354-
client.player.sendMessage(Text.of(status), true);
354+
client.player.sendMessage(Text.literal(status), true);
355355
}));
356356

357357
ClientTickEvents.START_CLIENT_TICK.register(_0 -> {
@@ -360,7 +360,7 @@ public Keybind2b2tHighwayTravelHelper(KeybindEjectJunk ejectJunk){
360360
Item chestItem = client.player.getInventory().getArmorStack(2).getItem();
361361
Identifier chestItemId = Registries.ITEM.getId(chestItem);
362362
if(chestItemId == null || !chestItemId.getPath().equals("elytra")){
363-
client.player.sendMessage(Text.of("Not wearing elytra"), true);
363+
client.player.sendMessage(Text.literal("Not wearing elytra"), true);
364364
return;
365365
}
366366
int y = client.player.getBlockY();
@@ -371,14 +371,14 @@ public Keybind2b2tHighwayTravelHelper(KeybindEjectJunk ejectJunk){
371371
if(y != 119 && y != 120) return;
372372

373373
if(fillHighwayHole(y == 119 ? null : "obsidian")){
374-
client.player.sendMessage(Text.of("Filled a hole"), true);
374+
client.player.sendMessage(Text.literal("Filled a hole"), true);
375375
// Main.LOGGER.info("Filled a hole");
376376
return;
377377
}
378378
if(putOutFireAndMineObstacles()) return;
379379

380380
if(ejectJunk != null && barfTrash(ejectJunk)){
381-
// client.player.sendMessage(Text.of("Tossed trashed"), true);
381+
// client.player.sendMessage(Text.literal("Tossed trashed"), true);
382382
// Main.LOGGER.info("Tossed trash");
383383
}
384384
});

src/main/java/net/evmodder/KeyBound/Keybinds/KeybindAIETravelHelper.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public KeybindAIETravelHelper(){
4141
KeyBindingHelper.registerKeyBinding(new EvKeybind("aie_travel_helper", ()->{
4242
if(!isEnabled){
4343
if(client.player == null || client.world == null) return;
44-
if(!client.player.isGliding()){client.player.sendMessage(Text.of("You need to be flying first"), true); return;}
44+
if(!client.player.isGliding()){client.player.sendMessage(Text.literal("You need to be flying first"), true); return;}
4545
enabledTs = System.currentTimeMillis();
4646
lastY = client.player.getY();
4747
}
4848
isEnabled = !isEnabled;
49-
client.player.sendMessage(Text.of("AutomaticInfiniteElytra Travel Helper: "+(isEnabled ? "enabled" : "disabled")), true);
49+
client.player.sendMessage(Text.literal("AutomaticInfiniteElytra Travel Helper: "+(isEnabled ? "enabled" : "disabled")), true);
5050
}));
5151

5252
ClientTickEvents.START_CLIENT_TICK.register(_0 -> {
@@ -56,7 +56,7 @@ public KeybindAIETravelHelper(){
5656
ItemStack chestStack = client.player.getInventory().getArmorStack(2);
5757
// //Identifier chestItemId = Registries.ITEM.getId(chestStack.getItem()); // Not really needed thanks to
5858
// if(chestStack.getItem() != Items.ELYTRA){
59-
// client.player.sendMessage(Text.of("Not wearing elytra"), true);
59+
// client.player.sendMessage(Text.literal("Not wearing elytra"), true);
6060
// isEnabled = false;
6161
// return;
6262
// }
@@ -75,7 +75,7 @@ public KeybindAIETravelHelper(){
7575
if(stoppedFlyingTs == 0) stoppedFlyingTs = System.currentTimeMillis();
7676
final long countDownToKick = safeKickDelay - (System.currentTimeMillis() - enabledTs);
7777
if(countDownToKick > 0){
78-
client.player.sendMessage(Text.of("AIE helper will disconnect due to not-flying in: " + TextUtils.formatTime(countDownToKick)), true);
78+
client.player.sendMessage(Text.literal("AIE helper will disconnect due to not-flying in: " + TextUtils.formatTime(countDownToKick)), true);
7979
return;
8080
}
8181
stoppedFlyingTs = 0;
@@ -96,19 +96,19 @@ public KeybindAIETravelHelper(){
9696
}
9797
else client.interactionManager.clickSlot(0, 6, i-36, SlotActionType.SWAP, client.player); // Swap with hotbar
9898
if(!atKickY){
99-
client.player.sendMessage(Text.of("Swapped to fresh elytra"), true);
99+
client.player.sendMessage(Text.literal("Swapped to fresh elytra"), true);
100100
return;
101101
}
102102
}
103103
if(!atKickY && dur > kickDur && waitForSafePitch && (pitch < safePitchLower || pitch > safePitchUpper || pitch <= lastPitch)){
104-
client.player.sendMessage(Text.of("Current AIE helper settings will trigger disconnect due to too low dur"), true);
104+
client.player.sendMessage(Text.literal("Current AIE helper settings will trigger disconnect due to too low dur"), true);
105105
return;
106106
}
107107
}
108108
if(!atKickY && dur > kickDur){
109109
final long countDownToKick = safeKickDelay - (System.currentTimeMillis() - enabledTs);
110110
if(countDownToKick > 0){
111-
client.player.sendMessage(Text.of("Current AIE helper settings will trigger disconnect due to too low "
111+
client.player.sendMessage(Text.literal("Current AIE helper settings will trigger disconnect due to too low "
112112
+(atUnsafeY?"Y":"dur")+" in: "+TextUtils.formatTime(countDownToKick)), true);
113113
return;
114114
}

src/main/java/net/evmodder/KeyBound/Keybinds/KeybindInventoryOrganize.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ private void organizeInventory(){
128128
Main.LOGGER.warn("InvOrganize: Unable to unequip incorrect armor - no room in inventory!");
129129
return;
130130
}
131-
//client.player.sendMessage(Text.of("Click: Unequipping armor"), false);
131+
//client.player.sendMessage(Text.literal("Click: Unequipping armor"), false);
132132
clicks.add(new ClickEvent(p.a, 0, SlotActionType.QUICK_MOVE));
133133
}
134-
//client.player.sendMessage(Text.of("Click: "+dstSlot+" Equipping armor"), false);
134+
//client.player.sendMessage(Text.literal("Click: "+dstSlot+" Equipping armor"), false);
135135
clicks.add(new ClickEvent(srcSlot, 0, SlotActionType.QUICK_MOVE));
136136
swapSlots(simSlots, emptySlots, srcSlot, dstSlot);
137137
doneSlots[dstSlot] = true;
@@ -158,7 +158,7 @@ private void organizeInventory(){
158158
final int srcSlot = findSlotWithItem(simSlots, p.b.getPath(), doneSlots);
159159
//if(srcSlot == -1) continue;
160160
if(srcSlot < 36) continue; // We want items coming FROM hotbar/offhand
161-
//client.player.sendMessage(Text.of("Click: "+dstSlot+" Hotbar->Anywhere (sorting"), false);
161+
//client.player.sendMessage(Text.literal("Click: "+dstSlot+" Hotbar->Anywhere (sorting"), false);
162162
if(srcSlot == 45) clicks.add(new ClickEvent(dstSlot, 40, SlotActionType.SWAP));
163163
else clicks.add(new ClickEvent(dstSlot, srcSlot-36, SlotActionType.SWAP));
164164

@@ -173,7 +173,7 @@ private void organizeInventory(){
173173
for(int i=36; i<45; ++i) if(!doneSlots[i] && !emptySlots[i]/* && !usedHotbarAndOffhandSlots[i-36]*/){
174174
final int originalCount = simSlots[i].getCount();
175175
if(simulateShiftClick(simSlots, emptySlots, /*fromArmor=*/false, i) < originalCount){
176-
//client.player.sendMessage(Text.of("Click: "+i+" Hotbar->UpperInv (cleaning)"), false);
176+
//client.player.sendMessage(Text.literal("Click: "+i+" Hotbar->UpperInv (cleaning)"), false);
177177
clicks.add(new ClickEvent(i, 0, SlotActionType.QUICK_MOVE));
178178
}
179179
}
@@ -201,7 +201,7 @@ private void organizeInventory(){
201201

202202
// Attempt to pick an empty hotbar/offhand slot to swap with
203203
int hb = 40; for(int i=0; i<9; ++i) if(emptySlots[i+36]){hb = i; break;}
204-
//client.player.sendMessage(Text.of("Click: "+dstSlot+" UpperInv->Hotbar->UpperInv"), false);
204+
//client.player.sendMessage(Text.literal("Click: "+dstSlot+" UpperInv->Hotbar->UpperInv"), false);
205205
clicks.add(new ClickEvent(srcSlot, hb, SlotActionType.SWAP));
206206
clicks.add(new ClickEvent(dstSlot, hb, SlotActionType.SWAP));
207207
if(!emptySlots[dstSlot] || !emptySlots[hb == 40 ? 45 : hb+36]){
@@ -226,7 +226,7 @@ private void organizeInventory(){
226226
if(dstSlot < 36) continue; // items going INTO hotbar/offhand
227227
final int srcSlot = findSlotWithItem(simSlots, p.b.getPath(), doneSlots);
228228
if(srcSlot == -1) continue;
229-
//client.player.sendMessage(Text.of("Click: "+dstSlot+" UpperInv->Hotbar"), false);
229+
//client.player.sendMessage(Text.literal("Click: "+dstSlot+" UpperInv->Hotbar"), false);
230230
if(dstSlot == 45) clicks.add(new ClickEvent(srcSlot, 40, SlotActionType.SWAP));
231231
else clicks.add(new ClickEvent(srcSlot, dstSlot-36, SlotActionType.SWAP));
232232

@@ -239,11 +239,11 @@ private void organizeInventory(){
239239
Main.inventoryUtils.executeClicks(client, clicks,
240240
//_->true,
241241
_0->{
242-
//client.player.sendMessage(Text.of("click "+c.slotId()+" "+c.button()+" "+c.actionType()), false);
242+
//client.player.sendMessage(Text.literal("click "+c.slotId()+" "+c.button()+" "+c.actionType()), false);
243243
return true;
244244
},
245245
()->{
246-
//client.player.sendMessage(Text.of("InvOrganize: done! clicks required: "+numClicks), false);
246+
//client.player.sendMessage(Text.literal("InvOrganize: done! clicks required: "+numClicks), false);
247247
Main.LOGGER.info("InvOrganize: done! clicks required: "+numClicks);
248248
ongoingOrganize = false;
249249
});

src/main/java/net/evmodder/KeyBound/Keybinds/KeybindMapCopy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public final class KeybindMapCopy{
2121
private static boolean ongoingCopy;
2222
private static long lastCopy;
2323
private static final long copyCooldown = 250l;
24-
private boolean PRESERVE_MAP_POS = true;
24+
private final boolean PRESERVE_MAP_POS = true;
2525
private final ItemStack EMPTY_ITEM = new ItemStack(Items.AIR);
2626

2727
// Shift-click results:
@@ -62,6 +62,7 @@ private final boolean simShiftClick(final ArrayDeque<ClickEvent> clicks, final I
6262
return false;
6363
}
6464

65+
@SuppressWarnings("unused")
6566
private void copyMapArtInInventory(){
6667
if(ongoingCopy){Main.LOGGER.warn("MapCopy: Already ongoing"); return;}
6768
//

src/main/java/net/evmodder/KeyBound/Keybinds/KeybindSpamclick.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public KeybindSpamclick(){
2525
KeyBindingHelper.registerKeyBinding(new EvKeybind("incr_clicks", ()->{
2626
//if(client.currentScreen instanceof InventoryScreen == false){Main.LOGGER.warn("SpamClickIncrClick: not in InventoryScreen"); return;}
2727
if(numClicks >= 1000){numClicks = 0; numTicks = 0;}//<<<<<<<<<<<<<<<<<
28-
client.player.sendMessage(Text.of("SpamClick: numClicks="+(numClicks+=(Screen.hasShiftDown() ? 1 : 20))+" numTicks="+numTicks), /*overlay=*/false);
28+
client.player.sendMessage(Text.literal("SpamClick: numClicks="+(numClicks+=(Screen.hasShiftDown() ? 1 : 20))+" numTicks="+numTicks), /*overlay=*/false);
2929
}));
3030

3131
KeyBindingHelper.registerKeyBinding(new EvKeybind("incr_ticks", ()->{
3232
//if(client.currentScreen instanceof InventoryScreen == false){Main.LOGGER.warn("SpamClickIncrTicks: not in InventoryScreen"); return;}
33-
client.player.sendMessage(Text.of("SpamClick: numClicks="+numClicks+" numTicks="+(numTicks+=(Screen.hasShiftDown() ? 20 : 1))), /*overlay=*/false);
33+
client.player.sendMessage(Text.literal("SpamClick: numClicks="+numClicks+" numTicks="+(numTicks+=(Screen.hasShiftDown() ? 20 : 1))), /*overlay=*/false);
3434
}));
3535

3636
KeyBindingHelper.registerKeyBinding(new EvKeybind("spam_click", ()->{
@@ -42,7 +42,7 @@ public KeybindSpamclick(){
4242
else lastPress = ts;
4343
ongoingSpamClick = true;
4444

45-
client.player.sendMessage(Text.of("SpamClick: executing "+numClicks+"c in "+numTicks+"t"), /*overlay=*/false);
45+
client.player.sendMessage(Text.literal("SpamClick: executing "+numClicks+"c in "+numTicks+"t"), /*overlay=*/false);
4646

4747
ArrayDeque<ClickEvent> clicks = new ArrayDeque<>();
4848
for(int i=0; i<numClicks; ++i){
@@ -52,12 +52,12 @@ public KeybindSpamclick(){
5252
}
5353
final int msPerClick = (int)((numTicks*50l)/numClicks);
5454
if(numTicks*50l % numClicks != 0){
55-
client.player.sendMessage(Text.of("SpamClick: ms per click is not exact: "+((numTicks*50d)/numClicks)).copy().withColor(16763080), /*overlay=*/false);
55+
client.player.sendMessage(Text.literal("SpamClick: ms per click is not exact: "+((numTicks*50d)/numClicks)).copy().withColor(16763080), /*overlay=*/false);
5656
}
5757
ClickUtils.executeClicksLEGACY(client, clicks, msPerClick, /*MAX_CLICKS_PER_SECOND=*/Integer.MAX_VALUE, _0->true, ()->{
5858
ongoingSpamClick = false;
5959
//Main.LOGGER.info("SpamClick: DONE");
60-
if(client.player != null) client.player.sendMessage(Text.of("SpamClick: DONE"), /*overlay=*/false);
60+
if(client.player != null) client.player.sendMessage(Text.literal("SpamClick: DONE"), /*overlay=*/false);
6161
});
6262
}, s->s instanceof InventoryScreen));
6363
}

src/main/java/net/evmodder/KeyBound/SendOnServerJoin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public class SendOnServerJoin{
4343
if(System.currentTimeMillis() - loadedAt < JOIN_DELAY) return;
4444

4545
//Main.LOGGER.info("JOIN_DELAY reached, triggering commands...");
46-
client.player.sendMessage(Text.of("Sending "+messages.length+" msgs/cmds"), false);
46+
client.player.sendMessage(Text.literal("Sending "+messages.length+" msgs/cmds"), false);
4747
ClientPlayNetworkHandler handler = client.getNetworkHandler();
4848
for(String msg : messages){
4949
msg = msg.trim();
50-
//client.player.sendMessage(Text.of("Sending "+(msg.startsWith("/")?"cmd":"msg")+": "+msg), false);
50+
//client.player.sendMessage(Text.literal("Sending "+(msg.startsWith("/")?"cmd":"msg")+": "+msg), false);
5151
if(msg.startsWith("/")) handler.sendChatCommand(msg.substring(1));
5252
else handler.sendChatMessage(msg);
5353
}

src/main/resources/keybound.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ temp_event_timestamp: 1738990800 # Fri, Feb7, 2025, 11pm CST
88

99
#========== MapArt Tools ==========#
1010
# 2b2t will kick you for sending 200+ clicks in 70 ticks (last checked: 2025-04-27)
11-
limiter_clicks_in_duration: 79
12-
limiter_duration_ticks: 81
11+
limiter_clicks_in_duration: 80
12+
limiter_duration_ticks: 85
1313

1414
keybind.mapart.load_from_shulker: true
1515
keybind.mapart.take_from_shulker: true

0 commit comments

Comments
 (0)