-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
to fix a mixin issue and a no such method error
- Loading branch information
1 parent
5de9a5a
commit 20bbe37
Showing
61 changed files
with
1,782 additions
and
6 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
libraries/networking/networking-client-mcb1.0-mcb1.4_01/build.gradle
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,4 @@ | ||
setUpModule(project, | ||
'entrypoints-client-mca1.0.6-mc12w30e', | ||
'lifecycle-events-client-mcb1.3-1750-mcb1.7.3' | ||
) |
7 changes: 7 additions & 0 deletions
7
libraries/networking/networking-client-mcb1.0-mcb1.4_01/gradle.properties
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,7 @@ | ||
environment = client | ||
min_mc_version = b1.0 | ||
max_mc_version = b1.4_01 | ||
mc_version_range = >=1.0.0-beta.0 <=1.0.0-beta.4.1 | ||
|
||
feather_build = 12 | ||
nests_build = 1 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
73 changes: 73 additions & 0 deletions
73
...mcb1.0-mcb1.4_01/src/main/java/net/ornithemc/osl/networking/impl/CustomPayloadPacket.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,73 @@ | ||
package net.ornithemc.osl.networking.impl; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
|
||
import net.minecraft.client.network.handler.ClientNetworkHandler; | ||
import net.minecraft.network.PacketHandler; | ||
import net.minecraft.network.packet.Packet; | ||
|
||
import net.ornithemc.osl.networking.impl.client.ClientPlayNetworkingImpl; | ||
|
||
public class CustomPayloadPacket extends Packet { | ||
|
||
public String channel; | ||
public int size; | ||
public byte[] data; | ||
|
||
public CustomPayloadPacket() { | ||
} | ||
|
||
public CustomPayloadPacket(String channel, byte[] data) { | ||
this.channel = channel; | ||
this.data = data; | ||
if (data != null) { | ||
this.size = data.length; | ||
if (this.size > Short.MAX_VALUE) { | ||
throw new IllegalArgumentException("Payload may not be larger than 32k"); | ||
} | ||
} | ||
} | ||
|
||
// the IOException has been stripped from the read/write methods | ||
// by the obfuscator, thus we catch it and re-throw it as a | ||
// runtime exception - it will be caught in Connection#read anyhow | ||
|
||
@Override | ||
public void read(DataInputStream input) { | ||
try { | ||
this.channel = input.readUTF(); | ||
this.size = input.readShort(); | ||
if (this.size > 0 && this.size < Short.MAX_VALUE) { | ||
this.data = new byte[this.size]; | ||
input.readFully(this.data); | ||
} | ||
} catch (IOException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void write(DataOutputStream output) { | ||
try { | ||
output.writeUTF(this.channel); | ||
output.writeShort(this.size); | ||
if (this.data != null) { | ||
output.write(this.data); | ||
} | ||
} catch (IOException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void handle(PacketHandler handler) { | ||
ClientPlayNetworkingImpl.handle((ClientNetworkHandler)handler, this); | ||
} | ||
|
||
@Override | ||
public int getSize() { | ||
return 2 + this.channel.length() * 2 + 2 + this.size; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...nt-mcb1.0-mcb1.4_01/src/main/java/net/ornithemc/osl/networking/impl/HandshakePayload.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,53 @@ | ||
package net.ornithemc.osl.networking.impl; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
import net.ornithemc.osl.networking.api.CustomPayload; | ||
import net.ornithemc.osl.networking.impl.client.ClientPlayNetworkingImpl; | ||
|
||
public class HandshakePayload implements CustomPayload { | ||
|
||
public static final String CHANNEL = "OSL|Handshake"; | ||
|
||
public Set<String> channels; | ||
|
||
public HandshakePayload() { | ||
} | ||
|
||
public HandshakePayload(Set<String> channels) { | ||
this.channels = channels; | ||
} | ||
|
||
public static HandshakePayload client() { | ||
return new HandshakePayload(ClientPlayNetworkingImpl.LISTENERS.keySet()); | ||
} | ||
|
||
public static HandshakePayload server() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void read(DataInputStream input) throws IOException { | ||
channels = new LinkedHashSet<>(); | ||
int channelCount = input.readInt(); | ||
|
||
if (channelCount > 0) { | ||
for (int i = 0; i < channelCount; i++) { | ||
channels.add(input.readUTF()); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void write(DataOutputStream output) throws IOException { | ||
output.writeInt(channels.size()); | ||
|
||
for (String channel : channels) { | ||
output.writeUTF(channel); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...g-client-mcb1.0-mcb1.4_01/src/main/java/net/ornithemc/osl/networking/impl/Networking.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,37 @@ | ||
package net.ornithemc.osl.networking.impl; | ||
|
||
import net.ornithemc.osl.entrypoints.api.ModInitializer; | ||
import net.ornithemc.osl.entrypoints.api.client.ClientModInitializer; | ||
import net.ornithemc.osl.lifecycle.api.MinecraftEvents; | ||
import net.ornithemc.osl.networking.api.client.ClientConnectionEvents; | ||
import net.ornithemc.osl.networking.api.client.ClientPlayNetworking; | ||
import net.ornithemc.osl.networking.impl.client.ClientPlayNetworkingImpl; | ||
import net.ornithemc.osl.networking.impl.interfaces.mixin.IClientNetworkHandler; | ||
import net.ornithemc.osl.networking.impl.mixin.common.PacketAccessor; | ||
|
||
public class Networking implements ModInitializer, ClientModInitializer { | ||
|
||
@Override | ||
public void init() { | ||
PacketAccessor.register(Constants.CUSTOM_PAYLOAD_PACKET_ID, CustomPayloadPacket.class); | ||
} | ||
|
||
@Override | ||
public void initClient() { | ||
MinecraftEvents.START.register(minecraft -> { | ||
ClientPlayNetworkingImpl.setUp(minecraft); | ||
}); | ||
MinecraftEvents.STOP.register(minecraft -> { | ||
ClientPlayNetworkingImpl.destroy(minecraft); | ||
}); | ||
ClientPlayNetworking.registerListener(HandshakePayload.CHANNEL, HandshakePayload::new, (minecraft, handler, payload) -> { | ||
// send channel registration data as a response to receiving server channel registration data | ||
ClientPlayNetworking.doSend(HandshakePayload.CHANNEL, HandshakePayload.client()); | ||
|
||
((IClientNetworkHandler)handler).osl$networking$registerServerChannels(payload.channels); | ||
ClientConnectionEvents.PLAY_READY.invoker().accept(minecraft); | ||
|
||
return true; | ||
}); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
...cb1.4_01/src/main/java/net/ornithemc/osl/networking/impl/mixin/common/PacketAccessor.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,15 @@ | ||
package net.ornithemc.osl.networking.impl.mixin.common; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
|
||
import net.minecraft.network.packet.Packet; | ||
|
||
@Mixin(Packet.class) | ||
public interface PacketAccessor { | ||
|
||
@Invoker("register") | ||
public static void register(int id, Class<? extends Packet> type) { | ||
throw new AssertionError(); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...-client-mcb1.0-mc11w48a/gradle.properties → ...-client-mcb1.5-mc11w48a/gradle.properties
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
environment = client | ||
min_mc_version = b1.0 | ||
min_mc_version = b1.5 | ||
max_mc_version = 11w48a | ||
mc_version_range = >=1.0.0-beta.0 <=1.1-alpha.11.48.a | ||
mc_version_range = >=1.0.0-beta.5 <=1.1-alpha.11.48.a | ||
|
||
feather_build = 12 | ||
nests_build = 1 |
File renamed without changes.
File renamed without changes.
70 changes: 70 additions & 0 deletions
70
...c11w48a/src/main/java/net/ornithemc/osl/networking/api/client/ClientConnectionEvents.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,70 @@ | ||
package net.ornithemc.osl.networking.api.client; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import net.minecraft.client.Minecraft; | ||
|
||
import net.ornithemc.osl.core.api.events.Event; | ||
|
||
/** | ||
* Events related to the client side of a client-server connection. | ||
*/ | ||
public class ClientConnectionEvents { | ||
|
||
/** | ||
* This event is fired after a successful login occurs. | ||
* | ||
* <p> | ||
* Note that channel registration happens after login, | ||
* and until then data cannot safely be sent to the server. | ||
* | ||
* <p> | ||
* Callbacks to this event should be registered in your mod's entrypoint, | ||
* and can be done as follows: | ||
* | ||
* <pre> | ||
* {@code | ||
* ClientConnectionEvents.LOGIN.register(minecraft -> { | ||
* ... | ||
* }); | ||
* } | ||
* </pre> | ||
*/ | ||
public static final Event<Consumer<Minecraft>> LOGIN = Event.consumer(); | ||
/** | ||
* This event is fired after login, once channel registration is complete. | ||
* | ||
* <p> | ||
* This marks the moment data can safely be sent to the server. | ||
* | ||
* <p> | ||
* Callbacks to this event should be registered in your mod's entrypoint, | ||
* and can be done as follows: | ||
* | ||
* <pre> | ||
* {@code | ||
* ClientConnectionEvents.PLAY_READY.register(minecraft -> { | ||
* ... | ||
* }); | ||
* } | ||
* </pre> | ||
*/ | ||
public static final Event<Consumer<Minecraft>> PLAY_READY = Event.consumer(); | ||
/** | ||
* This event is fired when the client disconnects from the server. | ||
* | ||
* <p> | ||
* Callbacks to this event should be registered in your mod's entrypoint, | ||
* and can be done as follows: | ||
* | ||
* <pre> | ||
* {@code | ||
* ClientConnectionEvents.DISCONNECT.register(minecraft -> { | ||
* ... | ||
* }); | ||
* } | ||
* </pre> | ||
*/ | ||
public static final Event<Consumer<Minecraft>> DISCONNECT = Event.consumer(); | ||
|
||
} |
Oops, something went wrong.