mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-23 17:09:19 +00:00
added MEG & BM support
This commit is contained in:
@@ -22,4 +22,6 @@ public abstract class Entity {
|
||||
public abstract World level();
|
||||
|
||||
public abstract Direction getDirection();
|
||||
|
||||
public abstract Object literalObject();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.momirealms.craftengine.core.entity.furniture;
|
||||
|
||||
public abstract class AbstractExternalModel implements ExternalModel {
|
||||
protected final String id;
|
||||
|
||||
public AbstractExternalModel(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String id() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Optional;
|
||||
|
||||
public class CustomFurniture {
|
||||
private final Key id;
|
||||
@@ -55,7 +56,11 @@ public class CustomFurniture {
|
||||
return placements.get(anchorType);
|
||||
}
|
||||
|
||||
public record Placement(FurnitureElement[] elements, HitBox[] hitBoxes, Collider[] colliders,
|
||||
RotationRule rotationRule, AlignmentRule alignmentRule) {
|
||||
public record Placement(FurnitureElement[] elements,
|
||||
HitBox[] hitBoxes,
|
||||
Collider[] colliders,
|
||||
RotationRule rotationRule,
|
||||
AlignmentRule alignmentRule,
|
||||
Optional<ExternalModel> externalModel) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.momirealms.craftengine.core.entity.furniture;
|
||||
|
||||
import net.momirealms.craftengine.core.entity.Entity;
|
||||
|
||||
public interface ExternalModel {
|
||||
|
||||
String plugin();
|
||||
|
||||
String id();
|
||||
|
||||
void bindModel(Entity entity);
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import org.joml.Vector3f;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface HitBox {
|
||||
|
||||
@@ -27,9 +27,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -38,7 +35,6 @@ import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BiConsumer;
|
||||
@@ -499,7 +495,6 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
this.generateCustomSounds(generatedPackPath);
|
||||
this.generateClientLang(generatedPackPath);
|
||||
this.generateEquipments(generatedPackPath);
|
||||
this.generateShulker(generatedPackPath);
|
||||
|
||||
Path zipFile = resourcePackPath();
|
||||
try {
|
||||
@@ -530,81 +525,6 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateShulker(Path generatedPackPath) {
|
||||
try {
|
||||
if (ConfigManager.removedCollisionBoxEntityTextureLegacy()) {
|
||||
File shulkerFile = generatedPackPath.resolve("assets/minecraft/textures/entity/shulker/shulker.png").toFile();
|
||||
shulkerFile.getParentFile().mkdirs();
|
||||
if (!shulkerFile.exists()) {
|
||||
try (OutputStream out = new FileOutputStream(shulkerFile)) {
|
||||
out.write(SHULKER_PNG.get(0));
|
||||
}
|
||||
} else {
|
||||
this.modifyShulker(shulkerFile, shulkerFile);
|
||||
}
|
||||
}
|
||||
if (ConfigManager.removedCollisionBoxEntityTexture()) {
|
||||
File overlaysFile = generatedPackPath.resolve("1_20_2_ce/assets/minecraft/textures/entity/shulker/shulker.png").toFile();
|
||||
overlaysFile.getParentFile().mkdirs();
|
||||
File shulkerFile = generatedPackPath.resolve("assets/minecraft/textures/entity/shulker/shulker.png").toFile();
|
||||
File packMetaFile = generatedPackPath.resolve("pack.mcmeta").toFile();
|
||||
boolean modifyPackMetaFile = false;
|
||||
if (!shulkerFile.exists() && packMetaFile.exists()) {
|
||||
try (OutputStream out = new FileOutputStream(overlaysFile)) {
|
||||
out.write(SHULKER_PNG.get(0));
|
||||
}
|
||||
modifyPackMetaFile = true;
|
||||
} else if (packMetaFile.exists()) {
|
||||
this.modifyShulker(shulkerFile, overlaysFile);
|
||||
modifyPackMetaFile = true;
|
||||
}
|
||||
if (modifyPackMetaFile) {
|
||||
JsonObject packMcmeta = GsonHelper.readJsonFile(packMetaFile.toPath()).getAsJsonObject();
|
||||
JsonArray entries = packMcmeta.getAsJsonObject("overlays").getAsJsonArray("entries");
|
||||
JsonObject entrie = new JsonObject();
|
||||
JsonObject formats = new JsonObject();
|
||||
formats.addProperty("min_inclusive", 16);
|
||||
formats.addProperty("max_inclusive", 34);
|
||||
entrie.add("formats", formats);
|
||||
entrie.addProperty("directory", "1_20_2_ce");
|
||||
entries.add(entrie);
|
||||
GsonHelper.writeJsonFile(packMcmeta, packMetaFile.toPath());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
this.plugin.logger().warn("Error creating shulker.png", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void modifyShulker(File shulkerFile, File saveFile) throws IOException {
|
||||
BufferedImage originalImage = ImageIO.read(shulkerFile);
|
||||
BufferedImage argbImage;
|
||||
if (originalImage.getType() == BufferedImage.TYPE_INT_ARGB) {
|
||||
argbImage = originalImage;
|
||||
} else {
|
||||
argbImage = new BufferedImage(
|
||||
originalImage.getWidth(),
|
||||
originalImage.getHeight(),
|
||||
BufferedImage.TYPE_INT_ARGB
|
||||
);
|
||||
Graphics2D g = argbImage.createGraphics();
|
||||
g.drawImage(originalImage, 0, 0, null);
|
||||
g.dispose();
|
||||
}
|
||||
int startX = 0;
|
||||
int startY = argbImage.getHeight() - 12;
|
||||
int width = 24;
|
||||
int heightRegion = 12;
|
||||
for (int y = startY; y < startY + heightRegion; y++) {
|
||||
for (int x = startX; x < startX + width; x++) {
|
||||
int pixel = argbImage.getRGB(x, y);
|
||||
int transparentPixel = pixel & 0x00FFFFFF;
|
||||
argbImage.setRGB(x, y, transparentPixel);
|
||||
}
|
||||
}
|
||||
ImageIO.write(argbImage, "PNG", saveFile);
|
||||
}
|
||||
|
||||
private void generateEquipments(Path generatedPackPath) {
|
||||
for (EquipmentGeneration generator : this.plugin.itemManager().equipmentsToGenerate()) {
|
||||
EquipmentData equipmentData = generator.modernData();
|
||||
|
||||
@@ -104,8 +104,6 @@ public class ConfigManager implements Reloadable {
|
||||
protected boolean furniture$remove_invalid_furniture_on_chunk_load$enable;
|
||||
protected Set<String> furniture$remove_invalid_furniture_on_chunk_load$list;
|
||||
protected boolean furniture$hide_base_entity;
|
||||
protected boolean furniture$removed_collision_box_entity_texture_1_20_2;
|
||||
protected boolean furniture$removed_collision_box_entity_texture_1_20;
|
||||
|
||||
protected boolean block$sound_system$enable;
|
||||
protected boolean recipe$enable;
|
||||
@@ -262,8 +260,6 @@ public class ConfigManager implements Reloadable {
|
||||
furniture$remove_invalid_furniture_on_chunk_load$enable = config.getBoolean("furniture.remove-invalid-furniture-on-chunk-load.enable", false);
|
||||
furniture$remove_invalid_furniture_on_chunk_load$list = new HashSet<>(config.getStringList("furniture.remove-invalid-furniture-on-chunk-load.list"));
|
||||
furniture$hide_base_entity = config.getBoolean("furniture.hide-base-entity", true);
|
||||
furniture$removed_collision_box_entity_texture_1_20_2 = config.getBoolean("furniture.removed-collision-box-entity-texture-1_20_2", true);
|
||||
furniture$removed_collision_box_entity_texture_1_20 = config.getBoolean("furniture.removed-collision-box-entity-texture-1_20", false);
|
||||
|
||||
// block
|
||||
block$sound_system$enable = config.getBoolean("block.sound-system.enable", true);
|
||||
@@ -557,14 +553,6 @@ public class ConfigManager implements Reloadable {
|
||||
return instance().furniture$hide_base_entity;
|
||||
}
|
||||
|
||||
public static boolean removedCollisionBoxEntityTexture() {
|
||||
return instance().furniture$removed_collision_box_entity_texture_1_20_2;
|
||||
}
|
||||
|
||||
public static boolean removedCollisionBoxEntityTextureLegacy() {
|
||||
return instance().furniture$removed_collision_box_entity_texture_1_20;
|
||||
}
|
||||
|
||||
public YamlDocument loadOrCreateYamlData(String fileName) {
|
||||
File file = new File(this.plugin.dataFolderFile(), fileName);
|
||||
if (!file.exists()) {
|
||||
|
||||
Reference in New Issue
Block a user