mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-05-20 08:40:26 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52133b129d | |||
| d579921894 | |||
| 780b3f25dc | |||
| 14f97de35d |
@@ -19,8 +19,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class OreAddon implements AddonInitializer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(OreAddon.class);
|
||||
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
@@ -33,9 +31,7 @@ public class OreAddon implements AddonInitializer {
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().registerConfigType(new OreConfigType(), addon.key("ORE"), 1))
|
||||
.then(event -> event.getPack().registerConfigType(new ScatteredOreConfigType(), addon.key("SCATTERED_ORE"), 1))
|
||||
.failThrough();
|
||||
|
||||
if(platform.getTerraConfig().isDebugLog())
|
||||
logger.warn("The ore-config addon is deprecated and scheduled for removal in Terra 7.0. It is recommended to use the ore-config-v2 addon for future pack development instead.");
|
||||
}
|
||||
}
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.ore;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
|
||||
public class ScatteredOreConfigType implements ConfigType<ScatteredOreTemplate, Structure> {
|
||||
public static final TypeKey<Structure> ORE_TYPE_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
private final ScatteredOreFactory factory = new ScatteredOreFactory();
|
||||
|
||||
@Override
|
||||
public ScatteredOreTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new ScatteredOreTemplate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigFactory<ScatteredOreTemplate, Structure> getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeKey<Structure> getTypeKey() {
|
||||
return ORE_TYPE_TOKEN;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.ore;
|
||||
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
|
||||
import com.dfsek.terra.addons.ore.ores.VanillaOre;
|
||||
import com.dfsek.terra.addons.ore.ores.VanillaScatteredOre;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.ConfigFactory;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
|
||||
public class ScatteredOreFactory implements ConfigFactory<ScatteredOreTemplate, Structure> {
|
||||
@Override
|
||||
public Structure build(ScatteredOreTemplate config, Platform platform) throws LoadException {
|
||||
BlockState m = config.getMaterial();
|
||||
return new VanillaScatteredOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.isExposed(),
|
||||
config.getMaterialOverrides(), config.getSpread());
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.ore;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Description;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Final;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||
public class ScatteredOreTemplate extends OreTemplate {
|
||||
@Value("size")
|
||||
private @Meta int spread = 7;
|
||||
|
||||
|
||||
public int getSpread() {
|
||||
return spread;
|
||||
}
|
||||
}
|
||||
+20
-45
@@ -20,16 +20,18 @@ import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import static com.dfsek.terra.addons.ore.utils.VanillaOreUtils.shouldPlace;
|
||||
|
||||
|
||||
public class VanillaOre implements Structure {
|
||||
|
||||
private final BlockState material;
|
||||
protected final BlockState material;
|
||||
|
||||
private final double size;
|
||||
private final MaterialSet replaceable;
|
||||
private final boolean applyGravity;
|
||||
private final double exposed;
|
||||
private final Map<BlockType, BlockState> materials;
|
||||
protected final double size;
|
||||
protected final MaterialSet replaceable;
|
||||
protected final boolean applyGravity;
|
||||
protected final double exposed;
|
||||
protected final Map<BlockType, BlockState> materials;
|
||||
|
||||
public VanillaOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity,
|
||||
double exposed, Map<BlockType, BlockState> materials) {
|
||||
@@ -41,16 +43,6 @@ public class VanillaOre implements Structure {
|
||||
this.materials = materials;
|
||||
}
|
||||
|
||||
protected static boolean shouldNotDiscard(Random random, double chance) {
|
||||
if(chance <= 0.0F) {
|
||||
return true;
|
||||
} else if(chance >= 1.0F) {
|
||||
return false;
|
||||
} else {
|
||||
return random.nextFloat() >= chance;
|
||||
}
|
||||
}
|
||||
|
||||
public static double lerp(double t, double v0, double v1) {
|
||||
return v0 + t * (v1 - v0);
|
||||
}
|
||||
@@ -58,14 +50,14 @@ public class VanillaOre implements Structure {
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
float randomRadian = random.nextFloat() * (float) Math.PI;
|
||||
double eigthSize = size / 8.0F;
|
||||
double eighthSize = size / 8.0F;
|
||||
|
||||
// Place points to form a line segment
|
||||
double startX = (double) location.getX() + MathUtil.sin(randomRadian) * eigthSize;
|
||||
double endX = (double) location.getX() - MathUtil.sin(randomRadian) * eigthSize;
|
||||
double startX = (double) location.getX() + MathUtil.sin(randomRadian) * eighthSize;
|
||||
double endX = (double) location.getX() - MathUtil.sin(randomRadian) * eighthSize;
|
||||
|
||||
double startZ = (double) location.getZ() + MathUtil.cos(randomRadian) * eigthSize;
|
||||
double endZ = (double) location.getZ() - MathUtil.cos(randomRadian) * eigthSize;
|
||||
double startZ = (double) location.getZ() + MathUtil.cos(randomRadian) * eighthSize;
|
||||
double endZ = (double) location.getZ() - MathUtil.cos(randomRadian) * eighthSize;
|
||||
|
||||
double startY = location.getY() + random.nextInt(3) - 2;
|
||||
double endY = location.getY() + random.nextInt(3) - 2;
|
||||
@@ -115,14 +107,14 @@ public class VanillaOre implements Structure {
|
||||
}
|
||||
|
||||
int outset = (int) Math.ceil((size / 16.0F * 2.0F + 1.0F) / 2.0F);
|
||||
int x = (int) (location.getX() - Math.ceil(eigthSize) - outset);
|
||||
int x = (int) (location.getX() - Math.ceil(eighthSize) - outset);
|
||||
int y = location.getY() - 2 - outset;
|
||||
int z = (int) (location.getZ() - Math.ceil(eigthSize) - outset);
|
||||
int z = (int) (location.getZ() - Math.ceil(eighthSize) - outset);
|
||||
|
||||
int horizontalSize = (int) (2 * (Math.ceil(eigthSize) + outset));
|
||||
int horizontalSize = (int) (2 * (Math.ceil(eighthSize) + outset));
|
||||
int verticalSize = 2 * (2 + outset);
|
||||
|
||||
int sphereCount = 0;
|
||||
int blockCount = 0;
|
||||
BitSet visited = new BitSet(horizontalSize * verticalSize * horizontalSize);
|
||||
|
||||
// Generate a sphere at each point
|
||||
@@ -159,10 +151,9 @@ public class VanillaOre implements Structure {
|
||||
|
||||
visited.set(index);
|
||||
BlockType block = world.getBlockState(xi, yi, zi).getBlockType();
|
||||
if(shouldPlace(block, random, world, xi, yi, zi)) {
|
||||
if(shouldPlace(getReplaceable(), block, exposed, random, world, xi, yi, zi)) {
|
||||
world.setBlockState(xi, yi, zi, getMaterial(block), isApplyGravity());
|
||||
++sphereCount;
|
||||
break;
|
||||
++blockCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,24 +165,8 @@ public class VanillaOre implements Structure {
|
||||
}
|
||||
}
|
||||
|
||||
return sphereCount > 0;
|
||||
return blockCount > 0;
|
||||
}
|
||||
|
||||
public boolean shouldPlace(BlockType type, Random random, WritableWorld world, int x, int y, int z) {
|
||||
if(!getReplaceable().contains(type)) {
|
||||
return false;
|
||||
} else if(shouldNotDiscard(random, exposed)) {
|
||||
return true;
|
||||
} else {
|
||||
return !(world.getBlockState(x, y, z - 1).isAir() ||
|
||||
world.getBlockState(x, y, z + 1).isAir() ||
|
||||
world.getBlockState(x, y - 1, z).isAir() ||
|
||||
world.getBlockState(x, y + 1, z).isAir() ||
|
||||
world.getBlockState(x - 1, y, z).isAir() ||
|
||||
world.getBlockState(x + 1, y, z).isAir());
|
||||
}
|
||||
}
|
||||
|
||||
public BlockState getMaterial(BlockType replace) {
|
||||
return materials.getOrDefault(replace, material);
|
||||
}
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.dfsek.terra.addons.ore.ores;
|
||||
|
||||
import com.dfsek.terra.addons.ore.utils.VanillaOreUtils;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.dfsek.terra.addons.ore.utils.VanillaOreUtils.shouldPlace;
|
||||
|
||||
|
||||
public class VanillaScatteredOre extends VanillaOre {
|
||||
protected final int spread;
|
||||
public VanillaScatteredOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity, double exposed,
|
||||
Map<BlockType, BlockState> materials, int spread) {
|
||||
super(material, size, replaceable, applyGravity, exposed, materials);
|
||||
|
||||
this.spread = spread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
int i = random.nextInt((int) (size + 1));
|
||||
Vector3Int.Mutable mutable = Vector3Int.zero().mutable();
|
||||
|
||||
for(int j = 0; j < i; ++j) {
|
||||
this.setPos(mutable, random, location, Math.min(j, spread));
|
||||
BlockType block = world.getBlockState(mutable).getBlockType();
|
||||
if (shouldPlace(getReplaceable(), block, exposed, random, world, mutable.getX(), mutable.getY(), mutable.getZ())) {
|
||||
world.setBlockState(mutable, getMaterial(block), isApplyGravity());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setPos(Vector3Int.Mutable mutable, Random random, Vector3Int location, int spread) {
|
||||
int x = this.getSpread(random, spread);
|
||||
int y = this.getSpread(random, spread);
|
||||
int z = this.getSpread(random, spread);
|
||||
mutable.setX(location.getX() + x);
|
||||
mutable.setY(location.getY() + y);
|
||||
mutable.setZ(location.getZ() + z);
|
||||
}
|
||||
|
||||
private int getSpread(Random random, int spread) {
|
||||
return Math.round((random.nextFloat() - random.nextFloat()) * (float)spread);
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.dfsek.terra.addons.ore.utils;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class VanillaOreUtils {
|
||||
protected static boolean shouldNotDiscard(Random random, double chance) {
|
||||
if(chance <= 0.0F) {
|
||||
return true;
|
||||
} else if(chance >= 1.0F) {
|
||||
return false;
|
||||
} else {
|
||||
return random.nextFloat() >= chance;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean shouldPlace(MaterialSet replaceable, BlockType type, Double exposed, Random random, WritableWorld world, int x, int y, int z) {
|
||||
if(!replaceable.contains(type)) {
|
||||
return false;
|
||||
} else if(shouldNotDiscard(random, exposed)) {
|
||||
return true;
|
||||
} else {
|
||||
return !(world.getBlockState(x, y, z - 1).isAir() ||
|
||||
world.getBlockState(x, y, z + 1).isAir() ||
|
||||
world.getBlockState(x, y - 1, z).isAir() ||
|
||||
world.getBlockState(x, y + 1, z).isAir() ||
|
||||
world.getBlockState(x - 1, y, z).isAir() ||
|
||||
world.getBlockState(x + 1, y, z).isAir());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version = version("1.0.1")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
-9
@@ -7,11 +7,6 @@ import java.util.function.Supplier;
|
||||
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
|
||||
import com.dfsek.terra.addons.image.config.ColorLoader;
|
||||
import com.dfsek.terra.addons.image.config.ColorLoader.ColorString;
|
||||
import com.dfsek.terra.addons.image.config.ImageLibraryPackConfigTemplate;
|
||||
import com.dfsek.terra.addons.image.config.noisesampler.ChannelNoiseSamplerTemplate;
|
||||
import com.dfsek.terra.addons.image.config.noisesampler.DistanceTransformNoiseSamplerTemplate;
|
||||
import com.dfsek.terra.addons.image.config.image.ImageTemplate;
|
||||
import com.dfsek.terra.addons.image.config.image.StitchedImageTemplate;
|
||||
import com.dfsek.terra.addons.image.config.colorsampler.ConstantColorSamplerTemplate;
|
||||
import com.dfsek.terra.addons.image.config.colorsampler.image.SingleImageColorSamplerTemplate;
|
||||
import com.dfsek.terra.addons.image.config.colorsampler.image.TileImageColorSamplerTemplate;
|
||||
@@ -57,10 +52,6 @@ public class ImageLibraryAddon implements AddonInitializer {
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.priority(10)
|
||||
.then(event -> {
|
||||
ImageLibraryPackConfigTemplate config = event.loadTemplate(new ImageLibraryPackConfigTemplate());
|
||||
event.getPack().getContext().put(config);
|
||||
})
|
||||
.then(event -> {
|
||||
ConfigPack pack = event.getPack();
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Image>>> imageRegistry = pack.getOrCreateRegistry(IMAGE_REGISTRY_KEY);
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
package com.dfsek.terra.addons.image.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Description;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
|
||||
public class ImageLibraryPackConfigTemplate implements ConfigTemplate, Properties {
|
||||
// TODO - These would be better as plugin wide config parameters in config.yml
|
||||
|
||||
@Value("images.cache.load-on-use")
|
||||
@Description("If set to true, images will load into memory upon use rather than on pack load.")
|
||||
@Default
|
||||
private boolean loadOnUse = false;
|
||||
|
||||
@Value("images.cache.timeout")
|
||||
@Description("How many seconds to keep images loaded in the image cache for. " +
|
||||
"If set to a number greater than 0, images will be removed from memory if not used after the timeout, otherwise images will stay loaded in memory. " +
|
||||
"Setting the timeout to greater than 0 will trade decreased memory consumption when not performing any image reads for a period of time for extra processing time required to perform cache lookups.")
|
||||
@Default
|
||||
private int cacheTimeout = 0;
|
||||
|
||||
public boolean loadOnUse() {
|
||||
return loadOnUse;
|
||||
}
|
||||
|
||||
public boolean unloadOnTimeout() {
|
||||
return cacheTimeout > 0;
|
||||
}
|
||||
|
||||
public int getCacheTimeout() {
|
||||
return cacheTimeout;
|
||||
}
|
||||
}
|
||||
+22
-38
@@ -3,60 +3,44 @@ package com.dfsek.terra.addons.image.config.image;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.dfsek.terra.addons.image.config.ImageLibraryPackConfigTemplate;
|
||||
import com.dfsek.terra.addons.image.image.BufferedImageWrapper;
|
||||
import com.dfsek.terra.addons.image.image.Image;
|
||||
import com.dfsek.terra.addons.image.image.SuppliedImage;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.Loader;
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
|
||||
|
||||
/*
|
||||
* Cache prevents configs from loading the same image multiple times into memory
|
||||
*/
|
||||
record ImageCache(LoadingCache<String, Image> cache) implements Properties {
|
||||
record ImageCache(ConcurrentHashMap<String, Image> map) implements Properties {
|
||||
public static Image load(String path, ConfigPack pack, Loader files) throws IOException {
|
||||
ImageLibraryPackConfigTemplate config = pack.getContext().get(ImageLibraryPackConfigTemplate.class);
|
||||
ImageCache images;
|
||||
ImageCache cache;
|
||||
if(!pack.getContext().has(ImageCache.class)) {
|
||||
var cacheBuilder = Caffeine.newBuilder();
|
||||
if (config.unloadOnTimeout()) cacheBuilder.expireAfterAccess(config.getCacheTimeout(), TimeUnit.SECONDS);
|
||||
images = new ImageCache(cacheBuilder.build(s -> loadImage(s, files)));
|
||||
pack.getContext().put(images);
|
||||
} else images = pack.getContext().get(ImageCache.class);
|
||||
|
||||
if (config.loadOnUse()) {
|
||||
if(config.unloadOnTimeout()) { // Grab directly from cache if images are to unload on timeout
|
||||
return new SuppliedImage(() -> images.cache.get(path));
|
||||
} else {
|
||||
// If images do not time out, image can be lazily loaded once instead of performing cache lookups for each image operation
|
||||
Lazy<Image> lazyImage = Lazy.lazy(() -> images.cache.get(path));
|
||||
return new SuppliedImage(lazyImage::value);
|
||||
}
|
||||
cache = new ImageCache(new ConcurrentHashMap<>());
|
||||
pack.getContext().put(cache);
|
||||
} else {
|
||||
cache = pack.getContext().get(ImageCache.class);
|
||||
}
|
||||
|
||||
return images.cache.get(path);
|
||||
}
|
||||
|
||||
private static Image loadImage(String path, Loader files) throws IOException {
|
||||
try {
|
||||
return new BufferedImageWrapper(ImageIO.read(files.get(path)));
|
||||
} catch(IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("Unable to load image (image might be too large?)", e);
|
||||
} catch(IOException e) {
|
||||
if(e instanceof FileNotFoundException) {
|
||||
// Rethrow using nicer message
|
||||
throw new IOException("Unable to load image: No such file or directory: " + path, e);
|
||||
if(cache.map.containsKey(path)) {
|
||||
return cache.map.get(path);
|
||||
} else {
|
||||
try {
|
||||
BufferedImageWrapper image = new BufferedImageWrapper(ImageIO.read(files.get(path)));
|
||||
cache.map.put(path, image);
|
||||
return image;
|
||||
} catch(IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("Unable to load image (image might be too large?)", e);
|
||||
} catch(IOException e) {
|
||||
if(e instanceof FileNotFoundException) {
|
||||
// Rethrow using nicer message
|
||||
throw new IOException("Unable to load image: No such file or directory: " + path, e);
|
||||
}
|
||||
throw new IOException("Unable to load image", e);
|
||||
}
|
||||
throw new IOException("Unable to load image", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.dfsek.terra.addons.image.image;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SuppliedImage implements Image {
|
||||
|
||||
private final Supplier<Image> imageSupplier;
|
||||
|
||||
public SuppliedImage(Supplier<Image> imageSupplier) {
|
||||
this.imageSupplier = imageSupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGB(int x, int y) {
|
||||
return imageSupplier.get().getRGB(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return imageSupplier.get().getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return imageSupplier.get().getHeight();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user