Adil Yilan Posted February 21, 2022 Share Posted February 21, 2022 (edited) I have implemented RpgLauncherItem that launches RpgEntity. This is how it works at the moment: https://vimeo.com/user167486120/review/680142871/22206a0362 I have modeled RPG and RPG launcher in BlockBench and imported them as JSON assets in mod. RpgEntity is using GeckoLib for animation, although there is none at the moment. There are 4 issues on the video above: a) RPG is launched from the feet instead from the eye point - what would be the proper way to set shooting point? b) When launcher is used, it looks as if it is trying to hit the ground - can this animation be disabled? c) Sometimes, RPG goes in totally different direction than the crosshair is targeting - is this related to client/server communication and can that be improved? d) As you can see in the video, RPG is spinning while moving - I have no clue why - haven't added that as an animation any way to prevent this from happening? This is RpgEntity code: public class RpgEntity extends AbstractHurtingProjectile implements IAnimatable { // GeckoLib private final AnimationFactory factory = new AnimationFactory(this); public RpgEntity(EntityType<RpgEntity> entityType, Level level) { super(entityType, level); } public RpgEntity(EntityType<RpgEntity> entityType, LivingEntity player, Level level) { super(entityType, player, player.getViewVector(100).x(), player.getViewVector(100).y(), player.getViewVector(100).z(), level); } public static EntityType<RpgEntity> createType() { Builder<RpgEntity> builder = Builder.of((EntityType.EntityFactory<RpgEntity>)RpgEntity::new, MobCategory.MISC); builder.sized(0.5F, 0.5F); builder.clientTrackingRange(4); builder.updateInterval(20); EntityType<RpgEntity> entityType = builder.build("rpg"); return entityType; } @Override protected void onHitEntity(EntityHitResult pResult) { super.onHitEntity(pResult); this.level.explode(this, this.getX(), this.getY(), this.getZ(), 5.0f, false, BlockInteraction.BREAK); this.discard(); } @Override protected void onHitBlock(BlockHitResult pResult) { super.onHitBlock(pResult); this.level.explode(this, this.getX(), this.getY(), this.getZ(), 5.0f, false, BlockInteraction.BREAK); this.discard(); } @Override public Packet<?> getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override public void registerControllers(AnimationData data) { data.addAnimationController(new AnimationController<RpgEntity>(this, "controller", 0, this::predicate)); } // GeckoLib @Override public AnimationFactory getFactory() { return this.factory; } // GeckoLib private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) { return PlayState.CONTINUE; } } This is RpgLauncherItem code: public class RpgLauncherItem extends Item { public RpgLauncherItem() { super(createProperties()); } private static Properties createProperties() { Properties properties = new Properties(); properties.tab(CreativeModeTab.TAB_COMBAT); properties.stacksTo(1); return properties; } @Override public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) { ItemStack item = pPlayer.getItemInHand(pUsedHand); if (pLevel.isClientSide()) { return InteractionResultHolder.sidedSuccess(item, true); } RpgEntity rpg = new RpgEntity(ProjectileEntities.RPG.get(), pPlayer, pLevel); pPlayer.level.addFreshEntity(rpg); return InteractionResultHolder.sidedSuccess(item, true); } } Any suggestions on how issues above could be resolved would be really appreciated. I am new to all this and getting rocket to fire properly was already a challenge. Edited February 21, 2022 by Adil Yilan 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.