mirror of
https://github.com/BlazingGames/blazing-games-plugin.git
synced 2025-02-03 21:26:41 -05:00
added textures & models for the altar interface
(also changed the order of the material and lapis lazuli slots)
This commit is contained in:
parent
1c4969a9f1
commit
4f842d7b1a
8 changed files with 129 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -19,6 +19,7 @@ import de.blazemcworld.blazinggames.packs.hooks.*;
|
|||
|
||||
public enum HookList {
|
||||
CUSTOM_ITEMS(new CustomItemsHook()),
|
||||
GUI_ELEMENTS(new GuiElementsHook()),
|
||||
|
||||
;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
12
src/main/resources/gui/blank.json
Normal file
12
src/main/resources/gui/blank.json
Normal 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]
|
||||
}
|
||||
}
|
||||
}
|
BIN
src/main/resources/gui/blank.png
Normal file
BIN
src/main/resources/gui/blank.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 564 B |
3
src/main/resources/gui/lapis_lazuli_slot.json
Normal file
3
src/main/resources/gui/lapis_lazuli_slot.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minecraft:item/lapis_lazuli"
|
||||
}
|
3
src/main/resources/gui/material_slot.json
Normal file
3
src/main/resources/gui/material_slot.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minecraft:item/copper_ingot"
|
||||
}
|
3
src/main/resources/gui/tool_slot.json
Normal file
3
src/main/resources/gui/tool_slot.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "minecraft:item/diamond_pickaxe"
|
||||
}
|
Loading…
Reference in a new issue