Search in sources :

Example 11 with ModelResourceLocation

use of net.minecraft.client.renderer.model.ModelResourceLocation in project BluePower by Qmunity.

the class RenderHelper method drawColoredCube.

/**
 * Draws a colored cube with the size of vector. All faces have the specified color. This uses OpenGL
 *
 * @author Koen Beckers (K4Unl) and Amadornes
 * @param vector
 */
public static void drawColoredCube(AxisAlignedBB vector, IVertexBuilder vertexBuilder, MatrixStack matrixStack, int r, int g, int b, int a, int light, boolean... renderFaces) {
    MatrixStack.Entry entry = matrixStack.last();
    Matrix4f positionMatrix = entry.pose();
    Matrix3f normalMatrix = entry.normal();
    TextureAtlasSprite sprite = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation("minecraft:white_concrete", "")).getParticleIcon();
    float minU = sprite.getU0();
    float maxU = sprite.getU1();
    float minV = sprite.getV0();
    float maxV = sprite.getV1();
    // Top side
    if (renderFaces.length < 1 || renderFaces[0]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 1.0F, 0.0F).endVertex();
    }
    // Bottom side
    if (renderFaces.length < 2 || renderFaces[1]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, -1.0F, 0.0F).endVertex();
    }
    // Draw west side:
    if (renderFaces.length < 3 || renderFaces[5]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, -1.0F, 0.0F, 0.0F).endVertex();
    }
    // Draw east side:
    if (renderFaces.length < 4 || renderFaces[4]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 1.0F, 0.0F, 0.0F).endVertex();
    }
    // Draw north side
    if (renderFaces.length < 5 || renderFaces[3]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.minZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.minZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, -1.0F).endVertex();
    }
    // Draw south side
    if (renderFaces.length < 6 || renderFaces[2]) {
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.minY, (float) vector.maxZ).color(r, g, b, a).uv(minU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.maxX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, minV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
        vertexBuilder.vertex(positionMatrix, (float) vector.minX, (float) vector.maxY, (float) vector.maxZ).color(r, g, b, a).uv(maxU, maxV).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(light).normal(normalMatrix, 0.0F, 0.0F, 1.0F).endVertex();
    }
}
Also used : Matrix4f(net.minecraft.util.math.vector.Matrix4f) Matrix3f(net.minecraft.util.math.vector.Matrix3f) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation)

Example 12 with ModelResourceLocation

use of net.minecraft.client.renderer.model.ModelResourceLocation in project Overloaded by CJ-MC-Mods.

the class BlockAlmostInfiniteCapacitor method registerModel.

@OnlyIn(Dist.CLIENT)
@Override
public void registerModel() {
    ModelResourceLocation location = new ModelResourceLocation(getRegistryName(), null);
    // ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, location);
    ResizeableTextureGenerator.addToTextureQueue(new ResizeableTextureGenerator.ResizableTexture(new ResourceLocation(MODID, "textures/block/almost_infinite_capacitor.png"), new ResourceLocation(MODID, "textures/dynamic/blocks/almost_infinite_capacitor.png"), OverloadedConfig.INSTANCE.textureResolutions.blockResolution));
}
Also used : ResizeableTextureGenerator(com.cjm721.overloaded.client.render.dynamic.general.ResizeableTextureGenerator) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 13 with ModelResourceLocation

use of net.minecraft.client.renderer.model.ModelResourceLocation in project Overloaded by CJ-MC-Mods.

the class BlockCreativeGenerator method registerModel.

@OnlyIn(Dist.CLIENT)
@Override
public void registerModel() {
    ModelResourceLocation location = new ModelResourceLocation(getRegistryName(), "inventory");
    // ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, location);
    ImageUtil.registerDynamicTexture(new ResourceLocation(MODID, "textures/block/creative_generator.png"), OverloadedConfig.INSTANCE.textureResolutions.blockResolution);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 14 with ModelResourceLocation

use of net.minecraft.client.renderer.model.ModelResourceLocation in project Overloaded by CJ-MC-Mods.

the class ItemRailGun method registerModel.

@OnlyIn(Dist.CLIENT)
@Override
public void registerModel() {
    ModelResourceLocation location = new ModelResourceLocation(new ResourceLocation(MODID, "railgun"), null);
    // ModelLoader.setCustomModelResourceLocation(this, 0, location);
    ImageUtil.registerDynamicTexture(new ResourceLocation(MODID, "textures/item/railgun.png"), OverloadedConfig.INSTANCE.textureResolutions.itemResolution);
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 15 with ModelResourceLocation

use of net.minecraft.client.renderer.model.ModelResourceLocation in project Overloaded by CJ-MC-Mods.

the class ItemSettingEditor method registerModel.

@OnlyIn(Dist.CLIENT)
@Override
public void registerModel() {
    ModelResourceLocation location = new ModelResourceLocation(new ResourceLocation(MODID, "settings_editor"), null);
    // ModelLoader.setCustomModelResourceLocation(this, 0, location);
    ImageUtil.registerDynamicTexture(new ResourceLocation(MODID, "textures/item/settings_editor.png"), OverloadedConfig.INSTANCE.textureResolutions.itemResolution);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

ModelResourceLocation (net.minecraft.client.renderer.model.ModelResourceLocation)20 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)17 ResourceLocation (net.minecraft.util.ResourceLocation)15 ResizeableTextureGenerator (com.cjm721.overloaded.client.render.dynamic.general.ResizeableTextureGenerator)3 IBakedModel (net.minecraft.client.renderer.model.IBakedModel)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 MimicBlock (logictechcorp.libraryex.block.MimicBlock)1 MimicBakedModel (logictechcorp.libraryex.client.render.model.MimicBakedModel)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 BlockPos (net.minecraft.util.math.BlockPos)1 Matrix3f (net.minecraft.util.math.vector.Matrix3f)1 Matrix4f (net.minecraft.util.math.vector.Matrix4f)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1