Jump to content

cowsbeforeplows

Members
  • Posts

    1
  • Joined

  • Last visited

cowsbeforeplows's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hey all, I'm having trouble with my ProjectileItemEntity that is loosely based off of the Vanilla Snowball. The entity itself is registered and rendered, as I can /summon it while in game, but throwing it seems like it creates a ghost entity. The entity does not appear but can be /kill'ed. Does anyone see the issue? Item public class SatchelCharge extends Item{ public SatchelCharge(Properties properties) { super(properties); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); worldIn.playSound((PlayerEntity)null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); playerIn.getCooldownTracker().setCooldown(this, 20); if (!worldIn.isRemote) { SatchelChargeEntity satchelChargeEntity = new SatchelChargeEntity(worldIn, playerIn); satchelChargeEntity.setItem(itemstack); satchelChargeEntity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 1.0F, 0.25F, 1.0F); worldIn.addEntity(satchelChargeEntity); DeepBlockGalactic.LOGGER.debug("Satchel Charge has been Spawned!"); } playerIn.addStat(Stats.ITEM_USED.get(this)); if (!playerIn.abilities.isCreativeMode) { itemstack.shrink(1); } return ActionResult.resultSuccess(itemstack); } } Entity public class SatchelChargeEntity extends ProjectileItemEntity { public SatchelChargeEntity(EntityType<? extends ProjectileItemEntity> type, World worldIn) { super(type, worldIn); } public SatchelChargeEntity(World worldIn, PlayerEntity playerIn) { super(ModEntityTypes.SATCHEL_CHARGE_ENTITY.get(), worldIn); } public SatchelChargeEntity(World worldIn, double x, double y, double z) { super(ModEntityTypes.SATCHEL_CHARGE_ENTITY.get(), x, y, z, worldIn); } @OnlyIn(Dist.CLIENT) public void handleStatusUpdate(byte id) { if (this.world.isRemote()) { if (id == 3) { IParticleData iparticledata = this.makeParticle(); for(int i = 0; i < 8; ++i) { this.world.addParticle(iparticledata, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D, 0.0D); } } } } @OnlyIn(Dist.CLIENT) private IParticleData makeParticle() { ItemStack itemstack = this.func_213882_k(); return (IParticleData)(itemstack.isEmpty() ? ParticleTypes.ITEM_SNOWBALL : new ItemParticleData(ParticleTypes.ITEM, itemstack)); } @Override protected void onImpact(RayTraceResult result) { if (result.getType() == RayTraceResult.Type.BLOCK){ this.setVelocity(0, 0, 0); } } @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } public void explode() { float f = 7.0F; this.world.createExplosion(this, this.getPosX(), this.getPosYHeight(0.0625D), this.getPosZ(), f, Explosion.Mode.BREAK); this.remove(); } protected Item getDefaultItem() { return ItemInit.SATCHEL_CHARGE.get(); } } Github Link
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.