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

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 :D 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 by Adil Yilan

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.