Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Un-hardcode multiple canFireProjectile methods #1681

Open
wants to merge 3 commits into
base: 1.21.x
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -24,3 +24,12 @@
double d0 = p_32141_.getX() - this.getX();
double d1 = p_32141_.getY(0.3333333333333333) - abstractarrow.getY();
double d2 = p_32141_.getZ() - this.getZ();
@@ -208,7 +_,7 @@

@Override
public boolean canFireProjectileWeapon(ProjectileWeaponItem p_32144_) {
- return p_32144_ == Items.BOW;
+ return p_32144_.builtInRegistryHolder().is(net.neoforged.neoforge.common.Tags.Items.SKELETON_USABLE_BOWS);
}

@Override
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
--- a/net/minecraft/world/entity/monster/Pillager.java
+++ b/net/minecraft/world/entity/monster/Pillager.java
@@ -92,7 +_,7 @@

@Override
public boolean canFireProjectileWeapon(ProjectileWeaponItem p_33280_) {
- return p_33280_ == Items.CROSSBOW;
+ return p_33280_.builtInRegistryHolder().is(net.neoforged.neoforge.common.Tags.Items.PILLAGER_USABLE_CROSSBOWS);
}

public boolean isChargingCrossbow() {
@@ -119,7 +_,7 @@
public AbstractIllager.IllagerArmPose getArmPose() {
if (this.isChargingCrossbow()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
}
}

@@ -384,7 +_,7 @@

@Override
public boolean canFireProjectileWeapon(ProjectileWeaponItem p_34715_) {
- return p_34715_ == Items.CROSSBOW;
+ return p_34715_.builtInRegistryHolder().is(net.neoforged.neoforge.common.Tags.Items.PIGLIN_USABLE_CROSSBOWS);
}

protected void holdInMainHand(ItemStack p_34784_) {
@@ -392,7 +_,7 @@
}

Expand Down
3 changes: 3 additions & 0 deletions src/generated/resources/assets/c/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@
"tag.item.c.tools.spear": "Spears",
"tag.item.c.villager_job_sites": "Villager Job Sites",
"tag.item.neoforge.enchanting_fuels": "Enchanting Fuels",
"tag.item.neoforge.piglin_usable_crossbows": "Piglin Usable Crossbows",
"tag.item.neoforge.pillager_usable_crossbows": "Pillager Usable Crossbows",
"tag.item.neoforge.skeleton_usable_bows": "Skeleton Usable Bows",
"tag.worldgen.biome.c.hidden_from_locator_selection": "Hidden From Locator's Selection",
"tag.worldgen.biome.c.is_aquatic": "Aquatic",
"tag.worldgen.biome.c.is_aquatic_icy": "Aquatic Icy",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"#c:tools/crossbow"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"#c:tools/crossbow"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"#c:tools/bow"
]
}
15 changes: 15 additions & 0 deletions src/main/java/net/neoforged/neoforge/common/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,21 @@ public static class Items {
* This tag defaults to {@link net.minecraft.world.item.Items#LAPIS_LAZULI} when not present in any datapacks, including forge client on vanilla server
*/
public static final TagKey<Item> ENCHANTING_FUELS = neoforgeTag("enchanting_fuels");
/**
* Controls what items Piglins can use as default as a valid crossbow
* This tag defaults to {@link net.minecraft.world.item.Items#CROSSBOW} when not present in any datapacks, including forge client on vanilla server
*/
public static final TagKey<Item> PIGLIN_USABLE_CROSSBOWS = neoforgeTag("piglin_usable_crossbows");
/**
* Controls what items Pillagers can use as default as a valid crossbow
* This tag defaults to {@link net.minecraft.world.item.Items#CROSSBOW} when not present in any datapacks, including forge client on vanilla server
*/
public static final TagKey<Item> PILLAGER_USABLE_CROSSBOWS = neoforgeTag("pillager_usable_crossbows");
/**
* Controls what items Skeletons can use as default as a valid bow
* This tag defaults to {@link net.minecraft.world.item.Items#BOW} when not present in any datapacks, including forge client on vanilla server
*/
public static final TagKey<Item> SKELETON_USABLE_BOWS = neoforgeTag("skeleton_usable_bows");

// `c` tags for common conventions
public static final TagKey<Item> BARRELS = tag("barrels");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public void addTags(HolderLookup.Provider lookupProvider) {
copy(Tags.Blocks.ORES_IN_GROUND_DEEPSLATE, Tags.Items.ORES_IN_GROUND_DEEPSLATE);
copy(Tags.Blocks.ORES_IN_GROUND_NETHERRACK, Tags.Items.ORES_IN_GROUND_NETHERRACK);
copy(Tags.Blocks.ORES_IN_GROUND_STONE, Tags.Items.ORES_IN_GROUND_STONE);
tag(Tags.Items.PIGLIN_USABLE_CROSSBOWS).addTag(Tags.Items.TOOLS_CROSSBOW);
tag(Tags.Items.PILLAGER_USABLE_CROSSBOWS).addTags(Tags.Items.TOOLS_CROSSBOW);
copy(Tags.Blocks.PLAYER_WORKSTATIONS_CRAFTING_TABLES, Tags.Items.PLAYER_WORKSTATIONS_CRAFTING_TABLES);
copy(Tags.Blocks.PLAYER_WORKSTATIONS_FURNACES, Tags.Items.PLAYER_WORKSTATIONS_FURNACES);
tag(Tags.Items.RAW_MATERIALS).addTags(Tags.Items.RAW_MATERIALS_COPPER, Tags.Items.RAW_MATERIALS_GOLD, Tags.Items.RAW_MATERIALS_IRON);
Expand Down Expand Up @@ -222,6 +224,7 @@ public void addTags(HolderLookup.Provider lookupProvider) {
tag(Tags.Items.SEEDS_MELON).add(Items.MELON_SEEDS);
tag(Tags.Items.SEEDS_PUMPKIN).add(Items.PUMPKIN_SEEDS);
tag(Tags.Items.SEEDS_WHEAT).add(Items.WHEAT_SEEDS);
tag(Tags.Items.SKELETON_USABLE_BOWS).addTag(Tags.Items.TOOLS_BOW);
tag(Tags.Items.SLIMEBALLS).add(Items.SLIME_BALL); // Deprecated
tag(Tags.Items.SLIME_BALLS).add(Items.SLIME_BALL).addOptionalTag(Tags.Items.SLIMEBALLS);
tag(Tags.Items.SHULKER_BOXES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ protected void addTranslations() {
add(Tags.Items.ORES_IN_GROUND_DEEPSLATE, "Deepslate Ores In Ground");
add(Tags.Items.ORES_IN_GROUND_NETHERRACK, "Netherrack Ores In Ground");
add(Tags.Items.ORES_IN_GROUND_STONE, "Stone Ores In Ground");
add(Tags.Items.PIGLIN_USABLE_CROSSBOWS, "Piglin Usable Crossbows");
add(Tags.Items.PILLAGER_USABLE_CROSSBOWS, "Pillager Usable Crossbows");
add(Tags.Items.PLAYER_WORKSTATIONS_CRAFTING_TABLES, "Crafting Tables");
add(Tags.Items.PLAYER_WORKSTATIONS_FURNACES, "Furnaces");
add(Tags.Items.RAW_MATERIALS, "Raw Materials");
Expand Down Expand Up @@ -302,6 +304,7 @@ protected void addTranslations() {
add(Tags.Items.SEEDS_MELON, "Melon Seeds");
add(Tags.Items.SEEDS_PUMPKIN, "Pumpkin Seeds");
add(Tags.Items.SEEDS_WHEAT, "Wheat Seeds");
add(Tags.Items.SKELETON_USABLE_BOWS, "Skeleton Usable Bows");
add(Tags.Items.SHULKER_BOXES, "Shulker Boxes");
add(Tags.Items.SLIME_BALLS, "Slimeballs");
add(Tags.Items.SLIMEBALLS, "Slimeballs");
Expand Down