mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 02:37:27 +00:00
PlayerData:
-Renamed loadPlayerDataFromFile() to load(), and moved it next to the save() function for later addition to the API. -Moved saving/loading to EP functions where they used to be. -Removed now unused PlayerData.get() and loadPlayerDataOld() functions ServerEventsHandler: -Added new EntityConstructing event to add the PlayerData EP earlier. NoppesUtilPlayer: -questCompletion() now saves player data right before its return statement.
This commit is contained in:
1 parent
dc42beee15
commit
cbf99be297
5 files changed
+30
-84
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -20,6 +21,7 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
@@ -253,7 +255,7 @@ public class ServerEventsHandler {
|
||||
doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving);
|
||||
}
|
||||
|
||||
if(event.source.getEntity() instanceof EntityNPCInterface && event.entityLiving != null){
|
||||
if(event.source.getEntity() instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
|
||||
Line line = npc.advanced.getKillLine();
|
||||
if(line != null)
|
||||
@@ -358,6 +360,15 @@ public class ServerEventsHandler {
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void onEntityConstructing(EntityEvent.EntityConstructing event) {
|
||||
if (event.entity instanceof EntityPlayerMP) {
|
||||
PlayerData data = new PlayerData();
|
||||
data.player = (EntityPlayer) event.entity;
|
||||
event.entity.registerExtendedProperties("CustomNpcsData", data);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void world(EntityJoinWorldEvent event){
|
||||
if(event.world.isRemote || !(event.entity instanceof EntityPlayer))
|
||||
@@ -366,12 +377,6 @@ public class ServerEventsHandler {
|
||||
data.updateCompanion(event.world);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void world(PlayerEvent.SaveToFile event){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
|
||||
data.save();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void populateChunk(PopulateChunkEvent.Post event){
|
||||
NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand);
|
||||
|
||||
Reference in new issue
Block a user