-
Notifications
You must be signed in to change notification settings - Fork 316
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
29 changed files
with
175 additions
and
256 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
23 changes: 0 additions & 23 deletions
23
Common/src/main/java/mezz/jei/common/platform/IPlatformRegistry.java
This file was deleted.
Oops, something went wrong.
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
8 changes: 2 additions & 6 deletions
8
Forge/src/main/java/mezz/jei/forge/JustEnoughItemsClientSafeRunner.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,26 +1,22 @@ | ||
package mezz.jei.forge; | ||
|
||
import mezz.jei.common.config.IServerConfig; | ||
import mezz.jei.forge.events.PermanentEventSubscriptions; | ||
import mezz.jei.forge.network.NetworkHandler; | ||
|
||
public class JustEnoughItemsClientSafeRunner { | ||
private final NetworkHandler networkHandler; | ||
private final PermanentEventSubscriptions subscriptions; | ||
private final IServerConfig serverConfig; | ||
|
||
public JustEnoughItemsClientSafeRunner( | ||
NetworkHandler networkHandler, | ||
PermanentEventSubscriptions subscriptions, | ||
IServerConfig serverConfig | ||
PermanentEventSubscriptions subscriptions | ||
) { | ||
this.networkHandler = networkHandler; | ||
this.subscriptions = subscriptions; | ||
this.serverConfig = serverConfig; | ||
} | ||
|
||
public void registerClient() { | ||
JustEnoughItemsClient jeiClient = new JustEnoughItemsClient(networkHandler, subscriptions, serverConfig); | ||
JustEnoughItemsClient jeiClient = new JustEnoughItemsClient(networkHandler, subscriptions); | ||
jeiClient.register(); | ||
} | ||
} |
11 changes: 3 additions & 8 deletions
11
Forge/src/main/java/mezz/jei/forge/JustEnoughItemsCommon.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,29 +1,24 @@ | ||
package mezz.jei.forge; | ||
|
||
import mezz.jei.common.network.IConnectionToClient; | ||
import mezz.jei.common.network.ServerPacketRouter; | ||
import mezz.jei.common.config.IServerConfig; | ||
import mezz.jei.forge.events.PermanentEventSubscriptions; | ||
import mezz.jei.forge.network.ConnectionToClient; | ||
import mezz.jei.forge.network.NetworkHandler; | ||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | ||
|
||
public class JustEnoughItemsCommon { | ||
private final NetworkHandler networkHandler; | ||
private final IServerConfig serverConfig; | ||
|
||
public JustEnoughItemsCommon(NetworkHandler networkHandler, IServerConfig serverConfig) { | ||
public JustEnoughItemsCommon(NetworkHandler networkHandler) { | ||
this.networkHandler = networkHandler; | ||
this.serverConfig = serverConfig; | ||
} | ||
|
||
public void register(PermanentEventSubscriptions subscriptions) { | ||
subscriptions.register(FMLCommonSetupEvent.class, event -> this.commonSetup()); | ||
} | ||
|
||
private void commonSetup() { | ||
IConnectionToClient connection = new ConnectionToClient(this.networkHandler); | ||
ServerPacketRouter packetRouter = new ServerPacketRouter(connection, serverConfig); | ||
this.networkHandler.registerServerPacketHandler(packetRouter); | ||
IConnectionToClient connection = new ConnectionToClient(networkHandler); | ||
this.networkHandler.registerServerPacketHandler(connection); | ||
} | ||
} |
26 changes: 11 additions & 15 deletions
26
Forge/src/main/java/mezz/jei/forge/network/ConnectionToClient.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,28 +1,24 @@ | ||
package mezz.jei.forge.network; | ||
|
||
import io.netty.buffer.Unpooled; | ||
import mezz.jei.common.network.IConnectionToClient; | ||
import mezz.jei.common.network.packets.PlayToClientPacket; | ||
import net.minecraft.core.RegistryAccess; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.protocol.Packet; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraftforge.network.ICustomPacket; | ||
import net.minecraftforge.network.NetworkDirection; | ||
|
||
public class ConnectionToClient implements IConnectionToClient { | ||
private final NetworkHandler networkHandler; | ||
|
||
public ConnectionToClient(NetworkHandler networkHandler) { | ||
this.networkHandler = networkHandler; | ||
} | ||
|
||
@Override | ||
public <T extends PlayToClientPacket<T>> void sendPacketToClient(T packet, ServerPlayer player) { | ||
@SuppressWarnings("resource") Level level = player.level(); | ||
RegistryAccess registryAccess = level.registryAccess(); | ||
RegistryFriendlyByteBuf buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), registryAccess); | ||
try { | ||
packet.streamCodec().m_318638_(buf, packet); | ||
ICustomPacket<Packet<?>> payload = NetworkDirection.PLAY_TO_CLIENT.buildPacket(buf, packet.type().f_314054_()); | ||
player.connection.send(payload.getThis()); | ||
} finally { | ||
buf.release(); | ||
} | ||
networkHandler.getClientChannel() | ||
.ifPresent(clientChannel -> { | ||
Packet<?> payload = NetworkDirection.PLAY_TO_CLIENT.buildPacket(clientChannel, packet); | ||
player.connection.send(payload); | ||
}); | ||
} | ||
} |
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.