Search in sources :

Example 1 with EntityShlime

use of stevekung.mods.moreplanets.module.planets.nibiru.entity.EntityShlime in project MorePlanets by SteveKunG.

the class EntityEventHandler method onInteractEntity.

@SubscribeEvent
public void onInteractEntity(EntityInteract event) {
    ItemStack itemStack = event.getItemStack();
    Entity entity = event.getTarget();
    if (!itemStack.isEmpty() && itemStack.getItem() == Items.DYE) {
        EnumDyeColor color = EnumDyeColor.byDyeDamage(itemStack.getItemDamage() & 15);
        if (entity instanceof EntityShlime) {
            EntityShlime shlime = (EntityShlime) entity;
            if (!shlime.getSheared() && shlime.getFleeceColor() != color) {
                shlime.setFleeceColor(color);
                if (!event.getEntityPlayer().capabilities.isCreativeMode) {
                    itemStack.shrink(1);
                }
            }
            event.setResult(Result.ALLOW);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityShlime(stevekung.mods.moreplanets.module.planets.nibiru.entity.EntityShlime) ItemStack(net.minecraft.item.ItemStack) EnumDyeColor(net.minecraft.item.EnumDyeColor) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with EntityShlime

use of stevekung.mods.moreplanets.module.planets.nibiru.entity.EntityShlime in project MorePlanets by SteveKunG.

the class ItemDyeMP method itemInteractionForEntity.

@Override
public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer player, EntityLivingBase target, EnumHand hand) {
    if (target instanceof EntitySheep) {
        EntitySheep entitysheep = (EntitySheep) target;
        EnumDyeColor enumdyecolor = EnumDyeColor.BLUE;
        if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != enumdyecolor) {
            entitysheep.setFleeceColor(enumdyecolor);
            itemStack.shrink(1);
        }
        return true;
    }
    if (target instanceof EntityShlime) {
        EntityShlime entitysheep = (EntityShlime) target;
        EnumDyeColor enumdyecolor = EnumDyeColor.BLUE;
        if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != enumdyecolor) {
            entitysheep.setFleeceColor(enumdyecolor);
            itemStack.shrink(1);
        }
        return true;
    } else {
        return false;
    }
}
Also used : EntitySheep(net.minecraft.entity.passive.EntitySheep) EntityShlime(stevekung.mods.moreplanets.module.planets.nibiru.entity.EntityShlime) EnumDyeColor(net.minecraft.item.EnumDyeColor)

Aggregations

EnumDyeColor (net.minecraft.item.EnumDyeColor)2 EntityShlime (stevekung.mods.moreplanets.module.planets.nibiru.entity.EntityShlime)2 Entity (net.minecraft.entity.Entity)1 EntitySheep (net.minecraft.entity.passive.EntitySheep)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1