24w34a (#4046)
Some checks failed
Build / build (21-ubuntu) (push) Has been cancelled
Build / client_test (push) Has been cancelled
Build / server_test (push) Has been cancelled
Build / check_resources (push) Has been cancelled

Co-authored-by: PepperCode1 <44146161+peppercode1@users.noreply.github.com>
This commit is contained in:
modmuss 2024-08-21 18:25:15 +01:00 committed by GitHub
parent 236902d814
commit 2be899094a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 140 additions and 475 deletions

View file

@ -30,37 +30,37 @@ import net.minecraft.nbt.NbtElement;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ProtoChunk;
import net.minecraft.world.chunk.SerializedChunk;
import net.minecraft.world.poi.PointOfInterestStorage;
import net.minecraft.world.storage.StorageKey;
import net.fabricmc.fabric.api.attachment.v1.AttachmentTarget;
import net.fabricmc.fabric.impl.attachment.AttachmentTargetImpl;
@Mixin(ChunkSerializer.class)
abstract class ChunkSerializerMixin {
@Mixin(SerializedChunk.class)
abstract class SerializedChunkMixin {
// Adding a mutable record field like this is likely a bad idea, but I cannot see a better way.
@Unique
@Nullable
private NbtCompound attachmentNbtData;
@Inject(method = "method_61794", at = @At("RETURN"))
private static void storeAttachmentNbtData(HeightLimitView heightLimitView, DynamicRegistryManager dynamicRegistryManager, NbtCompound nbt, CallbackInfoReturnable<ChunkSerializer> cir, @Share("attachmentDataNbt") LocalRef<NbtCompound> attachmentDataNbt) {
final ChunkSerializer serializer = cir.getReturnValue();
@Inject(method = "fromNbt", at = @At("RETURN"))
private static void storeAttachmentNbtData(HeightLimitView heightLimitView, DynamicRegistryManager dynamicRegistryManager, NbtCompound nbt, CallbackInfoReturnable<SerializedChunk> cir, @Share("attachmentDataNbt") LocalRef<NbtCompound> attachmentDataNbt) {
final SerializedChunk serializer = cir.getReturnValue();
if (serializer == null) {
return;
}
if (nbt.contains(AttachmentTarget.NBT_ATTACHMENT_KEY, NbtElement.COMPOUND_TYPE)) {
((ChunkSerializerMixin) (Object) serializer).attachmentNbtData = nbt.getCompound(AttachmentTarget.NBT_ATTACHMENT_KEY);
((SerializedChunkMixin) (Object) serializer).attachmentNbtData = nbt.getCompound(AttachmentTarget.NBT_ATTACHMENT_KEY);
}
}
@Inject(method = "deserialize", at = @At("RETURN"))
@Inject(method = "convert", at = @At("RETURN"))
private void setAttachmentDataInChunk(ServerWorld serverWorld, PointOfInterestStorage pointOfInterestStorage, StorageKey storageKey, ChunkPos chunkPos, CallbackInfoReturnable<ProtoChunk> cir) {
ProtoChunk chunk = cir.getReturnValue();
@ -71,11 +71,11 @@ abstract class ChunkSerializerMixin {
}
}
@Inject(method = "method_61793", at = @At("RETURN"))
private static void storeAttachmentNbtData(ServerWorld world, Chunk chunk, CallbackInfoReturnable<ChunkSerializer> cir) {
@Inject(method = "fromChunk", at = @At("RETURN"))
private static void storeAttachmentNbtData(ServerWorld world, Chunk chunk, CallbackInfoReturnable<SerializedChunk> cir) {
var nbt = new NbtCompound();
((AttachmentTargetImpl) chunk).fabric_writeAttachmentsToNbt(nbt, world.getRegistryManager());
((ChunkSerializerMixin) (Object) cir.getReturnValue()).attachmentNbtData = nbt.getCompound(AttachmentTarget.NBT_ATTACHMENT_KEY);
((SerializedChunkMixin) (Object) cir.getReturnValue()).attachmentNbtData = nbt.getCompound(AttachmentTarget.NBT_ATTACHMENT_KEY);
}
@Inject(method = "serialize", at = @At("RETURN"))

View file

@ -6,7 +6,7 @@
"AttachmentTargetsMixin",
"BannerBlockEntityMixin",
"BlockEntityMixin",
"ChunkSerializerMixin",
"SerializedChunkMixin",
"EntityMixin",
"ServerWorldMixin",
"WorldChunkMixin",

View file

@ -42,14 +42,14 @@ public class ArmorKnockbackResistanceTest implements ModInitializer {
}
private static ArmorMaterial createTestArmorMaterial() {
return new ArmorMaterial(Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> {
map.put(ArmorItem.Type.BOOTS, 1);
map.put(ArmorItem.Type.LEGGINGS, 2);
map.put(ArmorItem.Type.CHESTPLATE, 3);
map.put(ArmorItem.Type.HELMET, 1);
map.put(ArmorItem.Type.BODY, 3);
}),
0,
return new ArmorMaterial(
Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> {
map.put(ArmorItem.Type.BOOTS, 1);
map.put(ArmorItem.Type.LEGGINGS, 2);
map.put(ArmorItem.Type.CHESTPLATE, 3);
map.put(ArmorItem.Type.HELMET, 1);
map.put(ArmorItem.Type.BODY, 3);
}),
SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,
(stack) -> stack.getItem() == Items.LEATHER,
List.of(new ArmorMaterial.Layer(Identifier.of("fabric-item-api-v1-testmod", "wood"))),

View file

@ -55,7 +55,7 @@ public abstract class ClientChunkManagerMixin {
}
}
@Inject(method = "unload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientChunkManager$ClientChunkMap;compareAndSet(ILnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/WorldChunk;)Lnet/minecraft/world/chunk/WorldChunk;"), locals = LocalCapture.CAPTURE_FAILHARD)
@Inject(method = "unload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientChunkManager$ClientChunkMap;method_62893(ILnet/minecraft/world/chunk/WorldChunk;)V"), locals = LocalCapture.CAPTURE_FAILHARD)
private void onChunkUnload(ChunkPos pos, CallbackInfo ci, int i, WorldChunk chunk) {
ClientChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload(this.world, chunk);
}

View file

@ -46,8 +46,8 @@ public final class DelegatingUnbakedModel implements UnbakedModel {
}
@Override
public void method_62326(class_10103 arg, class_10102 arg2) {
arg.method_62642(delegate);
public void resolve(Resolver resolver, ModelType modelType) {
resolver.resolve(delegate);
}
@Override

View file

@ -85,7 +85,7 @@ public class ModelLoadingEventDispatcher {
}
}
public BlockStatesLoader.class_10095 loadBlockStateModels() {
public BlockStatesLoader.BlockStateDefinition loadBlockStateModels() {
Map<ModelIdentifier, BlockStatesLoader.BlockModel> map = new HashMap<>();
pluginContext.blockStateResolvers.forEach((block, resolver) -> {
@ -105,7 +105,7 @@ public class ModelLoadingEventDispatcher {
resolveBlockStates(resolver, block, output);
});
return new BlockStatesLoader.class_10095(map);
return new BlockStatesLoader.BlockStateDefinition(map);
}
private void resolveBlockStates(BlockStateResolver resolver, Block block, BiConsumer<BlockState, UnbakedModel> output) {

View file

@ -35,10 +35,10 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.class_10097;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.render.model.BlockStatesLoader;
import net.minecraft.client.render.model.ReferencedModelsCollector;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.resource.ResourceManager;
@ -79,14 +79,14 @@ abstract class BakedModelManagerMixin implements FabricBakedModelManager {
}
@ModifyExpressionValue(method = "reload", at = @At(value = "INVOKE", target = "net/minecraft/client/render/model/BakedModelManager.reloadBlockStates(Lnet/minecraft/client/render/model/BlockStatesLoader;Lnet/minecraft/resource/ResourceManager;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"))
private CompletableFuture<BlockStatesLoader.class_10095> hookBlockStateModelLoading(CompletableFuture<BlockStatesLoader.class_10095> modelsFuture) {
CompletableFuture<BlockStatesLoader.class_10095> resolvedModelsFuture = eventDispatcherFuture.thenApplyAsync(ModelLoadingEventDispatcher::loadBlockStateModels);
private CompletableFuture<BlockStatesLoader.BlockStateDefinition> hookBlockStateModelLoading(CompletableFuture<BlockStatesLoader.BlockStateDefinition> modelsFuture) {
CompletableFuture<BlockStatesLoader.BlockStateDefinition> resolvedModelsFuture = eventDispatcherFuture.thenApplyAsync(ModelLoadingEventDispatcher::loadBlockStateModels);
return modelsFuture.thenCombine(resolvedModelsFuture, (models, resolvedModels) -> {
Map<ModelIdentifier, BlockStatesLoader.BlockModel> map = models.models();
if (!(map instanceof HashMap)) {
map = new HashMap<>(map);
models = new BlockStatesLoader.class_10095(map);
models = new BlockStatesLoader.BlockStateDefinition(map);
}
map.putAll(resolvedModels.models());
@ -102,17 +102,17 @@ abstract class BakedModelManagerMixin implements FabricBakedModelManager {
ordinal = 0,
remap = false
))
private CompletableFuture<class_10097> hookModelDiscovery(
CompletableFuture<BlockStatesLoader.class_10095> self,
private CompletableFuture<ReferencedModelsCollector> hookModelDiscovery(
CompletableFuture<BlockStatesLoader.BlockStateDefinition> self,
CompletionStage<Map<Identifier, UnbakedModel>> otherFuture,
BiFunction<BlockStatesLoader.class_10095, Map<Identifier, UnbakedModel>, class_10097> function,
BiFunction<BlockStatesLoader.BlockStateDefinition, Map<Identifier, UnbakedModel>, ReferencedModelsCollector> function,
Executor executor) {
CompletableFuture<Pair<BlockStatesLoader.class_10095, Map<Identifier, UnbakedModel>>> pairFuture = self.thenCombine(otherFuture, Pair::new);
CompletableFuture<Pair<BlockStatesLoader.BlockStateDefinition, Map<Identifier, UnbakedModel>>> pairFuture = self.thenCombine(otherFuture, Pair::new);
return pairFuture.thenCombineAsync(eventDispatcherFuture, (pair, eventDispatcher) -> {
ModelLoadingEventDispatcher.CURRENT.set(eventDispatcher);
class_10097 class_10097 = function.apply(pair.getLeft(), pair.getRight());
ReferencedModelsCollector referencedModelsCollector = function.apply(pair.getLeft(), pair.getRight());
ModelLoadingEventDispatcher.CURRENT.remove();
return class_10097;
return referencedModelsCollector;
}, executor);
}

View file

@ -29,7 +29,7 @@ import org.spongepowered.asm.mixin.injection.Coerce;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.Baker;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.ModelBaker;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.SpriteIdentifier;
@ -39,16 +39,16 @@ import net.fabricmc.fabric.impl.client.model.loading.BakerImplHooks;
import net.fabricmc.fabric.impl.client.model.loading.ModelLoaderHooks;
import net.fabricmc.fabric.impl.client.model.loading.ModelLoadingEventDispatcher;
@Mixin(targets = "net/minecraft/client/render/model/ModelLoader$BakerImpl")
@Mixin(targets = "net/minecraft/client/render/model/ModelBaker$BakerImpl")
abstract class ModelLoaderBakerImplMixin implements BakerImplHooks {
@Shadow
@Final
private ModelLoader field_40571;
private ModelBaker field_40571;
@Shadow
@Final
private Function<SpriteIdentifier, Sprite> textureGetter;
@WrapOperation(method = "bake(Lnet/minecraft/util/Identifier;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/ModelLoader$BakerImpl;bake(Lnet/minecraft/client/render/model/UnbakedModel;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;"))
@WrapOperation(method = "bake(Lnet/minecraft/util/Identifier;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/ModelBaker$BakerImpl;bake(Lnet/minecraft/client/render/model/UnbakedModel;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;"))
private BakedModel wrapInnerBake(@Coerce Baker self, UnbakedModel unbakedModel, ModelBakeSettings settings, Operation<BakedModel> operation, Identifier id) {
ModelLoadingEventDispatcher dispatcher = ((ModelLoaderHooks) this.field_40571).fabric_getDispatcher();
unbakedModel = dispatcher.modifyModelBeforeBake(unbakedModel, id, null, textureGetter, settings, self);

View file

@ -28,11 +28,11 @@ import org.spongepowered.asm.mixin.injection.Coerce;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.class_10096;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.Baker;
import net.minecraft.client.render.model.MissingModel;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.ModelBaker;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.ModelIdentifier;
@ -43,7 +43,7 @@ import net.fabricmc.fabric.impl.client.model.loading.ModelLoaderHooks;
import net.fabricmc.fabric.impl.client.model.loading.ModelLoadingConstants;
import net.fabricmc.fabric.impl.client.model.loading.ModelLoadingEventDispatcher;
@Mixin(ModelLoader.class)
@Mixin(ModelBaker.class)
abstract class ModelLoaderMixin implements ModelLoaderHooks {
@Unique
@Nullable
@ -54,13 +54,13 @@ abstract class ModelLoaderMixin implements ModelLoaderHooks {
fabric_eventDispatcher = ModelLoadingEventDispatcher.CURRENT.get();
}
@WrapOperation(method = "method_61072(Lnet/minecraft/client/render/model/ModelLoader$SpriteGetter;Lnet/minecraft/client/util/ModelIdentifier;Lnet/minecraft/client/render/model/UnbakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/ModelLoader$BakerImpl;bake(Lnet/minecraft/client/render/model/UnbakedModel;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;"))
private BakedModel wrapSingleOuterBake(@Coerce Baker baker, UnbakedModel unbakedModel, ModelBakeSettings settings, Operation<BakedModel> operation, ModelLoader.SpriteGetter spriteGetter, ModelIdentifier id) {
@WrapOperation(method = "method_61072", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/ModelBaker$BakerImpl;bake(Lnet/minecraft/client/render/model/UnbakedModel;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;"))
private BakedModel wrapSingleOuterBake(@Coerce Baker baker, UnbakedModel unbakedModel, ModelBakeSettings settings, Operation<BakedModel> operation, ModelBaker.SpriteGetter spriteGetter, ModelIdentifier id) {
if (fabric_eventDispatcher == null) {
return operation.call(baker, unbakedModel, settings);
}
if (ModelLoadingConstants.isResourceModelId(id) || id.equals(class_10096.field_53661)) {
if (ModelLoadingConstants.isResourceModelId(id) || id.equals(MissingModel.MODEL_ID)) {
// Call the baker instead of the operation to ensure the baked model is cached and doesn't end up going
// through events twice.
// This ignores the UnbakedModel in field_53662 (top-level model map) but it should be the same as the one in field_53663 (resource model map).

View file

@ -25,8 +25,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.class_10097;
import net.minecraft.client.render.model.BlockStatesLoader;
import net.minecraft.client.render.model.ReferencedModelsCollector;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.util.Identifier;
@ -34,37 +34,37 @@ import net.minecraft.util.Identifier;
import net.fabricmc.fabric.impl.client.model.loading.ModelLoadingConstants;
import net.fabricmc.fabric.impl.client.model.loading.ModelLoadingEventDispatcher;
@Mixin(class_10097.class)
abstract class class_10097Mixin {
@Mixin(ReferencedModelsCollector.class)
abstract class ReferencedModelsCollectorMixin {
@Unique
@Nullable
private ModelLoadingEventDispatcher fabric_eventDispatcher;
@Shadow
abstract UnbakedModel method_62638(Identifier identifier);
abstract UnbakedModel computeResolvedModel(Identifier identifier);
@Shadow
abstract void method_62635(ModelIdentifier modelIdentifier, UnbakedModel unbakedModel);
abstract void addTopLevelModel(ModelIdentifier modelIdentifier, UnbakedModel unbakedModel);
@Inject(method = "<init>", at = @At("RETURN"))
private void onReturnInit(CallbackInfo ci) {
fabric_eventDispatcher = ModelLoadingEventDispatcher.CURRENT.get();
}
@Inject(method = "method_62632", at = @At("RETURN"))
private void onAddStandardModels(BlockStatesLoader.class_10095 blockStateModels, CallbackInfo ci) {
@Inject(method = "addBlockStates", at = @At("RETURN"))
private void onAddStandardModels(BlockStatesLoader.BlockStateDefinition blockStateModels, CallbackInfo ci) {
if (fabric_eventDispatcher == null) {
return;
}
fabric_eventDispatcher.addExtraModels(id -> {
ModelIdentifier modelId = ModelLoadingConstants.toResourceModelId(id);
UnbakedModel unbakedModel = method_62638(id);
method_62635(modelId, unbakedModel);
UnbakedModel unbakedModel = computeResolvedModel(id);
addTopLevelModel(modelId, unbakedModel);
});
}
@ModifyVariable(method = "method_62640", at = @At(value = "STORE", ordinal = 0), ordinal = 0)
@ModifyVariable(method = "getModel", at = @At(value = "STORE", ordinal = 0), ordinal = 0)
@Nullable
private UnbakedModel onLoadResourceModel(@Nullable UnbakedModel model, Identifier id) {
if (fabric_eventDispatcher == null) {
@ -80,7 +80,7 @@ abstract class class_10097Mixin {
return fabric_eventDispatcher.modifyModelOnLoad(model, id, null);
}
@ModifyVariable(method = "method_62635", at = @At("HEAD"), argsOnly = true)
@ModifyVariable(method = "addTopLevelModel", at = @At("HEAD"), argsOnly = true)
private UnbakedModel onAddTopLevelModel(UnbakedModel model, ModelIdentifier modelId) {
if (fabric_eventDispatcher == null) {
return model;

View file

@ -4,7 +4,7 @@
"compatibilityLevel": "JAVA_21",
"client": [
"BakedModelManagerMixin",
"class_10097Mixin",
"ReferencedModelsCollectorMixin",
"ModelLoaderBakerImplMixin",
"ModelLoaderMixin"
],

View file

@ -22,10 +22,10 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.CropBlock;
import net.minecraft.block.HorizontalConnectingBlock;
import net.minecraft.class_10096;
import net.minecraft.client.render.block.BlockModels;
import net.minecraft.client.render.entity.PlayerEntityRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.MissingModel;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.resource.ResourceType;
@ -86,7 +86,7 @@ public class ModelTestModClient implements ClientModInitializer {
ModelIdentifier id = context.topLevelId();
if (id != null && id.equals(fenceId)) {
return new DelegatingUnbakedModel(class_10096.field_53660);
return new DelegatingUnbakedModel(MissingModel.ID);
}
return model;
@ -98,7 +98,7 @@ public class ModelTestModClient implements ClientModInitializer {
Identifier id = context.resourceId();
if (id != null && id.equals(BROWN_GLAZED_TERRACOTTA_MODEL_ID)) {
return context.baker().getOrLoadModel(class_10096.field_53660);
return context.baker().getModel(MissingModel.ID);
}
return model;

View file

@ -207,5 +207,9 @@ public class FabricRegistryInit implements ModInitializer {
// Synced via PacketCodecs.registry
RegistryAttributeHolder.get(Registries.ARMOR_MATERIAL)
.addAttribute(RegistryAttribute.SYNCED);
// Synced via PacketCodecs.registry
RegistryAttributeHolder.get(Registries.field_53967)
.addAttribute(RegistryAttribute.SYNCED);
}
}

View file

@ -21,10 +21,10 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.chunk.SerializedChunk;
@Mixin(ChunkSerializer.class)
public class ChunkSerializerMixin {
@Mixin(SerializedChunk.class)
public class SerializedChunkMixin {
@Redirect(method = "readStructureReferences", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false))
private static void log(Logger logger, String msg, Object identifier, Object chunkPos) {
// Drop to debug log level.

View file

@ -5,7 +5,7 @@
"mixins": [
"BlocksMixin",
"BootstrapMixin",
"ChunkSerializerMixin",
"SerializedChunkMixin",
"DebugChunkGeneratorAccessor",
"ExperimentalRegistriesValidatorMixin",
"IdListMixin",

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.api.renderer.v1.mesh;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector2f;
import org.joml.Vector2fc;
@ -303,29 +302,7 @@ public interface MutableQuadView extends QuadView {
*
* <p>Calling this method does not emit the quad.
*/
default MutableQuadView fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace) {
return fromVanilla(quad, material, cullFace, true);
}
// TODO: If this is unmarked as experimental, update the javadoc of the other overloads.
/**
* Enables bulk vertex data transfer using the standard Minecraft quad format.
*
* <p>The material applied to this quad view might be slightly different from the {@code material} parameter regarding diffuse shading.
* If either the baked quad {@link BakedQuad#hasShade() does not have shade} or the material {@link MaterialFinder#disableDiffuse(boolean) does not have shade},
* diffuse shading will be disabled for this quad view.
* This is reflected in the quad view's {@link #material()}, but the {@code material} parameter is unchanged (it is immutable anyway).
*
* <p>If {@code applyLightEmission} is {@code true}, the {@linkplain BakedQuad#getLightEmission() baked quad's light emission} will be applied
* to the lightmap values from the vertex data after copying. Otherwise, the light emission will be ignored.
*
* <p>Calling this method does not emit the quad.
*
* @apiNote This method is marked as experimental because future snapshots may change the item renderer to also respect quad light emission,
* in which case this method will be removed. See <a href="https://bugs.mojang.com/browse/MC-275296">MC-275296</a>.
*/
@ApiStatus.Experimental
MutableQuadView fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace, boolean applyLightEmission);
MutableQuadView fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace);
/**
* @deprecated Use {@link #color(int, int)} instead.

View file

@ -16,7 +16,6 @@
package net.fabricmc.fabric.api.renderer.v1.mesh;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector2f;
import org.joml.Vector2fc;
@ -139,14 +138,7 @@ public interface QuadEmitter extends MutableQuadView {
QuadEmitter fromVanilla(int[] quadData, int startIndex);
@Override
default QuadEmitter fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace) {
MutableQuadView.super.fromVanilla(quad, material, cullFace);
return this;
}
@ApiStatus.Experimental
@Override
QuadEmitter fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace, boolean applyLightEmission);
QuadEmitter fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace);
/**
* Tolerance for determining if the depth parameter to {@link #square(Direction, float, float, float, float, float)}

View file

@ -78,7 +78,7 @@ public class VanillaModelEncoder {
for (int j = 0; j < count; j++) {
final BakedQuad q = quads.get(j);
emitter.fromVanilla(q, STANDARD_MATERIAL, cullFace, false);
emitter.fromVanilla(q, STANDARD_MATERIAL, cullFace);
emitter.emit();
}
}

View file

@ -40,7 +40,7 @@ public class FrameUnbakedModel implements UnbakedModel {
private static final SpriteIdentifier OBSIDIAN_SPRITE_ID = new SpriteIdentifier(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE, Identifier.ofVanilla("block/obsidian"));
@Override
public void method_62326(class_10103 arg, class_10102 arg2) {
public void resolve(Resolver resolver, ModelType currentlyResolvingType) {
}
/*

View file

@ -55,7 +55,7 @@ public class OctagonalColumnUnbakedModel implements UnbakedModel {
}
@Override
public void method_62326(class_10103 arg, class_10102 arg2) {
public void resolve(Resolver resolver, ModelType currentlyResolvingType) {
}
@Override

View file

@ -38,7 +38,7 @@ public class PillarUnbakedModel implements UnbakedModel {
.toList();
@Override
public void method_62326(class_10103 arg, class_10102 arg2) {
public void resolve(Resolver resolver, ModelType currentlyResolvingType) {
}
@Nullable

View file

@ -33,9 +33,9 @@ public class RiverstoneUnbakedModel implements UnbakedModel {
private static final Identifier GOLD_BLOCK_MODEL_ID = Identifier.ofVanilla("block/gold_block");
@Override
public void method_62326(class_10103 arg, class_10102 arg2) {
arg.method_62642(STONE_MODEL_ID);
arg.method_62642(GOLD_BLOCK_MODEL_ID);
public void resolve(Resolver resolver, ModelType currentlyResolvingType) {
resolver.resolve(STONE_MODEL_ID);
resolver.resolve(GOLD_BLOCK_MODEL_ID);
}
@Nullable

View file

@ -36,7 +36,6 @@ import net.minecraft.block.BlockState;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.block.BlockModelRenderer;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
@ -150,16 +149,14 @@ public abstract class AoCalculator {
private final float[] vanillaAoData = new float[Direction.values().length * 2];
private final BitSet vanillaAoFlags = new BitSet(3);
private final int[] vertexData = new int[EncodingFormat.QUAD_STRIDE];
private final DummyBakedQuad dummyBakedQuad = new DummyBakedQuad();
private void calcVanilla(QuadViewImpl quad, float[] aoDest, int[] lightDest) {
vanillaAoFlags.clear();
final Direction lightFace = quad.lightFace();
quad.toVanilla(vertexData, 0);
dummyBakedQuad.prepare(quad.lightFace(), quad.hasShade());
VanillaAoHelper.getQuadDimensions(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, vertexData, lightFace, vanillaAoData, vanillaAoFlags);
vanillaCalc.apply(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, vanillaAoData, vanillaAoFlags, dummyBakedQuad);
vanillaCalc.apply(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, lightFace, vanillaAoData, vanillaAoFlags, quad.hasShade());
System.arraycopy(vanillaCalc.brightness, 0, aoDest, 0, 4);
System.arraycopy(vanillaCalc.light, 0, lightDest, 0, 4);
@ -584,31 +581,4 @@ public abstract class AoCalculator {
if (b == 0) return a;
return Math.min(a, b);
}
// This quad is passed to the vanilla AO calc. It only calls getFace, isEmissive, getLightEmission, and hasShade.
// Since Indigo already applies vanilla's light emission value in MutableQuadView#fromVanilla, this quad should not
// provide its own light emission.
private static class DummyBakedQuad extends BakedQuad {
private Direction lightFace;
private boolean shade;
DummyBakedQuad() {
super(new int[32], -1, Direction.UP, null, true, 0);
}
public void prepare(Direction lightFace, boolean shade) {
this.lightFace = lightFace;
this.shade = shade;
}
@Override
public Direction getFace() {
return lightFace;
}
@Override
public boolean hasShade() {
return shade;
}
}
}

View file

@ -28,7 +28,7 @@ import net.minecraft.world.BlockRenderView;
public final class VanillaAoHelper {
// Renderer method we call isn't declared as static, but uses no
// instance data and is called from multiple threads in vanilla also.
private static BlockModelRenderer BLOCK_RENDERER = MinecraftClient.getInstance().getBlockRenderManager().getModelRenderer();
private static final BlockModelRenderer BLOCK_RENDERER = MinecraftClient.getInstance().getBlockRenderManager().getModelRenderer();
public static void getQuadDimensions(BlockRenderView blockRenderView, BlockState blockState, BlockPos pos, int[] vertexData, Direction face, float[] aoData, BitSet controlBits) {
BLOCK_RENDERER.getQuadDimensions(blockRenderView, blockState, pos, vertexData, face, aoData, controlBits);

View file

@ -195,7 +195,7 @@ public abstract class MutableQuadViewImpl extends QuadViewImpl implements QuadEm
}
@Override
public final MutableQuadViewImpl fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace, boolean applyLightEmission) {
public final MutableQuadViewImpl fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace) {
fromVanilla(quad.getVertexData(), 0);
data[baseIndex + HEADER_BITS] = EncodingFormat.cullFace(0, cullFace);
nominalFace(quad.getFace());
@ -205,9 +205,9 @@ public abstract class MutableQuadViewImpl extends QuadViewImpl implements QuadEm
material = RenderMaterialImpl.setDisableDiffuse((RenderMaterialImpl) material, true);
}
if (applyLightEmission && quad.isEmissive()) {
int lightEmission = quad.getLightEmission();
int lightEmission = quad.getLightEmission();
if (lightEmission > 0) {
for (int i = 0; i < 4; i++) {
lightmap(i, LightmapTextureManager.applyEmission(lightmap(i), lightEmission));
}

View file

@ -21,7 +21,6 @@ import java.util.function.Supplier;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.RenderLayer;
@ -33,8 +32,6 @@ import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MatrixUtil;
@ -85,7 +82,6 @@ public class ItemRenderContext extends AbstractRenderContext {
private int lightmap;
private boolean isDefaultTranslucent;
private boolean isTranslucentDirect;
private boolean isDefaultGlint;
private boolean isGlintDynamicDisplay;
@ -146,24 +142,7 @@ public class ItemRenderContext extends AbstractRenderContext {
}
private void computeOutputInfo() {
isDefaultTranslucent = true;
isTranslucentDirect = true;
Item item = itemStack.getItem();
if (item instanceof BlockItem blockItem) {
BlockState state = blockItem.getBlock().getDefaultState();
RenderLayer renderLayer = RenderLayers.getBlockLayer(state);
if (renderLayer != RenderLayer.getTranslucent()) {
isDefaultTranslucent = false;
}
if (transformMode != ModelTransformationMode.GUI && !transformMode.isFirstPerson()) {
isTranslucentDirect = false;
}
}
isDefaultTranslucent = RenderLayers.getItemLayer(itemStack) == TexturedRenderLayers.getItemEntityTranslucentCull();
isDefaultGlint = itemStack.hasGlint();
isGlintDynamicDisplay = ItemRendererAccessor.fabric_callUsesDynamicDisplay(itemStack);
}
@ -209,7 +188,7 @@ public class ItemRenderContext extends AbstractRenderContext {
/**
* Caches custom blend mode / vertex consumers and mimics the logic
* in {@code RenderLayers.getEntityBlockLayer}. Layers other than
* in {@code RenderLayers.getItemLayer}. Layers other than
* translucent are mapped to cutout.
*/
private VertexConsumer getVertexConsumer(BlendMode blendMode, TriState glintMode) {
@ -231,13 +210,13 @@ public class ItemRenderContext extends AbstractRenderContext {
if (translucent) {
if (glint) {
if (translucentGlintVertexConsumer == null) {
translucentGlintVertexConsumer = createTranslucentVertexConsumer(true);
translucentGlintVertexConsumer = createVertexConsumer(TexturedRenderLayers.getItemEntityTranslucentCull(), true);
}
return translucentGlintVertexConsumer;
} else {
if (translucentVertexConsumer == null) {
translucentVertexConsumer = createTranslucentVertexConsumer(false);
translucentVertexConsumer = createVertexConsumer(TexturedRenderLayers.getItemEntityTranslucentCull(), false);
}
return translucentVertexConsumer;
@ -245,13 +224,13 @@ public class ItemRenderContext extends AbstractRenderContext {
} else {
if (glint) {
if (cutoutGlintVertexConsumer == null) {
cutoutGlintVertexConsumer = createCutoutVertexConsumer(true);
cutoutGlintVertexConsumer = createVertexConsumer(TexturedRenderLayers.getEntityCutout(), true);
}
return cutoutGlintVertexConsumer;
} else {
if (cutoutVertexConsumer == null) {
cutoutVertexConsumer = createCutoutVertexConsumer(false);
cutoutVertexConsumer = createVertexConsumer(TexturedRenderLayers.getEntityCutout(), false);
}
return cutoutVertexConsumer;
@ -259,40 +238,22 @@ public class ItemRenderContext extends AbstractRenderContext {
}
}
private VertexConsumer createTranslucentVertexConsumer(boolean glint) {
if (glint && isGlintDynamicDisplay) {
return createDynamicDisplayGlintVertexConsumer(MinecraftClient.isFabulousGraphicsOrBetter() && !isTranslucentDirect ? TexturedRenderLayers.getItemEntityTranslucentCull() : TexturedRenderLayers.getEntityTranslucentCull());
}
private VertexConsumer createVertexConsumer(RenderLayer layer, boolean glint) {
if (isGlintDynamicDisplay && glint) {
if (dynamicDisplayGlintEntry == null) {
dynamicDisplayGlintEntry = matrixStack.peek().copy();
if (isTranslucentDirect) {
return ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, TexturedRenderLayers.getEntityTranslucentCull(), true, glint);
} else if (MinecraftClient.isFabulousGraphicsOrBetter()) {
return ItemRenderer.getItemGlintConsumer(vertexConsumerProvider, TexturedRenderLayers.getItemEntityTranslucentCull(), true, glint);
} else {
return ItemRenderer.getItemGlintConsumer(vertexConsumerProvider, TexturedRenderLayers.getEntityTranslucentCull(), true, glint);
}
}
private VertexConsumer createCutoutVertexConsumer(boolean glint) {
if (glint && isGlintDynamicDisplay) {
return createDynamicDisplayGlintVertexConsumer(TexturedRenderLayers.getEntityCutout());
}
return ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, TexturedRenderLayers.getEntityCutout(), true, glint);
}
private VertexConsumer createDynamicDisplayGlintVertexConsumer(RenderLayer layer) {
if (dynamicDisplayGlintEntry == null) {
dynamicDisplayGlintEntry = matrixStack.peek().copy();
if (transformMode == ModelTransformationMode.GUI) {
MatrixUtil.scale(dynamicDisplayGlintEntry.getPositionMatrix(), 0.5F);
} else if (transformMode.isFirstPerson()) {
MatrixUtil.scale(dynamicDisplayGlintEntry.getPositionMatrix(), 0.75F);
if (transformMode == ModelTransformationMode.GUI) {
MatrixUtil.scale(dynamicDisplayGlintEntry.getPositionMatrix(), 0.5F);
} else if (transformMode.isFirstPerson()) {
MatrixUtil.scale(dynamicDisplayGlintEntry.getPositionMatrix(), 0.75F);
}
}
return ItemRenderer.getDynamicDisplayGlintConsumer(vertexConsumerProvider, layer, dynamicDisplayGlintEntry);
}
return ItemRenderer.getDynamicDisplayGlintConsumer(vertexConsumerProvider, layer, dynamicDisplayGlintEntry);
return ItemRenderer.getItemGlintConsumer(vertexConsumerProvider, layer, true, glint);
}
private class BakedModelConsumerImpl implements BakedModelConsumer {

View file

@ -1,45 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.impl.client.rendering;
import java.io.IOException;
import net.minecraft.client.gl.ShaderProgram;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.resource.ResourceFactory;
import net.minecraft.util.Identifier;
public final class FabricShaderProgram extends ShaderProgram {
public FabricShaderProgram(ResourceFactory factory, Identifier name, VertexFormat format) throws IOException {
super(factory, name.toString(), format);
}
/**
* Rewrites the input string containing an identifier
* with the namespace of the id in the front instead of in the middle.
*
* <p>Example: {@code shaders/core/my_mod:xyz} -> {@code my_mod:shaders/core/xyz}
*
* @param input the raw input string
* @param containedId the ID contained within the input string
* @return the corrected full ID string
*/
public static Identifier rewriteAsId(String input, String containedId) {
Identifier contained = Identifier.of(containedId);
return contained.withPath(path -> input.replace(containedId, path));
}
}

View file

@ -30,7 +30,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.PostEffectProcessor;
import net.minecraft.client.option.CloudRenderMode;
import net.minecraft.client.render.BufferBuilderStorage;
import net.minecraft.client.render.Camera;
@ -61,7 +60,6 @@ public abstract class WorldRendererMixin {
@Shadow
private BufferBuilderStorage bufferBuilders;
@Shadow private ClientWorld world;
@Shadow private PostEffectProcessor transparencyPostProcessor;
@Final
@Shadow
private MinecraftClient client;
@ -69,7 +67,7 @@ public abstract class WorldRendererMixin {
@Inject(method = "render", at = @At("HEAD"))
private void beforeRender(ObjectAllocator objectAllocator, RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, Matrix4f projectionMatrix, CallbackInfo ci) {
context.prepare((WorldRenderer) (Object) this, tickCounter, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, projectionMatrix, positionMatrix, bufferBuilders.getEntityVertexConsumers(), world.getProfiler(), transparencyPostProcessor != null, world);
context.prepare((WorldRenderer) (Object) this, tickCounter, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, projectionMatrix, positionMatrix, bufferBuilders.getEntityVertexConsumers(), world.getProfiler(), MinecraftClient.isFabulousGraphicsOrBetter(), world);
WorldRenderEvents.START.invoker().onStart(context);
}
@ -144,7 +142,7 @@ public abstract class WorldRendererMixin {
method = "method_62214",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/debug/DebugRenderer;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;DDD)V",
target = "Lnet/minecraft/client/render/debug/DebugRenderer;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/Frustum;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;DDD)V",
ordinal = 0
)
)

View file

@ -1,53 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.client.rendering.shader;
import java.io.IOException;
import java.util.List;
import java.util.function.Consumer;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.datafixers.util.Pair;
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.CallbackInfo;
import net.minecraft.client.gl.ShaderProgram;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.resource.ResourceFactory;
import net.fabricmc.fabric.api.client.rendering.v1.CoreShaderRegistrationCallback;
import net.fabricmc.fabric.impl.client.rendering.FabricShaderProgram;
/**
* Implements custom core shader registration (CoreShaderRegistrationCallback).
*/
@Mixin(GameRenderer.class)
abstract class GameRendererMixin {
@Inject(
method = "loadPrograms",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;loadBlurPostProcessor(Lnet/minecraft/resource/ResourceFactory;)V")
)
private void registerShaders(ResourceFactory factory, CallbackInfo info, @Local(ordinal = 0) List<?> shaderStages, @Local(ordinal = 1) List<Pair<ShaderProgram, Consumer<ShaderProgram>>> programs) throws IOException {
CoreShaderRegistrationCallback.RegistrationContext context = (id, vertexFormat, loadCallback) -> {
ShaderProgram program = new FabricShaderProgram(factory, id, vertexFormat);
programs.add(Pair.of(program, loadCallback));
};
CoreShaderRegistrationCallback.EVENT.invoker().registerShaders(context);
}
}

View file

@ -1,57 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.client.rendering.shader;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.util.Identifier;
import net.fabricmc.fabric.impl.client.rendering.FabricShaderProgram;
/**
* Lets modded shaders {@code #moj_import} shaders from any namespace with the
* {@code <>} syntax.
*/
@Mixin(targets = "net.minecraft.client.gl.ShaderProgram$1")
abstract class ShaderProgramImportProcessorMixin {
@Unique
private String capturedImport;
@Inject(method = "loadImport", at = @At("HEAD"))
private void captureImport(boolean inline, String name, CallbackInfoReturnable<String> info) {
capturedImport = name;
}
@ModifyVariable(method = "loadImport", at = @At("STORE"), ordinal = 0, argsOnly = true)
private String modifyImportId(String id, boolean inline) {
if (!inline && capturedImport.contains(String.valueOf(Identifier.NAMESPACE_SEPARATOR))) {
return FabricShaderProgram.rewriteAsId(id, capturedImport).toString();
}
return id;
}
@Inject(method = "loadImport", at = @At("RETURN"))
private void uncaptureImport(boolean inline, String name, CallbackInfoReturnable<String> info) {
capturedImport = null;
}
}

View file

@ -1,68 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.client.rendering.shader;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import net.minecraft.client.gl.ShaderProgram;
import net.minecraft.client.gl.ShaderStage;
import net.minecraft.resource.ResourceFactory;
import net.minecraft.util.Identifier;
import net.fabricmc.fabric.impl.client.rendering.FabricShaderProgram;
@Mixin(ShaderProgram.class)
abstract class ShaderProgramMixin {
@Shadow
@Final
private String name;
// Allow loading FabricShaderPrograms from arbitrary namespaces.
@WrapOperation(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;ofVanilla(Ljava/lang/String;)Lnet/minecraft/util/Identifier;"), allow = 1)
private Identifier modifyId(String id, Operation<Identifier> original) {
if ((Object) this instanceof FabricShaderProgram) {
return FabricShaderProgram.rewriteAsId(id, name);
}
return original.call(id);
}
// Allow loading shader stages from arbitrary namespaces.
@ModifyVariable(method = "loadShader", at = @At("STORE"), ordinal = 1)
private static String modifyStageId(String id, ResourceFactory factory, ShaderStage.Type type, String name) {
if (name.contains(String.valueOf(Identifier.NAMESPACE_SEPARATOR))) {
return FabricShaderProgram.rewriteAsId(id, name).toString();
}
return id;
}
@WrapOperation(method = "loadShader", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;ofVanilla(Ljava/lang/String;)Lnet/minecraft/util/Identifier;"), allow = 1)
private static Identifier allowNoneMinecraftId(String id, Operation<Identifier> original) {
if (id.contains(String.valueOf(Identifier.NAMESPACE_SEPARATOR))) {
return Identifier.of(id);
}
return original.call(id);
}
}

View file

@ -18,10 +18,7 @@
"ItemColorsMixin",
"LivingEntityRendererAccessor",
"TooltipComponentMixin",
"WorldRendererMixin",
"shader.GameRendererMixin",
"shader.ShaderProgramImportProcessorMixin",
"shader.ShaderProgramMixin"
"WorldRendererMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -61,14 +61,14 @@ public class TooltipComponentTestInit implements ModInitializer {
}
private static ArmorMaterial createTestArmorMaterial() {
return new ArmorMaterial(Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> {
map.put(ArmorItem.Type.BOOTS, 1);
map.put(ArmorItem.Type.LEGGINGS, 2);
map.put(ArmorItem.Type.CHESTPLATE, 3);
map.put(ArmorItem.Type.HELMET, 1);
map.put(ArmorItem.Type.BODY, 3);
}),
0,
return new ArmorMaterial(
Util.make(new EnumMap<>(ArmorItem.Type.class), (map) -> {
map.put(ArmorItem.Type.BOOTS, 1);
map.put(ArmorItem.Type.LEGGINGS, 2);
map.put(ArmorItem.Type.CHESTPLATE, 3);
map.put(ArmorItem.Type.HELMET, 1);
map.put(ArmorItem.Type.BODY, 3);
}),
SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,
(stack) -> stack.getItem() == Items.LEATHER,
List.of(new ArmorMaterial.Layer(Identifier.of("fabric-rendering-v1-testmod", "test_material"))),

View file

@ -19,10 +19,10 @@ package net.fabricmc.fabric.test.rendering.client;
import com.mojang.blaze3d.systems.RenderSystem;
import org.joml.Matrix4f;
import net.minecraft.class_10142;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.DimensionEffects;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
@ -41,7 +41,7 @@ public class DimensionalRenderingTest implements ClientModInitializer {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.depthMask(false);
RenderSystem.setShader(GameRenderer::getPositionTexColorProgram);
RenderSystem.setShader(class_10142.POSITION_TEX_COLOR);
RenderSystem.setShaderTexture(0, END_SKY);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);

View file

@ -16,17 +16,8 @@
package net.fabricmc.fabric.test.rendering.client;
import com.mojang.blaze3d.systems.RenderSystem;
import org.joml.Matrix4f;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.ShaderProgram;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.Window;
import net.minecraft.util.Identifier;
import net.fabricmc.api.ClientModInitializer;
@ -48,12 +39,12 @@ public class HudAndShaderTest implements ClientModInitializer {
context.register(id, VertexFormats.POSITION, program -> testShader = program);
});
HudRenderCallback.EVENT.register((drawContext, tickDelta) -> {
/*HudRenderCallback.EVENT.register((drawContext, tickDelta) -> {
MinecraftClient client = MinecraftClient.getInstance();
Window window = client.getWindow();
int x = window.getScaledWidth() - 15;
int y = window.getScaledHeight() - 15;
RenderSystem.setShader(() -> testShader);
RenderSystem.setShader(testShader);
RenderSystem.setShaderColor(0f, 1f, 0f, 1f);
Matrix4f positionMatrix = drawContext.getMatrices().peek().getPositionMatrix();
BufferBuilder buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
@ -64,6 +55,6 @@ public class HudAndShaderTest implements ClientModInitializer {
BufferRenderer.drawWithGlobalProgram(buffer.end());
// Reset shader color
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
});
});*/
}
}

View file

@ -19,11 +19,11 @@ package net.fabricmc.fabric.test.rendering.client;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.block.Blocks;
import net.minecraft.class_10142;
import net.minecraft.class_9974;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
@ -70,7 +70,7 @@ public class WorldRenderEventsTests implements ClientModInitializer {
matrices.push();
matrices.translate(-camera.x, -camera.y, -camera.z);
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
RenderSystem.setShader(class_10142.POSITION_COLOR);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();

View file

@ -21,12 +21,12 @@ import java.util.List;
import com.mojang.blaze3d.systems.RenderSystem;
import org.joml.Matrix4f;
import net.minecraft.class_10142;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
@ -93,7 +93,7 @@ public class FluidVariantRenderTest implements ClientModInitializer {
float b = (color & 255) / 255f;
RenderSystem.disableDepthTest();
RenderSystem.setShader(GameRenderer::getPositionTexColorProgram);
RenderSystem.setShader(class_10142.POSITION_TEX_COLOR);
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
float x0 = (float) i;
float y0 = (float) j;

View file

@ -269,7 +269,6 @@ transitive-accessible field net/minecraft/client/render/RenderPhase ENTITY_CUTOU
transitive-accessible field net/minecraft/client/render/RenderPhase ENTITY_CUTOUT_NONULL_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase ENTITY_CUTOUT_NONULL_OFFSET_Z_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase ITEM_ENTITY_TRANSLUCENT_CULL_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase ENTITY_TRANSLUCENT_CULL_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase ENTITY_TRANSLUCENT_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase ENTITY_TRANSLUCENT_EMISSIVE_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase ENTITY_SMOOTH_CUTOUT_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
@ -287,7 +286,6 @@ transitive-accessible field net/minecraft/client/render/RenderPhase ARMOR_ENTITY
transitive-accessible field net/minecraft/client/render/RenderPhase TRANSLUCENT_GLINT_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase GLINT_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase ENTITY_GLINT_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase DIRECT_ENTITY_GLINT_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase CRUMBLING_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase TEXT_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase TEXT_BACKGROUND_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;

View file

@ -2,9 +2,9 @@ org.gradle.jvmargs=-Xmx2560M
org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true
version=0.102.2
minecraft_version=24w33a
yarn_version=+build.18
version=0.102.3
minecraft_version=24w34a
yarn_version=+build.1
loader_version=0.16.2
installer_version=1.0.1
@ -13,7 +13,7 @@ curseforge_minecraft_version=1.21.2-Snapshot
# Do not manually update, use the bumpversions task:
fabric-api-base-version=0.4.43
fabric-api-lookup-api-v1-version=1.6.69
fabric-api-lookup-api-v1-version=1.6.70
fabric-biome-api-v1-version=14.0.0
fabric-block-api-v1-version=1.0.23
fabric-block-view-api-v2-version=1.0.11
@ -21,42 +21,42 @@ fabric-blockrenderlayer-v1-version=1.1.53
fabric-command-api-v1-version=1.2.50
fabric-command-api-v2-version=2.2.29
fabric-commands-v0-version=0.2.67
fabric-content-registries-v0-version=9.0.0
fabric-content-registries-v0-version=9.0.1
fabric-crash-report-info-v1-version=0.2.30
fabric-data-attachment-api-v1-version=1.1.28
fabric-data-generation-api-v1-version=21.0.0
fabric-data-attachment-api-v1-version=1.1.29
fabric-data-generation-api-v1-version=21.0.1
fabric-dimensions-v1-version=4.0.1
fabric-entity-events-v1-version=1.6.13
fabric-events-interaction-v0-version=2.0.0
fabric-game-rule-api-v1-version=1.0.54
fabric-gametest-api-v1-version=2.0.5
fabric-item-api-v1-version=11.0.1
fabric-item-api-v1-version=11.0.2
fabric-item-group-api-v1-version=4.1.5
fabric-key-binding-api-v1-version=1.0.48
fabric-keybindings-v0-version=0.2.46
fabric-lifecycle-events-v1-version=2.3.13
fabric-lifecycle-events-v1-version=2.3.14
fabric-loot-api-v2-version=3.0.15
fabric-loot-api-v3-version=1.0.3
fabric-message-api-v1-version=6.0.14
fabric-model-loading-api-v1-version=2.0.0
fabric-model-loading-api-v1-version=3.0.0
fabric-networking-api-v1-version=4.2.3
fabric-object-builder-api-v1-version=16.0.0
fabric-particles-v1-version=4.0.3
fabric-recipe-api-v1-version=6.0.0
fabric-registry-sync-v0-version=5.1.3
fabric-renderer-api-v1-version=3.4.0
fabric-renderer-indigo-version=1.7.0
fabric-registry-sync-v0-version=5.1.4
fabric-renderer-api-v1-version=3.5.0
fabric-renderer-indigo-version=1.8.0
fabric-rendering-data-attachment-v1-version=0.3.49
fabric-rendering-fluids-v1-version=3.1.7
fabric-rendering-v0-version=1.1.72
fabric-rendering-v1-version=5.0.6
fabric-rendering-v0-version=1.1.73
fabric-rendering-v1-version=6.0.0
fabric-resource-conditions-api-v1-version=5.0.0
fabric-resource-loader-v0-version=2.0.0
fabric-screen-api-v1-version=2.0.26
fabric-screen-handler-api-v1-version=1.3.87
fabric-screen-handler-api-v1-version=1.3.88
fabric-sound-api-v1-version=1.0.24
fabric-transfer-api-v1-version=5.1.18
fabric-transitive-access-wideners-v1-version=6.1.1
fabric-convention-tags-v1-version=2.0.21
fabric-convention-tags-v2-version=2.6.1
fabric-transfer-api-v1-version=5.1.19
fabric-transitive-access-wideners-v1-version=6.1.2
fabric-convention-tags-v1-version=2.0.22
fabric-convention-tags-v2-version=2.6.2
fabric-client-tags-api-v1-version=1.1.16