2013-11-03 06:36:41 +00:00
|
|
|
package biomesoplenty.asm;
|
2013-10-17 07:32:13 +00:00
|
|
|
|
|
|
|
import net.minecraft.launchwrapper.IClassTransformer;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.biome.BiomeGenBase;
|
2013-11-03 06:36:41 +00:00
|
|
|
import biomesoplenty.asm.biomecolourblending.BlockFluid;
|
|
|
|
import biomesoplenty.asm.biomecolourblending.BlockGrass;
|
|
|
|
import biomesoplenty.asm.biomecolourblending.BlockLeaves;
|
|
|
|
import biomesoplenty.asm.biomecolourblending.BlockTallGrass;
|
2013-10-17 07:32:13 +00:00
|
|
|
import biomesoplenty.configuration.configfile.BOPConfigurationMisc;
|
2013-10-18 21:48:57 +00:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
2013-10-19 01:43:51 +00:00
|
|
|
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
2013-10-18 21:48:57 +00:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-10-17 07:32:13 +00:00
|
|
|
|
2013-11-03 06:36:41 +00:00
|
|
|
public class BOPBiomeColourBlending implements IClassTransformer
|
2013-10-17 07:32:13 +00:00
|
|
|
{
|
2013-10-19 01:43:51 +00:00
|
|
|
private static String SIDE = FMLLaunchHandler.side().name();
|
|
|
|
|
2013-10-17 07:32:13 +00:00
|
|
|
@Override
|
|
|
|
public byte[] transform(String name, String newname, byte[] bytes)
|
|
|
|
{
|
2013-10-19 01:43:51 +00:00
|
|
|
if (SIDE.equals("CLIENT"))
|
2013-10-17 07:32:13 +00:00
|
|
|
{
|
2013-10-19 01:43:51 +00:00
|
|
|
if (name.equals("net.minecraft.block.BlockFluid"))
|
|
|
|
{
|
|
|
|
return BlockFluid.patchColourMultiplier(newname, bytes, false);
|
|
|
|
}
|
2013-10-18 21:48:57 +00:00
|
|
|
|
2013-10-19 01:43:51 +00:00
|
|
|
if (name.equals("net.minecraft.block.BlockGrass"))
|
|
|
|
{
|
|
|
|
return BlockGrass.patchColourMultiplier(newname, bytes, false);
|
|
|
|
}
|
2013-10-18 21:48:57 +00:00
|
|
|
|
2013-10-19 01:43:51 +00:00
|
|
|
if (name.equals("net.minecraft.block.BlockLeaves"))
|
|
|
|
{
|
|
|
|
return BlockLeaves.patchColourMultiplier(newname, bytes, false);
|
|
|
|
}
|
2013-10-18 21:16:15 +00:00
|
|
|
|
2013-10-19 01:43:51 +00:00
|
|
|
if (name.equals("net.minecraft.block.BlockTallGrass"))
|
|
|
|
{
|
|
|
|
return BlockTallGrass.patchColourMultiplier(newname, bytes, false);
|
|
|
|
}
|
2013-10-18 21:16:15 +00:00
|
|
|
|
2013-10-19 01:43:51 +00:00
|
|
|
if (name.equals("apc"))
|
|
|
|
{
|
|
|
|
return BlockFluid.patchColourMultiplier(newname, bytes, true);
|
|
|
|
}
|
2013-10-18 21:16:15 +00:00
|
|
|
|
|
|
|
|
2013-10-19 01:43:51 +00:00
|
|
|
if (name.equals("aon"))
|
|
|
|
{
|
|
|
|
return BlockGrass.patchColourMultiplier(newname, bytes, true);
|
|
|
|
}
|
2013-10-18 21:16:15 +00:00
|
|
|
|
|
|
|
|
2013-10-19 01:43:51 +00:00
|
|
|
if (name.equals("aoz"))
|
|
|
|
{
|
|
|
|
return BlockLeaves.patchColourMultiplier(newname, bytes, true);
|
|
|
|
}
|
2013-10-18 21:48:57 +00:00
|
|
|
|
|
|
|
|
2013-10-19 01:43:51 +00:00
|
|
|
if (name.equals("aqv"))
|
|
|
|
{
|
|
|
|
return BlockTallGrass.patchColourMultiplier(newname, bytes, true);
|
|
|
|
}
|
2013-10-18 21:48:57 +00:00
|
|
|
}
|
2013-10-18 21:16:15 +00:00
|
|
|
|
2013-10-17 07:32:13 +00:00
|
|
|
return bytes;
|
|
|
|
}
|
2013-10-18 21:16:15 +00:00
|
|
|
|
2013-10-18 21:48:57 +00:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-10-17 07:32:13 +00:00
|
|
|
public static int getGrassColourMultiplier(IBlockAccess world, int ox, int oy, int oz)
|
|
|
|
{
|
2013-10-18 21:16:15 +00:00
|
|
|
int distance = FMLClientHandler.instance().getClient().gameSettings.fancyGraphics ? BOPConfigurationMisc.grassColourSmoothingArea : 1;
|
2013-10-17 07:32:13 +00:00
|
|
|
|
|
|
|
int r = 0;
|
|
|
|
int g = 0;
|
|
|
|
int b = 0;
|
|
|
|
|
|
|
|
int divider = 0;
|
|
|
|
|
|
|
|
for (int x = -distance; x <= distance; ++x)
|
|
|
|
{
|
|
|
|
for (int z = -distance; z <= distance; ++z)
|
|
|
|
{
|
|
|
|
BiomeGenBase biome = world.getBiomeGenForCoords(ox + x, oz + z);
|
|
|
|
int colour = biome.getBiomeGrassColor();
|
|
|
|
r += (colour & 0xFF0000) >> 16;
|
|
|
|
g += (colour & 0x00FF00) >> 8;
|
|
|
|
b += colour & 0x0000FF;
|
|
|
|
divider++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (r / divider & 255) << 16 | (g / divider & 255) << 8 | b / divider & 255;
|
|
|
|
}
|
|
|
|
|
2013-10-18 21:48:57 +00:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-10-17 07:32:13 +00:00
|
|
|
public static int getLeavesColourMultiplier(IBlockAccess world, int ox, int oy, int oz)
|
|
|
|
{
|
2013-10-18 21:16:15 +00:00
|
|
|
int distance = FMLClientHandler.instance().getClient().gameSettings.fancyGraphics ? BOPConfigurationMisc.leavesColourSmoothingArea : 1;
|
2013-10-17 07:32:13 +00:00
|
|
|
|
|
|
|
int r = 0;
|
|
|
|
int g = 0;
|
|
|
|
int b = 0;
|
|
|
|
|
|
|
|
int divider = 0;
|
|
|
|
|
|
|
|
for (int x = -distance; x <= distance; ++x)
|
|
|
|
{
|
|
|
|
for (int z = -distance; z <= distance; ++z)
|
|
|
|
{
|
|
|
|
BiomeGenBase biome = world.getBiomeGenForCoords(ox + x, oz + z);
|
|
|
|
int colour = biome.getBiomeFoliageColor();
|
|
|
|
r += (colour & 0xFF0000) >> 16;
|
|
|
|
g += (colour & 0x00FF00) >> 8;
|
|
|
|
b += colour & 0x0000FF;
|
|
|
|
divider++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (r / divider & 255) << 16 | (g / divider & 255) << 8 | b / divider & 255;
|
|
|
|
}
|
|
|
|
|
2013-10-18 21:48:57 +00:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-10-17 07:32:13 +00:00
|
|
|
public static int getWaterColourMultiplier(IBlockAccess world, int ox, int oy, int oz)
|
|
|
|
{
|
2013-10-18 21:16:15 +00:00
|
|
|
int distance = FMLClientHandler.instance().getClient().gameSettings.fancyGraphics ? BOPConfigurationMisc.waterColourSmoothingArea : 1;
|
2013-10-17 07:32:13 +00:00
|
|
|
|
|
|
|
int r = 0;
|
|
|
|
int g = 0;
|
|
|
|
int b = 0;
|
|
|
|
|
|
|
|
int divider = 0;
|
|
|
|
|
|
|
|
for (int x = -distance; x <= distance; ++x)
|
|
|
|
{
|
|
|
|
for (int z = -distance; z <= distance; ++z)
|
|
|
|
{
|
|
|
|
BiomeGenBase biome = world.getBiomeGenForCoords(ox + x, oz + z);
|
|
|
|
int colour = biome.getWaterColorMultiplier();
|
|
|
|
r += (colour & 0xFF0000) >> 16;
|
|
|
|
g += (colour & 0x00FF00) >> 8;
|
|
|
|
b += colour & 0x0000FF;
|
|
|
|
divider++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (r / divider & 255) << 16 | (g / divider & 255) << 8 | b / divider & 255;
|
|
|
|
}
|
|
|
|
}
|