mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 14:34:28 +00:00
More model/rendering fixes:
- Breaking change: Change ClientRegistry.bindTileEntityRenderer to a factory, so mods don't have to manually specify the dispatcher. - Breaking change: Delete obsolete SimpleModelState (the class was duplicated by mistake, see SimpleModelTransform) and ICustomModelState (part of the old loader API). - Breaking change: Rename getTextureDependencies to getTextures, for consistency. - Reinstate the getRenderLayer method, fixed appropriately to return the new RenderType value. - Fix OBJ loader applying the model transform in the wrong reference frame. - Fix vanilla bug in TransformationMatrix#func_227986_a_ - Fix QuadTransformer logic. - Added new method to IModelConfiguration to retrieve the owner IUnbakedModel, needed in order to construct ItemOverrideLists when baking custom models. - Reintroduce multi-layer model through the new model loader system.
This commit is contained in:
1 parent
e8ce61d4cd
commit
fc189c9aaf
29 files changed
+325
-344
No files matched your search
@@ -17,28 +17,22 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
package net.minecraftforge.debug.client.model;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
//@Mod(modid = MultiLayerModelTest.MODID, name = "ForgeDebugMultiLayerModel", version = MultiLayerModelTest.VERSION, acceptableRemoteVersions = "*")
|
||||
@Mod(MultiLayerModelTest.MODID)
|
||||
public class MultiLayerModelTest
|
||||
{
|
||||
private static final boolean ENABLED = true;
|
||||
@@ -50,7 +44,7 @@ public class MultiLayerModelTest
|
||||
@ObjectHolder(blockName)
|
||||
public static final Block TEST_BLOCK = null;
|
||||
|
||||
//@Mod.EventBusSubscriber(modid = MODID)
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class Registration
|
||||
{
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
@@ -59,48 +53,28 @@ public class MultiLayerModelTest
|
||||
if (!ENABLED)
|
||||
return;
|
||||
event.getRegistry().register(
|
||||
new Block(Material.WOOD)
|
||||
new Block(Block.Properties.create(Material.WOOD))
|
||||
{
|
||||
{
|
||||
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
||||
setUnlocalizedName(MODID + "." + blockName);
|
||||
setRegistryName(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer)
|
||||
{
|
||||
return layer == BlockRenderLayer.SOLID || layer == BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
}
|
||||
}.setRegistryName(blockId)
|
||||
);
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().register(new ItemBlock(TEST_BLOCK).setRegistryName(TEST_BLOCK.getRegistryName()));
|
||||
if (!ENABLED)
|
||||
return;
|
||||
event.getRegistry().register(new BlockItem(TEST_BLOCK, new Item.Properties().group(ItemGroup.MISC)).setRegistryName(TEST_BLOCK.getRegistryName()));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
public static void clientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
if (!ENABLED)
|
||||
return;
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TEST_BLOCK), 0, new ModelResourceLocation(blockId, "inventory"));
|
||||
RenderTypeLookup.setRenderLayer(TEST_BLOCK, (layer) -> {
|
||||
return layer == RenderType.func_228639_c_() || layer == RenderType.func_228645_f_();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -23,12 +23,17 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FourWayBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
@@ -45,6 +50,8 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod(NewModelLoaderTest.MODID)
|
||||
public class NewModelLoaderTest
|
||||
{
|
||||
@@ -52,8 +59,27 @@ public class NewModelLoaderTest
|
||||
public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID);
|
||||
public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Block> obj_block = BLOCKS.register("obj_block", () ->
|
||||
new Block(Block.Properties.create(Material.WOOD)) {
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
|
||||
{
|
||||
builder.add(BlockStateProperties.HORIZONTAL_FACING);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context)
|
||||
{
|
||||
return getDefaultState().with(
|
||||
BlockStateProperties.HORIZONTAL_FACING, context.getPlacementHorizontalFacing()
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> obj_item = ITEMS.register("obj_item", () ->
|
||||
new Item(new Item.Properties().group(ItemGroup.MISC)) {
|
||||
new BlockItem(obj_block.get(), new Item.Properties().group(ItemGroup.MISC)) {
|
||||
@Override
|
||||
public boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity)
|
||||
{
|
||||
|
||||
@@ -51,3 +51,5 @@ loaderVersion="[28,)"
|
||||
## modId="custom_tnt_test"
|
||||
[[mods]]
|
||||
modId="new_model_loader_test"
|
||||
[[mods]]
|
||||
modId="forgedebugmultilayermodel"
|
||||
+1
-22
@@ -1,26 +1,5 @@
|
||||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "forge:multi-layer",
|
||||
"custom": {
|
||||
// base is used for model properties - camera transforms, isGui3d, e.t.c.
|
||||
"base": "forgedebugmultilayermodel:test_layer_block#aux",
|
||||
// per-layer models
|
||||
"Solid": "forgedebugmultilayermodel:test_layer_block#aux",
|
||||
"Translucent": "forgedebugmultilayermodel:test_layer_block#pane"
|
||||
},
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
"normal": [{}],
|
||||
"inventory": [{}],
|
||||
"pane": [{
|
||||
"model": "minecraft:pink_stained_glass_pane_noside"
|
||||
}],
|
||||
"aux": [{
|
||||
"model": "cube_all",
|
||||
"textures": { "all": "blocks/slime" },
|
||||
"transform": { "scale": 0.5 }
|
||||
}]
|
||||
"": { "model": "forgedebugmultilayermodel:block/test_layer_block"}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"parent": "block/block",
|
||||
"loader": "forge:multi-layer",
|
||||
"layers": {
|
||||
"__comment": "base is used for model properties - camera transforms, isGui3d, e.t.c.",
|
||||
"base": {
|
||||
"parent": "block/cube_all",
|
||||
"textures": { "all": "block/slime_block" }
|
||||
},
|
||||
|
||||
"__comment": "per-layer models",
|
||||
"solid": {
|
||||
"parent": "block/cube_all",
|
||||
"textures": { "all": "block/slime_block" },
|
||||
"transform": { "scale": 0.5 }
|
||||
},
|
||||
"translucent": {
|
||||
"parent": "minecraft:block/pink_stained_glass_pane_noside"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "forgedebugmultilayermodel:block/test_layer_block"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"variants": {
|
||||
"facing=east": { "model": "new_model_loader_test:block/obj_block", "y": 90 },
|
||||
"facing=west": { "model": "new_model_loader_test:block/obj_block", "y": 270 },
|
||||
"facing=north": { "model": "new_model_loader_test:block/obj_block", "y": 0 },
|
||||
"facing=south": { "model": "new_model_loader_test:block/obj_block", "y": 180 }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"parent": "forge:item/default",
|
||||
"loader": "forge:composite",
|
||||
"parts": {
|
||||
"part1": {
|
||||
"loader": "forge:obj",
|
||||
"model": "new_model_loader_test:models/item/sugar_glider.obj",
|
||||
"ambientToFullbright": true,
|
||||
"textures": {
|
||||
"qr": "minecraft:block/oak_planks"
|
||||
}
|
||||
}
|
||||
},
|
||||
"textures": {
|
||||
"particle": "block/oak_planks"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user