/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.mod.mixin.core.event.inventory;

import com.google.common.collect.ImmutableList;
import net.minecraft.entity.item.EntityItem;
import net.minecraftforge.event.entity.item.ItemEvent;
import net.minecraftforge.event.entity.item.ItemExpireEvent;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.EntitySnapshot;
import org.spongepowered.api.entity.Item;
import org.spongepowered.api.event.entity.AffectEntityEvent;
import org.spongepowered.api.event.entity.ExpireEntityEvent;
import org.spongepowered.api.util.annotation.NonnullByDefault;
import org.spongepowered.api.world.World;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.common.entity.EntityUtil;
import org.spongepowered.mod.mixin.core.event.entity.MixinEventEntity;

import java.util.ArrayList;
import java.util.List;

@NonnullByDefault
@Mixin(value = ItemEvent.class, remap = false)
public abstract class MixinEventItem extends MixinEventEntity implements AffectEntityEvent {

    protected List<Entity> entities;

    @Shadow @Final public EntityItem entityItem;

    @Inject(method = "<init>", at = @At("RETURN"))
    public void onConstructed(EntityItem itemEntity, CallbackInfo ci) {
        this.entities = new ArrayList<>();
        this.entities.add((Entity) itemEntity);
    }

    @Override
    public List<Entity> getEntities() {
        return this.entities;
    }

//    @Override
//    public List<EntitySnapshot> getEntitySnapshots() {
//        return this.entitySnapshots;
//    }

    @Mixin(value = ItemExpireEvent.class, remap = false)
    static abstract class Expire extends MixinEventItem implements ExpireEntityEvent.TargetItem {

        @Override
        public Item getTargetEntity() {
            return (Item) this.entityItem;
        }

        @Override
        public World getTargetWorld() {
            return (World) this.entityItem.worldObj;
        }

    }

}

@@ -1304,56 +1304,8 @@
 y;%0A%0A
-import com.google.common.collect.ImmutableList;%0A
 impo
@@ -1341,24 +1341,24 @@
 EntityItem;%0A
+
 import net.m
@@ -1509,60 +1509,8 @@
 ty;%0A
-import org.spongepowered.api.entity.EntitySnapshot;%0A
 impo
@@ -2075,59 +2075,8 @@
 fo;%0A
-import org.spongepowered.common.entity.EntityUtil;%0A
 impo
@@ -2412,21 +2412,73 @@
 @Final p
-ublic
+rivate EntityItem entityItem;%0A    @Shadow public abstract
  EntityI
@@ -2473,33 +2473,36 @@
 ract EntityItem 
-e
+getE
 ntityItem;%0A%0A    
@@ -2494,16 +2494,18 @@
 tityItem
+()
 ;%0A%0A    @
@@ -3173,25 +3173,28 @@
 (Item) this.
-e
+getE
 ntityItem;%0A 
@@ -3186,24 +3186,26 @@
 etEntityItem
+()
 ;%0A        %7D%0A
@@ -3291,25 +3291,28 @@
 World) this.
-e
+getE
 ntityItem.wo
@@ -3308,16 +3308,18 @@
 tityItem
+()
 .worldOb

Clean up MixinEventItem to avoid illegal access exceptions.