Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.EntityHitResult;
Expand All @@ -23,6 +24,8 @@ public class EntityTossedItem extends ThrowableItemProjectile {

protected static final EntityDataAccessor<Boolean> DART = SynchedEntityData.defineId(EntityTossedItem.class, EntityDataSerializers.BOOLEAN);

protected static final Item DEFAULT_ITEM = Items.COBBLESTONE;

public EntityTossedItem(EntityType p_i50154_1_, Level p_i50154_2_) {
super(p_i50154_1_, p_i50154_2_);
}
Expand All @@ -47,6 +50,7 @@ public boolean isDart() {

public void setDart(boolean dart) {
this.entityData.set(DART, dart);
this.setItem(new ItemStack(getDartItem(dart)));
}

@OnlyIn(Dist.CLIENT)
Expand Down Expand Up @@ -124,6 +128,13 @@ protected void onHit(HitResult result) {
}

protected Item getDefaultItem() {
return isDart() ? AMItemRegistry.ANCIENT_DART.get() : Items.COBBLESTONE;
return Items.COBBLESTONE;
}

private static Item getDartItem(boolean dart) {
if (dart)
return AMItemRegistry.ANCIENT_DART.get();

return DEFAULT_ITEM;
}
}