Skip to content

Commit

Permalink
move different crossbow arrows into arrow behaviors
Browse files Browse the repository at this point in the history
- craft special arrows with oils

now there are the following arrows:
- normal
- bleeding
- garlic
- spitfire
- teleport
- vampire killer
  • Loading branch information
Cheaterpaul committed Mar 16, 2024
1 parent 6bdf160 commit 8560eb4
Show file tree
Hide file tree
Showing 55 changed files with 1,351 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
import de.teamlapen.vampirism.api.VReference;
import de.teamlapen.vampirism.api.entity.factions.IFaction;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public interface IVampirismCrossbowArrow<T extends AbstractArrow & IEntityCrossbowArrow> extends IFactionExclusiveItem {

@Nullable
Expand All @@ -18,9 +24,59 @@ default IFaction<?> getExclusiveFaction(@NotNull ItemStack stack) {
return VReference.HUNTER_FACTION;
}

/**
* @return If an arrow of this type can be used in an infinite crossbow
*/
boolean isCanBeInfinite();

/**
* Called when the {@link IVampirismCrossbowArrow} hits a block
*
* @param arrow The itemstack of the shot arrow
* @param blockPos The position of the hit block
* @param arrowEntity The arrow entity
* @param shootingEntity The shooting entity. Can be the arrow entity itself
*/
void onHitBlock(ItemStack arrow, BlockPos blockPos, IEntityCrossbowArrow arrowEntity, @Nullable Entity shootingEntity);

default void onHitBlock(ItemStack arrow, BlockPos blockPos, IEntityCrossbowArrow arrowEntity, @Nullable Entity shootingEntity, Direction direction) {
onHitBlock(arrow, blockPos, arrowEntity, shootingEntity);
}

/**
* Called when the {@link IVampirismCrossbowArrow} hits an entity
*
* @param arrow The itemstack of the shot arrow
* @param entity The hit entity
* @param arrowEntity The arrow entity
* @param shootingEntity The shooting entity. Can be the arrow entity itself
*/
void onHitEntity(ItemStack arrow, LivingEntity entity, IEntityCrossbowArrow arrowEntity, Entity shootingEntity);

interface ICrossbowArrowBehavior {

int color();

default void onHitEntity(ItemStack arrow, LivingEntity entity, AbstractArrow arrowEntity, Entity shootingEntity) {

}

default void onHitBlock(ItemStack arrow, @NotNull BlockPos blockPos, AbstractArrow arrowEntity, @Nullable Entity shootingEntity, Direction up) {

}

void appendHoverText(ItemStack itemStack, @Nullable Level world, List<Component> textComponents, TooltipFlag tooltipFlag);

boolean canBeInfinite();

default AbstractArrow.Pickup pickupBehavior() {
return AbstractArrow.Pickup.CREATIVE_ONLY;
}

float baseDamage(@NotNull Level level, @NotNull ItemStack stack, @Nullable LivingEntity shooter);

default void modifyArrow(@NotNull Level level, @NotNull ItemStack stack, @Nullable LivingEntity shooter, @NotNull AbstractArrow arrow) {

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "vampirism:item/crossbow_arrow"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "vampirism:item/crossbow_arrow"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"has_the_recipe": {
"conditions": {
"recipe": "vampirism:crossbow_arrow_spitfire"
"recipe": "minecraft:bleeding_arrow_1"
},
"trigger": "minecraft:recipe_unlocked"
}
Expand All @@ -35,7 +35,7 @@
],
"rewards": {
"recipes": [
"vampirism:crossbow_arrow_spitfire"
"minecraft:bleeding_arrow_1"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,29 @@
},
"trigger": "minecraft:inventory_changed"
},
"has_garlic": {
"has_skill": {
"conditions": {
"items": [
{
"tag": "forge:crops/garlic"
}
]
"skill": "vampirism:weapon_table"
},
"trigger": "minecraft:inventory_changed"
"trigger": "vampirism:skill_unlocked"
},
"has_the_recipe": {
"conditions": {
"recipe": "vampirism:crossbow_arrow_vampire_killer"
"recipe": "minecraft:bleeding_arrow_2"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_garlic",
"has_skill",
"has_crossbow_arrow_normal"
]
],
"rewards": {
"recipes": [
"vampirism:crossbow_arrow_vampire_killer"
"minecraft:bleeding_arrow_2"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_crossbow_arrow_normal": {
"conditions": {
"items": [
{
"items": [
"vampirism:crossbow_arrow_normal"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_skill": {
"conditions": {
"skill": "vampirism:weapon_table"
},
"trigger": "vampirism:skill_unlocked"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:bleeding_arrow_3"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_skill",
"has_crossbow_arrow_normal"
]
],
"rewards": {
"recipes": [
"minecraft:bleeding_arrow_3"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_crossbow_arrow_normal": {
"conditions": {
"items": [
{
"items": [
"vampirism:crossbow_arrow_normal"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_skill": {
"conditions": {
"skill": "vampirism:weapon_table"
},
"trigger": "vampirism:skill_unlocked"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:garlic_arrow_1"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_skill",
"has_crossbow_arrow_normal"
]
],
"rewards": {
"recipes": [
"minecraft:garlic_arrow_1"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_crossbow_arrow_normal": {
"conditions": {
"items": [
{
"items": [
"vampirism:crossbow_arrow_normal"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_skill": {
"conditions": {
"skill": "vampirism:weapon_table"
},
"trigger": "vampirism:skill_unlocked"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:garlic_arrow_2"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_skill",
"has_crossbow_arrow_normal"
]
],
"rewards": {
"recipes": [
"minecraft:garlic_arrow_2"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_crossbow_arrow_normal": {
"conditions": {
"items": [
{
"items": [
"vampirism:crossbow_arrow_normal"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_skill": {
"conditions": {
"skill": "vampirism:weapon_table"
},
"trigger": "vampirism:skill_unlocked"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:garlic_arrow_3"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_skill",
"has_crossbow_arrow_normal"
]
],
"rewards": {
"recipes": [
"minecraft:garlic_arrow_3"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_crossbow_arrow_normal": {
"conditions": {
"items": [
{
"items": [
"vampirism:crossbow_arrow_normal"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_skill": {
"conditions": {
"skill": "vampirism:weapon_table"
},
"trigger": "vampirism:skill_unlocked"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:spitfire_arrow_1"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_skill",
"has_crossbow_arrow_normal"
]
],
"rewards": {
"recipes": [
"minecraft:spitfire_arrow_1"
]
}
}
Loading

0 comments on commit 8560eb4

Please sign in to comment.