-
-
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.
- Loading branch information
Showing
10 changed files
with
91 additions
and
62 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
20 changes: 12 additions & 8 deletions
20
platform/forge/src/main/java/lol/bai/badpackets/impl/forge/ForgeProxy.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 |
---|---|---|
@@ -1,33 +1,37 @@ | ||
package lol.bai.badpackets.impl.forge; | ||
|
||
import java.util.Set; | ||
import java.util.function.Supplier; | ||
|
||
import lol.bai.badpackets.impl.Constants; | ||
import lol.bai.badpackets.impl.platform.PlatformProxy; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; | ||
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket; | ||
import net.minecraft.network.protocol.common.custom.DiscardedPayload; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public class ForgeProxy extends PlatformProxy { | ||
|
||
@Override | ||
public Packet<?> createVanillaRegisterConfigS2CPacket(FriendlyByteBuf buf) { | ||
return new ClientboundCustomPayloadPacket(new DiscardedPayload(Constants.MC_REGISTER_CHANNEL, buf)); | ||
public Packet<?> createVanillaRegisterConfigS2CPacket(Set<ResourceLocation> channels, Supplier<FriendlyByteBuf> buf) { | ||
return new ClientboundCustomPayloadPacket(new DiscardedPayload(Constants.MC_REGISTER_CHANNEL, buf.get())); | ||
} | ||
|
||
@Override | ||
public Packet<?> createVanillaRegisterConfigC2SPacket(FriendlyByteBuf buf) { | ||
return new ServerboundCustomPayloadPacket(new DiscardedPayload(Constants.MC_REGISTER_CHANNEL, buf)); | ||
public Packet<?> createVanillaRegisterConfigC2SPacket(Set<ResourceLocation> channels, Supplier<FriendlyByteBuf> buf) { | ||
return new ServerboundCustomPayloadPacket(new DiscardedPayload(Constants.MC_REGISTER_CHANNEL, buf.get())); | ||
} | ||
|
||
@Override | ||
public Packet<?> createVanillaRegisterPlayS2CPacket(FriendlyByteBuf buf) { | ||
return new ClientboundCustomPayloadPacket(new DiscardedPayload(Constants.MC_REGISTER_CHANNEL, buf)); | ||
public Packet<?> createVanillaRegisterPlayS2CPacket(Set<ResourceLocation> channels, Supplier<FriendlyByteBuf> buf) { | ||
return new ClientboundCustomPayloadPacket(new DiscardedPayload(Constants.MC_REGISTER_CHANNEL, buf.get())); | ||
} | ||
|
||
@Override | ||
public Packet<?> createVanillaRegisterPlayC2SPacket(FriendlyByteBuf buf) { | ||
return new ServerboundCustomPayloadPacket(new DiscardedPayload(Constants.MC_REGISTER_CHANNEL, buf)); | ||
public Packet<?> createVanillaRegisterPlayC2SPacket(Set<ResourceLocation> channels, Supplier<FriendlyByteBuf> buf) { | ||
return new ServerboundCustomPayloadPacket(new DiscardedPayload(Constants.MC_REGISTER_CHANNEL, buf.get())); | ||
} | ||
|
||
} |
29 changes: 15 additions & 14 deletions
29
platform/neo/src/main/java/lol/bai/badpackets/impl/neo/NeoProxy.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 |
---|---|---|
@@ -1,35 +1,36 @@ | ||
package lol.bai.badpackets.impl.neo; | ||
|
||
import java.util.Set; | ||
import java.util.function.Supplier; | ||
|
||
import lol.bai.badpackets.impl.platform.PlatformProxy; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; | ||
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.neoforged.neoforge.network.payload.MinecraftRegisterPayload; | ||
|
||
// TODO: NeoForge has different format for minecraft:register. Support it again when it reuse the old format. | ||
public class NeoProxy extends PlatformProxy { | ||
|
||
@Override | ||
public boolean canSendVanillaRegisterPackets() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Packet<?> createVanillaRegisterConfigS2CPacket(FriendlyByteBuf buf) { | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
public Packet<?> createVanillaRegisterConfigS2CPacket(Set<ResourceLocation> channels, Supplier<FriendlyByteBuf> buf) { | ||
return new ClientboundCustomPayloadPacket(new MinecraftRegisterPayload(channels)); | ||
} | ||
|
||
@Override | ||
public Packet<?> createVanillaRegisterConfigC2SPacket(FriendlyByteBuf buf) { | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
public Packet<?> createVanillaRegisterConfigC2SPacket(Set<ResourceLocation> channels, Supplier<FriendlyByteBuf> buf) { | ||
return new ServerboundCustomPayloadPacket(new MinecraftRegisterPayload(channels)); | ||
} | ||
|
||
@Override | ||
public Packet<?> createVanillaRegisterPlayS2CPacket(FriendlyByteBuf buf) { | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
public Packet<?> createVanillaRegisterPlayS2CPacket(Set<ResourceLocation> channels, Supplier<FriendlyByteBuf> buf) { | ||
return new ClientboundCustomPayloadPacket(new MinecraftRegisterPayload(channels)); | ||
} | ||
|
||
@Override | ||
public Packet<?> createVanillaRegisterPlayC2SPacket(FriendlyByteBuf buf) { | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
public Packet<?> createVanillaRegisterPlayC2SPacket(Set<ResourceLocation> channels, Supplier<FriendlyByteBuf> buf) { | ||
return new ServerboundCustomPayloadPacket(new MinecraftRegisterPayload(channels)); | ||
} | ||
|
||
} |
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