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.

Featured Replies

Posted

So basically, I trying to create a "Smoke Bomb", and for that I made Item that throwing a smoke bomb projectile, and after smoke bomb projectile is hit block, it should create entity "smoke zone" but instead of that I got immediately crashed. I can't even make a renderer for this entity in mod class, it give an error, and I honestly don't know WHERE and WHY.

public class SmokeBombEntity extends ThrowableItemProjectile {
    public  SmokeBombEntity(EntityType<? extends ThrowableItemProjectile> pEntityType, Level pLevel) {

        super(pEntityType, pLevel);
    }
public  SmokeBombEntity(Level pLevel) {
        super(ModEntities.SMOKE_BOMB_PROJECTILE.get(), pLevel);
    }
public  SmokeBombEntity(Level pLevel, LivingEntity livingEntity) {
        super(ModEntities.SMOKE_BOMB_PROJECTILE.get(), livingEntity, pLevel);
    }
    @Override
    protected Item getDefaultItem() {
        return ModItems.SMOKE_BOMB.get();
    }

    @Override
    protected void onHitBlock(BlockHitResult pResult) {
        if(!this.level.isClientSide) {
            SmokeZoneEntity smokeZone = new SmokeZoneEntity(ModEntities.SMOKE_ZONE_ENTITY.get(), level);
            smokeZone.setPos(getBlockX(),getBlockY(),getBlockZ());
            this.level.addFreshEntity(smokeZone);
        }
        level.playSound((Player) null, getBlockX(), getBlockY(), getBlockZ(), SoundEvents.GLASS_BREAK, SoundSource.NEUTRAL, 0.5F, 0.4F);
        this.discard();
        super.onHitBlock(pResult);
    }
}
public class SmokeZoneEntity extends Entity {
    public SmokeZoneEntity(EntityType<?> pEntityType, Level pLevel) {
        super(pEntityType, pLevel);
        this.noPhysics = true;
    }
    public SmokeZoneEntity(Level pLevel, double pX, double pY, double pZ) {
        this(ModEntities.SMOKE_ZONE_ENTITY.get(), pLevel);
        this.setPos(pX, pY, pZ);
    }
    public  SmokeZoneEntity(Level pLevel) {
        super(ModEntities.SMOKE_ZONE_ENTITY.get(), pLevel);
    }



    protected void defineSynchedData() {}
    protected void readAdditionalSaveData(CompoundTag pCompound) {}
    protected void addAdditionalSaveData(CompoundTag pCompound) {

    }
    public Packet<?> getAddEntityPacket() {
        return new ClientboundAddEntityPacket(this);
    }
}

Also I can't render a smoke zone entity in a mod class, but smoke bomb projectile works completely fine

 @SubscribeEvent
        public static void onClientSetup(FMLClientSetupEvent event) {

            EntityRenderers.register(ModEntities.SMOKE_BOMB_PROJECTILE.get(), ThrownItemRenderer::new);
          //HERE AN ISSUE  EntityRenderers.register(ModEntities.SMOKE_ZONE_ENTITY.get(), EntityRenderer::new);

        }
    }
}

GitHub repository
 

Edited by JuSTGh0sT1242
added code for context

  • JuSTGh0sT1242 changed the title to [1.19.2]Crash on creating entity

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.