Display DataExchange Dialog
This commit is contained in:
parent
7bfe0b01cd
commit
70cfdf0dd8
6 changed files with 46 additions and 1 deletions
|
@ -8,6 +8,7 @@ import ru.bclib.api.TagAPI;
|
|||
import ru.bclib.api.WorldDataAPI;
|
||||
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
||||
import ru.bclib.api.dataexchange.handler.HelloClient;
|
||||
import ru.bclib.api.dataexchange.handler.HelloServer;
|
||||
import ru.bclib.config.Configs;
|
||||
import ru.bclib.recipes.CraftingRecipes;
|
||||
import ru.bclib.registry.BaseBlockEntities;
|
||||
|
@ -30,6 +31,7 @@ public class BCLib implements ModInitializer {
|
|||
Configs.save();
|
||||
|
||||
DataExchangeAPI.registerDescriptor(HelloClient.DESCRIPTOR);
|
||||
DataExchangeAPI.registerDescriptor(HelloServer.DESCRIPTOR);
|
||||
}
|
||||
|
||||
public static boolean isDevEnvironment() {
|
||||
|
|
|
@ -91,7 +91,6 @@ public class HelloClient extends DataHandler {
|
|||
|
||||
@Environment(EnvType.CLIENT)
|
||||
protected void showBCLibError(Minecraft client){
|
||||
client.pauseGame(false);
|
||||
BCLib.LOGGER.error("BCLib differs on client and server.");
|
||||
client.setScreen(new WarnBCLibVersionMismatch((download) -> {
|
||||
Minecraft.getInstance().setScreen((Screen)null);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package ru.bclib.mixin.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
import net.minecraft.network.protocol.game.ClientboundLoginPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
||||
|
||||
@Mixin(ClientboundLoginPacket.class)
|
||||
public abstract class ClientboundLoginPacketMixin {
|
||||
@Inject(method = "handle", cancellable = true, at=@At("HEAD"))
|
||||
public void bclib_handle(ClientGamePacketListener clientGamePacketListener, CallbackInfo ci){
|
||||
//cLevel.setBCLibDidSendHello();
|
||||
// DataExchangeAPI.sendOnEnter();
|
||||
// ci.cancel();
|
||||
}
|
||||
}
|
18
src/main/java/ru/bclib/mixin/client/GameMixin.java
Normal file
18
src/main/java/ru/bclib/mixin/client/GameMixin.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package ru.bclib.mixin.client;
|
||||
|
||||
import net.minecraft.client.Game;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
||||
import ru.bclib.api.dataexchange.handler.HelloServer;
|
||||
|
||||
@Mixin(Game.class)
|
||||
public class GameMixin {
|
||||
|
||||
@Inject(method="onStartGameSession", at=@At("TAIL"))
|
||||
public void bcliv_onStart(CallbackInfo ci){
|
||||
DataExchangeAPI.send(new HelloServer());
|
||||
}
|
||||
}
|
|
@ -3,7 +3,9 @@ package ru.bclib.mixin.client;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.main.GameConfig;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess.RegistryHolder;
|
||||
import net.minecraft.world.level.LevelSettings;
|
||||
|
@ -16,6 +18,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
||||
import ru.bclib.api.datafixer.DataFixerAPI;
|
||||
import ru.bclib.interfaces.CustomColorProvider;
|
||||
|
||||
|
@ -51,6 +54,8 @@ public abstract class MinecraftMixin {
|
|||
if (levelID.startsWith(BCLIB_RECURSION)) {
|
||||
levelID = levelID.substring(BCLIB_RECURSION.length());
|
||||
recursiveCall = true;
|
||||
} else {
|
||||
DataExchangeAPI.prepareServerside();
|
||||
}
|
||||
|
||||
final String recursiveLevelID = BCLIB_RECURSION + levelID;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"client": [
|
||||
"EnchantingTableBlockMixin",
|
||||
"BackgroundRendererMixin",
|
||||
"GameMixin",
|
||||
"TextureAtlasMixin",
|
||||
"ModelBakeryMixin",
|
||||
"MinecraftMixin"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue