    001    /*
    002     * The FML Forge Mod Loader suite.
    003     * Copyright (C) 2012 cpw
    004     *
    005     * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
    006     * Software Foundation; either version 2.1 of the License, or any later version.
    007     *
    008     * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
    009     * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    010     *
    011     * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
    012     * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    013     */
    014
    015    package cpw.mods.fml.client;
    016
    017    import java.awt.Dimension;
    018    import java.util.List;
    019    import java.util.logging.Logger;
    020
    021    import net.minecraft.client.renderer.RenderEngine;
    022    import net.minecraft.client.renderer.texturefx.TextureFX;
    023    import net.minecraft.client.texturepacks.ITexturePack;
    024
    025    import cpw.mods.fml.common.FMLCommonHandler;
    026    import cpw.mods.fml.common.FMLLog;
    027
    028    public class FMLTextureFX extends TextureFX implements ITextureFX
    029    {
    030        public int tileSizeBase = 16;
    031        public int tileSizeSquare = 256;
    032        public int tileSizeMask = 15;
    033        public int tileSizeSquareMask = 255;
    034        public boolean errored = false;
    035        protected Logger log = FMLLog.getLogger();
    036
    037        public FMLTextureFX(int icon)
    038        {
    039            super(icon);
    040        }
    041
    042        @Override public void setErrored(boolean err){ errored = err; }
    043        @Override public boolean getErrored(){ return errored; }
    044        @Override
    045        public void onTexturePackChanged(RenderEngine engine, ITexturePack texturepack, Dimension dimensions)
    046        {
    047            onTextureDimensionsUpdate(dimensions.width, dimensions.height);
    048        }
    049        @Override
    050        public void onTextureDimensionsUpdate(int width, int height)
    051        {
    052            tileSizeBase = width >> 4;
    053            tileSizeSquare = tileSizeBase * tileSizeBase;
    054            tileSizeMask = tileSizeBase - 1;
    055            tileSizeSquareMask = tileSizeSquare - 1;
    056            setErrored(false);
    057            setup();
    058        }
    059
    060        protected void setup()
    061        {
    062            imageData = new byte[tileSizeSquare << 2];
    063        }
    064
    065        public boolean unregister(RenderEngine engine, List<TextureFX> effects)
    066        {
    067            effects.remove(this);
    068            return true;
    069        }
    070    }