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

Update to 1.21.4: mod #243

Merged
merged 1 commit into from
Dec 30, 2024
Merged
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
2 changes: 1 addition & 1 deletion develop/items/first-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ For example, if you want to make your item compostable, you can use the `Compost

@[code transcludeWith=:::_10](@/reference/latest/src/main/java/com/example/docs/item/ModItems.java)

Alternatively, if you want to make your item a fuel, you can use the `FuelRegistry` class:
Alternatively, if you want to make your item a fuel, you can use the `FuelRegistryEvents.BUILD` event:

@[code transcludeWith=:::_11](@/reference/latest/src/main/java/com/example/docs/item/ModItems.java)

Expand Down
2 changes: 1 addition & 1 deletion reference/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

loader_version=0.16.8
loader_version=0.16.9
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected void configure(RegistryWrapper.WrapperLookup registries, Entries entri
// Our new enchantment, "Thundering."
register(entries, ModEnchantmentEffects.THUNDERING, Enchantment.builder(
Enchantment.definition(
registries.getWrapperOrThrow(RegistryKeys.ITEM).getOrThrow(ItemTags.WEAPON_ENCHANTABLE),
registries.getOrThrow(RegistryKeys.ITEM).getOrThrow(ItemTags.WEAPON_ENCHANTABLE),
// this is the "weight" or probability of our enchantment showing up in the table
10,
// the maximum level of the enchantment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import net.minecraft.advancement.AdvancementFrame;
import net.minecraft.advancement.criterion.ConsumeItemCriterion;
import net.minecraft.advancement.criterion.InventoryChangedCriterion;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -49,6 +51,7 @@ public void generateAdvancement(RegistryWrapper.WrapperLookup wrapperLookup, Con
.build(consumer, FabricDocsReference.MOD_ID + "/get_dirt");
// :::datagen-advancements:simple-advancement
// :::datagen-advancements:second-advancement
final RegistryWrapper.Impl<Item> itemLookup = wrapperLookup.getOrThrow(RegistryKeys.ITEM);
AdvancementEntry appleAndBeef = Advancement.Builder.create()
.parent(getDirt)
.display(
Expand All @@ -61,8 +64,8 @@ public void generateAdvancement(RegistryWrapper.WrapperLookup wrapperLookup, Con
true,
false
)
.criterion("ate_apple", ConsumeItemCriterion.Conditions.item(Items.APPLE))
.criterion("ate_cooked_beef", ConsumeItemCriterion.Conditions.item(Items.COOKED_BEEF))
.criterion("ate_apple", ConsumeItemCriterion.Conditions.item(wrapperLookup.getOrThrow(RegistryKeys.ITEM), Items.APPLE))
.criterion("ate_cooked_beef", ConsumeItemCriterion.Conditions.item(itemLookup, Items.COOKED_BEEF))
.build(consumer, FabricDocsReference.MOD_ID + "/apple_and_beef");
// :::datagen-advancements:second-advancement
// :::datagen-advancements:custom-criteria-advancement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;

import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
import net.minecraft.data.recipe.RecipeExporter;
import net.minecraft.data.recipe.RecipeGenerator;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.ItemTags;

Expand All @@ -22,46 +23,58 @@ public FabricDocsReferenceRecipeProvider(FabricDataOutput output, CompletableFut
}

@Override
public void generate(RecipeExporter recipeExporter) {
// :::datagen-recipes:provider
// :::datagen-recipes:shapeless
ShapelessRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, Items.DIRT) // You can also specify an int to produce more than one
.input(Items.COARSE_DIRT) // You can also specify an int to require more than one, or a tag to accept multiple things
// Create an advancement that gives you the recipe
.criterion(FabricRecipeProvider.hasItem(Items.COARSE_DIRT), FabricRecipeProvider.conditionsFromItem(Items.COARSE_DIRT))
.offerTo(recipeExporter);
// :::datagen-recipes:shapeless
// :::datagen-recipes:shaped
ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, Items.CRAFTING_TABLE, 4)
.pattern("ll")
.pattern("ll")
.input('l', ItemTags.LOGS) // 'l' means "any log"
.group("multi_bench") // Put it in a group called "multi_bench" - groups are shown in one slot in the recipe book
.criterion(FabricRecipeProvider.hasItem(Items.CRAFTING_TABLE), FabricRecipeProvider.conditionsFromItem(Items.CRAFTING_TABLE))
.offerTo(recipeExporter);
ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, Items.LOOM, 4)
.pattern("ww")
.pattern("ll")
.input('w', ItemTags.WOOL) // 'w' means "any wool"
.input('l', ItemTags.LOGS)
.group("multi_bench")
.criterion(FabricRecipeProvider.hasItem(Items.LOOM), FabricRecipeProvider.conditionsFromItem(Items.LOOM))
.offerTo(recipeExporter);
FabricRecipeProvider.createDoorRecipe(Items.OAK_DOOR, Ingredient.ofItems(Items.OAK_BUTTON)) // Using a helper method!
.criterion(FabricRecipeProvider.hasItem(Items.OAK_BUTTON), FabricRecipeProvider.conditionsFromItem(Items.OAK_BUTTON))
.offerTo(recipeExporter);
// :::datagen-recipes:shaped
// :::datagen-recipes:other
FabricRecipeProvider.offerSmelting(recipeExporter,
List.of(Items.BREAD, Items.COOKIE, Items.HAY_BLOCK), // Inputs
RecipeCategory.FOOD, // Category
Items.WHEAT, // Output
0.1f, // Experience
300, // Cooking time
"food_to_wheat" // group
);
// :::datagen-recipes:other
// :::datagen-recipes:provider
protected RecipeGenerator getRecipeGenerator(RegistryWrapper.WrapperLookup registryLookup, RecipeExporter exporter) {
return new RecipeGenerator(registryLookup, exporter) {
@Override
public void generate() {
RegistryWrapper.Impl<Item> itemLookup = registries.getOrThrow(RegistryKeys.ITEM);
// :::datagen-recipes:provider
// :::datagen-recipes:shapeless

createShapeless(RecipeCategory.BUILDING_BLOCKS, Items.DIRT) // You can also specify an int to produce more than one
.input(Items.COARSE_DIRT) // You can also specify an int to require more than one, or a tag to accept multiple things
// Create an advancement that gives you the recipe
.criterion(hasItem(Items.COARSE_DIRT), conditionsFromItem(Items.COARSE_DIRT))
.offerTo(exporter);
// :::datagen-recipes:shapeless
// :::datagen-recipes:shaped
createShaped(RecipeCategory.MISC, Items.CRAFTING_TABLE, 4)
.pattern("ll")
.pattern("ll")
.input('l', ItemTags.LOGS) // 'l' means "any log"
.group("multi_bench") // Put it in a group called "multi_bench" - groups are shown in one slot in the recipe book
.criterion(hasItem(Items.CRAFTING_TABLE), conditionsFromItem(Items.CRAFTING_TABLE))
.offerTo(exporter);
createShaped(RecipeCategory.MISC, Items.LOOM, 4)
.pattern("ww")
.pattern("ll")
.input('w', ItemTags.WOOL) // 'w' means "any wool"
.input('l', ItemTags.LOGS)
.group("multi_bench")
.criterion(hasItem(Items.LOOM), conditionsFromItem(Items.LOOM))
.offerTo(exporter);
createDoorRecipe(Items.OAK_DOOR, Ingredient.ofItems(Items.OAK_BUTTON)) // Using a helper method!
.criterion(hasItem(Items.OAK_BUTTON), conditionsFromItem(Items.OAK_BUTTON))
.offerTo(exporter);
// :::datagen-recipes:shaped
// :::datagen-recipes:other
offerSmelting(
List.of(Items.BREAD, Items.COOKIE, Items.HAY_BLOCK), // Inputs
RecipeCategory.FOOD, // Category
Items.WHEAT, // Output
0.1f, // Experience
300, // Cooking time
"food_to_wheat" // group
);
// :::datagen-recipes:other
// :::datagen-recipes:provider
}
};
}

@Override
public String getName() {
return "FabricDocsReferenceRecipeProvider";
}
}
// :::datagen-recipes:provider
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

Expand Down Expand Up @@ -57,14 +58,14 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// :::5
Identifier texture = Identifier.of("minecraft", "textures/block/deepslate.png");
// texture, x, y, u, v, width, height, textureWidth, textureHeight
context.drawTexture(texture, 90, 90, 0, 0, 16, 16, 16, 16);
context.drawTexture(RenderLayer::getGuiTextured, texture, 90, 90, 0, 0, 16, 16, 16, 16);
// :::5

// :::6
Identifier texture2 = Identifier.of("fabric-docs-reference", "textures/gui/test-uv-drawing.png");
int u = 10, v = 13, regionWidth = 14, regionHeight = 14;
// texture, x, y, width, height, u, v, regionWidth, regionHeight, textureWidth, textureHeight
context.drawTexture(texture2, 90, 190, 14, 14, u, v, regionWidth, regionHeight, 256, 256);
context.drawTexture(RenderLayer::getGuiTextured, texture2, 90, 190, 14, 14, u, v, regionWidth, regionHeight, 256, 256);
// :::6

// :::7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void onInitializeClient() {

// "lerp" simply means "linear interpolation", which is a fancy way of saying "blend".
float lerpedAmount = MathHelper.abs(MathHelper.sin(totalTickDelta / 50F));
int lerpedColor = ColorHelper.Argb.lerp(lerpedAmount, color, targetColor);
int lerpedColor = ColorHelper.lerp(lerpedAmount, color, targetColor);

// Draw a square with the lerped color.
// x1, x2, y1, y2, z, color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.mojang.blaze3d.systems.RenderSystem;
import org.joml.Matrix4f;

import net.minecraft.client.gl.ShaderProgramKeys;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void onInitializeClient() {
buffer.vertex(transformationMatrix, 20, 60, 5).color(0xFF414141);

// We'll get to this bit in the next section.
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

// Draw the buffer onto the screen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public <T extends AbstractDynamicSoundInstance> void stop(T soundInstance) {
public Optional<AbstractDynamicSoundInstance> getPlayingSoundInstance(SoundEvent soundEvent) {
for (var activeSound : this.activeSounds) {
// SoundInstances use their SoundEvent's id by default
if (activeSound.getId().equals(soundEvent.getId())) {
if (activeSound.getId().equals(soundEvent.id())) {
return Optional.of(activeSound);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"category": "misc",
"group": "multi_bench",
"key": {
"l": {
"tag": "minecraft:logs"
}
"l": "#minecraft:logs"
},
"pattern": [
"ll",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"type": "minecraft:crafting_shapeless",
"category": "building",
"ingredients": [
{
"item": "minecraft:coarse_dirt"
}
"minecraft:coarse_dirt"
],
"result": {
"count": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
"category": "misc",
"group": "multi_bench",
"key": {
"l": {
"tag": "minecraft:logs"
},
"w": {
"tag": "minecraft:wool"
}
"l": "#minecraft:logs",
"w": "#minecraft:wool"
},
"pattern": [
"ww",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"type": "minecraft:crafting_shaped",
"category": "redstone",
"key": {
"#": {
"item": "minecraft:oak_button"
}
"#": "minecraft:oak_button"
},
"pattern": [
"##",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"cookingtime": 300,
"experience": 0.1,
"group": "food_to_wheat",
"ingredient": {
"item": "minecraft:bread"
},
"ingredient": "minecraft:bread",
"result": {
"id": "minecraft:wheat"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"cookingtime": 300,
"experience": 0.1,
"group": "food_to_wheat",
"ingredient": {
"item": "minecraft:cookie"
},
"ingredient": "minecraft:cookie",
"result": {
"id": "minecraft:wheat"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"cookingtime": 300,
"experience": 0.1,
"group": "food_to_wheat",
"ingredient": {
"item": "minecraft:hay_block"
},
"ingredient": "minecraft:hay_block",
"result": {
"id": "minecraft:wheat"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;

Expand All @@ -23,36 +25,43 @@ public class ModBlocks {
// :::1

// :::2
public static final RegistryKey<Block> CONDENSED_DIRT_KEY = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(FabricDocsReference.MOD_ID, "condensed_dirt"));
public static final Block CONDENSED_DIRT = register(
new Block(AbstractBlock.Settings.create().sounds(BlockSoundGroup.GRASS)),
new Block(AbstractBlock.Settings.create().registryKey(CONDENSED_DIRT_KEY).sounds(BlockSoundGroup.GRASS)),
"condensed_dirt",
true
);
// :::2
// :::3
public static final RegistryKey<Block> CONDENSED_OAK_LOG_KEY = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(FabricDocsReference.MOD_ID, "condensed_oak_log"));
public static final Block CONDENSED_OAK_LOG = register(
new PillarBlock(
AbstractBlock.Settings.create()
.registryKey(CONDENSED_OAK_LOG_KEY)
.sounds(BlockSoundGroup.WOOD)
), "condensed_oak_log", true
);
// :::3
// :::4
public static final RegistryKey<Block> PRISMARINE_LAMP_KEY = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(FabricDocsReference.MOD_ID, "prismarine_lamp"));
public static final Block PRISMARINE_LAMP = register(
new PrismarineLampBlock(
AbstractBlock.Settings.create()
.registryKey(PRISMARINE_LAMP_KEY)
.sounds(BlockSoundGroup.LANTERN)
.luminance(PrismarineLampBlock::getLuminance)
), "prismarine_lamp", true
);
// :::4
public static final RegistryKey<Block> ENGINE_BLOCK_KEY = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(FabricDocsReference.MOD_ID, "engine"));
public static final Block ENGINE_BLOCK = register(
new EngineBlock(AbstractBlock.Settings.create()), "engine", true
new EngineBlock(AbstractBlock.Settings.create().registryKey(ENGINE_BLOCK_KEY)), "engine", true
);

// :::5
public static final RegistryKey<Block> COUNTER_BLOCK_KEY = RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(FabricDocsReference.MOD_ID, "counter_block"));
public static final Block COUNTER_BLOCK = register(
new CounterBlock(AbstractBlock.Settings.create()), "counter_block", true
new CounterBlock(AbstractBlock.Settings.create().registryKey(COUNTER_BLOCK_KEY)), "counter_block", true
);
// :::5

Expand All @@ -64,7 +73,7 @@ public static Block register(Block block, String name, boolean shouldRegisterIte
// Sometimes, you may not want to register an item for the block.
// Eg: if it's a technical block like `minecraft:air` or `minecraft:end_gateway`
if (shouldRegisterItem) {
BlockItem blockItem = new BlockItem(block, new Item.Settings());
BlockItem blockItem = new BlockItem(block, new Item.Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, id)));
Registry.register(Registries.ITEM, id, blockItem);
}

Expand Down
Loading