Skip to content

Commit

Permalink
Merge branch 'refs/heads/architectury-1.20.6' into architectury-1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Nov 25, 2024
2 parents 74ac91d + 454a0da commit 604bd03
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.unlikepaladin.pfm.client.fabric;

import com.unlikepaladin.pfm.PaladinFurnitureMod;
import com.unlikepaladin.pfm.client.screens.PFMConfigScreen;
import com.unlikepaladin.pfm.config.option.Side;
import com.unlikepaladin.pfm.networking.MicrowaveUpdatePayload;
import com.unlikepaladin.pfm.networking.SyncConfigPayload;
import com.unlikepaladin.pfm.networking.fabric.LeaveEventHandlerFabric;
import com.unlikepaladin.pfm.registry.NetworkIDs;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;

public class ClientPacketRegistry {

public static void registerClientPackets() {
PayloadTypeRegistry.playS2C().register(NetworkIDs.MICROWAVE_UPDATE_PACKET_ID, MicrowaveUpdatePayload.PACKET_CODEC);
ClientPlayNetworking.registerGlobalReceiver(NetworkIDs.MICROWAVE_UPDATE_PACKET_ID, (payload, context) -> { payload.handle(context.player(), context.client());});
PayloadTypeRegistry.playS2C().register(NetworkIDs.CONFIG_SYNC_ID, SyncConfigPayload.PACKET_CODEC);
ClientPlayNetworking.registerGlobalReceiver(NetworkIDs.CONFIG_SYNC_ID,
(payload, context) -> {
context.client().execute(() -> {
payload.configOptionMap().forEach((title, configOption) -> {
PFMConfigScreen.isOnServer = true;
if (configOption.getSide() == Side.SERVER) {
LeaveEventHandlerFabric.originalConfigValues.put(title, PaladinFurnitureMod.getPFMConfig().options.get(title).getValue());
PaladinFurnitureMod.getPFMConfig().options.get(title).setValue(configOption.getValue());
}
});
});
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
import com.unlikepaladin.pfm.client.PaladinFurnitureModClient;
import com.unlikepaladin.pfm.client.ScreenRegistry;
import com.unlikepaladin.pfm.client.fabric.modelLoaders.PFMModelLoadingV1;
import com.unlikepaladin.pfm.client.screens.PFMConfigScreen;
import com.unlikepaladin.pfm.config.option.Side;
import com.unlikepaladin.pfm.fabric.PaladinFurnitureModFabric;
import com.unlikepaladin.pfm.networking.MicrowaveUpdatePayload;
import com.unlikepaladin.pfm.networking.SyncConfigPayload;
import com.unlikepaladin.pfm.networking.fabric.LeaveEventHandlerFabric;
import com.unlikepaladin.pfm.registry.NetworkIDs;
import com.unlikepaladin.pfm.registry.fabric.NetworkRegistryFabric;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
Expand All @@ -29,7 +36,7 @@ public void onInitializeClient() {
PaladinFurnitureModFabric.registerLateEntries();
PaladinFurnitureModFabric.replaceHomePOIStates();
ColorRegistryFabric.registerAll();
NetworkRegistryFabric.registerClientPackets();
ClientPacketRegistry.registerClientPackets();

PaladinFurnitureModClient.USE_TOILET_KEYBIND = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.pfm.toiletUse", // The translation key of the keybinding's name
Expand All @@ -46,4 +53,5 @@ public void onInitializeClient() {
ParticleProviderRegistryFabric.registerParticleFactories();
ClientPlayConnectionEvents.DISCONNECT.register(LeaveEventHandlerFabric::onServerLeave);
}

}
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
package com.unlikepaladin.pfm.registry.fabric;

import com.google.common.collect.Lists;
import com.unlikepaladin.pfm.PaladinFurnitureMod;
import com.unlikepaladin.pfm.blocks.BasicToiletBlock;
import com.unlikepaladin.pfm.blocks.ToiletState;
import com.unlikepaladin.pfm.blocks.blockentities.MicrowaveBlockEntity;
import com.unlikepaladin.pfm.blocks.blockentities.TrashcanBlockEntity;
import com.unlikepaladin.pfm.client.screens.MicrowaveScreen;
import com.unlikepaladin.pfm.client.screens.PFMConfigScreen;
import com.unlikepaladin.pfm.config.option.AbstractConfigOption;
import com.unlikepaladin.pfm.config.option.Side;
import com.unlikepaladin.pfm.networking.*;
import com.unlikepaladin.pfm.networking.fabric.LeaveEventHandlerFabric;
import com.unlikepaladin.pfm.registry.NetworkIDs;
import com.unlikepaladin.pfm.registry.SoundIDs;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableTextContent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.io.IOException;
import java.util.*;

public class NetworkRegistryFabric {
public static void registerPackets() {
Expand All @@ -42,23 +19,4 @@ public static void registerPackets() {
ServerPlayNetworking.registerGlobalReceiver(NetworkIDs.TOILET_USE_ID,
((payload, context) -> payload.handle(context.server(), context.player())));
}

public static void registerClientPackets() {
PayloadTypeRegistry.playS2C().register(NetworkIDs.MICROWAVE_UPDATE_PACKET_ID, MicrowaveUpdatePayload.PACKET_CODEC);
ClientPlayNetworking.registerGlobalReceiver(NetworkIDs.MICROWAVE_UPDATE_PACKET_ID, (payload, context) -> { payload.handle(context.player(), context.client());});
PayloadTypeRegistry.playS2C().register(NetworkIDs.CONFIG_SYNC_ID, SyncConfigPayload.PACKET_CODEC);
ClientPlayNetworking.registerGlobalReceiver(NetworkIDs.CONFIG_SYNC_ID,
(payload, context) -> {
context.client().execute(() -> {
payload.configOptionMap().forEach((title, configOption) -> {
PFMConfigScreen.isOnServer = true;
if (configOption.getSide() == Side.SERVER) {
LeaveEventHandlerFabric.originalConfigValues.put(title, PaladinFurnitureMod.getPFMConfig().options.get(title).getValue());
PaladinFurnitureMod.getPFMConfig().options.get(title).setValue(configOption.getValue());
}
});
});
}
);
}
}

0 comments on commit 604bd03

Please sign in to comment.