数据system
本帖最后由 数据system 于 2020-10-16 23:25 编辑
  1. public EntityMagicBullet(World worldIn, EntityLivingBase throwerIn)
  2.     {
  3.         super(worldIn, throwerIn);
  4.         shoot((Entity)throwerIn, throwerIn.rotationPitch, throwerIn.rotationYaw, 0.0f, 1.5f, 1.0f);
  5.     }
复制代码
  1. protected float getVelocity()
  2.         {
  3.                 return 1.5F;
  4.         }
  5.         
  6.     protected float getGravityVelocity()
  7.     {
  8.         return 1.0F; //重力影响极小
  9.     }
  10.    
  11.     protected float getInaccuracy() {
  12.             return 1.0F;
  13.     }
复制代码

设置似乎对生成的实体也没有什么作用
使用shoot方法似乎实体一直都保持不动。
Forge1.12.2-14.23.5.2847

=赤刃=
本帖最后由 赤刃泉润CQR 于 2020-10-17 00:07 编辑

可以参考原版雪球的发射写法
  1.     public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
  2.     {
  3.         ItemStack itemstack = playerIn.getHeldItem(handIn);

  4.         if (!playerIn.capabilities.isCreativeMode)
  5.         {
  6.             itemstack.shrink(1);
  7.         }

  8.         worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

  9. if (!worldIn.isRemote)
  10.         {
  11.             EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
  12.             entitysnowball.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
  13.             worldIn.spawnEntity(entitysnowball);
  14.       }

  15.         playerIn.addStat(StatList.getObjectUseStats(this));
  16.         return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
  17.     }
复制代码
发射雪球实体的是这段(从上段中提取的)
  1. if (!worldIn.isRemote)
  2.         {
  3.             EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
  4.             entitysnowball.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
  5.             worldIn.spawnEntity(entitysnowball);
  6.       }
复制代码




第一页 上一页 下一页 最后一页