-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated internals to Java Edition 1.20.2
- Loading branch information
Showing
47 changed files
with
1,153 additions
and
675 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,14 @@ | ||
# ViaBedrock Update Process | ||
|
||
This file lists the steps necessary to update ViaBedrock. | ||
|
||
1. Update data assets (See `Data Asset Sources.md`) and BedrockMappingData | ||
2. Update ProtocolConstants class | ||
3. Update hardcoded blockstates: Search all files for `new BlockState("` | ||
4. Replace `Types1_20_2` with the new type | ||
5. Replace `EntityTypes1_19_4` and `Protocol1_19_4To1_19_3.class` with the new type | ||
6. Replace `ClientboundPackets1_20_2` and `ServerboundPackets1_20_2` with the new packet enum | ||
7. Replace `ClientboundConfigurationPackets1_20_2` and `ServerboundConfigurationPackets1_20_2` with the new packet enum | ||
8. Update changed packet contents | ||
9. Update rewriters | ||
10. Done! |
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
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
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
39 changes: 39 additions & 0 deletions
39
src/main/java/net/raphimc/viabedrock/api/protocol/StatelessProtocol.java
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,39 @@ | ||
/* | ||
* This file is part of ViaBedrock - https://github.com/RaphiMC/ViaBedrock | ||
* Copyright (C) 2023 RK_01/RaphiMC and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.raphimc.viabedrock.api.protocol; | ||
|
||
import com.viaversion.viaversion.api.protocol.AbstractProtocol; | ||
import com.viaversion.viaversion.api.protocol.packet.*; | ||
|
||
public abstract class StatelessProtocol<CU extends ClientboundPacketType, CM extends ClientboundPacketType, SM extends ServerboundPacketType, SU extends ServerboundPacketType> extends AbstractProtocol<CU, CM, SM, SU> { | ||
|
||
public StatelessProtocol(final Class<CU> unmappedClientboundPacketType, final Class<CM> mappedClientboundPacketType, final Class<SM> mappedServerboundPacketType, final Class<SU> unmappedServerboundPacketType) { | ||
super(unmappedClientboundPacketType, mappedClientboundPacketType, mappedServerboundPacketType, unmappedServerboundPacketType); | ||
} | ||
|
||
@Override | ||
public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception { | ||
if (state == State.STATUS) { // Needed for RakNet ping workaround | ||
super.transform(direction, state, packetWrapper); | ||
return; | ||
} | ||
|
||
super.transform(direction, direction == Direction.SERVERBOUND ? state : State.PLAY, packetWrapper); | ||
} | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/net/raphimc/viabedrock/api/protocol/StatelessTransitionProtocol.java
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,67 @@ | ||
/* | ||
* This file is part of ViaBedrock - https://github.com/RaphiMC/ViaBedrock | ||
* Copyright (C) 2023 RK_01/RaphiMC and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.raphimc.viabedrock.api.protocol; | ||
|
||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; | ||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; | ||
import com.viaversion.viaversion.api.protocol.packet.State; | ||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; | ||
|
||
public abstract class StatelessTransitionProtocol<CU extends ClientboundPacketType, CM extends ClientboundPacketType, SM extends ServerboundPacketType, SU extends ServerboundPacketType> extends StatelessProtocol<CU, CM, SM, SU> { | ||
|
||
public StatelessTransitionProtocol(final Class<CU> unmappedClientboundPacketType, final Class<CM> mappedClientboundPacketType, final Class<SM> mappedServerboundPacketType, final Class<SU> unmappedServerboundPacketType) { | ||
super(unmappedClientboundPacketType, mappedClientboundPacketType, mappedServerboundPacketType, unmappedServerboundPacketType); | ||
} | ||
|
||
public void registerServerboundTransition(final ServerboundPacketType unmappedPacketType, final SM mappedPacketType, final PacketHandler handler) { | ||
this.registerServerbound(unmappedPacketType.state(), unmappedPacketType.getId(), mappedPacketType != null ? mappedPacketType.getId() : -1, wrapper -> { | ||
wrapper.setPacketType(mappedPacketType); | ||
if (handler != null) { | ||
handler.handle(wrapper); | ||
} | ||
}); | ||
} | ||
|
||
public void registerClientboundTransition(final CU unmappedPacketType, final Object... handlers) { | ||
if (handlers.length % 2 != 0) throw new IllegalArgumentException("handlers.length % 2 != 0"); | ||
|
||
this.registerClientbound(unmappedPacketType.state(), unmappedPacketType.getId(), -1, wrapper -> { | ||
final State currentState = wrapper.user().getProtocolInfo().getServerState(); | ||
|
||
for (int i = 0; i < handlers.length; i += 2) { | ||
if (handlers[i] instanceof State) { | ||
final State state = (State) handlers[i]; | ||
if (state != currentState) continue; | ||
} else { | ||
final ClientboundPacketType mappedPacketType = (ClientboundPacketType) handlers[i]; | ||
if (mappedPacketType.state() != currentState) continue; | ||
wrapper.setPacketType(mappedPacketType); | ||
} | ||
|
||
final PacketHandler handler = (PacketHandler) handlers[i + 1]; | ||
if (handler != null) { | ||
handler.handle(wrapper); | ||
} | ||
return; | ||
} | ||
|
||
throw new IllegalStateException("No handler found for packet " + unmappedPacketType + " in state " + currentState); | ||
}); | ||
} | ||
|
||
} |
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
Oops, something went wrong.