    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.src.RenderEngine;
    022    import net.minecraft.src.TextureFX;
    023    import net.minecraft.src.ITexturePack;
    024    import cpw.mods.fml.common.FMLCommonHandler;
    025    import cpw.mods.fml.common.FMLLog;
    026
    027    public class FMLTextureFX extends TextureFX implements ITextureFX
    028    {
    029        public int tileSizeBase = 16;
    030        public int tileSizeSquare = 256;
    031        public int tileSizeMask = 15;
    032        public int tileSizeSquareMask = 255;
    033        public boolean errored = false;
    034        protected Logger log = FMLLog.getLogger();
    035
    036        public FMLTextureFX(int icon)
    037        {
    038            super(icon);
    039        }
    040
    041        @Override public void setErrored(boolean err){ errored = err; }
    042        @Override public boolean getErrored(){ return errored; }
    043        @Override
    044        public void onTexturePackChanged(RenderEngine engine, ITexturePack texturepack, Dimension dimensions)
    045        {
    046            onTextureDimensionsUpdate(dimensions.width, dimensions.height);
    047        }
    048        @Override
    049        public void onTextureDimensionsUpdate(int width, int height)
    050        {
    051            tileSizeBase = width >> 4;
    052            tileSizeSquare = tileSizeBase * tileSizeBase;
    053            tileSizeMask = tileSizeBase - 1;
    054            tileSizeSquareMask = tileSizeSquare - 1;
    055            setErrored(false);
    056            setup();
    057        }
    058
    059        protected void setup()
    060        {
    061            imageData = new byte[tileSizeSquare << 2];
    062        }
    063
    064        public boolean unregister(RenderEngine engine, List<TextureFX> effects)
    065        {
    066            effects.remove(this);
    067            return true;
    068        }
    069    }