diff --git a/deprecated/fabric-rendering-data-attachment-v1/build.gradle b/deprecated/fabric-rendering-data-attachment-v1/build.gradle
new file mode 100644
index 0000000000..886022f45d
--- /dev/null
+++ b/deprecated/fabric-rendering-data-attachment-v1/build.gradle
@@ -0,0 +1,4 @@
+archivesBaseName = "fabric-rendering-data-attachment-v1"
+version = getSubprojectVersion(project)
+
+moduleDependencies(project, ['fabric-render-data-api-v2'])
diff --git a/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachedBlockView.java b/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachedBlockView.java
new file mode 100644
index 0000000000..40091889e0
--- /dev/null
+++ b/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachedBlockView.java
@@ -0,0 +1,46 @@
+/*
+ * 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.api.rendering.data.v1;
+
+import org.jetbrains.annotations.Nullable;
+
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.BlockRenderView;
+import net.minecraft.world.WorldView;
+
+import net.fabricmc.fabric.api.renderdata.v2.RenderDataBlockView;
+
+/**
+ * This interface is guaranteed to be implemented on all {@link WorldView} instances.
+ * It is likely to be implemented on any given {@link BlockRenderView} instance, but
+ * this is not guaranteed.
+ *
+ * @deprecated Use {@link RenderDataBlockView} instead.
+ */
+@Deprecated
+public interface RenderAttachedBlockView extends BlockRenderView {
+ /**
+ * This method will call {@link RenderDataBlockView#getBlockEntityRenderData(BlockPos)} by default.
+ *
+ * @deprecated Use {@link RenderDataBlockView#getBlockEntityRenderData(BlockPos)} instead.
+ */
+ @Deprecated
+ @Nullable
+ default Object getBlockEntityRenderAttachment(BlockPos pos) {
+ return getBlockEntityRenderData(pos);
+ }
+}
diff --git a/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachmentBlockEntity.java b/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachmentBlockEntity.java
new file mode 100644
index 0000000000..0b7c52b825
--- /dev/null
+++ b/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/api/rendering/data/v1/RenderAttachmentBlockEntity.java
@@ -0,0 +1,41 @@
+/*
+ * 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.api.rendering.data.v1;
+
+import org.jetbrains.annotations.Nullable;
+
+import net.minecraft.block.entity.BlockEntity;
+
+import net.fabricmc.fabric.api.renderdata.v2.RenderDataBlockEntity;
+
+/**
+ * This interface is guaranteed to be implemented on all {@link BlockEntity} instances.
+ *
+ * @deprecated Use {@link RenderDataBlockEntity} instead.
+ */
+@Deprecated
+@FunctionalInterface
+public interface RenderAttachmentBlockEntity {
+ /**
+ * This method will be automatically called if {@link RenderDataBlockEntity#getRenderData()} is not overridden.
+ *
+ * @deprecated Use {@link RenderDataBlockEntity#getRenderData()} instead.
+ */
+ @Deprecated
+ @Nullable
+ Object getRenderAttachmentData();
+}
diff --git a/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/BlockEntityMixin.java b/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/BlockEntityMixin.java
new file mode 100644
index 0000000000..befa65abbf
--- /dev/null
+++ b/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/BlockEntityMixin.java
@@ -0,0 +1,43 @@
+/*
+ * 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.rendering.data;
+
+import org.jetbrains.annotations.Nullable;
+import org.spongepowered.asm.mixin.Mixin;
+
+import net.minecraft.block.entity.BlockEntity;
+
+import net.fabricmc.fabric.api.renderdata.v2.RenderDataBlockEntity;
+import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;
+
+@Mixin(BlockEntity.class)
+public class BlockEntityMixin implements RenderAttachmentBlockEntity, RenderDataBlockEntity {
+ @Override
+ @Nullable
+ public Object getRenderAttachmentData() {
+ return null;
+ }
+
+ /**
+ * Instead of returning null by default in v2, proxy to v1 method instead.
+ */
+ @Override
+ @Nullable
+ public Object getRenderData() {
+ return getRenderAttachmentData();
+ }
+}
diff --git a/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/attachment/WorldViewMixin.java b/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/WorldViewMixin.java
similarity index 82%
rename from fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/attachment/WorldViewMixin.java
rename to deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/WorldViewMixin.java
index 317cc7df8a..bbd04fcfdc 100644
--- a/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/attachment/WorldViewMixin.java
+++ b/deprecated/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/WorldViewMixin.java
@@ -14,15 +14,14 @@
* limitations under the License.
*/
-package net.fabricmc.fabric.mixin.rendering.data.attachment;
+package net.fabricmc.fabric.mixin.rendering.data;
import org.spongepowered.asm.mixin.Mixin;
-import net.minecraft.world.BlockRenderView;
import net.minecraft.world.WorldView;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView;
-/** Make {@link BlockRenderView} implement {@link RenderAttachedBlockView}. */
@Mixin(WorldView.class)
-public interface WorldViewMixin extends RenderAttachedBlockView { }
+public interface WorldViewMixin extends RenderAttachedBlockView {
+}
diff --git a/fabric-rendering-data-attachment-v1/src/main/resources/assets/fabric-rendering-data-attachment-v1/icon.png b/deprecated/fabric-rendering-data-attachment-v1/src/main/resources/assets/fabric-rendering-data-attachment-v1/icon.png
similarity index 100%
rename from fabric-rendering-data-attachment-v1/src/main/resources/assets/fabric-rendering-data-attachment-v1/icon.png
rename to deprecated/fabric-rendering-data-attachment-v1/src/main/resources/assets/fabric-rendering-data-attachment-v1/icon.png
diff --git a/fabric-rendering-data-attachment-v1/src/main/resources/fabric-rendering-data-attachment-v1.mixins.json b/deprecated/fabric-rendering-data-attachment-v1/src/main/resources/fabric-rendering-data-attachment-v1.mixins.json
similarity index 56%
rename from fabric-rendering-data-attachment-v1/src/main/resources/fabric-rendering-data-attachment-v1.mixins.json
rename to deprecated/fabric-rendering-data-attachment-v1/src/main/resources/fabric-rendering-data-attachment-v1.mixins.json
index 3e4c81bc9d..9c09ede3c4 100644
--- a/fabric-rendering-data-attachment-v1/src/main/resources/fabric-rendering-data-attachment-v1.mixins.json
+++ b/deprecated/fabric-rendering-data-attachment-v1/src/main/resources/fabric-rendering-data-attachment-v1.mixins.json
@@ -1,7 +1,7 @@
{
"required": true,
- "package": "net.fabricmc.fabric.mixin.rendering.data.attachment",
- "compatibilityLevel": "JAVA_16",
+ "package": "net.fabricmc.fabric.mixin.rendering.data",
+ "compatibilityLevel": "JAVA_17",
"mixins": [
"BlockEntityMixin",
"WorldViewMixin"
diff --git a/fabric-rendering-data-attachment-v1/src/main/resources/fabric.mod.json b/deprecated/fabric-rendering-data-attachment-v1/src/main/resources/fabric.mod.json
similarity index 68%
rename from fabric-rendering-data-attachment-v1/src/main/resources/fabric.mod.json
rename to deprecated/fabric-rendering-data-attachment-v1/src/main/resources/fabric.mod.json
index 03fcd46275..5cfddc0a53 100644
--- a/fabric-rendering-data-attachment-v1/src/main/resources/fabric.mod.json
+++ b/deprecated/fabric-rendering-data-attachment-v1/src/main/resources/fabric.mod.json
@@ -17,18 +17,13 @@
],
"depends": {
"fabricloader": ">=0.4.0",
- "fabric-api-base": "*"
+ "fabric-render-data-api-v2": "*"
},
"description": "Thread-safe hooks for block entity data use during terrain rendering.",
"mixins": [
- "fabric-rendering-data-attachment-v1.mixins.json",
- {
- "config": "fabric-rendering-data-attachment-v1.client.mixins.json",
- "environment": "client"
- }
+ "fabric-rendering-data-attachment-v1.mixins.json"
],
"custom": {
- "fabric-api:module-lifecycle": "stable"
- },
- "accessWidener": "fabric-rendering-data-attachment-v1.accesswidener"
+ "fabric-api:module-lifecycle": "deprecated"
+ }
}
diff --git a/fabric-block-api-v1/src/main/java/net/fabricmc/fabric/api/block/v1/FabricBlock.java b/fabric-block-api-v1/src/main/java/net/fabricmc/fabric/api/block/v1/FabricBlock.java
index 5240b08f44..6304c434a5 100644
--- a/fabric-block-api-v1/src/main/java/net/fabricmc/fabric/api/block/v1/FabricBlock.java
+++ b/fabric-block-api-v1/src/main/java/net/fabricmc/fabric/api/block/v1/FabricBlock.java
@@ -56,11 +56,12 @@ public interface FabricBlock {
*
This can be called on the server, where block entity data can be safely accessed,
* and on the client, possibly in a meshing thread, where block entity data is not safe to access!
* Here is an example of how data from a block entity can be handled safely.
- * The block entity needs to implement {@code RenderAttachmentBlockEntity} for this to work.
+ * The block entity should override {@code RenderDataBlockEntity#getBlockEntityRenderData} to return
+ * the necessary data. Refer to the documentation of {@code RenderDataBlockEntity} for more information.
*
{@code @Override
* public BlockState getAppearance(BlockState state, BlockRenderView renderView, BlockPos pos, Direction side, @Nullable BlockState sourceState, @Nullable BlockPos sourcePos) {
* if (renderView instanceof ServerWorld serverWorld) {
- * // Server side, ok to use block entity directly!
+ * // Server side; ok to use block entity directly!
* BlockEntity blockEntity = serverWorld.getBlockEntity(pos);
*
* if (blockEntity instanceof ...) {
@@ -68,9 +69,8 @@ public interface FabricBlock {
* return ...;
* }
* } else {
- * // Client side, need to use the render attachment!
- * RenderAttachedBlockView attachmentView = (RenderAttachedBlockView) renderView;
- * Object data = attachmentView.getBlockEntityRenderAttachment(pos);
+ * // Client side; need to use the block entity render data!
+ * Object data = renderView.getBlockEntityRenderData(pos);
*
* // Check if data is not null and of the correct type, and use that to determine the appearance
* if (data instanceof ...) {
diff --git a/fabric-render-data-api-v2/build.gradle b/fabric-render-data-api-v2/build.gradle
new file mode 100644
index 0000000000..d18a9aac58
--- /dev/null
+++ b/fabric-render-data-api-v2/build.gradle
@@ -0,0 +1,6 @@
+archivesBaseName = "fabric-render-data-api-v2"
+version = getSubprojectVersion(project)
+
+loom {
+ accessWidenerPath = file("src/main/resources/fabric-render-data-api-v2.accesswidener")
+}
diff --git a/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/impl/rendering/data/attachment/RenderDataObjectConsumer.java b/fabric-render-data-api-v2/src/client/java/net/fabricmc/fabric/impl/renderdata/client/RenderDataMapConsumer.java
similarity index 71%
rename from fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/impl/rendering/data/attachment/RenderDataObjectConsumer.java
rename to fabric-render-data-api-v2/src/client/java/net/fabricmc/fabric/impl/renderdata/client/RenderDataMapConsumer.java
index 32c50114a0..e4e7679595 100644
--- a/fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/impl/rendering/data/attachment/RenderDataObjectConsumer.java
+++ b/fabric-render-data-api-v2/src/client/java/net/fabricmc/fabric/impl/renderdata/client/RenderDataMapConsumer.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package net.fabricmc.fabric.impl.rendering.data.attachment;
+package net.fabricmc.fabric.impl.renderdata.client;
-import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
+import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
-public interface RenderDataObjectConsumer {
- void fabric_acceptRenderDataObjects(Long2ObjectOpenHashMap