@Override protected void onImpact(@Nonnull RayTraceResult mop) { if (!this.world.isRemote) { AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().grow(4.0D, 2.0D, 4.0D); List<EntityLivingBase> list = this.world.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); if (!list.isEmpty()) { for (EntityLivingBase entitylivingbase : list) { if (entitylivingbase instanceof EntitySkeletonWarrior || entitylivingbase instanceof EntityBabySkeleton || entitylivingbase instanceof EntitySkeleton || entitylivingbase instanceof EntitySkeletonHorse) { double d0 = this.getDistanceSqToEntity(entitylivingbase); if (d0 < 16.0D) entitylivingbase.heal(1); } } } world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.NEUTRAL, 0.5F, 0.8F / (rand.nextFloat() * 0.4F + 0.8F)); this.setDead(); } }
@SubscribeEvent public void onEntityInteractEvent(EntityInteract event) { if (event.getEntity() instanceof EntityPlayer == false) { return; } EntityPlayer player = (EntityPlayer) event.getEntity(); // ItemStack held = player.getHeldItemMainhand(); ItemStack itemstack = event.getItemStack(); if (itemstack != null && itemstack.getItem() instanceof ItemAppleLapis && itemstack.getCount() > 0) { if (event.getTarget() instanceof EntityZombieHorse || event.getTarget() instanceof EntitySkeletonHorse) { AbstractHorse h = (AbstractHorse) event.getTarget(); if (h.isTame() == false) { h.setTamedBy(player); h.setEatingHaystack(true); // UtilChat.addChatMessage(player, UtilChat.lang("item.apple_emerald.merchant")); itemstack.shrink(1); if (itemstack.getCount() == 0) { itemstack = ItemStack.EMPTY; } event.setCanceled(true);// stop the GUI inventory opening && horse mounting } } } }
private AbstractHorse createHorse(DifficultyInstance p_188515_1_) { EntitySkeletonHorse entityskeletonhorse = new EntitySkeletonHorse(this.horse.world); entityskeletonhorse.onInitialSpawn(p_188515_1_, (IEntityLivingData)null); entityskeletonhorse.setPosition(this.horse.posX, this.horse.posY, this.horse.posZ); entityskeletonhorse.hurtResistantTime = 60; entityskeletonhorse.enablePersistence(); entityskeletonhorse.setHorseTamed(true); entityskeletonhorse.setGrowingAge(0); entityskeletonhorse.world.spawnEntityInWorld(entityskeletonhorse); return entityskeletonhorse; }
public boolean shouldExecute() { EntityLivingBase entity = this.attacker.getAttackTarget(); if (entity != null && !(entity instanceof EntityUndeadHorse) && !(entity instanceof EntityZombieHorse) && !(entity instanceof EntitySkeletonHorse)) { return super.shouldExecute(); } return false; }
public ModelAdapterZombieHorse() { super(EntitySkeletonHorse.class, "skeleton_horse", 0.75F); }
public EntityAISkeletonRiders(EntitySkeletonHorse horseIn) { this.horse = horseIn; }
@SubscribeEvent public static void rightClickEntity(PlayerInteractEvent.EntityInteract event) { if (event.getTarget() instanceof EntitySkeleton || ((event.getTarget() instanceof EntitySkeletonWarrior || event.getTarget() instanceof EntityBabySkeleton || event.getTarget() instanceof EntitySkeletonHorse) && event.getEntityPlayer().isSneaking())) { if (((EntityLivingBase) event.getTarget()).getHealth() < ((EntityLivingBase) event.getTarget()).getMaxHealth()) if (!event.getItemStack().isEmpty()) if (event.getItemStack().getItem() == Items.MILK_BUCKET) { ((EntityLivingBase) event.getTarget()).heal(1); if (!event.getEntityPlayer().isCreative()) { if (event.getItemStack().getCount() > 1) event.getItemStack().shrink(1); else event.getEntityPlayer().setItemStackToSlot(event.getHand() == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY); event.getEntityPlayer().inventory.addItemStackToInventory(new ItemStack(Items.BUCKET)); } if (event.getTarget() instanceof EntitySkeletonWarrior) ((EntitySkeletonWarrior) event.getTarget()).increaseMilkLevel(false); } if (event.getTarget() instanceof EntitySkeleton && ((EntitySkeleton) event.getTarget()).isPotionActive(MobEffects.WEAKNESS) && !(event.getTarget() instanceof EntityCuringSkeleton) && event.getItemStack().getItem() == Items.GOLDEN_APPLE && event.getItemStack().getMetadata() == 0) { if (!event.getEntityPlayer().capabilities.isCreativeMode) { event.getItemStack().shrink(1); } if (!event.getWorld().isRemote) { EntitySkeleton oldSkelly = (EntitySkeleton) event.getTarget(); EntityCuringSkeleton newSkelly = new EntityCuringSkeleton(event.getWorld(), event.getEntityPlayer() != null ? event.getEntityPlayer().getUniqueID() : null); newSkelly.copyLocationAndAnglesFrom(oldSkelly); newSkelly.setHeldItem(EnumHand.MAIN_HAND, oldSkelly.getHeldItemMainhand()); newSkelly.setHeldItem(EnumHand.OFF_HAND, oldSkelly.getHeldItemOffhand()); newSkelly.setItemStackToSlot(EntityEquipmentSlot.HEAD, oldSkelly.getItemStackFromSlot(EntityEquipmentSlot.HEAD)); newSkelly.setItemStackToSlot(EntityEquipmentSlot.CHEST, oldSkelly.getItemStackFromSlot(EntityEquipmentSlot.CHEST)); newSkelly.setItemStackToSlot(EntityEquipmentSlot.LEGS, oldSkelly.getItemStackFromSlot(EntityEquipmentSlot.LEGS)); newSkelly.setItemStackToSlot(EntityEquipmentSlot.FEET, oldSkelly.getItemStackFromSlot(EntityEquipmentSlot.FEET)); event.getWorld().removeEntity(oldSkelly); event.getWorld().spawnEntity(newSkelly); newSkelly.startConverting(event.getWorld().rand.nextInt(4802) + 3600); } } } else if (event.getTarget() instanceof EntityCow) { if (!event.getItemStack().isEmpty()) if (event.getItemStack().getItem() == Items.GLASS_BOTTLE) { if (!event.getWorld().isRemote) { if (!event.getEntityPlayer().isCreative()) { if (event.getItemStack().getCount() > 1) event.getItemStack().shrink(1); else event.getEntityPlayer().setItemStackToSlot(event.getHand() == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY); } event.getEntityPlayer().inventory.addItemStackToInventory(new ItemStack(Overlord.milk_bottle)); } event.getEntityPlayer().playSound(SoundEvents.ENTITY_COW_MILK, 1.0F, 1.0F + event.getWorld().rand.nextFloat()); } } if (event.getTarget() instanceof ISkinsuitWearer && event.getItemStack().getItem() == Items.SHEARS) { ISkinsuitWearer skin = (ISkinsuitWearer) event.getTarget(); if (!skin.getSkinType().isNone()) { skin.setSkinsuit(ItemStack.EMPTY, SkinType.NONE); if (!event.getEntityPlayer().isCreative()) event.getItemStack().damageItem(1, event.getEntityPlayer()); } } }