equivalent-exchange-3/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java

47 lines
1.8 KiB
Java
Raw Normal View History

package com.pahimar.ee3.handler;
2023-01-03 17:47:36 +01:00
import static com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy.Blacklist;
import com.pahimar.ee3.network.PacketHandler;
import com.pahimar.ee3.network.message.MessageChalkSettings;
import com.pahimar.ee3.network.message.MessageSyncBlacklist;
2014-09-11 22:13:39 +02:00
import com.pahimar.ee3.network.message.MessageSyncEnergyValues;
import com.pahimar.ee3.settings.ChalkSettings;
import com.pahimar.ee3.util.EntityHelper;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
public class PlayerEventHandler {
2015-01-29 16:50:38 +01:00
@SubscribeEvent
2023-01-03 17:47:36 +01:00
public void
onPlayerLoggedIn(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event
) {
if (event.player != null) {
2023-01-03 17:47:36 +01:00
NBTTagCompound playerCustomData
= EntityHelper.getCustomEntityData(event.player);
// Chalk Settings
ChalkSettings chalkSettings = new ChalkSettings();
chalkSettings.readFromNBT(playerCustomData);
chalkSettings.writeToNBT(playerCustomData);
EntityHelper.saveCustomEntityData(event.player, playerCustomData);
2023-01-03 17:47:36 +01:00
PacketHandler.INSTANCE.sendTo(
new MessageChalkSettings(chalkSettings), (EntityPlayerMP) event.player
);
2023-01-03 17:47:36 +01:00
PacketHandler.INSTANCE.sendTo(
new MessageSyncEnergyValues(), (EntityPlayerMP) event.player
);
PacketHandler.INSTANCE.sendTo(
new MessageSyncBlacklist(Blacklist.KNOWLEDGE),
(EntityPlayerMP) event.player
);
PacketHandler.INSTANCE.sendTo(
new MessageSyncBlacklist(Blacklist.EXCHANGE),
(EntityPlayerMP) event.player
);
}
}
}