/** * 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); float f = ageInTicks - (float)entityIn.ticksExisted; float f1 = ((EntityPolarBear)entityIn).getStandingAnimationScale(f); f1 = f1 * f1; float f2 = 1.0F - f1; this.body.rotateAngleX = ((float)Math.PI / 2F) - f1 * (float)Math.PI * 0.35F; this.body.rotationPointY = 9.0F * f2 + 11.0F * f1; this.leg3.rotationPointY = 14.0F * f2 + -6.0F * f1; this.leg3.rotationPointZ = -8.0F * f2 + -4.0F * f1; this.leg3.rotateAngleX -= f1 * (float)Math.PI * 0.45F; this.leg4.rotationPointY = this.leg3.rotationPointY; this.leg4.rotationPointZ = this.leg3.rotationPointZ; this.leg4.rotateAngleX -= f1 * (float)Math.PI * 0.45F; this.head.rotationPointY = 10.0F * f2 + -12.0F * f1; this.head.rotationPointZ = -16.0F * f2 + -3.0F * f1; this.head.rotateAngleX += f1 * (float)Math.PI * 0.15F; }
@Override public void onUpdate(PossessivePlayer possessivePlayer, EntityPlayer player) { EntityPolarBear possessing = (EntityPolarBear) possessivePlayer.getPossessing(); if (!player.worldObj.isRemote) { NBTTagCompound data = this.getData(player); short attackTimer = data.getShort("AttackTimer"); if (attackTimer > 0) { possessing.setStanding(true); data.setShort("AttackTimer", (short) (attackTimer - 1)); } else { if (player.isSwingInProgress) { data.setShort("AttackTimer", (short) 15); } possessing.setStanding(false); } } }
public static void convertToTamed(World world, EntityPolarBear polarBear, EntityPlayer player){ EntityTamedPolarBear tamedBear = new EntityTamedPolarBear(world); tamedBear.copyLocationAndAnglesFrom(polarBear); world.removeEntity(polarBear); tamedBear.setNoAI(polarBear.isAIDisabled()); if (polarBear.hasCustomName()) { tamedBear.setCustomNameTag(polarBear.getCustomNameTag()); tamedBear.setAlwaysRenderNameTag(polarBear.getAlwaysRenderNameTag()); } world.spawnEntity(tamedBear); tamedBear.setTamed(true); tamedBear.navigator.clearPathEntity(); tamedBear.setAttackTarget((EntityLivingBase)null); tamedBear.aiSit.setSitting(true); tamedBear.setOwnerId(player.getUniqueID()); tamedBear.playTameEffect(true); tamedBear.world.setEntityState(tamedBear, (byte)7); }
/** * 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); float f = ageInTicks - (float)entityIn.ticksExisted; float f1 = ((EntityPolarBear)entityIn).func_189795_r(f); f1 = f1 * f1; float f2 = 1.0F - f1; this.body.rotateAngleX = ((float)Math.PI / 2F) - f1 * (float)Math.PI * 0.35F; this.body.rotationPointY = 9.0F * f2 + 11.0F * f1; this.leg3.rotationPointY = 14.0F * f2 + -6.0F * f1; this.leg3.rotationPointZ = -8.0F * f2 + -4.0F * f1; this.leg3.rotateAngleX -= f1 * (float)Math.PI * 0.45F; this.leg4.rotationPointY = this.leg3.rotationPointY; this.leg4.rotationPointZ = this.leg3.rotationPointZ; this.leg4.rotateAngleX -= f1 * (float)Math.PI * 0.45F; this.head.rotationPointY = 10.0F * f2 + -12.0F * f1; this.head.rotationPointZ = -16.0F * f2 + -3.0F * f1; this.head.rotateAngleX += f1 * (float)Math.PI * 0.15F; }
public BiomeSnow(boolean superIcyIn, Biome.BiomeProperties properties) { super(properties); this.superIcy = superIcyIn; if (superIcyIn) { this.topBlock = Blocks.SNOW.getDefaultState(); } this.spawnableCreatureList.clear(); this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityRabbit.class, 10, 2, 3)); this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityPolarBear.class, 1, 1, 2)); Iterator<Biome.SpawnListEntry> iterator = this.spawnableMonsterList.iterator(); while (iterator.hasNext()) { Biome.SpawnListEntry biome$spawnlistentry = (Biome.SpawnListEntry)iterator.next(); if (biome$spawnlistentry.entityClass == EntitySkeleton.class) { iterator.remove(); } } this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntitySkeleton.class, 20, 4, 4)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityStray.class, 80, 4, 4)); }
public BiomeSnow(boolean superIcyIn, Biome.BiomeProperties properties) { super(properties); this.superIcy = superIcyIn; if (superIcyIn) { this.topBlock = Blocks.SNOW.getDefaultState(); } this.spawnableCreatureList.clear(); this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityRabbit.class, 10, 2, 3)); this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityPolarBear.class, 1, 1, 2)); }
@Override protected void initEntityAI() { this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIExtinguishFire()); this.tasks.addTask(2, new EntityAIPanic(this, 1.5D)); this.tasks.addTask(3, new EntityAIMate(this, 0.8D)); this.tasks.addTask(4, new EntityAIAvoidEntity<>(this, EntityPolarBear.class, 6.0F, 1.0D, 1.2D)); this.tasks.addTask(5, new EntityAITempt(this, 1.0D, false, TEMPTATION_ITEMS)); this.tasks.addTask(6, new EntityAIFollowParent(this, 1.1D)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityAdeliePenguin.class, 6.0F)); this.tasks.addTask(10, new EntityAILookIdle(this)); }
private boolean isApplicableType(final Entity e) { if (e instanceof EntityLiving) { if (e instanceof IMob) return true; if (e instanceof EntityPlayer) return true; if (e instanceof EntityGolem) return true; if (e instanceof EntityPolarBear) return true; } return false; }
public ModelAdapterPolarBear() { super(EntityPolarBear.class, "polar_bear", 0.7F); }
/** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityPolarBear entity) { return POLAR_BEAR_TEXTURE; }
/** * Renders the desired {@code T} type Entity. */ public void doRender(EntityPolarBear entity, double x, double y, double z, float entityYaw, float partialTicks) { super.doRender(entity, x, y, z, entityYaw, partialTicks); }
/** * Allows the render to do state modifications necessary before the model is rendered. */ protected void preRenderCallback(EntityPolarBear entitylivingbaseIn, float partialTickTime) { GlStateManager.scale(1.2F, 1.2F, 1.2F); super.preRenderCallback(entitylivingbaseIn, partialTickTime); }
public RenderManager(TextureManager renderEngineIn, RenderItem itemRendererIn) { this.renderEngine = renderEngineIn; this.entityRenderMap.put(EntityCaveSpider.class, new RenderCaveSpider(this)); this.entityRenderMap.put(EntitySpider.class, new RenderSpider(this)); this.entityRenderMap.put(EntityPig.class, new RenderPig(this, new ModelPig(), 0.7F)); this.entityRenderMap.put(EntitySheep.class, new RenderSheep(this, new ModelSheep2(), 0.7F)); this.entityRenderMap.put(EntityCow.class, new RenderCow(this, new ModelCow(), 0.7F)); this.entityRenderMap.put(EntityMooshroom.class, new RenderMooshroom(this, new ModelCow(), 0.7F)); this.entityRenderMap.put(EntityWolf.class, new RenderWolf(this, new ModelWolf(), 0.5F)); this.entityRenderMap.put(EntityChicken.class, new RenderChicken(this, new ModelChicken(), 0.3F)); this.entityRenderMap.put(EntityOcelot.class, new RenderOcelot(this, new ModelOcelot(), 0.4F)); this.entityRenderMap.put(EntityRabbit.class, new RenderRabbit(this, new ModelRabbit(), 0.3F)); this.entityRenderMap.put(EntitySilverfish.class, new RenderSilverfish(this)); this.entityRenderMap.put(EntityEndermite.class, new RenderEndermite(this)); this.entityRenderMap.put(EntityCreeper.class, new RenderCreeper(this)); this.entityRenderMap.put(EntityEnderman.class, new RenderEnderman(this)); this.entityRenderMap.put(EntitySnowman.class, new RenderSnowMan(this)); this.entityRenderMap.put(EntitySkeleton.class, new RenderSkeleton(this)); this.entityRenderMap.put(EntityWitch.class, new RenderWitch(this)); this.entityRenderMap.put(EntityBlaze.class, new RenderBlaze(this)); this.entityRenderMap.put(EntityPigZombie.class, new RenderPigZombie(this)); this.entityRenderMap.put(EntityZombie.class, new RenderZombie(this)); this.entityRenderMap.put(EntitySlime.class, new RenderSlime(this, new ModelSlime(16), 0.25F)); this.entityRenderMap.put(EntityMagmaCube.class, new RenderMagmaCube(this)); this.entityRenderMap.put(EntityGiantZombie.class, new RenderGiantZombie(this, new ModelZombie(), 0.5F, 6.0F)); this.entityRenderMap.put(EntityGhast.class, new RenderGhast(this)); this.entityRenderMap.put(EntitySquid.class, new RenderSquid(this, new ModelSquid(), 0.7F)); this.entityRenderMap.put(EntityVillager.class, new RenderVillager(this)); this.entityRenderMap.put(EntityIronGolem.class, new RenderIronGolem(this)); this.entityRenderMap.put(EntityBat.class, new RenderBat(this)); this.entityRenderMap.put(EntityGuardian.class, new RenderGuardian(this)); this.entityRenderMap.put(EntityShulker.class, new RenderShulker(this, new ModelShulker())); this.entityRenderMap.put(EntityPolarBear.class, new RenderPolarBear(this, new ModelPolarBear(), 0.7F)); this.entityRenderMap.put(EntityDragon.class, new RenderDragon(this)); this.entityRenderMap.put(EntityEnderCrystal.class, new RenderEnderCrystal(this)); this.entityRenderMap.put(EntityWither.class, new RenderWither(this)); this.entityRenderMap.put(Entity.class, new RenderEntity(this)); this.entityRenderMap.put(EntityPainting.class, new RenderPainting(this)); this.entityRenderMap.put(EntityItemFrame.class, new RenderItemFrame(this, itemRendererIn)); this.entityRenderMap.put(EntityLeashKnot.class, new RenderLeashKnot(this)); this.entityRenderMap.put(EntityTippedArrow.class, new RenderTippedArrow(this)); this.entityRenderMap.put(EntitySpectralArrow.class, new RenderSpectralArrow(this)); this.entityRenderMap.put(EntitySnowball.class, new RenderSnowball(this, Items.SNOWBALL, itemRendererIn)); this.entityRenderMap.put(EntityEnderPearl.class, new RenderSnowball(this, Items.ENDER_PEARL, itemRendererIn)); this.entityRenderMap.put(EntityEnderEye.class, new RenderSnowball(this, Items.ENDER_EYE, itemRendererIn)); this.entityRenderMap.put(EntityEgg.class, new RenderSnowball(this, Items.EGG, itemRendererIn)); this.entityRenderMap.put(EntityPotion.class, new RenderPotion(this, itemRendererIn)); this.entityRenderMap.put(EntityExpBottle.class, new RenderSnowball(this, Items.EXPERIENCE_BOTTLE, itemRendererIn)); this.entityRenderMap.put(EntityFireworkRocket.class, new RenderSnowball(this, Items.FIREWORKS, itemRendererIn)); this.entityRenderMap.put(EntityLargeFireball.class, new RenderFireball(this, 2.0F)); this.entityRenderMap.put(EntitySmallFireball.class, new RenderFireball(this, 0.5F)); this.entityRenderMap.put(EntityDragonFireball.class, new RenderDragonFireball(this)); this.entityRenderMap.put(EntityWitherSkull.class, new RenderWitherSkull(this)); this.entityRenderMap.put(EntityShulkerBullet.class, new RenderShulkerBullet(this)); this.entityRenderMap.put(EntityItem.class, new RenderEntityItem(this, itemRendererIn)); this.entityRenderMap.put(EntityXPOrb.class, new RenderXPOrb(this)); this.entityRenderMap.put(EntityTNTPrimed.class, new RenderTNTPrimed(this)); this.entityRenderMap.put(EntityFallingBlock.class, new RenderFallingBlock(this)); this.entityRenderMap.put(EntityArmorStand.class, new RenderArmorStand(this)); this.entityRenderMap.put(EntityMinecartTNT.class, new RenderTntMinecart(this)); this.entityRenderMap.put(EntityMinecartMobSpawner.class, new RenderMinecartMobSpawner(this)); this.entityRenderMap.put(EntityMinecart.class, new RenderMinecart(this)); this.entityRenderMap.put(EntityBoat.class, new RenderBoat(this)); this.entityRenderMap.put(EntityFishHook.class, new RenderFish(this)); this.entityRenderMap.put(EntityAreaEffectCloud.class, new RenderAreaEffectCloud(this)); this.entityRenderMap.put(EntityHorse.class, new RenderHorse(this, new ModelHorse(), 0.75F)); this.entityRenderMap.put(EntityLightningBolt.class, new RenderLightningBolt(this)); this.playerRenderer = new RenderPlayer(this); this.skinMap.put("default", this.playerRenderer); this.skinMap.put("slim", new RenderPlayer(this, true)); net.minecraftforge.fml.client.registry.RenderingRegistry.loadEntityRenderers(this, this.entityRenderMap); }
@Override public Class<? extends EntityLivingBase> getEntityClass() { return EntityPolarBear.class; }
@SubscribeEvent public void onEntityLivingInteract(EntityInteract event) { if(event.getTarget() == null)return; EntityPlayer player = event.getEntityPlayer(); ItemStack held = event.getItemStack(); Entity entity = event.getTarget(); if(entity instanceof AbstractHorse){ AbstractHorse horse = (AbstractHorse)entity; if(HorseAccessories.handleHorseInteract(player, held, event.getHand(), horse)){ event.setCanceled(true); } } if(entity instanceof EntityWolf){ if(WolfAccessories.handleWolfInteract(player, held, event.getHand(), (EntityWolf)entity)){ event.setCanceled(true); } } if(entity instanceof EntityPolarBear){ EntityPolarBear bear = (EntityPolarBear)entity; if(ItemStackTools.isValid(held)){ if(held.getItem() == ModItems.miscFood && held.getMetadata() == FoodType.WHITE_FISH_RAW.getMetadata()){ if (!player.capabilities.isCreativeMode) { held.shrink(1); } if (!player.getEntityWorld().isRemote){ if (EntityUtil.rand.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(bear, player)) { EntityTamedPolarBear.convertToTamed(player.getEntityWorld(), bear, player); } } event.setCanceled(true); } } } if(entity instanceof EntityShulkerBullet){ if(ItemStackTools.isValid(held)){ if(held.getItem() == Item.getItemFromBlock(ModBlocks.jar)){ NBTTagCompound nbt = new NBTTagCompound(); if(held.hasTagCompound() && held.getTagCompound().hasKey(BlockJar.TILE_NBT_STACK)){ nbt = ItemNBTHelper.getCompound(held).getCompoundTag(BlockJar.TILE_NBT_STACK); } if((!nbt.hasKey("IsShulker") || !nbt.getBoolean("IsShulker")) && (!nbt.hasKey("Count") || nbt.getInteger("Count") <=0)){ nbt.setBoolean("IsShulker", true); if(ItemStackTools.getStackSize(held) == 1){ ItemNBTHelper.getCompound(held).setTag(BlockJar.TILE_NBT_STACK, nbt); } else { ItemStack newStack = ItemUtil.copy(held, 1); ItemNBTHelper.getCompound(newStack).setTag(BlockJar.TILE_NBT_STACK, nbt); player.setHeldItem(event.getHand(), ItemUtil.consumeItem(held)); if(!player.inventory.addItemStackToInventory(newStack)){ ItemUtil.dropFromPlayer(player, newStack, false); } } entity.setDead(); } } } } }
public static boolean isColdMob(EntityLivingBase e){ if(e instanceof EntitySnowman||e instanceof EntityPolarBear||(e instanceof EntitySkeleton&&((EntitySkeleton)e).getSkeletonType()==SkeletonType.STRAY)||isEndMob(e)){ return true; } return false; }
/** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityPolarBear entity) { return field_190090_a; }
@Override public Class helperForClass() { return EntityPolarBear.class; }