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

24w12a port #3658

Merged
merged 2 commits into from
Mar 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void onInitialize() {
Item item = stack.getItem();

if (item instanceof ToolItem) {
return () -> Text.literal("Tool mining level: " + ((ToolItem) item).getMaterial().getMiningLevel());
return () -> Text.literal("Tool mining level: " + ((ToolItem) item).getMaterial());
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.concurrent.CompletableFuture;

import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -142,7 +143,7 @@ private void generateDyeTags() {

private void generateConsumableTags() {
Registries.ITEM.forEach(item -> {
if (item.getFoodComponent() != null) {
if (item.getDefaultStack().contains(DataComponentTypes.FOOD)) {
getOrCreateTagBuilder(ConventionalItemTags.FOODS).add(item);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraft.loot.LootTables;
import net.minecraft.loot.context.LootContextTypes;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.resource.featuretoggle.FeatureFlags;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -72,27 +73,27 @@ public void excludeFromStrictValidation(Block block) {
}

@Override
public void accept(RegistryWrapper.WrapperLookup registryLookup, BiConsumer<Identifier, LootTable.Builder> biConsumer) {
public void accept(RegistryWrapper.WrapperLookup registryLookup, BiConsumer<RegistryKey<LootTable>, LootTable.Builder> biConsumer) {
generate();

for (Map.Entry<Identifier, LootTable.Builder> entry : lootTables.entrySet()) {
Identifier identifier = entry.getKey();
for (Map.Entry<RegistryKey<LootTable>, LootTable.Builder> entry : lootTables.entrySet()) {
RegistryKey<LootTable> registryKey = entry.getKey();

if (identifier.equals(LootTables.EMPTY)) {
if (registryKey.equals(LootTables.EMPTY)) {
continue;
}

biConsumer.accept(identifier, entry.getValue());
biConsumer.accept(registryKey, entry.getValue());
}

if (output.isStrictValidationEnabled()) {
Set<Identifier> missing = Sets.newHashSet();

for (Identifier blockId : Registries.BLOCK.getIds()) {
if (blockId.getNamespace().equals(output.getModId())) {
Identifier blockLootTableId = Registries.BLOCK.get(blockId).getLootTableId();
RegistryKey<LootTable> blockLootTableId = Registries.BLOCK.get(blockId).getLootTableId();

if (blockLootTableId.getNamespace().equals(output.getModId())) {
if (blockLootTableId.getValue().getNamespace().equals(output.getModId())) {
if (!lootTables.containsKey(blockLootTableId)) {
missing.add(blockId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import net.minecraft.data.DataProvider;
import net.minecraft.data.server.loottable.LootTableGenerator;
import net.minecraft.loot.LootTable;
import net.minecraft.util.Identifier;
import net.minecraft.registry.RegistryKey;

import net.fabricmc.fabric.api.datagen.v1.loot.FabricBlockLootTableGenerator;
import net.fabricmc.fabric.api.resource.conditions.v1.ConditionJsonProvider;
Expand All @@ -44,7 +44,7 @@ public interface FabricLootTableProvider extends LootTableGenerator, DataProvide
*
* <p>For block loot tables, use {@link FabricBlockLootTableGenerator#withConditions} instead.
*/
default BiConsumer<Identifier, LootTable.Builder> withConditions(BiConsumer<Identifier, LootTable.Builder> exporter, ConditionJsonProvider... conditions) {
default BiConsumer<RegistryKey<LootTable>, LootTable.Builder> withConditions(BiConsumer<RegistryKey<LootTable>, LootTable.Builder> exporter, ConditionJsonProvider... conditions) {
Preconditions.checkArgument(conditions.length > 0, "Must add at least one condition.");
return (id, table) -> {
FabricDataGenHelper.addConditions(table, conditions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ public static CompletableFuture<?> run(
HashMap<Identifier, ConditionJsonProvider[]> conditionMap = new HashMap<>();

return registryLookup.thenCompose(lookup -> {
provider.accept(lookup, (identifier, builder) -> {
provider.accept(lookup, (registryKey, builder) -> {
ConditionJsonProvider[] conditions = FabricDataGenHelper.consumeConditions(builder);
conditionMap.put(identifier, conditions);
conditionMap.put(registryKey.getValue(), conditions);

if (builders.put(identifier, builder.type(lootContextType).build()) != null) {
throw new IllegalStateException("Duplicate loot table " + identifier);
if (builders.put(registryKey.getValue(), builder.type(lootContextType).build()) != null) {
throw new IllegalStateException("Duplicate loot table " + registryKey.getValue());
}
});

RegistryOps<JsonElement> ops = lookup.getOps(JsonOps.INSTANCE);
final List<CompletableFuture<?>> futures = new ArrayList<>();

for (Map.Entry<Identifier, LootTable> entry : builders.entrySet()) {
JsonObject tableJson = (JsonObject) Util.getResult(LootTable.CODEC.encodeStart(ops, entry.getValue()), IllegalStateException::new);
JsonObject tableJson = (JsonObject) Util.getResult(LootTable.field_50021.encodeStart(ops, entry.getValue()), IllegalStateException::new);
ConditionJsonProvider.write(tableJson, conditionMap.remove(entry.getKey()));
futures.add(DataProvider.writeToPath(writer, tableJson, getOutputPath(fabricDataOutput, entry.getKey())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import net.minecraft.registry.Registerable;
import net.minecraft.registry.RegistryBuilder;
import net.minecraft.registry.RegistryEntryLookup;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.entry.RegistryEntry;
Expand Down Expand Up @@ -402,7 +403,7 @@ private TestBarterLootTableProvider(FabricDataOutput output, CompletableFuture<R
}

@Override
public void accept(RegistryWrapper.WrapperLookup registryLookup, BiConsumer<Identifier, LootTable.Builder> consumer) {
public void accept(RegistryWrapper.WrapperLookup registryLookup, BiConsumer<RegistryKey<LootTable>, LootTable.Builder> consumer) {
withConditions(consumer, ALWAYS_LOADED).accept(
LootTables.PIGLIN_BARTERING_GAMEPLAY,
LootTable.builder().pool(
Expand Down Expand Up @@ -434,7 +435,7 @@ public String getName() {

private static class TestPredicateProvider extends FabricCodecDataProvider<LootCondition> {
private TestPredicateProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(dataOutput, registriesFuture, DataOutput.OutputType.DATA_PACK, "predicates", LootConditionTypes.CODEC);
super(dataOutput, registriesFuture, DataOutput.OutputType.DATA_PACK, "predicates", LootConditionTypes.field_50031);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package net.fabricmc.fabric.mixin.entity.event.elytra;

import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -41,10 +40,6 @@ abstract class PlayerEntityMixin extends LivingEntity {
@Shadow
public abstract void startFallFlying();

@Shadow
@Nullable
public Double ignoreFallDamageAboveY;

/**
* Allow the server-side and client-side elytra checks to fail when {@link EntityElytraEvents#ALLOW} blocks flight,
* and otherwise to succeed for elytra flight through {@link EntityElytraEvents#CUSTOM}.
Expand All @@ -61,7 +56,6 @@ void injectElytraCheck(CallbackInfoReturnable<Boolean> cir) {

if (EntityElytraEvents.CUSTOM.invoker().useCustomElytra(self, false)) {
startFallFlying();
this.ignoreFallDamageAboveY = null;
cir.setReturnValue(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
package net.fabricmc.fabric.api.item.v1;

import com.google.common.collect.Multimap;
import org.jetbrains.annotations.Nullable;

import net.minecraft.block.BlockState;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.entry.RegistryEntry;
Expand Down Expand Up @@ -84,18 +81,6 @@ default Multimap<RegistryEntry<EntityAttribute>, EntityAttributeModifier> getAtt
return ((Item) this).getAttributeModifiers(slot);
}

/**
* Determines if mining with this item allows drops to be harvested from the specified block state.
* Stack-aware version of {@link Item#isSuitableFor(BlockState)}.
*
* @param stack the current stack
* @param state the block state of the targeted block
* @return true if drops can be harvested
*/
default boolean isSuitableFor(ItemStack stack, BlockState state) {
return ((Item) this).isSuitableFor(state);
}

/**
* Returns a leftover item stack after {@code stack} is consumed in a recipe.
* (This is also known as "recipe remainder".)
Expand Down Expand Up @@ -128,17 +113,6 @@ default ItemStack getRecipeRemainder(ItemStack stack) {
return ((Item) this).hasRecipeRemainder() ? ((Item) this).getRecipeRemainder().getDefaultStack() : ItemStack.EMPTY;
}

/**
* This is a stack-aware version of {@link Item#getFoodComponent()}.
* Note that simple food component can also be set via {@link Item.Settings#food(FoodComponent)}.
* If you want to get a food component for a stack, is <strong>recommended</strong> to use the stack version of this method: {@link FabricItemStack#getFoodComponent()}.
*
* @return this item's {@link FoodComponent}, or {@code null} if none was set
*/
default @Nullable FoodComponent getFoodComponent(ItemStack stack) {
return ((Item) this).getFoodComponent();
}

/**
* Fabric-provided extensions for {@link Item.Settings}.
* This interface is automatically implemented on all item settings via Mixin and interface injection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

package net.fabricmc.fabric.api.item.v1;

import org.jetbrains.annotations.Nullable;

import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

Expand All @@ -39,14 +36,4 @@ public interface FabricItemStack {
default ItemStack getRecipeRemainder() {
return ((ItemStack) this).getItem().getRecipeRemainder((ItemStack) this);
}

/**
* Stack-aware version of {@link Item#getFoodComponent()}.
* See {@link FabricItem#getFoodComponent(ItemStack)} for a more in depth description.
*
* @return this item stack's {@link FoodComponent}, or {@code null} if none was set
*/
default @Nullable FoodComponent getFoodComponent() {
return ((ItemStack) this).getItem().getFoodComponent(((ItemStack) this));
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading