Skip to content

Commit

Permalink
23w45a
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Nov 8, 2023
1 parent 0f7e959 commit 23e8616
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.slf4j.LoggerFactory;

import net.minecraft.client.MinecraftClient;
import net.minecraft.command.CommandException;
import net.minecraft.text.Text;
import net.minecraft.text.Texts;

Expand Down Expand Up @@ -96,11 +95,7 @@ public static boolean executeCommand(String command) {
LOGGER.warn("Syntax exception for client-sided command '{}'", command, e);
commandSource.sendError(getErrorMessage(e));
return true;
} catch (CommandException e) {
LOGGER.warn("Error while executing client-sided command '{}'", command, e);
commandSource.sendError(e.getTextMessage());
return true;
} catch (RuntimeException e) {
} catch (Exception e) {
LOGGER.warn("Error while executing client-sided command '{}'", command, e);
commandSource.sendError(Text.of(e.getMessage()));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import com.google.gson.JsonObject;
import com.mojang.serialization.JsonOps;

import net.minecraft.advancement.Advancement;
import net.minecraft.advancement.AdvancementEntry;
import net.minecraft.data.DataOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.DataWriter;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;

import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
Expand Down Expand Up @@ -85,7 +87,7 @@ public CompletableFuture<?> run(DataWriter writer) {
throw new IllegalStateException("Duplicate advancement " + advancement.id());
}

JsonObject advancementJson = advancement.value().toJson();
JsonObject advancementJson = Util.getResult(Advancement.field_47179.encodeStart(JsonOps.INSTANCE, advancement.value()), IllegalStateException::new).getAsJsonObject();
ConditionJsonProvider.write(advancementJson, FabricDataGenHelper.consumeConditions(advancement));

futures.add(DataProvider.writeToPath(writer, advancementJson, getOutputPath(advancement)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import com.google.gson.JsonObject;
import com.mojang.serialization.JsonOps;
import org.jetbrains.annotations.Nullable;

import net.minecraft.advancement.Advancement;
import net.minecraft.advancement.AdvancementEntry;
import net.minecraft.data.DataProvider;
import net.minecraft.data.DataWriter;
import net.minecraft.data.server.recipe.CraftingRecipeJsonBuilder;
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.RecipeJsonProvider;
import net.minecraft.data.server.recipe.RecipeProvider;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
import net.minecraft.recipe.Recipe;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;

import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
Expand Down Expand Up @@ -68,9 +71,9 @@ protected RecipeExporter withConditions(RecipeExporter exporter, ConditionJsonPr
Preconditions.checkArgument(conditions.length > 0, "Must add at least one condition.");
return new RecipeExporter() {
@Override
public void accept(RecipeJsonProvider provider) {
FabricDataGenHelper.addConditions(provider, conditions);
exporter.accept(provider);
public void accept(Identifier identifier, Recipe<?> recipe, @Nullable AdvancementEntry advancementEntry) {
FabricDataGenHelper.addConditions(recipe, conditions);
exporter.accept(identifier, recipe, advancementEntry);
}

@Override
Expand All @@ -86,23 +89,21 @@ public CompletableFuture<?> run(DataWriter writer) {
List<CompletableFuture<?>> list = new ArrayList<>();
generate(new RecipeExporter() {
@Override
public void accept(RecipeJsonProvider provider) {
Identifier identifier = getRecipeIdentifier(provider.id());
public void accept(Identifier recipeId, Recipe<?> recipe, @Nullable AdvancementEntry advancement) {
Identifier identifier = getRecipeIdentifier(recipeId);

if (!generatedRecipes.add(identifier)) {
throw new IllegalStateException("Duplicate recipe " + identifier);
}

JsonObject recipeJson = provider.toJson();
ConditionJsonProvider[] conditions = FabricDataGenHelper.consumeConditions(provider);
JsonObject recipeJson = Util.getResult(Recipe.field_47319.encodeStart(JsonOps.INSTANCE, recipe), IllegalStateException::new).getAsJsonObject();
ConditionJsonProvider[] conditions = FabricDataGenHelper.consumeConditions(recipe);
ConditionJsonProvider.write(recipeJson, conditions);

list.add(DataProvider.writeToPath(writer, recipeJson, recipesPathResolver.resolveJson(identifier)));

AdvancementEntry advancement = provider.advancement();

if (advancement != null) {
JsonObject advancementJson = advancement.value().toJson();
JsonObject advancementJson = Util.getResult(Advancement.field_47179.encodeStart(JsonOps.INSTANCE, advancement.value()), IllegalStateException::new).getAsJsonObject();
ConditionJsonProvider.write(advancementJson, conditions);
list.add(DataProvider.writeToPath(writer, advancementJson, advancementsPathResolver.resolveJson(getRecipeIdentifier(advancement.id()))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider off
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerShapelessRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;I)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSmelting (Lnet/minecraft/data/server/recipe/RecipeExporter;Ljava/util/List;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerBlasting (Lnet/minecraft/data/server/recipe/RecipeExporter;Ljava/util/List;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerMultipleOptions (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/recipe/RecipeSerializer;Ljava/util/List;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;Ljava/lang/String;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerMultipleOptions (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/recipe/RecipeSerializer;Lnet/minecraft/recipe/AbstractCookingRecipe$RecipeFactory;Ljava/util/List;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;FILjava/lang/String;Ljava/lang/String;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerNetheriteUpgradeRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/item/Item;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/Item;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSmithingTrimRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/item/Item;Lnet/minecraft/util/Identifier;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offer2x2CompactingRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V
Expand Down Expand Up @@ -122,8 +122,8 @@ transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider off
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerReversibleCompactingRecipes (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/book/RecipeCategory;Lnet/minecraft/item/ItemConvertible;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSmithingTemplateCopyingRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/registry/tag/TagKey;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerSmithingTemplateCopyingRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generateCookingRecipes (Lnet/minecraft/data/server/recipe/RecipeExporter;Ljava/lang/String;Lnet/minecraft/recipe/RecipeSerializer;I)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerFoodCookingRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Ljava/lang/String;Lnet/minecraft/recipe/RecipeSerializer;ILnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;F)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generateCookingRecipes (Lnet/minecraft/data/server/recipe/RecipeExporter;Ljava/lang/String;Lnet/minecraft/recipe/RecipeSerializer;Lnet/minecraft/recipe/AbstractCookingRecipe$RecipeFactory;I)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerFoodCookingRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Ljava/lang/String;Lnet/minecraft/recipe/RecipeSerializer;Lnet/minecraft/recipe/AbstractCookingRecipe$RecipeFactory;ILnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;F)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerWaxingRecipes (Lnet/minecraft/data/server/recipe/RecipeExporter;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerGrateRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider offerBulbRecipe (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V
Expand Down Expand Up @@ -256,7 +256,7 @@ transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator
transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerPlantPart (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Lnet/minecraft/data/client/BlockStateModelGenerator$TintType;)V
transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerBed (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerRoots (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator addJigsawOrientationToVariant (Lnet/minecraft/block/enums/JigsawOrientation;Lnet/minecraft/data/client/BlockStateVariant;)Lnet/minecraft/data/client/BlockStateVariant;
transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator addJigsawOrientationToVariant (Lnet/minecraft/block/enums/Orientation;Lnet/minecraft/data/client/BlockStateVariant;)Lnet/minecraft/data/client/BlockStateVariant;
transitive-accessible method net/minecraft/data/client/BlockStateModelGenerator registerCandle (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)V
transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator applyExplosionDecay (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/function/LootFunctionConsumingBuilder;)Lnet/minecraft/loot/function/LootFunctionConsumingBuilder;
transitive-accessible method net/minecraft/data/server/loottable/BlockLootTableGenerator addSurvivesExplosionCondition (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/loot/condition/LootConditionConsumingBuilder;)Lnet/minecraft/loot/condition/LootConditionConsumingBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.mojang.brigadier.exceptions.CommandSyntaxException;

import net.minecraft.block.Blocks;
import net.minecraft.command.CommandException;
import net.minecraft.command.argument.DimensionArgumentType;
import net.minecraft.entity.Entity;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -127,7 +126,7 @@ private int swapTargeted(CommandContext<ServerCommandSource> context) {
FabricDimensions.teleport(player, modWorld, target);

if (player.getWorld() != modWorld) {
throw new CommandException(Text.literal("Teleportation failed!"));
throw new RuntimeException("Teleportation failed!");
}

modWorld.setBlockState(new BlockPos(0, 100, 0), Blocks.DIAMOND_BLOCK.getDefaultState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*/
public final class BlockSetTypeBuilder {
private boolean openableByHand = true;
private boolean openableByWindCharge = true;
private boolean buttonActivatedByArrows = true;
private BlockSetType.ActivationRule pressurePlateActivationRule = BlockSetType.ActivationRule.EVERYTHING;
private BlockSoundGroup soundGroup = BlockSoundGroup.WOOD;
Expand All @@ -55,6 +56,18 @@ public BlockSetTypeBuilder openableByHand(boolean openableByHand) {
return this;
}

/**
* Sets whether this block set type's door and trapdoor can be opened by wind charge.
*
* <p>Defaults to {@code true}.
*
* @return this builder for chaining
*/
public BlockSetTypeBuilder openableByWindCharge(boolean openableByWindCharge) {
this.openableByWindCharge = openableByWindCharge;
return this;
}

/**
* Sets whether this block set type's button can be activated by an arrow.
*
Expand Down Expand Up @@ -260,6 +273,6 @@ public BlockSetType register(Identifier id) {
* @return the built {@link BlockSetType}
*/
public BlockSetType build(Identifier id) {
return new BlockSetType(id.toString(), openableByHand, buttonActivatedByArrows, pressurePlateActivationRule, soundGroup, doorCloseSound, doorOpenSound, trapdoorCloseSound, trapdoorOpenSound, pressurePlateClickOffSound, pressurePlateClickOnSound, buttonClickOffSound, buttonClickOnSound);
return new BlockSetType(id.toString(), openableByHand, openableByWindCharge, buttonActivatedByArrows, pressurePlateActivationRule, soundGroup, doorCloseSound, doorOpenSound, trapdoorCloseSound, trapdoorOpenSound, pressurePlateClickOffSound, pressurePlateClickOnSound, buttonClickOffSound, buttonClickOnSound);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.mojang.serialization.Codec;
Expand Down Expand Up @@ -77,10 +78,10 @@ public void testCustomIngredientSerialization(TestContext context) {
Ingredient ingredient = DefaultCustomIngredients.all(
Ingredient.ofItems(Items.STONE)
);
JsonElement json = ingredient.toJson(allowEmpty);
Codec<Ingredient> ingredientCodec = allowEmpty ? Ingredient.ALLOW_EMPTY_CODEC : Ingredient.DISALLOW_EMPTY_CODEC;
JsonObject json = Util.getResult(ingredientCodec.encodeStart(JsonOps.INSTANCE, ingredient), IllegalStateException::new).getAsJsonObject();
context.assertTrue(json.toString().equals(ingredientJson), "Unexpected json: " + json);
// Make sure that we can deserialize it
Codec<Ingredient> ingredientCodec = allowEmpty ? Ingredient.ALLOW_EMPTY_CODEC : Ingredient.DISALLOW_EMPTY_CODEC;
Ingredient deserialized = Util.getResult(
ingredientCodec.parse(JsonOps.INSTANCE, json), JsonParseException::new
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ transitive-accessible method net/minecraft/entity/SpawnRestriction register (Lne
transitive-accessible method net/minecraft/item/ItemUsageContext <init> (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/hit/BlockHitResult;)V
transitive-accessible method net/minecraft/item/ItemPlacementContext <init> (Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/hit/BlockHitResult;)V

# Recipe factories
transitive-accessible class net/minecraft/recipe/CookingRecipeSerializer$RecipeFactory
transitive-accessible class net/minecraft/recipe/CuttingRecipe$Serializer$RecipeFactory

# Registering custom brewing recipes
transitive-accessible method net/minecraft/recipe/BrewingRecipeRegistry registerItemRecipe (Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;)V
transitive-accessible method net/minecraft/recipe/BrewingRecipeRegistry registerPotionType (Lnet/minecraft/item/Item;)V
Expand Down Expand Up @@ -130,7 +126,6 @@ transitive-accessible method net/minecraft/entity/damage/DamageSources create (L
transitive-accessible field net/minecraft/client/MinecraftClient attackCooldown I

# Creating certain types of blocks
transitive-accessible method net/minecraft/block/Blocks createBambooBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createFlowerPotBlock (Lnet/minecraft/block/Block;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createLeavesBlock (Lnet/minecraft/sound/BlockSoundGroup;)Lnet/minecraft/block/Block;
transitive-accessible method net/minecraft/block/Blocks createLogBlock (Lnet/minecraft/block/MapColor;Lnet/minecraft/block/MapColor;)Lnet/minecraft/block/Block;
Expand Down Expand Up @@ -314,6 +309,7 @@ transitive-accessible field net/minecraft/client/render/RenderPhase GUI_PROGRAM
transitive-accessible field net/minecraft/client/render/RenderPhase GUI_OVERLAY_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase GUI_TEXT_HIGHLIGHT_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase GUI_GHOST_RECIPE_OVERLAY_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase field_47463 Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase MIPMAP_BLOCK_ATLAS_TEXTURE Lnet/minecraft/client/render/RenderPhase$Texture;
transitive-accessible field net/minecraft/client/render/RenderPhase BLOCK_ATLAS_TEXTURE Lnet/minecraft/client/render/RenderPhase$Texture;
transitive-accessible field net/minecraft/client/render/RenderPhase NO_TEXTURE Lnet/minecraft/client/render/RenderPhase$TextureBase;
Expand Down
Loading

0 comments on commit 23e8616

Please sign in to comment.