[finish-factions-and-banking] A few QOL commands. Block entity with working model & textures and screen handler. UPDATED MOD TO 1.20.2 IN THIS
Some checks are pending
build / build (21) (push) Waiting to run

This commit is contained in:
Jkibbels 2024-12-21 02:07:14 -05:00
parent c9473c59a1
commit b6b73d96e8
35 changed files with 1233 additions and 579 deletions

2
.gitignore vendored
View File

@ -5,6 +5,8 @@ build/
out/
classes/
remappedSrc/
# eclipse
*.launch

View File

@ -32,13 +32,13 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "My Project"
PROJECT_NAME = "Keeblarcraft"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER =
PROJECT_NUMBER = 1.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a

View File

@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'maven-publish'
}
@ -51,9 +51,9 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
//modCompileOnly "cc.tweaked:cc-tweaked-1.20-fabric-api:1.105.0"
//modRuntimeOnly "cc.tweaked:cc-tweaked-1.20-fabric-api:1.105.0"
modImplementation 'net.kyrptonaught:customportalapi:0.0.1-beta65-1.20'
include 'net.kyrptonaught:customportalapi:0.0.1-beta65-1.20'
modImplementation 'com.github.glitchfiend:TerraBlender-fabric:1.20.1-3.0.1.7'
modImplementation 'net.kyrptonaught:customportalapi:0.0.1-beta64.5-1.20.2'
include 'net.kyrptonaught:customportalapi:0.0.1-beta64.5-1.20.2'
modImplementation 'com.github.glitchfiend:TerraBlender-fabric:1.20.2-3.2.0.14'
}
processResources {
@ -72,10 +72,10 @@ java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withSourcesJar()
}
jar {

View File

@ -1,17 +1,17 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.15.11
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.16.9
# Mod Properties
mod_version=0.0.1
mod_version=1.0.0
maven_group=jesse.keeblarcraft
archives_base_name=keeblarcraft
# Dependencies
fabric_version=0.83.0+1.20
fabric_version=0.91.6+1.20.2

Binary file not shown.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

5
gradlew vendored
View File

@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

2
gradlew.bat vendored
View File

@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################

View File

@ -1,18 +1,20 @@
#!/bin/bash
BASH_PATH=$(which bash)
#!BASH_PATH
#########
# GLOBALS
#########
SCRIPT_NAME=$0
PRINT_NAME=${SCRIPT_NAME:2}
REPO_TOP=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
SCRIPT_NAME=$(basename $0)
SERVER_MODE=0 # 1=true, 0=false
CLIENT_MODE=0 # 1=true, 0=false
LOG_LEVEL=1
BUILD_PATH="build"
RUN_PATH="run"
RESET_ALL=0
GRADLEW_PATH="gradlew"
GRADLEW_PATH=${REPO_TOP}/gradlew
# $1 is text level
# LEVELS:
@ -22,14 +24,14 @@ GRADLEW_PATH="gradlew"
function TermWrite() {
textLevel=$1
text="${2}"
prefix="[\033[34m"${PRINT_NAME}"\033[0m]: "
prefix="[\033[34m"${SCRIPT_NAME}"\033[0m]: "
if [[ "${textLevel}" == "2" ]]; then
prefix="[\033[33m"${PRINT_NAME}"\033[0m]:"
prefix="[\033[33m"${SCRIPT_NAME}"\033[0m]:"
fi
if [[ "${textLevel}" == "3" ]]; then
prefix="[\033[31m"${PRINT_NAME}"\033[0m]:"
prefix="[\033[31m"${SCRIPT_NAME}"\033[0m]:"
fi
if [[ ${LOG_LEVEL} -ge ${textLevel} ]]; then

View File

@ -1,8 +1,8 @@
package jesse.keeblarcraft;
import jesse.keeblarcraft.gui.ClientHandlers;
import jesse.keeblarcraft.gui.ScreenManager;
import jesse.keeblarcraft.gui.widgets.TreeWidget;
// import jesse.keeblarcraft.gui.ScreenManager;
// import jesse.keeblarcraft.gui.widgets.TreeWidget;
import jesse.keeblarcraft.Shortcuts.ShortcutManager;
import net.fabricmc.api.ClientModInitializer;
@ -14,8 +14,8 @@ public class KeeblarcraftClient implements ClientModInitializer {
ShortcutManager.RegisterKeybinds();
ClientHandlers.RegisterHandlers();
ScreenManager.GetInstance();
ScreenManager.AddWidget(TreeWidget.class, 10);
// ScreenManager.GetInstance();
// ScreenManager.AddWidget(TreeWidget.class, 10);
}
}

View File

@ -12,7 +12,7 @@ package jesse.keeblarcraft.Shortcuts;
import org.lwjgl.glfw.GLFW;
// import jesse.keeblarcraft.Keeblarcraft;
import jesse.keeblarcraft.gui.ScreenManager;
// import jesse.keeblarcraft.gui.ScreenManager;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
@ -83,10 +83,10 @@ public class ShortcutManager {
// treeGui = new ScreenManager(Keeblarcraft.TREE_HANDLER.create(0, client.player.getInventory()), client.player.getInventory(), Text.of("Test"));
// treeGui.AddParent(currentScreen); ///TODO: Put this in the constructor when you figure out how the hell the magic is happening with registration
ScreenManager treeGui = ScreenManager.GetInstance();
treeGui.AddParent(currentScreen);
// ScreenManager treeGui = ScreenManager.GetInstance();
// treeGui.AddParent(currentScreen);
MinecraftClient.getInstance().setScreen(treeGui);
// MinecraftClient.getInstance().setScreen(treeGui);
// toggleTreeGui intentionally never bit-flipped to false as a slight implementation bug exists such that pressing the keybind again
// does NOT call this callback function until the previous screen is CLOSED (which is why this isn't resource leaking...). This will

View File

@ -1,11 +1,13 @@
package jesse.keeblarcraft.gui;
import jesse.keeblarcraft.Keeblarcraft;
import jesse.keeblarcraft.GuiMgr.ScreenHandlerRegistration;
import net.minecraft.client.gui.screen.ingame.HandledScreens;
public class ClientHandlers {
public static void RegisterHandlers() {
System.out.println("Registering tree handler screen");
HandledScreens.register(Keeblarcraft.TREE_HANDLER, ScreenManager::new);
// HandledScreens.register(Keeblarcraft.TREE_HANDLER, ScreenManager::new);
HandledScreens.register(ScreenHandlerRegistration.FACTION_BLOCK_SCREEN_HANDLER, FactionBlockScreen::new);
}
}

View File

@ -0,0 +1,46 @@
package jesse.keeblarcraft.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import jesse.keeblarcraft.Keeblarcraft;
import jesse.keeblarcraft.GuiMgr.FactionBlockScreenHandler;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
public class FactionBlockScreen extends HandledScreen<FactionBlockScreenHandler> {
private static final Identifier TEXTURE = new Identifier(Keeblarcraft.MOD_ID, "textures/gui/attribute_flight.png");
public FactionBlockScreen(FactionBlockScreenHandler handler, PlayerInventory inventory, Text title) {
super(handler, inventory, title);
}
@Override
protected void init() {
super.init();
titleY = 1000; //begone from screen
playerInventoryTitleY = 1000; //begone from screen
}
@Override
protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.setShaderTexture(0, TEXTURE);
int x = (width - backgroundWidth) / 2;
int y = (height - backgroundHeight) / 2;
context.drawTexture(TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight);
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
drawMouseoverTooltip(context, mouseX, mouseY);
}
}

View File

@ -1,381 +1,381 @@
/*
*
* ScreenManager
*
* This is the screen manager for the global screen handler of `TreeHandler` type
* Please note: `TreeHandler` is suited for a more broad range of things; however
* its initial implementation is for the skill tree. It will be renamed to a more
* generic name so this class is more obviously re-usable after its implementation
* is complete AND we verify this class can be made more generic for it. Since this
* is unknown, it will remain the name it has currently.
*
*
*/
// /*
// *
// * ScreenManager
// *
// * This is the screen manager for the global screen handler of `TreeHandler` type
// * Please note: `TreeHandler` is suited for a more broad range of things; however
// * its initial implementation is for the skill tree. It will be renamed to a more
// * generic name so this class is more obviously re-usable after its implementation
// * is complete AND we verify this class can be made more generic for it. Since this
// * is unknown, it will remain the name it has currently.
// *
// *
// */
package jesse.keeblarcraft.gui;
// package jesse.keeblarcraft.gui;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
// import java.lang.reflect.InvocationTargetException;
// import java.util.ArrayList;
// import java.util.HashMap;
// import java.util.List;
// import java.util.Map.Entry;
import jesse.keeblarcraft.Keeblarcraft;
import jesse.keeblarcraft.GuiMgr.TreeHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
// import jesse.keeblarcraft.Keeblarcraft;
// import jesse.keeblarcraft.GuiMgr.TreeHandler;
// import net.minecraft.client.MinecraftClient;
// import net.minecraft.client.gui.DrawContext;
// import net.minecraft.client.gui.screen.Screen;
// import net.minecraft.client.gui.screen.ingame.HandledScreen;
// import net.minecraft.entity.player.PlayerInventory;
// import net.minecraft.text.Text;
// Client side renderer
public class ScreenManager extends HandledScreen<TreeHandler> {
private static ScreenManager static_inst;
@SuppressWarnings("resource")
private static PlayerInventory static_inventory = new PlayerInventory(null);// = MinecraftClient.getInstance().player.getInventory();
// // Client side renderer
// public class ScreenManager extends HandledScreen<TreeHandler> {
// private static ScreenManager static_inst;
// @SuppressWarnings("resource")
// private static PlayerInventory static_inventory = new PlayerInventory(null);// = MinecraftClient.getInstance().player.getInventory();
public static ScreenManager GetInstance() {
if (static_inst == null) {
static_inst = new ScreenManager(Keeblarcraft.TREE_HANDLER.create(0, static_inventory), static_inventory, Text.of("Test"));
}
return static_inst;
}
// public static ScreenManager GetInstance() {
// if (static_inst == null) {
// static_inst = new ScreenManager(Keeblarcraft.TREE_HANDLER.create(0, static_inventory), static_inventory, Text.of("Test"));
// }
// return static_inst;
// }
private static HashMap<Integer, ArrayList<Class<? extends GenericLayerT>>> layerMap = new HashMap<Integer, ArrayList<Class<? extends GenericLayerT>>>();
private static HashMap<Integer, ArrayList<GenericLayerT>> layers = new HashMap<Integer, ArrayList<GenericLayerT>>(); // key: layer id; value: list of classes to draw
// private static HashMap<Integer, ArrayList<Class<? extends GenericLayerT>>> layerMap = new HashMap<Integer, ArrayList<Class<? extends GenericLayerT>>>();
// private static HashMap<Integer, ArrayList<GenericLayerT>> layers = new HashMap<Integer, ArrayList<GenericLayerT>>(); // key: layer id; value: list of classes to draw
// private TreeWidget treeWidget = null;
private Screen parent;
// // private TreeWidget treeWidget = null;
// private Screen parent;
/////////////////////////////////////////////////////////////////////////////
/// @fn ScreenManager
///
/// @arg[in] handler is the TreeHandler (ScreenHandler) object
///
/// @arg[in] inventory is the players inventory. Required by HandledScreen
/// object however is unused currently in this Screen
///
/// @arg[in] title is the title of the screen window
///
/// @brief Class constructor
/////////////////////////////////////////////////////////////////////////////
public ScreenManager(TreeHandler handler, PlayerInventory inventory, Text title) {
super(handler, inventory, title);
System.out.println("Called constructor of screen manager!");
// /////////////////////////////////////////////////////////////////////////////
// /// @fn ScreenManager
// ///
// /// @arg[in] handler is the TreeHandler (ScreenHandler) object
// ///
// /// @arg[in] inventory is the players inventory. Required by HandledScreen
// /// object however is unused currently in this Screen
// ///
// /// @arg[in] title is the title of the screen window
// ///
// /// @brief Class constructor
// /////////////////////////////////////////////////////////////////////////////
// public ScreenManager(TreeHandler handler, PlayerInventory inventory, Text title) {
// super(handler, inventory, title);
// System.out.println("Called constructor of screen manager!");
// Initialize layers in map
// for (int i = 0; i < NUMBER_DRAW_LAYERS; i++) {
// layers.put(i, new ArrayList<Class<? extends GenericLayerT>>());
// }
}
// // Initialize layers in map
// // for (int i = 0; i < NUMBER_DRAW_LAYERS; i++) {
// // layers.put(i, new ArrayList<Class<? extends GenericLayerT>>());
// // }
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn AddParent
///
/// @arg[in] parent is the parent screen object
///
/// @brief Add a parent screen to the screen object. This is useful if
/// you want to return to the previous screen when this one gets
/// closed by the user
/////////////////////////////////////////////////////////////////////////////
public void AddParent(Screen parent) {
this.parent = parent;
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn AddParent
// ///
// /// @arg[in] parent is the parent screen object
// ///
// /// @brief Add a parent screen to the screen object. This is useful if
// /// you want to return to the previous screen when this one gets
// /// closed by the user
// /////////////////////////////////////////////////////////////////////////////
// public void AddParent(Screen parent) {
// this.parent = parent;
// }
public static void AddWidget(Class<? extends GenericLayerT> widget, int drawLayer) {
if (layerMap.containsKey(drawLayer)) {
// Just append the widget to the draw layer
var layerList = layerMap.get(drawLayer);
layerList.add(widget);
} else {
// Brand new layer!
layerMap.put(drawLayer, new ArrayList<>(List.of(widget)));
}
}
// public static void AddWidget(Class<? extends GenericLayerT> widget, int drawLayer) {
// if (layerMap.containsKey(drawLayer)) {
// // Just append the widget to the draw layer
// var layerList = layerMap.get(drawLayer);
// layerList.add(widget);
// } else {
// // Brand new layer!
// layerMap.put(drawLayer, new ArrayList<>(List.of(widget)));
// }
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn init
///
/// @brief Initialize method; called one-time to setup class variables
/////////////////////////////////////////////////////////////////////////////
@Override
public void init() {
// initialize screen size to the global background picture
this.width = MinecraftClient.getInstance().getWindow().getScaledWidth();
this.height = MinecraftClient.getInstance().getWindow().getScaledHeight();
// /////////////////////////////////////////////////////////////////////////////
// /// @fn init
// ///
// /// @brief Initialize method; called one-time to setup class variables
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public void init() {
// // initialize screen size to the global background picture
// this.width = MinecraftClient.getInstance().getWindow().getScaledWidth();
// this.height = MinecraftClient.getInstance().getWindow().getScaledHeight();
// Let's go through and initialize all the screen types now in our active memory
for (Entry<Integer, ArrayList<Class<? extends GenericLayerT>>> layerEntry : layerMap.entrySet()) {
var layerList = layerEntry.getValue();
// // Let's go through and initialize all the screen types now in our active memory
// for (Entry<Integer, ArrayList<Class<? extends GenericLayerT>>> layerEntry : layerMap.entrySet()) {
// var layerList = layerEntry.getValue();
layers.put(layerEntry.getKey(), new ArrayList<>());
var activeLayerList = layers.get(layerEntry.getKey());
for (int i = 0; i < layerList.size(); i++) {
try {
System.out.println("Attempting to initialize widget with information: LAYER I-VAL W H: " + layerEntry.getKey() + " " + i + " " + this.width + " " + this.height);
GenericLayerT initializedWidget = layerList.get(i).getDeclaredConstructor(int.class, int.class, int.class, int.class, Text.class).newInstance(0, 0, this.width, this.height, Text.of(""));
activeLayerList.add(initializedWidget);
} catch (InstantiationException e) {
System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of IntantiationException");
e.printStackTrace();
} catch (IllegalAccessException e) {
System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of IllegalAccessException");
e.printStackTrace();
} catch (IllegalArgumentException e) {
System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of IllegalArgumentException");
e.printStackTrace();
} catch (InvocationTargetException e) {
System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of InvocationTargetException");
e.printStackTrace();
} catch (NoSuchMethodException e) {
System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of NoSuchMethodException");
e.printStackTrace();
} catch (SecurityException e) {
System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of SecurityException");
e.printStackTrace();
}
}
}
// layers.put(layerEntry.getKey(), new ArrayList<>());
// var activeLayerList = layers.get(layerEntry.getKey());
// for (int i = 0; i < layerList.size(); i++) {
// try {
// System.out.println("Attempting to initialize widget with information: LAYER I-VAL W H: " + layerEntry.getKey() + " " + i + " " + this.width + " " + this.height);
// GenericLayerT initializedWidget = layerList.get(i).getDeclaredConstructor(int.class, int.class, int.class, int.class, Text.class).newInstance(0, 0, this.width, this.height, Text.of(""));
// activeLayerList.add(initializedWidget);
// } catch (InstantiationException e) {
// System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of IntantiationException");
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of IllegalAccessException");
// e.printStackTrace();
// } catch (IllegalArgumentException e) {
// System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of IllegalArgumentException");
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of InvocationTargetException");
// e.printStackTrace();
// } catch (NoSuchMethodException e) {
// System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of NoSuchMethodException");
// e.printStackTrace();
// } catch (SecurityException e) {
// System.out.println("Could not initialize GenericLayerT class (" + layerList.get(i).getClass().toString() + ") because of SecurityException");
// e.printStackTrace();
// }
// }
// }
// Initialize child widgets with correct screen values so they can draw themselves in the right area on the screen (duh!)
// treeWidget = new TreeWidget(GLOBAL_SCREEN_START_X + 24, GLOBAL_SCREEN_START_Y + 24, GLOBAL_SCREEN_WIDTH - 24, GLOBAL_SCREEN_HEIGHT - 24);
// this.addDrawableChild(treeWidget);
}
// // Initialize child widgets with correct screen values so they can draw themselves in the right area on the screen (duh!)
// // treeWidget = new TreeWidget(GLOBAL_SCREEN_START_X + 24, GLOBAL_SCREEN_START_Y + 24, GLOBAL_SCREEN_WIDTH - 24, GLOBAL_SCREEN_HEIGHT - 24);
// // this.addDrawableChild(treeWidget);
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn render
///
/// @arg[in] context is the drawing context of super class
///
/// @arg[in] mouseX is passed to parent class but unused here
///
/// @arg[in] mouseY is passed to parent class but unused here
///
/// @brief Render is called every frame while the screen is open
///
/// @note This is a pure abstract in parent and is required
/////////////////////////////////////////////////////////////////////////////
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta); // This takes care of calling drawBackground which calls DrawMainScreen
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn render
// ///
// /// @arg[in] context is the drawing context of super class
// ///
// /// @arg[in] mouseX is passed to parent class but unused here
// ///
// /// @arg[in] mouseY is passed to parent class but unused here
// ///
// /// @brief Render is called every frame while the screen is open
// ///
// /// @note This is a pure abstract in parent and is required
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// super.render(context, mouseX, mouseY, delta); // This takes care of calling drawBackground which calls DrawMainScreen
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn drawForeground
///
/// @arg[in] context is the drawing context of super class
///
/// @arg[in] mouseX is unused
///
/// @arg[in] mouseY is unused
///
/// @brief Draw foreground exists to draw the titles; however we
/// intentionally override it so the superclass object does not
/// draw the overlay over the background screen
/////////////////////////////////////////////////////////////////////////////
@Override
public void drawForeground(DrawContext context, int mouseX, int mouseY) {
// We override this function to intentionally do nothing
// If in the future we want, we would draw the foreground and TITLES with this!
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn drawForeground
// ///
// /// @arg[in] context is the drawing context of super class
// ///
// /// @arg[in] mouseX is unused
// ///
// /// @arg[in] mouseY is unused
// ///
// /// @brief Draw foreground exists to draw the titles; however we
// /// intentionally override it so the superclass object does not
// /// draw the overlay over the background screen
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public void drawForeground(DrawContext context, int mouseX, int mouseY) {
// // We override this function to intentionally do nothing
// // If in the future we want, we would draw the foreground and TITLES with this!
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn close
///
/// @brief Called when the screen closes
///
/// @note This is a pure abstract in parent and is required
/////////////////////////////////////////////////////////////////////////////
@Override
public void close() {
this.client.setScreen(parent); // return to previous screen or null
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn close
// ///
// /// @brief Called when the screen closes
// ///
// /// @note This is a pure abstract in parent and is required
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public void close() {
// this.client.setScreen(parent); // return to previous screen or null
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn mouseDragged
///
/// @arg[in] mouseX is x-axis position of original mouse click
///
/// @arg[in] mouseY is y-axis position of original mouse click
///
/// @arg[in] button is the int value of button pressed for mouse dragging
///
/// @arg[in] deltaX is the change in the X position from the previous
/// mouse click
///
/// @arg[in] deltaY is the change in the Y position from the previous
/// mouse click
///
/// @brief The drag event is called on all widgets on the screen so
/// long as the initial position of the drag is within the
/// bounds of the widget box itself. Widgets themselves will need
/// to handle any sub-widgets since the bound check is only
/// there to verify if the event happened ANYWHERE within a
/// widget box
/////////////////////////////////////////////////////////////////////////////
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
// UpdateAnchorValues();
// /////////////////////////////////////////////////////////////////////////////
// /// @fn mouseDragged
// ///
// /// @arg[in] mouseX is x-axis position of original mouse click
// ///
// /// @arg[in] mouseY is y-axis position of original mouse click
// ///
// /// @arg[in] button is the int value of button pressed for mouse dragging
// ///
// /// @arg[in] deltaX is the change in the X position from the previous
// /// mouse click
// ///
// /// @arg[in] deltaY is the change in the Y position from the previous
// /// mouse click
// ///
// /// @brief The drag event is called on all widgets on the screen so
// /// long as the initial position of the drag is within the
// /// bounds of the widget box itself. Widgets themselves will need
// /// to handle any sub-widgets since the bound check is only
// /// there to verify if the event happened ANYWHERE within a
// /// widget box
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
// super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
// // UpdateAnchorValues();
for (Entry<Integer, ArrayList<GenericLayerT>> layerEntry : layers.entrySet()) {
var layerList = layerEntry.getValue();
// for (Entry<Integer, ArrayList<GenericLayerT>> layerEntry : layers.entrySet()) {
// var layerList = layerEntry.getValue();
for (var layerListIterator = 0; layerListIterator < layerList.size(); layerListIterator++) {
var layer = layerList.get(layerListIterator);
// for (var layerListIterator = 0; layerListIterator < layerList.size(); layerListIterator++) {
// var layer = layerList.get(layerListIterator);
// Check to make sure scroll is within the context of the widget then deliver information
if (InBounds(layer.startX, layer.startY, layer.endX, layer.endY, (int) mouseX, (int) mouseY)) {
layer.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
}
}
}
return true;
}
// // Check to make sure scroll is within the context of the widget then deliver information
// if (InBounds(layer.startX, layer.startY, layer.endX, layer.endY, (int) mouseX, (int) mouseY)) {
// layer.mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
// }
// }
// }
// return true;
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn mouseScrolled
///
/// @arg[in] mouseX is the initial X position of the cursor on a scroll
///
/// @arg[in] mouseY is the initial Y position of the cursor on a scroll
///
/// @arg[in] amount is a normalized value that indicates scroll direction
///
/// @brief The scroll event is called on all widgets on the screen so
/// long as the initial position of the scroll is within the
/// bounds of the widget box itself. Widgets themselves will need
/// to handle any sub-widgets since the bound check is only
/// there to verify if the event happened ANYWHERE within a
/// widget box
///
/////////////////////////////////////////////////////////////////////////////
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
super.mouseScrolled(mouseX, mouseY, amount);
// /////////////////////////////////////////////////////////////////////////////
// /// @fn mouseScrolled
// ///
// /// @arg[in] mouseX is the initial X position of the cursor on a scroll
// ///
// /// @arg[in] mouseY is the initial Y position of the cursor on a scroll
// ///
// /// @arg[in] amount is a normalized value that indicates scroll direction
// ///
// /// @brief The scroll event is called on all widgets on the screen so
// /// long as the initial position of the scroll is within the
// /// bounds of the widget box itself. Widgets themselves will need
// /// to handle any sub-widgets since the bound check is only
// /// there to verify if the event happened ANYWHERE within a
// /// widget box
// ///
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
// super.mouseScrolled(mouseX, mouseY, amount);
for (Entry<Integer, ArrayList<GenericLayerT>> layerEntry : layers.entrySet()) {
var layerList = layerEntry.getValue();
// for (Entry<Integer, ArrayList<GenericLayerT>> layerEntry : layers.entrySet()) {
// var layerList = layerEntry.getValue();
for (var layerListIterator = 0; layerListIterator < layerList.size(); layerListIterator++) {
var layer = layerList.get(layerListIterator);
// for (var layerListIterator = 0; layerListIterator < layerList.size(); layerListIterator++) {
// var layer = layerList.get(layerListIterator);
// Check to make sure scroll is within the context of the widget then deliver information
if (InBounds(layer.startX, layer.startY, layer.endX, layer.endY, (int) mouseX, (int) mouseY)) {
layer.mouseScrolled(mouseX, mouseY, amount);
}
}
}
return true; // The parent function defines this to be boolean; but I have no idea when I would want to return false from this
}
// // Check to make sure scroll is within the context of the widget then deliver information
// if (InBounds(layer.startX, layer.startY, layer.endX, layer.endY, (int) mouseX, (int) mouseY)) {
// layer.mouseScrolled(mouseX, mouseY, amount);
// }
// }
// }
// return true; // The parent function defines this to be boolean; but I have no idea when I would want to return false from this
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn mouseClicked
///
/// @arg[in] mouseX is the initial X position of the mouse click event
///
/// @arg[in] mouseY is the initial Y position of the mouse click event
///
/// @arg[in] button is the mouse click button (left/right click value)
///
/// @brief The mouse click is called on all widgets on the screen so
/// long as the initial position of the click is within the
/// bounds of the widget box itself. Widgets themselves will need
/// to handle any sub-widgets since the bound check is only
/// there to verify if the event happened ANYWHERE within a
/// widget box
///
/////////////////////////////////////////////////////////////////////////////
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
super.mouseClicked(mouseX, mouseY, button);
// /////////////////////////////////////////////////////////////////////////////
// /// @fn mouseClicked
// ///
// /// @arg[in] mouseX is the initial X position of the mouse click event
// ///
// /// @arg[in] mouseY is the initial Y position of the mouse click event
// ///
// /// @arg[in] button is the mouse click button (left/right click value)
// ///
// /// @brief The mouse click is called on all widgets on the screen so
// /// long as the initial position of the click is within the
// /// bounds of the widget box itself. Widgets themselves will need
// /// to handle any sub-widgets since the bound check is only
// /// there to verify if the event happened ANYWHERE within a
// /// widget box
// ///
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public boolean mouseClicked(double mouseX, double mouseY, int button) {
// super.mouseClicked(mouseX, mouseY, button);
for (Entry<Integer, ArrayList<GenericLayerT>> layerEntry : layers.entrySet()) {
var layerList = layerEntry.getValue();
// for (Entry<Integer, ArrayList<GenericLayerT>> layerEntry : layers.entrySet()) {
// var layerList = layerEntry.getValue();
for (var layerListIterator = 0; layerListIterator < layerList.size(); layerListIterator++) {
var layer = layerList.get(layerListIterator);
// for (var layerListIterator = 0; layerListIterator < layerList.size(); layerListIterator++) {
// var layer = layerList.get(layerListIterator);
// Check to make sure scroll is within the context of the widget then deliver information
if (InBounds(layer.startX, layer.startY, layer.endX, layer.endY, (int) mouseX, (int) mouseY)) {
layer.mouseClicked(mouseX, mouseY, button);
}
}
}
return true;
}
// // Check to make sure scroll is within the context of the widget then deliver information
// if (InBounds(layer.startX, layer.startY, layer.endX, layer.endY, (int) mouseX, (int) mouseY)) {
// layer.mouseClicked(mouseX, mouseY, button);
// }
// }
// }
// return true;
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn DrawLayers
///
/// @arg[in] context is the global drawing context for the screen
///
/// @arg[in] delta is passed in from background draw
///
/// @brief This is the primary drawing function so that all the texture
/// draws can be done in one place in this class. We want as
/// little distance as possible between redraws when possible!
///
/// @note Currently the foreground is not drawn in the custom screen
/// manager. This is because the foreground features the general
/// inventory manager that this screen handler is based on and we
/// do not want to see those text pop ups.
/////////////////////////////////////////////////////////////////////////////
public void DrawLayers(DrawContext context, float delta) {
for (Entry<Integer, ArrayList<GenericLayerT>> layerEntry : layers.entrySet()) {
var layerList = layerEntry.getValue();
// /////////////////////////////////////////////////////////////////////////////
// /// @fn DrawLayers
// ///
// /// @arg[in] context is the global drawing context for the screen
// ///
// /// @arg[in] delta is passed in from background draw
// ///
// /// @brief This is the primary drawing function so that all the texture
// /// draws can be done in one place in this class. We want as
// /// little distance as possible between redraws when possible!
// ///
// /// @note Currently the foreground is not drawn in the custom screen
// /// manager. This is because the foreground features the general
// /// inventory manager that this screen handler is based on and we
// /// do not want to see those text pop ups.
// /////////////////////////////////////////////////////////////////////////////
// public void DrawLayers(DrawContext context, float delta) {
// for (Entry<Integer, ArrayList<GenericLayerT>> layerEntry : layers.entrySet()) {
// var layerList = layerEntry.getValue();
for (var layerListIterator = 0; layerListIterator < layerList.size(); layerListIterator++) {
var layer = layerList.get(layerListIterator);
System.out.println("Drawing layer " + layerEntry.getKey() + " for class type " + layer.getClass().toString());
layer.DrawLayer(context, layerEntry.getKey());
}
}
}
// for (var layerListIterator = 0; layerListIterator < layerList.size(); layerListIterator++) {
// var layer = layerList.get(layerListIterator);
// System.out.println("Drawing layer " + layerEntry.getKey() + " for class type " + layer.getClass().toString());
// layer.DrawLayer(context, layerEntry.getKey());
// }
// }
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn InBounds
///
/// @arg[in] initX is initial position of X axis
///
/// @arg[in] initY is initial position of Y axis
///
/// @arg[in] endX is the end position of X axis
///
/// @arg[in] endY is the end position of Y axis
///
/// @arg[in] x is the current X value we are comparing in the X axis
///
/// @arg[in] y is the current Y value we are comparing in the Y axis
///
/// @brief Checks if an x,y coordinate position falls within the bounds
/// of a bounded box
/////////////////////////////////////////////////////////////////////////////
private boolean InBounds(int initX, int initY, int endX, int endY, int x, int y) {
return (x >= initX && x <= endX) && (y >= initY && y <= endY);
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn InBounds
// ///
// /// @arg[in] initX is initial position of X axis
// ///
// /// @arg[in] initY is initial position of Y axis
// ///
// /// @arg[in] endX is the end position of X axis
// ///
// /// @arg[in] endY is the end position of Y axis
// ///
// /// @arg[in] x is the current X value we are comparing in the X axis
// ///
// /// @arg[in] y is the current Y value we are comparing in the Y axis
// ///
// /// @brief Checks if an x,y coordinate position falls within the bounds
// /// of a bounded box
// /////////////////////////////////////////////////////////////////////////////
// private boolean InBounds(int initX, int initY, int endX, int endY, int x, int y) {
// return (x >= initX && x <= endX) && (y >= initY && y <= endY);
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn drawBackground
///
/// @arg[in] context is the drawing context of super class
///
/// @arg[in] delta is the change in background draw
///
/// @arg[in] mouseX is the mouse x-axis position
///
/// @arg[in] mouseY is the mouse y-axis position
///
/// @brief This function is an abstract parent class and must be
/// implemented. This is "hijacked" and just being used as our
/// main drawing method of all the background images. There isn't
/// a huge difference of drawing our stuff in background vs the
/// foreground - except possibly foreground is drawn first.
/////////////////////////////////////////////////////////////////////////////
@Override
protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) {
DrawLayers(context, delta);
}
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn drawBackground
// ///
// /// @arg[in] context is the drawing context of super class
// ///
// /// @arg[in] delta is the change in background draw
// ///
// /// @arg[in] mouseX is the mouse x-axis position
// ///
// /// @arg[in] mouseY is the mouse y-axis position
// ///
// /// @brief This function is an abstract parent class and must be
// /// implemented. This is "hijacked" and just being used as our
// /// main drawing method of all the background images. There isn't
// /// a huge difference of drawing our stuff in background vs the
// /// foreground - except possibly foreground is drawn first.
// /////////////////////////////////////////////////////////////////////////////
// @Override
// protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) {
// DrawLayers(context, delta);
// }
// }

View File

@ -1,165 +1,165 @@
/*
*
* TreeWidget
*
* Handles the skill tree widget
*
*
*/
// /*
// *
// * TreeWidget
// *
// * Handles the skill tree widget
// *
// *
// */
package jesse.keeblarcraft.gui.widgets;
// package jesse.keeblarcraft.gui.widgets;
import jesse.keeblarcraft.Keeblarcraft;
import jesse.keeblarcraft.Utils.CommonStructures.Position2d;
import jesse.keeblarcraft.gui.GenericLayerT;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
// import jesse.keeblarcraft.Keeblarcraft;
// import jesse.keeblarcraft.Utils.CommonStructures.Position2d;
// import jesse.keeblarcraft.gui.GenericLayerT;
// import net.minecraft.client.gui.DrawContext;
// import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
// import net.minecraft.text.Text;
// import net.minecraft.util.Identifier;
public class TreeWidget extends GenericLayerT {
private static Identifier BACKGROUND_TEXTURE = new Identifier(Keeblarcraft.MOD_ID + ":" + "textures/gui/attribute_tree_background.png");
private static int maxHeight = 320;
private static int maxLength = 640;
private int zoomScale = 1;
// private static Identifier FLIGHT_ATTRIBUTE = new Identifier(Keeblarcraft.MOD_ID + ":" + "textures/gui/attribute_flight.png");
// public class TreeWidget extends GenericLayerT {
// private static Identifier BACKGROUND_TEXTURE = new Identifier(Keeblarcraft.MOD_ID + ":" + "textures/gui/attribute_tree_background.png");
// private static int maxHeight = 320;
// private static int maxLength = 640;
// private int zoomScale = 1;
// // private static Identifier FLIGHT_ATTRIBUTE = new Identifier(Keeblarcraft.MOD_ID + ":" + "textures/gui/attribute_flight.png");
///TODO: Make this THE root node in the attribute tree! Rename in future
// private static Identifier EXAMPLE_NODE = new Identifier(Keeblarcraft.MOD_ID + ":" + "textures/gui/attribute_tree_example_node.png"); ///TODO: Make a way to make this programmatic (Proabably extend AbstractNode to carry this var)
// ///TODO: Make this THE root node in the attribute tree! Rename in future
// // private static Identifier EXAMPLE_NODE = new Identifier(Keeblarcraft.MOD_ID + ":" + "textures/gui/attribute_tree_example_node.png"); ///TODO: Make a way to make this programmatic (Proabably extend AbstractNode to carry this var)
/////////////////////////////////////////////////////////////////////////////
/// @fn TreeWidget
///
/// @brief Class constructor for constructing a tree widget. This will
/// be deprecated in a future version but exists for testing
/////////////////////////////////////////////////////////////////////////////
public TreeWidget() {
this(0, 0, 0, 0, Text.of("Test"));
System.out.println("Calling empty tree constructor");
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn TreeWidget
// ///
// /// @brief Class constructor for constructing a tree widget. This will
// /// be deprecated in a future version but exists for testing
// /////////////////////////////////////////////////////////////////////////////
// public TreeWidget() {
// this(0, 0, 0, 0, Text.of("Test"));
// System.out.println("Calling empty tree constructor");
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn TreeWidget
///
/// @brief Class constructor for constructing a tree widget
/////////////////////////////////////////////////////////////////////////////
public TreeWidget(int x, int y, int width, int height, Text message) {
super(x, y, width, height, message);
// /////////////////////////////////////////////////////////////////////////////
// /// @fn TreeWidget
// ///
// /// @brief Class constructor for constructing a tree widget
// /////////////////////////////////////////////////////////////////////////////
// public TreeWidget(int x, int y, int width, int height, Text message) {
// super(x, y, width, height, message);
this.startX = x;
this.startY = y;
this.endX = x + width;
this.endY = y + height;
}
// this.startX = x;
// this.startY = y;
// this.endX = x + width;
// this.endY = y + height;
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn renderButton
///
/// @param[in] context is the drawing pane
///
/// @param[in] x is the X position to draw at
///
/// @param[in] y is the Y position to draw at
///
/// @param[in] delta is unused in this version
///
/// @brief Primary call to draw the GUI for this widget
/////////////////////////////////////////////////////////////////////////////
@Override
public void renderButton(DrawContext context, int x, int y, float delta) {
context.drawTexture(BACKGROUND_TEXTURE, x, y, 0, 0, maxLength, maxHeight, maxLength, maxHeight);
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn renderButton
// ///
// /// @param[in] context is the drawing pane
// ///
// /// @param[in] x is the X position to draw at
// ///
// /// @param[in] y is the Y position to draw at
// ///
// /// @param[in] delta is unused in this version
// ///
// /// @brief Primary call to draw the GUI for this widget
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public void renderButton(DrawContext context, int x, int y, float delta) {
// context.drawTexture(BACKGROUND_TEXTURE, x, y, 0, 0, maxLength, maxHeight, maxLength, maxHeight);
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn appendClickableNarrations
///
/// @param[in] builder is the narration builder. This is pure virtual in
/// the parent but is unused in this widget currently
///
/// @brief Handles the narrator
/////////////////////////////////////////////////////////////////////////////
@Override
protected void appendClickableNarrations(NarrationMessageBuilder builder) {
return;
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn appendClickableNarrations
// ///
// /// @param[in] builder is the narration builder. This is pure virtual in
// /// the parent but is unused in this widget currently
// ///
// /// @brief Handles the narrator
// /////////////////////////////////////////////////////////////////////////////
// @Override
// protected void appendClickableNarrations(NarrationMessageBuilder builder) {
// return;
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn mouseClicked
///
/// @param[in] mouseX is where on the x-axis the mouse was clicked
///
/// @param[in] mouseY is where on the y-axis the mouse was clicked
///
/// @param[in] button is the button clicked with (think of a mouse...)
///
/// @brief Handler for mouse click events
/////////////////////////////////////////////////////////////////////////////
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
return true;
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn mouseClicked
// ///
// /// @param[in] mouseX is where on the x-axis the mouse was clicked
// ///
// /// @param[in] mouseY is where on the y-axis the mouse was clicked
// ///
// /// @param[in] button is the button clicked with (think of a mouse...)
// ///
// /// @brief Handler for mouse click events
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public boolean mouseClicked(double mouseX, double mouseY, int button) {
// return true;
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn mouseDragged
///
/// @param[in] mouseX is where on the x-axis the mouse was dragged
///
/// @param[in] mouseY is where on the y-axis the mouse was dragged
///
/// @param[in] button is the button dragged with (think of a mouse...)
///
/// @brief Handler for mouse drag events. delta's unused currently
/////////////////////////////////////////////////////////////////////////////
@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
boolean ret = false;
if (this.isValidClickButton(button)) {
// Do camera panning magic stuff here
ret = true;
}
return ret;
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn mouseDragged
// ///
// /// @param[in] mouseX is where on the x-axis the mouse was dragged
// ///
// /// @param[in] mouseY is where on the y-axis the mouse was dragged
// ///
// /// @param[in] button is the button dragged with (think of a mouse...)
// ///
// /// @brief Handler for mouse drag events. delta's unused currently
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
// boolean ret = false;
// if (this.isValidClickButton(button)) {
// // Do camera panning magic stuff here
// ret = true;
// }
// return ret;
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn mouseDragged
///
/// @param[in] mouseX is where on the x-axis the mouse was dragged
///
/// @param[in] mouseY is where on the y-axis the mouse was dragged
///
/// @param[in] amount represents scroll direction. If the value is negative
/// we scale out. If positive, we scale in
///
/// @brief Handler for mouse scroll events
/////////////////////////////////////////////////////////////////////////////
@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
// Zooming INWARDS on scroll wheel produces 1.0 (which means zoom in)
// Zooming BACKWARDS on scroll wheel produces -1.0 (which means zoom out)
// We enforce a max scroll of 10 in either direction here
if (amount > 0 && zoomScale <= 10) {
// Zoom in
zoomScale++;
} else if (amount < 0 && zoomScale >= -10) {
// Zoom out
zoomScale--;
}
return true;
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn mouseDragged
// ///
// /// @param[in] mouseX is where on the x-axis the mouse was dragged
// ///
// /// @param[in] mouseY is where on the y-axis the mouse was dragged
// ///
// /// @param[in] amount represents scroll direction. If the value is negative
// /// we scale out. If positive, we scale in
// ///
// /// @brief Handler for mouse scroll events
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
// // Zooming INWARDS on scroll wheel produces 1.0 (which means zoom in)
// // Zooming BACKWARDS on scroll wheel produces -1.0 (which means zoom out)
// // We enforce a max scroll of 10 in either direction here
// if (amount > 0 && zoomScale <= 10) {
// // Zoom in
// zoomScale++;
// } else if (amount < 0 && zoomScale >= -10) {
// // Zoom out
// zoomScale--;
// }
// return true;
// }
/////////////////////////////////////////////////////////////////////////////
/// @fn DrawLayer
///
/// @param[in] context is the drawing pane
///
/// @param[in] layer is the layer in which this widget is being drawn in
///
/// @brief This calls renderButton and gives it the valid drawing
/// context to use. This function is called by a ScreenManager<T>
/////////////////////////////////////////////////////////////////////////////
@Override
public void DrawLayer(DrawContext context, int layer) {
Position2d pos = GetScreenCenter();
this.renderButton(context, pos.x - (maxLength / 2), pos.y - (maxHeight / 2), 0);
}
}
// /////////////////////////////////////////////////////////////////////////////
// /// @fn DrawLayer
// ///
// /// @param[in] context is the drawing pane
// ///
// /// @param[in] layer is the layer in which this widget is being drawn in
// ///
// /// @brief This calls renderButton and gives it the valid drawing
// /// context to use. This function is called by a ScreenManager<T>
// /////////////////////////////////////////////////////////////////////////////
// @Override
// public void DrawLayer(DrawContext context, int layer) {
// Position2d pos = GetScreenCenter();
// this.renderButton(context, pos.x - (maxLength / 2), pos.y - (maxHeight / 2), 0);
// }
// }

View File

@ -1,3 +1,3 @@
// 1.20 2024-12-05T22:38:15.935314478 keeblarcraft/Keeblarcraft World Generation
// 1.20.2 2024-12-21T01:52:28.294091413 keeblarcraft/Keeblarcraft World Generation
afc3340283d1101601bd4d2ca96341a58eceaf83 data/keeblarcraft/dimension_type/keeblarcraftdim_type.json
4398eda2b0c28b2c754c45f5805534bf1921b243 data/keeblarcraft/worldgen/biome/test_biome.json

View File

@ -5,8 +5,6 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Map.Entry;
import org.apache.logging.log4j.core.jmx.Server;
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;

View File

@ -1,35 +1,16 @@
package jesse.keeblarcraft.Commands;
import org.apache.logging.log4j.core.jmx.Server;
import com.mojang.brigadier.arguments.StringArgumentType;
import jesse.keeblarcraft.Keeblarcraft;
import jesse.keeblarcraft.ConfigMgr.ConfigManager;
import jesse.keeblarcraft.ConfigMgr.GeneralConfig;
import jesse.keeblarcraft.EventMgr.DimensionLoadingEvent;
import jesse.keeblarcraft.Utils.DirectionalVec;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ChestBlock;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.inventory.EnderChestInventory;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.nbt.NbtList;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
public class MiscCommands {
ConfigManager config = new ConfigManager();
@ -75,6 +56,17 @@ public class MiscCommands {
dispatcher.getRoot().addChild(warp);
warp.addChild(warpLoc);
});
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
var warp = CommandManager.literal("nick").build();
var warpLoc = CommandManager.argument("CUSTOM_NICKNAME", StringArgumentType.string())
.executes(context -> SetNickname(context.getSource().getPlayer(), StringArgumentType.getString(context, "CUSTOM_NICKNAME"))).build();
dispatcher.getRoot().addChild(warp);
warp.addChild(warpLoc);
});
}
public int Warp(ServerPlayerEntity player, String location) {
@ -132,6 +124,11 @@ public class MiscCommands {
return 0;
}
public int SetNickname(ServerPlayerEntity player, String name) {
player.setCustomName(Text.of(name));
return 0;
}
public int GetEnderchestOfPlayer(ServerPlayerEntity cmdInitiator, ServerPlayerEntity targetPlayer) {
// if (cmdInitiator.hasPermissionLevel(4)) {

View File

@ -0,0 +1,18 @@
package jesse.keeblarcraft.Commands;
import com.mojang.brigadier.arguments.StringArgumentType;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.server.command.CommandManager;
public class ShopCommands {
public void RegisterShopCommands() {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
var shopCmd = CommandManager.literal("shop").build();
var shopCreate = CommandManager.literal("create").build();
dispatcher.getRoot().addChild(shopCmd);
});
}
}

View File

@ -16,6 +16,7 @@ import com.mojang.brigadier.context.CommandContext;
import jesse.keeblarcraft.Utils.ChatUtil;
import jesse.keeblarcraft.Utils.ChatUtil.CONSOLE_COLOR;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.entity.player.PlayerAbilities;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
@ -61,11 +62,17 @@ public class ShortcutCommands {
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(CommandManager.literal("heal")
.executes(context -> { HealShortcut(context);
.executes(context -> { HealShortcut(context, null);
return 0;
}));
});
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
var healNode = CommandManager.literal("heal").build();
var targetPlayer = CommandManager.argument("targetPlayer", EntityArgumentType.player())
.executes(context -> HealShortcut(context, EntityArgumentType.getPlayer(context, "targetPlayer")));
});
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
dispatcher.register(CommandManager.literal("day")
.executes(context -> { DayShortcut(context);
@ -194,33 +201,34 @@ public class ShortcutCommands {
// return retValue;
// }
// TODO: Add when we can find where in the API to fill players hunger level
// private int FeedShortcut(CommandContext<ServerCommandSource> context) {
// int retValue = -1;
// if (context.getSource().isExecutedByPlayer()) {
// ServerPlayerEntity player = context.getSource().getPlayer();
private int FeedShortcut(CommandContext<ServerCommandSource> context, ServerPlayerEntity target) {
// if (player.hasPermissionLevel(4)) {
// } else {
// player.sendMessage(Text.literal("You do not have permission for this command"));
// }
// }
// return retValue;
// }
private int HealShortcut(CommandContext<ServerCommandSource> context) {
int retValue = -1;
if (context.getSource().isExecutedByPlayer()) {
// if target is null, feed ourselves
if (target == null) {
ServerPlayerEntity player = context.getSource().getPlayer();
player.getHungerManager().setExhaustion(0.0f);
player.getHungerManager().setFoodLevel(20); // 20 is hardcoded inside class
player.getHungerManager().setSaturationLevel(10.0f); // 5 is set in constructor, but let's try 10!
ChatUtil.SendPlayerMsg(player, "You were just super fed!");
} else {
target.getHungerManager().setExhaustion(0.0f);
target.getHungerManager().setFoodLevel(20); // 20 is hardcoded inside class
target.getHungerManager().setSaturationLevel(10.0f); // 5 is set in constructor, but let's try 10!
ChatUtil.SendPlayerMsg(target, "You were just super fed!");
}
return 0;
}
if (player.hasPermissionLevel(4)) {
player.setHealth(player.getMaxHealth());
ChatUtil.SendPlayerMsg(player, "Healed!");
} else {
player.sendMessage(Text.literal("You do not have permission for this command"));
}
private int HealShortcut(CommandContext<ServerCommandSource> context, ServerPlayerEntity target) {
int retValue = -1;
// If no player specified; then heal ourself full HP
if (target == null) {
context.getSource().getPlayer().setHealth(context.getSource().getPlayer().getMaxHealth());
ChatUtil.SendPlayerMsg(context.getSource().getPlayer(), "Healed!");
} else {
target.setHealth(target.getMaxHealth());
ChatUtil.SendPlayerMsg(target, "You were just healed!");
ChatUtil.SendPlayerMsg(context.getSource().getPlayer(), "You healed " + target.getDisplayName());
}
return retValue;

View File

@ -0,0 +1,27 @@
package jesse.keeblarcraft.CustomBlocks.BlockEntities;
import jesse.keeblarcraft.Keeblarcraft;
import jesse.keeblarcraft.CustomBlocks.BlockManager;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
// EVENTUALLY THIS CLASS WILL GET COLLAPSED UNDER @ref BlockManager.java
// However; I don't have the time to figure out how to do this dynamically this second (I'm lazy and doing this
// all in one sitting)
public class BlockEntityRegistration {
// PLEASE STICK A COMMENT ABOVE EACH REGISTRATION FOR LATER REFERENCE
// FactionBlockEntity
public static final BlockEntityType<FactionBlockEntity> FACTION_BLOCK_ENTITY =
Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(Keeblarcraft.MOD_ID, "faction_block_entity"),
FabricBlockEntityTypeBuilder.create(FactionBlockEntity::new, BlockManager.GetBlock("faction_base_block")).build());
public static void RegisterBlockEntities() {
Keeblarcraft.LOGGER.info("Registering block entities for " + Keeblarcraft.MOD_ID);
}
}

View File

@ -0,0 +1,104 @@
package jesse.keeblarcraft.CustomBlocks.BlockEntities;
import jesse.keeblarcraft.GuiMgr.FactionBlockScreenHandler;
import jesse.keeblarcraft.world.ImplementedInventory;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.PropertyDelegate;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class FactionBlockEntity extends BlockEntity implements ExtendedScreenHandlerFactory, ImplementedInventory {
private final DefaultedList<ItemStack> inventory = DefaultedList.ofSize(4, ItemStack.EMPTY);
private static final int DEFENSE_SLOT_ONE = 0;
private static final int DEFENSE_SLOT_TWO = 1;
private static final int OFFENSE_SLOT_ONE = 2;
private static final int OFFENSE_SLOT_TWO = 3;
private static int power = 0;
protected final PropertyDelegate propertyDelegate;
public FactionBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityRegistration.FACTION_BLOCK_ENTITY, pos, state);
this.propertyDelegate = new PropertyDelegate() {
@Override
public int get(int index) {
return switch(index) {
default -> power;
};
}
@Override
public void set(int index, int value) {
switch(index) {
default -> power = value;
};
}
@Override
public int size() {
return 1;
}
};
}
@Override
public Text getDisplayName() {
return Text.literal("Faction Home Base Station"); // Replace with proper en_us format later
}
@Override
public ScreenHandler createMenu(int syncId, PlayerInventory playerInventory, PlayerEntity player) {
return new FactionBlockScreenHandler(syncId, playerInventory, this, this.propertyDelegate);
}
@Override
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
Inventories.readNbt(nbt, inventory);
power = nbt.getInt("faction_block_entity.power");
}
@Override
public void writeNbt(NbtCompound nbt) {
super.writeNbt(nbt);
Inventories.writeNbt(nbt, inventory); // Write our inventory when world is saved; etc
nbt.putInt("faction_block_entity.power", power);
}
@Override
public DefaultedList<ItemStack> getItems() {
return inventory;
}
@Override
public void writeScreenOpeningData(ServerPlayerEntity player, PacketByteBuf buf) {
// Send position of this block entity from server->client->server etc
buf.writeBlockPos(this.pos);
}
// Tick method is called 20 times a second
public void tick(World world, BlockPos pos, BlockState state) {
// For reasons unknown to me and only to Kaupenjoe (youtube video) - we never want to call this on a client.
if (world.isClient()) {
return;
}
// Do stuff here that we need to do on a per tick basis. Probably check the items inside the slots and do stuff?
}
}

View File

@ -1,7 +1,7 @@
package jesse.keeblarcraft.CustomBlocks;
import jesse.keeblarcraft.CustomBlocks.Blocks.FactionBaseBlock;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.ExperienceDroppingBlock;
@ -20,5 +20,6 @@ public class BlockList {
BlockManager.RegisterBlock("example_block_ore", new Block(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).sounds(BlockSoundGroup.AMETHYST_BLOCK).requiresTool().breakInstantly()));
BlockManager.RegisterBlock("example_block", new ExperienceDroppingBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).sounds(BlockSoundGroup.ANCIENT_DEBRIS).requiresTool(), UniformIntProvider.create(4, 20)));
BlockManager.RegisterBlock("example_statue", new Block(FabricBlockSettings.copyOf(Blocks.BELL)));
BlockManager.RegisterBlock("faction_base_block", new FactionBaseBlock(FabricBlockSettings.copyOf(Blocks.IRON_BLOCK).nonOpaque()));
}
}

View File

@ -0,0 +1,77 @@
package jesse.keeblarcraft.CustomBlocks.Blocks;
import javax.swing.text.html.BlockView;
import jesse.keeblarcraft.CustomBlocks.BlockEntities.BlockEntityRegistration;
import jesse.keeblarcraft.CustomBlocks.BlockEntities.FactionBlockEntity;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.World;
public class FactionBaseBlock extends BlockWithEntity implements BlockEntityProvider {
// public static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, 0, 16, 12, 16);
public FactionBaseBlock(Settings settings) {
super(settings);
}
// @Override
// protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
// return SHAPE;
// }
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new FactionBlockEntity(pos, state);
}
// If block is destroyed; drop inventory
@Override
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
if (state.getBlock() != newState.getBlock()) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null && blockEntity instanceof FactionBlockEntity) {
ItemScatterer.spawn(world, pos, (FactionBlockEntity) blockEntity);
world.updateComparators(pos, this);
}
super.onStateReplaced(state, world, pos, newState, moved);
}
}
// Open the inventory
// Calls ScreenHandler inside createMenu of entity class
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
// Server side handling is different than that of client side handling; we MUST check if we are on a server first because then we must
// request information about this block entity from the server
if (!world.isClient()) {
NamedScreenHandlerFactory screenHandlerFactory = (FactionBlockEntity) world.getBlockEntity(pos);
if (screenHandlerFactory != null) {
player.openHandledScreen(screenHandlerFactory);
}
}
return ActionResult.SUCCESS;
}
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return validateTicker(type, BlockEntityRegistration.FACTION_BLOCK_ENTITY,
(world1, pos, state1, blockEntity) -> blockEntity.tick(world1, pos, state1));
}
}

View File

@ -19,7 +19,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
public class FactionManager {
private static String FACTION_CFG_FILE = "config/keeblarcraft/factions/factions.json";
private static String FACTION_CFG_FILE = "factions/factions.json";
ConfigManager config = new ConfigManager();
private static FactionManager static_inst;

View File

@ -0,0 +1,75 @@
package jesse.keeblarcraft.GuiMgr;
import jesse.keeblarcraft.CustomBlocks.BlockEntities.FactionBlockEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.ArrayPropertyDelegate;
import net.minecraft.screen.PropertyDelegate;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
public class FactionBlockScreenHandler extends ScreenHandler {
private final Inventory inventory;
private final PropertyDelegate propertyDelegate;
public final FactionBlockEntity blockEntity;
public FactionBlockScreenHandler(int syncId, PlayerInventory inventory, PacketByteBuf buf) {
this(syncId, inventory, inventory.player.getWorld().getBlockEntity(buf.readBlockPos()), new ArrayPropertyDelegate(4));
}
public FactionBlockScreenHandler(int syncId, PlayerInventory playerInventory, BlockEntity blockEntity, PropertyDelegate arrayPropertyDelegate) {
super(ScreenHandlerRegistration.FACTION_BLOCK_SCREEN_HANDLER, syncId);
checkSize((Inventory) blockEntity, 4);
this.inventory = (Inventory) blockEntity;
inventory.onOpen(playerInventory.player);
this.propertyDelegate = arrayPropertyDelegate;
this.blockEntity = (FactionBlockEntity) blockEntity;
// TODO: These positions need to be redrawn with an actual GUI
this.addSlot(new Slot(inventory, 0, 60, 11));
this.addSlot(new Slot(inventory, 1, 70, 11));
this.addSlot(new Slot(inventory, 2, 80, 11));
this.addSlot(new Slot(inventory, 3, 90, 11));
// Need to reference Kaupendim tutorial again; but we could theoretically just add the player inventory
// right here so that they can drag items in and whatnot (I assume). I am unsure if I am taking that
// direction with this block RIGHT NOW - so for now I am NOT doing that
// Remainder stuff
addProperties(arrayPropertyDelegate);
}
// This is just for SHIFT+CLICK moving
@Override
public ItemStack quickMove(PlayerEntity player, int invSlot) {
ItemStack newStack = ItemStack.EMPTY;
Slot slot = this.slots.get(invSlot);
if (slot != null && slot.hasStack()) {
ItemStack originalStack = slot.getStack();
newStack = originalStack.copy();
// TODO: This is from the YT video and it looks atrocious. Refactor this later
if ( (invSlot < this.inventory.size() && !this.insertItem(originalStack, this.inventory.size(), this.slots.size(), true) ) ||
(!this.insertItem(originalStack, 0, this.inventory.size(), false))) {
return ItemStack.EMPTY;
}
if (originalStack.isEmpty()) {
slot.setStack(ItemStack.EMPTY);
} else {
slot.markDirty();;
}
}
return newStack;
}
@Override
public boolean canUse(PlayerEntity player) {
return this.inventory.canPlayerUse(player);
}
}

View File

@ -0,0 +1,18 @@
package jesse.keeblarcraft.GuiMgr;
import jesse.keeblarcraft.Keeblarcraft;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.Identifier;
public class ScreenHandlerRegistration {
public static final ScreenHandlerType<FactionBlockScreenHandler> FACTION_BLOCK_SCREEN_HANDLER =
Registry.register(Registries.SCREEN_HANDLER, new Identifier(Keeblarcraft.MOD_ID, "faction_block"),
new ExtendedScreenHandlerType<>(FactionBlockScreenHandler::new));
public static void registerScreenHandlers() {
Keeblarcraft.LOGGER.info("Registering screen handlers for " + Keeblarcraft.MOD_ID);
}
}

View File

@ -41,12 +41,14 @@ import jesse.keeblarcraft.AttributeMgr.AttributeTree;
import jesse.keeblarcraft.BankMgr.BankManager;
import jesse.keeblarcraft.Commands.CustomCommandManager;
import jesse.keeblarcraft.CustomBlocks.BlockList;
import jesse.keeblarcraft.CustomBlocks.BlockEntities.BlockEntityRegistration;
// import jesse.keeblarcraft.CustomBlocks.BlockEntities.MagicChestBlockEntity;
// import jesse.keeblarcraft.CustomBlocks.Blocks.MagicChestBlock;
import jesse.keeblarcraft.CustomItems.ItemManager;
import jesse.keeblarcraft.EventMgr.DimensionLoadingEvent;
import jesse.keeblarcraft.EventMgr.PlayerJoinListener;
import jesse.keeblarcraft.EventMgr.ServerTickListener;
import jesse.keeblarcraft.GuiMgr.ScreenHandlerRegistration;
import jesse.keeblarcraft.GuiMgr.TreeHandler;
import jesse.keeblarcraft.Utils.CustomExceptions.SETUP_FAILED_EXCEPTION;
import jesse.keeblarcraft.Utils.ChatUtil;
@ -140,6 +142,7 @@ public class Keeblarcraft implements ModInitializer {
// Register blocks
BlockList.RegisterBlocks();
BlockEntityRegistration.RegisterBlockEntities();
// World generation
@ -152,6 +155,9 @@ public class Keeblarcraft implements ModInitializer {
.tintColor(234, 183, 8)
.registerPortal();
// Screen handlers
ScreenHandlerRegistration.registerScreenHandlers();
} catch (SETUP_FAILED_EXCEPTION e) {
System.out.println(ChatUtil.ColoredString("ERROR. Setup failed to initialize environment. Mod likely does not have read/write permissions inside area. Mod will now close out.", CONSOLE_COLOR.RED));

View File

@ -0,0 +1,25 @@
package jesse.keeblarcraft.datagen;
import jesse.keeblarcraft.CustomBlocks.BlockManager;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
public class KeeblarModelProvider extends FabricModelProvider {
public KeeblarModelProvider(FabricDataOutput output) {
super(output);
}
@Override
public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
blockStateModelGenerator.registerSimpleState(BlockManager.GetBlock("faction_base_block"));
}
@Override
public void generateItemModels(ItemModelGenerator itemModelGenerator) {
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "keeblarcraft:block/faction_base_block"
}
}
}

View File

@ -9,6 +9,7 @@
"block.keeblarcraft.example_block": "Keeblarcraft example block",
"block.keeblarcraft.example_block_ore": "Keeblarcraft example block ore",
"block.keeblarcraft.example_statue": "Keeblarcraft example statue",
"block.keeblarcraft.faction_base_block": "Factions Base Block",
"category.keeblarcraft.test": "Keeblarcraft bindings",
"key.keeblarcraft.treemap": "Tree GUI",

View File

@ -0,0 +1,232 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"0": "keeblarcraft:block/faction_base_block",
"particle": "keeblarcraft:block/faction_base_block"
},
"elements": [
{
"from": [12, 0, 2],
"to": [14, 3, 14],
"rotation": {"angle": 0, "axis": "y", "origin": [2, 0, 2]},
"faces": {
"north": {"uv": [2, 6, 2.5, 6.75], "texture": "#0"},
"east": {"uv": [2.5, 2, 5.5, 2.75], "texture": "#0"},
"south": {"uv": [6, 3.25, 6.5, 4], "texture": "#0"},
"west": {"uv": [2.5, 2.75, 5.5, 3.5], "texture": "#0"},
"up": {"uv": [3, 8, 2.5, 5], "texture": "#0"},
"down": {"uv": [3.5, 5, 3, 8], "texture": "#0"}
}
},
{
"from": [2, 0, 2],
"to": [4, 3, 14],
"rotation": {"angle": 0, "axis": "y", "origin": [-8, 0, 2]},
"faces": {
"north": {"uv": [5.75, 6, 6.25, 6.75], "texture": "#0"},
"east": {"uv": [2.5, 3.5, 5.5, 4.25], "texture": "#0"},
"south": {"uv": [0, 6.25, 0.5, 7], "texture": "#0"},
"west": {"uv": [0, 4.25, 3, 5], "texture": "#0"},
"up": {"uv": [4, 8, 3.5, 5], "texture": "#0"},
"down": {"uv": [4.5, 5, 4, 8], "texture": "#0"}
}
},
{
"from": [7, 0, 5],
"to": [9, 2, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [-3, 0, 3]},
"faces": {
"north": {"uv": [1.5, 6.25, 2, 6.75], "texture": "#0"},
"east": {"uv": [4.5, 5, 6, 5.5], "texture": "#0"},
"south": {"uv": [6.25, 4.5, 6.75, 5], "texture": "#0"},
"west": {"uv": [5.5, 2, 7, 2.5], "texture": "#0"},
"up": {"uv": [6, 4, 5.5, 2.5], "texture": "#0"},
"down": {"uv": [5, 5.5, 4.5, 7], "texture": "#0"}
}
},
{
"from": [3, 5, 4],
"to": [13, 7, 12],
"rotation": {"angle": 0, "axis": "y", "origin": [7, 5, 7]},
"faces": {
"north": {"uv": [5, 0, 7.5, 0.5], "texture": "#0"},
"east": {"uv": [5, 1, 7, 1.5], "texture": "#0"},
"south": {"uv": [5, 0.5, 7.5, 1], "texture": "#0"},
"west": {"uv": [5, 1.5, 7, 2], "texture": "#0"},
"up": {"uv": [2.5, 2, 0, 0], "texture": "#0"},
"down": {"uv": [2.5, 2, 0, 4], "texture": "#0"}
}
},
{
"from": [3, 1, 4],
"to": [13, 5, 7],
"rotation": {"angle": 0, "axis": "y", "origin": [7, 2, 5]},
"faces": {
"north": {"uv": [2.5, 0, 5, 1], "texture": "#0"},
"east": {"uv": [5.5, 4, 6.25, 5], "texture": "#0"},
"south": {"uv": [2.5, 1, 5, 2], "texture": "#0"},
"west": {"uv": [5, 5.5, 5.75, 6.5], "texture": "#0"},
"up": {"uv": [5.5, 5, 3, 4.25], "texture": "#0"},
"down": {"uv": [2.5, 5, 0, 5.75], "texture": "#0"}
}
},
{
"from": [3, 7, 4],
"to": [13, 8, 5],
"rotation": {"angle": 0, "axis": "y", "origin": [5, 7, 3]},
"faces": {
"north": {"uv": [0, 4, 2.5, 4.25], "texture": "#0"},
"east": {"uv": [2, 7.25, 2.25, 7.5], "texture": "#0"},
"south": {"uv": [0, 5.75, 2.5, 6], "texture": "#0"},
"west": {"uv": [2.25, 7.25, 2.5, 7.5], "texture": "#0"},
"up": {"uv": [8.25, 5.75, 5.75, 5.5], "texture": "#0"},
"down": {"uv": [8.25, 5.75, 5.75, 6], "texture": "#0"}
}
},
{
"from": [3.001, 6.999, 4.001],
"to": [4.001, 7.999, 9.001],
"rotation": {"angle": 0, "axis": "y", "origin": [5, 7, 6]},
"faces": {
"north": {"uv": [4.5, 7.25, 4.75, 7.5], "texture": "#0"},
"east": {"uv": [6, 5, 7.25, 5.25], "texture": "#0"},
"south": {"uv": [7.25, 4.5, 7.5, 4.75], "texture": "#0"},
"west": {"uv": [6, 5.25, 7.25, 5.5], "texture": "#0"},
"up": {"uv": [0.75, 7.5, 0.5, 6.25], "texture": "#0"},
"down": {"uv": [1, 6.25, 0.75, 7.5], "texture": "#0"}
}
},
{
"from": [11.99, 6.999, 4.001],
"to": [12.99, 7.999, 9.001],
"rotation": {"angle": 0, "axis": "y", "origin": [14, 7, 6]},
"faces": {
"north": {"uv": [4.75, 7.25, 5, 7.5], "texture": "#0"},
"east": {"uv": [6.25, 4, 7.5, 4.25], "texture": "#0"},
"south": {"uv": [7.25, 4.75, 7.5, 5], "texture": "#0"},
"west": {"uv": [6.25, 4.25, 7.5, 4.5], "texture": "#0"},
"up": {"uv": [1.25, 7.5, 1, 6.25], "texture": "#0"},
"down": {"uv": [1.5, 6.25, 1.25, 7.5], "texture": "#0"}
}
},
{
"from": [5, 7, 6],
"to": [7, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [7, 7, 5]},
"faces": {
"north": {"uv": [6.5, 3.75, 7, 4], "texture": "#0"},
"east": {"uv": [6.75, 6, 7.25, 6.25], "texture": "#0"},
"south": {"uv": [6.75, 6.25, 7.25, 6.5], "texture": "#0"},
"west": {"uv": [6.75, 6.5, 7.25, 6.75], "texture": "#0"},
"up": {"uv": [6.75, 6.5, 6.25, 6], "texture": "#0"},
"down": {"uv": [7, 3.25, 6.5, 3.75], "texture": "#0"}
}
},
{
"from": [9, 7, 6],
"to": [11, 8, 8],
"rotation": {"angle": 0, "axis": "y", "origin": [11, 7, 5]},
"faces": {
"north": {"uv": [6.75, 6.75, 7.25, 7], "texture": "#0"},
"east": {"uv": [0, 7, 0.5, 7.25], "texture": "#0"},
"south": {"uv": [7, 1, 7.5, 1.25], "texture": "#0"},
"west": {"uv": [7, 1.25, 7.5, 1.5], "texture": "#0"},
"up": {"uv": [5.5, 7, 5, 6.5], "texture": "#0"},
"down": {"uv": [6.75, 6.5, 6.25, 7], "texture": "#0"}
}
},
{
"from": [9, 7, 9],
"to": [11, 8, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [11, 7, 8]},
"faces": {
"north": {"uv": [7, 1.5, 7.5, 1.75], "texture": "#0"},
"east": {"uv": [7, 1.75, 7.5, 2], "texture": "#0"},
"south": {"uv": [7, 2, 7.5, 2.25], "texture": "#0"},
"west": {"uv": [7, 2.25, 7.5, 2.5], "texture": "#0"},
"up": {"uv": [2, 7.25, 1.5, 6.75], "texture": "#0"},
"down": {"uv": [2.5, 6.75, 2, 7.25], "texture": "#0"}
}
},
{
"from": [5, 7, 9],
"to": [7, 8, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [7, 7, 8]},
"faces": {
"north": {"uv": [7, 3.25, 7.5, 3.5], "texture": "#0"},
"east": {"uv": [7, 3.5, 7.5, 3.75], "texture": "#0"},
"south": {"uv": [7, 3.75, 7.5, 4], "texture": "#0"},
"west": {"uv": [4.5, 7, 5, 7.25], "texture": "#0"},
"up": {"uv": [7.25, 5, 6.75, 4.5], "texture": "#0"},
"down": {"uv": [6, 6.75, 5.5, 7.25], "texture": "#0"}
}
},
{
"from": [11, 7, 2],
"to": [12, 8, 4],
"rotation": {"angle": 0, "axis": "y", "origin": [10, 6, 2]},
"faces": {
"north": {"uv": [5, 7.25, 5.25, 7.5], "texture": "#0"},
"east": {"uv": [5, 7, 5.5, 7.25], "texture": "#0"},
"south": {"uv": [7.25, 5, 7.5, 5.25], "texture": "#0"},
"west": {"uv": [6, 7, 6.5, 7.25], "texture": "#0"},
"up": {"uv": [6.75, 7.5, 6.5, 7], "texture": "#0"},
"down": {"uv": [7, 7, 6.75, 7.5], "texture": "#0"}
}
},
{
"from": [4, 7, 2],
"to": [5, 8, 4],
"rotation": {"angle": 0, "axis": "y", "origin": [3, 6, 2]},
"faces": {
"north": {"uv": [5.25, 7.25, 5.5, 7.5], "texture": "#0"},
"east": {"uv": [7, 7, 7.5, 7.25], "texture": "#0"},
"south": {"uv": [7.25, 5.25, 7.5, 5.5], "texture": "#0"},
"west": {"uv": [0, 7.25, 0.5, 7.5], "texture": "#0"},
"up": {"uv": [1.75, 7.75, 1.5, 7.25], "texture": "#0"},
"down": {"uv": [2, 7.25, 1.75, 7.75], "texture": "#0"}
}
},
{
"from": [4, 7, 1],
"to": [12, 8, 2],
"rotation": {"angle": 0, "axis": "y", "origin": [6, 6, 0]},
"faces": {
"north": {"uv": [0, 6, 2, 6.25], "texture": "#0"},
"east": {"uv": [5.5, 6.5, 5.75, 6.75], "texture": "#0"},
"south": {"uv": [6, 2.5, 8, 2.75], "texture": "#0"},
"west": {"uv": [6, 6.75, 6.25, 7], "texture": "#0"},
"up": {"uv": [8, 3, 6, 2.75], "texture": "#0"},
"down": {"uv": [8, 3, 6, 3.25], "texture": "#0"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [-138.53, -0.13, 178.31],
"translation": [-0.25, 2.75, -2.5],
"scale": [0.77734, 0.5625, 0.76172]
},
"thirdperson_lefthand": {
"rotation": [-173.23, 0.42, -179.8],
"translation": [0.25, 0, -3.5],
"scale": [0.60156, 0.42188, 0.58984]
},
"gui": {
"rotation": [44.5, 31.22, -19.39],
"translation": [1.75, 3, 0],
"scale": [0.88281, 0.87109, 1.02539]
},
"head": {
"rotation": [180, 0.5, 180],
"translation": [0, 10, 0],
"scale": [1.94141, 1.45703, 2.06641]
},
"fixed": {
"rotation": [90, 40, -180],
"translation": [0, 0, -7],
"scale": [1.17188, 1, 1]
}
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "keeblarcraft:block/faction_base_block"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B