Almost everything fixed!
Viel ist jetzt repariert, es gibt nur noch einen bug im Networking, wenn man den Knop im Schlaf oder DeathScreen drückt
This commit is contained in:
parent
6b7188db8b
commit
594c6ce423
|
@ -1,31 +0,0 @@
|
|||
package modchest.networking;
|
||||
|
||||
import modchest.REServerMod;
|
||||
import modchest.networking.packet.respawnRequestS2CPacket;
|
||||
import modchest.networking.payload.requestRespawn;
|
||||
import modchest.networking.payload.startSleepingCallButtons;
|
||||
import modchest.networking.payload.deathMultiRespawnButtons;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class modNetworkingClient { //Identifier werden eingeführt
|
||||
//public static final Identifier request_respawn = Identifier.of(REServerMod.MOD_ID, "request_respawn"); //alle Identifier muessen leider IMMER auf Client und Server (doppelt) eingefuehrt werden
|
||||
public static final Identifier start_sleeping_call_buttons = Identifier.of(REServerMod.MOD_ID, "start_sleeping_call_buttons");
|
||||
public static final Identifier death_multi_respawn_buttons = Identifier.of(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
|
||||
public static void registerC2SPackets() { //Identifier fuer packets werden registriert (Identifier die der Server aufruft um beim CLient was auszufuehren)
|
||||
PayloadTypeRegistry.playC2S().register(startSleepingCallButtons.ID, startSleepingCallButtons.CODEC);
|
||||
PayloadTypeRegistry.playC2S().register(deathMultiRespawnButtons.ID, deathMultiRespawnButtons.CODEC);
|
||||
|
||||
|
||||
ClientPlayNetworking.registerGlobalReceiver(startSleepingCallButtons.ID, (payload, context) -> {
|
||||
context.client().execute(() -> {
|
||||
respawnRequestS2CPacket.receive(context.client(), payload);
|
||||
}
|
||||
);});
|
||||
|
||||
|
||||
//ClientPlayNetworking.registerGlobalReceiver(request_respawn, respawnRequestS2CPacket::receive); //was der Client dann machen soll steht in der receive Methode
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package modchest;
|
||||
package modchestClient;
|
||||
|
||||
import modchest.networking.modNetworkingClient;
|
||||
import modchestClient.networking.modNetworkingClient;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
|
@ -1,7 +1,7 @@
|
|||
package modchest.mixin.client;
|
||||
package modchestClient.mixin;
|
||||
|
||||
import modchest.REServerModClient;
|
||||
import modchest.networking.payload.startSleepingCallButtons;
|
||||
import modchestClient.REServerModClient;
|
||||
import modchestClient.networking.payload.startSleepingCallButtons;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
|
@ -61,7 +61,7 @@ public class DeathScreen extends Screen {
|
|||
try {
|
||||
ClientPlayNetworking.send(new startSleepingCallButtons(number));
|
||||
} catch (Exception e) {
|
||||
REServerModClient.LOGGER.info("Error when trying to network to server in DeathScreen class!");
|
||||
REServerModClient.LOGGER.info("Error when trying to network to server in DeathScreen class: " + e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package modchest.mixin.client;
|
||||
package modchestClient.mixin;
|
||||
|
||||
import modchest.REServerModClient;
|
||||
import modchestClient.REServerModClient;
|
||||
import modchestClient.networking.payload.deathMultiRespawnButtons;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
|
@ -10,7 +11,6 @@ import org.spongepowered.asm.mixin.Unique;
|
|||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import modchest.networking.payload.deathMultiRespawnButtons;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.SleepingChatScreen.class)
|
||||
public class SleepingChatScreen extends Screen { //Sehr identisch zu Death Screen, siehe dort fuer Kommentare!
|
||||
|
@ -62,7 +62,7 @@ public class SleepingChatScreen extends Screen { //Sehr identisch zu Deat
|
|||
try {
|
||||
ClientPlayNetworking.send(new deathMultiRespawnButtons(number));
|
||||
} catch (Exception e) {
|
||||
REServerModClient.LOGGER.info("Error when trying to network to server in sleepingChatScreen class!");
|
||||
REServerModClient.LOGGER.info("Error when trying to network to server in sleepingChatScreen class: " + e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package modchestClient.networking;
|
||||
|
||||
import modchest.REServerMod;
|
||||
import modchestClient.networking.packet.respawnRequestS2CPacket;
|
||||
import modchestClient.networking.payload.requestRespawn;
|
||||
import modchestClient.networking.payload.startSleepingCallButtons;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class modNetworkingClient { //Identifier werden eingeführt //alle Identifier muessen leider IMMER auf Client und Server (doppelt) eingefuehrt werden
|
||||
public static final Identifier request_respawn = Identifier.of(REServerMod.MOD_ID, "request_respawn");
|
||||
public static final Identifier start_sleeping_call_buttons = Identifier.of(REServerMod.MOD_ID, "start_sleeping_call_buttons");
|
||||
public static final Identifier death_call_respawn_buttons = Identifier.of(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
|
||||
public static void registerC2SPackets() { //Identifier fuer packets werden registriert (Identifier die der Server aufruft um beim CLient was auszufuehren)
|
||||
//PayloadTypeRegistry.playC2S().register(startSleepingCallButtons.ID, startSleepingCallButtons.CODEC);
|
||||
//PayloadTypeRegistry.playC2S().register(deathMultiRespawnButtons.ID, deathMultiRespawnButtons.CODEC);
|
||||
PayloadTypeRegistry.playS2C().register(requestRespawn.ID, requestRespawn.CODEC);
|
||||
|
||||
|
||||
ClientPlayNetworking.registerGlobalReceiver(requestRespawn.ID, (payload, context) -> {
|
||||
context.client().execute(() -> {
|
||||
respawnRequestS2CPacket.receive(context.client(), payload);
|
||||
}
|
||||
);});
|
||||
|
||||
|
||||
//ClientPlayNetworking.registerGlobalReceiver(request_respawn, respawnRequestS2CPacket::receive); //was der Client dann machen soll steht in der receive Methode
|
||||
}
|
||||
}
|
|
@ -1,10 +1,6 @@
|
|||
package modchest.networking.packet;
|
||||
package modchestClient.networking.packet;
|
||||
|
||||
import modchest.REServerModClient;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
|
||||
public class respawnRequestS2CPacket {
|
|
@ -1,4 +1,4 @@
|
|||
package modchest.networking.payload;
|
||||
package modchestClient.networking.payload;
|
||||
|
||||
import modchest.networking.modNetworkingServer;
|
||||
import net.minecraft.network.RegistryByteBuf;
|
||||
|
@ -7,7 +7,7 @@ import net.minecraft.network.codec.PacketCodecs;
|
|||
import net.minecraft.network.packet.CustomPayload;
|
||||
|
||||
public record deathMultiRespawnButtons(int number) implements CustomPayload {
|
||||
public static final Id<deathMultiRespawnButtons> ID = new Id<>(modNetworkingServer.request_respawn);
|
||||
public static final CustomPayload.Id<deathMultiRespawnButtons> ID = new CustomPayload.Id<>(modNetworkingServer.death_call_respawn_buttons);
|
||||
public static final PacketCodec<RegistryByteBuf, deathMultiRespawnButtons> CODEC = PacketCodec.tuple(PacketCodecs.INTEGER, deathMultiRespawnButtons::number, deathMultiRespawnButtons::new);
|
||||
//PacketCodec.tuple(PacketCodecs.INTEGER, requestRespawn::new);
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
package modchest.networking.payload;
|
||||
package modchestClient.networking.payload;
|
||||
|
||||
import modchest.networking.modNetworkingServer;
|
||||
import modchestClient.networking.modNetworkingClient;
|
||||
import net.minecraft.network.RegistryByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.codec.PacketCodecs;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
|
||||
public record requestRespawn(int number) implements CustomPayload {
|
||||
public static final Id<requestRespawn> ID = new Id<>(modNetworkingServer.request_respawn);
|
||||
public static final CustomPayload.Id<requestRespawn> ID = new CustomPayload.Id<>(modNetworkingClient.request_respawn);
|
||||
public static final PacketCodec<RegistryByteBuf, requestRespawn> CODEC = PacketCodec.tuple(PacketCodecs.INTEGER, requestRespawn::number, requestRespawn::new);
|
||||
//PacketCodec.tuple(PacketCodecs.INTEGER, requestRespawn::new);
|
||||
|
||||
@Override
|
||||
public Id<? extends CustomPayload> getId() {
|
|
@ -1,4 +1,4 @@
|
|||
package modchest.networking.payload;
|
||||
package modchestClient.networking.payload;
|
||||
|
||||
import modchest.networking.modNetworkingServer;
|
||||
import net.minecraft.network.RegistryByteBuf;
|
||||
|
@ -7,7 +7,7 @@ import net.minecraft.network.codec.PacketCodecs;
|
|||
import net.minecraft.network.packet.CustomPayload;
|
||||
|
||||
public record startSleepingCallButtons(int number) implements CustomPayload {
|
||||
public static final CustomPayload.Id<startSleepingCallButtons> ID = new CustomPayload.Id<>(modNetworkingServer.request_respawn);
|
||||
public static final CustomPayload.Id<startSleepingCallButtons> ID = new CustomPayload.Id<>(modNetworkingServer.start_sleeping_call_buttons);
|
||||
public static final PacketCodec<RegistryByteBuf, startSleepingCallButtons> CODEC = PacketCodec.tuple(PacketCodecs.INTEGER, startSleepingCallButtons::number, startSleepingCallButtons::new);
|
||||
|
||||
@Override
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "modchest.mixin.client",
|
||||
"package": "modchestClient.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"DeathScreen",
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.nbt.NbtCompound;
|
|||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -24,7 +25,7 @@ public class playerAfterRespawnEvent implements ServerPlayerEvents.AfterRespawn
|
|||
|
||||
String[] parts = nbt.getString("dimension").split(":"); //holt sich die gespeicherte Dimension; trennt den String entspreichend; damit sollte es auch funktionieren, sollte eine Mod weitere Dimensionen hinzufuegen
|
||||
parts = parts[2].split("]");
|
||||
RegistryKey<World> dim = RegistryKey.of(Registry<World>, Identifier.of(parts[0]));
|
||||
RegistryKey<World> dim = RegistryKey.of(RegistryKeys.WORLD, Identifier.of(parts[0]));
|
||||
|
||||
float angle = nbt.getFloat("angle"); //Und den blickwinkel
|
||||
|
||||
|
|
|
@ -13,10 +13,12 @@ import net.minecraft.util.Identifier;
|
|||
public class modNetworkingServer { //Identifier werden eingeführt
|
||||
public static final Identifier request_respawn = Identifier.of(REServerMod.MOD_ID, "request_respawn"); //alle Identifier muessen leider IMMER auf Client und Server (doppelt) eingefuehrt werden
|
||||
public static final Identifier start_sleeping_call_buttons = Identifier.of(REServerMod.MOD_ID, "start_sleeping_call_buttons");
|
||||
public static final Identifier death_multi_respawn_buttons = Identifier.of(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
public static final Identifier death_call_respawn_buttons = Identifier.of(REServerMod.MOD_ID, "death_call_respawn_buttons");
|
||||
|
||||
public static void registerS2CPackets() { //Identifier fuer packets werden registriert (Identifier die der Client aufruft um beim Server was auszufuehren)
|
||||
PayloadTypeRegistry.playC2S().register(requestRespawn.ID, requestRespawn.CODEC);
|
||||
PayloadTypeRegistry.playC2S().register(startSleepingCallButtons.ID, startSleepingCallButtons.CODEC);
|
||||
PayloadTypeRegistry.playC2S().register(deathMultiRespawnButtons.ID, deathMultiRespawnButtons.CODEC);
|
||||
//PayloadTypeRegistry.playC2S().register(requestRespawn.ID, requestRespawn.CODEC);
|
||||
|
||||
ServerPlayNetworking.registerGlobalReceiver(startSleepingCallButtons.ID, (payload, context) -> {
|
||||
context.server().execute(() -> {
|
||||
|
|
|
@ -7,9 +7,8 @@ import net.minecraft.network.codec.PacketCodecs;
|
|||
import net.minecraft.network.packet.CustomPayload;
|
||||
|
||||
public record deathMultiRespawnButtons(int number) implements CustomPayload {
|
||||
public static final Id<deathMultiRespawnButtons> ID = new Id<>(modNetworkingServer.request_respawn);
|
||||
public static final CustomPayload.Id<deathMultiRespawnButtons> ID = new CustomPayload.Id<>(modNetworkingServer.death_call_respawn_buttons);
|
||||
public static final PacketCodec<RegistryByteBuf, deathMultiRespawnButtons> CODEC = PacketCodec.tuple(PacketCodecs.INTEGER, deathMultiRespawnButtons::number, deathMultiRespawnButtons::new);
|
||||
//PacketCodec.tuple(PacketCodecs.INTEGER, requestRespawn::new);
|
||||
|
||||
@Override
|
||||
public Id<? extends CustomPayload> getId() {
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.network.packet.CustomPayload;
|
|||
public record requestRespawn(int number) implements CustomPayload {
|
||||
public static final CustomPayload.Id<requestRespawn> ID = new CustomPayload.Id<>(modNetworkingServer.request_respawn);
|
||||
public static final PacketCodec<RegistryByteBuf, requestRespawn> CODEC = PacketCodec.tuple(PacketCodecs.INTEGER, requestRespawn::number, requestRespawn::new);
|
||||
//PacketCodec.tuple(PacketCodecs.INTEGER, requestRespawn::new);
|
||||
|
||||
@Override
|
||||
public Id<? extends CustomPayload> getId() {
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.network.codec.PacketCodecs;
|
|||
import net.minecraft.network.packet.CustomPayload;
|
||||
|
||||
public record startSleepingCallButtons(int number) implements CustomPayload {
|
||||
public static final Id<startSleepingCallButtons> ID = new Id<>(modNetworkingServer.request_respawn);
|
||||
public static final CustomPayload.Id<startSleepingCallButtons> ID = new CustomPayload.Id<>(modNetworkingServer.start_sleeping_call_buttons);
|
||||
public static final PacketCodec<RegistryByteBuf, startSleepingCallButtons> CODEC = PacketCodec.tuple(PacketCodecs.INTEGER, startSleepingCallButtons::number, startSleepingCallButtons::new);
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
"Theo Dupuis",
|
||||
"Paula Dupuis",
|
||||
"Jakob Kircher",
|
||||
"Clemens von Molo"
|
||||
"Clemens von Molo",
|
||||
"Hanno Reents"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "reents.tv",
|
||||
|
@ -23,7 +24,7 @@
|
|||
"modchest.REServerMod"
|
||||
],
|
||||
"client": [
|
||||
"modchest.REServerModClient"
|
||||
"modchestClient.REServerModClient"
|
||||
],
|
||||
"fabric-datagen": [
|
||||
"modchest.REServerModDataGenerator"
|
||||
|
@ -38,7 +39,7 @@
|
|||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.23",
|
||||
"minecraft": "~1.19.2",
|
||||
"minecraft": "~1.21",
|
||||
"java": ">=17",
|
||||
"fabric-api": "*"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue