Search in sources :

Example 6 with Overwrite

use of org.spongepowered.asm.mixin.Overwrite in project Almura by AlmuraDev.

the class MixinGuiIngame method renderPotionEffects.

/**
 * @author Grinch - Steven Downer
 * @reason Move down where PotionEffects render to not conflict with the far right element of the OriginHUD
 */
@Overwrite
protected void renderPotionEffects(ScaledResolution resolution) {
    Minecraft mc = Minecraft.getMinecraft();
    Collection<PotionEffect> collection = mc.player.getActivePotionEffects();
    if (!collection.isEmpty()) {
        mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
        GlStateManager.enableBlend();
        int i = 0;
        int j = 0;
        for (PotionEffect potioneffect : Ordering.natural().reverse().sortedCopy(collection)) {
            Potion potion = potioneffect.getPotion();
            if (!potion.shouldRenderHUD(potioneffect))
                continue;
            // Rebind in case previous renderHUDEffect changed texture
            mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
            if (potioneffect.doesShowParticles()) {
                int k = resolution.getScaledWidth();
                // TODO Figure out how to do this without overwrite
                // Almura start
                int l = hud.getHUD().map(AbstractHUD::getPotionOffsetY).orElse(1);
                if (mc.isDemo()) {
                    l += 15;
                }
                int i1 = potion.getStatusIconIndex();
                if (potion.isBeneficial()) {
                    ++i;
                    k = k - 25 * i;
                } else {
                    ++j;
                    k = k - 25 * j;
                    l += 26;
                }
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                float f = 1.0F;
                if (potioneffect.getIsAmbient()) {
                    this.drawTexturedModalRect(k, l, 165, 166, 24, 24);
                } else {
                    this.drawTexturedModalRect(k, l, 141, 166, 24, 24);
                    if (potioneffect.getDuration() <= 200) {
                        int j1 = 10 - potioneffect.getDuration() / 20;
                        f = MathHelper.clamp((float) potioneffect.getDuration() / 10.0F / 5.0F * 0.5F, 0.0F, 0.5F) + MathHelper.cos((float) potioneffect.getDuration() * (float) Math.PI / 5.0F) * MathHelper.clamp((float) j1 / 10.0F * 0.25F, 0.0F, 0.25F);
                    }
                }
                GlStateManager.color(1.0F, 1.0F, 1.0F, f);
                // FORGE - Move status icon check down from above so renderHUDEffect will still be called without a status icon
                if (potion.hasStatusIcon())
                    this.drawTexturedModalRect(k + 3, l + 3, i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
                potion.renderHUDEffect(k, l, potioneffect, mc, f);
            }
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Potion(net.minecraft.potion.Potion) Minecraft(net.minecraft.client.Minecraft) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 7 with Overwrite

use of org.spongepowered.asm.mixin.Overwrite in project Almura by AlmuraDev.

the class MixinBiome method getGrassColorAtPos.

/**
 * @author Zidane - Chris Sanders
 * @reason Have Grass color use temperature/rainfall.
 */
@Overwrite
@SideOnly(Side.CLIENT)
public int getGrassColorAtPos(BlockPos pos) {
    final BiomeChunk chunk = BiomeUtil.getChunk(pos);
    float temperature;
    float rainfall;
    if (chunk == null) {
        temperature = ((Biome) (Object) this).getTemperature(pos);
        rainfall = ((Biome) (Object) this).getRainfall();
    } else {
        temperature = chunk.getTemperature(pos, (Biome) (Object) this);
        rainfall = chunk.getRainfall(pos, (Biome) (Object) this);
    }
    double d0 = (double) MathHelper.clamp(temperature, 0.0F, 1.0F);
    double d1 = (double) MathHelper.clamp(rainfall, 0.0F, 1.0F);
    return ((Biome) (Object) this).getModdedBiomeGrassColor(ColorizerGrass.getGrassColor(d0, d1));
}
Also used : Biome(net.minecraft.world.biome.Biome) BiomeChunk(com.almuradev.almura.feature.biome.BiomeChunk) Overwrite(org.spongepowered.asm.mixin.Overwrite) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with Overwrite

use of org.spongepowered.asm.mixin.Overwrite in project Almura by AlmuraDev.

the class MixinBiome method getFoliageColorAtPos.

/**
 * @author Zidane - Chris Sanders
 * @reason Have Foilage color use temperature/rainfall.
 */
@Overwrite
@SideOnly(Side.CLIENT)
public int getFoliageColorAtPos(BlockPos pos) {
    final BiomeChunk chunk = BiomeUtil.getChunk(pos);
    float temperature;
    float rainfall;
    if (chunk == null) {
        temperature = ((Biome) (Object) this).getTemperature(pos);
        rainfall = ((Biome) (Object) this).getRainfall();
    } else {
        temperature = chunk.getTemperature(pos, (Biome) (Object) this);
        rainfall = chunk.getRainfall(pos, (Biome) (Object) this);
    }
    double d0 = (double) MathHelper.clamp(temperature, 0.0F, 1.0F);
    double d1 = (double) MathHelper.clamp(rainfall, 0.0F, 1.0F);
    return ((Biome) (Object) this).getModdedBiomeFoliageColor(ColorizerFoliage.getFoliageColor(d0, d1));
}
Also used : Biome(net.minecraft.world.biome.Biome) BiomeChunk(com.almuradev.almura.feature.biome.BiomeChunk) Overwrite(org.spongepowered.asm.mixin.Overwrite) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Overwrite (org.spongepowered.asm.mixin.Overwrite)8 Biome (net.minecraft.world.biome.Biome)4 BiomeChunk (com.almuradev.almura.feature.biome.BiomeChunk)3 BlockPos (net.minecraft.util.math.BlockPos)3 Random (java.util.Random)2 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 ClientConfiguration (com.almuradev.almura.core.client.ClientConfiguration)1 MixinBlock (com.almuradev.content.type.block.mixin.impl.MixinBlock)1 SeedItem (com.almuradev.content.type.item.type.seed.SeedItem)1 DoubleRange (com.almuradev.toolbox.util.math.DoubleRange)1 IntRange (com.almuradev.toolbox.util.math.IntRange)1 Collections (java.util.Collections)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 BlockTallGrass (net.minecraft.block.BlockTallGrass)1 PropertyBool (net.minecraft.block.properties.PropertyBool)1 PropertyInteger (net.minecraft.block.properties.PropertyInteger)1 Minecraft (net.minecraft.client.Minecraft)1