mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 19:15:32 +00:00
Forge 1.19.4
Properly move `ServerStatusPing` to codec Reimplement custom display contexts Co-authored-by: Matyrobbrt <[email protected]> Co-authored-by: coehlrich <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
1f44339d6e
commit
44c689f171
347 files changed
+2545
-2436
No files matched your search
@@ -47,7 +47,7 @@ public class CreativeModeTabTest
|
||||
LOGS = event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "logs"), builder -> builder.icon(() -> new ItemStack(Blocks.ACACIA_LOG))
|
||||
.title(Component.literal("Logs"))
|
||||
.withLabelColor(0x00FF00)
|
||||
.displayItems((features, output, hasPermissions) -> {
|
||||
.displayItems((params, output) -> {
|
||||
output.accept(new ItemStack(Blocks.ACACIA_LOG));
|
||||
output.accept(new ItemStack(Blocks.BIRCH_LOG));
|
||||
output.accept(new ItemStack(Blocks.DARK_OAK_LOG));
|
||||
@@ -59,7 +59,7 @@ public class CreativeModeTabTest
|
||||
STONE = event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "stone"), List.of(CreativeModeTabs.BUILDING_BLOCKS), List.of(), builder -> builder.icon(() -> new ItemStack(Blocks.STONE))
|
||||
.title(Component.literal("Stone"))
|
||||
.withLabelColor(0x0000FF)
|
||||
.displayItems((features, output, hasPermissions) -> {
|
||||
.displayItems((params, output) -> {
|
||||
output.accept(new ItemStack(Blocks.STONE));
|
||||
output.accept(new ItemStack(Blocks.GRANITE));
|
||||
output.accept(new ItemStack(Blocks.DIORITE));
|
||||
@@ -67,7 +67,7 @@ public class CreativeModeTabTest
|
||||
}));
|
||||
|
||||
event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "colors"), builder -> builder.title(Component.literal("Colors"))
|
||||
.displayItems((features, output, hasPermissions) ->
|
||||
.displayItems((params, output) ->
|
||||
{
|
||||
for (DyeColor color : DyeColor.values())
|
||||
{
|
||||
|
||||
@@ -41,6 +41,7 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
@@ -775,27 +776,27 @@ public class DataGeneratorTest
|
||||
ModelFile block = models().getBuilder("block")
|
||||
.guiLight(GuiLight.SIDE)
|
||||
.transforms()
|
||||
.transform(ItemTransforms.TransformType.GUI)
|
||||
.transform(ItemDisplayContext.GUI)
|
||||
.rotation(30, 225, 0)
|
||||
.scale(0.625f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.GROUND)
|
||||
.transform(ItemDisplayContext.GROUND)
|
||||
.translation(0, 3, 0)
|
||||
.scale(0.25f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIXED)
|
||||
.transform(ItemDisplayContext.FIXED)
|
||||
.scale(0.5f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.THIRD_PERSON_RIGHT_HAND)
|
||||
.transform(ItemDisplayContext.THIRD_PERSON_RIGHT_HAND)
|
||||
.rotation(75, 45, 0)
|
||||
.translation(0, 2.5f, 0)
|
||||
.scale(0.375f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIRST_PERSON_RIGHT_HAND)
|
||||
.transform(ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
.rotation(0, 45, 0)
|
||||
.scale(0.4f)
|
||||
.end()
|
||||
.transform(ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND)
|
||||
.transform(ItemDisplayContext.FIRST_PERSON_LEFT_HAND)
|
||||
.rotation(0, 225, 0)
|
||||
.scale(0.4f)
|
||||
.end()
|
||||
@@ -1131,7 +1132,7 @@ public class DataGeneratorTest
|
||||
} else if (generatedDisplay != null) { // Both must be non-null
|
||||
ItemTransforms generatedTransforms = GSON.fromJson(generatedDisplay, ItemTransforms.class);
|
||||
ItemTransforms vanillaTransforms = GSON.fromJson(vanillaDisplay, ItemTransforms.class);
|
||||
for (ItemTransforms.TransformType type : ItemTransforms.TransformType.values()) {
|
||||
for (ItemDisplayContext type : ItemDisplayContext.values()) {
|
||||
if (!generatedTransforms.getTransform(type).equals(vanillaTransforms.getTransform(type))) {
|
||||
ret.add("Model " + loc + " has transforms that differ from vanilla equivalent for perspective " + type.name());
|
||||
return;
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ManyMobEffectsTest
|
||||
MinecraftForge.EVENT_BUS.addListener(ManyMobEffectsTest::mobInteract);
|
||||
modBus.addListener((CreativeModeTabEvent.Register event) -> event.registerCreativeModeTab(new ResourceLocation(MODID, "many_mob_effects_test"), builder -> builder.withSearchBar()
|
||||
.icon(() -> new ItemStack(Items.POTION))
|
||||
.displayItems((flags, output, isOperator) -> {
|
||||
.displayItems((params, output) -> {
|
||||
var stack = new ItemStack(Items.POTION);
|
||||
PotionUtils.setCustomEffects(stack, List.of(new MobEffectInstance(LAST_EFFECT.get(), 1000)));
|
||||
output.accept(stack);
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.world.item.HangingSignItem;
|
||||
import net.minecraft.world.level.block.CeilingHangingSignBlock;
|
||||
import net.minecraft.world.level.block.WallHangingSignBlock;
|
||||
import net.minecraft.world.level.block.entity.HangingSignBlockEntity;
|
||||
import net.minecraft.world.level.block.state.properties.BlockSetType;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer;
|
||||
@@ -46,7 +47,7 @@ public class CustomSignsTest
|
||||
public static final boolean ENABLE = false; // TODO fix
|
||||
public static final String MODID = "custom_signs_test";
|
||||
|
||||
public static final WoodType TEST_WOOD_TYPE = WoodType.create(new ResourceLocation(MODID, "test").toString());
|
||||
public static final WoodType TEST_WOOD_TYPE = WoodType.register(new WoodType(new ResourceLocation(MODID, "test").toString(), BlockSetType.ACACIA));
|
||||
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final RegistryObject<CustomStandingSignBlock> TEST_STANDING_SIGN = BLOCKS.register("test_sign", () -> new CustomStandingSignBlock(Properties.of(Material.WOOD).noCollission().strength(1.0F).sound(SoundType.WOOD), CustomSignsTest.TEST_WOOD_TYPE));
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ClientCommandTest
|
||||
.then(Commands.argument("recipe", ResourceLocationArgument.id())
|
||||
.executes((context) -> {
|
||||
context.getSource()
|
||||
.sendSuccess(ResourceLocationArgument.getRecipe(context, "recipe").getResultItem().getDisplayName(), false);
|
||||
.sendSuccess(ResourceLocationArgument.getRecipe(context, "recipe").getResultItem(context.getSource().registryAccess()).getDisplayName(), false);
|
||||
return 1;
|
||||
})))
|
||||
// Used for checking if getting a team works on the client side
|
||||
|
||||
@@ -39,10 +39,10 @@ public class CustomArmorModelTest
|
||||
static final String MOD_ID = "custom_armor_model_test";
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);
|
||||
// demonstrates custom non-humanoid model
|
||||
private static final RegistryObject<Item> RED_LEGGINGS = ITEMS.register("red_leggings", () -> new TintedArmorItem(ArmorMaterials.DIAMOND, EquipmentSlot.LEGS, new Properties().stacksTo(1)));
|
||||
private static final RegistryObject<Item> RED_LEGGINGS = ITEMS.register("red_leggings", () -> new TintedArmorItem(ArmorMaterials.DIAMOND, ArmorItem.Type.LEGGINGS, new Properties().stacksTo(1)));
|
||||
// demonstrates the properties are copied from the vanilla model
|
||||
private static final RegistryObject<Item> ENDERMAN_CHESTPLATE = ITEMS.register("enderman_chestplate", () -> new EndermanArmorItem(ArmorMaterials.GOLD, EquipmentSlot.CHEST, new Properties().stacksTo(1)));
|
||||
private static final RegistryObject<Item> ENDERMAN_BOOTS = ITEMS.register("enderman_boots", () -> new EndermanArmorItem(ArmorMaterials.GOLD, EquipmentSlot.FEET, new Properties().stacksTo(1)));
|
||||
private static final RegistryObject<Item> ENDERMAN_CHESTPLATE = ITEMS.register("enderman_chestplate", () -> new EndermanArmorItem(ArmorMaterials.GOLD, ArmorItem.Type.CHESTPLATE, new Properties().stacksTo(1)));
|
||||
private static final RegistryObject<Item> ENDERMAN_BOOTS = ITEMS.register("enderman_boots", () -> new EndermanArmorItem(ArmorMaterials.GOLD, ArmorItem.Type.BOOTS, new Properties().stacksTo(1)));
|
||||
|
||||
public CustomArmorModelTest()
|
||||
{
|
||||
@@ -63,7 +63,7 @@ public class CustomArmorModelTest
|
||||
|
||||
private static class TintedArmorItem extends ArmorItem
|
||||
{
|
||||
public TintedArmorItem(ArmorMaterial material, EquipmentSlot slot, Properties props)
|
||||
public TintedArmorItem(ArmorMaterial material, ArmorItem.Type slot, Properties props)
|
||||
{
|
||||
super(material, slot, props);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class CustomArmorModelTest
|
||||
|
||||
private static class EndermanArmorItem extends ArmorItem
|
||||
{
|
||||
public EndermanArmorItem(ArmorMaterial material, EquipmentSlot slot, Properties props)
|
||||
public EndermanArmorItem(ArmorMaterial material, ArmorItem.Type slot, Properties props)
|
||||
{
|
||||
super(material, slot, props);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package net.minecraftforge.debug.client;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.ColorResolver;
|
||||
@@ -49,7 +50,7 @@ public class CustomColorResolverTest
|
||||
private static class ClientHandler
|
||||
{
|
||||
|
||||
private static final ColorResolver COLOR_RESOLVER = (biome, x, z) -> biome.getPrecipitation() == Biome.Precipitation.NONE ? 0xFF0000 : 0x0000FF;
|
||||
private static final ColorResolver COLOR_RESOLVER = (biome, x, z) -> biome.getPrecipitationAt(BlockPos.containing(x, 0, z)) == Biome.Precipitation.NONE ? 0xFF0000 : 0x0000FF;
|
||||
|
||||
@SubscribeEvent
|
||||
static void registerColorResolver(RegisterColorHandlersEvent.ColorResolvers event)
|
||||
|
||||
@@ -94,7 +94,7 @@ public class CustomTooltipTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderImage(Font font, int x, int y, PoseStack poseStack, ItemRenderer itemRenderer_, int zIndex)
|
||||
public void renderImage(Font font, int x, int y, PoseStack poseStack, ItemRenderer itemRenderer_)
|
||||
{
|
||||
GuiComponent.fill(poseStack, x, y, x + 10, y+ 10, tooltip.color);
|
||||
}
|
||||
|
||||
+12
-11
@@ -8,7 +8,6 @@ package net.minecraftforge.debug.client.model;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
@@ -48,10 +47,11 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.data.event.GatherDataEvent;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Test mod for the custom transform types feature.
|
||||
* This test mod adds an item that should be held in the main hand, while another item is in the offhand.
|
||||
* When right-clicked on a block, the item will "hang" the stack from the offhand slot on the wall.
|
||||
@@ -60,25 +60,26 @@ import org.jetbrains.annotations.Nullable;
|
||||
* when compared to similar items such as a fishing rod.
|
||||
* Editing that model json will reflect ingame after a resource reload (F3+T).
|
||||
*/
|
||||
@Mod(CustomTransformTypeTest.MODID)
|
||||
public class CustomTransformTypeTest
|
||||
@Mod(CustomItemDisplayContextTest.MODID)
|
||||
public class CustomItemDisplayContextTest
|
||||
{
|
||||
public static final String MODID = "custom_transformtype_test";
|
||||
|
||||
@Mod.EventBusSubscriber(value= Dist.CLIENT, modid = MODID, bus= Mod.EventBusSubscriber.Bus.MOD)
|
||||
@Mod.EventBusSubscriber(value= Dist.CLIENT, modid = MODID, bus= Mod.EventBusSubscriber.Bus.MOD)
|
||||
private static class RendererEvents
|
||||
{
|
||||
public static final ItemTransforms.TransformType HANGING = ItemTransforms.TransformType.create(
|
||||
"custom_transformtype_test_hanging",
|
||||
new ResourceLocation("custom_transformtype_test", "hanging")
|
||||
);
|
||||
|
||||
public static final ItemDisplayContext HANGING = ItemDisplayContext.create("custom_transformtype_test_hanging", new ResourceLocation("custom_transformtype_test", "hanging"), null);
|
||||
@SubscribeEvent
|
||||
public static void registerRenderers(EntityRenderersEvent.RegisterRenderers event)
|
||||
{
|
||||
event.registerBlockEntityRenderer(ITEM_HANGER_BE.get(), ItemHangerBlockEntityRenderer::new);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerContext(final RegisterEvent event) {
|
||||
event.register(ForgeRegistries.Keys.DISPLAY_CONTEXTS, helper -> helper.register("hanging", HANGING));
|
||||
}
|
||||
|
||||
private static class ItemHangerBlockEntityRenderer
|
||||
implements BlockEntityRenderer<ItemHangerBlockEntity>
|
||||
{
|
||||
@@ -121,7 +122,7 @@ public class CustomTransformTypeTest
|
||||
public static final RegistryObject<Item>
|
||||
ITEM_HANGER_ITEM = ITEMS.register("item_hanger", () -> new ItemHangerItem(ITEM_HANGER_BLOCK.get(), new Item.Properties()));
|
||||
|
||||
public CustomTransformTypeTest()
|
||||
public CustomItemDisplayContextTest()
|
||||
{
|
||||
var modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
modBus.addListener(this::gatherData);
|
||||
@@ -209,8 +209,8 @@ public class NewModelLoaderTest
|
||||
withExistingParent(NewModelLoaderTest.separate_perspective.getId().getPath(), "forge:item/default")
|
||||
.customLoader(SeparateTransformsModelBuilder::begin)
|
||||
.base(nested().parent(getExistingFile(mcLoc("minecraft:item/coal"))))
|
||||
.perspective(ItemTransforms.TransformType.GUI, nested().parent(getExistingFile(mcLoc("minecraft:item/snowball"))))
|
||||
.perspective(ItemTransforms.TransformType.FIRST_PERSON_LEFT_HAND, nested().parent(getExistingFile(mcLoc("minecraft:item/bone"))))
|
||||
.perspective(ItemDisplayContext.GUI, nested().parent(getExistingFile(mcLoc("minecraft:item/snowball"))))
|
||||
.perspective(ItemDisplayContext.FIRST_PERSON_LEFT_HAND, nested().parent(getExistingFile(mcLoc("minecraft:item/bone"))))
|
||||
.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ public class CustomItemDecorationsTest
|
||||
@Override
|
||||
public boolean render(Font font, ItemStack stack, int xOffset, int yOffset, float blitOffset)
|
||||
{
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.disableBlend();
|
||||
Tesselator tesselator = Tesselator.getInstance();
|
||||
BufferBuilder bufferbuilder = tesselator.getBuilder();
|
||||
@@ -61,7 +60,6 @@ public class CustomItemDecorationsTest
|
||||
fillRect(bufferbuilder, xOffset + 2, yOffset, blitOffset + 189, 13, 2, 0, 0, 0);
|
||||
fillRect(bufferbuilder, xOffset + 2, yOffset, blitOffset + 190, i, 1, j >> 16 & 255, j >> 8 & 255, j & 255);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableTexture();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ public class RenderableTest
|
||||
private static void render(Stage stage, PoseStack poseStack, int renderTick, float partialTick, double camX, double camY, double camZ, int xOffset)
|
||||
{
|
||||
double x = camX, y = camY, z = camZ;
|
||||
if (!new BlockPos(0, y, 0).closerThan(new BlockPos(x, y, z), 100))
|
||||
if (!BlockPos.containing(0, y, 0).closerThan(BlockPos.containing(x, y, z), 100))
|
||||
return;
|
||||
|
||||
var profiler = Minecraft.getInstance().getProfiler();
|
||||
|
||||
@@ -148,7 +148,7 @@ public class GlobalLootModifiersTest {
|
||||
|
||||
private static ItemStack smelt(ItemStack stack, LootContext context) {
|
||||
return context.getLevel().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SimpleContainer(stack), context.getLevel())
|
||||
.map(SmeltingRecipe::getResultItem)
|
||||
.map(smeltingRecipe -> smeltingRecipe.getResultItem(context.getLevel().registryAccess()))
|
||||
.filter(itemStack -> !itemStack.isEmpty())
|
||||
.map(itemStack -> ItemHandlerHelper.copyStackWithSize(itemStack, stack.getCount() * itemStack.getCount()))
|
||||
.orElse(stack);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class EnderMaskTest
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Item> ENDER_MASK = ITEMS.register("ender_mask", () ->
|
||||
new ArmorItem(ArmorMaterials.LEATHER, EquipmentSlot.HEAD, (new Item.Properties()))
|
||||
new ArmorItem(ArmorMaterials.LEATHER, ArmorItem.Type.HELMET, (new Item.Properties()))
|
||||
{
|
||||
@Override
|
||||
public boolean isEnderMask(ItemStack stack, Player player, EnderMan endermanEntity)
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SnowBootsTest
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Item> SNOW_BOOTS = ITEMS.register("snow_boots", () ->
|
||||
new ArmorItem(ArmorMaterials.DIAMOND, EquipmentSlot.FEET, (new Item.Properties()))
|
||||
new ArmorItem(ArmorMaterials.DIAMOND, ArmorItem.Type.BOOTS, (new Item.Properties()))
|
||||
{
|
||||
@Override
|
||||
public boolean canWalkOnPowderedSnow(ItemStack stack, LivingEntity wearer) {
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ package net.minecraftforge.debug.recipe.recipebook;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.RecipeBookCategories;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
@@ -26,7 +27,7 @@ public class RecipeBookExtensionClientHelper
|
||||
event.registerAggregateCategory(TESTING_SEARCH.get(), ImmutableList.of(TESTING_CAT_1.get(), TESTING_CAT_2.get()));
|
||||
event.registerRecipeCategoryFinder(RecipeBookExtensionTest.RECIPE_BOOK_TEST_RECIPE_TYPE.get(), r ->
|
||||
{
|
||||
if (r.getResultItem().getItem() == Items.DIAMOND_BLOCK)
|
||||
if (r.getResultItem(Minecraft.getInstance().level.registryAccess()).getItem() == Items.DIAMOND_BLOCK)
|
||||
return TESTING_CAT_1.get();
|
||||
else return TESTING_CAT_2.get();
|
||||
});
|
||||
|
||||
@@ -166,7 +166,7 @@ public class RecipeBookTestMenu extends RecipeBookMenu<RecipeBookTestContainer>
|
||||
if (recipe.isEmpty())
|
||||
this.resultContainer.setItem(0, ItemStack.EMPTY);
|
||||
else if (player instanceof ServerPlayer sp && this.resultContainer.setRecipeUsed(level, sp, recipe.get())) {
|
||||
ItemStack stack = recipe.get().assemble(this.container);
|
||||
ItemStack stack = recipe.get().assemble(this.container, level.registryAccess());
|
||||
this.resultContainer.setItem(0, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.mojang.serialization.Dynamic;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
@@ -95,9 +96,9 @@ public class RecipeBookTestRecipe implements Recipe<RecipeBookExtensionTest.Reci
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(RecipeBookExtensionTest.RecipeBookTestContainer p_44001_)
|
||||
public ItemStack assemble(RecipeBookExtensionTest.RecipeBookTestContainer p_44001_, RegistryAccess registryAccess)
|
||||
{
|
||||
return this.getResultItem().copy();
|
||||
return this.getResultItem(registryAccess).copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,7 +108,7 @@ public class RecipeBookTestRecipe implements Recipe<RecipeBookExtensionTest.Reci
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResultItem()
|
||||
public ItemStack getResultItem(RegistryAccess registryAccess)
|
||||
{
|
||||
return this.ingredients.result();
|
||||
}
|
||||
@@ -160,7 +161,7 @@ public class RecipeBookTestRecipe implements Recipe<RecipeBookExtensionTest.Reci
|
||||
public record Ingredients(String group, List<String> pattern, Map<String, Ingredient> recipe, ItemStack result)
|
||||
{
|
||||
private static final Function<String, DataResult<String>> VERIFY_LENGTH_2 = s -> s.length() == 2 ? DataResult.success(s) :
|
||||
DataResult.error("Key row length must be of 2!");
|
||||
DataResult.error(() -> "Key row length must be of 2!");
|
||||
private static final Function<List<String>, DataResult<List<String>>> VERIFY_SIZE = l ->
|
||||
{
|
||||
if (l.size() <= 4 && l.size() >= 1)
|
||||
@@ -169,10 +170,10 @@ public class RecipeBookTestRecipe implements Recipe<RecipeBookExtensionTest.Reci
|
||||
Collections.reverse(temp); //reverse so the first row is at the bottom in the json.
|
||||
return DataResult.success(ImmutableList.copyOf(temp));
|
||||
}
|
||||
return DataResult.error("Pattern must have between 1 and 4 rows of keys");
|
||||
return DataResult.error(() -> "Pattern must have between 1 and 4 rows of keys");
|
||||
};
|
||||
private static final Function<String, DataResult<String>> VERIFY_LENGTH_1 = s -> s.length() == 1 ? DataResult.success(s) :
|
||||
DataResult.error("Key must be a single character!");
|
||||
DataResult.error(() -> "Key must be a single character!");
|
||||
|
||||
public static final Codec<Ingredient> INGREDIENT_CODEC = Codec.PASSTHROUGH.comapFlatMap(obj ->
|
||||
{
|
||||
@@ -183,7 +184,7 @@ public class RecipeBookTestRecipe implements Recipe<RecipeBookExtensionTest.Reci
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return DataResult.error("Failed to parse ingredient: " + e.getMessage());
|
||||
return DataResult.error(() -> "Failed to parse ingredient: " + e.getMessage());
|
||||
}
|
||||
}, ingredient -> new Dynamic<>(JsonOps.INSTANCE, ingredient.toJson()));
|
||||
|
||||
|
||||
+3
-2
@@ -7,6 +7,7 @@ package net.minecraftforge.debug.recipe.recipebook;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
@@ -26,13 +27,13 @@ public class RecipeBookTestRecipeSerializer implements RecipeSerializer<RecipeBo
|
||||
@Override
|
||||
public RecipeBookTestRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf)
|
||||
{
|
||||
Ingredients ingredients = buf.readWithCodec(Ingredients.CODEC);
|
||||
Ingredients ingredients = buf.readWithCodec(NbtOps.INSTANCE, Ingredients.CODEC);
|
||||
return new RecipeBookTestRecipe(id, ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(FriendlyByteBuf buffer, RecipeBookTestRecipe recipe)
|
||||
{
|
||||
buffer.writeWithCodec(Ingredients.CODEC, recipe.ingredients);
|
||||
buffer.writeWithCodec(NbtOps.INSTANCE, Ingredients.CODEC, recipe.ingredients);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
package net.minecraftforge.debug.world;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@@ -73,7 +74,7 @@ public class BiomeModifierTest
|
||||
private static final RegistryObject<Codec<TestModifier>> MODIFY_BIOMES = BIOME_MODIFIER_SERIALIZERS.register("modify_biomes", () ->
|
||||
RecordCodecBuilder.create(builder -> builder.group(
|
||||
Biome.LIST_CODEC.fieldOf("biomes").forGetter(TestModifier::biomes),
|
||||
Precipitation.CODEC.fieldOf("precipitation").forGetter(TestModifier::precipitation),
|
||||
Codec.STRING.xmap(s -> Precipitation.valueOf(s.toUpperCase(Locale.ROOT)), e -> e.name().toLowerCase(Locale.ROOT)).fieldOf("precipitation").forGetter(TestModifier::precipitation),
|
||||
Codec.INT.fieldOf("water_color").forGetter(TestModifier::waterColor)
|
||||
).apply(builder, TestModifier::new))
|
||||
);
|
||||
@@ -167,7 +168,7 @@ public class BiomeModifierTest
|
||||
{
|
||||
if (phase == Phase.MODIFY && this.biomes.contains(biome))
|
||||
{
|
||||
builder.getClimateSettings().setPrecipitation(this.precipitation);
|
||||
builder.getClimateSettings().setHasPrecipitation(true);
|
||||
builder.getSpecialEffects().waterColor(this.waterColor);
|
||||
if (this.precipitation == Precipitation.SNOW)
|
||||
builder.getClimateSettings().setTemperature(0F);
|
||||
|
||||
Reference in new issue
Block a user