@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)); }
@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)); }
@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)); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (headTexture != null && haftTexture != null && handleTexture != null) { ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder(); if (haftTexture != null) { texBuilder.add(haftTexture); } if (headTexture != null) { texBuilder.add(headTexture); } if (handleTexture != null) { texBuilder.add(handleTexture); } if (adornmentTexture != null) { texBuilder.add(adornmentTexture); } ImmutableList<ResourceLocation> textures = texBuilder.build(); IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter); builder.addAll(model.getQuads(null, null, 0)); } return new BakedMaceModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (bladeTexture != null && handleTexture != null) { ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder(); if (bladeTexture != null) { texBuilder.add(bladeTexture); } if (handleTexture != null) { texBuilder.add(handleTexture); } if (adornmentTexture != null) { texBuilder.add(adornmentTexture); } ImmutableList<ResourceLocation> textures = texBuilder.build(); IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter); builder.addAll(model.getQuads(null, null, 0)); } return new BakedDaggerModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (headTexture != null && haftTexture != null && handleTexture != null) { ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder(); if (haftTexture != null) { texBuilder.add(haftTexture); } if (headTexture != null) { texBuilder.add(headTexture); } if (handleTexture != null) { texBuilder.add(handleTexture); } if (adornmentTexture != null) { texBuilder.add(adornmentTexture); } ImmutableList<ResourceLocation> textures = texBuilder.build(); IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter); builder.addAll(model.getQuads(null, null, 0)); } return new BakedHoeModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (headTexture != null && haftTexture != null && handleTexture != null) { ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder(); if (haftTexture != null) { texBuilder.add(haftTexture); } if (headTexture != null) { texBuilder.add(headTexture); } if (handleTexture != null) { texBuilder.add(handleTexture); } if (adornmentTexture != null) { texBuilder.add(adornmentTexture); } ImmutableList<ResourceLocation> textures = texBuilder.build(); IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter); builder.addAll(model.getQuads(null, null, 0)); } return new BakedPickaxeModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (headTexture != null && haftTexture != null && handleTexture != null) { ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder(); if (haftTexture != null) { texBuilder.add(haftTexture); } if (headTexture != null) { texBuilder.add(headTexture); } if (handleTexture != null) { texBuilder.add(handleTexture); } if (adornmentTexture != null) { texBuilder.add(adornmentTexture); } ImmutableList<ResourceLocation> textures = texBuilder.build(); IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter); builder.addAll(model.getQuads(null, null, 0)); } return new BakedAxeModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (headTexture != null && haftTexture != null && handleTexture != null) { ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder(); if (haftTexture != null) { texBuilder.add(haftTexture); } if (headTexture != null) { texBuilder.add(headTexture); } if (handleTexture != null) { texBuilder.add(handleTexture); } if (adornmentTexture != null) { texBuilder.add(adornmentTexture); } ImmutableList<ResourceLocation> textures = texBuilder.build(); IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter); builder.addAll(model.getQuads(null, null, 0)); } return new BakedHammerModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (headTexture != null && haftTexture != null && handleTexture != null) { ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder(); if (haftTexture != null) { texBuilder.add(haftTexture); } if (headTexture != null) { texBuilder.add(headTexture); } if (handleTexture != null) { texBuilder.add(handleTexture); } if (adornmentTexture != null) { texBuilder.add(adornmentTexture); } ImmutableList<ResourceLocation> textures = texBuilder.build(); IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter); builder.addAll(model.getQuads(null, null, 0)); } return new BakedShovelModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); ImmutableList<ResourceLocation> textures = ImmutableList.<ResourceLocation>of(new ResourceLocation(modid, "items/" + toolName + "/" + partName + "_" + matName)); builder.addAll(new ItemLayerModel(textures).bake(state, format, bakedTextureGetter).getQuads(null, null, 0)); return new BakedToolHeadModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (bladeTexture != null && crossguardTexture != null && handleTexture != null) { ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder(); if (bladeTexture != null) { texBuilder.add(bladeTexture); } if (handleTexture != null) { texBuilder.add(handleTexture); } if (crossguardTexture != null) { texBuilder.add(crossguardTexture); } if (adornmentTexture != null) { texBuilder.add(adornmentTexture); } ImmutableList<ResourceLocation> textures = texBuilder.build(); IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter); builder.addAll(model.getQuads(null, null, 0)); } return new BakedSwordModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType type) { if(instrument != null) { HashMap<ItemCameraTransforms.TransformType, TRSRTransformation> map = new HashMap<>(); map.put(ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, new TRSRTransformation(new Vector3f(1F, 0F, 1F), TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 180F, 0F)), new Vector3f(1F, 1F, 1F), new Quat4f())); map.put(ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, new TRSRTransformation(new Vector3f(0.1F, 0F + (instrument.handImg.getHeight() <= 16F ? 0F : MathHelper.clamp((float)instrument.info.activeHandPosition[1], -0.3F, 0.3F)), 0.025F - (instrument.handImg.getWidth() <= 16F ? 0F : MathHelper.clamp((float)instrument.info.activeHandPosition[0], -0.5F, 0.5F))), TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 80F, 0F)), new Vector3f(-1F, 1F, 1F), TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 0F, 0F)))); map.put(ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, new TRSRTransformation(new Vector3f(-0.1F, 0F + (instrument.handImg.getHeight() <= 16F ? 0F : MathHelper.clamp((float)instrument.info.activeHandPosition[1], -0.3F, 0.3F)), 1F - (instrument.handImg.getWidth() <= 16F ? 0F : MathHelper.clamp((float)instrument.info.activeHandPosition[0], -0.5F, 0.5F))), TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 80F, 0F)), new Vector3f(1F, 1F, 1F), TRSRTransformation.quatFromXYZDegrees(new Vector3f(0F, 0F, 0F)))); ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms = ImmutableMap.copyOf(map); return PerspectiveMapWrapper.handlePerspective(ModelBaseWrapper.isEntityRender(type) ? instrument.handModel : instrument.iconModel, transforms, type); } return PerspectiveMapWrapper.handlePerspective(this, transforms, type); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { if (properties instanceof PerspectiveProperties) { return PerspectiveMapWrapper.handlePerspective(this, ((PerspectiveProperties) properties).getModelState(), cameraTransformType); } return IModelParticleProvider.super.handlePerspective(cameraTransformType); }
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); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { final ImmutableMap<TransformType, TRSRTransformation> transforms = PerspectiveMapWrapper.getTransforms(state); final IModel base; if (baseModel.isPresent()) { base = ModelLoaderRegistry.getModelOrLogError(baseModel.get(), "Couldn't load canvas base: " + baseModel.get()); } else { base = ModelLoaderRegistry.getMissingModel(); } final IBakedModel bakedBaseModel = base.bake(state, format, bakedTextureGetter); return new BakedModelCanvas(bakedBaseModel, baseModelRenderLayers, transforms, bakedTextureGetter, format); }
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; }
@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); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, state, cameraTransformType); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, transforms, cameraTransformType); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state); TRSRTransformation transform = (TRSRTransformation.identity()); ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); if (headTexture != null && haftTexture != null && handleTexture != null) { ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder(); if (haftTexture != null) { texBuilder.add(haftTexture); } if (headTexture != null) { texBuilder.add(headTexture); } if (handleTexture != null) { texBuilder.add(handleTexture); } if (adornmentTexture != null) { texBuilder.add(adornmentTexture); } ImmutableList<ResourceLocation> textures = texBuilder.build(); IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter); builder.addAll(model.getQuads(null, null, 0)); } return new BakedHandpickModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap()); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, this.model.getState(), cameraTransformType); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, this.transforms, cameraTransformType); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, this.transformMap, cameraTransformType); }
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; }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType); }
/** * Override this to do more custom transforms that cannot be done through getTransforms. * I HIGHLY suggest using getTransforms and just creating a static CCModelState and passing that trough. * You should be able to do all perspective aware transforms you need to through that. * * @param cameraTransformType The transform type. * @return The IBakedModel to actually render and the Matrix4 to apply as transforms. */ @Override default Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { CCRenderItem.notifyTransform(cameraTransformType); return PerspectiveMapWrapper.handlePerspective(this, getTransforms(), cameraTransformType); }