private IBakedModel bakeModel(ModelBlock modelBlockIn, ModelRotation modelRotationIn, boolean uvLocked) { TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName("particle"))); SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn)).setTexture(textureatlassprite); for (BlockPart blockpart : modelBlockIn.getElements()) { for (EnumFacing enumfacing : blockpart.mapFaces.keySet()) { BlockPartFace blockpartface = (BlockPartFace)blockpart.mapFaces.get(enumfacing); TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)this.sprites.get(new ResourceLocation(modelBlockIn.resolveTextureName(blockpartface.texture))); if (blockpartface.cullFace == null) { simplebakedmodel$builder.addGeneralQuad(this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked)); } else { simplebakedmodel$builder.addFaceQuad(modelRotationIn.rotateFace(blockpartface.cullFace), this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked)); } } } return simplebakedmodel$builder.makeBakedModel(); }
private Set<ResourceLocation> getTextureLocations(ModelBlock p_177585_1_) { Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet(); for (BlockPart blockpart : p_177585_1_.getElements()) { for (BlockPartFace blockpartface : blockpart.mapFaces.values()) { ResourceLocation resourcelocation = new ResourceLocation(p_177585_1_.resolveTextureName(blockpartface.texture)); set.add(resourcelocation); } } set.add(new ResourceLocation(p_177585_1_.resolveTextureName("particle"))); return set; }
public MBJoint(String name, BlockPart part) { this.name = name; if(part.partRotation != null) { float x = 0, y = 0, z = 0; switch(part.partRotation.axis) { case X: x = 1; case Y: y = 1; case Z: z = 1; } Quat4f rotation = new Quat4f(); rotation.set(new AxisAngle4f(x, y, z, 0)); Matrix4f m = new TRSRTransformation( TRSRTransformation.toVecmath(part.partRotation.origin), rotation, null, null).getMatrix(); m.invert(); invBindPose = new TRSRTransformation(m); } else { invBindPose = TRSRTransformation.identity(); } }
public TRSRTransformation getPartTransform(IModelState state, BlockPart part, int i) { ImmutableCollection<MBJointWeight> infos = getJoint(i); if(!infos.isEmpty()) { Matrix4f m = new Matrix4f(), tmp; float weight = 0; for(MBJointWeight info : infos) { if(info.getWeights().containsKey(i)) { ModelBlockAnimation.MBJoint joint = new ModelBlockAnimation.MBJoint(info.getName(), part); Optional<TRSRTransformation> trOp = state.apply(Optional.of(joint)); if(trOp.isPresent() && trOp.get() != TRSRTransformation.identity()) { float w = info.getWeights().get(i)[0]; tmp = trOp.get().getMatrix(); tmp.mul(w); m.add(tmp); weight += w; } } } if(weight > 1e-5) { m.mul(1f / weight); return new TRSRTransformation(m); } } return null; }
public IBakedModel bake(IModelState state, final VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { if(!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT)) { throw new IllegalArgumentException("can't bake vanilla models to the format that doesn't fit into the default one: " + format); } ModelBlock model = this.model; if(model == null) return getMissingModel().bake(getMissingModel().getDefaultState(), format, bakedTextureGetter); List<TRSRTransformation> newTransforms = Lists.newArrayList(); for(int i = 0; i < model.getElements().size(); i++) { BlockPart part = model.getElements().get(i); newTransforms.add(animation.getPartTransform(state, part, i)); } ItemCameraTransforms transforms = model.getAllTransforms(); Map<TransformType, TRSRTransformation> tMap = Maps.newHashMap(); tMap.putAll(IPerspectiveAwareModel.MapWrapper.getTransforms(transforms)); tMap.putAll(IPerspectiveAwareModel.MapWrapper.getTransforms(state)); IModelState perState = new SimpleModelState(ImmutableMap.copyOf(tMap)); if(hasItemModel(model)) { return new ItemLayerModel(model).bake(perState, format, bakedTextureGetter); } if(isCustomRenderer(model)) return new BuiltInModel(transforms, model.createOverrides()); return bakeNormal(model, perState, state, newTransforms, format, bakedTextureGetter, uvlock); }
@Override public BlockPart deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException { JsonObject jsonobject = p_deserialize_1_.getAsJsonObject(); Vector3f vector3f = this.parsePositionFrom(jsonobject); Vector3f vector3f1 = this.parsePositionTo(jsonobject); BlockPartRotation blockpartrotation = this.parseRotation(jsonobject); Map<EnumFacing, BlockPartFace> map = this.parseFacesCheck(p_deserialize_3_, jsonobject); if (jsonobject.has("shade") && !JsonUtils.isBoolean(jsonobject, "shade")) { throw new JsonParseException("Expected shade to be a Boolean"); } else { boolean flag = JsonUtils.getBoolean(jsonobject, "shade", true); return new BlockPart(vector3f, vector3f1, map, blockpartrotation, flag); } }
private BakedQuad makeBakedQuad(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, ModelRotation p_177589_5_, boolean p_177589_6_) { return this.faceBakery.makeBakedQuad(p_177589_1_.positionFrom, p_177589_1_.positionTo, p_177589_2_, p_177589_3_, p_177589_4_, p_177589_5_, p_177589_1_.partRotation, p_177589_6_, p_177589_1_.shade); }
private Set<ResourceLocation> getItemsTextureLocations() { Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet(); for (ResourceLocation resourcelocation : this.itemLocations.values()) { ModelBlock modelblock = (ModelBlock)this.models.get(resourcelocation); if (modelblock != null) { set.add(new ResourceLocation(modelblock.resolveTextureName("particle"))); if (this.hasItemModel(modelblock)) { for (String s : ItemModelGenerator.LAYERS) { ResourceLocation resourcelocation2 = new ResourceLocation(modelblock.resolveTextureName(s)); if (modelblock.getRootModel() == MODEL_COMPASS && !TextureMap.LOCATION_MISSING_TEXTURE.equals(resourcelocation2)) { TextureAtlasSprite.setLocationNameCompass(resourcelocation2.toString()); } else if (modelblock.getRootModel() == MODEL_CLOCK && !TextureMap.LOCATION_MISSING_TEXTURE.equals(resourcelocation2)) { TextureAtlasSprite.setLocationNameClock(resourcelocation2.toString()); } set.add(resourcelocation2); } } else if (!this.isCustomRenderer(modelblock)) { for (BlockPart blockpart : modelblock.getElements()) { for (BlockPartFace blockpartface : blockpart.mapFaces.values()) { ResourceLocation resourcelocation1 = new ResourceLocation(modelblock.resolveTextureName(blockpartface.texture)); set.add(resourcelocation1); } } } } } return set; }
private static BakedQuad makeBakedQuad(BlockPart p_makeBakedQuad_0_, BlockPartFace p_makeBakedQuad_1_, TextureAtlasSprite p_makeBakedQuad_2_, EnumFacing p_makeBakedQuad_3_, ModelRotation p_makeBakedQuad_4_, boolean p_makeBakedQuad_5_) { FaceBakery facebakery = new FaceBakery(); return facebakery.makeBakedQuad(p_makeBakedQuad_0_.positionFrom, p_makeBakedQuad_0_.positionTo, p_makeBakedQuad_1_, p_makeBakedQuad_2_, p_makeBakedQuad_3_, p_makeBakedQuad_4_, p_makeBakedQuad_0_.partRotation, p_makeBakedQuad_5_, p_makeBakedQuad_0_.shade); }