Skip to content

Commit

Permalink
0.0.8 (#18)
Browse files Browse the repository at this point in the history
- Fixed flint-path library loading
- Fixed a bug when the project did not reload during the build
  • Loading branch information
Nelonn authored Apr 5, 2023
1 parent 2380fe4 commit cad17e0
Show file tree
Hide file tree
Showing 21 changed files with 156 additions and 76 deletions.
49 changes: 27 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
Modern solution for minecraft resource pack development

## Features
- [Resource pack obfuscation](#obfuscation)
- [Auto CustomModelData Mapping](#autocmd)
- [Auto fancyPants custom armor](#customarmor)
- And much more...
- [Models generating](#meshes--models)
- [Auto CustomModelData](#auto-custommodeldata)
- [Auto sounds FFmpeg conversion](#sounds)
- [Auto fancyPants (custom armor)](#armor-textures)
- [Obfuscation](#obfuscation)

## Example Project
Look at the [example project](https://github.com/Nelonn/ProPack/blob/master/propack-core/src/main/resources/example)
Expand All @@ -20,10 +21,11 @@ Json is used in lenient mode, possible file extensions:
Some futures from json 5 will not work due to [GSON](https://github.com/google/gson) flaws

## Meshes & Models
[Java Block/Item models](https://minecraft.fandom.com/wiki/Model) in the ProPack are called meshes.
Their files should end with `.mesh.json`
[Java Block/Item models](https://minecraft.fandom.com/wiki/Model) in the ProPack are called *meshes*.
Their files should end with `.mesh.json`.

Models configuration file name should end with `.model.json`.

Models file name should end with `.model.json`.
Currently implemented model types:

<br>
Expand Down Expand Up @@ -85,9 +87,9 @@ SlotItemModel, example:
}
```

`Target` - this is an indication of the items for which you need to `Auto CustomModelData Mapping` of the specified model
`Target` - this is an indication of the items for which you need to [Auto CustomModelData](#auto-custommodeldata) of the specified model.

## <a name="autocmd"></a> Auto CustomModelData Mapping
## Auto CustomModelData
When building resource pack ProPack takes the default model from the folder `include/assets/minecraft/models/item/<item>.json`
and adds the necessary elements to override.

Expand All @@ -106,18 +108,17 @@ Example NBT tag for SlotItemModel: `{CustomModel:"example:models/example_slotmod

## Sounds

Sound files must ends with `.sound.json`
- Example: `scream.sound.json`
Sound files must ends with `.sound.json`, eg. `scream.sound.json`

Sound file paths can be relative, example `../folder/sound`.

FFmpeg auto conversion is supported. Use `-Dpropack.ffmpeg=path` to indicate its location,
by default it `ffmpeg`

## <a name="armortextures"></a> Armor Textures
## Armor Textures
Added an automatic builder of custom textures for leather armor for the [shader `fancyPants`](https://github.com/Ancientkingg/fancyPants)

Armor file must ends with `.armor.json`
Armor file must ends with `.armor.json`, eg. `emerald.armor.json`

[Example file]():
```json
Expand Down Expand Up @@ -146,32 +147,36 @@ The second animated version:
}
}
```
`.png` is not required to be specified
`.png` is not required to be specified.

For more information, see [README.md of fancyPants](https://github.com/Ancientkingg/fancyPants/blob/master/README.md)

`SaveImage` allows you to determine whether to save
the specified `Image` in the output resource pack

## Languages
Language file must ends with `.lang.json`
- Example: `en_us.lang.json`
Language file must ends with `.lang.json`, eg. `en_us.lang.json`.

Path in content doesn't matter.

There is also a placeholder `<namespace>`.
Multiple languages in the same namespace will be merged into one.

There is also a placeholder `<namespace>`.

## Fonts
Fonts work unchanged except for the file extension `.font.json`

## <a name="obfuscation"></a> Obfuscation
## Obfuscation
It just obfuscates the entire resource pack, except for translations.
The settings for this function are in [`config/build.json5`](https://github.com/Nelonn/ProPack/blob/master/propack-core/src/main/resources/example/config/build.json5)

## Planned in the future
- [ ] Rewrite builder to C++ or Golang as binary executable.
- [ ] Integration into [ItemsAdder](https://www.spigotmc.org/resources/%E2%9C%A8itemsadder%E2%AD%90emotes-mobs-items-armors-hud-gui-emojis-blocks-wings-hats-liquids.73355/), [Oraxen](https://www.spigotmc.org/resources/%E2%98%84%EF%B8%8F-oraxen-add-items-blocks-armors-hats-food-furnitures-plants-and-gui.72448/), [Model Engine](https://www.spigotmc.org/resources/conxeptworks-model-engine—ultimate-custom-entity-model-manager-1-16-5-1-19-3.79477/), etc.
- [ ] Fonts generating
- [ ] CI/CD using [Redis](https://redis.io/), etc.
- [ ] Improve the quality of the code and API
- [ ] Mod for [Fabric](https://fabricmc.net/)
- [ ] Fonts generating.
- [ ] Resource pack CI/CD using [Redis](https://redis.io/), etc. (for multi server)
- [ ] Improve the quality of the code and API.
- [ ] Mod for [Fabric](https://fabricmc.net/).

## License
*Click here to read [the entire license](https://github.com/Nelonn/ProPack/blob/master/LICENSE.txt).*
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=me.nelonn.propack
version=0.0.7
version=0.0.8

org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
Binary file not shown.
2 changes: 1 addition & 1 deletion propack-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repositories {
}

dependencies {
"compileOnly"(files("../libs/flint-path-0.0.1.jar"))
"compileOnly"(files("../libs/lib-flint-path-0.0.1.jar"))
"compileOnly"("net.kyori:adventure-api:4.12.0")
"compileOnly"("org.jetbrains:annotations:23.1.0")
}
Expand Down
2 changes: 1 addition & 1 deletion propack-bukkit/adapters/adapter-1.17.1/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
dependencies {
// https://papermc.io/repo/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
paperDevBundle("1.17.1-R0.1-20220414.034903-210")
"compileOnly"(files("../../../libs/flint-path-0.0.1.jar"))
"compileOnly"(files("../../../libs/lib-flint-path-0.0.1.jar"))
"compileOnly"(project(":propack-api"))
"compileOnly"(project(":propack-core"))
"compileOnly"(project(":propack-bukkit"))
Expand Down
2 changes: 1 addition & 1 deletion propack-bukkit/adapters/adapter-1.18.2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
dependencies {
// https://papermc.io/repo/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
paperDevBundle("1.18.2-R0.1-20220304.102823-4")
"compileOnly"(files("../../../libs/flint-path-0.0.1.jar"))
"compileOnly"(files("../../../libs/lib-flint-path-0.0.1.jar"))
"compileOnly"(project(":propack-api"))
"compileOnly"(project(":propack-core"))
"compileOnly"(project(":propack-bukkit"))
Expand Down
2 changes: 1 addition & 1 deletion propack-bukkit/adapters/adapter-1.19.3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
dependencies {
// https://papermc.io/repo/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
paperDevBundle("1.19.3-R0.1-20221226.180038-55")
"compileOnly"(files("../../../libs/flint-path-0.0.1.jar"))
"compileOnly"(files("../../../libs/lib-flint-path-0.0.1.jar"))
"compileOnly"(project(":propack-api"))
"compileOnly"(project(":propack-core"))
"compileOnly"(project(":propack-bukkit"))
Expand Down
2 changes: 1 addition & 1 deletion propack-bukkit/adapters/adapter-1.19.4/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
dependencies {
// https://papermc.io/repo/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
paperDevBundle("1.19.4-R0.1-20230315.180636-1")
"compileOnly"(files("../../../libs/flint-path-0.0.1.jar"))
"compileOnly"(files("../../../libs/lib-flint-path-0.0.1.jar"))
"compileOnly"(project(":propack-api"))
"compileOnly"(project(":propack-core"))
"compileOnly"(project(":propack-bukkit"))
Expand Down
2 changes: 1 addition & 1 deletion propack-bukkit/adapters/adapter-1.19/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
dependencies {
// https://papermc.io/repo/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/
paperDevBundle("1.19-R0.1-20220609.175204-1")
"compileOnly"(files("../../../libs/flint-path-0.0.1.jar"))
"compileOnly"(files("../../../libs/lib-flint-path-0.0.1.jar"))
"compileOnly"(project(":propack-api"))
"compileOnly"(project(":propack-core"))
"compileOnly"(project(":propack-bukkit"))
Expand Down
2 changes: 1 addition & 1 deletion propack-bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
"implementation"(project(":propack-core")) {
exclude(group = "net.kyori")
}
"compileOnly"(files("../libs/flint-path-0.0.1.jar"))
"compileOnly"(files("../libs/lib-flint-path-0.0.1.jar"))

/*"compileOnly"("org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT") {
exclude("junit", "junit")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

public final class ProPackPlugin extends JavaPlugin {
private static final Logger LOGGER = LogManagerCompat.getLogger();
private static final SharedLoader.Library library = new SharedLoader.Library("flint-path-0.0.1.jar", "me.nelonn.flint.path.Path");
private static final SharedLoader.Library library = new SharedLoader.Library("lib-flint-path-0.0.1.jar", "me.nelonn.flint.path.Path");

public static ProPackPlugin getInstance() {
return (ProPackPlugin) Bukkit.getPluginManager().getPlugin("ProPack");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;

public final class SharedLoader {
Expand Down Expand Up @@ -56,8 +54,8 @@ public void loadIfNotExists(@NotNull Library library) {
in.transferTo(out);
}
}
URLClassLoader loader = new URLClassLoader(new URL[]{file.toURI().toURL()}, Bukkit.class.getClassLoader());
Class.forName(library.getCheckClass(), true, loader);
Bukkit.getPluginManager().loadPlugin(file);
Class.forName(library.getCheckClass());
} catch (Exception e) {
throw new RuntimeException("Unable to load shared library '" + library.getFileName() + "'", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import me.nelonn.propack.bukkit.Util;
import me.nelonn.propack.bukkit.definition.PackDefinition;
import me.nelonn.propack.bukkit.definition.ProjectDefinition;
import me.nelonn.propack.core.builder.InternalProject;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -56,9 +55,8 @@ protected void onCommand(@NotNull CommandSender sender, @NotNull String s, @NotN
}
new Thread(() -> {
try {
InternalProject internalProject = (InternalProject) projectDefinition.getProject();
internalProject.build();
ResourcePack resourcePack = internalProject.getResourcePack().orElseThrow();
projectDefinition.build();
ResourcePack resourcePack = projectDefinition.getResourcePack().orElseThrow();
if (resourcePack.isUploaded()) {
for (Player player : Bukkit.getOnlinePlayers()) {
Optional<ResourcePack> playerPack = ProPack.getCore().getDispatcher().getAppliedResourcePack(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ public HelpCommand(@NotNull ProPackPlugin plugin) {
protected void onCommand(@NotNull CommandSender sender, @NotNull String command, @NotNull String[] args) {
Util.send(sender, "<white>" + plugin.getDescription().getName() + " <gray>v" + plugin.getDescription().getVersion());
Util.send(sender, "<gray>/propack build <project>");
Util.send(sender, "<gray>/propack reload [config|modules|packs]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.google.gson.JsonObject;
import me.nelonn.propack.core.ProPackCore;
import me.nelonn.propack.core.builder.InternalProject;
import me.nelonn.propack.core.loader.ProjectLoader;
import me.nelonn.propack.core.util.GsonHelper;
import me.nelonn.propack.core.util.LogManagerCompat;
Expand Down Expand Up @@ -65,12 +64,8 @@ public void loadAll() {
if (type.equalsIgnoreCase("Project")) {
boolean buildAtStartup = GsonHelper.getBoolean(jsonObject, "BuildAtStartup", false);
File projectFile = new File(directory, name + File.separatorChar + "project.json5");
InternalProject internalProject = projectLoader.load(projectFile, !buildAtStartup);
if (buildAtStartup || internalProject.getResourcePack().isEmpty()) {
internalProject.build(); // TODO: improve
}
ProjectDefinition resourcePackDefinition = new ProjectDefinition(internalProject);
definitions.put(name, resourcePackDefinition);
ProjectDefinition projectDefinition = new ProjectDefinition(projectFile, projectLoader, !buildAtStartup);
definitions.put(name, projectDefinition);
} else if (type.equalsIgnoreCase("File")) {
throw new UnsupportedOperationException("Resource pack definition type 'File' currently not supported");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,26 @@
package me.nelonn.propack.bukkit.definition;

import me.nelonn.propack.ResourcePack;
import me.nelonn.propack.builder.Project;
import me.nelonn.propack.core.builder.InternalProject;
import me.nelonn.propack.core.loader.ProjectLoader;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.Optional;

public class ProjectDefinition implements PackDefinition {
private final Project project;
private final File file;
private InternalProject project;
private ProjectLoader projectLoader;

public ProjectDefinition(@NotNull Project project) {
this.project = project;
public ProjectDefinition(@NotNull File file, @NotNull ProjectLoader projectLoader, boolean tryLoadBuilt) {
this.file = file;
this.projectLoader = projectLoader;
if (tryLoadBuilt) {
loadOrBuild();
} else {
build();
}
}

@Override
Expand All @@ -41,7 +51,35 @@ public ProjectDefinition(@NotNull Project project) {
return project.getResourcePack();
}

public @NotNull Project getProject() {
public @NotNull File getFile() {
return file;
}

public @NotNull InternalProject getProject() {
return project;
}

public @NotNull ProjectLoader getProjectLoader() {
return projectLoader;
}

public void setProjectLoader(@NotNull ProjectLoader projectLoader) {
this.projectLoader = projectLoader;
}

public void loadOrBuild() {
project = projectLoader.load(file, true);
if (project.getResourcePack().isEmpty()) {
build0();
}
}

public void build() {
project = projectLoader.load(file, false);
build0();
}

private void build0() {
project.build(); // TODO: improve
}
}
Binary file not shown.
2 changes: 1 addition & 1 deletion propack-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
dependencies {
"implementation"(project(":propack-api"))
"implementation"(project(":propack-core"))
"implementation"(files("../libs/flint-path-0.0.1.jar"))
"implementation"(files("../libs/lib-flint-path-0.0.1.jar"))

"implementation"("org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r")

Expand Down
2 changes: 1 addition & 1 deletion propack-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {

dependencies {
"implementation"(project(":propack-api"))
"compileOnly"(files("../libs/flint-path-0.0.1.jar"))
"compileOnly"(files("../libs/lib-flint-path-0.0.1.jar"))

"compileOnly"("org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public List<TextLoader> getTextLoaders() {
return textLoaders;
}

public @NotNull InternalProject load(@NotNull File projectFile, boolean loadBuilt) {
public @NotNull InternalProject load(@NotNull File projectFile, boolean tryLoadBuilt) {
String name;
VirtualFile packMeta;
VirtualFile packIcon;
Expand Down Expand Up @@ -287,7 +287,7 @@ public List<TextLoader> getTextLoaders() {

ResourcePack resourcePack = null;
File builtResourcePack = new File(projectFile.getParentFile(), "build/" + name + ".propack");
if (builtResourcePack.exists() && loadBuilt) {
if (builtResourcePack.exists() && tryLoadBuilt) {
try {
ResourcePackLoader resourcePackLoader = new ResourcePackLoader();
resourcePack = resourcePackLoader.load(builtResourcePack);
Expand Down
Loading

0 comments on commit cad17e0

Please sign in to comment.