use of net.minecraft.client.renderer.block.model.IBakedModel in project TechReborn by TechReborn.
the class SlotConfigPopupElement method draw.
@Override
public void draw(GuiBase gui) {
drawDefaultBackground(gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0));
super.draw(gui);
TileLegacyMachineBase machine = ((TileLegacyMachineBase) gui.tile);
IBlockAccess blockAccess = machine.getWorld();
BlockPos pos = machine.getPos();
IBlockState state = blockAccess.getBlockState(pos);
IBlockState actualState = state.getBlock().getDefaultState().getActualState(blockAccess, pos);
BlockRendererDispatcher dispatcher = FMLClientHandler.instance().getClient().getBlockRendererDispatcher();
IBakedModel model = dispatcher.getBlockModelShapes().getModelForState(state.getBlock().getDefaultState());
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
// left
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 4, 23);
// top
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, -12, -90F, 1F, 0F, 0F);
// centre
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 23, -90F, 0F, 1F, 0F);
// bottom
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 42, 90F, 1F, 0F, 0F);
// right
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 23, 180F, 0F, 1F, 0F);
// back
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 42, 90F, 0F, 1F, 0F);
drawSlotSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.DOWN.getFacing(machine), id, 22, 37, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), id, 41, 18, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.BACK.getFacing(machine), id, 41, 37, gui);
drawSlotSateColor(gui.getMachine(), MachineFacing.LEFT.getFacing(machine), id, 3, 18, gui);
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project Tropicraft by Tropicraft.
the class ClientProxy method onModelBake.
@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
for (Entry<String, String[]> e : blockVariants.entrySet()) {
for (String variant : e.getValue()) {
ModelResourceLocation loc = new ModelResourceLocation(Info.MODID + ":" + e.getKey(), variant);
IModel model = ModelLoaderRegistry.getModelOrLogError(loc, "Could not load arbitrary block variant " + variant + " for block " + e.getKey());
event.getModelRegistry().putObject(loc, model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()));
}
}
try {
IModel waterTop = ModelLoaderRegistry.getModel(new ResourceLocation("tropicraft:block/tropics_water_top"));
final IBakedModel waterTopBaked = waterTop.bake(waterTop.getDefaultState(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
Block[] fences = new Block[] { BlockRegistry.bambooFence, BlockRegistry.chunkFence, BlockRegistry.mahoganyFence, BlockRegistry.palmFence, BlockRegistry.thatchFence };
for (Block block : fences) {
ModelResourceLocation loc = new ModelResourceLocation(block.getRegistryName(), "normal");
final IBakedModel fenceModel = event.getModelRegistry().getObject(loc);
event.getModelRegistry().putObject(loc, new IBakedModel() {
@Override
@Nonnull
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
if (layer == null || layer == BlockRenderLayer.SOLID) {
return fenceModel.getQuads(state, side, rand);
} else if (layer == BlockRenderLayer.TRANSLUCENT && state.getValue(BlockTropicraftFence.WATER) == WaterState.SURFACE) {
return waterTopBaked.getQuads(state, side, rand);
}
return Collections.emptyList();
}
@Override
public boolean isGui3d() {
return true;
}
@Override
public boolean isBuiltInRenderer() {
return false;
}
@Override
public boolean isAmbientOcclusion() {
return true;
}
@Override
@Nonnull
public TextureAtlasSprite getParticleTexture() {
return fenceModel.getParticleTexture();
}
@Override
@Nonnull
public ItemOverrideList getOverrides() {
return fenceModel.getOverrides();
}
});
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project Tropicraft by Tropicraft.
the class RenderBambooItemFrame method doRender.
/**
* Renders the desired {@code T} type Entity.
*/
@Override
public void doRender(EntityBambooItemFrame entity, double x, double y, double z, float entityYaw, float partialTicks) {
GlStateManager.pushMatrix();
BlockPos blockpos = entity.getHangingPosition();
double d0 = (double) blockpos.getX() - entity.posX + x;
double d1 = (double) blockpos.getY() - entity.posY + y;
double d2 = (double) blockpos.getZ() - entity.posZ + z;
GlStateManager.translate(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D);
GlStateManager.rotate(180.0F - entity.rotationYaw, 0.0F, 1.0F, 0.0F);
this.renderManager.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
ModelManager modelmanager = blockrendererdispatcher.getBlockModelShapes().getModelManager();
IBakedModel ibakedmodel;
if (entity.getDisplayedItem() != null && entity.getDisplayedItem().getItem() == Items.FILLED_MAP) {
ibakedmodel = modelmanager.getModel(this.mapModel);
} else {
ibakedmodel = modelmanager.getModel(this.itemFrameModel);
}
GlStateManager.pushMatrix();
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
if (this.renderOutlines) {
GlStateManager.enableColorMaterial();
GlStateManager.enableOutlineMode(this.getTeamColor(entity));
}
blockrendererdispatcher.getBlockModelRenderer().renderModelBrightnessColor(ibakedmodel, 1.0F, 1.0F, 1.0F, 1.0F);
if (this.renderOutlines) {
GlStateManager.disableOutlineMode();
GlStateManager.disableColorMaterial();
}
GlStateManager.popMatrix();
GlStateManager.translate(0.0F, 0.0F, 0.4375F);
this.renderItem(entity);
GlStateManager.popMatrix();
this.renderName(entity, x + (double) ((float) entity.facingDirection.getFrontOffsetX() * 0.3F), y - 0.25D, z + (double) ((float) entity.facingDirection.getFrontOffsetZ() * 0.3F));
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project EnderIO by SleepyTrousers.
the class ItemModelRegistry method bakeModels.
@SubscribeEvent()
public void bakeModels(@Nonnull ModelBakeEvent event) {
for (Entry<ModelResourceLocation, Registry> entry : registries.entrySet()) {
final ModelResourceLocation resource = entry.getKey();
if (resource != null) {
IBakedModel model = event.getModelRegistry().getObject(resource);
final Registry registry = entry.getValue();
if (registry != null && model != null) {
event.getModelRegistry().putObject(resource, registry.wrap(model));
}
}
}
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project EnderIO by SleepyTrousers.
the class EnderItemOverrideList method handleItemState.
@SuppressWarnings("deprecation")
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) {
if (Prep.isInvalid(stack)) {
return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel();
}
Block block = Block.getBlockFromItem(stack.getItem());
if (block == Blocks.AIR) {
Registerable modObject = ModObjectRegistry.getModObject(stack.getItem());
if (modObject != null) {
block = modObject.getBlock();
}
if (block == null || block == Blocks.AIR) {
throw new NullPointerException("Wrong parameter 'ItemStack stack', not an ItemBlock and not registered with ModObjectRegistry");
}
}
if (block instanceof ITESRItemBlock) {
return RelayingBakedModel.wrapModelForTESRRendering(originalModel);
}
if (block instanceof IBlockPaintableBlock && (!(block instanceof IWrenchHideablePaint) || !YetaUtil.shouldHeldItemHideFacadesClient())) {
IBlockState paintSource = ((IBlockPaintableBlock) block).getPaintSource(block, stack);
if (paintSource != null && paintSource != Blocks.AIR.getDefaultState()) {
Pair<Block, Long> cacheKey = NullHelper.notnull(Pair.of((Block) null, new CacheKey().addCacheKey(paintSource).getCacheKey()), "no way");
ItemQuadCollector quads = cache.getIfPresent(cacheKey);
if (quads == null) {
quads = new ItemQuadCollector();
quads.addItemBlockState(paintSource, Prep.getEmpty());
quads.addBlockState(ModObject.block_machine_base.getBlockNN().getDefaultState().withProperty(EnumRenderPart.SUB, EnumRenderPart.PAINT_OVERLAY), Prep.getEmpty());
cache.put(cacheKey, quads);
}
return new CollectedItemQuadBakedBlockModel(originalModel, quads);
}
}
if (block instanceof ISmartRenderAwareBlock) {
IRenderMapper.IItemRenderMapper renderMapper = ((ISmartRenderAwareBlock) block).getItemRenderMapper();
Pair<Block, Long> cacheKey = Pair.of(block, renderMapper.getCacheKey(block, stack, new CacheKey().addCacheKey(stack.getMetadata())).getCacheKey());
ItemQuadCollector quads = cacheKey.getRight() == null ? null : cache.getIfPresent(cacheKey);
if (quads == null) {
quads = new ItemQuadCollector();
if (renderMapper instanceof IRenderMapper.IItemRenderMapper.IItemStateMapper) {
quads.addBlockStates(((IRenderMapper.IItemRenderMapper.IItemStateMapper) renderMapper).mapItemRender(block, stack, quads), stack, block);
} else if (renderMapper instanceof IRenderMapper.IItemRenderMapper.IItemModelMapper) {
List<IBakedModel> bakedModels = ((IRenderMapper.IItemRenderMapper.IItemModelMapper) renderMapper).mapItemRender(block, stack);
if (bakedModels != null) {
for (IBakedModel bakedModel : bakedModels) {
quads.addItemBakedModel(bakedModel);
}
}
} else {
return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel();
}
if (cacheKey.getRight() != null) {
cache.put(cacheKey, quads);
}
}
if (renderMapper instanceof IItemRenderMapper.IDynamicOverlayMapper) {
quads = quads.combine(((IItemRenderMapper.IDynamicOverlayMapper) renderMapper).mapItemDynamicOverlayRender(block, stack));
}
return new CollectedItemQuadBakedBlockModel(originalModel, quads);
}
return originalModel;
}
Aggregations