This commit is contained in:
modmuss50 2022-04-06 21:49:45 +01:00
parent 09a7afff2f
commit 717abbc48a
25 changed files with 94 additions and 100 deletions
fabric-data-generation-api-v1/src/main/resources
fabric-gametest-api-v1/src/main/java/net/fabricmc/fabric/mixin/gametest
fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item
fabric-models-v0/src/testmod/java/net/fabricmc/fabric/test/model
fabric-object-builder-api-v1/src
main/java/net/fabricmc/fabric/mixin/object/builder
testmod/java/net/fabricmc/fabric/test/object/builder
fabric-particles-v1/src/main/java/net/fabricmc/fabric/impl/client/particle
fabric-renderer-api-v1/src
main/java/net/fabricmc/fabric
testmod/java/net/fabricmc/fabric/test/renderer/simple/client
fabric-renderer-indigo/src/main/java/net/fabricmc/fabric
fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader
fabric-screen-api-v1/src/testmod/java/net/fabricmc/fabric/test/screen
fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer
gradle.properties

View file

@ -42,7 +42,7 @@ transitive-accessible method net/minecraft/data/server/RecipeProvider offerPlank
transitive-accessible method net/minecraft/data/server/RecipeProvider offerPlanksRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/tag/TagKey;)V
transitive-accessible method net/minecraft/data/server/RecipeProvider offerBarkBlockRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V
transitive-accessible method net/minecraft/data/server/RecipeProvider offerBoatRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V
transitive-accessible method net/minecraft/data/server/RecipeProvider method_42754 (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V
transitive-accessible method net/minecraft/data/server/RecipeProvider offerChestBoatRecipe (Ljava/util/function/Consumer;Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/item/ItemConvertible;)V
transitive-accessible method net/minecraft/data/server/RecipeProvider createTransmutationRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder;
transitive-accessible method net/minecraft/data/server/RecipeProvider createDoorRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder;
transitive-accessible method net/minecraft/data/server/RecipeProvider createFenceRecipe (Lnet/minecraft/item/ItemConvertible;Lnet/minecraft/recipe/Ingredient;)Lnet/minecraft/data/server/recipe/CraftingRecipeJsonBuilder;
@ -228,7 +228,7 @@ transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator d
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator glowLichenDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator leavesDrop (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator oakLeavesDrop (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;[F)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator method_42752 (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator mangroveLeavesDrop (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator cropDrops (Lnet/minecraft/block/Block;Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/loot/condition/LootCondition$Builder;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator seagrassDrops (Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder;
transitive-accessible method net/minecraft/data/server/BlockLootTableGenerator tallGrassDrops (Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;)Lnet/minecraft/loot/LootTable$Builder;

View file

@ -20,11 +20,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper;
@ -45,7 +45,12 @@ public abstract class StructureTestUtilMixin {
Identifier structureId = new Identifier(baseId.getNamespace(), GAMETEST_STRUCTURE_PATH + baseId.getPath() + ".snbt");
try {
Resource resource = world.getServer().getResourceManager().getResource(structureId);
Resource resource = world.getServer().getResourceManager().getResource(structureId).orElse(null);
if (resource == null) {
throw new RuntimeException("Unable to get resource: " + structureId);
}
String snbt;
try (InputStream inputStream = resource.getInputStream()) {

View file

@ -49,7 +49,7 @@ public abstract class ItemStackMixin {
this.fabric_breakCallback = breakCallback;
}
@ModifyArg(method = "damage(ILnet/minecraft/entity/LivingEntity;Ljava/util/function/Consumer;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;damage(ILjava/util/Random;Lnet/minecraft/server/network/ServerPlayerEntity;)Z"), index = 0)
@ModifyArg(method = "damage(ILnet/minecraft/entity/LivingEntity;Ljava/util/function/Consumer;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;damage(ILnet/minecraft/world/gen/random/AbstractRandom;Lnet/minecraft/server/network/ServerPlayerEntity;)Z"), index = 0)
private int hookDamage(int amount) {
CustomDamageHandler handler = ((ItemExtensions) getItem()).fabric_getCustomDamageHandler();
@ -61,7 +61,7 @@ public abstract class ItemStackMixin {
}
@Inject(method = "damage(ILnet/minecraft/entity/LivingEntity;Ljava/util/function/Consumer;)V", at = @At("RETURN"))
private <T extends LivingEntity> void clearDamager(int amount, T entity, Consumer<T> breakCallback, CallbackInfo ci) {
private <T extends LivingEntity> void clearDamage(int amount, T entity, Consumer<T> breakCallback, CallbackInfo ci) {
this.fabric_damagingEntity = null;
this.fabric_breakCallback = null;
}

View file

@ -16,8 +16,6 @@
package net.fabricmc.fabric.test.model;
import java.util.Random;
import org.apache.commons.lang3.ArrayUtils;
import net.minecraft.client.render.OverlayTexture;
@ -26,10 +24,11 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Direction;
import net.minecraft.world.gen.random.AbstractRandom;
public class BakedModelRenderer {
private static final Direction[] CULL_FACES = ArrayUtils.add(Direction.values(), null);
private static final Random RANDOM = new Random();
private static final AbstractRandom RANDOM = AbstractRandom.method_43047();
public static void renderBakedModel(BakedModel model, VertexConsumer vertices, MatrixStack.Entry entry, int light) {
for (Direction cullFace : CULL_FACES) {

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.mixin.object.builder;
import java.util.Random;
import java.util.stream.Stream;
import org.spongepowered.asm.mixin.Mixin;
@ -30,6 +29,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.registry.DefaultedRegistry;
import net.minecraft.village.TradeOffer;
import net.minecraft.world.gen.random.AbstractRandom;
@Mixin(targets = "net/minecraft/village/TradeOffers$TypeAwareBuyForOneEmeraldFactory")
public abstract class TypeAwareTradeMixin {
@ -47,8 +47,8 @@ public abstract class TypeAwareTradeMixin {
/**
* To prevent "item" -> "air" trades, if the result of a type aware trade is air, make sure no offer is created.
*/
@Inject(method = "create(Lnet/minecraft/entity/Entity;Ljava/util/Random;)Lnet/minecraft/village/TradeOffer;", at = @At(value = "NEW", target = "net/minecraft/village/TradeOffer"), locals = LocalCapture.CAPTURE_FAILEXCEPTION, cancellable = true)
private void failOnNullItem(Entity entity, Random random, CallbackInfoReturnable<TradeOffer> cir, ItemStack buyingItem) {
@Inject(method = "create", at = @At(value = "NEW", target = "net/minecraft/village/TradeOffer"), locals = LocalCapture.CAPTURE_FAILEXCEPTION, cancellable = true)
private void failOnNullItem(Entity entity, AbstractRandom random, CallbackInfoReturnable<TradeOffer> cir, ItemStack buyingItem) {
if (buyingItem.isEmpty()) { // Will return true for an "empty" item stack that had null passed in the ctor
cir.setReturnValue(null); // Return null to prevent creation of empty trades
}

View file

@ -16,11 +16,10 @@
package net.fabricmc.fabric.test.object.builder;
import java.util.Random;
import net.minecraft.entity.Entity;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOffers;
import net.minecraft.world.gen.random.AbstractRandom;
class SimpleTradeFactory implements TradeOffers.Factory {
private final TradeOffer offer;
@ -30,7 +29,7 @@ class SimpleTradeFactory implements TradeOffers.Factory {
}
@Override
public TradeOffer create(Entity entity, Random random) {
public TradeOffer create(Entity entity, AbstractRandom random) {
// ALWAYS supply a copy of the offer.
return new TradeOffer(this.offer.toNbt());
}

View file

@ -21,8 +21,6 @@ import static net.minecraft.command.argument.EntityArgumentType.getEntity;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
import java.util.Random;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.entity.Entity;
@ -33,6 +31,7 @@ import net.minecraft.text.LiteralText;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOffers;
import net.minecraft.village.VillagerProfession;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
@ -69,7 +68,7 @@ public class VillagerTypeTest1 implements ModInitializer {
for (TradeOffers.Factory[] value : TradeOffers.WANDERING_TRADER_TRADES.values()) {
for (TradeOffers.Factory factory : value) {
final TradeOffer result = factory.create(trader, new Random());
final TradeOffer result = factory.create(trader, AbstractRandom.method_43047());
if (result == null) {
continue;

View file

@ -17,12 +17,12 @@
package net.fabricmc.fabric.impl.client.particle;
import java.util.List;
import java.util.Random;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.client.particle.v1.FabricSpriteProvider;
import net.fabricmc.fabric.mixin.client.particle.ParticleManagerAccessor;
@ -52,7 +52,7 @@ public class FabricSpriteProviderImpl implements FabricSpriteProvider {
}
@Override
public Sprite getSprite(Random random) {
public Sprite getSprite(AbstractRandom random) {
return delegate.getSprite(random);
}
}

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.api.renderer.v1.model;
import java.util.Random;
import java.util.function.Supplier;
import net.minecraft.block.BlockState;
@ -27,6 +26,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.Renderer;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
@ -42,7 +42,7 @@ import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
*/
public interface FabricBakedModel {
/**
* When true, signals renderer this producer is implemented through {@link BakedModel#getQuads(BlockState, net.minecraft.util.math.Direction, Random)}.
* When true, signals renderer this producer is implemented through {@link BakedModel#getQuads(BlockState, net.minecraft.util.math.Direction, AbstractRandom)}.
* Also means the model does not rely on any non-vanilla features.
* Allows the renderer to optimize or route vanilla models through the unmodified vanilla pipeline if desired.
*
@ -64,7 +64,7 @@ public interface FabricBakedModel {
* <p>Also called to render block models outside of chunk rebuild or block entity rendering.
* Typically this happens when the block is being rendered as an entity, not as a block placed in the world.
* Currently this happens for falling blocks and blocks being pushed by a piston, but renderers
* should invoke this for all calls to {@link BlockModelRenderer#render(BlockRenderView, BakedModel, BlockState, BlockPos, MatrixStack, VertexConsumer, boolean, Random, long, int)}
* should invoke this for all calls to {@link BlockModelRenderer#render(BlockRenderView, BakedModel, BlockState, BlockPos, MatrixStack, VertexConsumer, boolean, AbstractRandom, long, int)}
* that occur outside of chunk rebuilds to allow for features added by mods, unless
* {@link #isVanillaAdapter()} returns true.
*
@ -78,7 +78,7 @@ public interface FabricBakedModel {
* neighboring blocks (if appropriate). Models only need to consider "sides" to the
* extent the model is driven by connection with neighbor blocks or other world state.
*
* <p>Note: with {@link BakedModel#getQuads(BlockState, net.minecraft.util.math.Direction, Random)}, the random
* <p>Note: with {@link BakedModel#getQuads(BlockState, net.minecraft.util.math.Direction, AbstractRandom)}, the random
* parameter is normally initialized with the same seed prior to each face layer.
* Model authors should note this method is called only once per block, and call the provided
* Random supplier multiple times if re-seeding is necessary. For wrapped vanilla baked models,
@ -94,7 +94,7 @@ public interface FabricBakedModel {
* Will not be thread-safe. Do not cache or retain a reference.
* @param context Accepts model output.
*/
void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context);
void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<AbstractRandom> randomSupplier, RenderContext context);
/**
* This method will be called during item rendering to generate both the static and
@ -123,5 +123,5 @@ public interface FabricBakedModel {
* logic here, instead of returning every possible shape from {@link BakedModel#getOverrides}
* as vanilla baked models.
*/
void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context);
void emitItemQuads(ItemStack stack, Supplier<AbstractRandom> randomSupplier, RenderContext context);
}

View file

@ -17,7 +17,6 @@
package net.fabricmc.fabric.api.renderer.v1.model;
import java.util.List;
import java.util.Random;
import java.util.function.Supplier;
import net.minecraft.block.BlockState;
@ -30,6 +29,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
@ -42,7 +42,7 @@ public abstract class ForwardingBakedModel implements BakedModel, FabricBakedMod
protected BakedModel wrapped;
@Override
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
((FabricBakedModel) wrapped).emitBlockQuads(blockView, state, pos, randomSupplier, context);
}
@ -52,12 +52,12 @@ public abstract class ForwardingBakedModel implements BakedModel, FabricBakedMod
}
@Override
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
public void emitItemQuads(ItemStack stack, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
((FabricBakedModel) wrapped).emitItemQuads(stack, randomSupplier, context);
}
@Override
public List<BakedQuad> getQuads(BlockState blockState, Direction face, Random rand) {
public List<BakedQuad> getQuads(BlockState blockState, Direction face, AbstractRandom rand) {
return wrapped.getQuads(blockState, face, rand);
}

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.mixin.renderer.client;
import java.util.Random;
import java.util.function.Supplier;
import org.spongepowered.asm.mixin.Mixin;
@ -26,6 +25,7 @@ import net.minecraft.client.render.model.BakedModel;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
@ -41,12 +41,12 @@ public interface MixinBakedModel extends FabricBakedModel {
}
@Override
default void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
default void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
context.fallbackConsumer().accept((BakedModel) this);
}
@Override
default void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
default void emitItemQuads(ItemStack stack, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
context.fallbackConsumer().accept((BakedModel) this);
}
}

View file

@ -19,7 +19,6 @@ package net.fabricmc.fabric.mixin.renderer.client;
import java.util.BitSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.function.Predicate;
import java.util.function.Supplier;
@ -38,6 +37,7 @@ import net.minecraft.client.render.model.MultipartBakedModel;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
@ -71,7 +71,7 @@ public class MixinMultipartBakedModel implements FabricBakedModel {
}
@Override
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
BitSet bitSet = this.stateCache.get(state);
if (bitSet == null) {
@ -95,7 +95,7 @@ public class MixinMultipartBakedModel implements FabricBakedModel {
}
@Override
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
public void emitItemQuads(ItemStack stack, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
// Vanilla doesn't use MultipartBakedModel for items.
}
}

View file

@ -17,7 +17,6 @@
package net.fabricmc.fabric.mixin.renderer.client;
import java.util.List;
import java.util.Random;
import java.util.function.Supplier;
import org.spongepowered.asm.mixin.Final;
@ -36,6 +35,7 @@ import net.minecraft.util.collection.Weighted;
import net.minecraft.util.collection.Weighting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
@ -67,7 +67,7 @@ public class MixinWeightedBakedModel implements FabricBakedModel {
}
@Override
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
Weighted.Present<BakedModel> selected = Weighting.getAt(this.models, Math.abs((int) randomSupplier.get().nextLong()) % this.totalWeight).orElse(null);
if (selected != null) {
@ -76,7 +76,7 @@ public class MixinWeightedBakedModel implements FabricBakedModel {
}
@Override
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
public void emitItemQuads(ItemStack stack, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
Weighted.Present<BakedModel> selected = Weighting.getAt(this.models, Math.abs((int) randomSupplier.get().nextLong()) % this.totalWeight).orElse(null);
if (selected != null) {

View file

@ -18,7 +18,6 @@ package net.fabricmc.fabric.test.renderer.simple.client;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.function.Supplier;
import org.jetbrains.annotations.Nullable;
@ -35,6 +34,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView;
@ -53,7 +53,7 @@ final class FrameBakedModel implements BakedModel, FabricBakedModel {
}
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction face, Random random) {
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction face, AbstractRandom random) {
return Collections.emptyList(); // Renderer API makes this obsolete, so return no quads
}
@ -98,7 +98,7 @@ final class FrameBakedModel implements BakedModel, FabricBakedModel {
}
@Override
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
public void emitBlockQuads(BlockRenderView blockView, BlockState state, BlockPos pos, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
// Emit our frame mesh
context.meshConsumer().accept(this.frameMesh);
@ -131,7 +131,7 @@ final class FrameBakedModel implements BakedModel, FabricBakedModel {
}
@Override
public void emitItemQuads(ItemStack stack, Supplier<Random> randomSupplier, RenderContext context) {
public void emitItemQuads(ItemStack stack, Supplier<AbstractRandom> randomSupplier, RenderContext context) {
// TODO: Implement an item test.
// For now we will just leave this as I have not added a block item yet
}

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.impl.client.indigo.renderer.render;
import java.util.Random;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@ -26,11 +25,12 @@ import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Matrix3f;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Matrix3f;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter;
@ -50,9 +50,9 @@ public class BlockRenderContext extends AbstractRenderContext implements RenderC
private boolean didOutput = false;
// These are kept as fields to avoid avoid the heap allocation for a supplier.
// BlockModelRenderer allows the caller to supply both the random object and seed.
private Random random;
private AbstractRandom random;
private long seed;
private final Supplier<Random> randomSupplier = () -> {
private final Supplier<AbstractRandom> randomSupplier = () -> {
random.setSeed(seed);
return random;
};
@ -96,7 +96,7 @@ public class BlockRenderContext extends AbstractRenderContext implements RenderC
return bufferBuilder;
}
public boolean render(BlockRenderView blockView, BakedModel model, BlockState state, BlockPos pos, MatrixStack matrixStack, VertexConsumer buffer, Random random, long seed, int overlay) {
public boolean render(BlockRenderView blockView, BakedModel model, BlockState state, BlockPos pos, MatrixStack matrixStack, VertexConsumer buffer, AbstractRandom random, long seed, int overlay) {
this.bufferBuilder = buffer;
this.matrix = matrixStack.peek().getPositionMatrix();
this.normalMatrix = matrixStack.peek().getNormalMatrix();

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.impl.client.indigo.renderer.render;
import java.util.Random;
import java.util.function.Supplier;
import net.minecraft.block.BlockState;
@ -27,6 +26,7 @@ import net.minecraft.client.render.RenderLayers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
@ -39,7 +39,7 @@ import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
*/
public class BlockRenderInfo {
private final BlockColors blockColorMap = MinecraftClient.getInstance().getBlockColors();
public final Random random = new Random();
private final AbstractRandom random = AbstractRandom.method_43047();
public BlockRenderView blockView;
public BlockPos blockPos;
public BlockState blockState;
@ -47,8 +47,8 @@ public class BlockRenderInfo {
boolean defaultAo;
RenderLayer defaultLayer;
public final Supplier<Random> randomSupplier = () -> {
final Random result = random;
public final Supplier<AbstractRandom> randomSupplier = () -> {
final AbstractRandom result = random;
long seed = this.seed;
if (seed == -1L) {

View file

@ -17,7 +17,6 @@
package net.fabricmc.fabric.impl.client.indigo.renderer.render;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;
import java.util.function.Supplier;
@ -34,10 +33,11 @@ import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.render.model.json.ModelTransformation.Mode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3f;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
@ -68,7 +68,7 @@ public class ItemRenderContext extends AbstractRenderContext implements RenderCo
}
private final ItemColors colorMap;
private final Random random = new Random();
private final AbstractRandom random = AbstractRandom.method_43047();
private final Consumer<BakedModel> fallbackConsumer;
private final Vec3f normalVec = new Vec3f();
@ -84,8 +84,8 @@ public class ItemRenderContext extends AbstractRenderContext implements RenderCo
private ItemStack itemStack;
private VanillaQuadHandler vanillaHandler;
private final Supplier<Random> randomSupplier = () -> {
final Random result = random;
private final Supplier<AbstractRandom> randomSupplier = () -> {
final AbstractRandom result = random;
result.setSeed(ITEM_RANDOM_SEED);
return random;
};

View file

@ -17,7 +17,6 @@
package net.fabricmc.fabric.impl.client.indigo.renderer.render;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@ -28,6 +27,7 @@ import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.util.math.Direction;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter;
import net.fabricmc.fabric.api.renderer.v1.model.ModelHelper;
@ -82,7 +82,7 @@ public abstract class TerrainFallbackConsumer extends AbstractQuadRenderer imple
@Override
public void accept(BakedModel model) {
final Supplier<Random> random = blockInfo.randomSupplier;
final Supplier<AbstractRandom> random = blockInfo.randomSupplier;
final Value defaultMaterial = blockInfo.defaultAo && model.useAmbientOcclusion() ? MATERIAL_SHADED : MATERIAL_FLAT;
final BlockState blockState = blockInfo.blockState;

View file

@ -17,7 +17,6 @@
package net.fabricmc.fabric.mixin.client.indigo.renderer;
import java.util.BitSet;
import java.util.Random;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -34,6 +33,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.impl.client.indigo.renderer.accessor.AccessBlockModelRenderer;
@ -47,8 +47,8 @@ public abstract class MixinBlockModelRenderer implements AccessBlockModelRendere
private final ThreadLocal<BlockRenderContext> CONTEXTS = ThreadLocal.withInitial(BlockRenderContext::new);
@Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLjava/util/Random;JI)Z", cancellable = true)
private void hookRender(BlockRenderView blockView, BakedModel model, BlockState state, BlockPos pos, MatrixStack matrix, VertexConsumer buffer, boolean checkSides, Random rand, long seed, int overlay, CallbackInfoReturnable<Boolean> ci) {
@Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/world/gen/random/AbstractRandom;JI)Z", cancellable = true)
private void hookRender(BlockRenderView blockView, BakedModel model, BlockState state, BlockPos pos, MatrixStack matrix, VertexConsumer buffer, boolean checkSides, AbstractRandom rand, long seed, int overlay, CallbackInfoReturnable<Boolean> ci) {
if (!((FabricBakedModel) model).isVanillaAdapter()) {
BlockRenderContext context = CONTEXTS.get();
// Note that we do not support face-culling here (so checkSides is ignored)

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.mixin.client.indigo.renderer;
import java.util.Random;
import java.util.Set;
import org.spongepowered.asm.mixin.Mixin;
@ -41,6 +40,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.BlockRenderView;
import net.minecraft.world.gen.random.AbstractRandom;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.impl.client.indigo.Indigo;
@ -85,21 +85,21 @@ public class MixinChunkRebuildTask {
* This is the hook that actually implements the rendering API for terrain rendering.
*
* <p>It's unusual to have a @Redirect in a Fabric library, but in this case
* it is our explicit intention that {@link BlockRenderManager#tesselateBlock(BlockState, BlockPos, BlockRenderView, BufferBuilder, Random)}
* it is our explicit intention that {@link BlockRenderManager#tesselateBlock(BlockState, BlockPos, BlockRenderView, BufferBuilder, AbstractRandom)}
* does not execute for models that will be rendered by our renderer.
*
* <p>Any mod that wants to redirect this specific call is likely also a renderer, in which case this
* renderer should not be present, or the mod should probably instead be relying on the renderer API
* which was specifically created to provide for enhanced terrain rendering.
*
* <p>Note also that {@link BlockRenderManager#tesselateBlock(BlockState, BlockPos, BlockRenderView, BufferBuilder, Random)}
* <p>Note also that {@link BlockRenderManager#tesselateBlock(BlockState, BlockPos, BlockRenderView, BufferBuilder, AbstractRandom)}
* IS called if the block render type is something other than {@link BlockRenderType#MODEL}.
* Normally this does nothing but will allow mods to create rendering hooks that are
* driven off of render type. (Not recommended or encouraged, but also not prevented.)
*/
@Redirect(method = "Lnet/minecraft/client/render/chunk/ChunkBuilder$BuiltChunk$RebuildTask;render(FFFLnet/minecraft/client/render/chunk/ChunkBuilder$ChunkData;Lnet/minecraft/client/render/chunk/BlockBufferBuilderStorage;)Ljava/util/Set;", require = 1, at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/render/block/BlockRenderManager;renderBlock(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLjava/util/Random;)Z"))
private boolean hookChunkBuildTesselate(BlockRenderManager renderManager, BlockState blockState, BlockPos blockPos, BlockRenderView blockView, MatrixStack matrix, VertexConsumer bufferBuilder, boolean checkSides, Random random) {
target = "Lnet/minecraft/client/render/block/BlockRenderManager;renderBlock(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/world/gen/random/AbstractRandom;)Z"))
private boolean hookChunkBuildTesselate(BlockRenderManager renderManager, BlockState blockState, BlockPos blockPos, BlockRenderView blockView, MatrixStack matrix, VertexConsumer bufferBuilder, boolean checkSides, AbstractRandom random) {
if (blockState.getRenderType() == BlockRenderType.MODEL) {
final BakedModel model = renderManager.getModel(blockState);

View file

@ -16,15 +16,11 @@
package net.fabricmc.fabric.mixin.resource.loader;
import java.io.IOException;
import java.io.InputStream;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.resource.NamespaceResourceManager;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
@ -33,9 +29,6 @@ public interface NamespaceResourceManagerAccessor {
@Accessor("type")
ResourceType getType();
@Invoker("open")
InputStream fabric$accessor_open(Identifier id, ResourcePack pack) throws IOException;
@Invoker("getMetadataPath")
static Identifier fabric$accessor_getMetadataPath(Identifier id) {
throw new UnsupportedOperationException("Invoker injection failed.");

View file

@ -26,8 +26,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.resource.NamespaceResourceManager;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourceRef;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
@ -43,7 +43,7 @@ public class NamespaceResourceManagerMixin {
@Inject(method = "getAllResources",
at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/NamespaceResourceManager;getMetadataPath(Lnet/minecraft/util/Identifier;)Lnet/minecraft/util/Identifier;"),
locals = LocalCapture.CAPTURE_FAILHARD)
private void onGetAllResources(Identifier id, CallbackInfoReturnable<List<ResourceRef>> cir, List<NamespaceResourceManager.Entry> resources) {
private void onGetAllResources(Identifier id, CallbackInfoReturnable<List<Resource>> cir, List<NamespaceResourceManager.Entry> resources) {
this.fabric$getAllResources$resources.set(resources);
}

View file

@ -16,9 +16,6 @@
package net.fabricmc.fabric.test.screen;
import java.util.Random;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.PressableWidget;
@ -27,9 +24,11 @@ import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.gen.random.AbstractRandom;
class SoundButton extends PressableWidget {
private static final Random RANDOM = new Random();
private static final AbstractRandom RANDOM = AbstractRandom.method_43047();
SoundButton(int x, int y, int width, int height) {
super(x, y, width, height, Text.of("Sound Button"));

View file

@ -60,7 +60,7 @@ public class DropperBlockMixin {
ci.cancel();
// We pick a non empty slot. It's not necessarily the same as the one vanilla picked, but that doesn't matter.
int slot = dispenser.chooseNonEmptySlot();
int slot = dispenser.chooseNonEmptySlot(world.random);
if (slot == -1) {
TransferApiImpl.LOGGER.warn("Skipping dropper transfer because the empty slot is unexpectedly -1.");

View file

@ -1,8 +1,8 @@
org.gradle.jvmargs=-Xmx2560M
version=0.49.5
minecraft_version=22w13a
yarn_version=+build.1
version=0.49.6
minecraft_version=22w14a
yarn_version=+build.2
loader_version=0.13.3
prerelease=true
@ -15,39 +15,39 @@ fabric-blockrenderlayer-v1-version=1.1.12
fabric-command-api-v1-version=1.1.11
fabric-commands-v0-version=0.2.10
fabric-containers-v0-version=0.1.21
fabric-content-registries-v0-version=3.0.6
fabric-content-registries-v0-version=3.0.7
fabric-crash-report-info-v1-version=0.1.11
fabric-data-generation-api-v1-version=2.0.9
fabric-data-generation-api-v1-version=2.0.10
fabric-dimensions-v1-version=2.1.19
fabric-entity-events-v1-version=1.4.10
fabric-events-interaction-v0-version=0.4.21
fabric-events-lifecycle-v0-version=0.2.13
fabric-events-lifecycle-v0-version=0.2.14
fabric-game-rule-api-v1-version=1.0.13
fabric-gametest-api-v1-version=1.0.19
fabric-item-api-v1-version=1.3.3
fabric-item-groups-v0-version=0.3.14
fabric-gametest-api-v1-version=1.0.20
fabric-item-api-v1-version=1.3.4
fabric-item-groups-v0-version=0.3.15
fabric-key-binding-api-v1-version=1.0.12
fabric-keybindings-v0-version=0.2.10
fabric-lifecycle-events-v1-version=2.0.2
fabric-loot-tables-v1-version=1.0.11
fabric-mining-level-api-v1-version=2.0.8
fabric-models-v0-version=0.3.6
fabric-mining-level-api-v1-version=2.0.9
fabric-models-v0-version=0.3.7
fabric-networking-api-v1-version=1.0.21
fabric-networking-v0-version=0.3.8
fabric-object-builder-api-v1-version=3.0.0
fabric-particles-v1-version=0.2.12
fabric-object-builder-api-v1-version=3.0.1
fabric-particles-v1-version=1.0.0
fabric-registry-sync-v0-version=0.9.8
fabric-renderer-api-v1-version=0.4.13
fabric-renderer-indigo-version=0.4.17
fabric-renderer-api-v1-version=1.0.0
fabric-renderer-indigo-version=0.4.18
fabric-renderer-registries-v1-version=3.2.11
fabric-rendering-data-attachment-v1-version=0.3.7
fabric-rendering-fluids-v1-version=2.0.2
fabric-rendering-v0-version=1.1.13
fabric-rendering-v1-version=1.10.7
fabric-resource-conditions-api-v1-version=2.0.2
fabric-resource-loader-v0-version=0.4.22
fabric-screen-api-v1-version=1.0.14
fabric-resource-loader-v0-version=0.4.23
fabric-screen-api-v1-version=1.0.15
fabric-screen-handler-api-v1-version=1.1.14
fabric-textures-v0-version=1.0.12
fabric-transfer-api-v1-version=1.5.15
fabric-transfer-api-v1-version=1.5.16
fabric-transitive-access-wideners-v1-version=1.0.1