Deprecated BlockEntityRendererRegistry in favor of vanilla's BlockEntityRendererFactories (#2582)

* Deprecated BlockEntityRendererRegistry in favor of vanilla's BlockEntityRendererFactories

* Undo unintended change

* Update fabric-transitive-access-wideners-v1/src/main/resources/fabric-transitive-access-wideners-v1.accesswidener

Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com>

* Update BlockEntityRendererRegistry javadoc to match others

* Implement sign renderer test

* Fix template

* Change SignTestBlockEntity to SignBlockEntityTest

Co-authored-by: haykam821 <24855774+haykam821@users.noreply.github.com>

(cherry picked from commit 08b73de4d1)
This commit is contained in:
AlphaMode 2022-12-23 15:32:04 +00:00 committed by modmuss50
parent b808eab9dd
commit 6dc0edd789
11 changed files with 163 additions and 0 deletions

View file

@ -26,7 +26,12 @@ import net.fabricmc.fabric.impl.client.rendering.BlockEntityRendererRegistryImpl
/**
* Helper class for registering BlockEntityRenderers.
*
* <p>Use {@link net.minecraft.client.render.block.entity.BlockEntityRendererFactories#register(BlockEntityType, BlockEntityRendererFactory)} instead.
*
* @deprecated Replaced with transitive access wideners in Fabric Transitive Access Wideners (v1).
*/
@Deprecated
public final class BlockEntityRendererRegistry {
/**
* Register a BlockEntityRenderer for a BlockEntityType. Can be called clientside before the world is rendered.

View file

@ -5,6 +5,12 @@ loom {
accessWidenerPath = file('src/main/resources/fabric-transitive-access-wideners-v1.accesswidener')
}
testDependencies(project, [
':fabric-rendering-v1',
':fabric-object-builder-api-v1'
])
import org.objectweb.asm.ClassReader
import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type

View file

@ -88,6 +88,9 @@ transitive-accessible method net/minecraft/client/render/RenderLayer of (Lnet/mi
transitive-accessible method net/minecraft/client/render/RenderLayer of (Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;IZZLnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase;
transitive-accessible method net/minecraft/client/render/RenderLayer of (Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;ILnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase;
# Registering custom block entity renderers
transitive-accessible method net/minecraft/client/render/block/entity/BlockEntityRendererFactories register (Lnet/minecraft/block/entity/BlockEntityType;Lnet/minecraft/client/render/block/entity/BlockEntityRendererFactory;)V
# Creating custom sensor types
transitive-accessible method net/minecraft/entity/ai/brain/sensor/SensorType <init> (Ljava/util/function/Supplier;)V

View file

@ -0,0 +1,29 @@
/*
* 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.test.access;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories;
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
import net.fabricmc.api.ClientModInitializer;
public class BlockEntityRendererTest implements ClientModInitializer {
@Override
public void onInitializeClient() {
BlockEntityRendererFactories.register(SignBlockEntityTest.TEST_SIGN_BLOCK_ENTITY, SignBlockEntityRenderer::new);
}
}

View file

@ -0,0 +1,72 @@
/*
* 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.test.access;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SignBlock;
import net.minecraft.block.WallSignBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.SignBlockEntity;
import net.minecraft.item.Item;
import net.minecraft.item.SignItem;
import net.minecraft.util.Identifier;
import net.minecraft.util.SignType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
public final class SignBlockEntityTest implements ModInitializer {
public static final String MOD_ID = "fabric-transitive-access-wideners-v1-testmod";
public static final SignBlock TEST_SIGN = new SignBlock(FabricBlockSettings.copy(Blocks.OAK_SIGN), SignType.OAK) {
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new TestSign(pos, state);
}
};
public static final WallSignBlock TEST_WALL_SIGN = new WallSignBlock(FabricBlockSettings.copy(Blocks.OAK_SIGN), SignType.OAK) {
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new TestSign(pos, state);
}
};
public static final SignItem TEST_SIGN_ITEM = new SignItem(new Item.Settings(), TEST_SIGN, TEST_WALL_SIGN);
public static final BlockEntityType<TestSign> TEST_SIGN_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(TestSign::new, TEST_SIGN, TEST_WALL_SIGN).build();
@Override
public void onInitialize() {
Registry.register(Registry.BLOCK, new Identifier(MOD_ID, "test_sign"), TEST_SIGN);
Registry.register(Registry.BLOCK, new Identifier(MOD_ID, "test_wall_sign"), TEST_WALL_SIGN);
Registry.register(Registry.ITEM, new Identifier(MOD_ID, "test_sign"), TEST_SIGN_ITEM);
Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(MOD_ID, "test_sign"), TEST_SIGN_BLOCK_ENTITY);
}
public static class TestSign extends SignBlockEntity {
public TestSign(BlockPos pos, BlockState state) {
super(pos, state);
}
@Override
public BlockEntityType<?> getType() {
return TEST_SIGN_BLOCK_ENTITY;
}
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "fabric-transitive-access-wideners-v1-testmod:block/test_sign"
}
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "fabric-transitive-access-wideners-v1-testmod:block/test_sign"
}
}
}

View file

@ -0,0 +1,5 @@
{
"textures": {
"particle": "minecraft:block/oak_planks"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/oak_sign"
}
}

View file

@ -0,0 +1,20 @@
{
"schemaVersion": 1,
"id": "fabric-transitive-access-wideners-v1-testmod",
"name": "Fabric Transitive Access Wideners (v1) Test Mod",
"version": "1.0.0",
"environment": "*",
"license": "Apache-2.0",
"depends": {
"fabric-transitive-access-wideners-v1": "*",
"fabric-object-builder-api-v1": "*"
},
"entrypoints": {
"main": [
"net.fabricmc.fabric.test.access.SignBlockEntityTest"
],
"client": [
"net.fabricmc.fabric.test.access.BlockEntityRendererTest"
]
}
}

View file

@ -83,6 +83,9 @@ transitive-accessible method net/minecraft/client/render/RenderLayer of (Lnet/mi
transitive-accessible method net/minecraft/client/render/RenderLayer of (Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;IZZLnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase;
transitive-accessible method net/minecraft/client/render/RenderLayer of (Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;Lnet/minecraft/client/render/VertexFormat$DrawMode;ILnet/minecraft/client/render/RenderLayer$MultiPhaseParameters;)Lnet/minecraft/client/render/RenderLayer$MultiPhase;
# Registering custom block entity renderers
transitive-accessible method net/minecraft/client/render/block/entity/BlockEntityRendererFactories register (Lnet/minecraft/block/entity/BlockEntityType;Lnet/minecraft/client/render/block/entity/BlockEntityRendererFactory;)V
# Creating custom sensor types
transitive-accessible method net/minecraft/entity/ai/brain/sensor/SensorType <init> (Ljava/util/function/Supplier;)V