Remove leafmask mapping feature
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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<String, String> maskMappings = Maps.newHashMap();
|
||||
|
||||
public Set<String> getResourceDomains() {
|
||||
return ImmutableSet.<String>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<Object, Object> 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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String, String> 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<String, String> 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()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user