net.minecraftforge.client.model.PerspectiveMapWrapper Java Examples

The following examples show how to use net.minecraftforge.client.model.PerspectiveMapWrapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PerspectiveAwareModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(final IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final Map<TransformType, IBakedModel> bakedModels = Maps.transformValues(models, location -> bakeModel(location, state, format, bakedTextureGetter));

	IModel missing = ModelLoaderRegistry.getMissingModel();
	IBakedModel bakedMissing = missing.bake(missing.getDefaultState(), format, bakedTextureGetter);

	final IBakedModel bakedBase;
	if (base.isPresent()) {
		bakedBase = bakeModel(base.get(), state, format, bakedTextureGetter);
	} else {
		bakedBase = bakedMissing;
	}

	return new PerspectiveAwareBakedModel(
			bakedModels,
			bakedBase,
			PerspectiveMapWrapper.getTransforms(state));
}
 
Example #2
Source File: MultiLayerModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(final IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final Map<BlockRenderLayer, IBakedModel> bakedModels = Maps.transformValues(models, location -> bakeModel(location, state, format, bakedTextureGetter));

	IModel missing = ModelLoaderRegistry.getMissingModel();
	IBakedModel bakedMissing = missing.bake(missing.getDefaultState(), format, bakedTextureGetter);

	final IBakedModel bakedBase;
	if (base.isPresent()) {
		bakedBase = bakeModel(base.get(), state, format, bakedTextureGetter);
	} else {
		bakedBase = bakedMissing;
	}

	return new MultiLayerBakedModel(
			bakedModels,
			bakedBase,
			bakedMissing,
			PerspectiveMapWrapper.getTransforms(state));
}
 
Example #3
Source File: VariantModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final Map<ResourceLocation, IBakedModel> bakedSubModels = Maps.newHashMap();

	for (ResourceLocation subModel : modelData.getAllModels()) {
		IModel model = ModelLoaderRegistry.getModelOrLogError(subModel, "Couldn't load sub-model dependency: " + subModel);
		bakedSubModels.put(subModel, model.bake(new ModelStateComposition(state, model.getDefaultState()), format, bakedTextureGetter));
	}

	final IModel baseModel;
	if (base.isPresent()) {
		ResourceLocation baseLocation = base.get();
		baseModel = ModelLoaderRegistry.getModelOrLogError(baseLocation, "Couldn't load base-model dependency: " + baseLocation);
	} else {
		baseModel = ModelLoaderRegistry.getMissingModel();
	}

	final IBakedModel bakedBaseModel = baseModel.bake(new ModelStateComposition(state, baseModel.getDefaultState()), format, bakedTextureGetter);

	return new BakedModel(bakedBaseModel, modelData, bakedSubModels, PerspectiveMapWrapper.getTransforms(state));
}
 
Example #4
Source File: ModelNullifierBaked.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ModelNullifierBaked(IModel baseModel, IModel lockedModel, IModelState state, VertexFormat format,
        Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    this.modelState = state;
    this.modelBase = baseModel.bake(state, format, bakedTextureGetter);
    this.modelLocked = lockedModel.bake(state, format, bakedTextureGetter);
    this.format = format;
    this.bakedTextureGetter = bakedTextureGetter;
    this.particle = bakedTextureGetter.apply(new ResourceLocation(ModelNullifier.TEX_BASE));
    this.transformMap = PerspectiveMapWrapper.getTransforms(state);
}
 
Example #5
Source File: TexturedItemModel.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final IModel untexturedModel = getModel(this.untexturedModel);
	final IBakedModel untexturedBakedModel = untexturedModel.bake(new ModelStateComposition(state, untexturedModel.getDefaultState()), format, bakedTextureGetter);

	final IModel texturedModel = getModel(this.texturedModel);
	final IBakedModel texturedBakedModel = texturedModel.bake(new ModelStateComposition(state, texturedModel.getDefaultState()), format, bakedTextureGetter);

	final ItemOverrideList overrides = new TexturedItemOverrides(untexturedBakedModel, texturedModel, texturedBakedModel.getOverrides().getOverrides(), textures, state, format, bakedTextureGetter);

	return new BakedModel(untexturedBakedModel, PerspectiveMapWrapper.getTransforms(state), overrides);
}
 
Example #6
Source File: BakedEvalModel.java    From OpenModsLib with MIT License 5 votes vote down vote up
public BakedEvalModel(IModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, ITransformEvaluator evaluator) {
	super(model.bake(state, format, bakedTextureGetter), PerspectiveMapWrapper.getTransforms(state));
	this.model = model;
	this.originalState = state;
	this.format = format;
	this.bakedTextureGetter = bakedTextureGetter;
	this.evaluator = evaluator;
}
 
Example #7
Source File: AbstractBakedPropertiesModel.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public IBakedModel handlePerspective(TransformType transformType, MatrixStack mat) {
    if (properties instanceof PerspectiveProperties) {
        ImmutableMap<TransformType, TransformationMatrix> transforms = ((PerspectiveProperties) properties).getTransforms();
        return PerspectiveMapWrapper.handlePerspective(this, transforms, transformType, mat);
    }
    return IModelParticleProvider.super.handlePerspective(transformType, mat);
}
 
Example #8
Source File: ModelEnderBucket.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
    return PerspectiveMapWrapper.handlePerspective(this, this.transforms, cameraTransformType);
}
 
Example #9
Source File: ModelEnderTools.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
    return PerspectiveMapWrapper.handlePerspective(this, this.transforms, cameraTransformType);
}
 
Example #10
Source File: BakedModelHandler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
    CCRenderItem.notifyTransform(cameraTransformType);
    return PerspectiveMapWrapper.handlePerspective(this, TransformUtils.DEFAULT_BLOCK, cameraTransformType);
}
 
Example #11
Source File: ModelNullifierBaked.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
    return PerspectiveMapWrapper.handlePerspective(this, this.transformMap, cameraTransformType);
}
 
Example #12
Source File: EvalExpandModel.java    From OpenModsLib with MIT License 4 votes vote down vote up
public BakedEvalExpandModel(IModel model, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IBlockState defaultBlockState, IVarExpander expander) {
	super(model.bake(state, format, bakedTextureGetter), PerspectiveMapWrapper.getTransforms(state));
	this.expander = expander;
	this.defaultBlockState = defaultBlockState;
}
 
Example #13
Source File: GTModelBlock.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return Pair.of(this, PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType).getRight());
}
 
Example #14
Source File: GTModelOre.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return Pair.of(this, PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType).getRight());
}
 
Example #15
Source File: BakedModelAdapter.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType);
}
 
Example #16
Source File: GTModelWire.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType);
}
 
Example #17
Source File: GTModelMortar.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType);
}
 
Example #18
Source File: IItemRenderer.java    From CodeChickenLib with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Called to handle this model's perspective. Either use {@link #getTransforms()}
 * Or add to the {@link MatrixStack} for the given {@link TransformType}.
 *
 * @param transformType Where we are handling perspective for.
 * @param mat           The {@link MatrixStack}.
 * @return The same model.
 */
@Override
default IBakedModel handlePerspective(TransformType transformType, MatrixStack mat) {
    return PerspectiveMapWrapper.handlePerspective(this, getTransforms(), transformType, mat);
}