[2020.2](2 of 3 common questions resolved)need help with ranged weapons

Started by _Zatsu_ on

Topic category: Help with modding (Java Edition)

Last seen on 02:37, 20. Mar 2024
Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[2020.2](2 of 3 common questions resolved)need help with ranged weapons
Sun, 02/25/2024 - 21:13 (edited)

Hello! i am kinda new to the modding scene, therefore theres much i have no knowledge about

currently i am having problems making ranged weapons, those being:
weapons have no cooldown.
bullets are affected by gravity.
no idea how to have weapons have a "charged shot" mode, or if it is even possible.

i am making a mod for 1.12.2, with MCcreator version 2020.2, if someone can give me a easy to understand guide in how to solve the problems above, it would be much apreciated.
 

Edited by _Zatsu_ on Sun, 02/25/2024 - 21:13
Last seen on 02:37, 20. Mar 2024
Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i alreadly was able to input…
Sun, 02/25/2024 - 20:48

i alreadly was able to input cooldown in weapons, that being, enabling the "shoot constantly" and then using the procedure"cooldown current entity for (number) ticks provided by entity" in the item procedures tab

but aside from that little improv i still need to learn about the other 2, im currently trying to find a way to make my bullets gravity less

 

and i think its in this line of code:
    @Override
        public void onUsingTick(ItemStack itemstack, EntityLivingBase entityLivingBase, int count) {
            World world = entityLivingBase.world;
            if (!world.isRemote && entityLivingBase instanceof EntityPlayerMP) {
                EntityPlayerMP entity = (EntityPlayerMP) entityLivingBase;
                float power = 2f;
                EntityArrowCustom entityarrow = new EntityArrowCustom(world, entity);
                entityarrow.shoot(entity.getLookVec().x, entity.getLookVec().y, entity.getLookVec().z, power * 2, 0);
                entityarrow.setSilent(true);
                entityarrow.setIsCritical(false);
                entityarrow.setDamage(12);
                entityarrow.setKnockbackStrength(1);
                itemstack.damageItem(1, entity); 

perhaps its float power, but i am not sure on what to change it to

Last seen on 02:37, 20. Mar 2024
Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i have found a way to make…
Sun, 02/25/2024 - 21:15

i have found a way to make your bullets not be influenced by gravity thanks to the guy who posted last in:
https://mcreator.net/forum/74710/toggle-gravity-ranged-item-creation

you need to manually add:
entityarrow.setNoGravity(true);

after this your code should look like this:
@Override
        public void onUsingTick(ItemStack itemstack, EntityLivingBase entityLivingBase, int count) {
            World world = entityLivingBase.world;
            if (!world.isRemote && entityLivingBase instanceof EntityPlayerMP) {
                EntityPlayerMP entity = (EntityPlayerMP) entityLivingBase;
                float power = 1f;
                EntityArrowCustom entityarrow = new EntityArrowCustom(world, entity);
                entityarrow.shoot(entity.getLookVec().x, entity.getLookVec().y, entity.getLookVec().z, power * 2, 0);
                entityarrow.setNoGravity(true);
                entityarrow.setSilent(true);
                entityarrow.setIsCritical(false);
                entityarrow.setDamage(12);
                entityarrow.setKnockbackStrength(1);
                itemstack.damageItem(1, entity);