mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 02:55:17 +00:00
B3D Improvements
- fixed keyframe transformation application - textures are now resolved the same way as in vanilla models - added the ability to use forge blockstate texture information - removed unused code from the B3D example
This commit is contained in:
1 parent
581363fddd
commit
d6bc936ffa
5 files changed
+96
-133
No files matched your search
@@ -64,14 +64,9 @@ public class ModelLoaderRegistryDebug
|
||||
|
||||
private void clientPreInit()
|
||||
{
|
||||
//ModelLoaderRegistry.registerLoader(DummyModelLoader.instance);
|
||||
B3DLoader.instance.addDomain(MODID.toLowerCase());
|
||||
//ModelBakery.addVariantName(Item.getItemFromBlock(CustomModelBlock.instance), "forgedebug:dummymodel");
|
||||
String modelLocation = MODID.toLowerCase() + ":untitled2.b3d";
|
||||
ModelBakery.addVariantName(Item.getItemFromBlock(CustomModelBlock.instance), modelLocation);
|
||||
Item item = Item.getItemFromBlock(CustomModelBlock.instance);
|
||||
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(modelLocation, "inventory"));
|
||||
//ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation("forgedebug:dummymodel", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + CustomModelBlock.name, "inventory"));
|
||||
}
|
||||
|
||||
public static class CustomModelBlock extends Block
|
||||
@@ -100,9 +95,7 @@ public class ModelLoaderRegistryDebug
|
||||
@Override
|
||||
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
IModel model = ModelLoaderRegistry.getModel(new ResourceLocation(MODID.toLowerCase(),"block/untitled2.b3d"));
|
||||
B3DLoader.B3DState defaultState = ((B3DLoader.Wrapper)model).getDefaultState();
|
||||
B3DLoader.B3DState newState = new B3DLoader.B3DState(defaultState.getAnimation(), counter);
|
||||
B3DLoader.B3DState newState = new B3DLoader.B3DState(null, counter);
|
||||
return ((IExtendedBlockState)this.state.getBaseState()).withProperty(B3DLoader.B3DFrameProperty.instance, newState);
|
||||
}
|
||||
|
||||
@@ -120,106 +113,4 @@ public class ModelLoaderRegistryDebug
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DummyModelLoader implements ICustomModelLoader
|
||||
{
|
||||
public static final DummyModelLoader instance = new DummyModelLoader();
|
||||
public static final ResourceLocation dummyTexture = new ResourceLocation("minecraft:blocks/dirt");
|
||||
|
||||
public boolean accepts(ResourceLocation modelLocation)
|
||||
{
|
||||
return modelLocation.getResourceDomain().equals("forgedebug") && modelLocation.getResourcePath().contains("dummymodel");
|
||||
}
|
||||
|
||||
public IModel loadModel(ResourceLocation model)
|
||||
{
|
||||
return DummyModel.instance;
|
||||
}
|
||||
|
||||
public static enum DummyModel implements IModel
|
||||
{
|
||||
instance;
|
||||
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public Collection<ResourceLocation> getTextures()
|
||||
{
|
||||
return Collections.singletonList(dummyTexture);
|
||||
}
|
||||
|
||||
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> textures)
|
||||
{
|
||||
return new DummyBakedModel(textures.apply(dummyTexture));
|
||||
}
|
||||
|
||||
public IModelState getDefaultState()
|
||||
{
|
||||
return ModelRotation.X0_Y0;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DummyBakedModel implements IFlexibleBakedModel
|
||||
{
|
||||
private final TextureAtlasSprite texture;
|
||||
|
||||
public DummyBakedModel(TextureAtlasSprite texture)
|
||||
{
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public List<BakedQuad> getFaceQuads(EnumFacing side)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private int[] vertexToInts(float x, float y, float z, int color, float u, float v)
|
||||
{
|
||||
return new int[] {
|
||||
Float.floatToRawIntBits(x),
|
||||
Float.floatToRawIntBits(y),
|
||||
Float.floatToRawIntBits(z),
|
||||
color,
|
||||
Float.floatToRawIntBits(texture.getInterpolatedU(u)),
|
||||
Float.floatToRawIntBits(texture.getInterpolatedV(v)),
|
||||
0
|
||||
};
|
||||
}
|
||||
|
||||
public List<BakedQuad> getGeneralQuads()
|
||||
{
|
||||
List<BakedQuad> ret = new ArrayList<BakedQuad>();
|
||||
// 1 half-way rotated quad looking UP
|
||||
ret.add(new BakedQuad(Ints.concat(
|
||||
vertexToInts(0, .5f, .5f, -1, 0, 0),
|
||||
vertexToInts(.5f, .5f, 1, -1, 0, 16),
|
||||
vertexToInts(1, .5f, .5f, -1, 16, 16),
|
||||
vertexToInts(.5f, .5f, 0, -1, 16, 0)
|
||||
), -1, EnumFacing.UP));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean isGui3d() { return true; }
|
||||
|
||||
public boolean isAmbientOcclusion() { return true; }
|
||||
|
||||
public boolean isBuiltInRenderer() { return false; }
|
||||
|
||||
public TextureAtlasSprite getTexture() { return this.texture; }
|
||||
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
public VertexFormat getFormat()
|
||||
{
|
||||
return Attributes.DEFAULT_BAKED_FORMAT;
|
||||
}
|
||||
}
|
||||
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user