net.minecraft.client.renderer.texture.TextureAtlasSprite Java Examples

The following examples show how to use net.minecraft.client.renderer.texture.TextureAtlasSprite. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GTModelTestTube.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format,
		Function<ResourceLocation, TextureAtlasSprite> getter) {
	if (BAKED_BASE == null)
		BAKED_BASE = GTModelUtils.load(GTMod.MODID, "test_tube_model").bake(state, format, getter);
	if (BAKED_OVERLAY == null)
		BAKED_OVERLAY = GTModelUtils.load(GTMod.MODID, "test_tube_overlay_model").bake(state, format, getter);
	ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
	if (fluid != null) {
		TextureAtlasSprite sprite = getter.apply(fluid.getStill());
		if (sprite != null) {
			List<BakedQuad> quads = BAKED_OVERLAY.getQuads(null, null, 0);
			quads = GTModelUtils.texAndTint(quads, fluid.getColor(), sprite);
			builder.addAll(quads);
		}
	}
	builder.addAll(BAKED_BASE.getQuads(null, null, 0));
	return new GTBakedTestTube(builder.build(), this, getter.apply(BASE), format);
}
 
Example #2
Source File: CustomParticleHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
@OnlyIn (Dist.CLIENT)
public static boolean handleRunningEffects(World world, BlockPos pos, BlockState state, Entity entity) {
    //Spoof a raytrace from the feet.
    BlockRayTraceResult traceResult = new BlockRayTraceResult(entity.getPositionVec().add(0, 1, 0), Direction.UP, pos, false);
    BlockModelShapes modelShapes = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes();
    IBakedModel model = modelShapes.getModel(state);
    if (model instanceof IModelParticleProvider) {
        IModelData modelData = ModelDataManager.getModelData(world, pos);
        ParticleManager particleManager = Minecraft.getInstance().particles;
        List<TextureAtlasSprite> sprites = new ArrayList<>(((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos, modelData));
        TextureAtlasSprite rolledSprite = sprites.get(world.rand.nextInt(sprites.size()));
        double x = entity.getPosX() + (world.rand.nextFloat() - 0.5D) * entity.getWidth();
        double y = entity.getBoundingBox().minY + 0.1D;
        double z = entity.getPosZ() + (world.rand.nextFloat() - 0.5D) * entity.getWidth();
        particleManager.addEffect(new CustomBreakingParticle(world, x, y, z, -entity.getMotion().x * 4.0D, 1.5D, -entity.getMotion().z * 4.0D, rolledSprite));
        return true;
    }

    return false;
}
 
Example #3
Source File: EvalExpandModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final IModel model = loadBaseModel(state, format, bakedTextureGetter);

	IBlockState blockState = null;

	if (defaultBlockState.isPresent()) {
		final Block defaultBlock = Block.REGISTRY.getObject(defaultBlockState.get());
		if (defaultBlock != Blocks.AIR) {
			blockState = defaultBlock.getDefaultState();
			if (!(blockState instanceof IExtendedBlockState) ||
					!((IExtendedBlockState)blockState).getUnlistedNames().contains(EvalModelState.PROPERTY)) {
				Log.warn("State %s does not contain eval state property", blockState);
			}
		} else {
			Log.warn("Can't find default block: %s", defaultBlockState.get());
		}
	}

	final IVarExpander expander = evaluatorFactory.createExpander();
	return new BakedEvalExpandModel(model, state, format, bakedTextureGetter, blockState, expander);
}
 
Example #4
Source File: VariantModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final Map<ResourceLocation, IBakedModel> bakedSubModels = Maps.newHashMap();

	for (ResourceLocation subModel : modelData.getAllModels()) {
		IModel model = ModelLoaderRegistry.getModelOrLogError(subModel, "Couldn't load sub-model dependency: " + subModel);
		bakedSubModels.put(subModel, model.bake(new ModelStateComposition(state, model.getDefaultState()), format, bakedTextureGetter));
	}

	final IModel baseModel;
	if (base.isPresent()) {
		ResourceLocation baseLocation = base.get();
		baseModel = ModelLoaderRegistry.getModelOrLogError(baseLocation, "Couldn't load base-model dependency: " + baseLocation);
	} else {
		baseModel = ModelLoaderRegistry.getMissingModel();
	}

	final IBakedModel bakedBaseModel = baseModel.bake(new ModelStateComposition(state, baseModel.getDefaultState()), format, bakedTextureGetter);

	return new BakedModel(bakedBaseModel, modelData, bakedSubModels, PerspectiveMapWrapper.getTransforms(state));
}
 
Example #5
Source File: ParticleGlint.java    From Logistics-Pipes-2 with MIT License 6 votes vote down vote up
public ParticleGlint(World worldIn, double x, double y, double z, double vx, double vy, double vz, float r, float g, float b, float scale, int lifetime) {
	super(worldIn,x,y,z,0,0,0);
	this.colorR = r;
	this.colorG = g;
	this.colorB = b;
	if (this.colorR > 1.0){
		this.colorR = this.colorR/255.0f;
	}
	if (this.colorG > 1.0){
		this.colorG = this.colorG/255.0f;
	}
	if (this.colorB > 1.0){
		this.colorB = this.colorB/255.0f;
	}
	this.setRBGColorF(colorR, colorG, colorB);
	this.particleMaxAge = (int)((float)lifetime*0.5f);
	this.particleScale = scale;
	this.initScale = scale;
	this.motionX = vx;
	this.motionY = vy;
	this.motionZ= vz;
	this.particleAngle = 2.0f*(float)Math.PI;
	TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(texture.toString());
	this.setParticleTexture(sprite);
}
 
Example #6
Source File: RenderBlockGrate.java    From AgriCraft with MIT License 6 votes vote down vote up
@Override
protected void renderWorldBlockWoodDynamic(ITessellator tess, World world, BlockPos pos, BlockGrate block,
        TileEntityGrate grate, TextureAtlasSprite sprite) {
    //vines
    final TextureAtlasSprite vinesIcon = BaseIcons.VINE.getIcon();
    int l = this.getMixedBrightness(grate.getWorld(), grate.getPos(), Blocks.VINE.getDefaultState());
    float f0 = (float) (l >> 16 & 255) / 255.0F;
    float f1 = (float) (l >> 8 & 255) / 255.0F;
    float f2 = (float) (l & 255) / 255.0F;
    tess.setColorRGB(f0, f1, f2);

    if (grate.hasVines(true)) {
        tess.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.NORTH, vinesIcon, 0.001f);
    }
    if (grate.hasVines(false)) {
        tess.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.NORTH, vinesIcon, 1.999f);
    }
}
 
Example #7
Source File: BakedModelInserter.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    IModel baseModel = null;
    IModel sideModel = null;

    try
    {
        baseModel = ModelLoaderRegistry.getModel(BASE_MODEL);
        sideModel = ModelLoaderRegistry.getModel(SIDE_MODEL);
    }
    catch (Exception e)
    {
        EnderUtilities.logger.warn("Failed to load a model for the Inserter!");
    }

    return new BakedModelInserter(this, baseModel, sideModel, state, format, bakedTextureGetter);
}
 
Example #8
Source File: RenderUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void renderFluidGauge(FluidStack stack, Rectangle4i rect, double density, double res) {
    if (!shouldRenderFluid(stack))
        return;

    int alpha = 255;
    if (stack.getFluid().isGaseous())
        alpha = (int) (fluidDensityToAlpha(density) * 255);
    else {
        int height = (int) (rect.h * density);
        rect.y += rect.h - height;
        rect.h = height;
    }

    TextureAtlasSprite tex = prepareFluidRender(stack, alpha);
    CCRenderState.startDrawing();
    renderFluidQuad(
            new Vector3(rect.x, rect.y + rect.h, 0),
            new Vector3(rect.w, 0, 0),
            new Vector3(0, -rect.h, 0), tex, res);
    CCRenderState.draw();
    postFluidRender();
}
 
Example #9
Source File: MultiLayerModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(final IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final Map<BlockRenderLayer, IBakedModel> bakedModels = Maps.transformValues(models, location -> bakeModel(location, state, format, bakedTextureGetter));

	IModel missing = ModelLoaderRegistry.getMissingModel();
	IBakedModel bakedMissing = missing.bake(missing.getDefaultState(), format, bakedTextureGetter);

	final IBakedModel bakedBase;
	if (base.isPresent()) {
		bakedBase = bakeModel(base.get(), state, format, bakedTextureGetter);
	} else {
		bakedBase = bakedMissing;
	}

	return new MultiLayerBakedModel(
			bakedModels,
			bakedBase,
			bakedMissing,
			PerspectiveMapWrapper.getTransforms(state));
}
 
Example #10
Source File: RenderCrop.java    From AgriCraft with MIT License 6 votes vote down vote up
@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, BlockCrop block, EnumFacing side) {
    TextureAtlasSprite sprite = RenderCrop.getIcon(TEXTURE);
    this.renderBaseQuads(tessellator, side, sprite);
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState extendedState = (IExtendedBlockState) state;
        IAgriPlant plant = extendedState.getValue(AgriProperties.CROP_PLANT);
        int growthstage = extendedState.getValue(AgriProperties.GROWTH_STAGE);
        if (extendedState.getValue(AgriProperties.CROSS_CROP)) {
            tessellator.drawScaledPrism(0, 10, 2, 16, 11, 3, sprite);
            tessellator.drawScaledPrism(0, 10, 13, 16, 11, 14, sprite);
            tessellator.drawScaledPrism(2, 10, 0, 3, 11, 16, sprite);
            tessellator.drawScaledPrism(13, 10, 0, 14, 11, 16, sprite);
        }
        if (plant != null) {
            tessellator.addQuads(plant.getPlantQuads(extendedState, growthstage, side, tessellator));
        }
    }
}
 
Example #11
Source File: EvalModelBase.java    From OpenModsLib with MIT License 5 votes vote down vote up
protected IModel loadBaseModel(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	if (baseModel.isPresent()) {
		return ModelLoaderRegistry.getModelOrLogError(baseModel.get(), "Couldn't load eval model dependency: " + baseModel.get());
	} else {
		return ModelLoaderRegistry.getMissingModel();
	}
}
 
Example #12
Source File: RenderChannelFull.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
protected void renderBottom(ITessellator tessellator, TextureAtlasSprite matIcon) {
    //draw bottom
    tessellator.drawScaledPrism(0, 0, 0, 16, 5, 16, matIcon);
    //draw top
    tessellator.drawScaledPrism(0, 12, 0, 16, 16, 16, matIcon);
    //draw four corners
    tessellator.drawScaledPrism(0, 5, 0, 5, 12, 5, matIcon);
    tessellator.drawScaledPrism(11, 5, 0, 16, 12, 5, matIcon);
    tessellator.drawScaledPrism(11, 5, 11, 16, 12, 16, matIcon);
    tessellator.drawScaledPrism(0, 5, 11, 5, 12, 16, matIcon);

}
 
Example #13
Source File: PlantRenderer.java    From AgriCraft with MIT License 5 votes vote down vote up
private static void renderStemPattern(ITessellator tessellator, TextureAtlasSprite icon) {
    int minY = 0;
    int maxY = 12;
    tessellator.drawScaledFaceDouble(-2, minY, 10, maxY, EnumFacing.NORTH, icon, 4);
    tessellator.drawScaledFaceDouble(6, minY, 18, maxY, EnumFacing.EAST, icon, 4);
    tessellator.drawScaledFaceDouble(6, minY, 18, maxY, EnumFacing.NORTH, icon, 12);
    tessellator.drawScaledFaceDouble(-2, minY, 10, maxY, EnumFacing.EAST, icon, 12);
}
 
Example #14
Source File: HydroponicTESR.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public void renderGrowthMedium(HydroponicTileEntity tileEntity, double x, double y, double z, float partialTicks,
         int destroyStage, float partial, BufferBuilder buffer) {

            // I was hella lazy here, could be improved

            final float PX = 1f / 16f;
            final float YOFF = 12 * PX;
            final float BORDER = 6f * PX;
            final float MAXHEIGHT = 4 * PX;
    
            float actualHeight = MAXHEIGHT + YOFF;

            TextureAtlasSprite containerTexture =  Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(CONTAINER_TEXTURE);
            TextureAtlasSprite texture = containerTexture;
            
            int mediumId = tileEntity.getGrowthMediumId();

            if (mediumId > 0) {
                IBlockState growthMediaBlockState = HydroponicHelper.getMediumBlockStateFromId(mediumId);
                BlockModelShapes bm = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
                texture = bm.getTexture(growthMediaBlockState);
            }

            // Lightmap calculations
            int upCombined = getWorld().getCombinedLight(tileEntity.getPos().up(), 0);
            int upLMa = upCombined >> 16 & 65535;
            int upLMb = upCombined & 65535;
    
            buffer.setTranslation(x,y,z);
    
            //UP face
            buffer.pos(BORDER, actualHeight, BORDER).color(1f,1f,1f,1f).tex(texture.getMinU(), texture.getMinV()).lightmap(upLMa,upLMb).endVertex();
            buffer.pos(1 - BORDER, actualHeight, BORDER).color(1f,1f,1f,1f).tex(texture.getMaxU(), texture.getMinV()).lightmap(upLMa,upLMb).endVertex();
            buffer.pos(1 - BORDER, actualHeight, 1 - BORDER).color(1f,1f,1f,1f).tex(texture.getMaxU(), texture.getMaxV()).lightmap(upLMa,upLMb).endVertex();
            buffer.pos(BORDER, actualHeight, 1 - BORDER).color(1f,1f,1f,1f).tex(texture.getMinU(), texture.getMaxV()).lightmap(upLMa,upLMb).endVertex();
}
 
Example #15
Source File: PlantRenderer.java    From AgriCraft with MIT License 5 votes vote down vote up
private static void renderCrossPattern(ITessellator tessellator, TextureAtlasSprite icon, int layer) {
    int minY = 16 * layer;
    int maxY = 16 * (layer + 1);
    tessellator.pushMatrix();
    tessellator.translate(0.5f, 0, 0.5f);
    tessellator.rotate(45, 0, 1, 0);
    tessellator.translate(-0.5f, 0, -0.5f);
    tessellator.drawScaledFaceDouble(0, minY, 16, maxY, EnumFacing.NORTH, icon, 8);
    tessellator.drawScaledFaceDouble(0, minY, 16, maxY, EnumFacing.EAST, icon, 8);
    tessellator.popMatrix();
}
 
Example #16
Source File: GTModelBlock.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void init() {
	int layers = this.block.getLayers(this.meta);
	this.quads = this.createList(7);
	this.setParticalTexture(this.block.getParticleTexture(this.meta));
	boolean color = this.block instanceof IGTColorBlock;
	EnumFacing blockFacing = EnumFacing.NORTH;
	ModelRotation rotation = ModelRotation.X0_Y0;
	for (int i = 0; i < layers; ++i) {
		AxisAlignedBB box = this.block.getRenderBox(this.meta, i);
		EnumFacing[] facings;
		int facingLength;
		int j;
		EnumFacing side;
		ModelRotation sideRotation;
		BlockPartFace face;
		TextureAtlasSprite sprite;
		facings = EnumFacing.VALUES;
		facingLength = facings.length;
		for (j = 0; j < facingLength; ++j) {
			side = facings[j];
			sideRotation = this.getRotation(blockFacing, side, rotation);
			face = this.createBlockFace(side, i, color);
			sprite = this.block.getLayerTexture(this.meta, side, i);
			if (sprite != null) {
				this.quads[side.getIndex()].add(this.getBakery().makeBakedQuad(this.getMinBox(side, box), this.getMaxBox(side, box), face, sprite, side, sideRotation, (BlockPartRotation) null, false, true));
			}
		}
	}
}
 
Example #17
Source File: IconVertexRangeUVTransform.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Retrieves a TextureAtlasSprite from the internal map based on a vertex index.
 *
 * @param index The vertex index.
 * @return Returns the Icon, Null if no transform for the vertex index.
 */
public TextureAtlasSprite getSpriteForVertexIndex(int index) {
    for (Triple<Integer, Integer, TextureAtlasSprite> entry : transformMap) {
        if (MathHelper.between(entry.getLeft(), index, entry.getMiddle())) {
            return entry.getRight();
        }
    }
    return null;
}
 
Example #18
Source File: LargeTurbineRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public void renderSided(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, EnumFacing side, boolean hasBase, boolean hasRotor, boolean isActive, int rotorRGB) {
    Matrix4 cornerOffset = null;
    switch (side.getAxis()) {
        case X:
            cornerOffset = translation.copy().translate(0.01 * side.getFrontOffsetX(), -1.0, -1.0);
            cornerOffset.scale(1.0, 3.0, 3.0);
            break;
        case Z:
            cornerOffset = translation.copy().translate(-1.0, -1.0, 0.01 * side.getFrontOffsetZ());
            cornerOffset.scale(3.0, 3.0, 1.0);
            break;
        case Y:
            cornerOffset = translation.copy().translate(-1.0, 0.01 * side.getFrontOffsetY(), -1.0);
            cornerOffset.scale(3.0, 1.0, 3.0);
            break;
    }
    if (hasBase) {
        Textures.renderFace(renderState, cornerOffset, pipeline, side, Cuboid6.full, baseRingSprite);
        renderState.brightness = 0xF000F0;
        renderState.colour = 0xFFFFFFFF;
        Textures.renderFace(renderState, cornerOffset, new IVertexOperation[0], side, Cuboid6.full, baseBackgroundSprite);
    }
    if (hasRotor) {
        TextureAtlasSprite sprite = isActive ? activeBladeSprite : idleBladeSprite;
        IVertexOperation[] color = ArrayUtils.add(pipeline, new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(rotorRGB)));
        Textures.renderFace(renderState, cornerOffset, color, side, Cuboid6.full, sprite);
    }
}
 
Example #19
Source File: InvPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Pair<TextureAtlasSprite, Integer> getParticleTexture(IPipeTile<InventoryPipeType, EmptyNodeData> tileEntity) {
    if (tileEntity == null) {
        return Pair.of(TextureUtils.getMissingSprite(), 0xFFFFFF);
    }
    TextureAtlasSprite atlasSprite = TextureUtils.getBlockTexture("stone");
    int particleColor = tileEntity.getInsulationColor();
    return Pair.of(atlasSprite, particleColor);
}
 
Example #20
Source File: AgriCraftFX.java    From AgriCraft with MIT License 5 votes vote down vote up
protected AgriCraftFX(World world, double x, double y, double z, float scale, float gravity, Vec3d vector, TextureAtlasSprite icon) {
    super(world, x, y, z, 0, 0, 0);
    this.texture = null;
    this.setParticleTexture(icon);
    this.particleGravity = gravity;
    this.particleScale = scale;
    this.motionX = vector.x;
    this.motionY = vector.y;
    this.motionZ = vector.z;
}
 
Example #21
Source File: ModelEnderBucket.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BakedEnderBucket(ModelEnderBucket parent, ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, VertexFormat format,
        ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms, Map<String, IBakedModel> cache)
{
    this.quads = quads;
    this.particle = particle;
    this.format = format;
    this.parent = parent;
    this.transforms = transforms;
    this.cache = cache;
}
 
Example #22
Source File: CCBakeryModel.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Set<TextureAtlasSprite> getHitEffects(BlockRayTraceResult traceResult, BlockState state, IBlockReader world, BlockPos pos, IModelData data) {
    IBakedModel model = ModelBakery.getCachedModel(state, data);
    if (model instanceof IModelParticleProvider) {
        return ((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos, data);
    }
    return Collections.emptySet();
}
 
Example #23
Source File: OrientedOverlayRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(TextureMap textureMap) {
    this.sprites = new HashMap<>();
    for (OverlayFace overlayFace : faces) {
        String faceName = overlayFace.name().toLowerCase();
        ResourceLocation normalLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/%s/overlay_%s", basePath, faceName));
        ResourceLocation activeLocation = new ResourceLocation(GTValues.MODID, String.format("blocks/%s/overlay_%s_active", basePath, faceName));
        TextureAtlasSprite normalSprite = textureMap.registerSprite(normalLocation);
        TextureAtlasSprite activeSprite = textureMap.registerSprite(activeLocation);
        sprites.put(overlayFace, new ActivePredicate(normalSprite, activeSprite));
    }
}
 
Example #24
Source File: EvalModel.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final IModel model = loadBaseModel(state, format, bakedTextureGetter);

	final ITransformEvaluator evaluator = evaluatorFactory.createEvaluator(c -> model.getClip(c));
	return new BakedEvalModel(model, state, format, bakedTextureGetter, evaluator);
}
 
Example #25
Source File: GTModelUtils.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static List<BakedQuad> texAndTint(List<BakedQuad> quads, int rgb, TextureAtlasSprite sprite) {
	List<BakedQuad> quadsTemp = new LinkedList<>();
	int size = quads.size();
	for (int i = 0; i < size; i++) {
		BakedQuad quad = new BakedQuadRetextured(quads.get(i), sprite);
		quadsTemp.add(new GTBakedQuadTinted(quad, rgb));
	}
	return quadsTemp;
}
 
Example #26
Source File: ParticleHandlerUtil.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void addBlockRunningEffects(World worldObj, Entity entity, TextureAtlasSprite atlasSprite, int spriteColor) {
    Random rand = new Random();
    double posX = entity.posX + (rand.nextFloat() - 0.5) * entity.width;
    double posY = entity.getEntityBoundingBox().minY + 0.1;
    double posZ = entity.posZ + (rand.nextFloat() - 0.5) * entity.width;
    ParticleManager manager = Minecraft.getMinecraft().effectRenderer;

    float red = (spriteColor >> 16 & 255) / 255.0F;
    float green = (spriteColor >> 8 & 255) / 255.0F;
    float blue = (spriteColor & 255) / 255.0F;

    DigIconParticle digIconParticle = new DigIconParticle(worldObj, posX, posY, posZ, -entity.motionX * 4.0, 1.5, -entity.motionZ * 4.0, atlasSprite);
    digIconParticle.setRBGColorF(red, green, blue);
    manager.addEffect(digIconParticle);
}
 
Example #27
Source File: RenderChannel.java    From AgriCraft with MIT License 5 votes vote down vote up
protected void drawWater(ITessellator tessellator, T channel, TextureAtlasSprite icon) {
    // Check if there is water to be rendered.
    if (channel.getFluidHeight() <= channel.getMinFluidHeight()) {
        // There exists no water to be rendered.
        return;
    }

    // Calculate water brightness.
    final int l = RenderUtilBase.getMixedBrightness(channel.getWorld(), channel.getPos(), Blocks.WATER);
    tessellator.setBrightness(l);
    tessellator.setAlpha(0.39f);

    // Calculate y to avoid plane rendering conflicts
    final float y = (channel.getFluidHeight() * 16 / 1_000f) - 0.001f;

    //draw central water levels
    tessellator.drawScaledFaceDouble(5, 5, 11, 11, EnumFacing.UP, icon, y);
    
    // Fetch the connections.
    final AgriSideMetaMatrix connections = channel.getConnections();

    //connect to edges
    if (connections.get(EnumFacing.NORTH) > 0) {
        tessellator.drawScaledFaceDouble(5, 0, 11, 5, EnumFacing.UP, icon, y);
    }
    if (connections.get(EnumFacing.EAST) > 0) {
        tessellator.drawScaledFaceDouble(11, 5, 16, 11, EnumFacing.UP, icon, y);
    }
    if (connections.get(EnumFacing.SOUTH) > 0) {
        tessellator.drawScaledFaceDouble(5, 11, 11, 16, EnumFacing.UP, icon, y);
    }
    if (connections.get(EnumFacing.WEST) > 0) {
        tessellator.drawScaledFaceDouble(0, 5, 5, 11, EnumFacing.UP, icon, y);
    }

}
 
Example #28
Source File: MetaTileEntityChest.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public Pair<TextureAtlasSprite, Integer> getParticleTexture() {
    if(ModHandler.isMaterialWood(material)) {
        return Pair.of(Textures.WOODEN_CHEST.getParticleTexture(), getPaintingColor());
    } else {
        return Pair.of(Textures.METAL_CHEST.getParticleTexture(), getPaintingColor());
    }
}
 
Example #29
Source File: DynamicStitcher.java    From VanillaFix with MIT License 5 votes vote down vote up
public void addSprite(TextureAtlasSprite sprite) {
    Holder holder = new Holder(sprite, mipmapLevels);

    if (maxSpriteSize > 0) {
        holder.setNewDimension(maxSpriteSize);
    }

    Slot slot = allocateSlot(holder);

    if (slot == null) {
        throw new StitcherException(null, String.format("Unable to fit %s (size %dx%d)", sprite.getIconName(), sprite.getIconWidth(), sprite.getIconHeight()));
    }

    sprite.initSprite(BASE_WIDTH, BASE_HEIGHT, slot.getOriginX(), slot.getOriginY(), holder.isRotated());
}
 
Example #30
Source File: TextureUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static TextureAtlasSprite getBlankIcon(int size, TextureMap textureMap) {
    String s = "blank_" + size;
    TextureAtlasSprite icon = textureMap.getTextureExtry(s);
    if (icon == null)
        textureMap.setTextureEntry(s, icon = new TextureSpecial(s).blank(size));

    return icon;
}