Jump to content

[1.16.5] Arrow rendering but not showing any type of movement or collision when shooted with a bow


Recommended Posts

Posted

my arrow wont move at all it would stay mid air and show no collision

 

my Entity class:

package net.jeezedboi.epicraft.entity.custom;


import net.jeezedboi.epicraft.init.ModItems;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.IPacket;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;

public class ExplosiveArrowEntity extends AbstractArrowEntity {
    // default constructor, required to register the entity
    public ExplosiveArrowEntity(EntityType<ExplosiveArrowEntity> entityType, World world) {
        super(entityType, world);
    }

    public ExplosiveArrowEntity(EntityType<ExplosiveArrowEntity> entityType, double x, double y, double z, World world) {
        super(entityType, x, y, z, world);
    }

    // the constructor used by the ArrowItem
    public ExplosiveArrowEntity(EntityType<ExplosiveArrowEntity> entityType, LivingEntity shooter, World world) {
        super(entityType, shooter, world);
    }

    // the item stack to give the player when they walk over your arrow stuck in the ground

    @Override
    protected ItemStack getArrowStack() {
        return new ItemStack(ModItems.EXPLOSIVE_ARROW.get());
    }
    @Override

    protected void onEntityHit(EntityRayTraceResult result) {
        super.onEntityHit(result);
        // this, x, y, z, explosionStrength, setsFires, breakMode (NONE, BREAK, DESTROY)
        this.world.createExplosion(this, this.getPosX(), this.getPosY(), this.getPosZ(), 4.0f, true, Explosion.Mode.BREAK);
    }

    // called each tick while in the ground
    @Override
    public void tick() {
        if (this.timeInGround > 60){
            this.world.createExplosion(this, this.getPosX(), this.getPosY(), this.getPosZ(), 4.0f, true, Explosion.Mode.BREAK);
            this.remove();
        }
    }

    // syncs to the client
    @Override
    public IPacket<?> createSpawnPacket() {
        return NetworkHooks.getEntitySpawningPacket(this);
    }
}

my item class:

package net.jeezedboi.epicraft.item.custom;

import net.jeezedboi.epicraft.entity.custom.ExplosiveArrowEntity;
import net.jeezedboi.epicraft.init.ModEntityTypes;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.item.ArrowItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ExplosiveArrowItem extends ArrowItem {
    public ExplosiveArrowItem(Properties props) {
        super(props);
    }

    @Override
    public AbstractArrowEntity createArrow(World world, ItemStack ammoStack, LivingEntity shooter) {
        ExplosiveArrowEntity explosiveArrowEntity = new ExplosiveArrowEntity(ModEntityTypes.EXPLOSIVE_ARROW.get(), shooter, world);
        return explosiveArrowEntity;
    }
}

other stuffs:

public static final RegistryObject<Item> EXPLOSIVE_ARROW = ITEMS.register("explosive_arrow",
            () -> new ExplosiveArrowItem(new Item.Properties().group(ModItemGroup.Epic_Items)));
public static final RegistryObject<Item> EXPLOSIVE_ARROW = ITEMS.register("explosive_arrow",
            () -> new ExplosiveArrowItem(new Item.Properties().group(ModItemGroup.Epic_Items)));

pls tell me where i  am wrong

mappings channel: 'snapshot', version: '20210309-1.16.5'

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.