protected void initEntityAI() { this.aiSit = new EntityAISit(this); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.aiSit); this.tasks.addTask(3, new EntityWolf.AIAvoidEntity(this, EntityLlama.class, 24.0F, 1.5D, 1.5D)); this.tasks.addTask(4, new EntityAILeapAtTarget(this, 0.4F)); this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true)); this.tasks.addTask(6, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); this.tasks.addTask(7, new EntityAIMate(this, 1.0D)); this.tasks.addTask(8, new EntityAIWanderAvoidWater(this, 1.0D)); this.tasks.addTask(9, new EntityAIBeg(this, 8.0F)); this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(10, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0])); this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityAnimal.class, false, new Predicate<Entity>() { public boolean apply(@Nullable Entity p_apply_1_) { return p_apply_1_ instanceof EntitySheep || p_apply_1_ instanceof EntityRabbit; } })); this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, AbstractSkeleton.class, false)); }
/** * Used for easily adding entity-dependent animations. The second and third float params here are the same second * and third as in the setRotationAngles method. */ public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime) { this.rightArmPose = ModelBiped.ArmPose.EMPTY; this.leftArmPose = ModelBiped.ArmPose.EMPTY; ItemStack itemstack = entitylivingbaseIn.getHeldItem(EnumHand.MAIN_HAND); if (itemstack.getItem() == Items.BOW && ((AbstractSkeleton)entitylivingbaseIn).isSwingingArms()) { if (entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT) { this.rightArmPose = ModelBiped.ArmPose.BOW_AND_ARROW; } else { this.leftArmPose = ModelBiped.ArmPose.BOW_AND_ARROW; } } super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime); }
/** * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how * "far" arms and legs can swing at most. */ public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) { super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn); ItemStack itemstack = ((EntityLivingBase)entityIn).getHeldItemMainhand(); AbstractSkeleton abstractskeleton = (AbstractSkeleton)entityIn; if (abstractskeleton.isSwingingArms() && (itemstack.func_190926_b() || itemstack.getItem() != Items.BOW)) { float f = MathHelper.sin(this.swingProgress * (float)Math.PI); float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float)Math.PI); this.bipedRightArm.rotateAngleZ = 0.0F; this.bipedLeftArm.rotateAngleZ = 0.0F; this.bipedRightArm.rotateAngleY = -(0.1F - f * 0.6F); this.bipedLeftArm.rotateAngleY = 0.1F - f * 0.6F; this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F); this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F); this.bipedRightArm.rotateAngleX -= f * 1.2F - f1 * 0.4F; this.bipedLeftArm.rotateAngleX -= f * 1.2F - f1 * 0.4F; this.bipedRightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F; this.bipedRightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F; this.bipedLeftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F; } }
@SubscribeEvent(priority = EventPriority.HIGH) public void onEntityLivingDeath(LivingDeathEvent event) { if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { if (ExtendedConfig.spawnSkullCrawlersAtMobsDeath) { if (event.getEntity() instanceof AbstractSkeleton) { EntitySkullCrawler crawler; if (MobSpawn.isWitherSkeleton((AbstractSkeleton) event.getEntity())) { crawler = new EntityWitherSkullCrawler(event.getEntity().getEntityWorld()); } else if (MobSpawn.isStraySkeleton((AbstractSkeleton) event.getEntity())) { crawler = new EntityStraySkullCrawler(event.getEntity().getEntityWorld()); } else { crawler = new EntitySkullCrawler(event.getEntity().getEntityWorld()); } MobSpawn.spawnCrawler(event.getEntity(), crawler); } else if (event.getEntity() instanceof EntityZombie) { MobSpawn.spawnCrawler(event.getEntity(), new EntityZombieSkullCrawler(event.getEntity().getEntityWorld())); } } if (event.getEntity() instanceof EntityCreeper && ((EntityCreeper) event.getEntity()).getPowered()) { // drop creeper statue if entity is a charged creeper GSBlock.MEMORIAL.dropCreeperMemorial(event.getEntity().getEntityWorld(), new BlockPos(event.getEntity())); } } }
public EntityAIAttackRangedBow(AbstractSkeleton skeleton, double speedAmplifier, int delay, float maxDistance) { this.entity = skeleton; this.moveSpeedAmp = speedAmplifier; this.attackCooldown = delay; this.maxAttackDistance = maxDistance * maxDistance; this.setMutexBits(3); }
/** * Listen to {@link EntityJoinWorldEvent} : * Adds random special {@link EntityArrow}s data to {@link AbstractSkeleton}s {@link net.minecraft.network.datasync.EntityDataManager} (for display) * Replace the vanilla fired {@link EntityTippedArrow} with the custom {@link AbstractMBArrow} (for actual action) * Note: Fails silently */ @SubscribeEvent(priority = EventPriority.LOW) public void onEntityJoinWorld(EntityJoinWorldEvent event){ if(event.getEntity() instanceof AbstractSkeleton){ registerArrowType((AbstractSkeleton)event.getEntity()); }else if(event.getEntity() instanceof EntityTippedArrow && ((EntityTippedArrow) event.getEntity()).getColor() == 0){ EntityArrow arrow = ((EntityArrow)event.getEntity()); if (arrow.shootingEntity instanceof AbstractSkeleton) { AbstractSkeleton skeleton = (AbstractSkeleton) arrow.shootingEntity; if(skeleton.getAttackTarget() != null) { ItemStack type = getArrowForMob(skeleton); if (type.getItem() instanceof ItemArrow) { EntityArrow mbArrow = ((ItemArrow)type.getItem()).createArrow(skeleton.world, type, skeleton); if (!(mbArrow instanceof EntityTippedArrow)) { EntityLivingBase target = skeleton.getAttackTarget(); float pow = MathHelper.sqrt(skeleton.getDistanceSq(target.posX, target.getEntityBoundingBox().minY, target.posZ)) / 15F; pow = MathHelper.clamp(pow, 0.1F, 1.0F); mbArrow.setEnchantmentEffectsFromEntity(skeleton, pow); if (skeleton instanceof EntityWitherSkeleton) mbArrow.setFire(100); double d0 = target.posX - skeleton.posX; double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - mbArrow.posY; double d2 = target.posZ - skeleton.posZ; double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2); mbArrow.setThrowableHeading(d0, d1 + d3 * 0.2D, d2, 1.6F, (float)(14 - skeleton.world.getDifficulty().getDifficultyId() * 4)); mbArrow.setDamage(arrow.getDamage()); if (skeleton.world.spawnEntity(mbArrow)) event.setCanceled(true); } } } } } }
/** * Writes AbstractSkeleton DataManager arrow type data * Based on configured chance rates * @param skeleton To write data to */ private void registerArrowType(AbstractSkeleton skeleton){ try{ skeleton.getDataManager().register(SKELETON_ARROW, (byte) -1); for(int i = 0; i < ItemMBArrow.names.length; i++){ if(skeleton.getRNG().nextFloat() < BattlegearConfig.skeletonArrowSpawnRate[i]){ skeleton.getDataManager().set(SKELETON_ARROW, (byte) i); break; } } }catch (Exception ignored){} }
/** * Reads AbstractSkeleton DataManager arrow type data * @param skeleton To read data from * @return the arrow type */ private int getArrowType(AbstractSkeleton skeleton){ int type; try { type = skeleton.getDataManager().get(SKELETON_ARROW); }catch (Exception handled){ type = -1; } return type; }
/** * Build ItemStack according to AbstractSkeleton DataManager arrow type data * @param skeleton To read data from * @return the arrow stack */ public ItemStack getArrowForMob(AbstractSkeleton skeleton){ int type = getArrowType(skeleton); if(type>-1) return new ItemStack(BattlegearConfig.MbArrows, 1, type); return new ItemStack(Items.ARROW); }
/** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(AbstractSkeleton entity) { return STRAY_SKELETON_TEXTURES; }
/** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(AbstractSkeleton entity) { return SKELETON_TEXTURES; }
/** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(AbstractSkeleton entity) { return WITHER_SKELETON_TEXTURES; }
/** * Allows the render to do state modifications necessary before the model is rendered. */ protected void preRenderCallback(AbstractSkeleton entitylivingbaseIn, float partialTickTime) { GlStateManager.scale(1.2F, 1.2F, 1.2F); }
@Override protected void preRenderCallback(AbstractSkeleton entity, float partialTickTime) { float scale = ((EntitySkeletonNemesis) entity).getNemesisScale(); GlStateManager.scale(scale, scale, scale); }
@Override protected void preRenderCallback(AbstractSkeleton entity, float partialTickTime) { float scale = ((EntityStrayNemesis) entity).getNemesisScale(); GlStateManager.scale(scale, scale, scale); }
public static boolean isWitherSkeleton(AbstractSkeleton skeleton) { return skeleton instanceof EntityGSSkeleton && ((EntityGSSkeleton) skeleton).getSkeletonType() == SkeletonType.WITHER || skeleton instanceof EntityWitherSkeleton; }
public static boolean isStraySkeleton(AbstractSkeleton skeleton) { return skeleton instanceof EntityGSSkeleton && ((EntityGSSkeleton) skeleton).getSkeletonType() == SkeletonType.STRAY || skeleton instanceof EntityStray; }
@Override protected ResourceLocation getEntityTexture(AbstractSkeleton entity) { return texture; }
/** * Render quiver on skeletons if possible */ @SubscribeEvent public void renderLiving(RenderLivingEvent.Post<AbstractSkeleton> event) { if (BattlegearConfig.enableSkeletonQuiver && event.getEntity() instanceof EntitySkeleton && event.getRenderer() instanceof RenderSkeleton) { GlStateManager.pushMatrix(); GlStateManager.disableCull(); GlStateManager.color(1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(quiverDetails); GlStateManager.translate((float) event.getX(), (float) event.getY(), (float) event.getZ()); GlStateManager.scale(1, -1, 1); float f2 = interpolateRotation(event.getEntity().prevRenderYawOffset, event.getEntity().renderYawOffset, BattlegearClientTickHandeler.getPartialTick()); GlStateManager.rotate(180.0F - f2, 0.0F, 1.0F, 0.0F); if (event.getEntity().deathTime > 0) { float f3 = ((float) event.getEntity().deathTime + BattlegearClientTickHandeler.getPartialTick() - 1.0F) / 20.0F * 1.6F; f3 = MathHelper.sqrt(f3); if (f3 > 1.0F) { f3 = 1.0F; } GlStateManager.rotate(-f3 * 90, 0.0F, 0.0F, 1.0F); } GlStateManager.translate(0, -1.5F, 0); GlStateManager.rotate(event.getEntity().rotationPitch, 0, 1, 0); if(event.getEntity().hasItemInSlot(EntityEquipmentSlot.CHEST)){ GlStateManager.translate(0, 0, BattlegearRenderHelper.RENDER_UNIT); } ((ModelBiped)event.getRenderer().mainModel).bipedBody.postRender(BattlegearRenderHelper.RENDER_UNIT); GlStateManager.scale(1.05F, 1.05F, 1.05F); quiverModel.render(SKELETON_ARROW, BattlegearRenderHelper.RENDER_UNIT); Minecraft.getMinecraft().getTextureManager().bindTexture(quiverBase); GlStateManager.color(0.10F, 0.10F, 0.10F); quiverModel.render(0, BattlegearRenderHelper.RENDER_UNIT); GlStateManager.color(1, 1, 1); GlStateManager.enableCull(); GlStateManager.popMatrix(); } }
@Override public Class helperForClass() { return AbstractSkeleton.class; }
@Override public boolean itemInteractionForEntity (ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand) { final World world = target.getEntityWorld(); if (!world.isRemote && stack.getMetadata() == 0 && target instanceof AbstractSkeleton && !(target instanceof EntityWitherSkeleton)) { transformEntity(world, target, stack); return true; } return false; }