use of net.minecraft.client.resources.IResourceManager in project BuildCraft by BuildCraft.
the class CoreProxyClient method init.
@Override
public void init() {
MinecraftForge.EVENT_BUS.register(RenderTickListener.INSTANCE);
IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
IReloadableResourceManager reloadable = (IReloadableResourceManager) resourceManager;
reloadable.registerReloadListener(DetailedConfigOption.ReloadListener.INSTANCE);
ClientRegistry.bindTileEntitySpecialRenderer(TileEngineBase.class, new RenderEngine());
ClientRegistry.bindTileEntitySpecialRenderer(TilePathMarker.class, new RenderPathMarker());
ClientRegistry.bindTileEntitySpecialRenderer(TileMarker.class, new RenderMarker());
RenderingRegistry.registerEntityRenderingHandler(EntityResizableCuboid.class, RenderResizableCuboid.INSTANCE);
RenderingRegistry.registerEntityRenderingHandler(EntityLaser.class, new RenderLaser());
for (Block block : blocksToRegisterRenderersFor) {
if (block instanceof IModelRegister) {
((IModelRegister) block).registerModels();
continue;
}
IBlockState defaultState = block.getDefaultState();
Multimap<Integer, IBlockState> metaStateMap = ArrayListMultimap.create();
Map<IBlockState, String> stateTypeMap = Maps.newHashMap();
for (IBlockState state : (List<IBlockState>) block.getBlockState().getValidStates()) {
String type = BuildCraftStateMapper.getPropertyString(state);
stateTypeMap.put(state, type);
metaStateMap.put(block.damageDropped(state), state);
}
for (Entry<Integer, Collection<IBlockState>> entry : metaStateMap.asMap().entrySet()) {
Collection<IBlockState> blockStates = entry.getValue();
if (blockStates.isEmpty())
continue;
if (blockStates.contains(defaultState)) {
registerBlockItemModel(defaultState, entry.getKey(), stateTypeMap.get(defaultState));
} else {
IBlockState state = blockStates.iterator().next();
registerBlockItemModel(state, entry.getKey(), stateTypeMap.get(state));
}
}
}
for (Item item : itemsToRegisterRenderersFor) {
if (item instanceof IModelRegister) {
((IModelRegister) item).registerModels();
}
}
}
use of net.minecraft.client.resources.IResourceManager in project ImmersiveEngineering by BluSunrize.
the class IEShaderLayerCompositeTexture method loadTexture.
@Override
public void loadTexture(IResourceManager resourceManager) {
this.deleteGlTexture();
IResource iresource = null;
BufferedImage bufferedimage;
BufferedImage scaledImage;
label255: {
try {
iresource = resourceManager.getResource(this.canvasTexture);
BufferedImage canvasImage = TextureUtil.readBufferedImage(iresource.getInputStream());
int imageType = canvasImage.getType();
if (imageType == 0)
imageType = 6;
int canvasWidth = canvasImage.getWidth();
int canvasHeight = canvasImage.getHeight();
bufferedimage = new BufferedImage(canvasWidth, canvasHeight, imageType);
int layer = 0;
while (true) {
if (layer >= 17 || layer >= this.layers.length)
break label255;
IResource iresource1 = null;
try {
String texPath = this.layers[layer].getTexture().getPath();
if (!texPath.startsWith("textures/"))
texPath = "textures/" + texPath;
if (!texPath.endsWith(".png"))
texPath += ".png";
String texture = this.layers[layer].getTexture().getNamespace() + ":" + texPath;
int colour = this.layers[layer].getColour();
iresource1 = resourceManager.getResource(new ResourceLocation(texture));
BufferedImage texureImage = TextureUtil.readBufferedImage(iresource1.getInputStream());
scaledImage = new BufferedImage(canvasWidth, canvasHeight, imageType);
float[] mod = { (colour >> 16 & 255) / 255f, (colour >> 8 & 255) / 255f, (colour & 255) / 255f, (colour >> 24 & 255) / 255f };
IntFunction<Integer> uInterpolate = uIn -> uIn;
IntFunction<Integer> vInterpolate = vIn -> vIn;
int bufImg2Size = Math.min(texureImage.getWidth(), texureImage.getHeight());
int uMin = 0;
int vMin = 0;
int uMax = canvasWidth;
int vMax = canvasHeight;
final double[] texBounds = this.layers[layer].getTextureBounds();
if (texBounds != null) {
final double uOffset = texBounds[0] * canvasWidth;
final double vOffset = texBounds[1] * canvasHeight;
final double uScale = bufImg2Size / ((texBounds[2] - texBounds[0]) * canvasWidth);
final double vScale = bufImg2Size / ((texBounds[3] - texBounds[1]) * canvasHeight);
uInterpolate = uIn -> (int) Math.round((uIn - uOffset) * uScale);
vInterpolate = vIn -> (int) Math.round((vIn - vOffset) * vScale);
uMin = (int) uOffset;
vMin = (int) vOffset;
uMax = (int) (texBounds[2] * canvasWidth);
vMax = (int) (texBounds[3] * canvasHeight);
}
try {
for (int v = vMin; v < vMax; ++v) for (int u = uMin; u < uMax; ++u) {
int interU = uInterpolate.apply(u) % bufImg2Size;
int interV = vInterpolate.apply(v) % bufImg2Size;
int iRGB = texureImage.getRGB(interU, interV);
float[] rgb = { (iRGB >> 16 & 255) / 255f, (iRGB >> 8 & 255) / 255f, (iRGB & 255) / 255f, (iRGB >> 24 & 255) / 255f };
if ((iRGB & -16777216) != 0) {
int iNoise = canvasImage.getRGB(u, v);
float[] noise = { (iNoise >> 16 & 255) / 255f, (iNoise >> 8 & 255) / 255f, (iNoise & 255) / 255f, (iNoise >> 24 & 255) / 255f };
for (int m = 0; m < 4; m++) rgb[m] = rgb[m] * mod[m] * noise[m];
int[] irgb = { (int) (rgb[0] * 255), (int) (rgb[1] * 255), (int) (rgb[2] * 255), (int) (rgb[3] * 255) };
int i2 = (irgb[0] << 16) + (irgb[1] << 8) + (irgb[2]) + (irgb[3] << 24);
scaledImage.setRGB(u, v, i2);
}
}
} catch (Exception e) {
e.printStackTrace();
}
bufferedimage.getGraphics().drawImage(scaledImage, 0, 0, null);
} finally {
IOUtils.closeQuietly(iresource1);
}
++layer;
}
} catch (IOException ioexception) {
IELogger.error("Couldn't load layered image", ioexception);
} finally {
IOUtils.closeQuietly(iresource);
}
return;
}
TextureUtil.uploadTextureImage(this.getGlTextureId(), bufferedimage);
}
use of net.minecraft.client.resources.IResourceManager in project GregTech by GregTechCE.
the class ResourcePackHook method init.
public static void init() {
IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
Minecraft.getMinecraft().defaultResourcePacks.add(instance);
if (resourceManager instanceof SimpleReloadableResourceManager) {
((SimpleReloadableResourceManager) resourceManager).registerReloadListener(instance);
}
}
use of net.minecraft.client.resources.IResourceManager in project ForestryMC by ForestryMC.
the class BlockForestryFluid method flowTextureExists.
@SideOnly(Side.CLIENT)
public boolean flowTextureExists() {
try {
ResourceLocation resourceLocation = new ResourceLocation(Defaults.ID, "textures/blocks/liquid/" + fluidName + "_flow.png");
IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
return resourceManager.getResource(resourceLocation) != null;
} catch (java.lang.Exception e) {
return false;
}
}
use of net.minecraft.client.resources.IResourceManager in project BuildCraft by BuildCraft.
the class SpriteBuilder method addSprite.
/**
* Performs simple addition of the current image and a new image, replacing old pixels with the new image if the
* new image's alpha channel is greater than the given value.
*/
public SpriteBuilder addSprite(String location, final int minAlpha) {
final ResourceLocation resLoc = new ResourceLocation(location);
buildingActions.add(new ISpriteAction() {
@Override
public void apply(Graphics2D original, IResourceManager resourceManager) {
BufferedImage image = getImage(resourceManager, resLoc);
int multiplier = original.getClipBounds().width / image.getWidth();
for (int x = 0; x < image.getWidth(); x++) {
for (int y = 0; y < image.getHeight(); y++) {
int pixel = image.getRGB(x, y);
int alpha = (pixel >> 24) & 0xFF;
if (alpha < minAlpha)
continue;
int red = (pixel >> 16) & 0xFF;
int green = (pixel >> 8) & 0xFF;
int blue = pixel & 0xFF;
original.setColor(new Color(red, green, blue));
original.fillRect(x * multiplier, y * multiplier, multiplier, multiplier);
}
}
}
@Override
public int getMinWidth(IResourceManager resourceManager) {
return SpriteBuilder.getMinWidth(resourceManager, resLoc);
}
});
return this;
}
Aggregations