Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

cowsbeforeplows

Members
  • Joined

  • Last visited

  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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.