    001    package net.minecraftforge.common;
    002
    003    import java.util.UUID;
    004
    005    import net.minecraft.src.*;
    006    import net.minecraftforge.event.*;
    007    import net.minecraftforge.event.entity.*;
    008    import net.minecraftforge.event.world.WorldEvent;
    009
    010    public class ForgeInternalHandler
    011    {
    012        @ForgeSubscribe(priority = EventPriority.HIGHEST)
    013        public void onEntityJoinWorld(EntityJoinWorldEvent event)
    014        {
    015            if (!event.world.isRemote)
    016            {
    017                if (event.entity.getPersistentID() == null)
    018                {
    019                    event.entity.generatePersistentID();
    020                }
    021                else
    022                {
    023                    ForgeChunkManager.loadEntity(event.entity);
    024                }
    025            }
    026            Entity entity = event.entity;
    027            if (entity.getClass().equals(EntityItem.class))
    028            {
    029                ItemStack item = ((EntityItem)entity).item;
    030                if (item != null && item.getItem().hasCustomEntity(item))
    031                {
    032                    Entity newEntity = item.getItem().createEntity(event.world, entity, item);
    033                    if (newEntity != null)
    034                    {
    035                        entity.setDead();
    036                        event.setCanceled(true);
    037                        event.world.spawnEntityInWorld(newEntity);
    038                    }
    039                }
    040            }
    041        }
    042
    043        @ForgeSubscribe(priority = EventPriority.HIGHEST)
    044        public void onDimensionLoad(WorldEvent.Load event)
    045        {
    046            ForgeChunkManager.loadWorld(event.world);
    047        }
    048
    049        @ForgeSubscribe(priority = EventPriority.HIGHEST)
    050        public void onDimensionSave(WorldEvent.Save event)
    051        {
    052            ForgeChunkManager.saveWorld(event.world);
    053        }
    054    }