2 Commits

Author SHA1 Message Date
2d4f820f04 added advanced texture support 2025-03-22 17:28:43 +01:00
ab97315910 added advanced model registry 2025-03-21 19:22:15 +01:00
2244 changed files with 27145 additions and 161 deletions

2
.idea/modules.xml generated
View File

@ -3,7 +3,7 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/PixelPic.main.iml" filepath="$PROJECT_DIR$/.idea/modules/PixelPic.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/PixelPics.main.iml" filepath="$PROJECT_DIR$/.idea/modules/PixelPics.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/PixelPics.PixelPic.main.iml" filepath="$PROJECT_DIR$/.idea/modules/PixelPics.PixelPic.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/eu.mhsl.minecraft.pixelpic.PixelPic.main.iml" filepath="$PROJECT_DIR$/.idea/modules/eu.mhsl.minecraft.pixelpic.PixelPic.main.iml" />
</modules>
</component>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>PAPER</platformType>
<platformType>ADVENTURE</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
</module>

View File

@ -2,7 +2,7 @@ plugins {
id 'java'
}
group = 'eu.mhsl.minecraft.pixelpics'
group = 'eu.mhsl.minecraft.pixelpic'
version = '1.0-SNAPSHOT'
repositories {

View File

@ -1 +1 @@
rootProject.name = 'PixelPics'
rootProject.name = 'PixelPic'

View File

@ -1,4 +1,4 @@
package eu.mhsl.minecraft.pixelpics;
package eu.mhsl.minecraft.pixelpic;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;

View File

@ -0,0 +1,107 @@
package eu.mhsl.minecraft.pixelpic;
import eu.mhsl.minecraft.pixelpic.commands.PixelPicCommand;
import eu.mhsl.minecraft.pixelpic.render.render.DefaultScreenRenderer;
import eu.mhsl.minecraft.pixelpic.render.render.Renderer;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public final class Main extends JavaPlugin {
private static Main instance;
private Renderer screenRenderer;
@Override
public void onEnable() {
instance = this;
extractJsonResources();
Bukkit.getPluginCommand("pixelPic").setExecutor(new PixelPicCommand());
Bukkit.getPluginCommand("test").setExecutor((sender, command, label, args) -> {
Material.getMaterial("acacia_button");
Bukkit.broadcast(Component.text(Material.STONE.getBlockTranslationKey().replace("block.minecraft.", "")));
if(!(sender instanceof Player player))
throw new IllegalStateException("Dieser Command kann nur von einem Spieler ausgeführt werden!");
File blockDir = new File(getDataFolder(), "models/block");
for (File file : blockDir.listFiles()) {
String blockName = file.getName().substring(0, file.getName().lastIndexOf('.'));
Material material = Material.getMaterial(blockName.toUpperCase());
System.out.println(material);
if(material == null) {
System.out.println(blockName);
}
}
return true;
});
}
@Override
public void onDisable() {
}
public void extractJsonResources() {
String resourcePath = "models/block/"; // Pfad im JAR
File outputDir = new File(getDataFolder(), resourcePath);
if (outputDir.exists()) return;
outputDir.mkdirs();
try {
URL jarUrl = getClass().getProtectionDomain().getCodeSource().getLocation();
File jarFile = new File(jarUrl.toURI());
try (JarFile jar = new JarFile(jarFile)) {
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String entryName = entry.getName();
// Nur JSON-Dateien im gewünschten Ordner
if (entryName.startsWith(resourcePath) && entryName.endsWith(".json")) {
InputStream in = getResource(entryName);
if (in == null) continue;
File outFile = new File(getDataFolder(), entryName);
outFile.getParentFile().mkdirs(); // Ordnerstruktur sicherstellen
try (OutputStream out = new FileOutputStream(outFile)) {
byte[] buffer = new byte[1024];
int len;
while ((len = in.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
System.out.println("Extrahiert: " + entryName);
}
in.close();
}
}
}
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
public Renderer getScreenRenderer() {
if(this.screenRenderer == null) this.screenRenderer = new DefaultScreenRenderer();
return this.screenRenderer;
}
public static Main getInstance() {
return instance;
}
}

View File

@ -1,8 +1,8 @@
package eu.mhsl.minecraft.pixelpics.commands;
package eu.mhsl.minecraft.pixelpic.commands;
import eu.mhsl.minecraft.pixelpics.ImageMapRenderer;
import eu.mhsl.minecraft.pixelpics.Main;
import eu.mhsl.minecraft.pixelpics.render.render.Resolution;
import eu.mhsl.minecraft.pixelpic.ImageMapRenderer;
import eu.mhsl.minecraft.pixelpic.Main;
import eu.mhsl.minecraft.pixelpic.render.render.Resolution;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
@ -18,7 +18,7 @@ import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
public class PixelPicsCommand implements CommandExecutor {
public class PixelPicCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
if(!(sender instanceof Player player))

View File

@ -1,12 +1,12 @@
package eu.mhsl.minecraft.pixelpics.render.model;
package eu.mhsl.minecraft.pixelpic.render.model;
import com.google.common.base.Preconditions;
import eu.mhsl.minecraft.pixelpics.render.model.MultiModel.MultiModelBuilder;
import eu.mhsl.minecraft.pixelpics.render.model.CrossModel.CrossModelBuilder;
import eu.mhsl.minecraft.pixelpics.render.model.StaticModel.StaticModelBuilder;
import eu.mhsl.minecraft.pixelpics.render.model.OctahedronModel.OctahedronModelBuilder;
import eu.mhsl.minecraft.pixelpics.render.model.SphereModel.SphereModelBuilder;
import eu.mhsl.minecraft.pixelpic.render.model.MultiModel.MultiModelBuilder;
import eu.mhsl.minecraft.pixelpic.render.model.CrossModel.CrossModelBuilder;
import eu.mhsl.minecraft.pixelpic.render.model.StaticModel.StaticModelBuilder;
import eu.mhsl.minecraft.pixelpic.render.model.OctahedronModel.OctahedronModelBuilder;
import eu.mhsl.minecraft.pixelpic.render.model.SphereModel.SphereModelBuilder;
public abstract class AbstractModel implements Model {

View File

@ -1,7 +1,7 @@
package eu.mhsl.minecraft.pixelpics.render.model;
package eu.mhsl.minecraft.pixelpic.render.model;
import eu.mhsl.minecraft.pixelpics.render.util.Intersection;
import eu.mhsl.minecraft.pixelpics.render.util.MathUtil;
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
import eu.mhsl.minecraft.pixelpic.render.util.MathUtil;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;

View File

@ -1,6 +1,6 @@
package eu.mhsl.minecraft.pixelpics.render.model;
package eu.mhsl.minecraft.pixelpic.render.model;
import eu.mhsl.minecraft.pixelpics.render.util.Intersection;
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
import org.bukkit.block.Block;
public interface Model {

View File

@ -1,6 +1,6 @@
package eu.mhsl.minecraft.pixelpics.render.model;
package eu.mhsl.minecraft.pixelpic.render.model;
import eu.mhsl.minecraft.pixelpics.render.util.Intersection;
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;

View File

@ -1,7 +1,7 @@
package eu.mhsl.minecraft.pixelpics.render.model;
package eu.mhsl.minecraft.pixelpic.render.model;
import eu.mhsl.minecraft.pixelpics.render.util.Intersection;
import eu.mhsl.minecraft.pixelpics.render.util.MathUtil;
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
import eu.mhsl.minecraft.pixelpic.render.util.MathUtil;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;

View File

@ -1,6 +1,6 @@
package eu.mhsl.minecraft.pixelpics.render.model;
package eu.mhsl.minecraft.pixelpic.render.model;
import eu.mhsl.minecraft.pixelpics.render.util.Intersection;
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;

View File

@ -1,7 +1,7 @@
package eu.mhsl.minecraft.pixelpics.render.model;
package eu.mhsl.minecraft.pixelpic.render.model;
import eu.mhsl.minecraft.pixelpics.render.util.Intersection;
import eu.mhsl.minecraft.pixelpics.render.util.MathUtil;
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
import eu.mhsl.minecraft.pixelpic.render.util.MathUtil;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;

View File

@ -1,7 +1,7 @@
package eu.mhsl.minecraft.pixelpics.render.model;
package eu.mhsl.minecraft.pixelpic.render.model;
import eu.mhsl.minecraft.pixelpics.render.model.AbstractModel.Builder;
import eu.mhsl.minecraft.pixelpics.render.util.Intersection;
import eu.mhsl.minecraft.pixelpic.render.model.AbstractModel.Builder;
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
import org.bukkit.block.Block;
public class StaticModel implements Model {

View File

@ -0,0 +1,151 @@
package eu.mhsl.minecraft.pixelpic.render.raytrace;
import eu.mhsl.minecraft.pixelpic.render.model.Model;
import eu.mhsl.minecraft.pixelpic.render.registry.AdvancedModelRegistry;
import eu.mhsl.minecraft.pixelpic.render.registry.ModelRegistry;
import eu.mhsl.minecraft.pixelpic.render.util.BlockRaytracer;
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
import eu.mhsl.minecraft.pixelpic.render.util.MathUtil;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.util.Vector;
public class AdvancedRaytracer implements Raytracer {
private final int maxDistance;
private final int reflectionDepth;
private final AdvancedModelRegistry textureRegistry;
private Block reflectedBlock;
public AdvancedRaytracer() {
this(300, 10);
}
public AdvancedRaytracer(int maxDistance, int reflectionDepth) {
this.maxDistance = maxDistance;
this.reflectionDepth = reflectionDepth;
this.textureRegistry = new AdvancedModelRegistry();
this.textureRegistry.initialize();
this.reflectedBlock = null;
}
@Override
public int trace(World world, Vector point, Vector direction) {
return trace(world, point, direction, reflectionDepth);
}
private int trace(World world, Vector point, Vector direction, int reflectionDepth) {
Location loc = point.toLocation(world);
loc.setDirection(direction);
BlockRaytracer iterator = new BlockRaytracer(loc);
int baseColor = Color.fromRGB(65, 89, 252).asRGB();
Vector finalIntersection = null;
int reflectionColor = 0;
double reflectionFactor = 0;
boolean reflected = false;
Vector transparencyStart = null;
int transparencyColor = 0;
double transparencyFactor = 0;
Material occlusionMaterial = null;
BlockData occlusionData = null;
for (int i = 0; i < maxDistance; i++) {
if (!iterator.hasNext()) break;
Block block = iterator.next();
if (reflectedBlock != null && reflectedBlock.equals(block)) continue;
reflectedBlock = null;
Material material = block.getType();
if (material == Material.AIR) {
occlusionMaterial = null;
occlusionData = null;
continue;
}
Model textureModel = textureRegistry.getModel(block.getType(), block.getBlockData(), block.getTemperature(), block.getHumidity());
Intersection currentIntersection = Intersection.of(
MathUtil.toVector(iterator.getIntersectionFace()),
i == 0 ? point : iterator.getIntersectionPoint(),
direction
);
Intersection newIntersection = textureModel.intersect(block, currentIntersection);
if (newIntersection == null) continue;
int color = newIntersection.getColor();
if (!reflected && textureModel.getReflectionFactor() > 0 && reflectionDepth > 0 && (color >> 24) != 0) {
reflectedBlock = block;
reflectionColor = trace(
world,
newIntersection.getPoint(),
MathUtil.reflectVector(
point,
direction,
newIntersection.getPoint(),
newIntersection.getNormal()
),
reflectionDepth - 1
);
reflectionFactor = textureModel.getReflectionFactor();
reflected = true;
}
if (transparencyStart == null && textureModel.getTransparencyFactor() > 0) {
transparencyStart = newIntersection.getPoint();
transparencyColor = newIntersection.getColor();
transparencyFactor = textureModel.getTransparencyFactor();
}
if (textureModel.isOccluding()) {
BlockData data = block.getBlockData();
if (material == occlusionMaterial && data.equals(occlusionData)) continue;
occlusionMaterial = material;
occlusionData = data;
} else {
occlusionMaterial = null;
occlusionData = null;
}
if (transparencyStart != null && textureModel.getTransparencyFactor() > 0) continue;
if ((color >> 24) == 0) continue;
baseColor = color;
finalIntersection = newIntersection.getPoint();
break;
}
if (transparencyStart != null) {
baseColor = MathUtil.weightedColorSum(
baseColor,
transparencyColor,
transparencyFactor,
(1
- transparencyFactor)
* (1 + transparencyStart.distance(finalIntersection == null ? transparencyStart : finalIntersection)
/ 5.0));
}
if (reflected) {
baseColor = MathUtil.weightedColorSum(
baseColor,
reflectionColor,
1 - reflectionFactor,
reflectionFactor
);
}
return baseColor & 0xFFFFFF;
}
}

View File

@ -1,15 +1,16 @@
package eu.mhsl.minecraft.pixelpics.render.raytrace;
package eu.mhsl.minecraft.pixelpic.render.raytrace;
import eu.mhsl.minecraft.pixelpics.render.model.Model;
import eu.mhsl.minecraft.pixelpics.render.registry.DefaultModelRegistry;
import eu.mhsl.minecraft.pixelpics.render.registry.ModelRegistry;
import eu.mhsl.minecraft.pixelpics.render.util.BlockRaytracer;
import eu.mhsl.minecraft.pixelpics.render.util.Intersection;
import eu.mhsl.minecraft.pixelpics.render.util.MathUtil;
import eu.mhsl.minecraft.pixelpic.render.model.Model;
import eu.mhsl.minecraft.pixelpic.render.registry.AdvancedModelRegistry;
import eu.mhsl.minecraft.pixelpic.render.registry.ModelRegistry;
import eu.mhsl.minecraft.pixelpic.render.util.BlockRaytracer;
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
import eu.mhsl.minecraft.pixelpic.render.util.MathUtil;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.util.Vector;
@ -29,7 +30,7 @@ public class DefaultRaytracer implements Raytracer {
this.maxDistance = maxDistance;
this.reflectionDepth = reflectionDepth;
this.textureRegistry = new DefaultModelRegistry();
this.textureRegistry = new AdvancedModelRegistry();
this.textureRegistry.initialize();
this.reflectedBlock = null;
@ -71,6 +72,7 @@ public class DefaultRaytracer implements Raytracer {
continue;
}
Biome biome = block.getBiome();
Model textureModel = textureRegistry.getModel(block);
Intersection currentIntersection = Intersection.of(
MathUtil.toVector(iterator.getIntersectionFace()),

View File

@ -1,4 +1,4 @@
package eu.mhsl.minecraft.pixelpics.render.raytrace;
package eu.mhsl.minecraft.pixelpic.render.raytrace;
import org.bukkit.World;
import org.bukkit.util.Vector;

View File

@ -0,0 +1,157 @@
package eu.mhsl.minecraft.pixelpic.render.registry;
import com.google.gson.Gson;
import eu.mhsl.minecraft.pixelpic.Main;
import eu.mhsl.minecraft.pixelpic.render.model.AbstractModel;
import eu.mhsl.minecraft.pixelpic.render.model.Model;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.URL;
import java.util.*;
import static eu.mhsl.minecraft.pixelpic.render.registry.DefaultModelRegistry.TEXTURE_SIZE;
public class AdvancedModelRegistry implements ModelRegistry {
private final Gson gson = new Gson();
private final Map<Material, Map<BlockData, Model>> modelMap = new HashMap<>();
private final Set<String> tintedBlocks = Set.of("grass", "grass_block", "leaves", "oak_leaves", "water", "vine", "sugar_cane");
public record BlockInfo(String parent, BlockTextures textures){}
public record BlockTextures(
String texture,
String bottom,
String top,
String all,
String particle,
String end,
String side,
String cross,
String rail,
String overlay
){}
@Override
public void initialize() {
System.out.println(modelMap);
File blockDir = new File(Main.getInstance().getDataFolder(), "models/block");
for (File file : Objects.requireNonNull(blockDir.listFiles())) {
addModelFromFile(file);
}
try {
registerModel(Material.LAVA, AbstractModel.Builder.createSimple(getTextureArray("lava_still"))
.transparency(0.15).reflection(0.05).occlusion().build());
registerModel(Material.WATER, AbstractModel.Builder.createSimple(getTextureArray("water_still"))
.transparency(0.60).reflection(0.1).occlusion().build());
} catch (Exception ignored) { }
}
@Override
public Model getModel(Block block) {
return ModelRegistry.super.getModel(block);
}
@Override
public Model getModel(Material material, BlockData blockData) {
return getModel(material, blockData, 0.8, 0.4);
}
public Model getModel(Material material, BlockData blockData, double temperature, double humidity) {
return modelMap.computeIfAbsent(material, key -> new HashMap<>()).getOrDefault(blockData,
blockData == null ? getDefaultModel()
: modelMap.get(material).getOrDefault(null, getDefaultModel()));
}
@Override
public Model getDefaultModel() {
return AbstractModel.Builder.createStatic(Color.PURPLE.asRGB()).build();
}
private void registerModel(Material material, Model blockModel) {
modelMap.computeIfAbsent(material, key -> new HashMap<>())
.put(null, blockModel);
}
private void addModelFromFile(File file) {
String blockName = file.getName().substring(0, file.getName().lastIndexOf('.'));
Material material = Material.getMaterial(blockName.toUpperCase());
if(material == null) return;
Model model = getModelFromFile(file);
if(model == null) return;
registerModel(material, model);
}
private Model getModelFromFile(File file) {
try (Reader reader = new FileReader(file)) {
BlockInfo blockInfo = gson.fromJson(reader, BlockInfo.class);
if(blockInfo.textures.all != null) {
return AbstractModel.Builder.createSimple(
getTextureArray(blockInfo.textures.all.substring(blockInfo.textures.all.lastIndexOf('/') + 1))
).build();
}
if(blockInfo.textures.cross != null) {
return AbstractModel.Builder.createCross(
getTextureArray(blockInfo.textures.cross.substring(blockInfo.textures.cross.lastIndexOf('/') + 1))
).build();
}
if(blockInfo.textures.side != null && blockInfo.textures.bottom != null && blockInfo.textures.top != null) {
return AbstractModel.Builder.createMulti(
getTextureArray(blockInfo.textures.top.substring(blockInfo.textures.top.lastIndexOf('/') + 1)),
getTextureArray(blockInfo.textures.side.substring(blockInfo.textures.side.lastIndexOf('/') + 1)),
getTextureArray(blockInfo.textures.bottom.substring(blockInfo.textures.bottom.lastIndexOf('/') + 1))
).build();
}
if(blockInfo.textures.side != null && blockInfo.textures.end != null) {
return AbstractModel.Builder.createMulti(
getTextureArray(blockInfo.textures.end.substring(blockInfo.textures.end.lastIndexOf('/') + 1)),
getTextureArray(blockInfo.textures.side.substring(blockInfo.textures.side.lastIndexOf('/') + 1)),
getTextureArray(blockInfo.textures.end.substring(blockInfo.textures.end.lastIndexOf('/') + 1))
).build();
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
return null;
}
private int[][] getTextureArray(String textureName) {
int[][] texture = new int[TEXTURE_SIZE][TEXTURE_SIZE];
BufferedImage img;
URL url = this.getClass().getClassLoader().getResource(String.format("textures/block/%s.png", textureName));
if (url == null) {
throw new RuntimeException("Block Texture Resource not found.");
}
try (InputStream input = url.openConnection().getInputStream()) {
img = ImageIO.read(input);
} catch (IOException e) {
throw new RuntimeException(e);
}
for (int pixelY = 0; pixelY < TEXTURE_SIZE; pixelY++) {
for (int pixelX = 0; pixelX < TEXTURE_SIZE; pixelX++) {
texture[TEXTURE_SIZE - 1 - pixelY][TEXTURE_SIZE - 1 - pixelX] = img.getRGB(pixelX, pixelY);
}
}
return texture;
}
private int tintPixel(int baseColor, int tintColor) {
int a = (baseColor >> 24) & 0xFF;
int r = ((baseColor >> 16) & 0xFF) * ((tintColor >> 16) & 0xFF) / 255;
int g = ((baseColor >> 8) & 0xFF) * ((tintColor >> 8) & 0xFF) / 255;
int b = (baseColor & 0xFF) * (tintColor & 0xFF) / 255;
return (a << 24) | (r << 16) | (g << 8) | b;
}
}

View File

@ -1,7 +1,7 @@
package eu.mhsl.minecraft.pixelpics.render.registry;
package eu.mhsl.minecraft.pixelpic.render.registry;
import eu.mhsl.minecraft.pixelpics.render.model.AbstractModel.Builder;
import eu.mhsl.minecraft.pixelpics.render.model.Model;
import eu.mhsl.minecraft.pixelpic.render.model.AbstractModel.Builder;
import eu.mhsl.minecraft.pixelpic.render.model.Model;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;

View File

@ -1,6 +1,6 @@
package eu.mhsl.minecraft.pixelpics.render.registry;
package eu.mhsl.minecraft.pixelpic.render.registry;
import eu.mhsl.minecraft.pixelpics.render.model.Model;
import eu.mhsl.minecraft.pixelpic.render.model.Model;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;

View File

@ -1,8 +1,8 @@
package eu.mhsl.minecraft.pixelpics.render.render;
package eu.mhsl.minecraft.pixelpic.render.render;
import eu.mhsl.minecraft.pixelpics.render.raytrace.DefaultRaytracer;
import eu.mhsl.minecraft.pixelpics.render.raytrace.Raytracer;
import eu.mhsl.minecraft.pixelpics.render.util.MathUtil;
import eu.mhsl.minecraft.pixelpic.render.raytrace.DefaultRaytracer;
import eu.mhsl.minecraft.pixelpic.render.raytrace.Raytracer;
import eu.mhsl.minecraft.pixelpic.render.util.MathUtil;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package eu.mhsl.minecraft.pixelpics.render.render;
package eu.mhsl.minecraft.pixelpic.render.render;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package eu.mhsl.minecraft.pixelpics.render.render;
package eu.mhsl.minecraft.pixelpic.render.render;
import com.google.common.base.Preconditions;

View File

@ -1,4 +1,4 @@
package eu.mhsl.minecraft.pixelpics.render.util;
package eu.mhsl.minecraft.pixelpic.render.util;
import org.bukkit.Location;
import org.bukkit.block.Block;

View File

@ -1,4 +1,4 @@
package eu.mhsl.minecraft.pixelpics.render.util;
package eu.mhsl.minecraft.pixelpic.render.util;
import org.bukkit.util.Vector;

View File

@ -1,4 +1,4 @@
package eu.mhsl.minecraft.pixelpics.render.util;
package eu.mhsl.minecraft.pixelpic.render.util;
import org.bukkit.Color;
import org.bukkit.block.BlockFace;

View File

@ -1,86 +0,0 @@
package eu.mhsl.minecraft.pixelpics;
import eu.mhsl.minecraft.pixelpics.commands.PixelPicsCommand;
import eu.mhsl.minecraft.pixelpics.render.render.DefaultScreenRenderer;
import eu.mhsl.minecraft.pixelpics.render.render.Renderer;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class Main extends JavaPlugin {
private static Main instance;
private Renderer screenRenderer;
@Override
public void onEnable() {
instance = this;
Bukkit.getPluginCommand("pixelPics").setExecutor(new PixelPicsCommand());
//
// Bukkit.getPluginCommand("test2").setExecutor((sender, command, label, args) -> {
// if(!(sender instanceof Player player)) return false;
// Bukkit.broadcast(Component.text("HI"));
//
// Resolution.Pixels pixels = Resolution.Pixels._256P;
// Resolution.AspectRatio aspectRatio = Resolution.AspectRatio._1_1;
// Resolution resolution = new Resolution(pixels, aspectRatio);
// BufferedImage image = screenRenderer.render((Player) sender, resolution);
// Bukkit.broadcast(Component.text(image.toString()));
//
// File file = new File(getDataFolder(), "Bild" + ".png");
// try {
// getDataFolder().mkdir();
// ImageIO.write(image, "png", file);
// } catch (Exception e) {
// return true;
// }
//
// ItemStack map = new ItemStack(Material.FILLED_MAP, 1);
// MapMeta meta = (MapMeta) map.getItemMeta();
// MapView mapView = Bukkit.createMap(Bukkit.getWorlds().getFirst());
// mapView.addRenderer(new ImageMapRenderer(image, 0, 0));
// meta.setMapView(mapView);
// map.setItemMeta(meta);
// player.getInventory().addItem(map);
//
// ItemStack map2 = new ItemStack(Material.FILLED_MAP, 1);
// MapMeta meta1 = (MapMeta) map2.getItemMeta();
// MapView mapView4 = Bukkit.createMap(Bukkit.getWorlds().getFirst());
// mapView4.addRenderer(new ImageMapRenderer(image, 1, 0));
// meta1.setMapView(mapView4);
// map2.setItemMeta(meta1);
// player.getInventory().addItem(map2);
//
// ItemStack map3 = new ItemStack(Material.FILLED_MAP, 1);
// MapMeta meta2 = (MapMeta) map3.getItemMeta();
// MapView mapView3 = Bukkit.createMap(Bukkit.getWorlds().getFirst());
// mapView3.addRenderer(new ImageMapRenderer(image, 0, 1));
// meta2.setMapView(mapView3);
// map3.setItemMeta(meta2);
// player.getInventory().addItem(map3);
//
// ItemStack map4 = new ItemStack(Material.FILLED_MAP, 1);
// MapMeta meta3 = (MapMeta) map4.getItemMeta();
// MapView mapView2 = Bukkit.createMap(Bukkit.getWorlds().getFirst());
// mapView2.addRenderer(new ImageMapRenderer(image, 1, 1));
// meta3.setMapView(mapView2);
// map4.setItemMeta(meta3);
// player.getInventory().addItem(map4);
//
// player.updateInventory();
//
// return true;
// });
}
@Override
public void onDisable() {
}
public Renderer getScreenRenderer() {
if(this.screenRenderer == null) this.screenRenderer = new DefaultScreenRenderer();
return this.screenRenderer;
}
public static Main getInstance() {
return instance;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/button",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/button_inventory",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/button_pressed",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/door_bottom_left",
"textures": {
"bottom": "minecraft:block/acacia_door_bottom",
"top": "minecraft:block/acacia_door_top"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/door_bottom_left_open",
"textures": {
"bottom": "minecraft:block/acacia_door_bottom",
"top": "minecraft:block/acacia_door_top"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/door_bottom_right",
"textures": {
"bottom": "minecraft:block/acacia_door_bottom",
"top": "minecraft:block/acacia_door_top"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/door_bottom_right_open",
"textures": {
"bottom": "minecraft:block/acacia_door_bottom",
"top": "minecraft:block/acacia_door_top"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/door_top_left",
"textures": {
"bottom": "minecraft:block/acacia_door_bottom",
"top": "minecraft:block/acacia_door_top"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/door_top_left_open",
"textures": {
"bottom": "minecraft:block/acacia_door_bottom",
"top": "minecraft:block/acacia_door_top"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/door_top_right",
"textures": {
"bottom": "minecraft:block/acacia_door_bottom",
"top": "minecraft:block/acacia_door_top"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/door_top_right_open",
"textures": {
"bottom": "minecraft:block/acacia_door_bottom",
"top": "minecraft:block/acacia_door_top"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_fence_gate",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_fence_gate_open",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_fence_gate_wall",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_fence_gate_wall_open",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/fence_inventory",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/fence_post",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/fence_side",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,5 @@
{
"textures": {
"particle": "minecraft:block/stripped_acacia_log"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/leaves",
"textures": {
"all": "minecraft:block/acacia_leaves"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "minecraft:block/acacia_log_top",
"side": "minecraft:block/acacia_log"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column_horizontal",
"textures": {
"end": "minecraft:block/acacia_log_top",
"side": "minecraft:block/acacia_log"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/pressure_plate_up",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/pressure_plate_down",
"textures": {
"texture": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "minecraft:block/acacia_sapling"
}
}

View File

@ -0,0 +1,5 @@
{
"textures": {
"particle": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/slab",
"textures": {
"bottom": "minecraft:block/acacia_planks",
"side": "minecraft:block/acacia_planks",
"top": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/slab_top",
"textures": {
"bottom": "minecraft:block/acacia_planks",
"side": "minecraft:block/acacia_planks",
"top": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/stairs",
"textures": {
"bottom": "minecraft:block/acacia_planks",
"side": "minecraft:block/acacia_planks",
"top": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/inner_stairs",
"textures": {
"bottom": "minecraft:block/acacia_planks",
"side": "minecraft:block/acacia_planks",
"top": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/outer_stairs",
"textures": {
"bottom": "minecraft:block/acacia_planks",
"side": "minecraft:block/acacia_planks",
"top": "minecraft:block/acacia_planks"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_orientable_trapdoor_bottom",
"textures": {
"texture": "minecraft:block/acacia_trapdoor"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_orientable_trapdoor_open",
"textures": {
"texture": "minecraft:block/acacia_trapdoor"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_orientable_trapdoor_top",
"textures": {
"texture": "minecraft:block/acacia_trapdoor"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "minecraft:block/acacia_log",
"side": "minecraft:block/acacia_log"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/rail_flat",
"textures": {
"rail": "minecraft:block/activator_rail"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/rail_flat",
"textures": {
"rail": "minecraft:block/activator_rail_on"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_rail_raised_ne",
"textures": {
"rail": "minecraft:block/activator_rail_on"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_rail_raised_sw",
"textures": {
"rail": "minecraft:block/activator_rail_on"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_rail_raised_ne",
"textures": {
"rail": "minecraft:block/activator_rail"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_rail_raised_sw",
"textures": {
"rail": "minecraft:block/activator_rail"
}
}

View File

@ -0,0 +1,5 @@
{
"textures": {
"particle": "minecraft:missingno"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "minecraft:block/allium"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "minecraft:block/amethyst_block"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "minecraft:block/amethyst_cluster"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "minecraft:block/ancient_debris_top",
"side": "minecraft:block/ancient_debris_side"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/slab",
"textures": {
"bottom": "minecraft:block/andesite",
"side": "minecraft:block/andesite",
"top": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/slab_top",
"textures": {
"bottom": "minecraft:block/andesite",
"side": "minecraft:block/andesite",
"top": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/stairs",
"textures": {
"bottom": "minecraft:block/andesite",
"side": "minecraft:block/andesite",
"top": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/inner_stairs",
"textures": {
"bottom": "minecraft:block/andesite",
"side": "minecraft:block/andesite",
"top": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/outer_stairs",
"textures": {
"bottom": "minecraft:block/andesite",
"side": "minecraft:block/andesite",
"top": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/wall_inventory",
"textures": {
"wall": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_wall_post",
"textures": {
"wall": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_wall_side",
"textures": {
"wall": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_wall_side_tall",
"textures": {
"wall": "minecraft:block/andesite"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/template_anvil",
"textures": {
"top": "minecraft:block/anvil_top"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/stem_fruit",
"textures": {
"stem": "minecraft:block/melon_stem",
"upperstem": "minecraft:block/attached_melon_stem"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/stem_fruit",
"textures": {
"stem": "minecraft:block/pumpkin_stem",
"upperstem": "minecraft:block/attached_pumpkin_stem"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/template_azalea",
"textures": {
"side": "minecraft:block/azalea_side",
"top": "minecraft:block/azalea_top"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "minecraft:block/azalea_leaves"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cross",
"textures": {
"cross": "minecraft:block/azure_bluet"
}
}

View File

@ -0,0 +1,19 @@
{
"textures": {
"all": "block/bamboo_stalk",
"particle": "block/bamboo_stalk"
},
"elements": [
{ "from": [ 7, 0, 7 ],
"to": [ 9, 16, 9 ],
"faces": {
"down": { "uv": [ 13, 4, 15, 6 ], "texture": "#all", "cullface": "down" },
"up": { "uv": [ 13, 0, 15, 2], "texture": "#all", "cullface": "up" },
"north": { "uv": [ 0, 0, 2, 16 ], "texture": "#all" },
"south": { "uv": [ 0, 0, 2, 16 ], "texture": "#all" },
"west": { "uv": [ 0, 0, 2, 16 ], "texture": "#all" },
"east": { "uv": [ 0, 0, 2, 16 ], "texture": "#all" }
}
}
]
}

View File

@ -0,0 +1,19 @@
{
"textures": {
"all": "block/bamboo_stalk",
"particle": "block/bamboo_stalk"
},
"elements": [
{ "from": [ 6.5, 0, 6.5 ],
"to": [ 9.5, 16, 9.5 ],
"faces": {
"down": { "uv": [ 13, 4, 16, 7 ], "texture": "#all", "cullface": "down" },
"up": { "uv": [ 13, 0, 16, 3 ], "texture": "#all", "cullface": "up" },
"north": { "uv": [ 0, 0, 3, 16 ], "texture": "#all" },
"south": { "uv": [ 0, 0, 3, 16 ], "texture": "#all" },
"west": { "uv": [ 0, 0, 3, 16 ], "texture": "#all" },
"east": { "uv": [ 0, 0, 3, 16 ], "texture": "#all" }
}
}
]
}

View File

@ -0,0 +1,19 @@
{
"textures": {
"all": "block/bamboo_stalk",
"particle": "block/bamboo_stalk"
},
"elements": [
{ "from": [ 7, 0, 7 ],
"to": [ 9, 16, 9 ],
"faces": {
"down": { "uv": [ 13, 4, 15, 6 ], "texture": "#all", "cullface": "down" },
"up": { "uv": [ 13, 0, 15, 2], "texture": "#all", "cullface": "up" },
"north": { "uv": [ 3, 0, 5, 16 ], "texture": "#all" },
"south": { "uv": [ 3, 0, 5, 16 ], "texture": "#all" },
"west": { "uv": [ 3, 0, 5, 16 ], "texture": "#all" },
"east": { "uv": [ 3, 0, 5, 16 ], "texture": "#all" }
}
}
]
}

View File

@ -0,0 +1,19 @@
{
"textures": {
"all": "block/bamboo_stalk",
"particle": "block/bamboo_stalk"
},
"elements": [
{ "from": [ 6.5, 0, 6.5 ],
"to": [ 9.5, 16, 9.5 ],
"faces": {
"down": { "uv": [ 13, 4, 16, 7 ], "texture": "#all", "cullface": "down" },
"up": { "uv": [ 13, 0, 16, 3 ], "texture": "#all", "cullface": "up" },
"north": { "uv": [ 3, 0, 6, 16 ], "texture": "#all" },
"south": { "uv": [ 3, 0, 6, 16 ], "texture": "#all" },
"west": { "uv": [ 3, 0, 6, 16 ], "texture": "#all" },
"east": { "uv": [ 3, 0, 6, 16 ], "texture": "#all" }
}
}
]
}

View File

@ -0,0 +1,19 @@
{
"textures": {
"all": "block/bamboo_stalk",
"particle": "block/bamboo_stalk"
},
"elements": [
{ "from": [ 7, 0, 7 ],
"to": [ 9, 16, 9 ],
"faces": {
"down": { "uv": [ 13, 4, 15, 6 ], "texture": "#all", "cullface": "down" },
"up": { "uv": [ 13, 0, 15, 2], "texture": "#all", "cullface": "up" },
"north": { "uv": [ 6, 0, 8, 16 ], "texture": "#all" },
"south": { "uv": [ 6, 0, 8, 16 ], "texture": "#all" },
"west": { "uv": [ 6, 0, 8, 16 ], "texture": "#all" },
"east": { "uv": [ 6, 0, 8, 16 ], "texture": "#all" }
}
}
]
}

View File

@ -0,0 +1,19 @@
{
"textures": {
"all": "block/bamboo_stalk",
"particle": "block/bamboo_stalk"
},
"elements": [
{ "from": [ 6.5, 0, 6.5 ],
"to": [ 9.5, 16, 9.5 ],
"faces": {
"down": { "uv": [ 13, 4, 16, 7 ], "texture": "#all", "cullface": "down" },
"up": { "uv": [ 13, 0, 16, 3 ], "texture": "#all", "cullface": "up" },
"north": { "uv": [ 6, 0, 9, 16 ], "texture": "#all" },
"south": { "uv": [ 6, 0, 9, 16 ], "texture": "#all" },
"west": { "uv": [ 6, 0, 9, 16 ], "texture": "#all" },
"east": { "uv": [ 6, 0, 9, 16 ], "texture": "#all" }
}
}
]
}

View File

@ -0,0 +1,19 @@
{
"textures": {
"all": "block/bamboo_stalk",
"particle": "block/bamboo_stalk"
},
"elements": [
{ "from": [ 7, 0, 7 ],
"to": [ 9, 16, 9 ],
"faces": {
"down": { "uv": [ 13, 4, 15, 6 ], "texture": "#all", "cullface": "down" },
"up": { "uv": [ 13, 0, 15, 2], "texture": "#all", "cullface": "up" },
"north": { "uv": [ 9, 0, 11, 16 ], "texture": "#all" },
"south": { "uv": [ 9, 0, 11, 16 ], "texture": "#all" },
"west": { "uv": [ 9, 0, 11, 16 ], "texture": "#all" },
"east": { "uv": [ 9, 0, 11, 16 ], "texture": "#all" }
}
}
]
}

Some files were not shown because too many files have changed in this diff Show More