Skip to content

Commit 4fa40aa

Browse files
authored
Merge pull request #249 from MrKinau/dev/1.21.2
1.21.2
2 parents 0484a61 + 410eea6 commit 4fa40aa

File tree

104 files changed

+21417
-1046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+21417
-1046
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ A list of all commands can be found in the wiki ([here](https://github.com/MrKin
8080
- 1.20.5
8181
- 1.20.6
8282
- 1.21
83+
- 1.21.1
84+
- 1.21.2
85+
- 1.21.3
8386

8487
## Discord
8588
To follow the project, get support or request features or bugs you can join my Discord: https://discord.gg/xHpCDYf

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<groupId>systems.kinau</groupId>
1313
<artifactId>FishingBot</artifactId>
14-
<version>2.12.5</version>
14+
<version>2.12.8</version>
1515
<name>FishingBot</name>
1616
<description>An AFK fishing bot for Minecraft</description>
1717

src/main/java/systems/kinau/fishingbot/bot/Enchantment.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ public void read(ByteArrayDataInputWrapper in, int protocolId) {
4444
this.level = Packet.readVarInt(in);
4545
this.enchantmentType = Registries.ENCHANTMENT.getEnchantmentName(enchantmentId, protocolId);
4646
}
47+
48+
@Override
49+
public String toString(int protocolId) {
50+
return "{enchantment=" + getEnchantmentType() + ",level=" + level + "}";
51+
}
4752
}

src/main/java/systems/kinau/fishingbot/bot/MovingObjectPositionBlock.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public class MovingObjectPositionBlock {
1212
private float dx;
1313
private float dy;
1414
private float dz;
15-
private boolean flag;
15+
private boolean inside;
16+
private boolean worldBorderHit;
1617
}

src/main/java/systems/kinau/fishingbot/bot/Player.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ public void onPosLookChange(PosLookChangeEvent event) {
8585
FishingBot.getInstance().getCurrentBot().getNet().sendPacket(new PacketOutTeleportConfirm(event.getTeleportId()));
8686
}
8787

88+
@EventHandler
89+
public void onPosLookChange(LookChangeEvent event) {
90+
this.yaw = event.getYaw();
91+
this.pitch = event.getPitch();
92+
this.originYaw = yaw;
93+
this.originPitch = pitch;
94+
}
95+
8896
@EventHandler
8997
public void onUpdateXP(UpdateExperienceEvent event) {
9098
if (getLevels() >= 0 && getLevels() < event.getLevel()) {
@@ -320,7 +328,7 @@ public void shiftToInventory(int slotId, Inventory inventory) {
320328
FishingBot.getInstance().getCurrentBot().getNet().sendPacket(
321329
new PacketOutClickWindow(
322330
/* player inventory */ inventory.getWindowId(),
323-
/* the clicked slot */ (short) (slotId + (inventory.getContent().size() == 63 ? 18 : 45)),
331+
/* the clicked slot */ (short) (slotId + (inventory.getContent().size() - 45)),
324332
/* use right click */ (byte) 0,
325333
/* action count starting at 1 */ inventory.getActionCounter(),
326334
/* shift click mode */ 1,
@@ -373,7 +381,7 @@ private void internalLook(float yaw, float pitch, int speed, Consumer<Boolean> o
373381
setYaw(-180 + (getYaw() - 180));
374382
if (getYaw() < -180)
375383
setYaw(180 + (getYaw() + 180));
376-
FishingBot.getInstance().getCurrentBot().getNet().sendPacket(new PacketOutPosLook(getX(), getY(), getZ(), getYaw(), getPitch(), true));
384+
FishingBot.getInstance().getCurrentBot().getNet().sendPacket(new PacketOutPosLook(getX(), getY(), getZ(), getYaw(), getPitch(), true, true));
377385
try {
378386
Thread.sleep(50);
379387
} catch (InterruptedException ignore) { }
@@ -414,6 +422,7 @@ public void openAdjacentChest(LocationUtils.Direction direction) {
414422
PacketOutBlockPlace.Hand.MAIN_HAND,
415423
x, y, z, blockFace,
416424
0.5F, 0.5F, 0.5F,
425+
false,
417426
false
418427
));
419428
if (autoSneak)
@@ -436,7 +445,7 @@ public void setHeldSlot(int heldSlot) {
436445
public void setHeldSlot(int heldSlot, boolean sendPacket) {
437446
if (sendPacket)
438447
FishingBot.getInstance().getCurrentBot().getNet().sendPacket(new PacketOutHeldItemChange(heldSlot));
439-
this.heldSlot = heldSlot;
448+
this.heldSlot = heldSlot + 36;
440449
}
441450

442451
public void use() {

src/main/java/systems/kinau/fishingbot/bot/registry/Registries.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class Registries {
2020
public static EnchantmentRegistry ENCHANTMENT;
2121
public static DataComponentTypeRegistry DATA_COMPONENT_TYPE;
2222
public static ParticleTypeRegistry PARTICLE_TYPE;
23+
public static ConsumeEffectTypeRegistry CONSUME_EFFECT_TYPE;
2324

2425
public static final Set<Integer> BUNDLED_REGISTRY_IDS = new HashSet<>();
2526

@@ -42,12 +43,14 @@ public class Registries {
4243
BUNDLED_REGISTRY_IDS.add(ProtocolConstants.MC_1_20_3);
4344
BUNDLED_REGISTRY_IDS.add(ProtocolConstants.MC_1_20_5);
4445
BUNDLED_REGISTRY_IDS.add(ProtocolConstants.MC_1_21);
46+
BUNDLED_REGISTRY_IDS.add(ProtocolConstants.MC_1_21_2);
4547

4648
ITEM = new ItemRegistry();
4749
ENTITY_TYPE = new EntityTypeRegistry();
4850
ENCHANTMENT = new EnchantmentRegistry();
4951
DATA_COMPONENT_TYPE = new DataComponentTypeRegistry();
5052
PARTICLE_TYPE = new ParticleTypeRegistry();
53+
CONSUME_EFFECT_TYPE = new ConsumeEffectTypeRegistry();
5154
}
5255

5356
public static Registries get() {
@@ -63,6 +66,7 @@ public static MetaRegistry<Integer, String> getByIdentifier(String identifier, i
6366
case "minecraft:enchantment": return ENCHANTMENT;
6467
case "minecraft:data_component_type": return DATA_COMPONENT_TYPE;
6568
case "minecraft:particle_type": return PARTICLE_TYPE;
69+
case "minecraft:consume_effect_type": return CONSUME_EFFECT_TYPE;
6670
}
6771
return null;
6872
}
@@ -106,6 +110,7 @@ private String getRegistriesFileName(int protocolId) {
106110
case ProtocolConstants.MC_1_20_3: return "mc_data/1_20_3/registries.json";
107111
case ProtocolConstants.MC_1_20_5: return "mc_data/1_20_5/registries.json";
108112
case ProtocolConstants.MC_1_21: return "mc_data/1_21/registries.json";
113+
case ProtocolConstants.MC_1_21_2: return "mc_data/1_21_2/registries.json";
109114
default: return null;
110115
}
111116
}

src/main/java/systems/kinau/fishingbot/bot/registry/Registry.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.common.collect.BiMap;
44
import com.google.common.collect.HashBiMap;
5+
import systems.kinau.fishingbot.FishingBot;
56

67
import java.util.*;
78
import java.util.function.BiConsumer;
@@ -43,7 +44,10 @@ public boolean containsValue(V value) {
4344
}
4445

4546
public K findKey(V value) {
46-
return registry.inverse().get(value);
47+
K key = registry.inverse().get(value);
48+
if (key == null)
49+
FishingBot.getLog().severe("Could not find key for value: " + value);
50+
return key;
4751
}
4852

4953
public void merge(Registry<Integer, String> other) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package systems.kinau.fishingbot.bot.registry.registries;
2+
3+
import systems.kinau.fishingbot.bot.registry.MetaRegistry;
4+
import systems.kinau.fishingbot.bot.registry.RegistryLoader;
5+
6+
import java.util.Optional;
7+
8+
public class ConsumeEffectTypeRegistry extends MetaRegistry<Integer, String> {
9+
10+
public ConsumeEffectTypeRegistry() {
11+
load(RegistryLoader.simple("minecraft:consume_effect_type"));
12+
}
13+
14+
public int getConsumeEffectTypeId(String consumeEffectTypeName, int protocol) {
15+
return Optional.ofNullable(findKey(consumeEffectTypeName, protocol)).orElse(0);
16+
}
17+
18+
public String getConsumeEffectTypeName(int consumeEffectTypeId, int protocol) {
19+
return getElement(consumeEffectTypeId, protocol);
20+
}
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package systems.kinau.fishingbot.event.play;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
import systems.kinau.fishingbot.event.Event;
6+
7+
@Getter
8+
@AllArgsConstructor
9+
public class ChunkBatchFinishedEvent extends Event {
10+
private final int chunkCount;
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package systems.kinau.fishingbot.event.play;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
import systems.kinau.fishingbot.event.Event;
6+
7+
@Getter
8+
@AllArgsConstructor
9+
public class LookChangeEvent extends Event {
10+
private float yaw;
11+
private float pitch;
12+
}

0 commit comments

Comments
 (0)