Skip to content

Commit

Permalink
Merge branch '1.21.1' into material_atlas
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD authored Oct 23, 2024
2 parents 4602f7c + 718fd71 commit d04f420
Show file tree
Hide file tree
Showing 22 changed files with 206 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ jobs:
run: ./gradlew assemble checkFormatting

- name: Run JCC
if: ${{ ! startsWith(github.event.pull_request.head.ref, 'refs/heads/port/') }}
run: ./gradlew checkJarCompatibility

- name: Upload JCC
if: ${{ ! startsWith(github.event.pull_request.head.ref, 'refs/heads/port/') }}
uses: neoforged/action-jar-compatibility/upload@v1

- name: Publish artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-jcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
publish-jcc:
if: true
if: ${{ ! startsWith(github.event.workflow_run.head_branch, 'port/') }}
uses: neoforged/actions/.github/workflows/publish-jcc.yml@main
with:
beta_version_pattern: .*-beta.*
Expand Down
21 changes: 11 additions & 10 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ Contributing to NeoForge
1. Have preliminary discussions on Discord (`#neoforge-github`)
2. Fork the repository
3. Check out your fork
4. Make a branch
5. Run `gradlew setup` from the project root to decompile sources and apply current patches
6. Import project into your IDE (IntelliJ/Eclipse) or Reload Gradle Project
7. Modify the patched Minecraft sources in `projects/neoforge/src/main/java` as needed. The unmodified sources are available in `projects/base/src/main/java` for your reference. Do not modify these.
8. Test your changes
4. Fetch tags from the upstream repository by running `git remote add upstream https://github.com/neoforged/NeoForge.git` followed by `git fetch upstream --tags`
5. Make a branch
6. Run `gradlew setup` from the project root to decompile sources and apply current patches
7. Import project into your IDE (IntelliJ/Eclipse) or Reload Gradle Project
8. Modify the patched Minecraft sources in `projects/neoforge/src/main/java` as needed. The unmodified sources are available in `projects/base/src/main/java` for your reference. Do not modify these.
9. Test your changes
- Run the game (Runs are available in the IDE)
- Run `gradlew :tests:runGameTestServer` or `Tests: GameTestServer` from IDE
- Run `gradlew :tests:runGameTestClient` or `Tests: GameTestClient` from IDE
- If possible, write an automated test under the tests project. See [NEOGAMETESTS.md](NEOGAMETESTS.md) for more info.
9. Run `gradlew unpackSourcePatches` to generate patch-files from the patched sources
10. Run `gradlew applyAllFormatting` to automatically format sources
11. Check correct formatting with `gradlew spotlessCheck`
12. Commit & Push
13. Make PR
10. Run `gradlew unpackSourcePatches` to generate patch-files from the patched sources
11. Run `gradlew applyAllFormatting` to automatically format sources
12. Check correct formatting with `gradlew spotlessCheck`
13. Commit & Push
14. Make PR

## Porting

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jetbrains_annotations_version=24.0.1
slf4j_api_version=2.0.7
apache_maven_artifact_version=3.8.5
jarjar_version=0.4.1
fancy_mod_loader_version=4.0.24
fancy_mod_loader_version=4.0.29
mojang_logging_version=1.1.1
log4j_version=2.22.1
guava_version=31.1.2-jre
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@
public boolean canEnchant(ItemStack p_44689_) {
return this.definition.supportedItems().contains(p_44689_.getItemHolder());
}
@@ -503,6 +_,15 @@
public static Enchantment.Builder enchantment(Enchantment.EnchantmentDefinition p_345873_) {
@@ -504,12 +_,26 @@
return new Enchantment.Builder(p_345873_);
}
+
+// TODO: Reimplement. Not sure if we want to patch EnchantmentDefinition or hack this in as an EnchantmentEffectComponent.
+// /**
+// * Is this enchantment allowed to be enchanted on books via Enchantment Table
Expand All @@ -56,6 +55,46 @@
+// public boolean isAllowedOnBooks() {
+// return true;
+// }
+
public static class Builder {
private final Enchantment.EnchantmentDefinition definition;
private HolderSet<Enchantment> exclusiveSet = HolderSet.direct();
private final Map<DataComponentType<?>, List<?>> effectLists = new HashMap<>();
private final DataComponentMap.Builder effectMapBuilder = DataComponentMap.builder();

+ /**
+ * Neo: Allow customizing or changing the {@link Component} created by the enchantment builder.
+ */
+ protected java.util.function.UnaryOperator<MutableComponent> nameFactory = java.util.function.UnaryOperator.identity();
+
public Builder(Enchantment.EnchantmentDefinition p_345317_) {
this.definition = p_345317_;
}
@@ -562,6 +_,16 @@
return this;
}

+ /**
+ * Allows specifying an operator that can customize the default {@link Component} created by {@link #build(ResourceLocation)}.
+ *
+ * @return this
+ */
+ public Enchantment.Builder withCustomName(java.util.function.UnaryOperator<MutableComponent> nameFactory) {
+ this.nameFactory = nameFactory;
+ return this;
+ }
+
private <E> List<E> getEffectsList(DataComponentType<List<E>> p_344770_) {
return (List<E>)this.effectLists.computeIfAbsent(p_344770_, p_346247_ -> {
ArrayList<E> arraylist = new ArrayList<>();
@@ -572,7 +_,9 @@

public Enchantment build(ResourceLocation p_344988_) {
return new Enchantment(
- Component.translatable(Util.makeDescriptionId("enchantment", p_344988_)), this.definition, this.exclusiveSet, this.effectMapBuilder.build()
+ // Neo: permit custom name components instead of a single hardcoded translatable component.
+ this.nameFactory.apply(Component.translatable(Util.makeDescriptionId("enchantment", p_344988_))),
+ this.definition, this.exclusiveSet, this.effectMapBuilder.build()
);
}
}
5 changes: 5 additions & 0 deletions src/generated/resources/assets/c/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@
"tag.block.c.storage_blocks.redstone": "Redstone Storage Blocks",
"tag.block.c.storage_blocks.slime": "Slime Storage Blocks",
"tag.block.c.storage_blocks.wheat": "Wheat Storage Blocks",
"tag.block.c.stripped_logs": "Stripped Logs",
"tag.block.c.stripped_woods": "Stripped Woods",
"tag.block.c.villager_job_sites": "Villager Job Sites",
"tag.block.neoforge.enderman_place_on_blacklist": "Enderman Place On Blacklist",
"tag.block.neoforge.needs_gold_tool": "Needs Gold Tools",
Expand All @@ -128,6 +130,7 @@
"tag.entity_type.c.minecarts": "Minecarts",
"tag.entity_type.c.teleporting_not_supported": "Teleporting Not Supported",
"tag.fluid.c.beetroot_soup": "Beetroot Soup",
"tag.fluid.c.experience": "Experience",
"tag.fluid.c.gaseous": "Gaseous",
"tag.fluid.c.hidden_from_recipe_viewers": "Hidden From Recipe Viewers",
"tag.fluid.c.honey": "Honey",
Expand Down Expand Up @@ -347,6 +350,8 @@
"tag.item.c.storage_blocks.slime": "Slime Storage Blocks",
"tag.item.c.storage_blocks.wheat": "Wheat Storage Blocks",
"tag.item.c.strings": "Strings",
"tag.item.c.stripped_logs": "Stripped Log Blocks",
"tag.item.c.stripped_woods": "Stripped Wood Blocks",
"tag.item.c.tools": "Tools",
"tag.item.c.tools.bow": "Bows",
"tag.item.c.tools.brush": "Brushes",
Expand Down
13 changes: 13 additions & 0 deletions src/generated/resources/data/c/tags/block/stripped_logs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"values": [
"minecraft:stripped_acacia_log",
"minecraft:stripped_bamboo_block",
"minecraft:stripped_birch_log",
"minecraft:stripped_cherry_log",
"minecraft:stripped_dark_oak_log",
"minecraft:stripped_jungle_log",
"minecraft:stripped_mangrove_log",
"minecraft:stripped_oak_log",
"minecraft:stripped_spruce_log"
]
}
12 changes: 12 additions & 0 deletions src/generated/resources/data/c/tags/block/stripped_woods.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"values": [
"minecraft:stripped_acacia_wood",
"minecraft:stripped_birch_wood",
"minecraft:stripped_cherry_wood",
"minecraft:stripped_dark_oak_wood",
"minecraft:stripped_jungle_wood",
"minecraft:stripped_mangrove_wood",
"minecraft:stripped_oak_wood",
"minecraft:stripped_spruce_wood"
]
}
3 changes: 3 additions & 0 deletions src/generated/resources/data/c/tags/fluid/experience.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"values": []
}
13 changes: 13 additions & 0 deletions src/generated/resources/data/c/tags/item/stripped_logs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"values": [
"minecraft:stripped_acacia_log",
"minecraft:stripped_bamboo_block",
"minecraft:stripped_birch_log",
"minecraft:stripped_cherry_log",
"minecraft:stripped_dark_oak_log",
"minecraft:stripped_jungle_log",
"minecraft:stripped_mangrove_log",
"minecraft:stripped_oak_log",
"minecraft:stripped_spruce_log"
]
}
12 changes: 12 additions & 0 deletions src/generated/resources/data/c/tags/item/stripped_woods.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"values": [
"minecraft:stripped_acacia_wood",
"minecraft:stripped_birch_wood",
"minecraft:stripped_cherry_wood",
"minecraft:stripped_dark_oak_wood",
"minecraft:stripped_jungle_wood",
"minecraft:stripped_mangrove_wood",
"minecraft:stripped_oak_wood",
"minecraft:stripped_spruce_wood"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.neoforged.neoforge.common.data.ExistingFileHelper;

/**
Expand All @@ -31,6 +32,33 @@ public ItemModelBuilder basicItem(ResourceLocation item) {
.texture("layer0", ResourceLocation.fromNamespaceAndPath(item.getNamespace(), "item/" + item.getPath()));
}

public ItemModelBuilder handheldItem(Item item) {
return handheldItem(Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(item)));
}

public ItemModelBuilder handheldItem(ResourceLocation item) {
return getBuilder(item.toString())
.parent(new ModelFile.UncheckedModelFile("item/handheld"))
.texture("layer0", ResourceLocation.fromNamespaceAndPath(item.getNamespace(), "item/" + item.getPath()));
}

public ItemModelBuilder spawnEggItem(Item item) {
return spawnEggItem(Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(item)));
}

public ItemModelBuilder spawnEggItem(ResourceLocation item) {
return getBuilder(item.toString())
.parent(new ModelFile.UncheckedModelFile("item/template_spawn_egg"));
}

public ItemModelBuilder simpleBlockItem(Block block) {
return simpleBlockItem(Objects.requireNonNull(BuiltInRegistries.BLOCK.getKey(block)));
}

public ItemModelBuilder simpleBlockItem(ResourceLocation block) {
return withExistingParent(block.toString(), ResourceLocation.fromNamespaceAndPath(block.getNamespace(), "block/" + block.getPath()));
}

@Override
public String getName() {
return "Item Models: " + modid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ public enum LogWarningMode {
createForgeMapEntry(Registries.FLUID, "milk", Tags.Fluids.MILK),
createForgeMapEntry(Registries.FLUID, "gaseous", Tags.Fluids.GASEOUS),
createForgeMapEntry(Registries.FLUID, "honey", Tags.Fluids.HONEY),
createForgeMapEntry(Registries.FLUID, "xp", Tags.Fluids.EXPERIENCE),
createForgeMapEntry(Registries.FLUID, "experience", Tags.Fluids.EXPERIENCE),
createForgeMapEntry(Registries.FLUID, "potion", Tags.Fluids.POTION),
createForgeMapEntry(Registries.FLUID, "plantoil", "plant_oil"),

Expand Down
34 changes: 25 additions & 9 deletions src/main/java/net/neoforged/neoforge/common/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ public static class Blocks {
public static final TagKey<Block> STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone");
public static final TagKey<Block> STORAGE_BLOCKS_SLIME = tag("storage_blocks/slime");
public static final TagKey<Block> STORAGE_BLOCKS_WHEAT = tag("storage_blocks/wheat");
public static final TagKey<Block> STRIPPED_LOGS = tag("stripped_logs");
public static final TagKey<Block> STRIPPED_WOODS = tag("stripped_woods");
public static final TagKey<Block> VILLAGER_JOB_SITES = tag("villager_job_sites");

/**
Expand Down Expand Up @@ -627,6 +629,8 @@ public static class Items {
public static final TagKey<Item> STORAGE_BLOCKS_SLIME = tag("storage_blocks/slime");
public static final TagKey<Item> STORAGE_BLOCKS_WHEAT = tag("storage_blocks/wheat");
public static final TagKey<Item> STRINGS = tag("strings");
public static final TagKey<Item> STRIPPED_LOGS = tag("stripped_logs");
public static final TagKey<Item> STRIPPED_WOODS = tag("stripped_woods");
public static final TagKey<Item> VILLAGER_JOB_SITES = tag("villager_job_sites");

// Tools and Armors
Expand Down Expand Up @@ -768,12 +772,12 @@ private static TagKey<Item> neoforgeTag(String name) {
*/
public static class Fluids {
/**
* Holds all fluids related to water.
* Holds all fluids related to water.<p>
* This tag is done to help out multi-loader mods/datapacks where the vanilla water tag has attached behaviors outside Neo.
*/
public static final TagKey<Fluid> WATER = tag("water");
/**
* Holds all fluids related to lava.
* Holds all fluids related to lava.<p>
* This tag is done to help out multi-loader mods/datapacks where the vanilla lava tag has attached behaviors outside Neo.
*/
public static final TagKey<Fluid> LAVA = tag("lava");
Expand All @@ -786,36 +790,48 @@ public static class Fluids {
*/
public static final TagKey<Fluid> GASEOUS = tag("gaseous");
/**
* Holds all fluids related to honey.<br></br>
* Holds all fluids related to honey.
* <p>
* (Standard unit for honey bottle is 250mb per bottle)
*/
public static final TagKey<Fluid> HONEY = tag("honey");
/**
* Holds all fluids related to potions. The effects of the potion fluid should be read from NBT.
* Holds all fluids related to experience.
* <p>
* (Standard unit for experience is 20mb per 1 experience. However, extraction from Bottle o' Enchanting should yield 250mb while smashing yields less)
*/
public static final TagKey<Fluid> EXPERIENCE = tag("experience");
/**
* Holds all fluids related to potions. The effects of the potion fluid should be read from DataComponents.
* The effects and color of the potion fluid should be read from {@link net.minecraft.core.component.DataComponents#POTION_CONTENTS}
* component that people should be attaching to the fluidstack of this fluid.<br></br>
* component that people should be attaching to the fluidstack of this fluid.
* <p>
* (Standard unit for potions is 250mb per bottle)
*/
public static final TagKey<Fluid> POTION = tag("potion");
/**
* Holds all fluids related to Suspicious Stew.
* The effects of the suspicious stew fluid should be read from {@link net.minecraft.core.component.DataComponents#SUSPICIOUS_STEW_EFFECTS}
* component that people should be attaching to the fluidstack of this fluid.<br></br>
* component that people should be attaching to the fluidstack of this fluid.
* <p>
* (Standard unit for suspicious stew is 250mb per bowl)
*/
public static final TagKey<Fluid> SUSPICIOUS_STEW = tag("suspicious_stew");
/**
* Holds all fluids related to Mushroom Stew.<br></br>
* Holds all fluids related to Mushroom Stew.
* <p>
* (Standard unit for mushroom stew is 250mb per bowl)
*/
public static final TagKey<Fluid> MUSHROOM_STEW = tag("mushroom_stew");
/**
* Holds all fluids related to Rabbit Stew.<br></br>
* Holds all fluids related to Rabbit Stew.
* <p>
* (Standard unit for rabbit stew is 250mb per bowl)
*/
public static final TagKey<Fluid> RABBIT_STEW = tag("rabbit_stew");
/**
* Holds all fluids related to Beetroot Soup.<br></br>
* Holds all fluids related to Beetroot Soup.
* <p>
* (Standard unit for beetroot soup is 250mb per bowl)
*/
public static final TagKey<Fluid> BEETROOT_SOUP = tag("beetroot_soup");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ public void addTags(HolderLookup.Provider p_256380_) {
tag(Tags.Blocks.STORAGE_BLOCKS_REDSTONE).add(Blocks.REDSTONE_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_SLIME).add(Blocks.SLIME_BLOCK);
tag(Tags.Blocks.STORAGE_BLOCKS_WHEAT).add(Blocks.HAY_BLOCK);
tag(Tags.Blocks.STRIPPED_LOGS).add(
Blocks.STRIPPED_ACACIA_LOG, Blocks.STRIPPED_BAMBOO_BLOCK, Blocks.STRIPPED_BIRCH_LOG,
Blocks.STRIPPED_CHERRY_LOG, Blocks.STRIPPED_DARK_OAK_LOG, Blocks.STRIPPED_JUNGLE_LOG,
Blocks.STRIPPED_MANGROVE_LOG, Blocks.STRIPPED_OAK_LOG, Blocks.STRIPPED_SPRUCE_LOG);
tag(Tags.Blocks.STRIPPED_WOODS).add(
Blocks.STRIPPED_ACACIA_WOOD, Blocks.STRIPPED_BIRCH_WOOD, Blocks.STRIPPED_CHERRY_WOOD,
Blocks.STRIPPED_DARK_OAK_WOOD, Blocks.STRIPPED_JUNGLE_WOOD, Blocks.STRIPPED_MANGROVE_WOOD,
Blocks.STRIPPED_OAK_WOOD, Blocks.STRIPPED_SPRUCE_WOOD);
tag(Tags.Blocks.VILLAGER_JOB_SITES).add(
Blocks.BARREL, Blocks.BLAST_FURNACE, Blocks.BREWING_STAND, Blocks.CARTOGRAPHY_TABLE,
Blocks.CAULDRON, Blocks.WATER_CAULDRON, Blocks.LAVA_CAULDRON, Blocks.POWDER_SNOW_CAULDRON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void addTags(HolderLookup.Provider lookupProvider) {
tag(Fluids.MILK).addOptional(NeoForgeMod.MILK.getId()).addOptional(NeoForgeMod.FLOWING_MILK.getId());
tag(Fluids.GASEOUS);
tag(Fluids.HONEY);
tag(Fluids.EXPERIENCE);
tag(Fluids.POTION);
tag(Fluids.SUSPICIOUS_STEW);
tag(Fluids.MUSHROOM_STEW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ public void addTags(HolderLookup.Provider lookupProvider) {
copy(Tags.Blocks.STORAGE_BLOCKS_SLIME, Tags.Items.STORAGE_BLOCKS_SLIME);
copy(Tags.Blocks.STORAGE_BLOCKS_WHEAT, Tags.Items.STORAGE_BLOCKS_WHEAT);
tag(Tags.Items.STRINGS).add(Items.STRING);
copy(Tags.Blocks.STRIPPED_LOGS, Tags.Items.STRIPPED_LOGS);
copy(Tags.Blocks.STRIPPED_WOODS, Tags.Items.STRIPPED_WOODS);
tag(Tags.Items.VILLAGER_JOB_SITES).add(
Items.BARREL, Items.BLAST_FURNACE, Items.BREWING_STAND, Items.CARTOGRAPHY_TABLE,
Items.CAULDRON, Items.COMPOSTER, Items.FLETCHING_TABLE, Items.GRINDSTONE,
Expand Down
Loading

0 comments on commit d04f420

Please sign in to comment.