added textures & models for the altar interface

(also changed the order of the material and lapis lazuli slots)
This commit is contained in:
XTerPL 2025-01-26 20:18:22 +01:00
parent 1c4969a9f1
commit 4f842d7b1a
8 changed files with 129 additions and 5 deletions

View file

@ -75,7 +75,7 @@ public class AltarInterface extends UserInterface {
public void preload() {
StaticUserInterfaceSlot tool = new StaticUserInterfaceSlot(BlazingGames.get().key("tool_slot"));
StaticUserInterfaceSlot randomMaterial = new StaticUserInterfaceSlot(BlazingGames.get().key("material_slot"));
StaticUserInterfaceSlot lapisLazuli = new StaticUserInterfaceSlot(BlazingGames.get().key("lazuli_slot"));
StaticUserInterfaceSlot lapisLazuli = new StaticUserInterfaceSlot(BlazingGames.get().key("lapis_lazuli_slot"));
int index = 0;
for(int y = 0; y < 5; y++) {
@ -90,12 +90,12 @@ public class AltarInterface extends UserInterface {
}
addSlot(0, 1, tool);
addSlot(0, 2, randomMaterial);
addSlot(0, 3, lapisLazuli);
addSlot(0, 2, lapisLazuli);
addSlot(0, 3, randomMaterial);
addSlot(1, 1, toolSlot);
addSlot(1, 2, materialSlot);
addSlot(1, 3, lapisSlot);
addSlot(1, 2, lapisSlot);
addSlot(1, 3, materialSlot);
}
@Override

View file

@ -19,6 +19,7 @@ import de.blazemcworld.blazinggames.packs.hooks.*;
public enum HookList {
CUSTOM_ITEMS(new CustomItemsHook()),
GUI_ELEMENTS(new GuiElementsHook()),
;

View file

@ -0,0 +1,102 @@
/*
* Copyright 2025 The Blazing Games Maintainers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.blazemcworld.blazinggames.packs.hooks;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.blazemcworld.blazinggames.BlazingGames;
import de.blazemcworld.blazinggames.packs.HookContext;
import de.blazemcworld.blazinggames.packs.PackBuildHook;
import org.bukkit.NamespacedKey;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.logging.Logger;
public class GuiElementsHook implements PackBuildHook {
private static List<NamespacedKey> getGuiTextures() {
BlazingGames bg = BlazingGames.get();
return List.of(
bg.key("blank")
);
}
private static List<NamespacedKey> getGuiModels() {
BlazingGames bg = BlazingGames.get();
return List.of(
bg.key("blank"),
bg.key("tool_slot"),
bg.key("material_slot"),
bg.key("lapis_lazuli_slot")
);
}
private static List<NamespacedKey> getGuiDefinitions() {
BlazingGames bg = BlazingGames.get();
return List.of(
bg.key("tool_slot"),
bg.key("material_slot"),
bg.key("lapis_lazuli_slot")
);
}
@Override
public void runHook(Logger logger, HookContext context) {
for (NamespacedKey texture : getGuiTextures()) {
// install texture
try (InputStream stream = BlazingGames.class.getResourceAsStream("/gui/" + texture.getKey() + ".png")) {
if (stream != null) context.installTexture(texture, "item", stream.readAllBytes());
} catch (IOException e) {
BlazingGames.get().log(e);
}
}
for (NamespacedKey model : getGuiModels()) {
// install model
try (InputStream stream = BlazingGames.class.getResourceAsStream("/gui/" + model.getKey() + ".json")) {
if (stream != null) context.installModel(model, stream.readAllBytes());
} catch (IOException e) {
BlazingGames.get().log(e);
}
}
NamespacedKey blankKey = BlazingGames.get().key("blank");
JsonObject blankRoot = new JsonObject();
JsonObject blankModel = new JsonObject();
blankModel.addProperty("type", "minecraft:model");
blankModel.addProperty("model", blankKey.toString());
blankRoot.add("model", blankModel);
context.writeFile("/assets/" + blankKey.getNamespace() + "/items/" + blankKey.getKey() + ".json", blankRoot);
for(NamespacedKey itemDefinition : getGuiDefinitions()) {
// create items data
JsonObject root = new JsonObject();
JsonObject composite = new JsonObject();
JsonArray models = new JsonArray();
models.add(blankModel);
JsonObject model = new JsonObject();
model.addProperty("type", "minecraft:model");
model.addProperty("model", itemDefinition.toString());
models.add(model);
composite.addProperty("type", "minecraft:composite");
composite.add("models", models);
root.add("model", composite);
context.writeFile("/assets/" + itemDefinition.getNamespace() + "/items/" + itemDefinition.getKey() + ".json", root);
}
}
}

View file

@ -0,0 +1,12 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "blazinggames:item/blank"
},
"display": {
"gui": {
"translation": [0,0,-80],
"scale": [1.125,1.125,1]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B

View file

@ -0,0 +1,3 @@
{
"parent": "minecraft:item/lapis_lazuli"
}

View file

@ -0,0 +1,3 @@
{
"parent": "minecraft:item/copper_ingot"
}

View file

@ -0,0 +1,3 @@
{
"parent": "minecraft:item/diamond_pickaxe"
}