Commit dca01b0
committed
BREAKING CHANGE: Port AutoOffhand to Minecraft 1.18.2
This commit ports the AutoOffhand mod from Minecraft 1.16.5 to 1.18.2, adapting to significant changes in the Forge API and Minecraft mappings. Not all changes may be listed here.
**Key Changes:**
**1. API Updates & Package/Class Renames:**
* Updated numerous imports to reflect package changes in Forge and Minecraft (e.g., `net.minecraft.world.entity`, `net.minecraft.network.chat`, `com.mojang.blaze3d.platform`).
* Renamed core classes:
* `PlayerEntity` -> `Player`
* `ServerPlayerEntity` -> `ServerPlayer`
* `ProjectileEntity` -> `Projectile`
* `TridentEntity` -> `ThrownTrident`
* `CompoundNBT` -> `CompoundTag`
* `KeyBinding` -> `KeyMapping`
* `ITextComponent` -> `Component`
* `TranslationTextComponent` -> `TranslatableComponent`
* `PlayerInventory` -> `Inventory`
* `NetworkManager` -> `Connection`
* Updated method calls for renamed/refactored vanilla classes (e.g., `player.getLevel().isClientSide()`, `player.getInventory()`, `entity.isRemoved()`, `entity.discard()`).
* Registry names are now primarily accessed via `ForgeRegistries` (e.g., `ForgeRegistries.ITEMS.getKey(item)`, `ForgeRegistries.ENTITIES.getKey(entityType)`).
**2. Event System Changes:**
* **Capability Registration:** Moved from `FMLCommonSetupEvent` using `CapabilityManager` to the dedicated `RegisterCapabilitiesEvent` on the MOD event bus.
* **Command Registration:** Moved from `FMLServerStartingEvent` (Forge bus) to the dedicated `RegisterCommandsEvent` (Forge bus).
* **Setup Events:** Utilized `event.enqueueWork()` more consistently in `FMLCommonSetupEvent` and `FMLClientSetupEvent` for thread-safe operations like network registration and screen registration.
**3. Capability Handling:**
* Capability interface (`IPlayerConfig`) and provider (`PlayerConfigProvider`) remain structurally similar.
* Registration logic updated as described above.
* Event handlers (`onAttachCapabilitiesPlayer`, `onPlayerClone`, `onPlayerLoggedIn`, `onPlayerChangedDimension`) updated to use new class names (`Player`, `ServerPlayer`).
**4. Networking:**
* Network packet classes (`SyncConfigPacket`, `RequestConfigPacket`, etc.) remain largely the same.
* `NetworkHandler` registration moved to `commonSetup`'s `enqueueWork`.
* Checking if a client has the mod installed during login (`onPlayerLoggedIn`) now uses the `Connection` object instead of `NetworkManager`.
**5. Client-Side Changes:**
* **Container/Menu:**
* Registered `ConfigItemListContainer` using a `DeferredRegister<MenuType<?>>` in `ClientSetup`.
* Screen factory registered using `MenuScreens.register` within `clientSetup`'s `enqueueWork`.
* **Keybinding:**
* Uses `KeyMapping` and `InputConstants` instead of `KeyBinding` and `InputMappings`. Registration is often handled automatically for static final fields.
* **GUI:** Updated `ConfigItemListScreen` to use `Component` and `Inventory`.
**6. Item/Entity Handling:**
* **Pickup Logic (`onPlayerPickupItem`):** Updated to use `InteractionHand`, `player.getLevel().isClientSide()`, `entity.discard()`, `entity.isRemoved()`. Item registry name logging adapted.
* **Config Check (`shouldMoveToOffhand`):** Updated to use `Player` and `ForgeRegistries.ITEMS.getKey()`. Item comparison logic (`ConfigItemUtils.stacksMatchIgnoreDamageAndCount`) remains, assuming internal compatibility or necessary updates within that utility class.
* **Projectile Return (`onProjectileReturn`, `checkAndMoveSpecificInventoryItem`):**
* Updated entity types (`ThrownTrident`, `Projectile`).
* Uses `CompoundTag` for NBT handling.
* Uses `ForgeRegistries.ENTITIES.getKey()` for entity type comparison.
* Uses `TickTask` instead of `TickDelayedTask` for scheduling the inventory check.
* Uses `ItemStack.isSameItemSameTags()` for more precise item comparison when moving returned items.
* Updated inventory access (`player.getInventory()`).
**7. Configuration:**
* `ModConfig` loading remains registered in the main mod class constructor.
* `ConfigItemUtils` parsing logic is assumed to be compatible, interacting with updated APIs where necessary (e.g., registry names).1 parent c89dd30 commit dca01b0
23 files changed
Lines changed: 547 additions & 642 deletions
File tree
- src/main
- java/com/thunderscore/autooffhand
- capability
- command
- config
- gui
- inventory
- network
- resources/META-INF
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
Lines changed: 33 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | 3 | | |
7 | | - | |
8 | | - | |
9 | 4 | | |
10 | 5 | | |
11 | | - | |
12 | 6 | | |
13 | | - | |
14 | 7 | | |
15 | 8 | | |
16 | | - | |
| 9 | + | |
| 10 | + | |
17 | 11 | | |
18 | 12 | | |
19 | 13 | | |
20 | 14 | | |
21 | 15 | | |
22 | 16 | | |
23 | 17 | | |
24 | | - | |
25 | 18 | | |
26 | 19 | | |
| 20 | + | |
| 21 | + | |
27 | 22 | | |
28 | 23 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 24 | + | |
| 25 | + | |
32 | 26 | | |
33 | 27 | | |
34 | | - | |
| 28 | + | |
35 | 29 | | |
36 | 30 | | |
37 | 31 | | |
38 | 32 | | |
39 | | - | |
40 | 33 | | |
41 | 34 | | |
42 | | - | |
43 | 35 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 36 | + | |
| 37 | + | |
48 | 38 | | |
49 | 39 | | |
| 40 | + | |
50 | 41 | | |
51 | 42 | | |
| 43 | + | |
| 44 | + | |
52 | 45 | | |
53 | 46 | | |
54 | 47 | | |
55 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
56 | 51 | | |
57 | 52 | | |
58 | 53 | | |
59 | 54 | | |
60 | | - | |
| 55 | + | |
61 | 56 | | |
62 | 57 | | |
63 | 58 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 59 | + | |
78 | 60 | | |
79 | 61 | | |
80 | | - | |
81 | | - | |
| 62 | + | |
| 63 | + | |
82 | 64 | | |
83 | 65 | | |
84 | | - | |
| 66 | + | |
85 | 67 | | |
86 | 68 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
90 | 72 | | |
91 | 73 | | |
92 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
93 | 81 | | |
94 | | - | |
95 | | - | |
96 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
97 | 85 | | |
98 | 86 | | |
99 | | - | |
100 | | - | |
101 | 87 | | |
Lines changed: 42 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
15 | 22 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
26 | | - | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
32 | | - | |
33 | 36 | | |
34 | 37 | | |
35 | | - | |
36 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
37 | 46 | | |
38 | | - | |
39 | | - | |
| 47 | + | |
| 48 | + | |
40 | 49 | | |
41 | 50 | | |
42 | 51 | | |
43 | | - | |
44 | 52 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 53 | + | |
59 | 54 | | |
60 | 55 | | |
61 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| |||
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
71 | | - | |
| 77 | + | |
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
| |||
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
87 | 93 | | |
88 | 94 | | |
89 | 95 | | |
| |||
0 commit comments