本文整理汇总了Java中net.minecraftforge.client.model.IModel类的典型用法代码示例。如果您正苦于以下问题:Java IModel类的具体用法?Java IModel怎么用?Java IModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IModel类属于net.minecraftforge.client.model包,在下文中一共展示了IModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bake
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
try
{
IModel sub = ModelLoaderRegistry.getModel(handle);
IBakedModel baked = sub.bake(state, format, bakedTextureGetter);
return new BakedModelCH(baked, ModelRegistry.getInstance().bake(state, format, bakedTextureGetter));
} catch (Exception e)
{
e.printStackTrace();
}
return ModelLoaderRegistry.getMissingModel().bake(state, format, bakedTextureGetter);
}
示例2: handleItemState
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack,
@Nullable World world, @Nullable EntityLivingBase entity) {
if (stack.getItem() != ModItems.sword) {
return originalModel;
}
BakedSwordModel model = (BakedSwordModel) originalModel;
String key = IBladeTool.getBladeMat(stack).getName() + "|"
+ ICrossguardTool.getCrossguardMat(stack).getName() + "|"
+ IHandleTool.getHandleMat(stack).getName() + "|"
+ IAdornedTool.getAdornmentMat(stack).getName();
if (!model.cache.containsKey(key)) {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("blade", IBladeTool.getBladeMat(stack).getName());
builder.put("crossguard", ICrossguardTool.getCrossguardMat(stack).getName());
builder.put("handle", IHandleTool.getHandleMat(stack).getName());
if (IAdornedTool.getAdornmentMat(stack) != ModMaterials.ADORNMENT_NULL) {
builder.put("adornment", IAdornedTool.getAdornmentMat(stack).getName());
}
IModel parent = model.parent.retexture(builder.build());
Function<ResourceLocation, TextureAtlasSprite> textureGetter;
textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
public TextureAtlasSprite apply(ResourceLocation location) {
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
}
};
IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format,
textureGetter);
model.cache.put(key, bakedModel);
return bakedModel;
}
return model.cache.get(key);
}
示例3: getModelClipNode
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
/**
* Retrieves the clip from the model.
*/
@SideOnly(Side.CLIENT)
public static IClip getModelClipNode(ResourceLocation modelLocation, String clipName)
{
IModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation);
if(model instanceof IAnimatedModel)
{
Optional<? extends IClip> clip = ((IAnimatedModel)model).getClip(clipName);
if(clip.isPresent())
{
return new ModelClip(clip.get(), modelLocation, clipName);
}
FMLLog.getLogger().error("Unable to find clip " + clipName + " in the model " + modelLocation);
}
// FIXME: missing clip?
return new ModelClip(IdentityClip.INSTANCE, modelLocation, clipName);
}
示例4: getBakedCluster
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
public static IBakedModel getBakedCluster(){
if(bakedCluster == null){
IModel model;
try {
model = OBJLoader.INSTANCE.loadModel(CrystalMod.resourceL("models/block/obj/cluster.obj"));
Function<ResourceLocation, TextureAtlasSprite> textureGetter;
textureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
{
@Override
public TextureAtlasSprite apply(ResourceLocation location)
{
return RenderUtil.getSprite(location);
}
};
bakedCluster = model.bake(new SimpleModelState(DynamicBaseModel.DEFAULT_PERSPECTIVE_TRANSFORMS), DefaultVertexFormats.BLOCK, textureGetter);
} catch (Exception e) {
e.printStackTrace();
}
}
return bakedCluster;
}
示例5: getActualModel
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
protected IBakedModel getActualModel(String texture)
{
IBakedModel bakedModel = standard;
if (texture!=null)
{
if (cache.containsKey(texture))
{
bakedModel = cache.get(texture);
}
else if (retexturableModel != null)
{
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("bottom", texture);
builder.put("top", texture);
builder.put("side", texture);
IModel retexturedModel = retexturableModel.retexture(builder.build());
bakedModel = retexturedModel.bake(TRSRTransformation.identity(), Attributes.DEFAULT_BAKED_FORMAT, ModelLoader.defaultTextureGetter());
cache.put(texture, bakedModel);
}
}
return bakedModel;
}
示例6: onModelBake
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@SubscribeEvent
public void onModelBake(ModelBakeEvent event)
{
try
{
IModel model = ModelLoaderRegistry.getModel(MODEL_grave);
if (model instanceof IRetexturableModel)
{
IRetexturableModel graveModel = (IRetexturableModel) model;
IBakedModel standard = event.getModelRegistry().getObject(locGrave);
IBakedModel finalModel = new GoodGraveModel(standard, graveModel);
event.getModelRegistry().putObject(locGrave, finalModel);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
示例7: bake
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format,
Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
try
{
IModel model = ModelLoaderRegistry.getModel(sourceModel);
if (model instanceof QBarOBJModel)
{
model = ((QBarOBJModel) model).retexture(replacedTextures);
return model.bake(state, format, bakedTextureGetter);
}
} catch (Exception e)
{
throw new RuntimeException(e);
}
return null;
}
示例8: getModel
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
protected IModel getModel(ResourceLocation modelLoc, ResourceLocation fallback) {
try {
return ModelLoaderRegistry.getModel(modelLoc);
} catch (Exception e) {
if (fallback != null) {
try {
return ModelLoaderRegistry.getModel(fallback);
} catch (Exception e2) {
logger.warn("Could not find model {} or fallback {}", modelLoc, fallback);
return ModelLoaderRegistry.getMissingModel();
}
}
logger.warn("Could not find model {}", modelLoc);
return ModelLoaderRegistry.getMissingModel();
}
}
示例9: process
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@Override
public IModel process(IModel base) {
boolean hasBase = base != ModelLoaderRegistry.getMissingModel();
if (hasBase) {
base = baseVariant.process(base);
}
List<IModel> subModels = new LinkedList<>();
for (Variant variant : finalVariants) {
if (!variant.getModelLocation().equals(new ResourceLocation("builtin/missing"))) {
IModel subModel = ModelLoaderRegistry.getModelOrLogError(variant.getModelLocation(), "Unable to load subModel's Model: " + variant.getModelLocation());
subModels.add(variant.process(new StateOverrideIModel(subModel, variant.getState())));
}
}
return new CCMultiModel(hasBase ? base : null, baseProperties, subModels);
}
示例10: getTextures
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Collection<ResourceLocation> getTextures() {
normalModels.clear();
Set<ResourceLocation> textures = Sets.newHashSet();
for (Entry<ResourceLocation, Integer> e : item.LOCATION_TO_META.entrySet()) {
ResourceLocation loc = e.getKey();
if (item.OVERRIDES.containsKey(e.getKey())) {
ResourceLocation[][] o = item.OVERRIDES.get(e.getKey());
textures.addAll(Arrays.asList(o[1]));
loc = o[0][0];
}
if (!normalModels.containsKey(loc)) {
normalModels.put(loc, getModel(loc));
}
IModel model = normalModels.get(loc);
textures.addAll(model.getTextures().stream().filter(l -> !l.getResourcePath().startsWith("texture")).collect(Collectors.toSet()));
}
return textures;
}
示例11: bake
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
CustomModelLoader.log.info("Baking " + nameN + " Model...");
IBlockState s = block.getDefaultState();
TerminalBakedModel.Builder builder = new Builder(bakedTextureGetter.apply(new ResourceLocation(hasFront ? imgLoc + "Front" : "tomsmodstorage:blocks/terminalFront")), block);
ResourceLocation base = new ResourceLocation("tomsmodstorage:block/" + block.getUnlocalizedName().substring(8, block.getUnlocalizedName().length() - 6) + "_base");
ResourceLocation front = new ResourceLocation("tomsmodstorage:block/terminalFront");
ResourceLocation terminalItemTransformsL = new ResourceLocation("tomsmodstorage:block/terminalitemtransforms");
IModel modelFront = getModel(front);
IModel terminalItemTransforms = getModel(terminalItemTransformsL);
TextureInjector injectorFront = new TextureInjector(bakedTextureGetter, hasFront ? imgLoc + "Front" : "tomsmodstorage:blocks/terminalFront");
TextureInjector injectorFrontP = new TextureInjector(bakedTextureGetter, hasFront ? imgLoc + "FrontP" : "tomsmodstorage:blocks/terminalFrontP");
TextureInjector injectorFrontOn = new TextureInjector(bakedTextureGetter, hasFront ? imgLoc + "FrontOn" : "tomsmodstorage:blocks/terminalFrontOn");
builder.setItemCameraTransformsModel(terminalItemTransforms.bake(state, format, bakedTextureGetter));
// load(null, builder, modelBase, modelFront, bakedTextureGetter,
// injectorFront, injectorFrontOn, format, s);
for (int ss = 0;ss < block.getStates();ss++) {
for (int i = 0;i < TileEntityBasicTerminal.TerminalState.VALUES.length;i++) {
TileEntityBasicTerminal.TerminalState termState = TileEntityBasicTerminal.TerminalState.VALUES[i];
load(termState, builder, base, modelFront, bakedTextureGetter, injectorFront, injectorFrontP, injectorFrontOn, format, s, ss);
}
}
TerminalBakedModel model = builder.makeModel();
CustomModelLoader.log.info(nameN + " Model Baking Complete.");
return model;
}
示例12: getConnectedSide
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@Override
public IModel getConnectedSide(boolean isTop,
boolean isBottom, boolean isDouble) {
if (!isDouble) {
return isBottom ? isTop ? this.singleSideLone :
this.singleSideBottom : isTop ?
this.singleSideTop : this.singleSideMiddle;
} else {
return isBottom ? isTop ? this.doubleSideLone :
this.doubleSideBottom : isTop ?
this.doubleSideTop : this.doubleSideMiddle;
}
}
示例13: getPostModel
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
/** @return Model for this wall's post with given properties. */
protected IModel getPostModel(boolean isTop, boolean isBottom,
boolean isDouble) {
if (!isDouble) {
return isBottom ? isTop ? this.singlePostLone :
this.singlePostBottom : isTop ?
this.singlePostTop : this.singlePostMiddle;
} else {
return isBottom ? isTop ? this.doublePostLone :
this.doublePostBottom : isTop ?
this.doublePostTop : this.doublePostMiddle;
}
}
示例14: bake
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@Override
public IBakedModel bake(IModelState state, VertexFormat format,
Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
ARKCraft.logger.info("Baking Cable Model");
ResourceLocation noc = new ResourceLocation("arkcraft:block/cable_noc");
ResourceLocation center = new ResourceLocation("arkcraft:block/cable_base");
ResourceLocation connection = new ResourceLocation("arkcraft:block/cable_c");
ResourceLocation vertical = new ResourceLocation("arkcraft:block/cable_v");
ResourceLocation centerP = new ResourceLocation("arkcraft:block/cable_base_powered");
ResourceLocation connectionP = new ResourceLocation("arkcraft:block/cable_c_powered");
ResourceLocation verticalP = new ResourceLocation("arkcraft:block/cable_v_powered");
IBakedModel[] connections = new IBakedModel[4];
IBakedModel[] connectionsP = new IBakedModel[4];
IModel modelConnection = getModel(connection);
IModel modelConnectionP = getModel(connectionP);
for(EnumFacing f : EnumFacing.HORIZONTALS){
connections[f.ordinal() - 2] = modelConnection.bake(new TRSRTransformation(getMatrix(f)), format, bakedTextureGetter);
connectionsP[f.ordinal() - 2] = modelConnectionP.bake(new TRSRTransformation(getMatrix(f)), format, bakedTextureGetter);
}
return new BakedCableModel(getModel(noc).bake(state, format, bakedTextureGetter),
new IBakedModel[]{getModel(center).bake(state, format, bakedTextureGetter), getModel(centerP).bake(state, format, bakedTextureGetter)},
new IBakedModel[][]{connections, connectionsP},
new IBakedModel[]{getModel(vertical).bake(state, format, bakedTextureGetter), getModel(verticalP).bake(state, format, bakedTextureGetter)});
}
示例15: bakeModels
import net.minecraftforge.client.model.IModel; //导入依赖的package包/类
@SubscribeEvent
public void bakeModels(TextureStitchEvent.Post event) {
final TextureMap map = event.map;
Function<ResourceLocation,TextureAtlasSprite> lookup = new Function<ResourceLocation, TextureAtlasSprite>() {
@Nullable
@Override
public TextureAtlasSprite apply(@Nullable ResourceLocation input) {
if (input == null) return map.getAtlasSprite(null);
return map.getAtlasSprite(input.toString());
}
};
for (FzModel fzm : instances) {
IModel rawModel = raws.get(fzm);
if (rawModel == null) {
fzm.model = null;
continue;
}
fzm.model = rawModel.bake(fzm.trsrt, fzm.getFormat(), lookup);
}
raws.clear();
}