use of net.minecraftforge.common.model.IModelState in project MinecraftForge by MinecraftForge.
the class FancyMissingModel method bake.
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
IBakedModel bigMissing = missingModel.bake(state, format, bakedTextureGetter);
IModelState smallState = new ModelStateComposition(state, smallTransformation);
IBakedModel smallMissing = missingModel.bake(smallState, format, bakedTextureGetter);
return new BakedModel(bigMissing, smallMissing, fontCache.getUnchecked(format), message, bakedTextureGetter.apply(font2));
}
use of net.minecraftforge.common.model.IModelState in project MinecraftForge by MinecraftForge.
the class AnimationStateMachine method apply.
public Pair<IModelState, Iterable<Event>> apply(float time) {
if (lastPollTime == Float.NEGATIVE_INFINITY) {
lastPollTime = time;
}
Pair<IModelState, Iterable<Event>> pair = clipCache.getUnchecked(Triple.of(currentState, lastPollTime, time));
lastPollTime = time;
boolean shouldFilter = false;
if (shouldHandleSpecialEvents) {
for (Event event : ImmutableList.copyOf(pair.getRight()).reverse()) {
if (event.event().startsWith("!")) {
shouldFilter = true;
if (event.event().startsWith("!transition:")) {
String newState = event.event().substring("!transition:".length());
transition(newState);
} else {
System.out.println("Unknown special event \"" + event.event() + "\", ignoring");
}
}
}
}
if (!shouldFilter) {
return pair;
}
return Pair.of(pair.getLeft(), Iterables.filter(pair.getRight(), new Predicate<Event>() {
public boolean apply(Event event) {
return !event.event().startsWith("!");
}
}));
}
use of net.minecraftforge.common.model.IModelState in project Charset by CharsetMC.
the class ProxyClient method onModelBake.
@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
IBakedModel origModel = event.getModelRegistry().getObject(bmLoc);
ModelCompressionCrafter result = new ModelCompressionCrafter(origModel);
event.getModelRegistry().putObject(bmLoc, result);
ProgressManager.ProgressBar bar = ProgressManager.push("Compression Crafter", 6 + (4 * 12));
IModel modelRod = RenderUtils.getModel(new ResourceLocation("charset:block/compression_crafter_rod"));
for (EnumFacing side : EnumFacing.VALUES) {
bar.step("rod " + side.name());
rodModels[side.ordinal()] = modelRod.bake(ROTATIONS[side.ordinal()], DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
}
IModel model = RenderUtils.getModel(new ResourceLocation("charset:block/compression_crafter_block"));
IBlockState defState = CharsetCraftingCompression.blockCompressionCrafter.getDefaultState();
for (int i = 0; i < 4; i++) {
IModel retexModel = model.retexture(ImmutableMap.of("top", "charset:blocks/compact/compact_inner#" + i, "bottom", "charset:blocks/compact/compact_bottom#" + i, "side_x", "charset:blocks/compact/compact_side#" + i, "side_z", "charset:blocks/compact/compact_side#" + i));
for (int k = 0; k < 12; k++) {
bar.step("crafter " + (i * 4 + k + 1) + "/48");
if (i == 0 && k >= 6) {
for (EnumFacing side : EnumFacing.VALUES) {
result.quads[k][side.ordinal()][i] = result.quads[k - 6][side.ordinal()][i];
}
continue;
}
EnumFacing facing = EnumFacing.getFront(k % 6);
IModelState modelState = ROTATIONS[k % 6];
if (k >= 6) {
modelState = new ModelStateComposition(modelState, ModelRotation.X0_Y90);
}
IBakedModel bakedModel = retexModel.bake(modelState, DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
for (EnumFacing side : EnumFacing.VALUES) {
List<BakedQuad> list = bakedModel.getQuads(defState, side, 0);
int j = i;
if ((facing == EnumFacing.DOWN && (side == EnumFacing.SOUTH || side == EnumFacing.WEST)) || (facing == EnumFacing.UP && (side == EnumFacing.NORTH || side == EnumFacing.EAST)) || ((facing == EnumFacing.SOUTH || facing == EnumFacing.WEST) && (side.getAxis() == EnumFacing.Axis.Y || (side.getAxis() == facing.getAxis() && k < 8))) || (facing == EnumFacing.DOWN && side == EnumFacing.UP && k >= 6) || (facing.getAxis() != EnumFacing.Axis.Y && k >= 8 && side == facing.rotateY())) {
if (j == 1)
j = 2;
else if (j == 2)
j = 1;
}
result.quads[k][side.ordinal()][j] = list.get(0);
}
}
}
ProgressManager.pop(bar);
}
use of net.minecraftforge.common.model.IModelState in project Charset by CharsetMC.
the class ModelShelf method bake.
@Override
public IBakedModel bake(ShelfCacheInfo info, boolean isItem, BlockRenderLayer layer) {
IModel retexturedModel = (shelfModel.retexture(ImmutableMap.of("plank", info.plank.getIconName()))).uvlock(false);
IModelState state = ModelRotation.getModelRotation(0, (int) info.facing.getHorizontalAngle());
if (info.back) {
state = new ModelStateComposition(state, STATE_BACK);
}
return new WrappedBakedModel(retexturedModel.bake(state, DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter()), info.plank).addDefaultBlockTransforms();
}
use of net.minecraftforge.common.model.IModelState in project Charset by CharsetMC.
the class BarrelModel method bake.
@Override
public IBakedModel bake(BarrelCacheInfo info, boolean isItem, BlockRenderLayer layer) {
TextureAtlasSprite log = info.log;
TextureAtlasSprite plank = info.plank;
TextureAtlasSprite top = info.isMetal ? this.top_metal : this.top;
TextureAtlasSprite front = this.front;
TextureAtlasSprite side = this.side;
if (info.upgrades.contains(BarrelUpgrade.STICKY)) {
side = this.side_sticky;
front = info.upgrades.contains(BarrelUpgrade.SILKY) ? this.front_silky_sticky : this.front_sticky;
} else if (info.upgrades.contains(BarrelUpgrade.SILKY)) {
front = this.front_silky;
}
ImmutableMap.Builder<String, String> textures = new ImmutableMap.Builder<>();
if (isItem || layer == BlockRenderLayer.SOLID) {
textures.put("log", log.getIconName());
textures.put("plank", plank.getIconName());
} else {
textures.put("#log", "");
textures.put("log", "");
textures.put("#plank", "");
textures.put("plank", "");
}
if (isItem || layer == BlockRenderLayer.TRANSLUCENT) {
if (info.upgrades.contains(BarrelUpgrade.HOPPING)) {
top = this.top_hopping;
textures.put("hopping", side_hopping.getIconName());
} else {
textures.put("#hopping", "");
textures.put("hopping", "");
}
textures.put("top", top.getIconName());
textures.put("front", front.getIconName());
textures.put("side", side.getIconName());
} else {
textures.put("#top", "");
textures.put("top", "");
textures.put("#front", "");
textures.put("front", "");
textures.put("#side", "");
textures.put("side", "");
textures.put("#hopping", "");
textures.put("hopping", "");
}
IModelState state = info.orientation.toTransformation();
IModel retexture = template.retexture(textures.build());
return new WrappedBakedModel(retexture.bake(state, DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter()), log).addDefaultBlockTransforms();
}
Aggregations