JuSTGh0sT1242 Posted November 29, 2023 Share Posted November 29, 2023 (edited) 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 November 29, 2023 by JuSTGh0sT1242 added code for context Quote Link to comment Share on other sites More sharing options...
JuSTGh0sT1242 Posted November 29, 2023 Author Share Posted November 29, 2023 So basically after spending sometime I fixed that by creating a new renderer for smoke zone. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.