Search in sources :

Example 11 with EntityWolf

use of net.minecraft.entity.passive.EntityWolf in project takumicraft by TNTModders.

the class EntityWolfCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    List<EntityWolf> list = new ArrayList<>();
    for (Entity entity : event.getAffectedEntities()) {
        if (entity instanceof EntityWolf) {
            list.add((EntityWolf) entity);
        }
    }
    event.getAffectedEntities().removeAll(list);
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) ArrayList(java.util.ArrayList) EntityWolf(net.minecraft.entity.passive.EntityWolf)

Example 12 with EntityWolf

use of net.minecraft.entity.passive.EntityWolf in project BiomesOPlenty by Glitchfiend.

the class DyeEventHandler method entityInteract.

@SubscribeEvent
public void entityInteract(PlayerInteractEvent.EntityInteract event) {
    ItemStack stack = event.getEntityPlayer().getHeldItem(event.getHand());
    if (stack == null) {
        return;
    }
    Item item = stack.getItem();
    EnumDyeColor dyeColor;
    if (item == BOPItems.black_dye) {
        dyeColor = EnumDyeColor.BLACK;
    } else if (item == BOPItems.blue_dye) {
        dyeColor = EnumDyeColor.BLUE;
    } else if (item == BOPItems.brown_dye) {
        dyeColor = EnumDyeColor.BROWN;
    } else if (item == BOPItems.green_dye) {
        dyeColor = EnumDyeColor.GREEN;
    } else if (item == BOPItems.white_dye) {
        dyeColor = EnumDyeColor.WHITE;
    } else {
        return;
    }
    Entity target = event.getTarget();
    if (target instanceof EntityWolf) {
        EntityWolf wolf = (EntityWolf) target;
        if (dyeColor != wolf.getCollarColor()) {
            wolf.setCollarColor(dyeColor);
            if (!event.getEntityPlayer().capabilities.isCreativeMode) {
                stack.setCount(stack.getCount() - 1);
            }
            event.setResult(Result.ALLOW);
        }
    } else if (target instanceof EntitySheep) {
        EntitySheep sheep = (EntitySheep) target;
        if (!sheep.getSheared() && dyeColor != sheep.getFleeceColor()) {
            sheep.setFleeceColor(dyeColor);
            if (!event.getEntityPlayer().capabilities.isCreativeMode) {
                stack.setCount(stack.getCount() - 1);
            }
            event.setResult(Result.ALLOW);
        }
    }
}
Also used : Item(net.minecraft.item.Item) Entity(net.minecraft.entity.Entity) EntitySheep(net.minecraft.entity.passive.EntitySheep) EntityWolf(net.minecraft.entity.passive.EntityWolf) ItemStack(net.minecraft.item.ItemStack) EnumDyeColor(net.minecraft.item.EnumDyeColor) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityWolf (net.minecraft.entity.passive.EntityWolf)12 Entity (net.minecraft.entity.Entity)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 BlockPos (net.minecraft.util.math.BlockPos)3 ITeleportHandler (net.dyeo.teleporter.capabilities.ITeleportHandler)2 EntityMob (net.minecraft.entity.monster.EntityMob)2 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)2 EntitySheep (net.minecraft.entity.passive.EntitySheep)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 PotionEffect (net.minecraft.potion.PotionEffect)2 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 TeleporterNode (net.dyeo.teleporter.teleport.TeleporterNode)1 TileEntityTeleporter (net.dyeo.teleporter.tileentity.TileEntityTeleporter)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPainting (net.minecraft.entity.item.EntityPainting)1 EntityChicken (net.minecraft.entity.passive.EntityChicken)1