From d5dd1a36e3c7ddefd500cbf0a09439a8b6932120 Mon Sep 17 00:00:00 2001 From: octarine-noise Date: Mon, 30 Jun 2014 23:23:55 +0200 Subject: [PATCH] Remove leafmask mapping feature --- .../client/BetterFoliageClient.java | 1 - .../client/resource/LeafTextureGenerator.java | 41 +------------------ .../client/resource/LeafTextureResource.java | 13 +++--- 3 files changed, 6 insertions(+), 49 deletions(-) diff --git a/src/main/java/mods/betterfoliage/client/BetterFoliageClient.java b/src/main/java/mods/betterfoliage/client/BetterFoliageClient.java index 7e4d29d..a8009bb 100644 --- a/src/main/java/mods/betterfoliage/client/BetterFoliageClient.java +++ b/src/main/java/mods/betterfoliage/client/BetterFoliageClient.java @@ -52,7 +52,6 @@ public class BetterFoliageClient implements ILeafTextureRecognizer { leafGenerator = new LeafTextureGenerator(); MinecraftForge.EVENT_BUS.register(leafGenerator); leafGenerator.recognizers.add(new BetterFoliageClient()); - leafGenerator.loadLeafMappings(new File(BetterFoliage.configDir, "leafMask.properties")); MinecraftForge.EVENT_BUS.register(new BetterFoliageClient()); } diff --git a/src/main/java/mods/betterfoliage/client/resource/LeafTextureGenerator.java b/src/main/java/mods/betterfoliage/client/resource/LeafTextureGenerator.java index 26e29b5..3299681 100644 --- a/src/main/java/mods/betterfoliage/client/resource/LeafTextureGenerator.java +++ b/src/main/java/mods/betterfoliage/client/resource/LeafTextureGenerator.java @@ -1,13 +1,9 @@ package mods.betterfoliage.client.resource; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.Set; import mods.betterfoliage.BetterFoliage; @@ -28,7 +24,6 @@ import net.minecraftforge.client.event.TextureStitchEvent; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.google.common.collect.Sets; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -56,9 +51,6 @@ public class LeafTextureGenerator implements IIconRegister, IResourceManager { /** Number of textures generated in the current run */ int counter = 0; - /** Map leaf types to alpha masks */ - public Map maskMappings = Maps.newHashMap(); - public Set getResourceDomains() { return ImmutableSet.of(domainName); } @@ -66,7 +58,7 @@ public class LeafTextureGenerator implements IIconRegister, IResourceManager { public IResource getResource(ResourceLocation resourceLocation) throws IOException { // remove "/blocks/textures/" from beginning String origResPath = resourceLocation.getResourcePath().substring(16); - LeafTextureResource result = new LeafTextureResource(new ResourceLocation(origResPath), maskMappings); + LeafTextureResource result = new LeafTextureResource(new ResourceLocation(origResPath)); if (result.data == null) { return Minecraft.getMinecraft().getResourceManager().getResource(missing_resource); } else { @@ -152,35 +144,4 @@ public class LeafTextureGenerator implements IIconRegister, IResourceManager { } } - public void loadLeafMappings(File leafMaskFile) { - Properties props = new Properties(); - try { - FileInputStream fis = new FileInputStream(leafMaskFile); - props.load(fis); - } catch (Exception e) { - maskMappings.put("spruce", "fine"); - maskMappings.put("fir", "fine"); - maskMappings.put("bamboo", "fine"); - saveLeafMappings(leafMaskFile); - return; - } - - for (Map.Entry entry : props.entrySet()) { - maskMappings.put(entry.getKey().toString(), entry.getValue().toString()); - } - BetterFoliage.log.info(String.format("Loaded %d leaf mask mappings", maskMappings.size())); - } - - protected void saveLeafMappings(File leafMaskFile) { - try { - FileOutputStream fos = new FileOutputStream(leafMaskFile); - Properties props = new Properties(); - props.putAll(maskMappings); - props.store(fos, ""); - } catch (Exception e) { - BetterFoliage.log.info("Failed to save default leaf mask mappings"); - return; - } - BetterFoliage.log.info("Created default leaf mask mappings"); - } } diff --git a/src/main/java/mods/betterfoliage/client/resource/LeafTextureResource.java b/src/main/java/mods/betterfoliage/client/resource/LeafTextureResource.java index 75101cd..369a540 100644 --- a/src/main/java/mods/betterfoliage/client/resource/LeafTextureResource.java +++ b/src/main/java/mods/betterfoliage/client/resource/LeafTextureResource.java @@ -4,9 +4,9 @@ import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.util.Map; import javax.imageio.ImageIO; @@ -31,7 +31,7 @@ public class LeafTextureResource implements IResource { /** Name of the default alpha mask to use */ public static String defaultMask = "rough"; - public LeafTextureResource(ResourceLocation resLeaf, Map maskMappings) { + public LeafTextureResource(ResourceLocation resLeaf) { IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager(); try { // load normal leaf texture @@ -41,12 +41,7 @@ public class LeafTextureResource implements IResource { int size = origImage.getWidth(); // load alpha mask of appropriate size - String maskType = defaultMask; - for(Map.Entry entry : maskMappings.entrySet()) if (resLeaf.getResourcePath().contains(entry.getKey())) { - maskType = entry.getValue(); - break; - } - BufferedImage maskImage = loadLeafMaskImage(maskType, size * 2); + BufferedImage maskImage = loadLeafMaskImage(defaultMask, size * 2); int scale = size * 2 / maskImage.getWidth(); // tile leaf texture 2x2 @@ -71,6 +66,8 @@ public class LeafTextureResource implements IResource { ImageIO.write(overlayIcon, "PNG", baos); data = baos.toByteArray(); } catch (Exception e) { + // stop log spam with GLSL installed + if (e instanceof FileNotFoundException) return; BetterFoliage.log.info(String.format("Could not create leaf texture: %s, exception: %s", resLeaf.toString(), e.getClass().getSimpleName())); } }