本文整理汇总了Java中net.minecraftforge.common.model.IModelState类的典型用法代码示例。如果您正苦于以下问题:Java IModelState类的具体用法?Java IModelState怎么用?Java IModelState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IModelState类属于net.minecraftforge.common.model包,在下文中一共展示了IModelState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bake
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE);
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
for (Map.Entry<String, Material> e : matLib.materials.entrySet())
{
if (e.getValue().getTexture().getTextureLocation().getResourcePath().startsWith("#"))
{
FMLLog.log.fatal("OBJLoader: Unresolved texture '{}' for obj model '{}'", e.getValue().getTexture().getTextureLocation().getResourcePath(), modelLocation);
builder.put(e.getKey(), missing);
}
else
{
builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue().getTexture().getTextureLocation()));
}
}
builder.put("missingno", missing);
return new TintedOBJBakedModel(this, state, format, builder.build());
}
示例2: bake
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state);
TRSRTransformation transform = state.apply(Optional.empty()).orElse(TRSRTransformation.identity());
TextureAtlasSprite widgetSprite = bakedTextureGetter.apply(getWidgetTexture(widget));
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
int width = widget.getWidth() + (widget.getParameters() != null && widget.getParameters().length > 0 ? 10 : 0);
int height = widget.getHeight() + (widget.hasStepOutput() ? 5 : 0);
Pair<Double, Double> maxUV = widget.getMaxUV();
int textureSize = widget.getTextureSize();
float scale = 1F / (float) Math.max(maxUV.getLeft(), maxUV.getRight());
float transX = 0;//maxUV.getLeft().floatValue();
float transY = -1 + maxUV.getRight().floatValue();
transform = transform.compose(new TRSRTransformation(new Vector3f(0, 0, 0), null, new Vector3f(scale, scale, 1), null));
transform = transform.compose(new TRSRTransformation(new Vector3f(transX, transY, 0), null, new Vector3f(1, 1, 1), null));
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16 * maxUV.getLeft().floatValue(), 16 * maxUV.getRight().floatValue(), NORTH_Z_BASE, widgetSprite, EnumFacing.NORTH, 0xffffffff));
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 0, 0, 16 * maxUV.getLeft().floatValue(), 16 * maxUV.getRight().floatValue(), SOUTH_Z_BASE, widgetSprite, EnumFacing.SOUTH, 0xffffffff));
return new BakedProgrammingPuzzle(this, builder.build(), widgetSprite, format, Maps.immutableEnumMap(transformMap), Maps.newHashMap());
}
示例3: bake
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
for(Map.Entry<String, ResourceLocation> e : textures.entrySet())
{
if(e.getValue().getResourcePath().startsWith("#"))
{
FMLLog.severe("unresolved texture '%s' for b3d model '%s'", e.getValue().getResourcePath(), modelLocation);
builder.put(e.getKey(), missing);
}
else
{
builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue()));
}
}
builder.put("missingno", missing);
return new BakedWrapper(model.getRoot(), state, smooth, gui3d, format, meshes, builder.build());
}
示例4: apply
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
/**
* IModelState wrapper for a Clip, sampled at specified time.
*/
public static Pair<IModelState, Iterable<Event>> apply(final IClip clip, final float lastPollTime, final float time)
{
return Pair.<IModelState, Iterable<Event>>of(new IModelState()
{
public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part)
{
if(!part.isPresent() || !(part.get() instanceof IJoint))
{
return Optional.absent();
}
IJoint joint = (IJoint)part.get();
// TODO: Cache clip application?
TRSRTransformation jointTransform = clip.apply(joint).apply(time).compose(joint.getInvBindPose());
Optional<? extends IJoint> parent = joint.getParent();
while(parent.isPresent())
{
TRSRTransformation parentTransform = clip.apply(parent.get()).apply(time);
jointTransform = parentTransform.compose(jointTransform);
parent = parent.get().getParent();
}
return Optional.of(jointTransform);
}
}, clip.pastEvents(lastPollTime, time));
}
示例5: getQuads
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
@Override
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand)
{
if (side != null) return ImmutableList.of();
if (quads == null)
{
quads = buildQuads(this.state);
}
if (blockState instanceof IExtendedBlockState)
{
IExtendedBlockState exState = (IExtendedBlockState) blockState;
if (exState.getUnlistedNames().contains(Properties.AnimationProperty))
{
IModelState newState = exState.getValue(Properties.AnimationProperty);
if (newState != null)
{
newState = new ModelStateComposition(this.state, newState);
return buildQuads(newState);
}
}
}
return quads;
}
示例6: BakedWrapper
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
public BakedWrapper(final Node<?> node, final IModelState state, final boolean smooth, final boolean gui3d, final VertexFormat format, final ImmutableSet<String> meshes, final ImmutableMap<String, TextureAtlasSprite> textures)
{
this(node, state, smooth, gui3d, format, meshes, textures, CacheBuilder.newBuilder()
.maximumSize(128)
.expireAfterAccess(2, TimeUnit.MINUTES)
.<Integer, B3DState>build(new CacheLoader<Integer, B3DState>()
{
public B3DState load(Integer frame) throws Exception
{
IModelState parent = state;
Animation newAnimation = node.getAnimation();
if(parent instanceof B3DState)
{
B3DState ps = (B3DState)parent;
parent = ps.getParent();
}
return new B3DState(newAnimation, frame, frame, 0, parent);
}
}));
}
示例7: getParent
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
@Nullable
public IModelState getParent(IModelState parent)
{
if (parent == null) return null;
else if (parent instanceof OBJState) return ((OBJState) parent).parent;
return parent;
}
示例8: TintedOBJBakedModel
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
public TintedOBJBakedModel(TintedOBJModel model, IModelState state, VertexFormat format, ImmutableMap<String, TextureAtlasSprite> textures)
{
this.model = model;
this.state = state;
if (this.state instanceof OBJState) this.updateStateVisibilityMap((OBJState) this.state);
this.format = format;
this.textures = textures;
}
示例9: ModelHandle
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
private ModelHandle(ModelHandle handle, IModelState state)
{
this.model = handle.model;
this.vertexFormat = handle.vertexFormat;
this.state = state;
this.uvLock = handle.uvLock;
textureReplacements.putAll(handle.textureReplacements);
this.key = computeKey();
}
示例10: loadModel
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
private static IBakedModel loadModel(ModelHandle handle)
{
IBakedModel model = loadedModels.get(handle.getKey());
if (model != null)
return model;
try
{
IModel mod = ModelLoaderRegistry.getModel(handle.getModel());
if (handle.getTextureReplacements().size() > 0)
{
mod = mod.retexture(ImmutableMap.copyOf(handle.getTextureReplacements()));
}
if (handle.uvLocked())
{
mod = mod.uvlock(true);
}
IModelState state = handle.getState();
if (state == null) state = mod.getDefaultState();
model = mod.bake(state, handle.getVertexFormat(), ModelLoader.defaultTextureGetter());
loadedModels.put(handle.getKey(), model);
return model;
}
catch (Exception e)
{
throw new ReportedException(new CrashReport("Error loading custom model " + handle.getModel(), e));
}
}
示例11: bake
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format,
Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
IBakedModel[] connections = new IBakedModel[6];
IBakedModel[] endings = new IBakedModel[6];
IBakedModel[] nodeSides = new IBakedModel[6];
//IBakedModel node = null;
// d u n s w e
ModelRotation[] rotations = new ModelRotation[] { ModelRotation.X90_Y0, ModelRotation.X270_Y0,
ModelRotation.X0_Y0, ModelRotation.X0_Y180, ModelRotation.X0_Y270, ModelRotation.X0_Y90 };
try {
IModel nodeSideModel = ModelLoaderRegistry.getModel(new ResourceLocation(Etheric.MODID, "block/pipe_node_side"));
IModel connectionModel = ModelLoaderRegistry
.getModel(new ResourceLocation(Etheric.MODID, "block/pipe_connection"));
IModel endingModel = ModelLoaderRegistry.getModel(new ResourceLocation(Etheric.MODID, "block/pipe_end"));
//node = nodeModel.bake(new TRSRTransformation(ModelRotation.X0_Y0), DefaultVertexFormats.BLOCK,
// ModelLoader.defaultTextureGetter());
for (int i = 0; i < connections.length; i++) {
connections[i] = connectionModel.bake(new TRSRTransformation(rotations[i]), DefaultVertexFormats.BLOCK,
ModelLoader.defaultTextureGetter());
endings[i] = endingModel.bake(new TRSRTransformation(rotations[i]), DefaultVertexFormats.BLOCK,
ModelLoader.defaultTextureGetter());
nodeSides[i] = nodeSideModel.bake(new TRSRTransformation(rotations[i]), DefaultVertexFormats.BLOCK,
ModelLoader.defaultTextureGetter());
}
} catch (Exception e) {
Etheric.logger.warn(e.getMessage());
}
if (connections[0] == null) {
return ModelLoaderRegistry.getMissingModel().bake(state, format, bakedTextureGetter);
}
return new BakedPipeModel(nodeSides, connections, endings);
}
示例12: bake
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
public Map<ResourceLocation, IBakedModel> bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) throws Exception
{
Map<ResourceLocation, IBakedModel> ret = Maps.newHashMap();
for (TransportableChest chest : ChestRegistry.getChests())
{
for (ResourceLocation location : chest.getChestModels())
{
IModel model = ModelLoaderRegistry.getModel(location);
ret.put(location, model.bake(state, format, bakedTextureGetter));
}
}
return ret;
}
示例13: bake
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
@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());
}
示例14: bake
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
@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());
}
示例15: bake
import net.minecraftforge.common.model.IModelState; //导入依赖的package包/类
@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());
}