Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bec37ce0a | ||
|
|
5fce26a796 | ||
|
|
28d47a0cbb | ||
|
|
00cb48b929 | ||
|
|
0d6613c3ba | ||
|
|
1607aa35ce | ||
|
|
b75cfc45d8 | ||
|
|
4537dd409d | ||
|
|
268d6e7a6b | ||
|
|
ca44da71e7 | ||
|
|
8570bde282 |
13
build.gradle
13
build.gradle
@@ -2,7 +2,6 @@ buildscript {
|
||||
repositories {
|
||||
maven { url = 'https://maven.minecraftforge.net' }
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
|
||||
maven { url = 'https://maven.parchmentmc.org' }
|
||||
}
|
||||
@@ -30,7 +29,9 @@ ext.buildNumber = System.getenv('BUILD_NUMBER')
|
||||
|
||||
version = mod_version
|
||||
group = 'nl.requios.effortlessbuilding'
|
||||
archivesBaseName = "effortlessbuilding-${artifact_minecraft_version}"
|
||||
base {
|
||||
archivesName = "effortlessbuilding-${artifact_minecraft_version}"
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
|
||||
@@ -121,7 +122,7 @@ dependencies {
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
|
||||
jarJar("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") {
|
||||
jarJar.ranged(it, '[0.6.9,0.6.10)')
|
||||
jarJar.ranged(it, '[0.6.9,0.7)')
|
||||
}
|
||||
|
||||
if (flywheelInWorkspace) {
|
||||
@@ -155,7 +156,7 @@ jar {
|
||||
"Specification-Title": "effortlessbuilding",
|
||||
"Specification-Vendor": "requios",
|
||||
"Specification-Version": "1",
|
||||
"Implementation-Title": project.jar.archiveBaseName,
|
||||
"Implementation-Title": project.name,
|
||||
"Implementation-Version": project.jar.archiveVersion,
|
||||
"Implementation-Vendor" :"requios",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
@@ -167,7 +168,7 @@ task jarJarRelease {
|
||||
group = 'jarjar'
|
||||
doLast {
|
||||
tasks.jarJar {
|
||||
archiveClassifier = ''
|
||||
classifier = ''
|
||||
}
|
||||
}
|
||||
finalizedBy tasks.jarJar
|
||||
@@ -184,7 +185,7 @@ tasks.jarJar.finalizedBy('reobfJarJar')
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifactId = archivesBaseName
|
||||
artifactId = base.archivesName.get()
|
||||
|
||||
from components.java
|
||||
fg.component(it)
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
mod_version = 3.4
|
||||
artifact_minecraft_version = 1.20.1
|
||||
mod_version = 3.7
|
||||
artifact_minecraft_version = 1.19.4
|
||||
|
||||
minecraft_version = 1.20.1
|
||||
forge_version = 47.0.43
|
||||
minecraft_version = 1.19.4
|
||||
forge_version = 45.2.6
|
||||
|
||||
forgegradle_version = 6.0.6
|
||||
forgegradle_version = 6.0.7
|
||||
mixingradle_version = 0.7-SNAPSHOT
|
||||
mixin_version = 0.8.5
|
||||
librarian_version = 1.+
|
||||
cursegradle_version = 1.4.0
|
||||
parchment_version = 2023.06.26
|
||||
|
||||
flywheel_minecraft_version = 1.20.1
|
||||
flywheel_version = 0.6.9-5
|
||||
flywheel_minecraft_version = 1.19.3
|
||||
flywheel_version = 0.6.9-2
|
||||
28
gradlew
vendored
28
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright <EFBFBD> 2015-2021 the original authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,10 @@
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions <EFBFBD>$var<EFBFBD>, <EFBFBD>${var}<EFBFBD>, <EFBFBD>${var:-default}<EFBFBD>, <EFBFBD>${var+SET}<EFBFBD>,
|
||||
# <EFBFBD>${var#prefix}<EFBFBD>, <EFBFBD>${var%suffix}<EFBFBD>, and <EFBFBD>$( cmd )<EFBFBD>;
|
||||
# * compound commands having a testable exit status, especially <EFBFBD>case<EFBFBD>;
|
||||
# * various built-in commands including <EFBFBD>command<EFBFBD>, <EFBFBD>set<EFBFBD>, and <EFBFBD>ulimit<EFBFBD>.
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
@@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -80,10 +80,10 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
@@ -143,12 +143,16 @@ fi
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -205,6 +209,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,8 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
@@ -1 +1,10 @@
|
||||
rootProject.name = 'EffortlessBuilding'
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven { url = 'https://maven.minecraftforge.net/' }
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -46,16 +47,23 @@ public enum AllGuiTextures implements ScreenElement {
|
||||
public void bind() {
|
||||
RenderSystem.setShaderTexture(0, location);
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(GuiGraphics graphics, int x, int y) {
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int x, int y) {
|
||||
bind();
|
||||
graphics.blit(location, x, y, startX, startY, width, height, width, height);
|
||||
GuiComponent.blit(poseStack, x, y, 0, startX, startY, width, height, 256, 256);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(PoseStack poseStack, int x, int y, GuiComponent component) {
|
||||
bind();
|
||||
component.blit(poseStack, x, y, 0, startX, startY, width, height, 256, 256);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(GuiGraphics graphics, int x, int y, Color c) {
|
||||
public void render(PoseStack poseStack, int x, int y, Color c, GuiComponent component) {
|
||||
bind();
|
||||
UIRenderHelper.drawColoredTexture(graphics, c, x, y, startX, startY, width, height);
|
||||
UIRenderHelper.drawColoredTexture(poseStack, c, x, y, startX, startY, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ package nl.requios.effortlessbuilding;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import org.joml.Matrix4f;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@@ -16,6 +15,7 @@ import nl.requios.effortlessbuilding.create.Create;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.DelegatedStencilElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public class AllIcons implements ScreenElement {
|
||||
|
||||
@@ -100,19 +100,18 @@ public class AllIcons implements ScreenElement {
|
||||
private static AllIcons newRow() {
|
||||
return new AllIcons(x = 0, ++y);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
||||
public void bind() {
|
||||
RenderSystem.setShaderTexture(0, ICON_ATLAS);
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int x, int y) {
|
||||
public void render(PoseStack ms, int x, int y) {
|
||||
bind();
|
||||
graphics.blit(ICON_ATLAS, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
||||
GuiComponent.blit(ms, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(PoseStack ms, MultiBufferSource buffer, int color) {
|
||||
VertexConsumer builder = buffer.getBuffer(RenderType.textSeeThrough(ICON_ATLAS));
|
||||
|
||||
@@ -20,7 +20,6 @@ import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.gui.buildmode.PlayerSettingsGui;
|
||||
import nl.requios.effortlessbuilding.gui.buildmode.RadialMenu;
|
||||
import nl.requios.effortlessbuilding.gui.buildmodifier.ModifiersScreen;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
@EventBusSubscriber(Dist.CLIENT)
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.CreativeModeTabRegistry;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
|
||||
public class EBCreativeModeTab implements CreativeModeTab.DisplayItemsGenerator {
|
||||
|
||||
@Override
|
||||
public void accept(CreativeModeTab.ItemDisplayParameters pParameters, CreativeModeTab.Output pOutput) {
|
||||
pOutput.accept(EffortlessBuilding.RANDOMIZER_BAG_ITEM.get());
|
||||
pOutput.accept(EffortlessBuilding.GOLDEN_RANDOMIZER_BAG_ITEM.get());
|
||||
pOutput.accept(EffortlessBuilding.DIAMOND_RANDOMIZER_BAG_ITEM.get());
|
||||
|
||||
pOutput.accept(EffortlessBuilding.REACH_UPGRADE_1_ITEM.get());
|
||||
pOutput.accept(EffortlessBuilding.REACH_UPGRADE_2_ITEM.get());
|
||||
pOutput.accept(EffortlessBuilding.REACH_UPGRADE_3_ITEM.get());
|
||||
|
||||
pOutput.accept(EffortlessBuilding.MUSCLES_ITEM.get());
|
||||
pOutput.accept(EffortlessBuilding.ELASTIC_HAND_ITEM.get());
|
||||
pOutput.accept(EffortlessBuilding.BUILDING_TECHNIQUES_BOOK_ITEM.get());
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package nl.requios.effortlessbuilding;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.loot.IGlobalLootModifier;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
@@ -40,6 +40,8 @@ import nl.requios.effortlessbuilding.systems.UndoRedo;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mod(EffortlessBuilding.MODID)
|
||||
public class EffortlessBuilding {
|
||||
|
||||
@@ -58,7 +60,6 @@ public class EffortlessBuilding {
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
private static final DeferredRegister<MenuType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, EffortlessBuilding.MODID);
|
||||
public static final DeferredRegister<Codec<? extends IGlobalLootModifier>> LOOT_MODIFIERS = DeferredRegister.create(ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, EffortlessBuilding.MODID);
|
||||
private static final DeferredRegister<CreativeModeTab> CREATIVE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, EffortlessBuilding.MODID);
|
||||
|
||||
public static final RegistryObject<Item> RANDOMIZER_BAG_ITEM = ITEMS.register("randomizer_bag", RandomizerBagItem::new);
|
||||
public static final RegistryObject<Item> GOLDEN_RANDOMIZER_BAG_ITEM = ITEMS.register("golden_randomizer_bag", GoldenRandomizerBagItem::new);
|
||||
@@ -74,12 +75,6 @@ public class EffortlessBuilding {
|
||||
public static final RegistryObject<MenuType<GoldenRandomizerBagContainer>> GOLDEN_RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("golden_randomizer_bag", () -> registerContainer(GoldenRandomizerBagContainer::new));
|
||||
public static final RegistryObject<MenuType<DiamondRandomizerBagContainer>> DIAMOND_RANDOMIZER_BAG_CONTAINER = CONTAINERS.register("diamond_randomizer_bag", () -> registerContainer(DiamondRandomizerBagContainer::new));
|
||||
|
||||
public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = CREATIVE_TABS.register("effortlessbuilding",
|
||||
() -> CreativeModeTab.builder()
|
||||
.title(Component.translatable("key.effortlessbuilding.category"))
|
||||
.icon(() -> new ItemStack(RANDOMIZER_BAG_ITEM.get()))
|
||||
.displayItems(new EBCreativeModeTab())
|
||||
.build());
|
||||
|
||||
public EffortlessBuilding() {
|
||||
instance = this;
|
||||
@@ -89,6 +84,7 @@ public class EffortlessBuilding {
|
||||
IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
|
||||
|
||||
modEventBus.addListener(EffortlessBuilding::setup);
|
||||
modEventBus.addListener(EffortlessBuilding::addTabContents);
|
||||
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> EffortlessBuildingClient.onConstructorClient(modEventBus, forgeEventBus));
|
||||
|
||||
@@ -98,12 +94,10 @@ public class EffortlessBuilding {
|
||||
var singleItemLootModifier = SingleItemLootModifier.CODEC; //load this class to register the loot modifier
|
||||
LOOT_MODIFIERS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
|
||||
CREATIVE_TABS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
|
||||
//Register config
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, CommonConfig.spec);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ClientConfig.spec);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ServerConfig.spec);
|
||||
modLoadingContext.registerConfig(ModConfig.Type.COMMON, CommonConfig.spec);
|
||||
modLoadingContext.registerConfig(ModConfig.Type.CLIENT, ClientConfig.spec);
|
||||
modLoadingContext.registerConfig(ModConfig.Type.SERVER, ServerConfig.spec);
|
||||
}
|
||||
|
||||
public static void setup(final FMLCommonSetupEvent event) {
|
||||
@@ -112,8 +106,15 @@ public class EffortlessBuilding {
|
||||
CompatHelper.setup();
|
||||
}
|
||||
|
||||
public static void addTabContents(final CreativeModeTabEvent.BuildContents event) {
|
||||
if (event.getTab() == CreativeModeTabs.TOOLS_AND_UTILITIES) {
|
||||
List<ItemStack> stacks = ITEMS.getEntries().stream().map(reg -> new ItemStack(reg.get())).toList();
|
||||
event.acceptAll(stacks);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends AbstractContainerMenu> MenuType<T> registerContainer(IContainerFactory<T> fact){
|
||||
MenuType<T> type = new MenuType<T>(fact, FeatureFlagSet.of());
|
||||
MenuType<T> type = new MenuType<T>(fact, FeatureFlags.REGISTRY.allFlags());
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package nl.requios.effortlessbuilding.buildmode;
|
||||
|
||||
import org.joml.Vector4f;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
|
||||
public enum BuildModeCategoryEnum {
|
||||
BASIC(new Vector4f(0f, .5f, 1f, .8f)),
|
||||
DIAGONAL(new Vector4f(0.56f, 0.28f, 0.87f, .8f)),
|
||||
CIRCULAR(new Vector4f(0.29f, 0.76f, 0.3f, 1f)),
|
||||
ROOF(new Vector4f(0.83f, 0.87f, 0.23f, .8f));
|
||||
BASIC(new Color(0f, .5f, 1f, .8f)),
|
||||
DIAGONAL(new Color(0.56f, 0.28f, 0.87f, .8f)),
|
||||
CIRCULAR(new Color(0.29f, 0.76f, 0.3f, 1f)),
|
||||
ROOF(new Color(0.83f, 0.87f, 0.23f, .8f));
|
||||
|
||||
public final Vector4f color;
|
||||
public final Color color;
|
||||
|
||||
BuildModeCategoryEnum(Vector4f color) {
|
||||
BuildModeCategoryEnum(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class BuildModes {
|
||||
if (!skipRaytrace) {
|
||||
//collision within a 1 block radius to selected is fine
|
||||
ClipContext rayTraceContext = new ClipContext(start, lineBound, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, player);
|
||||
HitResult rayTraceResult = player.level().clip(rayTraceContext);
|
||||
HitResult rayTraceResult = player.level.clip(rayTraceContext);
|
||||
intersects = rayTraceResult != null && rayTraceResult.getType() == HitResult.Type.BLOCK &&
|
||||
planeBound.subtract(rayTraceResult.getLocation()).lengthSqr() > 4;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ModeOptions {
|
||||
case CIRCLE_START_CORNER -> circleStart = ActionEnum.CIRCLE_START_CORNER;
|
||||
}
|
||||
|
||||
if (player.level().isClientSide &&
|
||||
if (player.level.isClientSide &&
|
||||
action != ActionEnum.OPEN_MODIFIER_SETTINGS &&
|
||||
action != ActionEnum.OPEN_PLAYER_SETTINGS &&
|
||||
action != ActionEnum.PREVIOUS_BUILD_MODE &&
|
||||
|
||||
@@ -6,7 +6,6 @@ import net.minecraft.world.entity.player.Player;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package nl.requios.effortlessbuilding.buildmode.buildmodes;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -90,7 +89,7 @@ public class Line extends TwoClicksBuildMode {
|
||||
|
||||
public static void addZLineBlocks(List<BlockPos> list, int z1, int z2, int x, int y) {
|
||||
for (int z = z1; z1 < z2 ? z <= z2 : z >= z2; z += z1 < z2 ? 1 : -1) {
|
||||
list.add(new BlockPos(x, y, z));
|
||||
list.add(BlockPos.containing(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.minecraft.core.BlockPos;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.ThreeClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -7,7 +7,6 @@ import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmode.BuildModes;
|
||||
import nl.requios.effortlessbuilding.buildmode.ModeOptions;
|
||||
import nl.requios.effortlessbuilding.buildmode.TwoClicksBuildMode;
|
||||
import nl.requios.effortlessbuilding.systems.PowerLevel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,24 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Array extends BaseModifier {
|
||||
|
||||
public Vec3i offset = BlockPos.ZERO;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ package nl.requios.effortlessbuilding.buildmodifier;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
@@ -4,23 +4,15 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.level.block.Mirror;
|
||||
import net.minecraft.world.level.block.Rotation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockEntry;
|
||||
import nl.requios.effortlessbuilding.utilities.BlockSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RadialMirror extends BaseModifier {
|
||||
|
||||
public Vec3 position = new Vec3(0.5, 64.5, 0.5);
|
||||
@@ -120,11 +112,11 @@ public class RadialMirror extends BaseModifier {
|
||||
BlockState newBlockState = blockState;
|
||||
|
||||
if (startAngleToCenter < -0.751 * Math.PI || startAngleToCenter > 0.749 * Math.PI) {
|
||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.CLOCKWISE_180);
|
||||
newBlockState = blockState.rotate(player.level, startPos, Rotation.CLOCKWISE_180);
|
||||
} else if (startAngleToCenter < -0.251 * Math.PI) {
|
||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.COUNTERCLOCKWISE_90);
|
||||
newBlockState = blockState.rotate(player.level, startPos, Rotation.COUNTERCLOCKWISE_90);
|
||||
} else if (startAngleToCenter > 0.249 * Math.PI) {
|
||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.CLOCKWISE_90);
|
||||
newBlockState = blockState.rotate(player.level, startPos, Rotation.CLOCKWISE_90);
|
||||
}
|
||||
|
||||
return newBlockState;
|
||||
@@ -135,17 +127,17 @@ public class RadialMirror extends BaseModifier {
|
||||
double angleToCenter = Mth.atan2(relVec.x, relVec.z); //between -PI and PI
|
||||
|
||||
if (angleToCenter < -0.751 * Math.PI || angleToCenter > 0.749 * Math.PI) {
|
||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.CLOCKWISE_180);
|
||||
newBlockState = blockState.rotate(player.level, startPos, Rotation.CLOCKWISE_180);
|
||||
if (alternate) {
|
||||
newBlockState = newBlockState.mirror(Mirror.FRONT_BACK);
|
||||
}
|
||||
} else if (angleToCenter < -0.251 * Math.PI) {
|
||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.CLOCKWISE_90);
|
||||
newBlockState = blockState.rotate(player.level, startPos, Rotation.CLOCKWISE_90);
|
||||
if (alternate) {
|
||||
newBlockState = newBlockState.mirror(Mirror.LEFT_RIGHT);
|
||||
}
|
||||
} else if (angleToCenter > 0.249 * Math.PI) {
|
||||
newBlockState = blockState.rotate(player.level(), startPos, Rotation.COUNTERCLOCKWISE_90);
|
||||
newBlockState = blockState.rotate(player.level, startPos, Rotation.COUNTERCLOCKWISE_90);
|
||||
if (alternate) {
|
||||
newBlockState = newBlockState.mirror(Mirror.LEFT_RIGHT);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import nl.requios.effortlessbuilding.create.foundation.item.ItemHelper;
|
||||
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||
|
||||
|
||||
@@ -1,69 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.create;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
//@EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
|
||||
public class AllKeys {
|
||||
|
||||
// TOOL_MENU("toolmenu", GLFW.GLFW_KEY_LEFT_ALT),
|
||||
// ACTIVATE_TOOL("", GLFW.GLFW_KEY_LEFT_CONTROL),
|
||||
// TOOLBELT("toolbelt", GLFW.GLFW_KEY_LEFT_ALT),
|
||||
//
|
||||
// ;
|
||||
//
|
||||
// private KeyMapping keybind;
|
||||
// private String description;
|
||||
// private int key;
|
||||
// private boolean modifiable;
|
||||
//
|
||||
// private AllKeys(String description, int defaultKey) {
|
||||
// this.description = Create.ID + ".keyinfo." + description;
|
||||
// this.key = defaultKey;
|
||||
// this.modifiable = !description.isEmpty();
|
||||
// }
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public static void register(RegisterKeyMappingsEvent event) {
|
||||
// for (AllKeys key : values()) {
|
||||
// key.keybind = new KeyMapping(key.description, key.key, Create.NAME);
|
||||
// if (!key.modifiable)
|
||||
// continue;
|
||||
//
|
||||
// event.register(key.keybind);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public KeyMapping getKeybind() {
|
||||
// return keybind;
|
||||
// }
|
||||
//
|
||||
// public boolean isPressed() {
|
||||
// if (!modifiable)
|
||||
// return isKeyDown(key);
|
||||
// return keybind.isDown();
|
||||
// }
|
||||
//
|
||||
// public String getBoundKey() {
|
||||
// return keybind.getTranslatedKeyMessage()
|
||||
// .getString()
|
||||
// .toUpperCase();
|
||||
// }
|
||||
//
|
||||
// public int getBoundCode() {
|
||||
// return keybind.getKey()
|
||||
// .getValue();
|
||||
// }
|
||||
|
||||
public static boolean isKeyDown(int key) {
|
||||
return InputConstants.isKeyDown(Minecraft.getInstance()
|
||||
.getWindow()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.create;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public enum AllSpecialTextures {
|
||||
|
||||
@@ -2,7 +2,7 @@ package nl.requios.effortlessbuilding.create;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperByteBufferCache;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.ghost.GhostBlocks;
|
||||
import nl.requios.effortlessbuilding.create.foundation.outliner.Outliner;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.outliner.Outliner;
|
||||
|
||||
public class CreateClient {
|
||||
public static final SuperByteBufferCache BUFFER_CACHE = new SuperByteBufferCache();
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.create;
|
||||
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
|
||||
@Mod.EventBusSubscriber(Dist.CLIENT)
|
||||
public class CreateClientTest {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.events;
|
||||
package nl.requios.effortlessbuilding.create.events;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -13,13 +11,11 @@ import net.minecraftforge.client.event.RenderLevelStageEvent;
|
||||
import net.minecraftforge.client.event.ViewportEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.event.level.LevelEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
import nl.requios.effortlessbuilding.create.CreateClient;
|
||||
import nl.requios.effortlessbuilding.create.foundation.item.TooltipModifier;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.AnimationTickHolder;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.CameraAngleAnimationService;
|
||||
@@ -62,21 +58,23 @@ public class ClientEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRenderWorld(RenderLevelStageEvent event) {
|
||||
if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_PARTICLES)
|
||||
return;
|
||||
if(event.getStage() != RenderLevelStageEvent.Stage.AFTER_CUTOUT_BLOCKS) return;
|
||||
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera()
|
||||
.getPosition();
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
|
||||
PoseStack ms = event.getPoseStack();
|
||||
ms.pushPose();
|
||||
ms.translate(-cameraPos.x(), -cameraPos.y(), -cameraPos.z());
|
||||
SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance();
|
||||
float partialTicks = AnimationTickHolder.getPartialTicks();
|
||||
Vec3 camera = Minecraft.getInstance().gameRenderer.getMainCamera()
|
||||
.getPosition();
|
||||
|
||||
CreateClient.GHOST_BLOCKS.renderAll(ms, buffer, camera);
|
||||
CreateClient.OUTLINER.renderOutlines(ms, buffer, camera, partialTicks);
|
||||
CreateClient.GHOST_BLOCKS.renderAll(ms, buffer);
|
||||
|
||||
CreateClient.OUTLINER.renderOutlines(ms, buffer, pt);
|
||||
buffer.draw();
|
||||
RenderSystem.enableCull();
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
@@ -91,20 +89,6 @@ public class ClientEvents {
|
||||
event.setPitch(CameraAngleAnimationService.getPitch(partialTicks));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void addToItemTooltip(ItemTooltipEvent event) {
|
||||
// if (!AllConfigs.client().tooltips.get())
|
||||
// return;
|
||||
if (event.getEntity() == null)
|
||||
return;
|
||||
|
||||
Item item = event.getItemStack().getItem();
|
||||
TooltipModifier modifier = TooltipModifier.REGISTRY.get(item);
|
||||
if (modifier != null && modifier != TooltipModifier.EMPTY) {
|
||||
modifier.modify(event);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isGameActive() {
|
||||
return !(Minecraft.getInstance().level == null || Minecraft.getInstance().player == null);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package nl.requios.effortlessbuilding.create.events;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.event.level.LevelEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.WorldAttached;
|
||||
|
||||
@EventBusSubscriber
|
||||
public class CommonEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onUnloadWorld(LevelEvent.Unload event) {
|
||||
LevelAccessor world = event.getLevel();
|
||||
WorldAttached.invalidateWorld(world);
|
||||
}
|
||||
|
||||
|
||||
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD)
|
||||
public static class ModBusEvents {
|
||||
|
||||
// @SubscribeEvent
|
||||
// public static void addPackFinders(AddPackFindersEvent event) {
|
||||
// if (event.getPackType() == PackType.CLIENT_RESOURCES) {
|
||||
// IModFileInfo modFileInfo = ModList.get().getModFileById(Create.ID);
|
||||
// if (modFileInfo == null) {
|
||||
// Create.LOGGER.error("Could not find Create mod file info; built-in resource packs will be missing!");
|
||||
// return;
|
||||
// }
|
||||
// IModFile modFile = modFileInfo.getFile();
|
||||
// event.addRepositorySource((consumer, constructor) -> {
|
||||
// consumer.accept(Pack.create(Create.asResource("legacy_copper").toString(), false, () -> new ModFilePackResources("Create Legacy Copper", modFile, "resourcepacks/legacy_copper"), constructor, Pack.Position.TOP, PackSource.DEFAULT));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.CreateClient;
|
||||
//import nl.requios.effortlessbuilding.create.foundation.sound.SoundScapes;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.LangNumberFormat;
|
||||
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
|
||||
|
||||
@@ -11,7 +8,7 @@ public class ClientResourceReloadListener implements ResourceManagerReloadListen
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(ResourceManager resourceManager) {
|
||||
CreateClient.invalidateRenderers();
|
||||
// CreateClient.invalidateRenderers();
|
||||
// SoundScapes.invalidateAll();
|
||||
LangNumberFormat.numberFormat.update();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import net.minecraftforge.resource.PathPackResources;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ModFilePackResources extends PathPackResources {
|
||||
protected final IModFile modFile;
|
||||
protected final String sourcePath;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.events;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraftforge.event.level.LevelEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.WorldAttached;
|
||||
|
||||
@EventBusSubscriber
|
||||
public class CommonEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onUnloadWorld(LevelEvent.Unload event) {
|
||||
LevelAccessor world = event.getLevel();
|
||||
WorldAttached.invalidateWorld(world);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
@@ -18,6 +11,12 @@ import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import nl.requios.effortlessbuilding.gui.buildmodifier.ModifiersScreenList;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class AbstractSimiScreen extends Screen {
|
||||
@@ -105,18 +104,16 @@ public abstract class AbstractSimiScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
partialTicks = minecraft.getFrameTime();
|
||||
PoseStack ms = graphics.pose();
|
||||
|
||||
ms.pushPose();
|
||||
|
||||
prepareFrame();
|
||||
|
||||
renderWindowBackground(graphics, mouseX, mouseY, partialTicks);
|
||||
renderWindow(graphics, mouseX, mouseY, partialTicks);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
renderWindowForeground(graphics, mouseX, mouseY, partialTicks);
|
||||
renderWindowBackground(ms, mouseX, mouseY, partialTicks);
|
||||
renderWindow(ms, mouseX, mouseY, partialTicks);
|
||||
super.render(ms, mouseX, mouseY, partialTicks);
|
||||
renderWindowForeground(ms, mouseX, mouseY, partialTicks);
|
||||
|
||||
endFrame();
|
||||
|
||||
@@ -140,13 +137,13 @@ public abstract class AbstractSimiScreen extends Screen {
|
||||
|
||||
protected void prepareFrame() {}
|
||||
|
||||
protected void renderWindowBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
renderBackground(graphics);
|
||||
protected void renderWindowBackground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
renderBackground(ms);
|
||||
}
|
||||
|
||||
protected abstract void renderWindow(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks);
|
||||
protected abstract void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks);
|
||||
|
||||
protected void renderWindowForeground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
protected void renderWindowForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
for (Renderable widget : renderables) {
|
||||
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isMouseOver(mouseX, mouseY)
|
||||
&& simiWidget.visible) {
|
||||
@@ -155,7 +152,12 @@ public abstract class AbstractSimiScreen extends Screen {
|
||||
continue;
|
||||
int ttx = simiWidget.lockedTooltipX == -1 ? mouseX : simiWidget.lockedTooltipX + simiWidget.getX();
|
||||
int tty = simiWidget.lockedTooltipY == -1 ? mouseY : simiWidget.lockedTooltipY + simiWidget.getY();
|
||||
graphics.renderComponentTooltip(font, tooltip, ttx, tty);
|
||||
renderComponentTooltip(ms, tooltip, ttx, tty);
|
||||
}
|
||||
|
||||
//Added
|
||||
if (widget instanceof ModifiersScreenList list) {
|
||||
list.renderWindowForeground(ms, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,8 +165,8 @@ public abstract class AbstractSimiScreen extends Screen {
|
||||
protected void endFrame() {}
|
||||
|
||||
@Deprecated
|
||||
protected void debugWindowArea(GuiGraphics graphics) {
|
||||
graphics.fill(guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3);
|
||||
protected void debugWindowArea(PoseStack graphics) {
|
||||
fill(graphics, guiLeft + windowWidth, guiTop + windowHeight, guiLeft, guiTop, 0xD3D3D3D3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,164 +1,17 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public enum AllGuiTextures implements ScreenElement {
|
||||
|
||||
// Inventories
|
||||
// PLAYER_INVENTORY("player_inventory", 176, 108),
|
||||
// WAND_OF_SYMMETRY("curiosities", 0, 131, 188, 101),
|
||||
// BLOCKZAPPER("curiosities", 0, 99, 214, 97),
|
||||
// TERRAINZAPPER("curiosities", 234, 103),
|
||||
// TERRAINZAPPER_INACTIVE_PARAM("curiosities", 238, 0, 18, 18),
|
||||
//
|
||||
// LOGO("logo", 256, 256),
|
||||
// CURSEFORGE_LOGO("platform_icons/curseforge", 256, 256),
|
||||
// MODRINTH_LOGO("platform_icons/modrinth", 256, 256),
|
||||
//
|
||||
// SCHEMATIC("schematics", 192, 121),
|
||||
// SCHEMATIC_SLOT("widgets", 54, 0, 16, 16),
|
||||
// SCHEMATIC_PROMPT("schematics_2", 213, 77),
|
||||
// HUD_BACKGROUND("overlay", 0, 0, 16, 16),
|
||||
//
|
||||
// SCHEMATIC_TABLE("schematics", 0, 121, 214, 83),
|
||||
// SCHEMATIC_TABLE_PROGRESS("schematics", 0, 204, 84, 16),
|
||||
//
|
||||
// SCHEMATICANNON_TOP("schematics_2", 0, 77, 213, 42),
|
||||
// SCHEMATICANNON_BOTTOM("schematics_2", 0, 119, 213, 99),
|
||||
// SCHEMATICANNON_PROGRESS("schematics_2", 76, 239, 114, 16),
|
||||
// SCHEMATICANNON_CHECKLIST_PROGRESS("schematics_2", 191, 240, 16, 14),
|
||||
// SCHEMATICANNON_HIGHLIGHT("schematics_2", 1, 229, 26, 26),
|
||||
// SCHEMATICANNON_FUEL("schematics_2", 28, 222, 47, 16),
|
||||
// SCHEMATICANNON_FUEL_CREATIVE("schematics_2", 28, 239, 47, 16),
|
||||
//
|
||||
// STOCKSWITCH("logistics", 182, 95),
|
||||
// STOCKSWITCH_ARROW_UP("logistics", 191, 0, 7, 24),
|
||||
// STOCKSWITCH_ARROW_DOWN("logistics", 198, 0, 7, 24),
|
||||
// STOCKSWITCH_CURSOR("logistics", 206, 0, 7, 16),
|
||||
// STOCKSWITCH_INTERVAL("logistics", 0, 95, 100, 18),
|
||||
// STOCKSWITCH_UNPOWERED_LANE("logistics", 37, 20, 100, 18),
|
||||
// STOCKSWITCH_POWERED_LANE("logistics", 37, 42, 100, 18),
|
||||
//
|
||||
// FILTER("filters", 214, 99),
|
||||
// ATTRIBUTE_FILTER("filters", 0, 99, 241, 85),
|
||||
//
|
||||
// TOOLBOX("toolbox", 188, 171),
|
||||
// TOOLBELT_SLOT("minecraft", "widgets", 24, 23, 22, 22),
|
||||
// TOOLBELT_SLOT_HIGHLIGHT("minecraft", "widgets", 0, 22, 24, 24),
|
||||
// TOOLBELT_MAIN_SLOT("widgets", 0, 97, 24, 24),
|
||||
// TOOLBELT_EMPTY_SLOT("widgets", 27, 98, 22, 22),
|
||||
// TOOLBELT_INACTIVE_SLOT("widgets", 52, 98, 22, 22),
|
||||
//
|
||||
// TOOLBELT_HOTBAR_OFF("widgets", 0, 130, 20, 24),
|
||||
// TOOLBELT_HOTBAR_ON("widgets", 20, 130, 20, 24),
|
||||
// TOOLBELT_SELECTED_OFF("widgets", 0, 155, 22, 22),
|
||||
// TOOLBELT_SELECTED_ON("widgets", 22, 155, 22, 22),
|
||||
//
|
||||
// SEQUENCER("sequencer", 173, 161),
|
||||
// SEQUENCER_INSTRUCTION("sequencer", 0, 16, 162, 22),
|
||||
// SEQUENCER_DELAY("sequencer", 0, 60, 162, 22),
|
||||
// SEQUENCER_END("sequencer", 0, 82, 162, 22),
|
||||
// SEQUENCER_EMPTY("sequencer", 0, 104, 162, 22),
|
||||
// SEQUENCER_AWAIT("sequencer", 0, 162, 162, 22),
|
||||
//
|
||||
// LINKED_CONTROLLER("curiosities_2", 179, 109),
|
||||
// BLUEPRINT("curiosities_2", 0, 109, 179, 109),
|
||||
//
|
||||
// CLIPBOARD("clipboard", 0, 0, 256, 256),
|
||||
//
|
||||
// DATA_GATHERER("display_link", 235, 162),
|
||||
// DATA_AREA_START("display_link", 0, 163, 2, 18),
|
||||
// DATA_AREA_SPEECH("display_link", 8, 163, 5, 18),
|
||||
// DATA_AREA("display_link", 3, 163, 1, 18),
|
||||
// DATA_AREA_END("display_link", 5, 163, 2, 18),
|
||||
//
|
||||
// SCHEDULE("schedule", 256, 226),
|
||||
// SCHEDULE_CARD_DARK("schedule", 5, 233, 1, 1),
|
||||
// SCHEDULE_CARD_MEDIUM("schedule", 6, 233, 1, 1),
|
||||
// SCHEDULE_CARD_LIGHT("schedule", 7, 233, 1, 1),
|
||||
// SCHEDULE_CARD_MOVE_UP("schedule", 51, 230, 12, 12),
|
||||
// SCHEDULE_CARD_MOVE_DOWN("schedule", 65, 230, 12, 12),
|
||||
// SCHEDULE_CARD_REMOVE("schedule", 51, 243, 12, 12),
|
||||
// SCHEDULE_CARD_DUPLICATE("schedule", 65, 243, 12, 12),
|
||||
// SCHEDULE_CARD_NEW("schedule", 79, 239, 16, 16),
|
||||
// SCHEDULE_CONDITION_NEW("schedule", 96, 239, 19, 16),
|
||||
// SCHEDULE_CONDITION_LEFT("schedule", 116, 239, 6, 16),
|
||||
// SCHEDULE_CONDITION_LEFT_CLEAN("schedule", 147, 239, 2, 16),
|
||||
// SCHEDULE_CONDITION_MIDDLE("schedule", 123, 239, 1, 16),
|
||||
// SCHEDULE_CONDITION_ITEM("schedule", 125, 239, 18, 16),
|
||||
// SCHEDULE_CONDITION_RIGHT("schedule", 144, 239, 2, 16),
|
||||
// SCHEDULE_CONDITION_APPEND("schedule", 150, 245, 10, 10),
|
||||
// SCHEDULE_SCROLL_LEFT("schedule", 161, 247, 4, 8),
|
||||
// SCHEDULE_SCROLL_RIGHT("schedule", 166, 247, 4, 8),
|
||||
// SCHEDULE_STRIP_DARK("schedule", 5, 235, 3, 1),
|
||||
// SCHEDULE_STRIP_LIGHT("schedule", 5, 237, 3, 1),
|
||||
// SCHEDULE_STRIP_WAIT("schedule", 1, 239, 11, 16),
|
||||
// SCHEDULE_STRIP_TRAVEL("schedule", 12, 239, 11, 16),
|
||||
// SCHEDULE_STRIP_DOTTED("schedule", 23, 239, 11, 16),
|
||||
// SCHEDULE_STRIP_END("schedule", 34, 239, 11, 16),
|
||||
// SCHEDULE_STRIP_ACTION("schedule", 209, 239, 11, 16),
|
||||
// SCHEDULE_EDITOR("schedule_2", 256, 89),
|
||||
// SCHEDULE_EDITOR_ADDITIONAL_SLOT("schedule_2", 55, 47, 32, 18),
|
||||
// SCHEDULE_EDITOR_INACTIVE_SLOT("schedule_2", 0, 91, 18, 18),
|
||||
// SCHEDULE_POINTER("schedule", 185, 239, 21, 16),
|
||||
// SCHEDULE_POINTER_OFFSCREEN("schedule", 171, 239, 13, 16),
|
||||
//
|
||||
// STATION("schedule_2", 0, 111, 200, 127),
|
||||
// STATION_ASSEMBLING("assemble", 200, 178),
|
||||
// STATION_TEXTBOX_TOP("assemble", 1, 179, 150, 18),
|
||||
// STATION_TEXTBOX_MIDDLE("assemble", 1, 198, 150, 1),
|
||||
// STATION_TEXTBOX_BOTTOM("assemble", 1, 200, 150, 4),
|
||||
// STATION_TEXTBOX_SPEECH("assemble", 152, 179, 8, 6),
|
||||
// STATION_EDIT_NAME("schedule_2", 0, 239, 13, 13),
|
||||
// STATION_EDIT_TRAIN_NAME("schedule_2", 89, 239, 13, 13),
|
||||
// I_NEW_TRAIN("schedule_2", 14, 239, 24, 16),
|
||||
// I_DISASSEMBLE_TRAIN("schedule_2", 39, 239, 24, 16),
|
||||
// I_ASSEMBLE_TRAIN("schedule_2", 64, 239, 24, 16),
|
||||
//
|
||||
// ELEVATOR_CONTACT("display_link", 20, 172, 233, 82),
|
||||
//
|
||||
// BRASS_FRAME_TL("value_settings", 65, 9, 4, 4),
|
||||
// BRASS_FRAME_TR("value_settings", 70, 9, 4, 4),
|
||||
// BRASS_FRAME_BL("value_settings", 65, 19, 4, 4),
|
||||
// BRASS_FRAME_BR("value_settings", 70, 19, 4, 4),
|
||||
// BRASS_FRAME_LEFT("value_settings", 65, 14, 3, 4),
|
||||
// BRASS_FRAME_RIGHT("value_settings", 71, 14, 3, 4),
|
||||
// BRASS_FRAME_TOP("value_settings", 0, 24, 256, 3),
|
||||
// BRASS_FRAME_BOTTOM("value_settings", 0, 27, 256, 3),
|
||||
//
|
||||
// VALUE_SETTINGS_MILESTONE("value_settings", 0, 0, 7, 8),
|
||||
// VALUE_SETTINGS_WIDE_MILESTONE("value_settings", 75, 14, 13, 8),
|
||||
// VALUE_SETTINGS_BAR("value_settings", 7, 0, 249, 8),
|
||||
// VALUE_SETTINGS_BAR_BG("value_settings", 75, 9, 1, 1),
|
||||
// VALUE_SETTINGS_OUTER_BG("value_settings", 80, 9, 1, 1),
|
||||
// VALUE_SETTINGS_CURSOR_LEFT("value_settings", 0, 9, 3, 14),
|
||||
// VALUE_SETTINGS_CURSOR("value_settings", 4, 9, 56, 14),
|
||||
// VALUE_SETTINGS_CURSOR_RIGHT("value_settings", 61, 9, 3, 14),
|
||||
// VALUE_SETTINGS_CURSOR_ICON("value_settings", 0, 44, 22, 20),
|
||||
// VALUE_SETTINGS_LABEL_BG("value_settings", 0, 31, 81, 11),
|
||||
//
|
||||
// // JEI
|
||||
// JEI_SLOT("jei/widgets", 18, 18),
|
||||
// JEI_CHANCE_SLOT("jei/widgets", 20, 156, 18, 18),
|
||||
// JEI_CATALYST_SLOT("jei/widgets", 0, 156, 18, 18),
|
||||
// JEI_ARROW("jei/widgets", 19, 10, 42, 10),
|
||||
// JEI_LONG_ARROW("jei/widgets", 19, 0, 71, 10),
|
||||
// JEI_DOWN_ARROW("jei/widgets", 0, 21, 18, 14),
|
||||
// JEI_LIGHT("jei/widgets", 0, 42, 52, 11),
|
||||
// JEI_QUESTION_MARK("jei/widgets", 0, 178, 12, 16),
|
||||
// JEI_SHADOW("jei/widgets", 0, 56, 52, 11),
|
||||
// BLOCKZAPPER_UPGRADE_RECIPE("jei/widgets", 0, 75, 144, 66),
|
||||
// JEI_HEAT_BAR("jei/widgets", 0, 201, 169, 19),
|
||||
// JEI_NO_HEAT_BAR("jei/widgets", 0, 221, 169, 19),
|
||||
|
||||
// Widgets
|
||||
BUTTON("widgets", 18, 18),
|
||||
BUTTON_HOVER("widgets", 18, 0, 18, 18),
|
||||
@@ -177,21 +30,15 @@ public enum AllGuiTextures implements ScreenElement {
|
||||
SPEECH_TOOLTIP_BACKGROUND("widgets", 0, 24, 8, 8),
|
||||
SPEECH_TOOLTIP_COLOR("widgets", 8, 24, 8, 8),
|
||||
|
||||
// TRAIN_HUD_SPEED_BG("widgets", 0, 190, 182, 5),
|
||||
// TRAIN_HUD_SPEED("widgets", 0, 185, 182, 5),
|
||||
// TRAIN_HUD_THROTTLE("widgets", 0, 195, 182, 5),
|
||||
// TRAIN_HUD_THROTTLE_POINTER("widgets", 0, 209, 6, 9),
|
||||
// TRAIN_HUD_FRAME("widgets", 0, 200, 186, 7),
|
||||
// TRAIN_HUD_DIRECTION("widgets", 77, 165, 28, 20),
|
||||
// TRAIN_PROMPT_L("widgets", 8, 209, 3, 16),
|
||||
// TRAIN_PROMPT_R("widgets", 11, 209, 3, 16),
|
||||
// TRAIN_PROMPT("widgets", 0, 230, 256, 16),
|
||||
|
||||
// PlacementIndicator
|
||||
// PLACEMENT_INDICATOR_SHEET("placement_indicator", 0, 0, 16, 256),
|
||||
|
||||
// ComputerCraft
|
||||
// COMPUTER("computer", 200, 102);
|
||||
TRAIN_HUD_SPEED_BG("widgets", 0, 190, 182, 5),
|
||||
TRAIN_HUD_SPEED("widgets", 0, 185, 182, 5),
|
||||
TRAIN_HUD_THROTTLE("widgets", 0, 195, 182, 5),
|
||||
TRAIN_HUD_THROTTLE_POINTER("widgets", 0, 209, 6, 9),
|
||||
TRAIN_HUD_FRAME("widgets", 0, 200, 186, 7),
|
||||
TRAIN_HUD_DIRECTION("widgets", 77, 165, 28, 20),
|
||||
TRAIN_PROMPT_L("widgets", 8, 209, 3, 16),
|
||||
TRAIN_PROMPT_R("widgets", 11, 209, 3, 16),
|
||||
TRAIN_PROMPT("widgets", 0, 230, 256, 16),
|
||||
|
||||
;
|
||||
|
||||
@@ -226,15 +73,21 @@ public enum AllGuiTextures implements ScreenElement {
|
||||
RenderSystem.setShaderTexture(0, location);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(GuiGraphics graphics, int x, int y) {
|
||||
graphics.blit(location, x, y, startX, startY, width, height);
|
||||
public void render(PoseStack ms, int x, int y) {
|
||||
bind();
|
||||
GuiComponent.blit(ms, x, y, startX, startY, width, height);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(GuiGraphics graphics, int x, int y, Color c) {
|
||||
public void render(PoseStack ms, int x, int y, GuiComponent component) {
|
||||
bind();
|
||||
UIRenderHelper.drawColoredTexture(graphics, c, x, y, startX, startY, width, height);
|
||||
component.blit(ms, x, y, startX, startY, width, height);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void render(PoseStack ms, int x, int y, Color c) {
|
||||
bind();
|
||||
UIRenderHelper.drawColoredTexture(ms, c, x, y, startX, startY, width, height);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.DelegatedStencilElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@@ -18,10 +11,15 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.DelegatedStencilElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public class AllIcons implements ScreenElement {
|
||||
|
||||
public static final ResourceLocation ICON_ATLAS = Create.asResource("textures/gui/icons.png");
|
||||
public static final ResourceLocation ICON_ATLAS = Create.asResource("textures/gui/create_icons.png");
|
||||
public static final int ICON_ATLAS_SIZE = 256;
|
||||
|
||||
private static int x = 0, y = -1;
|
||||
@@ -105,10 +103,6 @@ public class AllIcons implements ScreenElement {
|
||||
|
||||
I_ADD_INVERTED_ATTRIBUTE = next(),
|
||||
I_FLIP = next(),
|
||||
|
||||
I_ROLLER_PAVE = next(),
|
||||
I_ROLLER_FILL = next(),
|
||||
I_ROLLER_WIDE_FILL = next(),
|
||||
|
||||
I_PLAY = newRow(),
|
||||
I_PAUSE = next(),
|
||||
@@ -128,14 +122,9 @@ public class AllIcons implements ScreenElement {
|
||||
I_PATTERN_CHANCE_75 = next(),
|
||||
I_FOLLOW_DIAGONAL = next(),
|
||||
I_FOLLOW_MATERIAL = next(),
|
||||
|
||||
I_CLEAR_CHECKED = next(),
|
||||
|
||||
I_SCHEMATIC = newRow(),
|
||||
I_SEQ_REPEAT = next(),
|
||||
VALUE_BOX_HOVER_6PX = next(),
|
||||
VALUE_BOX_HOVER_4PX = next(),
|
||||
VALUE_BOX_HOVER_8PX = next(),
|
||||
|
||||
I_MTD_LEFT = newRow(),
|
||||
I_MTD_CLOSE = next(),
|
||||
@@ -184,8 +173,9 @@ public class AllIcons implements ScreenElement {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int x, int y) {
|
||||
graphics.blit(ICON_ATLAS, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
||||
public void render(PoseStack ms, int x, int y) {
|
||||
bind();
|
||||
GuiComponent.blit(ms, x, y, 0, iconX, iconY, 16, 16, 256, 256);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.BoxElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.TextStencilElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.BoxWidget;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.BoxElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.TextStencilElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.BoxWidget;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ConfirmationScreen extends AbstractSimiScreen {
|
||||
|
||||
@@ -177,12 +173,11 @@ public class ConfirmationScreen extends AbstractSimiScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderWindow(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
textBackground.render(graphics);
|
||||
protected void renderWindow(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
textBackground.render(ms);
|
||||
int offset = font.lineHeight + 1;
|
||||
int lineY = y - offset;
|
||||
|
||||
PoseStack ms = graphics.pose();
|
||||
ms.pushPose();
|
||||
ms.translate(0, 0, 200);
|
||||
|
||||
@@ -190,21 +185,21 @@ public class ConfirmationScreen extends AbstractSimiScreen {
|
||||
lineY += offset;
|
||||
if (line == null)
|
||||
continue;
|
||||
graphics.drawString(font, line.getString(), x, lineY, 0xeaeaea, false);
|
||||
font.draw(ms, line.getString(), x, lineY, 0xeaeaea);
|
||||
}
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderWindowBackground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
protected void renderWindowBackground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
endFrame();
|
||||
|
||||
source.render(graphics, 0, 0, 10); // zero mouse coords to prevent further tooltips
|
||||
source.render(ms, 0, 0, 10); // zero mouse coords to prevent further tooltips
|
||||
|
||||
prepareFrame();
|
||||
|
||||
graphics.fillGradient(0, 0, this.width, this.height, 0x70101010, 0x80101010);
|
||||
fillGradient(ms, 0, 0, this.width, this.height, 0x70101010, 0x80101010);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.TooltipArea;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Pair;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class ModularGuiLine {
|
||||
|
||||
List<Pair<AbstractWidget, String>> widgets;
|
||||
List<Couple<Integer>> customBoxes;
|
||||
boolean speechBubble;
|
||||
|
||||
public ModularGuiLine() {
|
||||
widgets = new ArrayList<>();
|
||||
customBoxes = new ArrayList<>();
|
||||
speechBubble = false;
|
||||
}
|
||||
|
||||
public void renderWidgetBG(int guiLeft, GuiGraphics graphics) {
|
||||
boolean first = true;
|
||||
|
||||
if (!customBoxes.isEmpty()) {
|
||||
for (Couple<Integer> couple : customBoxes) {
|
||||
int x = couple.getFirst() + guiLeft;
|
||||
int width = couple.getSecond();
|
||||
box(graphics, x, width, first & speechBubble);
|
||||
first = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (Pair<AbstractWidget, String> pair : widgets) {
|
||||
if (pair.getSecond()
|
||||
.equals("Dummy"))
|
||||
continue;
|
||||
|
||||
AbstractWidget aw = pair.getFirst();
|
||||
int x = aw.getX();
|
||||
int width = aw.getWidth();
|
||||
|
||||
if (aw instanceof EditBox) {
|
||||
x -= 5;
|
||||
width += 9;
|
||||
}
|
||||
|
||||
box(graphics, x, width, first & speechBubble);
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void box(GuiGraphics graphics, int x, int width, boolean b) {
|
||||
// UIRenderHelper.drawStretched(graphics, x, 0, width, 18, 0, AllGuiTextures.DATA_AREA);
|
||||
// if (b)
|
||||
// AllGuiTextures.DATA_AREA_SPEECH.render(graphics, x - 3, 0);
|
||||
// else
|
||||
// AllGuiTextures.DATA_AREA_START.render(graphics, x, 0);
|
||||
// AllGuiTextures.DATA_AREA_END.render(graphics, x + width - 2, 0);
|
||||
}
|
||||
|
||||
public void saveValues(CompoundTag data) {
|
||||
for (Pair<AbstractWidget, String> pair : widgets) {
|
||||
AbstractWidget w = pair.getFirst();
|
||||
String key = pair.getSecond();
|
||||
if (w instanceof EditBox eb)
|
||||
data.putString(key, eb.getValue());
|
||||
if (w instanceof ScrollInput si)
|
||||
data.putInt(key, si.getState());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends GuiEventListener & Renderable & NarratableEntry> void loadValues(CompoundTag data,
|
||||
Consumer<T> addRenderable, Consumer<T> addRenderableOnly) {
|
||||
for (Pair<AbstractWidget, String> pair : widgets) {
|
||||
AbstractWidget w = pair.getFirst();
|
||||
String key = pair.getSecond();
|
||||
if (w instanceof EditBox eb)
|
||||
eb.setValue(data.getString(key));
|
||||
if (w instanceof ScrollInput si)
|
||||
si.setState(data.getInt(key));
|
||||
|
||||
if (w instanceof TooltipArea)
|
||||
addRenderableOnly.accept((T) w);
|
||||
else
|
||||
addRenderable.accept((T) w);
|
||||
}
|
||||
}
|
||||
|
||||
public void forEach(Consumer<GuiEventListener> callback) {
|
||||
widgets.forEach(p -> callback.accept(p.getFirst()));
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
widgets.clear();
|
||||
customBoxes.clear();
|
||||
}
|
||||
|
||||
public void add(Pair<AbstractWidget, String> pair) {
|
||||
widgets.add(pair);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.Label;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.ScrollInput;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.SelectionScrollInput;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.TooltipArea;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Pair;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
|
||||
public class ModularGuiLineBuilder {
|
||||
|
||||
private ModularGuiLine target;
|
||||
private Font font;
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
public ModularGuiLineBuilder(Font font, ModularGuiLine target, int x, int y) {
|
||||
this.font = font;
|
||||
this.target = target;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public ModularGuiLineBuilder addScrollInput(int x, int width, BiConsumer<ScrollInput, Label> inputTransform,
|
||||
String dataKey) {
|
||||
ScrollInput input = new ScrollInput(x + this.x, y - 4, width, 18);
|
||||
addScrollInput(input, inputTransform, dataKey);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModularGuiLineBuilder addSelectionScrollInput(int x, int width,
|
||||
BiConsumer<SelectionScrollInput, Label> inputTransform, String dataKey) {
|
||||
SelectionScrollInput input = new SelectionScrollInput(x + this.x, y - 4, width, 18);
|
||||
addScrollInput(input, inputTransform, dataKey);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModularGuiLineBuilder customArea(int x, int width) {
|
||||
target.customBoxes.add(Couple.create(x, width));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModularGuiLineBuilder speechBubble() {
|
||||
target.speechBubble = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
private <T extends ScrollInput> void addScrollInput(T input, BiConsumer<T, Label> inputTransform, String dataKey) {
|
||||
Label label = new Label(input.getX() + 5, y, Components.immutableEmpty());
|
||||
label.withShadow();
|
||||
inputTransform.accept(input, label);
|
||||
input.writingTo(label);
|
||||
target.add(Pair.of(label, "Dummy"));
|
||||
target.add(Pair.of(input, dataKey));
|
||||
}
|
||||
|
||||
public ModularGuiLineBuilder addIntegerTextInput(int x, int width, BiConsumer<EditBox, TooltipArea> inputTransform,
|
||||
String dataKey) {
|
||||
return addTextInput(x, width, inputTransform.andThen((editBox, $) -> editBox.setFilter(s -> {
|
||||
if (s.isEmpty())
|
||||
return true;
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
})), dataKey);
|
||||
}
|
||||
|
||||
public ModularGuiLineBuilder addTextInput(int x, int width, BiConsumer<EditBox, TooltipArea> inputTransform,
|
||||
String dataKey) {
|
||||
EditBox input = new EditBox(font, x + this.x + 5, y, width - 9, 8, Components.immutableEmpty());
|
||||
input.setBordered(false);
|
||||
input.setTextColor(0xffffff);
|
||||
input.setFocused(false);
|
||||
input.mouseClicked(0, 0, 0);
|
||||
TooltipArea tooltipArea = new TooltipArea(this.x + x, y - 4, width, 18);
|
||||
inputTransform.accept(input, tooltipArea);
|
||||
target.add(Pair.of(input, dataKey));
|
||||
target.add(Pair.of(tooltipArea, "Dummy"));
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,203 +1,202 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.client.extensions.IForgeGuiGraphics;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class RemovedGuiUtils {
|
||||
@Nonnull
|
||||
private static ItemStack cachedTooltipStack = ItemStack.EMPTY;
|
||||
|
||||
public static void preItemToolTip(@Nonnull ItemStack stack) {
|
||||
cachedTooltipStack = stack;
|
||||
}
|
||||
|
||||
public static void postItemToolTip() {
|
||||
cachedTooltipStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static void drawHoveringText(GuiGraphics graphics, List<? extends FormattedText> textLines, int mouseX,
|
||||
int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) {
|
||||
drawHoveringText(graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||
IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
||||
font);
|
||||
}
|
||||
|
||||
public static void drawHoveringText(GuiGraphics graphics, List<? extends FormattedText> textLines, int mouseX,
|
||||
int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart,
|
||||
int borderColorEnd, Font font) {
|
||||
drawHoveringText(cachedTooltipStack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||
backgroundColor, borderColorStart, borderColorEnd, font);
|
||||
}
|
||||
|
||||
public static void drawHoveringText(@Nonnull final ItemStack stack, GuiGraphics graphics,
|
||||
List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||
int maxTextWidth, Font font) {
|
||||
drawHoveringText(stack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||
IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
||||
font);
|
||||
}
|
||||
|
||||
public static void drawHoveringText(@Nonnull final ItemStack stack, GuiGraphics graphics,
|
||||
List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||
int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font) {
|
||||
if (textLines.isEmpty())
|
||||
return;
|
||||
|
||||
List<ClientTooltipComponent> list = ForgeHooksClient.gatherTooltipComponents(stack, textLines,
|
||||
stack.getTooltipImage(), mouseX, screenWidth, screenHeight, font);
|
||||
RenderTooltipEvent.Pre event =
|
||||
new RenderTooltipEvent.Pre(stack, graphics, mouseX, mouseY, screenWidth, screenHeight, font, list, null);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return;
|
||||
|
||||
PoseStack pStack = graphics.pose();
|
||||
|
||||
mouseX = event.getX();
|
||||
mouseY = event.getY();
|
||||
screenWidth = event.getScreenWidth();
|
||||
screenHeight = event.getScreenHeight();
|
||||
font = event.getFont();
|
||||
|
||||
// RenderSystem.disableRescaleNormal();
|
||||
RenderSystem.disableDepthTest();
|
||||
int tooltipTextWidth = 0;
|
||||
|
||||
for (FormattedText textLine : textLines) {
|
||||
int textLineWidth = font.width(textLine);
|
||||
if (textLineWidth > tooltipTextWidth)
|
||||
tooltipTextWidth = textLineWidth;
|
||||
}
|
||||
|
||||
boolean needsWrap = false;
|
||||
|
||||
int titleLinesCount = 1;
|
||||
int tooltipX = mouseX + 12;
|
||||
if (tooltipX + tooltipTextWidth + 4 > screenWidth) {
|
||||
tooltipX = mouseX - 16 - tooltipTextWidth;
|
||||
if (tooltipX < 4) // if the tooltip doesn't fit on the screen
|
||||
{
|
||||
if (mouseX > screenWidth / 2)
|
||||
tooltipTextWidth = mouseX - 12 - 8;
|
||||
else
|
||||
tooltipTextWidth = screenWidth - 16 - mouseX;
|
||||
needsWrap = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) {
|
||||
tooltipTextWidth = maxTextWidth;
|
||||
needsWrap = true;
|
||||
}
|
||||
|
||||
if (needsWrap) {
|
||||
int wrappedTooltipWidth = 0;
|
||||
List<FormattedText> wrappedTextLines = new ArrayList<>();
|
||||
for (int i = 0; i < textLines.size(); i++) {
|
||||
FormattedText textLine = textLines.get(i);
|
||||
List<FormattedText> wrappedLine = font.getSplitter()
|
||||
.splitLines(textLine, tooltipTextWidth, Style.EMPTY);
|
||||
if (i == 0)
|
||||
titleLinesCount = wrappedLine.size();
|
||||
|
||||
for (FormattedText line : wrappedLine) {
|
||||
int lineWidth = font.width(line);
|
||||
if (lineWidth > wrappedTooltipWidth)
|
||||
wrappedTooltipWidth = lineWidth;
|
||||
wrappedTextLines.add(line);
|
||||
}
|
||||
}
|
||||
tooltipTextWidth = wrappedTooltipWidth;
|
||||
textLines = wrappedTextLines;
|
||||
|
||||
if (mouseX > screenWidth / 2)
|
||||
tooltipX = mouseX - 16 - tooltipTextWidth;
|
||||
else
|
||||
tooltipX = mouseX + 12;
|
||||
}
|
||||
|
||||
int tooltipY = mouseY - 12;
|
||||
int tooltipHeight = 8;
|
||||
|
||||
if (textLines.size() > 1) {
|
||||
tooltipHeight += (textLines.size() - 1) * 10;
|
||||
if (textLines.size() > titleLinesCount)
|
||||
tooltipHeight += 2; // gap between title lines and next lines
|
||||
}
|
||||
|
||||
if (tooltipY < 4)
|
||||
tooltipY = 4;
|
||||
else if (tooltipY + tooltipHeight + 4 > screenHeight)
|
||||
tooltipY = screenHeight - tooltipHeight - 4;
|
||||
|
||||
final int zLevel = 400;
|
||||
RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, graphics, tooltipX, tooltipY,
|
||||
font, backgroundColor, borderColorStart, borderColorEnd, list);
|
||||
MinecraftForge.EVENT_BUS.post(colorEvent);
|
||||
backgroundColor = colorEvent.getBackgroundStart();
|
||||
borderColorStart = colorEvent.getBorderStart();
|
||||
borderColorEnd = colorEvent.getBorderEnd();
|
||||
|
||||
pStack.pushPose();
|
||||
Matrix4f mat = pStack.last()
|
||||
.pose();
|
||||
graphics.fillGradient(tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3,
|
||||
tooltipY - 3, zLevel, backgroundColor, backgroundColor);
|
||||
graphics.fillGradient(tooltipX - 3, tooltipY + tooltipHeight + 3,
|
||||
tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, zLevel, backgroundColor, backgroundColor);
|
||||
graphics.fillGradient(tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3,
|
||||
tooltipY + tooltipHeight + 3, zLevel, backgroundColor, backgroundColor);
|
||||
graphics.fillGradient(tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3,
|
||||
zLevel, backgroundColor, backgroundColor);
|
||||
graphics.fillGradient(tooltipX + tooltipTextWidth + 3, tooltipY - 3,
|
||||
tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, zLevel, backgroundColor, backgroundColor);
|
||||
graphics.fillGradient(tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1,
|
||||
tooltipY + tooltipHeight + 3 - 1, zLevel, borderColorStart, borderColorEnd);
|
||||
graphics.fillGradient(tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1,
|
||||
tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, zLevel, borderColorStart, borderColorEnd);
|
||||
graphics.fillGradient(tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3,
|
||||
tooltipY - 3 + 1, zLevel, borderColorStart, borderColorStart);
|
||||
graphics.fillGradient(tooltipX - 3, tooltipY + tooltipHeight + 2,
|
||||
tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, zLevel, borderColorEnd, borderColorEnd);
|
||||
|
||||
MultiBufferSource.BufferSource renderType = MultiBufferSource.immediate(Tesselator.getInstance()
|
||||
.getBuilder());
|
||||
pStack.translate(0.0D, 0.0D, zLevel);
|
||||
|
||||
for (int lineNumber = 0; lineNumber < list.size(); ++lineNumber) {
|
||||
ClientTooltipComponent line = list.get(lineNumber);
|
||||
|
||||
if (line != null)
|
||||
line.renderText(font, tooltipX, tooltipY, mat, renderType);
|
||||
|
||||
if (lineNumber + 1 == titleLinesCount)
|
||||
tooltipY += 2;
|
||||
|
||||
tooltipY += 10;
|
||||
}
|
||||
|
||||
renderType.endBatch();
|
||||
pStack.popPose();
|
||||
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
}
|
||||
//package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//import javax.annotation.Nonnull;
|
||||
//
|
||||
//import net.minecraft.client.gui.GuiComponent;
|
||||
//import org.joml.Matrix4f;
|
||||
//
|
||||
//import com.mojang.blaze3d.systems.RenderSystem;
|
||||
//import com.mojang.blaze3d.vertex.PoseStack;
|
||||
//import com.mojang.blaze3d.vertex.Tesselator;
|
||||
//
|
||||
//import net.minecraft.client.gui.Font;
|
||||
//import com.mojang.blaze3d.vertex.PoseStack;
|
||||
//import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
//import net.minecraft.client.renderer.MultiBufferSource;
|
||||
//import net.minecraft.network.chat.FormattedText;
|
||||
//import net.minecraft.network.chat.Style;
|
||||
//import net.minecraft.world.item.ItemStack;
|
||||
//import net.minecraftforge.client.ForgeHooksClient;
|
||||
//import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
//import net.minecraftforge.client.extensions.IForgeGuiGraphics;
|
||||
//import net.minecraftforge.common.MinecraftForge;
|
||||
//
|
||||
//public class RemovedGuiUtils {
|
||||
// @Nonnull
|
||||
// private static ItemStack cachedTooltipStack = ItemStack.EMPTY;
|
||||
//
|
||||
// public static void preItemToolTip(@Nonnull ItemStack stack) {
|
||||
// cachedTooltipStack = stack;
|
||||
// }
|
||||
//
|
||||
// public static void postItemToolTip() {
|
||||
// cachedTooltipStack = ItemStack.EMPTY;
|
||||
// }
|
||||
//
|
||||
// public static void drawHoveringText(PoseStack graphics, List<? extends FormattedText> textLines, int mouseX,
|
||||
// int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) {
|
||||
// drawHoveringText(graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||
// IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
||||
// font);
|
||||
// }
|
||||
//
|
||||
// public static void drawHoveringText(PoseStack graphics, List<? extends FormattedText> textLines, int mouseX,
|
||||
// int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart,
|
||||
// int borderColorEnd, Font font) {
|
||||
// drawHoveringText(cachedTooltipStack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||
// backgroundColor, borderColorStart, borderColorEnd, font);
|
||||
// }
|
||||
//
|
||||
// public static void drawHoveringText(@Nonnull final ItemStack stack, PoseStack graphics,
|
||||
// List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||
// int maxTextWidth, Font font) {
|
||||
// drawHoveringText(stack, graphics, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth,
|
||||
// IForgeGuiGraphics.DEFAULT_BACKGROUND_COLOR, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_START, IForgeGuiGraphics.DEFAULT_BORDER_COLOR_END,
|
||||
// font);
|
||||
// }
|
||||
//
|
||||
// public static void drawHoveringText(@Nonnull final ItemStack stack, PoseStack pStack,
|
||||
// List<? extends FormattedText> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
|
||||
// int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font) {
|
||||
// if (textLines.isEmpty())
|
||||
// return;
|
||||
//
|
||||
// List<ClientTooltipComponent> list = ForgeHooksClient.gatherTooltipComponents(stack, textLines,
|
||||
// stack.getTooltipImage(), mouseX, screenWidth, screenHeight, font);
|
||||
// RenderTooltipEvent.Pre event =
|
||||
// new RenderTooltipEvent.Pre(stack, pStack, mouseX, mouseY, screenWidth, screenHeight, font, list, null);
|
||||
// if (MinecraftForge.EVENT_BUS.post(event))
|
||||
// return;
|
||||
//
|
||||
// mouseX = event.getX();
|
||||
// mouseY = event.getY();
|
||||
// screenWidth = event.getScreenWidth();
|
||||
// screenHeight = event.getScreenHeight();
|
||||
// font = event.getFont();
|
||||
//
|
||||
// // RenderSystem.disableRescaleNormal();
|
||||
// RenderSystem.disableDepthTest();
|
||||
// int tooltipTextWidth = 0;
|
||||
//
|
||||
// for (FormattedText textLine : textLines) {
|
||||
// int textLineWidth = font.width(textLine);
|
||||
// if (textLineWidth > tooltipTextWidth)
|
||||
// tooltipTextWidth = textLineWidth;
|
||||
// }
|
||||
//
|
||||
// boolean needsWrap = false;
|
||||
//
|
||||
// int titleLinesCount = 1;
|
||||
// int tooltipX = mouseX + 12;
|
||||
// if (tooltipX + tooltipTextWidth + 4 > screenWidth) {
|
||||
// tooltipX = mouseX - 16 - tooltipTextWidth;
|
||||
// if (tooltipX < 4) // if the tooltip doesn't fit on the screen
|
||||
// {
|
||||
// if (mouseX > screenWidth / 2)
|
||||
// tooltipTextWidth = mouseX - 12 - 8;
|
||||
// else
|
||||
// tooltipTextWidth = screenWidth - 16 - mouseX;
|
||||
// needsWrap = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) {
|
||||
// tooltipTextWidth = maxTextWidth;
|
||||
// needsWrap = true;
|
||||
// }
|
||||
//
|
||||
// if (needsWrap) {
|
||||
// int wrappedTooltipWidth = 0;
|
||||
// List<FormattedText> wrappedTextLines = new ArrayList<>();
|
||||
// for (int i = 0; i < textLines.size(); i++) {
|
||||
// FormattedText textLine = textLines.get(i);
|
||||
// List<FormattedText> wrappedLine = font.getSplitter()
|
||||
// .splitLines(textLine, tooltipTextWidth, Style.EMPTY);
|
||||
// if (i == 0)
|
||||
// titleLinesCount = wrappedLine.size();
|
||||
//
|
||||
// for (FormattedText line : wrappedLine) {
|
||||
// int lineWidth = font.width(line);
|
||||
// if (lineWidth > wrappedTooltipWidth)
|
||||
// wrappedTooltipWidth = lineWidth;
|
||||
// wrappedTextLines.add(line);
|
||||
// }
|
||||
// }
|
||||
// tooltipTextWidth = wrappedTooltipWidth;
|
||||
// textLines = wrappedTextLines;
|
||||
//
|
||||
// if (mouseX > screenWidth / 2)
|
||||
// tooltipX = mouseX - 16 - tooltipTextWidth;
|
||||
// else
|
||||
// tooltipX = mouseX + 12;
|
||||
// }
|
||||
//
|
||||
// int tooltipY = mouseY - 12;
|
||||
// int tooltipHeight = 8;
|
||||
//
|
||||
// if (textLines.size() > 1) {
|
||||
// tooltipHeight += (textLines.size() - 1) * 10;
|
||||
// if (textLines.size() > titleLinesCount)
|
||||
// tooltipHeight += 2; // gap between title lines and next lines
|
||||
// }
|
||||
//
|
||||
// if (tooltipY < 4)
|
||||
// tooltipY = 4;
|
||||
// else if (tooltipY + tooltipHeight + 4 > screenHeight)
|
||||
// tooltipY = screenHeight - tooltipHeight - 4;
|
||||
//
|
||||
// final int zLevel = 400;
|
||||
// RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, pStack, tooltipX, tooltipY,
|
||||
// font, backgroundColor, borderColorStart, borderColorEnd, list);
|
||||
// MinecraftForge.EVENT_BUS.post(colorEvent);
|
||||
// backgroundColor = colorEvent.getBackgroundStart();
|
||||
// borderColorStart = colorEvent.getBorderStart();
|
||||
// borderColorEnd = colorEvent.getBorderEnd();
|
||||
//
|
||||
// pStack.pushPose();
|
||||
// Matrix4f mat = pStack.last()
|
||||
// .pose();
|
||||
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3,
|
||||
// tooltipY - 3, zLevel, backgroundColor, backgroundColor);
|
||||
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY + tooltipHeight + 3,
|
||||
// tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, zLevel, backgroundColor, backgroundColor);
|
||||
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3,
|
||||
// tooltipY + tooltipHeight + 3, zLevel, backgroundColor, backgroundColor);
|
||||
// GuiComponent.fillGradient(pStack, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3,
|
||||
// zLevel, backgroundColor, backgroundColor);
|
||||
// GuiComponent.fillGradient(pStack, tooltipX + tooltipTextWidth + 3, tooltipY - 3,
|
||||
// tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, zLevel, backgroundColor, backgroundColor);
|
||||
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1,
|
||||
// tooltipY + tooltipHeight + 3 - 1, zLevel, borderColorStart, borderColorEnd);
|
||||
// GuiComponent.fillGradient(pStack, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1,
|
||||
// tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, zLevel, borderColorStart, borderColorEnd);
|
||||
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3,
|
||||
// tooltipY - 3 + 1, zLevel, borderColorStart, borderColorStart);
|
||||
// GuiComponent.fillGradient(pStack, tooltipX - 3, tooltipY + tooltipHeight + 2,
|
||||
// tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, zLevel, borderColorEnd, borderColorEnd);
|
||||
//
|
||||
// MultiBufferSource.BufferSource renderType = MultiBufferSource.immediate(Tesselator.getInstance()
|
||||
// .getBuilder());
|
||||
// pStack.translate(0.0D, 0.0D, zLevel);
|
||||
//
|
||||
// for (int lineNumber = 0; lineNumber < list.size(); ++lineNumber) {
|
||||
// ClientTooltipComponent line = list.get(lineNumber);
|
||||
//
|
||||
// if (line != null)
|
||||
// line.renderText(font, tooltipX, tooltipY, mat, renderType);
|
||||
//
|
||||
// if (lineNumber + 1 == titleLinesCount)
|
||||
// tooltipY += 2;
|
||||
//
|
||||
// tooltipY += 10;
|
||||
// }
|
||||
//
|
||||
// renderType.endBatch();
|
||||
// pStack.popPose();
|
||||
//
|
||||
// RenderSystem.enableDepthTest();
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class Theme {
|
||||
|
||||
private static final List<Theme> THEMES = new ArrayList<>();
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||
import com.mojang.blaze3d.platform.GlConst;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
@@ -15,12 +11,14 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraftforge.client.gui.ScreenUtils;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
public class UIRenderHelper {
|
||||
|
||||
@@ -57,14 +55,14 @@ public class UIRenderHelper {
|
||||
GlStateManager._glBindFramebuffer(GlConst.GL_FRAMEBUFFER, dst.frameBufferId);
|
||||
}
|
||||
|
||||
public static void streak(GuiGraphics graphics, float angle, int x, int y, int breadth, int length) {
|
||||
streak(graphics, angle, x, y, breadth, length, Theme.i(Theme.Key.STREAK));
|
||||
public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length) {
|
||||
streak(ms, angle, x, y, breadth, length, Theme.i(Theme.Key.STREAK));
|
||||
}
|
||||
// angle in degrees; 0° -> fading to the right
|
||||
// x and y specify the middle point of the starting edge
|
||||
// breadth is the total width of the streak
|
||||
|
||||
public static void streak(GuiGraphics graphics, float angle, int x, int y, int breadth, int length, int color) {
|
||||
public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length, int color) {
|
||||
int a1 = 0xa0 << 24;
|
||||
int a2 = 0x80 << 24;
|
||||
int a3 = 0x10 << 24;
|
||||
@@ -76,60 +74,59 @@ public class UIRenderHelper {
|
||||
int c3 = a3 | color;
|
||||
int c4 = a4 | color;
|
||||
|
||||
PoseStack ms = graphics.pose();
|
||||
ms.pushPose();
|
||||
ms.translate(x, y, 0);
|
||||
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
||||
|
||||
streak(graphics, breadth / 2, length, c1, c2, c3, c4);
|
||||
streak(ms, breadth / 2, length, c1, c2, c3, c4);
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
public static void streak(GuiGraphics graphics, float angle, int x, int y, int breadth, int length, Color c) {
|
||||
public static void streak(PoseStack ms, float angle, int x, int y, int breadth, int length, Color c) {
|
||||
Color color = c.copy().setImmutable();
|
||||
int c1 = color.scaleAlpha(0.625f).getRGB();
|
||||
int c2 = color.scaleAlpha(0.5f).getRGB();
|
||||
int c3 = color.scaleAlpha(0.0625f).getRGB();
|
||||
int c4 = color.scaleAlpha(0f).getRGB();
|
||||
|
||||
PoseStack ms = graphics.pose();
|
||||
ms.pushPose();
|
||||
ms.translate(x, y, 0);
|
||||
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
||||
|
||||
streak(graphics, breadth / 2, length, c1, c2, c3, c4);
|
||||
streak(ms, breadth / 2, length, c1, c2, c3, c4);
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
private static void streak(GuiGraphics graphics, int width, int height, int c1, int c2, int c3, int c4) {
|
||||
private static void streak(PoseStack ms, int width, int height, int c1, int c2, int c3, int c4) {
|
||||
double split1 = .5;
|
||||
double split2 = .75;
|
||||
graphics.fillGradient(-width, 0, width, (int) (split1 * height), 0, c1, c2);
|
||||
graphics.fillGradient(-width, (int) (split1 * height), width, (int) (split2 * height), 0, c2, c3);
|
||||
graphics.fillGradient(-width, (int) (split2 * height), width, height, 0, c3, c4);
|
||||
Matrix4f model = ms.last().pose();
|
||||
ScreenUtils.drawGradientRect(model, -width, 0, width, (int) (split1 * height), 0, c1, c2);
|
||||
ScreenUtils.drawGradientRect(model, -width, (int) (split1 * height), width, (int) (split2 * height), 0, c2, c3);
|
||||
ScreenUtils.drawGradientRect(model, -width, (int) (split2 * height), width, height, 0, c3, c4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color)
|
||||
* @see #angledGradient(PoseStack, float, int, int, int, int, int, Color, Color)
|
||||
*/
|
||||
public static void angledGradient(GuiGraphics graphics, float angle, int x, int y, int breadth, int length, Couple<Color> c) {
|
||||
angledGradient(graphics, angle, x, y, 0, breadth, length, c);
|
||||
public static void angledGradient(PoseStack ms, float angle, int x, int y, int breadth, int length, Couple<Color> c) {
|
||||
angledGradient(ms, angle, x, y, 0, breadth, length, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color)
|
||||
* @see #angledGradient(PoseStack, float, int, int, int, int, int, Color, Color)
|
||||
*/
|
||||
public static void angledGradient(GuiGraphics graphics, float angle, int x, int y, int z, int breadth, int length, Couple<Color> c) {
|
||||
angledGradient(graphics, angle, x, y, z, breadth, length, c.getFirst(), c.getSecond());
|
||||
public static void angledGradient(PoseStack ms, float angle, int x, int y, int z, int breadth, int length, Couple<Color> c) {
|
||||
angledGradient(ms, angle, x, y, z, breadth, length, c.getFirst(), c.getSecond());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #angledGradient(MatrixStack, float, int, int, int, int, int, Color, Color)
|
||||
* @see #angledGradient(PoseStack, float, int, int, int, int, int, Color, Color)
|
||||
*/
|
||||
public static void angledGradient(GuiGraphics graphics, float angle, int x, int y, int breadth, int length, Color color1, Color color2) {
|
||||
angledGradient(graphics, angle, x, y, 0, breadth, length, color1, color2);
|
||||
public static void angledGradient(PoseStack ms, float angle, int x, int y, int breadth, int length, Color color1, Color color2) {
|
||||
angledGradient(ms, angle, x, y, 0, breadth, length, color1, color2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,32 +137,31 @@ public class UIRenderHelper {
|
||||
* @param color2 the color at the ending edge
|
||||
* @param breadth the total width of the gradient
|
||||
*/
|
||||
public static void angledGradient(GuiGraphics graphics, float angle, int x, int y, int z, int breadth, int length, Color color1, Color color2) {
|
||||
PoseStack ms = graphics.pose();
|
||||
public static void angledGradient(PoseStack ms, float angle, int x, int y, int z, int breadth, int length, Color color1, Color color2) {
|
||||
ms.pushPose();
|
||||
ms.translate(x, y, z);
|
||||
ms.mulPose(Axis.ZP.rotationDegrees(angle - 90));
|
||||
|
||||
int w = breadth / 2;
|
||||
graphics.fillGradient(-w, 0, w, length, 0, color1.getRGB(), color2.getRGB());
|
||||
Matrix4f model = ms.last().pose();
|
||||
ScreenUtils.drawGradientRect(model, -w, 0, w, length, 0, color1.getRGB(), color2.getRGB());
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
public static void breadcrumbArrow(GuiGraphics graphics, int x, int y, int z, int width, int height, int indent, Couple<Color> colors) {breadcrumbArrow(graphics, x, y, z, width, height, indent, colors.getFirst(), colors.getSecond());}
|
||||
public static void breadcrumbArrow(PoseStack ms, int x, int y, int z, int width, int height, int indent, Couple<Color> colors) {breadcrumbArrow(ms, x, y, z, width, height, indent, colors.getFirst(), colors.getSecond());}
|
||||
|
||||
// draws a wide chevron-style breadcrumb arrow pointing left
|
||||
public static void breadcrumbArrow(GuiGraphics graphics, int x, int y, int z, int width, int height, int indent, Color startColor, Color endColor) {
|
||||
PoseStack matrixStack = graphics.pose();
|
||||
matrixStack.pushPose();
|
||||
matrixStack.translate(x - indent, y, z);
|
||||
public static void breadcrumbArrow(PoseStack ms, int x, int y, int z, int width, int height, int indent, Color startColor, Color endColor) {
|
||||
ms.pushPose();
|
||||
ms.translate(x - indent, y, z);
|
||||
|
||||
breadcrumbArrow(graphics, width, height, indent, startColor, endColor);
|
||||
breadcrumbArrow(ms, width, height, indent, startColor, endColor);
|
||||
|
||||
matrixStack.popPose();
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
private static void breadcrumbArrow(GuiGraphics graphics, int width, int height, int indent, Color c1, Color c2) {
|
||||
private static void breadcrumbArrow(PoseStack ms, int width, int height, int indent, Color c1, Color c2) {
|
||||
|
||||
/*
|
||||
* 0,0 x1,y1 ********************* x4,y4 ***** x7,y7
|
||||
@@ -203,7 +199,7 @@ public class UIRenderHelper {
|
||||
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
BufferBuilder bufferbuilder = tessellator.getBuilder();
|
||||
Matrix4f model = graphics.pose().last().pose();
|
||||
Matrix4f model = ms.last().pose();
|
||||
bufferbuilder.begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION_COLOR);
|
||||
|
||||
bufferbuilder.vertex(model, x0, y0, 0).color(fc1.getRed(), fc1.getGreen(), fc1.getBlue(), fc1.getAlpha()).endVertex();
|
||||
@@ -237,30 +233,30 @@ public class UIRenderHelper {
|
||||
}
|
||||
|
||||
//just like AbstractGui#drawTexture, but with a color at every vertex
|
||||
public static void drawColoredTexture(GuiGraphics graphics, Color c, int x, int y, int tex_left, int tex_top, int width, int height) {
|
||||
drawColoredTexture(graphics, c, x, y, 0, (float) tex_left, (float) tex_top, width, height, 256, 256);
|
||||
public static void drawColoredTexture(PoseStack ms, Color c, int x, int y, int tex_left, int tex_top, int width, int height) {
|
||||
drawColoredTexture(ms, c, x, y, 0, (float) tex_left, (float) tex_top, width, height, 256, 256);
|
||||
}
|
||||
|
||||
public static void drawColoredTexture(GuiGraphics graphics, Color c, int x, int y, int z, float tex_left, float tex_top, int width, int height, int sheet_width, int sheet_height) {
|
||||
drawColoredTexture(graphics, c, x, x + width, y, y + height, z, width, height, tex_left, tex_top, sheet_width, sheet_height);
|
||||
public static void drawColoredTexture(PoseStack ms, Color c, int x, int y, int z, float tex_left, float tex_top, int width, int height, int sheet_width, int sheet_height) {
|
||||
drawColoredTexture(ms, c, x, x + width, y, y + height, z, width, height, tex_left, tex_top, sheet_width, sheet_height);
|
||||
}
|
||||
|
||||
public static void drawStretched(GuiGraphics graphics, int left, int top, int w, int h, int z, AllGuiTextures tex) {
|
||||
public static void drawStretched(PoseStack ms, int left, int top, int w, int h, int z, AllGuiTextures tex) {
|
||||
tex.bind();
|
||||
drawTexturedQuad(graphics.pose().last()
|
||||
drawTexturedQuad(ms.last()
|
||||
.pose(), Color.WHITE, left, left + w, top, top + h, z, tex.startX / 256f, (tex.startX + tex.width) / 256f,
|
||||
tex.startY / 256f, (tex.startY + tex.height) / 256f);
|
||||
}
|
||||
|
||||
public static void drawCropped(GuiGraphics graphics, int left, int top, int w, int h, int z, AllGuiTextures tex) {
|
||||
public static void drawCropped(PoseStack ms, int left, int top, int w, int h, int z, AllGuiTextures tex) {
|
||||
tex.bind();
|
||||
drawTexturedQuad(graphics.pose().last()
|
||||
drawTexturedQuad(ms.last()
|
||||
.pose(), Color.WHITE, left, left + w, top, top + h, z, tex.startX / 256f, (tex.startX + w) / 256f,
|
||||
tex.startY / 256f, (tex.startY + h) / 256f);
|
||||
}
|
||||
|
||||
private static void drawColoredTexture(GuiGraphics graphics, Color c, int left, int right, int top, int bot, int z, int tex_width, int tex_height, float tex_left, float tex_top, int sheet_width, int sheet_height) {
|
||||
drawTexturedQuad(graphics.pose().last().pose(), c, left, right, top, bot, z, (tex_left + 0.0F) / (float) sheet_width, (tex_left + (float) tex_width) / (float) sheet_width, (tex_top + 0.0F) / (float) sheet_height, (tex_top + (float) tex_height) / (float) sheet_height);
|
||||
private static void drawColoredTexture(PoseStack ms, Color c, int left, int right, int top, int bot, int z, int tex_width, int tex_height, float tex_left, float tex_top, int sheet_width, int sheet_height) {
|
||||
drawTexturedQuad(ms.last().pose(), c, left, right, top, bot, z, (tex_left + 0.0F) / (float) sheet_width, (tex_left + (float) tex_width) / (float) sheet_width, (tex_top + 0.0F) / (float) sheet_height, (tex_top + (float) tex_height) / (float) sheet_height);
|
||||
}
|
||||
|
||||
private static void drawTexturedQuad(Matrix4f m, Color c, int left, int right, int top, int bot, int z, float u1, float u2, float v1, float v2) {
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.TickableGuiEventListener;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
@@ -25,6 +15,13 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.TickableGuiEventListener;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.widget.AbstractSimiWidget;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@ParametersAreNonnullByDefault
|
||||
@@ -94,26 +91,26 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
partialTicks = minecraft.getFrameTime();
|
||||
|
||||
renderBackground(graphics);
|
||||
renderBackground(ms);
|
||||
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
super.render(ms, mouseX, mouseY, partialTicks);
|
||||
|
||||
renderForeground(graphics, mouseX, mouseY, partialTicks);
|
||||
renderForeground(ms, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
protected void renderLabels(PoseStack ms, int mouseX, int mouseY) {
|
||||
// no-op to prevent screen- and inventory-title from being rendered at incorrect
|
||||
// location
|
||||
// could also set this.titleX/Y and this.playerInventoryTitleX/Y to the proper
|
||||
// values instead
|
||||
}
|
||||
|
||||
protected void renderForeground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
renderTooltip(graphics, mouseX, mouseY);
|
||||
protected void renderForeground(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
renderTooltip(ms, mouseX, mouseY);
|
||||
for (Renderable widget : renderables) {
|
||||
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isMouseOver(mouseX, mouseY)) {
|
||||
List<Component> tooltip = simiWidget.getToolTip();
|
||||
@@ -121,7 +118,7 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
||||
continue;
|
||||
int ttx = simiWidget.lockedTooltipX == -1 ? mouseX : simiWidget.lockedTooltipX + simiWidget.getX();
|
||||
int tty = simiWidget.lockedTooltipY == -1 ? mouseY : simiWidget.lockedTooltipY + simiWidget.getY();
|
||||
graphics.renderComponentTooltip(font, tooltip, ttx, tty);
|
||||
renderComponentTooltip(ms, tooltip, ttx, tty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,10 +127,10 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
||||
return leftPos - windowXOffset + (imageWidth - textureWidth) / 2;
|
||||
}
|
||||
|
||||
public void renderPlayerInventory(GuiGraphics graphics, int x, int y) {
|
||||
// public void renderPlayerInventory(PoseStack graphics, int x, int y) {
|
||||
// AllGuiTextures.PLAYER_INVENTORY.render(graphics, x, y);
|
||||
graphics.drawString(font, playerInventoryTitle, x + 8, y + 6, 0x404040, false);
|
||||
}
|
||||
// graphics.drawString(font, playerInventoryTitle, x + 8, y + 6, 0x404040, false);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
|
||||
@@ -170,14 +167,14 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void debugWindowArea(GuiGraphics graphics) {
|
||||
graphics.fill(leftPos + imageWidth, topPos + imageHeight, leftPos, topPos, 0xD3D3D3D3);
|
||||
protected void debugWindowArea(PoseStack ms) {
|
||||
fill(ms, leftPos + imageWidth, topPos + imageHeight, leftPos, topPos, 0xD3D3D3D3);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void debugExtraAreas(GuiGraphics graphics) {
|
||||
protected void debugExtraAreas(PoseStack ms) {
|
||||
for (Rect2i area : getExtraAreas()) {
|
||||
graphics.fill(area.getX() + area.getWidth(), area.getY() + area.getHeight(), area.getX(), area.getY(),
|
||||
fill(ms, area.getX() + area.getWidth(), area.getY() + area.getHeight(), area.getX(), area.getY(),
|
||||
0xD3D3D3D3);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.networking.SimplePacketBase;
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.network.NetworkEvent.Context;
|
||||
import nl.requios.effortlessbuilding.create.foundation.networking.SimplePacketBase;
|
||||
|
||||
public class ClearMenuPacket extends SimplePacketBase {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
@@ -1,11 +1,10 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.networking.SimplePacketBase;
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.network.NetworkEvent.Context;
|
||||
import nl.requios.effortlessbuilding.create.foundation.networking.SimplePacketBase;
|
||||
|
||||
public class GhostItemSubmitPacket extends SimplePacketBase {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||
|
||||
public interface IClearableMenu {
|
||||
|
||||
default void sendClearPacket() {
|
||||
// PacketHandler.INSTANCE.sendToServer(new ClearMenuPacket());
|
||||
}
|
||||
|
||||
public void clearContents();
|
||||
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.IInteractionChecker;
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.container;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
@@ -10,6 +8,7 @@ import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.IInteractionChecker;
|
||||
|
||||
public abstract class MenuBase<T> extends AbstractContainerMenu {
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public class BoxElement extends RenderElement {
|
||||
|
||||
@@ -67,8 +64,8 @@ public class BoxElement extends RenderElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics) {
|
||||
renderBox(graphics.pose());
|
||||
public void render(PoseStack ms) {
|
||||
renderBox(ms);
|
||||
}
|
||||
|
||||
//total box width = 1 * 2 (outer border) + 1 * 2 (inner color border) + 2 * borderOffset + width
|
||||
|
||||
@@ -4,8 +4,6 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
public class CombinedStencilElement extends StencilElement {
|
||||
|
||||
private StencilElement element1;
|
||||
@@ -45,22 +43,21 @@ public class CombinedStencilElement extends StencilElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderStencil(GuiGraphics graphics) {
|
||||
PoseStack ms = graphics.pose();
|
||||
protected void renderStencil(PoseStack ms) {
|
||||
ms.pushPose();
|
||||
element1.transform(ms);
|
||||
element1.withBounds(width, height);
|
||||
element1.renderStencil(graphics);
|
||||
element1.renderStencil(ms);
|
||||
ms.popPose();
|
||||
ms.pushPose();
|
||||
element2.transform(ms);
|
||||
element2.withBounds(width, height);
|
||||
element2.renderStencil(graphics);
|
||||
element2.renderStencil(ms);
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderElement(GuiGraphics graphics) {
|
||||
protected void renderElement(PoseStack graphics) {
|
||||
if (mode.rendersFirst())
|
||||
element1.<StencilElement>withBounds(width, height).renderElement(graphics);
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
public class DelegatedStencilElement extends StencilElement {
|
||||
|
||||
protected static final ElementRenderer EMPTY_RENDERER = (graphics, width, height, alpha) -> {};
|
||||
@@ -36,18 +35,18 @@ public class DelegatedStencilElement extends StencilElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderStencil(GuiGraphics graphics) {
|
||||
stencil.render(graphics, width, height, 1);
|
||||
protected void renderStencil(PoseStack ms) {
|
||||
stencil.render(ms, width, height, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderElement(GuiGraphics graphics) {
|
||||
element.render(graphics, width, height, alpha);
|
||||
protected void renderElement(PoseStack ms) {
|
||||
element.render(ms, width, height, alpha);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ElementRenderer {
|
||||
void render(GuiGraphics graphics, int width, int height, float alpha);
|
||||
void render(PoseStack ms, int width, int height, float alpha);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.core.model.ModelUtil;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
|
||||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
|
||||
import com.mojang.blaze3d.platform.Lighting;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.ILightingSettings;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@@ -39,7 +30,12 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.RenderTypeHelper;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.ILightingSettings;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.VecHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GuiGameElement {
|
||||
|
||||
@@ -164,8 +160,7 @@ public class GuiGameElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics) {
|
||||
PoseStack matrixStack = graphics.pose();
|
||||
public void render(PoseStack matrixStack) {
|
||||
prepareMatrix(matrixStack);
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
@@ -234,7 +229,7 @@ public class GuiGameElement {
|
||||
|
||||
// FluidRenderer.renderFluidBox(new FluidStack(blockState.getFluidState()
|
||||
// .getType(), 1000), 0, 0, 0, 1, 1, 1, buffer, ms, LightTexture.FULL_BRIGHT, false);
|
||||
buffer.endBatch();
|
||||
// buffer.endBatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,8 +254,7 @@ public class GuiGameElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics) {
|
||||
PoseStack matrixStack = graphics.pose();
|
||||
public void render(PoseStack matrixStack) {
|
||||
prepareMatrix(matrixStack);
|
||||
transformMatrix(matrixStack);
|
||||
renderItemIntoGUI(matrixStack, stack, customLighting == null);
|
||||
@@ -275,7 +269,7 @@ public class GuiGameElement {
|
||||
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
matrixStack.pushPose();
|
||||
matrixStack.translate(0, 0, 100.0F);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
public abstract class RenderElement implements ScreenElement {
|
||||
|
||||
public static final RenderElement EMPTY = new RenderElement() {
|
||||
@Override
|
||||
public void render(GuiGraphics graphics) {
|
||||
public void render(PoseStack ms) {
|
||||
}
|
||||
};
|
||||
|
||||
@@ -66,11 +66,11 @@ public abstract class RenderElement implements ScreenElement {
|
||||
return z;
|
||||
}
|
||||
|
||||
public abstract void render(GuiGraphics graphics);
|
||||
public abstract void render(PoseStack ms);
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int x, int y) {
|
||||
this.at(x, y).render(graphics);
|
||||
public void render(PoseStack ms, int x, int y) {
|
||||
this.at(x, y).render(ms);
|
||||
}
|
||||
|
||||
public static class SimpleRenderElement extends RenderElement {
|
||||
@@ -82,8 +82,8 @@ public abstract class RenderElement implements ScreenElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics) {
|
||||
renderable.render(graphics, (int) x, (int) y);
|
||||
public void render(PoseStack ms) {
|
||||
renderable.render(ms, (int) x, (int) y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public interface ScreenElement {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
void render(GuiGraphics graphics, int x, int y);
|
||||
void render(PoseStack poseStack, int x, int y);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,26 +6,24 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
public abstract class StencilElement extends RenderElement {
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics) {
|
||||
PoseStack ms = graphics.pose();
|
||||
public void render(PoseStack ms) {
|
||||
ms.pushPose();
|
||||
transform(ms);
|
||||
prepareStencil(ms);
|
||||
renderStencil(graphics);
|
||||
renderStencil(ms);
|
||||
prepareElement(ms);
|
||||
renderElement(graphics);
|
||||
renderElement(ms);
|
||||
cleanUp(ms);
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
protected abstract void renderStencil(GuiGraphics graphics);
|
||||
protected abstract void renderStencil(PoseStack graphics);
|
||||
|
||||
protected abstract void renderElement(GuiGraphics graphics);
|
||||
protected abstract void renderElement(PoseStack graphics);
|
||||
|
||||
protected void transform(PoseStack ms) {
|
||||
ms.translate(x, y, z);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.element;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
|
||||
public class TextStencilElement extends DelegatedStencilElement {
|
||||
|
||||
@@ -47,7 +45,7 @@ public class TextStencilElement extends DelegatedStencilElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderStencil(GuiGraphics graphics) {
|
||||
protected void renderStencil(PoseStack ms) {
|
||||
float x = 0, y = 0;
|
||||
if (centerHorizontally)
|
||||
x = width / 2f - font.width(component) / 2f;
|
||||
@@ -55,11 +53,11 @@ public class TextStencilElement extends DelegatedStencilElement {
|
||||
if (centerVertically)
|
||||
y = height / 2f - (font.lineHeight - 1) / 2f;
|
||||
|
||||
graphics.drawString(font, component, Math.round(x), Math.round(y), 0xff_000000, false);
|
||||
font.draw(ms, component, Math.round(x), Math.round(y), 0xff_000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderElement(GuiGraphics graphics) {
|
||||
protected void renderElement(PoseStack ms) {
|
||||
float x = 0, y = 0;
|
||||
if (centerHorizontally)
|
||||
x = width / 2f - font.width(component) / 2f;
|
||||
@@ -67,10 +65,9 @@ public class TextStencilElement extends DelegatedStencilElement {
|
||||
if (centerVertically)
|
||||
y = height / 2f - (font.lineHeight - 1) / 2f;
|
||||
|
||||
PoseStack ms = graphics.pose();
|
||||
ms.pushPose();
|
||||
ms.translate(x, y, 0);
|
||||
element.render(graphics, font.width(component), font.lineHeight + 2, alpha);
|
||||
element.render(ms, font.width(component), font.lineHeight + 2, alpha);
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.menu;
|
||||
|
||||
//import nl.requios.effortlessbuilding.create.AllPackets;
|
||||
|
||||
public interface IClearableMenu {
|
||||
|
||||
default void sendClearPacket() {
|
||||
// AllPackets.getChannel().sendToServer(new ClearMenuPacket());
|
||||
}
|
||||
|
||||
public void clearContents();
|
||||
|
||||
}
|
||||
@@ -1,20 +1,18 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.TickableGuiEventListener;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.DefaultTooltipPositioner;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.TickableGuiEventListener;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public abstract class AbstractSimiWidget extends AbstractWidget implements TickableGuiEventListener {
|
||||
|
||||
@@ -40,7 +38,7 @@ public abstract class AbstractSimiWidget extends AbstractWidget implements Ticka
|
||||
protected AbstractSimiWidget(int x, int y, int width, int height, Component message) {
|
||||
super(x, y, width, height, message);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ClientTooltipPositioner createTooltipPositioner() {
|
||||
return DefaultTooltipPositioner.INSTANCE;
|
||||
@@ -70,22 +68,22 @@ public abstract class AbstractSimiWidget extends AbstractWidget implements Ticka
|
||||
public void tick() {}
|
||||
|
||||
@Override
|
||||
public void renderWidget(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
beforeRender(graphics, mouseX, mouseY, partialTicks);
|
||||
renderButton(graphics, mouseX, mouseY, partialTicks);
|
||||
afterRender(graphics, mouseX, mouseY, partialTicks);
|
||||
public void renderWidget(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
beforeRender(ms, mouseX, mouseY, partialTicks);
|
||||
doRender(ms, mouseX, mouseY, partialTicks);
|
||||
afterRender(ms, mouseX, mouseY, partialTicks);
|
||||
wasHovered = isHoveredOrFocused();
|
||||
}
|
||||
|
||||
protected void beforeRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
graphics.pose().pushPose();
|
||||
protected void beforeRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
ms.pushPose();
|
||||
}
|
||||
|
||||
protected void renderButton(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
protected void doRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
}
|
||||
|
||||
protected void afterRender(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
graphics.pose().popPose();
|
||||
protected void afterRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
public void runCallback(double mouseX, double mouseY) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.Theme;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.Theme.Key;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.UIRenderHelper;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.BoxElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.DelegatedStencilElement;
|
||||
@@ -11,7 +9,7 @@ import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.animation.LerpedFloat;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class BoxWidget extends ElementWidget {
|
||||
|
||||
@@ -98,8 +96,8 @@ public class BoxWidget extends ElementWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
super.beforeRender(graphics, mouseX, mouseY, partialTicks);
|
||||
protected void beforeRender(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
super.beforeRender(ms, mouseX, mouseY, partialTicks);
|
||||
|
||||
if (isHovered != wasHovered) {
|
||||
startGradientAnimation(
|
||||
@@ -121,7 +119,7 @@ public class BoxWidget extends ElementWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
public void doRender(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
float fadeValue = fade.getValue(partialTicks);
|
||||
if (fadeValue < .1f)
|
||||
return;
|
||||
@@ -131,9 +129,9 @@ public class BoxWidget extends ElementWidget {
|
||||
.gradientBorder(gradientColor1, gradientColor2)
|
||||
.at(getX(), getY(), z)
|
||||
.withBounds(width, height)
|
||||
.render(graphics);
|
||||
.render(ms);
|
||||
|
||||
super.renderButton(graphics, mouseX, mouseY, partialTicks);
|
||||
super.doRender(ms, mouseX, mouseY, partialTicks);
|
||||
|
||||
wasHovered = isHovered;
|
||||
}
|
||||
@@ -148,7 +146,7 @@ public class BoxWidget extends ElementWidget {
|
||||
|
||||
return getX() - padX <= mX && getY() - padY <= mY && mX < getX() + padX + width && mY < getY() + padY + height;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean clicked(double pMouseX, double pMouseY) {
|
||||
if (!active || !visible)
|
||||
@@ -209,19 +207,19 @@ public class BoxWidget extends ElementWidget {
|
||||
return customBorderBot != null ? customBorderBot : Theme.c(getIdleTheme(), false);
|
||||
}
|
||||
|
||||
public Key getDisabledTheme() {
|
||||
public Theme.Key getDisabledTheme() {
|
||||
return Theme.Key.BUTTON_DISABLE;
|
||||
}
|
||||
|
||||
public Key getIdleTheme() {
|
||||
public Theme.Key getIdleTheme() {
|
||||
return Theme.Key.BUTTON_IDLE;
|
||||
}
|
||||
|
||||
public Key getHoverTheme() {
|
||||
public Theme.Key getHoverTheme() {
|
||||
return Theme.Key.BUTTON_HOVER;
|
||||
}
|
||||
|
||||
public Key getClickTheme() {
|
||||
public Theme.Key getClickTheme() {
|
||||
return Theme.Key.BUTTON_CLICK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.RenderElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.animation.LerpedFloat;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class ElementWidget extends AbstractSimiWidget {
|
||||
|
||||
@@ -118,20 +116,19 @@ public class ElementWidget extends AbstractSimiWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeRender(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
super.beforeRender(graphics, mouseX, mouseY, partialTicks);
|
||||
protected void beforeRender(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
super.beforeRender(ms, mouseX, mouseY, partialTicks);
|
||||
isHovered = isMouseOver(mouseX, mouseY);
|
||||
|
||||
float fadeValue = fade.getValue(partialTicks);
|
||||
element.withAlpha(fadeValue);
|
||||
if (fadeValue < 1) {
|
||||
graphics.pose().translate((1 - fadeValue) * fadeModX, (1 - fadeValue) * fadeModY, 0);
|
||||
ms.translate((1 - fadeValue) * fadeModX, (1 - fadeValue) * fadeModY, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
PoseStack ms = graphics.pose();
|
||||
public void doRender(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
ms.pushPose();
|
||||
ms.translate(getX() + paddingX, getY() + paddingY, z);
|
||||
float innerWidth = width - 2 * paddingX;
|
||||
@@ -145,7 +142,7 @@ public class ElementWidget extends AbstractSimiWidget {
|
||||
innerWidth /= xScale;
|
||||
innerHeight /= yScale;
|
||||
}
|
||||
element.withBounds((int) innerWidth, (int) innerHeight).render(graphics);
|
||||
element.withBounds((int) innerWidth, (int) innerHeight).render(ms);
|
||||
ms.popPose();
|
||||
if (rescaleElement) {
|
||||
element.at(eX, eY);
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.element.ScreenElement;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class IconButton extends AbstractSimiWidget {
|
||||
|
||||
protected ScreenElement icon;
|
||||
@@ -14,14 +13,14 @@ public class IconButton extends AbstractSimiWidget {
|
||||
public IconButton(int x, int y, ScreenElement icon) {
|
||||
this(x, y, 18, 18, icon);
|
||||
}
|
||||
|
||||
|
||||
public IconButton(int x, int y, int w, int h, ScreenElement icon) {
|
||||
super(x, y, w, h);
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
public void doRender(PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
if (visible) {
|
||||
isHovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height;
|
||||
|
||||
@@ -29,13 +28,14 @@ public class IconButton extends AbstractSimiWidget {
|
||||
: isMouseOver(mouseX, mouseY) ? AllGuiTextures.BUTTON_HOVER : AllGuiTextures.BUTTON;
|
||||
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
drawBg(graphics, button);
|
||||
icon.render(graphics, getX() + 1, getY() + 1);
|
||||
drawBg(ms, button);
|
||||
icon.render(ms, getX() + 1, getY() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawBg(GuiGraphics graphics, AllGuiTextures button) {
|
||||
graphics.blit(button.location, getX(), getY(), button.startX, button.startY, button.width, button.height);
|
||||
protected void drawBg(PoseStack ms, AllGuiTextures button) {
|
||||
AllGuiTextures.BUTTON.bind();
|
||||
blit(ms, getX(), getY(), button.startX, button.startY, button.width, button.height);
|
||||
}
|
||||
|
||||
public void setToolTip(Component text) {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import nl.requios.effortlessbuilding.create.foundation.gui.AllGuiTextures;
|
||||
|
||||
public class Indicator extends AbstractSimiWidget {
|
||||
|
||||
@@ -17,7 +16,7 @@ public class Indicator extends AbstractSimiWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks ) {
|
||||
public void render(PoseStack ms, int mouseX, int mouseY, float partialTicks ) {
|
||||
if (!visible)
|
||||
return;
|
||||
AllGuiTextures toDraw;
|
||||
@@ -29,7 +28,7 @@ public class Indicator extends AbstractSimiWidget {
|
||||
case GREEN: toDraw = AllGuiTextures.INDICATOR_GREEN; break;
|
||||
default: toDraw = AllGuiTextures.INDICATOR; break;
|
||||
}
|
||||
toDraw.render(graphics, getX(), getY());
|
||||
toDraw.render(ms, getX(), getY());
|
||||
}
|
||||
|
||||
public enum State {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class Label extends AbstractSimiWidget {
|
||||
|
||||
@@ -71,7 +70,7 @@ public class Label extends AbstractSimiWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderButton(@Nonnull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
protected void doRender(@Nonnull PoseStack ms, int mouseX, int mouseY, float partialTicks) {
|
||||
if (text == null || text.getString().isEmpty())
|
||||
return;
|
||||
|
||||
@@ -80,7 +79,10 @@ public class Label extends AbstractSimiWidget {
|
||||
if (suffix != null && !suffix.isEmpty())
|
||||
copy.append(suffix);
|
||||
|
||||
graphics.drawString(font, copy, getX(), getY(), color, hasShadow);
|
||||
if (hasShadow)
|
||||
font.drawShadow(ms, copy, getX(), getY(), color);
|
||||
else
|
||||
font.draw(ms, copy, getX(), getY(), color);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import nl.requios.effortlessbuilding.create.AllKeys;
|
||||
//import nl.requios.effortlessbuilding.create.AllSoundEvents;
|
||||
//import nl.requios.effortlessbuilding.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour.StepContext;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ScrollInput extends AbstractSimiWidget {
|
||||
|
||||
@@ -123,6 +118,8 @@ public class ScrollInput extends AbstractSimiWidget {
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
|
||||
if (!this.visible || !this.isHovered) return false; //Added
|
||||
|
||||
if (inverted)
|
||||
delta *= -1;
|
||||
|
||||
@@ -152,7 +149,8 @@ public class ScrollInput extends AbstractSimiWidget {
|
||||
onChanged();
|
||||
}
|
||||
|
||||
return priorState != state;
|
||||
// return priorState != state;
|
||||
return true; //Changed
|
||||
}
|
||||
|
||||
protected void clampState() {
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SelectionScrollInput extends ScrollInput {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package nl.requios.effortlessbuilding.create.foundation.gui.widget;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class TooltipArea extends AbstractSimiWidget {
|
||||
@@ -12,7 +12,7 @@ public class TooltipArea extends AbstractSimiWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
public void renderWidget(PoseStack graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
if (visible)
|
||||
isHovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height;
|
||||
}
|
||||
|
||||
@@ -1,253 +1,182 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
||||
|
||||
import static net.minecraft.ChatFormatting.DARK_GRAY;
|
||||
import static net.minecraft.ChatFormatting.GRAY;
|
||||
import static net.minecraft.ChatFormatting.WHITE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper.Palette;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public record ItemDescription(ImmutableList<Component> lines, ImmutableList<Component> linesOnShift, ImmutableList<Component> linesOnCtrl) {
|
||||
private static final Map<Item, Supplier<String>> CUSTOM_TOOLTIP_KEYS = new IdentityHashMap<>();
|
||||
import static net.minecraft.ChatFormatting.*;
|
||||
import static nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper.cutStringTextComponent;
|
||||
import static nl.requios.effortlessbuilding.create.foundation.item.TooltipHelper.cutTextComponent;
|
||||
|
||||
@Nullable
|
||||
public static ItemDescription create(Item item, Palette palette) {
|
||||
return create(getTooltipTranslationKey(item), palette);
|
||||
public class ItemDescription {
|
||||
|
||||
public static final ItemDescription MISSING = new ItemDescription(null);
|
||||
public static Component trim = Components.literal(" ").withStyle(WHITE, STRIKETHROUGH);
|
||||
|
||||
public enum Palette {
|
||||
|
||||
Blue(BLUE, AQUA),
|
||||
Green(DARK_GREEN, GREEN),
|
||||
Yellow(GOLD, YELLOW),
|
||||
Red(DARK_RED, RED),
|
||||
Purple(DARK_PURPLE, LIGHT_PURPLE),
|
||||
Gray(DARK_GRAY, GRAY),
|
||||
|
||||
;
|
||||
|
||||
private Palette(ChatFormatting primary, ChatFormatting highlight) {
|
||||
color = primary;
|
||||
hColor = highlight;
|
||||
}
|
||||
|
||||
public ChatFormatting color;
|
||||
public ChatFormatting hColor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ItemDescription create(String translationKey, Palette palette) {
|
||||
if (!canFillBuilder(translationKey)) {
|
||||
return null;
|
||||
}
|
||||
private List<Component> lines;
|
||||
private List<Component> linesOnShift;
|
||||
private List<Component> linesOnCtrl;
|
||||
private Palette palette;
|
||||
|
||||
Builder builder = new Builder(palette);
|
||||
fillBuilder(builder, translationKey);
|
||||
return builder.build();
|
||||
public ItemDescription(Palette palette) {
|
||||
this.palette = palette;
|
||||
lines = new ArrayList<>();
|
||||
linesOnShift = new ArrayList<>();
|
||||
linesOnCtrl = new ArrayList<>();
|
||||
}
|
||||
|
||||
public static boolean canFillBuilder(String translationKey) {
|
||||
return I18n.exists(translationKey);
|
||||
public ItemDescription withSummary(Component summary) {
|
||||
addStrings(linesOnShift, cutTextComponent(summary, palette.color, palette.hColor));
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void fillBuilder(Builder builder, String translationKey) {
|
||||
// Summary
|
||||
String summaryKey = translationKey + ".summary";
|
||||
if (I18n.exists(summaryKey)) {
|
||||
builder.addSummary(I18n.get(summaryKey));
|
||||
}
|
||||
|
||||
// Behaviours
|
||||
for (int i = 1; i < 100; i++) {
|
||||
String conditionKey = translationKey + ".condition" + i;
|
||||
String behaviourKey = translationKey + ".behaviour" + i;
|
||||
if (!I18n.exists(conditionKey))
|
||||
break;
|
||||
builder.addBehaviour(I18n.get(conditionKey), I18n.get(behaviourKey));
|
||||
}
|
||||
|
||||
// Actions
|
||||
for (int i = 1; i < 100; i++) {
|
||||
String controlKey = translationKey + ".control" + i;
|
||||
String actionKey = translationKey + ".action" + i;
|
||||
if (!I18n.exists(controlKey))
|
||||
break;
|
||||
builder.addAction(I18n.get(controlKey), I18n.get(actionKey));
|
||||
}
|
||||
public static String makeProgressBar(int length, int filledLength) {
|
||||
String bar = " ";
|
||||
int emptySpaces = length - filledLength;
|
||||
for (int i = 0; i < filledLength; i++)
|
||||
bar += "\u2588";
|
||||
for (int i = 0; i < emptySpaces; i++)
|
||||
bar += "\u2592";
|
||||
return bar + " ";
|
||||
}
|
||||
|
||||
public static void useKey(Item item, Supplier<String> supplier) {
|
||||
CUSTOM_TOOLTIP_KEYS.put(item, supplier);
|
||||
public ItemDescription withBehaviour(String condition, String behaviour) {
|
||||
add(linesOnShift, Components.literal(condition).withStyle(GRAY));
|
||||
addStrings(linesOnShift, cutStringTextComponent(behaviour, palette.color, palette.hColor, 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void useKey(ItemLike item, String string) {
|
||||
useKey(item.asItem(), () -> string);
|
||||
public ItemDescription withControl(String condition, String action) {
|
||||
add(linesOnCtrl, Components.literal(condition).withStyle(GRAY));
|
||||
addStrings(linesOnCtrl, cutStringTextComponent(action, palette.color, palette.hColor, 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void referKey(ItemLike item, Supplier<? extends ItemLike> otherItem) {
|
||||
useKey(item.asItem(), () -> otherItem.get()
|
||||
.asItem()
|
||||
.getDescriptionId());
|
||||
}
|
||||
public ItemDescription createTabs() {
|
||||
boolean hasDescription = !linesOnShift.isEmpty();
|
||||
boolean hasControls = !linesOnCtrl.isEmpty();
|
||||
|
||||
public static String getTooltipTranslationKey(Item item) {
|
||||
if (CUSTOM_TOOLTIP_KEYS.containsKey(item)) {
|
||||
return CUSTOM_TOOLTIP_KEYS.get(item).get() + ".tooltip";
|
||||
}
|
||||
return item.getDescriptionId() + ".tooltip";
|
||||
}
|
||||
if (hasDescription || hasControls) {
|
||||
String[] holdDesc = Lang.translateDirect("tooltip.holdForDescription", "$")
|
||||
.getString()
|
||||
.split("\\$");
|
||||
String[] holdCtrl = Lang.translateDirect("tooltip.holdForControls", "$")
|
||||
.getString()
|
||||
.split("\\$");
|
||||
MutableComponent keyShift = Lang.translateDirect("tooltip.keyShift");
|
||||
MutableComponent keyCtrl = Lang.translateDirect("tooltip.keyCtrl");
|
||||
for (List<Component> list : Arrays.asList(lines, linesOnShift, linesOnCtrl)) {
|
||||
boolean shift = list == linesOnShift;
|
||||
boolean ctrl = list == linesOnCtrl;
|
||||
|
||||
public ImmutableList<Component> getCurrentLines() {
|
||||
if (Screen.hasShiftDown()) {
|
||||
return linesOnShift;
|
||||
} else if (Screen.hasControlDown()) {
|
||||
return linesOnCtrl;
|
||||
} else {
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
protected final Palette palette;
|
||||
protected final List<String> summary = new ArrayList<>();
|
||||
protected final List<Pair<String, String>> behaviours = new ArrayList<>();
|
||||
protected final List<Pair<String, String>> actions = new ArrayList<>();
|
||||
|
||||
public Builder(Palette palette) {
|
||||
this.palette = palette;
|
||||
}
|
||||
|
||||
public Builder addSummary(String summaryLine) {
|
||||
summary.add(summaryLine);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addBehaviour(String condition, String behaviour) {
|
||||
behaviours.add(Pair.of(condition, behaviour));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addAction(String condition, String action) {
|
||||
actions.add(Pair.of(condition, action));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemDescription build() {
|
||||
List<Component> lines = new ArrayList<>();
|
||||
List<Component> linesOnShift = new ArrayList<>();
|
||||
List<Component> linesOnCtrl = new ArrayList<>();
|
||||
|
||||
for (String summaryLine : summary) {
|
||||
linesOnShift.addAll(TooltipHelper.cutStringTextComponent(summaryLine, palette));
|
||||
}
|
||||
|
||||
if (!behaviours.isEmpty()) {
|
||||
linesOnShift.add(Components.immutableEmpty());
|
||||
}
|
||||
|
||||
for (Pair<String, String> behaviourPair : behaviours) {
|
||||
String condition = behaviourPair.getLeft();
|
||||
String behaviour = behaviourPair.getRight();
|
||||
linesOnShift.add(Components.literal(condition).withStyle(GRAY));
|
||||
linesOnShift.addAll(TooltipHelper.cutStringTextComponent(behaviour, palette.primary(), palette.highlight(), 1));
|
||||
}
|
||||
|
||||
for (Pair<String, String> actionPair : actions) {
|
||||
String condition = actionPair.getLeft();
|
||||
String action = actionPair.getRight();
|
||||
linesOnCtrl.add(Components.literal(condition).withStyle(GRAY));
|
||||
linesOnCtrl.addAll(TooltipHelper.cutStringTextComponent(action, palette.primary(), palette.highlight(), 1));
|
||||
}
|
||||
|
||||
boolean hasDescription = !linesOnShift.isEmpty();
|
||||
boolean hasControls = !linesOnCtrl.isEmpty();
|
||||
|
||||
if (hasDescription || hasControls) {
|
||||
String[] holdDesc = Lang.translateDirect("tooltip.holdForDescription", "$")
|
||||
.getString()
|
||||
.split("\\$");
|
||||
String[] holdCtrl = Lang.translateDirect("tooltip.holdForControls", "$")
|
||||
.getString()
|
||||
.split("\\$");
|
||||
MutableComponent keyShift = Lang.translateDirect("tooltip.keyShift");
|
||||
MutableComponent keyCtrl = Lang.translateDirect("tooltip.keyCtrl");
|
||||
for (List<Component> list : Arrays.asList(lines, linesOnShift, linesOnCtrl)) {
|
||||
boolean shift = list == linesOnShift;
|
||||
boolean ctrl = list == linesOnCtrl;
|
||||
|
||||
if (holdDesc.length != 2 || holdCtrl.length != 2) {
|
||||
list.add(0, Components.literal("Invalid lang formatting!"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasControls) {
|
||||
MutableComponent tabBuilder = Components.empty();
|
||||
tabBuilder.append(Components.literal(holdCtrl[0]).withStyle(DARK_GRAY));
|
||||
tabBuilder.append(keyCtrl.plainCopy()
|
||||
.withStyle(ctrl ? WHITE : GRAY));
|
||||
tabBuilder.append(Components.literal(holdCtrl[1]).withStyle(DARK_GRAY));
|
||||
list.add(0, tabBuilder);
|
||||
}
|
||||
|
||||
if (hasDescription) {
|
||||
MutableComponent tabBuilder = Components.empty();
|
||||
tabBuilder.append(Components.literal(holdDesc[0]).withStyle(DARK_GRAY));
|
||||
tabBuilder.append(keyShift.plainCopy()
|
||||
.withStyle(shift ? WHITE : GRAY));
|
||||
tabBuilder.append(Components.literal(holdDesc[1]).withStyle(DARK_GRAY));
|
||||
list.add(0, tabBuilder);
|
||||
}
|
||||
|
||||
if (shift || ctrl)
|
||||
list.add(hasDescription && hasControls ? 2 : 1, Components.immutableEmpty());
|
||||
if (holdDesc.length != 2 || holdCtrl.length != 2) {
|
||||
list.add(0, Components.literal("Invalid lang formatting!"));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasDescription) {
|
||||
linesOnCtrl.clear();
|
||||
linesOnShift.addAll(lines);
|
||||
}
|
||||
if (!hasControls) {
|
||||
linesOnCtrl.clear();
|
||||
linesOnCtrl.addAll(lines);
|
||||
}
|
||||
if (hasControls) {
|
||||
MutableComponent tabBuilder = Components.empty();
|
||||
tabBuilder.append(Components.literal(holdCtrl[0]).withStyle(DARK_GRAY));
|
||||
tabBuilder.append(keyCtrl.plainCopy()
|
||||
.withStyle(ctrl ? WHITE : GRAY));
|
||||
tabBuilder.append(Components.literal(holdCtrl[1]).withStyle(DARK_GRAY));
|
||||
list.add(0, tabBuilder);
|
||||
}
|
||||
|
||||
return new ItemDescription(ImmutableList.copyOf(lines), ImmutableList.copyOf(linesOnShift), ImmutableList.copyOf(linesOnCtrl));
|
||||
if (hasDescription) {
|
||||
MutableComponent tabBuilder = Components.empty();
|
||||
tabBuilder.append(Components.literal(holdDesc[0]).withStyle(DARK_GRAY));
|
||||
tabBuilder.append(keyShift.plainCopy()
|
||||
.withStyle(shift ? WHITE : GRAY));
|
||||
tabBuilder.append(Components.literal(holdDesc[1]).withStyle(DARK_GRAY));
|
||||
list.add(0, tabBuilder);
|
||||
}
|
||||
|
||||
if (shift || ctrl)
|
||||
list.add(hasDescription && hasControls ? 2 : 1, Components.immutableEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasDescription)
|
||||
linesOnShift = lines;
|
||||
if (!hasControls)
|
||||
linesOnCtrl = lines;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Modifier implements TooltipModifier {
|
||||
protected final Item item;
|
||||
protected final Palette palette;
|
||||
protected String cachedLanguage;
|
||||
protected ItemDescription description;
|
||||
|
||||
public Modifier(Item item, Palette palette) {
|
||||
this.item = item;
|
||||
this.palette = palette;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(ItemTooltipEvent context) {
|
||||
if (checkLocale()) {
|
||||
description = create(item, palette);
|
||||
}
|
||||
if (description == null) {
|
||||
return;
|
||||
}
|
||||
context.getToolTip().addAll(1, description.getCurrentLines());
|
||||
}
|
||||
|
||||
protected boolean checkLocale() {
|
||||
String currentLanguage = Minecraft.getInstance()
|
||||
.getLanguageManager()
|
||||
.getSelected();
|
||||
if (!currentLanguage.equals(cachedLanguage)) {
|
||||
cachedLanguage = currentLanguage;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static String hightlight(String s, Palette palette) {
|
||||
return palette.hColor + s + palette.color;
|
||||
}
|
||||
|
||||
public static void addStrings(List<Component> infoList, List<Component> textLines) {
|
||||
textLines.forEach(s -> add(infoList, s));
|
||||
}
|
||||
|
||||
public static void add(List<Component> infoList, List<Component> textLines) {
|
||||
infoList.addAll(textLines);
|
||||
}
|
||||
|
||||
public static void add(List<Component> infoList, Component line) {
|
||||
infoList.add(line);
|
||||
}
|
||||
|
||||
public Palette getPalette() {
|
||||
return palette;
|
||||
}
|
||||
|
||||
public List<Component> addInformation(List<Component> tooltip) {
|
||||
if (Screen.hasShiftDown()) {
|
||||
tooltip.addAll(linesOnShift);
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
if (Screen.hasControlDown()) {
|
||||
tooltip.addAll(linesOnCtrl);
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
tooltip.addAll(lines);
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
public List<Component> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public List<Component> getLinesOnCtrl() {
|
||||
return linesOnCtrl;
|
||||
}
|
||||
|
||||
public List<Component> getLinesOnShift() {
|
||||
return linesOnShift;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Pair;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.util.Mth;
|
||||
@@ -20,17 +10,16 @@ import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class ItemHelper {
|
||||
|
||||
public static boolean sameItem(ItemStack stack, ItemStack otherStack) {
|
||||
return !otherStack.isEmpty() && stack.is(otherStack.getItem());
|
||||
}
|
||||
|
||||
public static Predicate<ItemStack> sameItemPredicate(ItemStack stack) {
|
||||
return s -> sameItem(stack, s);
|
||||
}
|
||||
|
||||
public static void dropContents(Level world, BlockPos pos, IItemHandler inv) {
|
||||
for (int slot = 0; slot < inv.getSlots(); slot++)
|
||||
Containers.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), inv.getStackInSlot(slot));
|
||||
@@ -133,7 +122,7 @@ public class ItemHelper {
|
||||
return true;
|
||||
if (stacks1.length == stacks2.length) {
|
||||
for (int i = 0; i < stacks1.length; i++)
|
||||
if (!ItemStack.isSameItem(stacks1[i], stacks2[i]))
|
||||
if (!ItemStack.isSame(stacks1[i], stacks2[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,37 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
||||
|
||||
import java.text.BreakIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
//import nl.requios.effortlessbuilding.create.content.equipment.goggles.IHaveGoggleInformation;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import nl.requios.effortlessbuilding.create.foundation.item.ItemDescription.Palette;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Components;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Couple;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.FontHelper;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Lang;
|
||||
|
||||
import java.text.BreakIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TooltipHelper {
|
||||
|
||||
public static final int MAX_WIDTH_PER_LINE = 200;
|
||||
public static final int maxWidthPerLine = 200;
|
||||
public static final Map<String, ItemDescription> cachedTooltips = new HashMap<>();
|
||||
private static boolean gogglesMode;
|
||||
private static final Map<Item, Supplier<String>> tooltipReferrals = new HashMap<>();
|
||||
|
||||
public static MutableComponent holdShift(Palette palette, boolean highlighted) {
|
||||
public static MutableComponent holdShift(Palette color, boolean highlighted) {
|
||||
return Lang.translateDirect("tooltip.holdForDescription", Lang.translateDirect("tooltip.keyShift")
|
||||
.withStyle(ChatFormatting.GRAY))
|
||||
.withStyle(ChatFormatting.DARK_GRAY);
|
||||
@@ -34,64 +43,87 @@ public class TooltipHelper {
|
||||
.append(Lang.translateDirect(hintKey + ".title"))
|
||||
.withStyle(ChatFormatting.GOLD));
|
||||
Component hint = Lang.translateDirect(hintKey);
|
||||
List<Component> cutComponent = cutTextComponent(hint, Palette.GRAY_AND_WHITE);
|
||||
List<Component> cutComponent = TooltipHelper.cutTextComponent(hint, ChatFormatting.GRAY, ChatFormatting.WHITE);
|
||||
for (Component component : cutComponent)
|
||||
tooltip.add(spacing.plainCopy()
|
||||
.append(component));
|
||||
}
|
||||
|
||||
public static String makeProgressBar(int length, int filledLength) {
|
||||
String bar = " ";
|
||||
int emptySpaces = length - filledLength;
|
||||
for (int i = 0; i < filledLength; i++)
|
||||
bar += "\u2588";
|
||||
for (int i = 0; i < emptySpaces; i++)
|
||||
bar += "\u2592";
|
||||
return bar + " ";
|
||||
public static void referTo(ItemLike item, Supplier<? extends ItemLike> itemWithTooltip) {
|
||||
tooltipReferrals.put(item.asItem(), () -> itemWithTooltip.get()
|
||||
.asItem()
|
||||
.getDescriptionId());
|
||||
}
|
||||
|
||||
public static Style styleFromColor(ChatFormatting color) {
|
||||
return Style.EMPTY.applyFormat(color);
|
||||
}
|
||||
|
||||
public static Style styleFromColor(int hex) {
|
||||
return Style.EMPTY.withColor(hex);
|
||||
public static void referTo(ItemLike item, String string) {
|
||||
tooltipReferrals.put(item.asItem(), () -> string);
|
||||
}
|
||||
|
||||
public static List<Component> cutStringTextComponent(String s, Palette palette) {
|
||||
return cutTextComponent(Components.literal(s), palette);
|
||||
@Deprecated
|
||||
public static List<String> cutString(Component s, ChatFormatting defaultColor, ChatFormatting highlightColor) {
|
||||
return cutString(s.getString(), defaultColor, highlightColor, 0);
|
||||
}
|
||||
|
||||
public static List<Component> cutTextComponent(Component c, Palette palette) {
|
||||
return cutTextComponent(c, palette.primary(), palette.highlight());
|
||||
}
|
||||
|
||||
public static List<Component> cutStringTextComponent(String s, Style primaryStyle,
|
||||
Style highlightStyle) {
|
||||
return cutTextComponent(Components.literal(s), primaryStyle, highlightStyle);
|
||||
}
|
||||
|
||||
public static List<Component> cutTextComponent(Component c, Style primaryStyle,
|
||||
Style highlightStyle) {
|
||||
return cutTextComponent(c, primaryStyle, highlightStyle, 0);
|
||||
}
|
||||
|
||||
public static List<Component> cutStringTextComponent(String c, Style primaryStyle,
|
||||
Style highlightStyle, int indent) {
|
||||
return cutTextComponent(Components.literal(c), primaryStyle, highlightStyle, indent);
|
||||
}
|
||||
|
||||
public static List<Component> cutTextComponent(Component c, Style primaryStyle,
|
||||
Style highlightStyle, int indent) {
|
||||
String s = c.getString();
|
||||
@Deprecated
|
||||
public static List<String> cutString(String s, ChatFormatting defaultColor, ChatFormatting highlightColor,
|
||||
int indent) {
|
||||
// Apply markup
|
||||
String markedUp = s.replaceAll("_([^_]+)_", highlightColor + "$1" + defaultColor);
|
||||
|
||||
// Split words
|
||||
List<String> words = new LinkedList<>();
|
||||
BreakIterator iterator = BreakIterator.getLineInstance(Minecraft.getInstance().getLocale());
|
||||
iterator.setText(s);
|
||||
iterator.setText(markedUp);
|
||||
int start = iterator.first();
|
||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator.next()) {
|
||||
String word = s.substring(start, end);
|
||||
String word = markedUp.substring(start, end);
|
||||
words.add(word);
|
||||
}
|
||||
|
||||
Font font = Minecraft.getInstance().font;
|
||||
List<String> lines = FontHelper.cutString(font, markedUp, maxWidthPerLine);
|
||||
|
||||
// Format
|
||||
String lineStart = Strings.repeat(" ", indent);
|
||||
List<String> formattedLines = new ArrayList<>(lines.size());
|
||||
String format = defaultColor.toString();
|
||||
for (String line : lines) {
|
||||
String formattedLine = format + lineStart + line;
|
||||
formattedLines.add(formattedLine);
|
||||
// format = TextFormatting.getFormatString(formattedLine);
|
||||
}
|
||||
return formattedLines;
|
||||
}
|
||||
|
||||
public static List<Component> cutStringTextComponent(String c, ChatFormatting defaultColor,
|
||||
ChatFormatting highlightColor) {
|
||||
return cutTextComponent(Components.literal(c), defaultColor, highlightColor, 0);
|
||||
}
|
||||
|
||||
public static List<Component> cutTextComponent(Component c, ChatFormatting defaultColor,
|
||||
ChatFormatting highlightColor) {
|
||||
return cutTextComponent(c, defaultColor, highlightColor, 0);
|
||||
}
|
||||
|
||||
public static List<Component> cutStringTextComponent(String c, ChatFormatting defaultColor,
|
||||
ChatFormatting highlightColor, int indent) {
|
||||
return cutTextComponent(Components.literal(c), defaultColor, highlightColor, indent);
|
||||
}
|
||||
|
||||
public static List<Component> cutTextComponent(Component c, ChatFormatting defaultColor,
|
||||
ChatFormatting highlightColor, int indent) {
|
||||
String s = c.getString();
|
||||
|
||||
// Apply markup
|
||||
String markedUp = s;// .replaceAll("_([^_]+)_", highlightColor + "$1" + defaultColor);
|
||||
|
||||
// Split words
|
||||
List<String> words = new LinkedList<>();
|
||||
BreakIterator iterator = BreakIterator.getLineInstance(Minecraft.getInstance().getLocale());
|
||||
iterator.setText(markedUp);
|
||||
int start = iterator.first();
|
||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator.next()) {
|
||||
String word = markedUp.substring(start, end);
|
||||
words.add(word);
|
||||
}
|
||||
|
||||
@@ -102,7 +134,7 @@ public class TooltipHelper {
|
||||
int width = 0;
|
||||
for (String word : words) {
|
||||
int newWidth = font.width(word.replaceAll("_", ""));
|
||||
if (width + newWidth > MAX_WIDTH_PER_LINE) {
|
||||
if (width + newWidth > maxWidthPerLine) {
|
||||
if (width > 0) {
|
||||
String line = currentLine.toString();
|
||||
lines.add(line);
|
||||
@@ -122,16 +154,16 @@ public class TooltipHelper {
|
||||
|
||||
// Format
|
||||
MutableComponent lineStart = Components.literal(Strings.repeat(" ", indent));
|
||||
lineStart.withStyle(primaryStyle);
|
||||
lineStart.withStyle(defaultColor);
|
||||
List<Component> formattedLines = new ArrayList<>(lines.size());
|
||||
Couple<Style> styles = Couple.create(highlightStyle, primaryStyle);
|
||||
Couple<ChatFormatting> f = Couple.create(highlightColor, defaultColor);
|
||||
|
||||
boolean currentlyHighlighted = false;
|
||||
for (String string : lines) {
|
||||
MutableComponent currentComponent = lineStart.plainCopy();
|
||||
String[] split = string.split("_");
|
||||
for (String part : split) {
|
||||
currentComponent.append(Components.literal(part).withStyle(styles.get(currentlyHighlighted)));
|
||||
currentComponent.append(Components.literal(part).withStyle(f.get(currentlyHighlighted)));
|
||||
currentlyHighlighted = !currentlyHighlighted;
|
||||
}
|
||||
|
||||
@@ -142,25 +174,110 @@ public class TooltipHelper {
|
||||
return formattedLines;
|
||||
}
|
||||
|
||||
public record Palette(Style primary, Style highlight) {
|
||||
public static final Palette STANDARD_CREATE = new Palette(styleFromColor(0xC9974C), styleFromColor(0xF1DD79));
|
||||
// public static List<ITextComponent> cutTextComponentOld(ITextComponent c, TextFormatting defaultColor,
|
||||
// TextFormatting highlightColor, int indent) {
|
||||
// IFormattableTextComponent lineStart = StringTextComponent.EMPTY.copy();
|
||||
// for (int i = 0; i < indent; i++)
|
||||
// lineStart.append(" ");
|
||||
// lineStart.formatted(defaultColor);
|
||||
//
|
||||
// List<ITextComponent> lines = new ArrayList<>();
|
||||
// String rawText = getUnformattedDeepText(c);
|
||||
// String[] words = rawText.split(" ");
|
||||
// String word;
|
||||
// IFormattableTextComponent currentLine = lineStart.copy();
|
||||
//
|
||||
// boolean firstWord = true;
|
||||
// boolean lastWord;
|
||||
//
|
||||
// // Apply hard wrap
|
||||
// for (int i = 0; i < words.length; i++) {
|
||||
// word = words[i];
|
||||
// lastWord = i == words.length - 1;
|
||||
//
|
||||
// if (!lastWord && !firstWord && getComponentLength(currentLine) + word.length() > maxCharsPerLine) {
|
||||
// lines.add(currentLine);
|
||||
// currentLine = lineStart.copy();
|
||||
// firstWord = true;
|
||||
// }
|
||||
//
|
||||
// currentLine.append(new StringTextComponent((firstWord ? "" : " ") + word.replace("_", ""))
|
||||
// .formatted(word.matches("_([^_]+)_") ? highlightColor : defaultColor));
|
||||
// firstWord = false;
|
||||
// }
|
||||
//
|
||||
// if (!firstWord) {
|
||||
// lines.add(currentLine);
|
||||
// }
|
||||
//
|
||||
// return lines;
|
||||
// }
|
||||
|
||||
public static final Palette BLUE = ofColors(ChatFormatting.BLUE, ChatFormatting.AQUA);
|
||||
public static final Palette GREEN = ofColors(ChatFormatting.DARK_GREEN, ChatFormatting.GREEN);
|
||||
public static final Palette YELLOW = ofColors(ChatFormatting.GOLD, ChatFormatting.YELLOW);
|
||||
public static final Palette RED = ofColors(ChatFormatting.DARK_RED, ChatFormatting.RED);
|
||||
public static final Palette PURPLE = ofColors(ChatFormatting.DARK_PURPLE, ChatFormatting.LIGHT_PURPLE);
|
||||
public static final Palette GRAY = ofColors(ChatFormatting.DARK_GRAY, ChatFormatting.GRAY);
|
||||
|
||||
public static final Palette ALL_GRAY = ofColors(ChatFormatting.GRAY, ChatFormatting.GRAY);
|
||||
public static final Palette GRAY_AND_BLUE = ofColors(ChatFormatting.GRAY, ChatFormatting.BLUE);
|
||||
public static final Palette GRAY_AND_WHITE = ofColors(ChatFormatting.GRAY, ChatFormatting.WHITE);
|
||||
public static final Palette GRAY_AND_GOLD = ofColors(ChatFormatting.GRAY, ChatFormatting.GOLD);
|
||||
public static final Palette GRAY_AND_RED = ofColors(ChatFormatting.GRAY, ChatFormatting.RED);
|
||||
|
||||
public static Palette ofColors(ChatFormatting primary, ChatFormatting highlight) {
|
||||
return new Palette(styleFromColor(primary), styleFromColor(highlight));
|
||||
private static boolean findTooltip(ItemStack stack) {
|
||||
String key = getTooltipTranslationKey(stack);
|
||||
if (I18n.exists(key)) {
|
||||
cachedTooltips.put(key, buildToolTip(key, stack));
|
||||
return true;
|
||||
}
|
||||
cachedTooltips.put(key, ItemDescription.MISSING);
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ItemDescription buildToolTip(String translationKey, ItemStack stack) {
|
||||
ItemDescription tooltip = new ItemDescription(Palette.Blue);
|
||||
String summaryKey = translationKey + ".summary";
|
||||
|
||||
// Summary
|
||||
if (I18n.exists(summaryKey))
|
||||
tooltip = tooltip.withSummary(Components.literal(I18n.get(summaryKey)));
|
||||
|
||||
// Requirements
|
||||
// if (stack.getItem() instanceof BlockItem) {
|
||||
// BlockItem item = (BlockItem) stack.getItem();
|
||||
// if (item.getBlock() instanceof IRotate || item.getBlock() instanceof EngineBlock) {
|
||||
// tooltip = tooltip.withKineticStats(item.getBlock());
|
||||
// }
|
||||
// }
|
||||
|
||||
// Behaviours
|
||||
for (int i = 1; i < 100; i++) {
|
||||
String conditionKey = translationKey + ".condition" + i;
|
||||
String behaviourKey = translationKey + ".behaviour" + i;
|
||||
if (!I18n.exists(conditionKey))
|
||||
break;
|
||||
if (i == 1)
|
||||
tooltip.getLinesOnShift()
|
||||
.add(Components.immutableEmpty());
|
||||
tooltip.withBehaviour(I18n.get(conditionKey), I18n.get(behaviourKey));
|
||||
}
|
||||
|
||||
// Controls
|
||||
for (int i = 1; i < 100; i++) {
|
||||
String controlKey = translationKey + ".control" + i;
|
||||
String actionKey = translationKey + ".action" + i;
|
||||
if (!I18n.exists(controlKey))
|
||||
break;
|
||||
tooltip.withControl(I18n.get(controlKey), I18n.get(actionKey));
|
||||
}
|
||||
|
||||
return tooltip.createTabs();
|
||||
}
|
||||
|
||||
public static String getTooltipTranslationKey(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (tooltipReferrals.containsKey(item))
|
||||
return tooltipReferrals.get(item)
|
||||
.get() + ".tooltip";
|
||||
return item.getDescriptionId(stack) + ".tooltip";
|
||||
}
|
||||
|
||||
// private static int getComponentLength(ITextComponent component) {
|
||||
// AtomicInteger l = new AtomicInteger();
|
||||
// TextProcessing.visitFormatted(component, Style.EMPTY, (s, style, charConsumer) -> {
|
||||
// l.getAndIncrement();
|
||||
// return true;
|
||||
// });
|
||||
// return l.get();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.item;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.AttachedRegistry;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public interface TooltipModifier {
|
||||
AttachedRegistry<Item, TooltipModifier> REGISTRY = new AttachedRegistry<>(ForgeRegistries.ITEMS);
|
||||
|
||||
TooltipModifier EMPTY = new TooltipModifier() {
|
||||
@Override
|
||||
public void modify(ItemTooltipEvent context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TooltipModifier andThen(TooltipModifier after) {
|
||||
return after;
|
||||
}
|
||||
};
|
||||
|
||||
void modify(ItemTooltipEvent context);
|
||||
|
||||
default TooltipModifier andThen(TooltipModifier after) {
|
||||
if (after == EMPTY) {
|
||||
return this;
|
||||
}
|
||||
return tooltip -> {
|
||||
modify(tooltip);
|
||||
after.modify(tooltip);
|
||||
};
|
||||
}
|
||||
|
||||
static TooltipModifier mapNull(@Nullable TooltipModifier modifier) {
|
||||
if (modifier == null) {
|
||||
return EMPTY;
|
||||
}
|
||||
return modifier;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.item.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraftforge.client.model.BakedModelWrapper;
|
||||
@@ -19,7 +18,7 @@ public class CustomRenderedItemModel extends BakedModelWrapper<BakedModel> {
|
||||
|
||||
@Override
|
||||
public BakedModel applyTransform(ItemDisplayContext cameraItemDisplayContext, PoseStack mat,
|
||||
boolean leftHand) {
|
||||
boolean leftHand) {
|
||||
// Super call returns originalModel, but we want to return this, else BEWLR
|
||||
// won't be used.
|
||||
super.applyTransform(cameraItemDisplayContext, mat, leftHand);
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.item.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public abstract class CustomRenderedItemModelRenderer extends BlockEntityWithoutLevelRenderer {
|
||||
|
||||
public CustomRenderedItemModelRenderer() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderByItem(ItemStack stack, ItemDisplayContext transformType, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
|
||||
CustomRenderedItemModel mainModel = (CustomRenderedItemModel) Minecraft.getInstance()
|
||||
.getItemRenderer()
|
||||
.getModel(stack, null, null, 0);
|
||||
PartialItemModelRenderer renderer = PartialItemModelRenderer.of(stack, transformType, ms, buffer, overlay);
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(0.5F, 0.5F, 0.5F);
|
||||
render(stack, mainModel, renderer, transformType, ms, buffer, light, overlay);
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
protected abstract void render(ItemStack stack, CustomRenderedItemModel model, PartialItemModelRenderer renderer, ItemDisplayContext transformType,
|
||||
PoseStack ms, MultiBufferSource buffer, int light, int overlay);
|
||||
|
||||
}
|
||||
@@ -2,9 +2,6 @@ package nl.requios.effortlessbuilding.create.foundation.item.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.RenderTypes;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@@ -16,6 +13,8 @@ import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.RenderTypes;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Iterate;
|
||||
|
||||
public class PartialItemModelRenderer {
|
||||
|
||||
@@ -48,13 +47,13 @@ public class PartialItemModelRenderer {
|
||||
render(model, RenderTypes.getItemPartialSolid(), light);
|
||||
}
|
||||
|
||||
public void renderSolidGlowing(BakedModel model, int light) {
|
||||
render(model, RenderTypes.getGlowingSolid(), light);
|
||||
}
|
||||
|
||||
public void renderGlowing(BakedModel model, int light) {
|
||||
render(model, RenderTypes.getGlowingTranslucent(), light);
|
||||
}
|
||||
// public void renderSolidGlowing(BakedModel model, int light) {
|
||||
// render(model, RenderTypes.getGlowingSolid(), light);
|
||||
// }
|
||||
//
|
||||
// public void renderGlowing(BakedModel model, int light) {
|
||||
// render(model, RenderTypes.getGlowingTranslucent(), light);
|
||||
// }
|
||||
|
||||
public void render(BakedModel model, RenderType type, int light) {
|
||||
if (stack.isEmpty())
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.mixin.accessor;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public interface EntityAccessor {
|
||||
@Invoker("setLevel")
|
||||
void create$callSetLevel(Level level);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.mixin.accessor;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public interface GameRendererAccessor {
|
||||
@Invoker("getFov")
|
||||
double create$callGetFov(Camera camera, float partialTicks, boolean useFOVSetting);
|
||||
}
|
||||
@@ -1,24 +1,17 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.networking;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
//import nl.requios.effortlessbuilding.create.AllPackets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.network.NetworkEvent.Context;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public interface ISyncPersistentData {
|
||||
|
||||
void onPersistentDataUpdated();
|
||||
|
||||
// default void syncPersistentDataWithTracking(Entity self) {
|
||||
// AllPackets.getChannel().send(PacketDistributor.TRACKING_ENTITY.with(() -> self), new PersistentDataPacket(self));
|
||||
// }
|
||||
|
||||
public static class PersistentDataPacket extends SimplePacketBase {
|
||||
|
||||
private int entityId;
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.outliner;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.RenderTypes;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class AABBOutline extends Outline {
|
||||
|
||||
protected AABB bb;
|
||||
|
||||
protected final Vector3f minPosTemp1 = new Vector3f();
|
||||
protected final Vector3f maxPosTemp1 = new Vector3f();
|
||||
|
||||
protected final Vector4f colorTemp1 = new Vector4f();
|
||||
protected final Vector3f pos0Temp = new Vector3f();
|
||||
protected final Vector3f pos1Temp = new Vector3f();
|
||||
protected final Vector3f pos2Temp = new Vector3f();
|
||||
protected final Vector3f pos3Temp = new Vector3f();
|
||||
protected final Vector3f normalTemp = new Vector3f();
|
||||
protected final Vector3f originTemp = new Vector3f();
|
||||
|
||||
public AABBOutline(AABB bb) {
|
||||
setBounds(bb);
|
||||
}
|
||||
|
||||
public AABB getBounds() {
|
||||
return bb;
|
||||
}
|
||||
|
||||
public void setBounds(AABB bb) {
|
||||
this.bb = bb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
params.loadColor(colorTemp);
|
||||
Vector4f color = colorTemp;
|
||||
int lightmap = params.lightmap;
|
||||
boolean disableLineNormals = params.disableLineNormals;
|
||||
renderBox(ms, buffer, camera, bb, color, lightmap, disableLineNormals);
|
||||
}
|
||||
|
||||
protected void renderBox(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, AABB box, Vector4f color, int lightmap, boolean disableLineNormals) {
|
||||
Vector3f minPos = minPosTemp1;
|
||||
Vector3f maxPos = maxPosTemp1;
|
||||
|
||||
boolean cameraInside = box.contains(camera);
|
||||
boolean cull = !cameraInside && !params.disableCull;
|
||||
float inflate = cameraInside ? -1 / 128f : 1 / 128f;
|
||||
|
||||
box = box.move(camera.scale(-1));
|
||||
minPos.set((float) box.minX - inflate, (float) box.minY - inflate, (float) box.minZ - inflate);
|
||||
maxPos.set((float) box.maxX + inflate, (float) box.maxY + inflate, (float) box.maxZ + inflate);
|
||||
|
||||
renderBoxFaces(ms, buffer, cull, params.getHighlightedFace(), minPos, maxPos, color, lightmap);
|
||||
|
||||
float lineWidth = params.getLineWidth();
|
||||
if (lineWidth == 0)
|
||||
return;
|
||||
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid());
|
||||
renderBoxEdges(ms, consumer, minPos, maxPos, lineWidth, color, lightmap, disableLineNormals);
|
||||
}
|
||||
|
||||
protected void renderBoxFaces(PoseStack ms, SuperRenderTypeBuffer buffer, boolean cull, Direction highlightedFace, Vector3f minPos, Vector3f maxPos, Vector4f color, int lightmap) {
|
||||
PoseStack.Pose pose = ms.last();
|
||||
renderBoxFace(pose, buffer, cull, highlightedFace, minPos, maxPos, Direction.DOWN, color, lightmap);
|
||||
renderBoxFace(pose, buffer, cull, highlightedFace, minPos, maxPos, Direction.UP, color, lightmap);
|
||||
renderBoxFace(pose, buffer, cull, highlightedFace, minPos, maxPos, Direction.NORTH, color, lightmap);
|
||||
renderBoxFace(pose, buffer, cull, highlightedFace, minPos, maxPos, Direction.SOUTH, color, lightmap);
|
||||
renderBoxFace(pose, buffer, cull, highlightedFace, minPos, maxPos, Direction.WEST, color, lightmap);
|
||||
renderBoxFace(pose, buffer, cull, highlightedFace, minPos, maxPos, Direction.EAST, color, lightmap);
|
||||
}
|
||||
|
||||
protected void renderBoxFace(PoseStack.Pose pose, SuperRenderTypeBuffer buffer, boolean cull, Direction highlightedFace, Vector3f minPos, Vector3f maxPos, Direction face, Vector4f color, int lightmap) {
|
||||
boolean highlighted = face == highlightedFace;
|
||||
|
||||
// TODO: Presumably, the other texture should be used, but this was not noticed before so fixing it may lead to suboptimal visuals.
|
||||
// Optional<AllSpecialTextures> optionalFaceTexture = highlighted ? params.hightlightedFaceTexture : params.faceTexture;
|
||||
Optional<AllSpecialTextures> optionalFaceTexture = params.faceTexture;
|
||||
if (!optionalFaceTexture.isPresent())
|
||||
return;
|
||||
AllSpecialTextures faceTexture = optionalFaceTexture.get();
|
||||
|
||||
RenderType renderType = RenderTypes.getOutlineTranslucent(faceTexture.getLocation(), cull);
|
||||
VertexConsumer consumer = buffer.getLateBuffer(renderType);
|
||||
|
||||
float alphaMult = highlighted ? 1 : 0.5f;
|
||||
colorTemp1.set(color.x(), color.y(), color.z(), color.w() * alphaMult);
|
||||
color = colorTemp1;
|
||||
|
||||
renderBoxFace(pose, consumer, minPos, maxPos, face, color, lightmap);
|
||||
}
|
||||
|
||||
protected void renderBoxFace(PoseStack.Pose pose, VertexConsumer consumer, Vector3f minPos, Vector3f maxPos, Direction face, Vector4f color, int lightmap) {
|
||||
Vector3f pos0 = pos0Temp;
|
||||
Vector3f pos1 = pos1Temp;
|
||||
Vector3f pos2 = pos2Temp;
|
||||
Vector3f pos3 = pos3Temp;
|
||||
Vector3f normal = normalTemp;
|
||||
|
||||
float minX = minPos.x();
|
||||
float minY = minPos.y();
|
||||
float minZ = minPos.z();
|
||||
float maxX = maxPos.x();
|
||||
float maxY = maxPos.y();
|
||||
float maxZ = maxPos.z();
|
||||
|
||||
float maxU;
|
||||
float maxV;
|
||||
|
||||
switch (face) {
|
||||
case DOWN -> {
|
||||
// 0 1 2 3
|
||||
pos0.set(minX, minY, maxZ);
|
||||
pos1.set(minX, minY, minZ);
|
||||
pos2.set(maxX, minY, minZ);
|
||||
pos3.set(maxX, minY, maxZ);
|
||||
maxU = maxX - minX;
|
||||
maxV = maxZ - minZ;
|
||||
normal.set(0, -1, 0);
|
||||
}
|
||||
case UP -> {
|
||||
// 4 5 6 7
|
||||
pos0.set(minX, maxY, minZ);
|
||||
pos1.set(minX, maxY, maxZ);
|
||||
pos2.set(maxX, maxY, maxZ);
|
||||
pos3.set(maxX, maxY, minZ);
|
||||
maxU = maxX - minX;
|
||||
maxV = maxZ - minZ;
|
||||
normal.set(0, 1, 0);
|
||||
}
|
||||
case NORTH -> {
|
||||
// 7 2 1 4
|
||||
pos0.set(maxX, maxY, minZ);
|
||||
pos1.set(maxX, minY, minZ);
|
||||
pos2.set(minX, minY, minZ);
|
||||
pos3.set(minX, maxY, minZ);
|
||||
maxU = maxX - minX;
|
||||
maxV = maxY - minY;
|
||||
normal.set(0, 0, -1);
|
||||
}
|
||||
case SOUTH -> {
|
||||
// 5 0 3 6
|
||||
pos0.set(minX, maxY, maxZ);
|
||||
pos1.set(minX, minY, maxZ);
|
||||
pos2.set(maxX, minY, maxZ);
|
||||
pos3.set(maxX, maxY, maxZ);
|
||||
maxU = maxX - minX;
|
||||
maxV = maxY - minY;
|
||||
normal.set(0, 0, 1);
|
||||
}
|
||||
case WEST -> {
|
||||
// 4 1 0 5
|
||||
pos0.set(minX, maxY, minZ);
|
||||
pos1.set(minX, minY, minZ);
|
||||
pos2.set(minX, minY, maxZ);
|
||||
pos3.set(minX, maxY, maxZ);
|
||||
maxU = maxZ - minZ;
|
||||
maxV = maxY - minY;
|
||||
normal.set(-1, 0, 0);
|
||||
}
|
||||
case EAST -> {
|
||||
// 6 3 2 7
|
||||
pos0.set(maxX, maxY, maxZ);
|
||||
pos1.set(maxX, minY, maxZ);
|
||||
pos2.set(maxX, minY, minZ);
|
||||
pos3.set(maxX, maxY, minZ);
|
||||
maxU = maxZ - minZ;
|
||||
maxV = maxY - minY;
|
||||
normal.set(1, 0, 0);
|
||||
}
|
||||
default -> {
|
||||
maxU = 1;
|
||||
maxV = 1;
|
||||
}
|
||||
}
|
||||
|
||||
bufferQuad(pose, consumer, pos0, pos1, pos2, pos3, color, 0, 0, maxU, maxV, lightmap, normal);
|
||||
}
|
||||
|
||||
protected void renderBoxEdges(PoseStack ms, VertexConsumer consumer, Vector3f minPos, Vector3f maxPos, float lineWidth, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
Vector3f origin = originTemp;
|
||||
|
||||
PoseStack.Pose pose = ms.last();
|
||||
|
||||
float lineLengthX = maxPos.x() - minPos.x();
|
||||
float lineLengthY = maxPos.y() - minPos.y();
|
||||
float lineLengthZ = maxPos.z() - minPos.z();
|
||||
|
||||
origin.set(minPos);
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.EAST, lineLengthX, lineWidth, color, lightmap, disableNormals);
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.UP, lineLengthY, lineWidth, color, lightmap, disableNormals);
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.SOUTH, lineLengthZ, lineWidth, color, lightmap, disableNormals);
|
||||
|
||||
origin.set(maxPos.x(), minPos.y(), minPos.z());
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.UP, lineLengthY, lineWidth, color, lightmap, disableNormals);
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.SOUTH, lineLengthZ, lineWidth, color, lightmap, disableNormals);
|
||||
|
||||
origin.set(minPos.x(), maxPos.y(), minPos.z());
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.EAST, lineLengthX, lineWidth, color, lightmap, disableNormals);
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.SOUTH, lineLengthZ, lineWidth, color, lightmap, disableNormals);
|
||||
|
||||
origin.set(minPos.x(), minPos.y(), maxPos.z());
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.EAST, lineLengthX, lineWidth, color, lightmap, disableNormals);
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.UP, lineLengthY, lineWidth, color, lightmap, disableNormals);
|
||||
|
||||
origin.set(minPos.x(), maxPos.y(), maxPos.z());
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.EAST, lineLengthX, lineWidth, color, lightmap, disableNormals);
|
||||
|
||||
origin.set(maxPos.x(), minPos.y(), maxPos.z());
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.UP, lineLengthY, lineWidth, color, lightmap, disableNormals);
|
||||
|
||||
origin.set(maxPos.x(), maxPos.y(), minPos.z());
|
||||
bufferCuboidLine(pose, consumer, origin, Direction.SOUTH, lineLengthZ, lineWidth, color, lightmap, disableNormals);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,272 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.outliner;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.RenderTypes;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.core.Direction.AxisDirection;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class BlockClusterOutline extends Outline {
|
||||
|
||||
private final Cluster cluster;
|
||||
|
||||
protected final Vector3f pos0Temp = new Vector3f();
|
||||
protected final Vector3f pos1Temp = new Vector3f();
|
||||
protected final Vector3f pos2Temp = new Vector3f();
|
||||
protected final Vector3f pos3Temp = new Vector3f();
|
||||
protected final Vector3f normalTemp = new Vector3f();
|
||||
protected final Vector3f originTemp = new Vector3f();
|
||||
|
||||
public BlockClusterOutline(Iterable<BlockPos> positions) {
|
||||
cluster = new Cluster();
|
||||
positions.forEach(cluster::include);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
params.loadColor(colorTemp);
|
||||
Vector4f color = colorTemp;
|
||||
int lightmap = params.lightmap;
|
||||
boolean disableLineNormals = params.disableLineNormals;
|
||||
|
||||
renderFaces(ms, buffer, camera, pt, color, lightmap);
|
||||
renderEdges(ms, buffer, camera, pt, color, lightmap, disableLineNormals);
|
||||
}
|
||||
|
||||
protected void renderFaces(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt, Vector4f color, int lightmap) {
|
||||
Optional<AllSpecialTextures> optionalFaceTexture = params.faceTexture;
|
||||
if (!optionalFaceTexture.isPresent())
|
||||
return;
|
||||
if (cluster.isEmpty())
|
||||
return;
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(cluster.anchor.getX() - camera.x, cluster.anchor.getY() - camera.y,
|
||||
cluster.anchor.getZ() - camera.z);
|
||||
|
||||
AllSpecialTextures faceTexture = optionalFaceTexture.get();
|
||||
PoseStack.Pose pose = ms.last();
|
||||
RenderType renderType = RenderTypes.getOutlineTranslucent(faceTexture.getLocation(), true);
|
||||
VertexConsumer consumer = buffer.getLateBuffer(renderType);
|
||||
|
||||
cluster.visibleFaces.forEach((face, axisDirection) -> {
|
||||
Direction direction = Direction.get(axisDirection, face.axis);
|
||||
BlockPos pos = face.pos;
|
||||
if (axisDirection == AxisDirection.POSITIVE)
|
||||
pos = pos.relative(direction.getOpposite());
|
||||
bufferBlockFace(pose, consumer, pos, direction, color, lightmap);
|
||||
});
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
protected void renderEdges(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
float lineWidth = params.getLineWidth();
|
||||
if (lineWidth == 0)
|
||||
return;
|
||||
if (cluster.isEmpty())
|
||||
return;
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(cluster.anchor.getX() - camera.x, cluster.anchor.getY() - camera.y,
|
||||
cluster.anchor.getZ() - camera.z);
|
||||
|
||||
PoseStack.Pose pose = ms.last();
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid());
|
||||
|
||||
cluster.visibleEdges.forEach(edge -> {
|
||||
BlockPos pos = edge.pos;
|
||||
Vector3f origin = originTemp;
|
||||
origin.set(pos.getX(), pos.getY(), pos.getZ());
|
||||
Direction direction = Direction.get(AxisDirection.POSITIVE, edge.axis);
|
||||
bufferCuboidLine(pose, consumer, origin, direction, 1, lineWidth, color, lightmap, disableNormals);
|
||||
});
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
public static void loadFaceData(Direction face, Vector3f pos0, Vector3f pos1, Vector3f pos2, Vector3f pos3, Vector3f normal) {
|
||||
switch (face) {
|
||||
case DOWN -> {
|
||||
// 0 1 2 3
|
||||
pos0.set(0, 0, 1);
|
||||
pos1.set(0, 0, 0);
|
||||
pos2.set(1, 0, 0);
|
||||
pos3.set(1, 0, 1);
|
||||
normal.set(0, -1, 0);
|
||||
}
|
||||
case UP -> {
|
||||
// 4 5 6 7
|
||||
pos0.set(0, 1, 0);
|
||||
pos1.set(0, 1, 1);
|
||||
pos2.set(1, 1, 1);
|
||||
pos3.set(1, 1, 0);
|
||||
normal.set(0, 1, 0);
|
||||
}
|
||||
case NORTH -> {
|
||||
// 7 2 1 4
|
||||
pos0.set(1, 1, 0);
|
||||
pos1.set(1, 0, 0);
|
||||
pos2.set(0, 0, 0);
|
||||
pos3.set(0, 1, 0);
|
||||
normal.set(0, 0, -1);
|
||||
}
|
||||
case SOUTH -> {
|
||||
// 5 0 3 6
|
||||
pos0.set(0, 1, 1);
|
||||
pos1.set(0, 0, 1);
|
||||
pos2.set(1, 0, 1);
|
||||
pos3.set(1, 1, 1);
|
||||
normal.set(0, 0, 1);
|
||||
}
|
||||
case WEST -> {
|
||||
// 4 1 0 5
|
||||
pos0.set(0, 1, 0);
|
||||
pos1.set(0, 0, 0);
|
||||
pos2.set(0, 0, 1);
|
||||
pos3.set(0, 1, 1);
|
||||
normal.set(-1, 0, 0);
|
||||
}
|
||||
case EAST -> {
|
||||
// 6 3 2 7
|
||||
pos0.set(1, 1, 1);
|
||||
pos1.set(1, 0, 1);
|
||||
pos2.set(1, 0, 0);
|
||||
pos3.set(1, 1, 0);
|
||||
normal.set(1, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addPos(float x, float y, float z, Vector3f pos0, Vector3f pos1, Vector3f pos2, Vector3f pos3) {
|
||||
pos0.add(x, y, z);
|
||||
pos1.add(x, y, z);
|
||||
pos2.add(x, y, z);
|
||||
pos3.add(x, y, z);
|
||||
}
|
||||
|
||||
protected void bufferBlockFace(PoseStack.Pose pose, VertexConsumer consumer, BlockPos pos, Direction face, Vector4f color, int lightmap) {
|
||||
Vector3f pos0 = pos0Temp;
|
||||
Vector3f pos1 = pos1Temp;
|
||||
Vector3f pos2 = pos2Temp;
|
||||
Vector3f pos3 = pos3Temp;
|
||||
Vector3f normal = normalTemp;
|
||||
|
||||
loadFaceData(face, pos0, pos1, pos2, pos3, normal);
|
||||
addPos(pos.getX() + face.getStepX() * 1 / 128f,
|
||||
pos.getY() + face.getStepY() * 1 / 128f,
|
||||
pos.getZ() + face.getStepZ() * 1 / 128f,
|
||||
pos0, pos1, pos2, pos3);
|
||||
|
||||
bufferQuad(pose, consumer, pos0, pos1, pos2, pos3, color, lightmap, normal);
|
||||
}
|
||||
|
||||
private static class Cluster {
|
||||
|
||||
private BlockPos anchor;
|
||||
private Map<MergeEntry, AxisDirection> visibleFaces;
|
||||
private Set<MergeEntry> visibleEdges;
|
||||
|
||||
public Cluster() {
|
||||
visibleEdges = new HashSet<>();
|
||||
visibleFaces = new HashMap<>();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return anchor == null;
|
||||
}
|
||||
|
||||
public void include(BlockPos pos) {
|
||||
if (anchor == null)
|
||||
anchor = pos;
|
||||
|
||||
pos = pos.subtract(anchor);
|
||||
|
||||
// 6 FACES
|
||||
for (Axis axis : Iterate.axes) {
|
||||
Direction direction = Direction.get(AxisDirection.POSITIVE, axis);
|
||||
for (int offset : Iterate.zeroAndOne) {
|
||||
MergeEntry entry = new MergeEntry(axis, pos.relative(direction, offset));
|
||||
if (visibleFaces.remove(entry) == null)
|
||||
visibleFaces.put(entry, offset == 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
|
||||
}
|
||||
}
|
||||
|
||||
// 12 EDGES
|
||||
for (Axis axis : Iterate.axes) {
|
||||
for (Axis axis2 : Iterate.axes) {
|
||||
if (axis == axis2)
|
||||
continue;
|
||||
for (Axis axis3 : Iterate.axes) {
|
||||
if (axis == axis3)
|
||||
continue;
|
||||
if (axis2 == axis3)
|
||||
continue;
|
||||
|
||||
Direction direction = Direction.get(AxisDirection.POSITIVE, axis2);
|
||||
Direction direction2 = Direction.get(AxisDirection.POSITIVE, axis3);
|
||||
|
||||
for (int offset : Iterate.zeroAndOne) {
|
||||
BlockPos entryPos = pos.relative(direction, offset);
|
||||
for (int offset2 : Iterate.zeroAndOne) {
|
||||
entryPos = entryPos.relative(direction2, offset2);
|
||||
MergeEntry entry = new MergeEntry(axis, entryPos);
|
||||
if (!visibleEdges.remove(entry))
|
||||
visibleEdges.add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class MergeEntry {
|
||||
|
||||
private Axis axis;
|
||||
private BlockPos pos;
|
||||
|
||||
public MergeEntry(Axis axis, BlockPos pos) {
|
||||
this.axis = axis;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof MergeEntry))
|
||||
return false;
|
||||
|
||||
MergeEntry other = (MergeEntry) o;
|
||||
return this.axis == other.axis && this.pos.equals(other.pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.pos.hashCode() * 31 + axis.ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.outliner;
|
||||
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class ItemOutline extends Outline {
|
||||
|
||||
protected Vec3 pos;
|
||||
protected ItemStack stack;
|
||||
|
||||
public ItemOutline(Vec3 pos, ItemStack stack) {
|
||||
this.pos = pos;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ms.pushPose();
|
||||
|
||||
TransformStack.cast(ms)
|
||||
.translate(pos.x - camera.x, pos.y - camera.y, pos.z - camera.z)
|
||||
.scale(params.alpha);
|
||||
|
||||
mc.getItemRenderer().render(stack, ItemDisplayContext.FIXED, false, ms,
|
||||
buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY,
|
||||
mc.getItemRenderer().getModel(stack, null, null, 0));
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.outliner;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.RenderTypes;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class LineOutline extends Outline {
|
||||
|
||||
protected final Vector3d start = new Vector3d(0, 0, 0);
|
||||
protected final Vector3d end = new Vector3d(0, 0, 0);
|
||||
|
||||
public LineOutline set(Vector3d start, Vector3d end) {
|
||||
this.start.set(start.x, start.y, start.z);
|
||||
this.end.set(end.x, end.y, end.z);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LineOutline set(Vec3 start, Vec3 end) {
|
||||
this.start.set(start.x, start.y, start.z);
|
||||
this.end.set(end.x, end.y, end.z);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
float width = params.getLineWidth();
|
||||
if (width == 0)
|
||||
return;
|
||||
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid());
|
||||
params.loadColor(colorTemp);
|
||||
Vector4f color = colorTemp;
|
||||
int lightmap = params.lightmap;
|
||||
boolean disableLineNormals = params.disableLineNormals;
|
||||
renderInner(ms, consumer, camera, pt, width, color, lightmap, disableLineNormals);
|
||||
}
|
||||
|
||||
protected void renderInner(PoseStack ms, VertexConsumer consumer, Vec3 camera, float pt, float width,
|
||||
Vector4f color, int lightmap, boolean disableNormals) {
|
||||
bufferCuboidLine(ms, consumer, camera, start, end, width, color, lightmap, disableNormals);
|
||||
}
|
||||
|
||||
public static class EndChasingLineOutline extends LineOutline {
|
||||
private float progress = 0;
|
||||
private float prevProgress = 0;
|
||||
private boolean lockStart;
|
||||
|
||||
private final Vector3d startTemp = new Vector3d(0, 0, 0);
|
||||
|
||||
public EndChasingLineOutline(boolean lockStart) {
|
||||
this.lockStart = lockStart;
|
||||
}
|
||||
|
||||
public EndChasingLineOutline setProgress(float progress) {
|
||||
prevProgress = this.progress;
|
||||
this.progress = progress;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderInner(PoseStack ms, VertexConsumer consumer, Vec3 camera, float pt, float width,
|
||||
Vector4f color, int lightmap, boolean disableNormals) {
|
||||
float distanceToTarget = Mth.lerp(pt, prevProgress, progress);
|
||||
|
||||
Vector3d end;
|
||||
if (lockStart) {
|
||||
end = this.start;
|
||||
} else {
|
||||
end = this.end;
|
||||
distanceToTarget = 1 - distanceToTarget;
|
||||
}
|
||||
|
||||
Vector3d start = this.startTemp;
|
||||
double x = (this.start.x - end.x) * distanceToTarget + end.x;
|
||||
double y = (this.start.y - end.y) * distanceToTarget + end.y;
|
||||
double z = (this.start.z - end.z) * distanceToTarget + end.z;
|
||||
start.set((float) x, (float) y, (float) z);
|
||||
bufferCuboidLine(ms, consumer, camera, start, end, width, color, lightmap, disableNormals);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,601 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.outliner;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperRenderTypeBuffer;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.AngleHelper;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public abstract class Outline {
|
||||
|
||||
protected final OutlineParams params;
|
||||
|
||||
protected final Vector4f colorTemp = new Vector4f();
|
||||
protected final Vector3f diffPosTemp = new Vector3f();
|
||||
protected final Vector3f minPosTemp = new Vector3f();
|
||||
protected final Vector3f maxPosTemp = new Vector3f();
|
||||
protected final Vector4f posTransformTemp = new Vector4f();
|
||||
protected final Vector3f normalTransformTemp = new Vector3f();
|
||||
|
||||
public Outline() {
|
||||
params = new OutlineParams();
|
||||
}
|
||||
|
||||
public OutlineParams getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt);
|
||||
|
||||
public void tick() {}
|
||||
|
||||
public void bufferCuboidLine(PoseStack poseStack, VertexConsumer consumer, Vec3 camera, Vector3d start, Vector3d end,
|
||||
float width, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
Vector3f diff = this.diffPosTemp;
|
||||
diff.set((float) (end.x - start.x), (float) (end.y - start.y), (float) (end.z - start.z));
|
||||
|
||||
float length = Mth.sqrt(diff.x() * diff.x() + diff.y() * diff.y() + diff.z() * diff.z());
|
||||
float hAngle = AngleHelper.deg(Mth.atan2(diff.x(), diff.z()));
|
||||
float hDistance = Mth.sqrt(diff.x() * diff.x() + diff.z() * diff.z());
|
||||
float vAngle = AngleHelper.deg(Mth.atan2(hDistance, diff.y())) - 90;
|
||||
|
||||
poseStack.pushPose();
|
||||
TransformStack.cast(poseStack)
|
||||
.translate(start.x - camera.x, start.y - camera.y, start.z - camera.z)
|
||||
.rotateY(hAngle)
|
||||
.rotateX(vAngle);
|
||||
bufferCuboidLine(poseStack.last(), consumer, new Vector3f(), Direction.SOUTH, length, width, color, lightmap,
|
||||
disableNormals);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
public void bufferCuboidLine(PoseStack.Pose pose, VertexConsumer consumer, Vector3f origin, Direction direction,
|
||||
float length, float width, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
Vector3f minPos = minPosTemp;
|
||||
Vector3f maxPos = maxPosTemp;
|
||||
|
||||
float halfWidth = width / 2;
|
||||
minPos.set(origin.x() - halfWidth, origin.y() - halfWidth, origin.z() - halfWidth);
|
||||
maxPos.set(origin.x() + halfWidth, origin.y() + halfWidth, origin.z() + halfWidth);
|
||||
|
||||
switch (direction) {
|
||||
case DOWN -> {
|
||||
minPos.add(0, -length, 0);
|
||||
}
|
||||
case UP -> {
|
||||
maxPos.add(0, length, 0);
|
||||
}
|
||||
case NORTH -> {
|
||||
minPos.add(0, 0, -length);
|
||||
}
|
||||
case SOUTH -> {
|
||||
maxPos.add(0, 0, length);
|
||||
}
|
||||
case WEST -> {
|
||||
minPos.add(-length, 0, 0);
|
||||
}
|
||||
case EAST -> {
|
||||
maxPos.add(length, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
bufferCuboid(pose, consumer, minPos, maxPos, color, lightmap, disableNormals);
|
||||
}
|
||||
|
||||
public void bufferCuboid(PoseStack.Pose pose, VertexConsumer consumer, Vector3f minPos, Vector3f maxPos,
|
||||
Vector4f color, int lightmap, boolean disableNormals) {
|
||||
Vector4f posTransformTemp = this.posTransformTemp;
|
||||
Vector3f normalTransformTemp = this.normalTransformTemp;
|
||||
|
||||
float minX = minPos.x();
|
||||
float minY = minPos.y();
|
||||
float minZ = minPos.z();
|
||||
float maxX = maxPos.x();
|
||||
float maxY = maxPos.y();
|
||||
float maxZ = maxPos.z();
|
||||
|
||||
Matrix4f posMatrix = pose.pose();
|
||||
|
||||
posTransformTemp.set(minX, minY, maxZ, 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x0 = posTransformTemp.x();
|
||||
double y0 = posTransformTemp.y();
|
||||
double z0 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(minX, minY, minZ, 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x1 = posTransformTemp.x();
|
||||
double y1 = posTransformTemp.y();
|
||||
double z1 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(maxX, minY, minZ, 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x2 = posTransformTemp.x();
|
||||
double y2 = posTransformTemp.y();
|
||||
double z2 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(maxX, minY, maxZ, 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x3 = posTransformTemp.x();
|
||||
double y3 = posTransformTemp.y();
|
||||
double z3 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(minX, maxY, minZ, 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x4 = posTransformTemp.x();
|
||||
double y4 = posTransformTemp.y();
|
||||
double z4 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(minX, maxY, maxZ, 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x5 = posTransformTemp.x();
|
||||
double y5 = posTransformTemp.y();
|
||||
double z5 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(maxX, maxY, maxZ, 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x6 = posTransformTemp.x();
|
||||
double y6 = posTransformTemp.y();
|
||||
double z6 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(maxX, maxY, minZ, 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x7 = posTransformTemp.x();
|
||||
double y7 = posTransformTemp.y();
|
||||
double z7 = posTransformTemp.z();
|
||||
|
||||
float r = color.x();
|
||||
float g = color.y();
|
||||
float b = color.z();
|
||||
float a = color.w();
|
||||
|
||||
Matrix3f normalMatrix = pose.normal();
|
||||
|
||||
// down
|
||||
|
||||
if (disableNormals) {
|
||||
normalTransformTemp.set(0, 1, 0);
|
||||
} else {
|
||||
normalTransformTemp.set(0, -1, 0);
|
||||
}
|
||||
normalTransformTemp.mul(normalMatrix);
|
||||
float nx0 = normalTransformTemp.x();
|
||||
float ny0 = normalTransformTemp.y();
|
||||
float nz0 = normalTransformTemp.z();
|
||||
|
||||
consumer.vertex(x0, y0, z0)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx0, ny0, nz0)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x1, y1, z1)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx0, ny0, nz0)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x2, y2, z2)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx0, ny0, nz0)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x3, y3, z3)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx0, ny0, nz0)
|
||||
.endVertex();
|
||||
|
||||
// up
|
||||
|
||||
normalTransformTemp.set(0, 1, 0);
|
||||
normalTransformTemp.mul(normalMatrix);
|
||||
float nx1 = normalTransformTemp.x();
|
||||
float ny1 = normalTransformTemp.y();
|
||||
float nz1 = normalTransformTemp.z();
|
||||
|
||||
consumer.vertex(x4, y4, z4)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx1, ny1, nz1)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x5, y5, z5)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx1, ny1, nz1)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x6, y6, z6)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx1, ny1, nz1)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x7, y7, z7)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx1, ny1, nz1)
|
||||
.endVertex();
|
||||
|
||||
// north
|
||||
|
||||
if (disableNormals) {
|
||||
normalTransformTemp.set(0, 1, 0);
|
||||
} else {
|
||||
normalTransformTemp.set(0, 0, -1);
|
||||
}
|
||||
normalTransformTemp.mul(normalMatrix);
|
||||
float nx2 = normalTransformTemp.x();
|
||||
float ny2 = normalTransformTemp.y();
|
||||
float nz2 = normalTransformTemp.z();
|
||||
|
||||
consumer.vertex(x7, y7, z7)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx2, ny2, nz2)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x2, y2, z2)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx2, ny2, nz2)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x1, y1, z1)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx2, ny2, nz2)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x4, y4, z4)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx2, ny2, nz2)
|
||||
.endVertex();
|
||||
|
||||
// south
|
||||
|
||||
if (disableNormals) {
|
||||
normalTransformTemp.set(0, 1, 0);
|
||||
} else {
|
||||
normalTransformTemp.set(0, 0, 1);
|
||||
}
|
||||
normalTransformTemp.mul(normalMatrix);
|
||||
float nx3 = normalTransformTemp.x();
|
||||
float ny3 = normalTransformTemp.y();
|
||||
float nz3 = normalTransformTemp.z();
|
||||
|
||||
consumer.vertex(x5, y5, z5)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx3, ny3, nz3)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x0, y0, z0)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx3, ny3, nz3)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x3, y3, z3)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx3, ny3, nz3)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x6, y6, z6)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx3, ny3, nz3)
|
||||
.endVertex();
|
||||
|
||||
// west
|
||||
|
||||
if (disableNormals) {
|
||||
normalTransformTemp.set(0, 1, 0);
|
||||
} else {
|
||||
normalTransformTemp.set(-1, 0, 0);
|
||||
}
|
||||
normalTransformTemp.mul(normalMatrix);
|
||||
float nx4 = normalTransformTemp.x();
|
||||
float ny4 = normalTransformTemp.y();
|
||||
float nz4 = normalTransformTemp.z();
|
||||
|
||||
consumer.vertex(x4, y4, z4)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx4, ny4, nz4)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x1, y1, z1)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx4, ny4, nz4)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x0, y0, z0)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx4, ny4, nz4)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x5, y5, z5)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx4, ny4, nz4)
|
||||
.endVertex();
|
||||
|
||||
// east
|
||||
|
||||
if (disableNormals) {
|
||||
normalTransformTemp.set(0, 1, 0);
|
||||
} else {
|
||||
normalTransformTemp.set(1, 0, 0);
|
||||
}
|
||||
normalTransformTemp.mul(normalMatrix);
|
||||
float nx5 = normalTransformTemp.x();
|
||||
float ny5 = normalTransformTemp.y();
|
||||
float nz5 = normalTransformTemp.z();
|
||||
|
||||
consumer.vertex(x6, y6, z6)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx5, ny5, nz5)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x3, y3, z3)
|
||||
.color(r, g, b, a)
|
||||
.uv(0, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx5, ny5, nz5)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x2, y2, z2)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 1)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx5, ny5, nz5)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x7, y7, z7)
|
||||
.color(r, g, b, a)
|
||||
.uv(1, 0)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx5, ny5, nz5)
|
||||
.endVertex();
|
||||
}
|
||||
|
||||
public void bufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2,
|
||||
Vector3f pos3, Vector4f color, int lightmap, Vector3f normal) {
|
||||
bufferQuad(pose, consumer, pos0, pos1, pos2, pos3, color, 0, 0, 1, 1, lightmap, normal);
|
||||
}
|
||||
|
||||
public void bufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2,
|
||||
Vector3f pos3, Vector4f color, float minU, float minV, float maxU, float maxV, int lightmap, Vector3f normal) {
|
||||
Vector4f posTransformTemp = this.posTransformTemp;
|
||||
Vector3f normalTransformTemp = this.normalTransformTemp;
|
||||
|
||||
Matrix4f posMatrix = pose.pose();
|
||||
|
||||
posTransformTemp.set(pos0.x(), pos0.y(), pos0.z(), 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x0 = posTransformTemp.x();
|
||||
double y0 = posTransformTemp.y();
|
||||
double z0 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(pos1.x(), pos1.y(), pos1.z(), 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x1 = posTransformTemp.x();
|
||||
double y1 = posTransformTemp.y();
|
||||
double z1 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(pos2.x(), pos2.y(), pos2.z(), 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x2 = posTransformTemp.x();
|
||||
double y2 = posTransformTemp.y();
|
||||
double z2 = posTransformTemp.z();
|
||||
|
||||
posTransformTemp.set(pos3.x(), pos3.y(), pos3.z(), 1);
|
||||
posTransformTemp.mul(posMatrix);
|
||||
double x3 = posTransformTemp.x();
|
||||
double y3 = posTransformTemp.y();
|
||||
double z3 = posTransformTemp.z();
|
||||
|
||||
float r = color.x();
|
||||
float g = color.y();
|
||||
float b = color.z();
|
||||
float a = color.w();
|
||||
|
||||
normalTransformTemp.set(normal);
|
||||
normalTransformTemp.mul(pose.normal());
|
||||
float nx = normalTransformTemp.x();
|
||||
float ny = normalTransformTemp.y();
|
||||
float nz = normalTransformTemp.z();
|
||||
|
||||
consumer.vertex(x0, y0, z0)
|
||||
.color(r, g, b, a)
|
||||
.uv(minU, minV)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx, ny, nz)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x1, y1, z1)
|
||||
.color(r, g, b, a)
|
||||
.uv(minU, maxV)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx, ny, nz)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x2, y2, z2)
|
||||
.color(r, g, b, a)
|
||||
.uv(maxU, maxV)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx, ny, nz)
|
||||
.endVertex();
|
||||
|
||||
consumer.vertex(x3, y3, z3)
|
||||
.color(r, g, b, a)
|
||||
.uv(maxU, minV)
|
||||
.overlayCoords(OverlayTexture.NO_OVERLAY)
|
||||
.uv2(lightmap)
|
||||
.normal(nx, ny, nz)
|
||||
.endVertex();
|
||||
}
|
||||
|
||||
public static class OutlineParams {
|
||||
protected Optional<AllSpecialTextures> faceTexture;
|
||||
protected Optional<AllSpecialTextures> hightlightedFaceTexture;
|
||||
protected Direction highlightedFace;
|
||||
protected boolean fadeLineWidth;
|
||||
protected boolean disableCull;
|
||||
protected boolean disableLineNormals;
|
||||
protected float alpha;
|
||||
protected int lightmap;
|
||||
protected Color rgb;
|
||||
private float lineWidth;
|
||||
|
||||
public OutlineParams() {
|
||||
faceTexture = hightlightedFaceTexture = Optional.empty();
|
||||
alpha = 1;
|
||||
lineWidth = 1 / 32f;
|
||||
fadeLineWidth = true;
|
||||
rgb = Color.WHITE;
|
||||
lightmap = LightTexture.FULL_BRIGHT;
|
||||
}
|
||||
|
||||
// builder
|
||||
|
||||
public OutlineParams colored(int color) {
|
||||
rgb = new Color(color, false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OutlineParams colored(Color c) {
|
||||
rgb = c.copy();
|
||||
return this;
|
||||
}
|
||||
|
||||
public OutlineParams lightmap(int light) {
|
||||
lightmap = light;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OutlineParams lineWidth(float width) {
|
||||
this.lineWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OutlineParams withFaceTexture(AllSpecialTextures texture) {
|
||||
this.faceTexture = Optional.ofNullable(texture);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OutlineParams clearTextures() {
|
||||
return this.withFaceTextures(null, null);
|
||||
}
|
||||
|
||||
public OutlineParams withFaceTextures(AllSpecialTextures texture, AllSpecialTextures highlightTexture) {
|
||||
this.faceTexture = Optional.ofNullable(texture);
|
||||
this.hightlightedFaceTexture = Optional.ofNullable(highlightTexture);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OutlineParams highlightFace(@Nullable Direction face) {
|
||||
highlightedFace = face;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OutlineParams disableLineNormals() {
|
||||
disableLineNormals = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OutlineParams disableCull() {
|
||||
disableCull = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
// getter
|
||||
|
||||
public float getLineWidth() {
|
||||
return fadeLineWidth ? alpha * lineWidth : lineWidth;
|
||||
}
|
||||
|
||||
public Direction getHighlightedFace() {
|
||||
return highlightedFace;
|
||||
}
|
||||
|
||||
public void loadColor(Vector4f vec) {
|
||||
vec.set(rgb.getRedAsFloat(), rgb.getGreenAsFloat(), rgb.getBlueAsFloat(), rgb.getAlphaAsFloat() * alpha);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||
|
||||
import com.jozufozu.flywheel.core.model.ModelUtil;
|
||||
import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferedData;
|
||||
import com.jozufozu.flywheel.util.Pair;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
@@ -13,7 +13,7 @@ public class BakedModelRenderHelper {
|
||||
|
||||
public static SuperByteBuffer standardBlockRender(BlockState renderedState) {
|
||||
BlockRenderDispatcher dispatcher = Minecraft.getInstance()
|
||||
.getBlockRenderer();
|
||||
.getBlockRenderer();
|
||||
return standardModelRender(dispatcher.getBlockModel(renderedState), renderedState);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ public class BakedModelRenderHelper {
|
||||
}
|
||||
|
||||
public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState, PoseStack ms) {
|
||||
ShadeSeparatedBufferedData data = ModelUtil.getBufferedData(model, referenceState, ms);
|
||||
SuperByteBuffer sbb = new SuperByteBuffer(data);
|
||||
data.release();
|
||||
return sbb;
|
||||
Pair<BufferBuilder.RenderedBuffer, Integer> pair = ModelUtil.getBufferBuilder(model, referenceState, ms);
|
||||
return new SuperByteBuffer(pair.first(), pair.second());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||
|
||||
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.CreateClient;
|
||||
import nl.requios.effortlessbuilding.create.foundation.render.SuperByteBufferCache.Compartment;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.AngleHelper;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
public class CachedBufferer {
|
||||
|
||||
public static final Compartment<BlockState> GENERIC_BLOCK = new Compartment<>();
|
||||
public static final Compartment<BlockState> GENERIC_TILE = new Compartment<>();
|
||||
public static final Compartment<PartialModel> PARTIAL = new Compartment<>();
|
||||
public static final Compartment<Pair<Direction, PartialModel>> DIRECTIONAL_PARTIAL = new Compartment<>();
|
||||
|
||||
public static SuperByteBuffer block(BlockState toRender) {
|
||||
return block(GENERIC_BLOCK, toRender);
|
||||
return block(GENERIC_TILE, toRender);
|
||||
}
|
||||
|
||||
public static SuperByteBuffer block(Compartment<BlockState> compartment, BlockState toRender) {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.util.DiffuseLightCalculator;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class ForcedDiffuseState {
|
||||
private static final ThreadLocal<ObjectArrayList<DiffuseLightCalculator>> FORCED_DIFFUSE = ThreadLocal.withInitial(ObjectArrayList::new);
|
||||
|
||||
|
||||
@@ -1,33 +1,24 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterShadersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
// TODO 1.17: use custom shaders instead of vanilla ones
|
||||
public class RenderTypes extends RenderStateShard {
|
||||
|
||||
public static final RenderStateShard.ShaderStateShard GLOWING_SHADER = new RenderStateShard.ShaderStateShard(() -> Shaders.glowingShader);
|
||||
// public static final ShaderStateShard GLOWING_SHADER = new ShaderStateShard(() -> Shaders.glowingShader);
|
||||
|
||||
private static final RenderType OUTLINE_SOLID =
|
||||
RenderType.create(createLayerName("outline_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false,
|
||||
false, RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_ENTITY_SOLID_SHADER)
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(AllSpecialTextures.BLANK.getLocation(), false, false))
|
||||
.setTextureState(new TextureStateShard(AllSpecialTextures.BLANK.getLocation(), false, false))
|
||||
.setCullState(CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
@@ -41,7 +32,7 @@ public class RenderTypes extends RenderStateShard {
|
||||
return RenderType.create(createLayerName("outline_translucent" + (cull ? "_cull" : "")),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(cull ? RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER : RENDERTYPE_ENTITY_TRANSLUCENT_SHADER)
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
||||
.setTextureState(new TextureStateShard(texture, false, false))
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setCullState(cull ? CULL : NO_CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
@@ -50,38 +41,38 @@ public class RenderTypes extends RenderStateShard {
|
||||
.createCompositeState(false));
|
||||
}
|
||||
|
||||
public static RenderType getGlowingSolid(ResourceLocation texture) {
|
||||
return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256,
|
||||
true, false, RenderType.CompositeState.builder()
|
||||
.setShaderState(GLOWING_SHADER)
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
||||
.setCullState(CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
}
|
||||
// public static RenderType getGlowingSolid(ResourceLocation texture) {
|
||||
// return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256,
|
||||
// true, false, RenderType.CompositeState.builder()
|
||||
// .setShaderState(GLOWING_SHADER)
|
||||
// .setTextureState(new TextureStateShard(texture, false, false))
|
||||
// .setCullState(CULL)
|
||||
// .setLightmapState(LIGHTMAP)
|
||||
// .setOverlayState(OVERLAY)
|
||||
// .createCompositeState(true));
|
||||
// }
|
||||
//
|
||||
// private static final RenderType GLOWING_SOLID_DEFAULT = getGlowingSolid(InventoryMenu.BLOCK_ATLAS);
|
||||
//
|
||||
// public static RenderType getGlowingSolid() {
|
||||
// return GLOWING_SOLID_DEFAULT;
|
||||
// }
|
||||
|
||||
private static final RenderType GLOWING_SOLID_DEFAULT = getGlowingSolid(InventoryMenu.BLOCK_ATLAS);
|
||||
|
||||
public static RenderType getGlowingSolid() {
|
||||
return GLOWING_SOLID_DEFAULT;
|
||||
}
|
||||
|
||||
public static RenderType getGlowingTranslucent(ResourceLocation texture) {
|
||||
return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS,
|
||||
256, true, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(GLOWING_SHADER)
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
}
|
||||
// public static RenderType getGlowingTranslucent(ResourceLocation texture) {
|
||||
// return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS,
|
||||
// 256, true, true, RenderType.CompositeState.builder()
|
||||
// .setShaderState(GLOWING_SHADER)
|
||||
// .setTextureState(new TextureStateShard(texture, false, false))
|
||||
// .setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
// .setLightmapState(LIGHTMAP)
|
||||
// .setOverlayState(OVERLAY)
|
||||
// .createCompositeState(true));
|
||||
// }
|
||||
|
||||
private static final RenderType ADDITIVE = RenderType.create(createLayerName("additive"), DefaultVertexFormat.BLOCK,
|
||||
VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_SOLID_SHADER)
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(InventoryMenu.BLOCK_ATLAS, false, false))
|
||||
.setTextureState(new TextureStateShard(InventoryMenu.BLOCK_ATLAS, false, false))
|
||||
.setTransparencyState(ADDITIVE_TRANSPARENCY)
|
||||
.setCullState(NO_CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
@@ -92,11 +83,11 @@ public class RenderTypes extends RenderStateShard {
|
||||
return ADDITIVE;
|
||||
}
|
||||
|
||||
private static final RenderType GLOWING_TRANSLUCENT_DEFAULT = getGlowingTranslucent(InventoryMenu.BLOCK_ATLAS);
|
||||
// private static final RenderType GLOWING_TRANSLUCENT_DEFAULT = getGlowingTranslucent(InventoryMenu.BLOCK_ATLAS);
|
||||
|
||||
public static RenderType getGlowingTranslucent() {
|
||||
return GLOWING_TRANSLUCENT_DEFAULT;
|
||||
}
|
||||
// public static RenderType getGlowingTranslucent() {
|
||||
// return GLOWING_TRANSLUCENT_DEFAULT;
|
||||
// }
|
||||
|
||||
private static final RenderType ITEM_PARTIAL_SOLID =
|
||||
RenderType.create(createLayerName("item_partial_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true,
|
||||
@@ -147,15 +138,15 @@ public class RenderTypes extends RenderStateShard {
|
||||
super(null, null, null);
|
||||
}
|
||||
|
||||
@EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
|
||||
private static class Shaders {
|
||||
private static ShaderInstance glowingShader;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterShaders(RegisterShadersEvent event) throws IOException {
|
||||
ResourceProvider resourceProvider = event.getResourceProvider();
|
||||
event.registerShader(new ShaderInstance(resourceProvider, Create.asResource("glowing_shader"), DefaultVertexFormat.NEW_ENTITY), shader -> glowingShader = shader);
|
||||
}
|
||||
}
|
||||
// @EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
|
||||
// private static class Shaders {
|
||||
// private static ShaderInstance glowingShader;
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public static void onRegisterShaders(RegisterShadersEvent event) throws IOException {
|
||||
// ResourceManager resourceManager = event.getResourceManager();
|
||||
// event.registerShader(new ShaderInstance(resourceManager, Create.asResource("glowing_shader"), DefaultVertexFormat.NEW_ENTITY), shader -> glowingShader = shader);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.function.IntPredicate;
|
||||
|
||||
import com.jozufozu.flywheel.util.Color;
|
||||
import nl.requios.effortlessbuilding.create.foundation.block.render.SpriteShiftEntry;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
@@ -11,18 +9,15 @@ import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import com.jozufozu.flywheel.api.vertex.ShadedVertexList;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||
import com.jozufozu.flywheel.backend.ShadersModHandler;
|
||||
import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferedData;
|
||||
import com.jozufozu.flywheel.core.vertex.BlockVertexList;
|
||||
import com.jozufozu.flywheel.util.DiffuseLightCalculator;
|
||||
import com.jozufozu.flywheel.util.transform.TStack;
|
||||
import com.jozufozu.flywheel.util.transform.Transform;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder.DrawState;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import nl.requios.effortlessbuilding.create.foundation.block.render.SpriteShiftEntry;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
@@ -37,11 +32,10 @@ import net.minecraft.world.level.Level;
|
||||
|
||||
public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<SuperByteBuffer> {
|
||||
|
||||
private final VertexList template;
|
||||
private final IntPredicate shadedPredicate;
|
||||
private final ShadedVertexList template;
|
||||
|
||||
// Vertex Position
|
||||
private final PoseStack transforms = new PoseStack();
|
||||
private final PoseStack transforms;
|
||||
|
||||
// Vertex Coloring
|
||||
private boolean shouldColor;
|
||||
@@ -69,28 +63,11 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
// Temporary
|
||||
private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap();
|
||||
|
||||
public SuperByteBuffer(ByteBuffer vertexBuffer, BufferBuilder.DrawState drawState, int unshadedStartVertex) {
|
||||
int vertexCount = drawState.vertexCount();
|
||||
int stride = drawState.format().getVertexSize();
|
||||
|
||||
ShadedVertexList template = new BlockVertexList.Shaded(vertexBuffer, vertexCount, stride, unshadedStartVertex);
|
||||
shadedPredicate = template::isShaded;
|
||||
this.template = template;
|
||||
|
||||
transforms.pushPose();
|
||||
}
|
||||
|
||||
public SuperByteBuffer(ShadeSeparatedBufferedData data) {
|
||||
this(data.vertexBuffer(), data.drawState(), data.unshadedStartVertex());
|
||||
}
|
||||
|
||||
public SuperByteBuffer(ByteBuffer vertexBuffer, BufferBuilder.DrawState drawState) {
|
||||
int vertexCount = drawState.vertexCount();
|
||||
int stride = drawState.format().getVertexSize();
|
||||
|
||||
template = new BlockVertexList(vertexBuffer, vertexCount, stride);
|
||||
shadedPredicate = index -> true;
|
||||
public SuperByteBuffer(RenderedBuffer buf, int unshadedStartVertex) {
|
||||
DrawState drawState = buf.drawState();
|
||||
template = new BlockVertexList.Shaded(buf.vertexBuffer(), drawState.vertexCount(), drawState.format().getVertexSize(), unshadedStartVertex);
|
||||
|
||||
transforms = new PoseStack();
|
||||
transforms.pushPose();
|
||||
}
|
||||
|
||||
@@ -99,21 +76,21 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
return;
|
||||
|
||||
Matrix4f modelMat = new Matrix4f(input.last()
|
||||
.pose());
|
||||
.pose());
|
||||
Matrix4f localTransforms = transforms.last()
|
||||
.pose();
|
||||
.pose();
|
||||
modelMat.mul(localTransforms);
|
||||
|
||||
Matrix3f normalMat;
|
||||
if (fullNormalTransform) {
|
||||
normalMat = new Matrix3f(input.last()
|
||||
.normal());
|
||||
.normal());
|
||||
Matrix3f localNormalTransforms = transforms.last()
|
||||
.normal();
|
||||
.normal();
|
||||
normalMat.mul(localNormalTransforms);
|
||||
} else {
|
||||
normalMat = new Matrix3f(transforms.last()
|
||||
.normal());
|
||||
.normal());
|
||||
}
|
||||
|
||||
if (useWorldLight) {
|
||||
@@ -126,7 +103,7 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
|
||||
DiffuseLightCalculator diffuseCalculator = ForcedDiffuseState.getForcedCalculator();
|
||||
final boolean disableDiffuseMult =
|
||||
this.disableDiffuseMult || (ShadersModHandler.isShaderPackInUse() && diffuseCalculator == null);
|
||||
this.disableDiffuseMult || (ShadersModHandler.isShaderPackInUse() && diffuseCalculator == null);
|
||||
if (diffuseCalculator == null) {
|
||||
diffuseCalculator = this.diffuseCalculator;
|
||||
if (diffuseCalculator == null) {
|
||||
@@ -169,7 +146,7 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
if (disableDiffuseMult) {
|
||||
builder.color(r, g, b, a);
|
||||
} else {
|
||||
float instanceDiffuse = diffuseCalculator.getDiffuse(nx, ny, nz, shadedPredicate.test(i));
|
||||
float instanceDiffuse = diffuseCalculator.getDiffuse(nx, ny, nz, template.isShaded(i));
|
||||
int colorR = transformColor(r, instanceDiffuse);
|
||||
int colorG = transformColor(g, instanceDiffuse);
|
||||
int colorB = transformColor(b, instanceDiffuse);
|
||||
@@ -248,10 +225,6 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
return template.isEmpty();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
template.delete();
|
||||
}
|
||||
|
||||
public PoseStack getTransforms() {
|
||||
return transforms;
|
||||
}
|
||||
@@ -289,40 +262,40 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
@Override
|
||||
public SuperByteBuffer mulPose(Matrix4f pose) {
|
||||
transforms.last()
|
||||
.pose()
|
||||
.mul(pose);
|
||||
.pose()
|
||||
.mul(pose);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuperByteBuffer mulNormal(Matrix3f normal) {
|
||||
transforms.last()
|
||||
.normal()
|
||||
.mul(normal);
|
||||
.normal()
|
||||
.mul(normal);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer transform(PoseStack stack) {
|
||||
transforms.last()
|
||||
.pose()
|
||||
.mul(stack.last()
|
||||
.pose());
|
||||
.pose()
|
||||
.mul(stack.last()
|
||||
.pose());
|
||||
transforms.last()
|
||||
.normal()
|
||||
.mul(stack.last()
|
||||
.normal());
|
||||
.normal()
|
||||
.mul(stack.last()
|
||||
.normal());
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer rotateCentered(Direction axis, float radians) {
|
||||
translate(.5f, .5f, .5f).rotate(axis, radians)
|
||||
.translate(-.5f, -.5f, -.5f);
|
||||
.translate(-.5f, -.5f, -.5f);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer rotateCentered(Quaternionf q) {
|
||||
translate(.5f, .5f, .5f).multiply(q)
|
||||
.translate(-.5f, -.5f, -.5f);
|
||||
.translate(-.5f, -.5f, -.5f);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -377,13 +350,13 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
public SuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollU, float scrollV) {
|
||||
this.spriteShiftFunc = (builder, u, v) -> {
|
||||
float targetU = u - entry.getOriginal()
|
||||
.getU0() + entry.getTarget()
|
||||
.getU0() + entry.getTarget()
|
||||
.getU0()
|
||||
+ scrollU;
|
||||
+ scrollU;
|
||||
float targetV = v - entry.getOriginal()
|
||||
.getV0() + entry.getTarget()
|
||||
.getV0() + entry.getTarget()
|
||||
.getV0()
|
||||
+ scrollV;
|
||||
+ scrollV;
|
||||
builder.uv(targetU, targetV);
|
||||
};
|
||||
return this;
|
||||
@@ -392,9 +365,9 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
public SuperByteBuffer shiftUVtoSheet(SpriteShiftEntry entry, float uTarget, float vTarget, int sheetSize) {
|
||||
this.spriteShiftFunc = (builder, u, v) -> {
|
||||
float targetU = entry.getTarget()
|
||||
.getU((SpriteShiftEntry.getUnInterpolatedU(entry.getOriginal(), u) / sheetSize) + uTarget * 16);
|
||||
.getU((SpriteShiftEntry.getUnInterpolatedU(entry.getOriginal(), u) / sheetSize) + uTarget * 16);
|
||||
float targetV = entry.getTarget()
|
||||
.getV((SpriteShiftEntry.getUnInterpolatedV(entry.getOriginal(), v) / sheetSize) + vTarget * 16);
|
||||
.getV((SpriteShiftEntry.getUnInterpolatedV(entry.getOriginal(), v) / sheetSize) + vTarget * 16);
|
||||
builder.uv(targetU, targetV);
|
||||
};
|
||||
return this;
|
||||
@@ -491,4 +464,4 @@ public class SuperByteBuffer implements Transform<SuperByteBuffer>, TStack<Super
|
||||
int getPackedLight(float x, float y, float z);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,13 @@ public class SuperByteBufferCache {
|
||||
|
||||
public synchronized void registerCompartment(Compartment<?> compartment) {
|
||||
caches.put(compartment, CacheBuilder.newBuilder()
|
||||
.<Object, SuperByteBuffer>removalListener(n -> n.getValue().delete())
|
||||
.build());
|
||||
.build());
|
||||
}
|
||||
|
||||
public synchronized void registerCompartment(Compartment<?> compartment, long ticksUntilExpired) {
|
||||
caches.put(compartment, CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS)
|
||||
.<Object, SuperByteBuffer>removalListener(n -> n.getValue().delete())
|
||||
.build());
|
||||
.expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS)
|
||||
.build());
|
||||
}
|
||||
|
||||
public <T> SuperByteBuffer get(Compartment<T> compartment, T key, Callable<SuperByteBuffer> callable) {
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SuperRenderTypeBuffer implements MultiBufferSource {
|
||||
put(map, p_173062_);
|
||||
});
|
||||
});
|
||||
private final MultiBufferSource.BufferSource bufferSource = MultiBufferSource.immediateWithBuffers(fixedBuffers, new BufferBuilder(256));
|
||||
private final BufferSource bufferSource = MultiBufferSource.immediateWithBuffers(fixedBuffers, new BufferBuilder(256));
|
||||
|
||||
private static void put(Object2ObjectLinkedOpenHashMap<RenderType, BufferBuilder> map, RenderType type) {
|
||||
map.put(type, new BufferBuilder(type.bufferSize()));
|
||||
|
||||
@@ -1,23 +1,11 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.render;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||
import com.jozufozu.flywheel.config.BackendType;
|
||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.AnimationTickHolder;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.RegisteredObjects;
|
||||
//import nl.requios.effortlessbuilding.create.infrastructure.config.AllConfigs;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
@@ -26,41 +14,49 @@ import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.AnimationTickHolder;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.RegisteredObjects;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
public class BlockEntityRenderHelper {
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Iterator;
|
||||
|
||||
public static void renderBlockEntities(Level world, Iterable<BlockEntity> customRenderBEs, PoseStack ms,
|
||||
public class TileEntityRenderHelper {
|
||||
|
||||
public static void renderTileEntities(Level world, Iterable<BlockEntity> customRenderTEs, PoseStack ms,
|
||||
MultiBufferSource buffer) {
|
||||
renderBlockEntities(world, null, customRenderBEs, ms, null, buffer);
|
||||
renderTileEntities(world, null, customRenderTEs, ms, null, buffer);
|
||||
}
|
||||
|
||||
public static void renderBlockEntities(Level world, Iterable<BlockEntity> customRenderBEs, PoseStack ms,
|
||||
public static void renderTileEntities(Level world, Iterable<BlockEntity> customRenderTEs, PoseStack ms,
|
||||
MultiBufferSource buffer, float pt) {
|
||||
renderBlockEntities(world, null, customRenderBEs, ms, null, buffer, pt);
|
||||
renderTileEntities(world, null, customRenderTEs, ms, null, buffer, pt);
|
||||
}
|
||||
|
||||
public static void renderBlockEntities(Level world, @Nullable VirtualRenderWorld renderWorld,
|
||||
Iterable<BlockEntity> customRenderBEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer) {
|
||||
renderBlockEntities(world, renderWorld, customRenderBEs, ms, lightTransform, buffer,
|
||||
public static void renderTileEntities(Level world, @Nullable VirtualRenderWorld renderWorld,
|
||||
Iterable<BlockEntity> customRenderTEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer) {
|
||||
renderTileEntities(world, renderWorld, customRenderTEs, ms, lightTransform, buffer,
|
||||
AnimationTickHolder.getPartialTicks());
|
||||
}
|
||||
|
||||
public static void renderBlockEntities(Level world, @Nullable VirtualRenderWorld renderWorld,
|
||||
Iterable<BlockEntity> customRenderBEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer,
|
||||
public static void renderTileEntities(Level world, @Nullable VirtualRenderWorld renderWorld,
|
||||
Iterable<BlockEntity> customRenderTEs, PoseStack ms, @Nullable Matrix4f lightTransform, MultiBufferSource buffer,
|
||||
float pt) {
|
||||
Iterator<BlockEntity> iterator = customRenderBEs.iterator();
|
||||
Iterator<BlockEntity> iterator = customRenderTEs.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
BlockEntity blockEntity = iterator.next();
|
||||
if (Backend.getBackendType() == BackendType.INSTANCING && Backend.isFlywheelWorld(renderWorld) && InstancedRenderRegistry.shouldSkipRender(blockEntity))
|
||||
BlockEntity tileEntity = iterator.next();
|
||||
if (Backend.getBackendType() == BackendType.INSTANCING && Backend.isFlywheelWorld(renderWorld) && InstancedRenderRegistry.shouldSkipRender(tileEntity))
|
||||
continue;
|
||||
|
||||
BlockEntityRenderer<BlockEntity> renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(blockEntity);
|
||||
BlockEntityRenderer<BlockEntity> renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(tileEntity);
|
||||
if (renderer == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockPos pos = blockEntity.getBlockPos();
|
||||
BlockPos pos = tileEntity.getBlockPos();
|
||||
ms.pushPose();
|
||||
TransformStack.cast(ms)
|
||||
.translate(pos);
|
||||
@@ -70,22 +66,22 @@ public class BlockEntityRenderHelper {
|
||||
|
||||
if (renderWorld != null) {
|
||||
// Swap the real world for the render world so that the renderer gets contraption-local information
|
||||
blockEntity.setLevel(renderWorld);
|
||||
renderer.render(blockEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY);
|
||||
blockEntity.setLevel(world);
|
||||
tileEntity.setLevel(renderWorld);
|
||||
renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY);
|
||||
tileEntity.setLevel(world);
|
||||
} else {
|
||||
renderer.render(blockEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY);
|
||||
renderer.render(tileEntity, pt, ms, buffer, worldLight, OverlayTexture.NO_OVERLAY);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
iterator.remove();
|
||||
|
||||
String message = "BlockEntity " + RegisteredObjects.getKeyOrThrow(blockEntity.getType())
|
||||
String message = "BlockEntity " + RegisteredObjects.getKeyOrThrow(tileEntity.getType())
|
||||
.toString() + " could not be rendered virtually.";
|
||||
// if (AllConfigs.client().explainRenderErrors.get())
|
||||
// Create.LOGGER.error(message, e);
|
||||
// if (AllConfigs.CLIENT.explainRenderErrors.get())
|
||||
Create.LOGGER.error(message, e);
|
||||
// else
|
||||
Create.LOGGER.error(message);
|
||||
// Create.LOGGER.error(message);
|
||||
}
|
||||
|
||||
ms.popPose();
|
||||
@@ -1,10 +1,5 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -13,6 +8,10 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class AbstractBlockBreakQueue {
|
||||
protected Consumer<BlockPos> makeCallbackFor(Level world, float effectChance, ItemStack toDamage,
|
||||
@Nullable Player playerEntity, BiConsumer<BlockPos, ItemStack> drop) {
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
//import nl.requios.effortlessbuilding.create.foundation.ponder.PonderWorld;
|
||||
//import nl.requios.effortlessbuilding.create.foundation.ponder.ui.PonderUI;
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.worldWrappers.WrappedClientWorld;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
@@ -46,7 +43,7 @@ public class AnimationTickHolder {
|
||||
public static int getTicks(LevelAccessor world) {
|
||||
if (world instanceof WrappedClientWorld)
|
||||
return getTicks(((WrappedClientWorld) world).getWrappedWorld());
|
||||
return /*world instanceof PonderWorld ? PonderUI.ponderTicks : */getTicks();
|
||||
return getTicks();
|
||||
}
|
||||
|
||||
public static float getRenderTime(LevelAccessor world) {
|
||||
@@ -54,6 +51,6 @@ public class AnimationTickHolder {
|
||||
}
|
||||
|
||||
public static float getPartialTicks(LevelAccessor world) {
|
||||
return /*world instanceof PonderWorld ? PonderUI.getPartialTicks() : */getPartialTicks();
|
||||
return getPartialTicks();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
public class AttachedRegistry<K, V> {
|
||||
private static final List<AttachedRegistry<?, ?>> ALL = new ArrayList<>();
|
||||
|
||||
protected final IForgeRegistry<K> objectRegistry;
|
||||
protected final Map<ResourceLocation, V> idMap = new HashMap<>();
|
||||
protected final Map<K, V> objectMap = new IdentityHashMap<>();
|
||||
protected final Map<ResourceLocation, Function<K, V>> deferredRegistrations = new HashMap<>();
|
||||
protected boolean unwrapped = false;
|
||||
|
||||
public AttachedRegistry(IForgeRegistry<K> objectRegistry) {
|
||||
this.objectRegistry = objectRegistry;
|
||||
ALL.add(this);
|
||||
}
|
||||
|
||||
public void register(ResourceLocation id, V value) {
|
||||
if (!unwrapped) {
|
||||
idMap.put(id, value);
|
||||
} else {
|
||||
K object = objectRegistry.getValue(id);
|
||||
if (object != null) {
|
||||
objectMap.put(object, value);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for id '" + id + "' in AttachedRegistry after unwrapping!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void register(K object, V value) {
|
||||
if (unwrapped) {
|
||||
objectMap.put(object, value);
|
||||
} else {
|
||||
ResourceLocation id = objectRegistry.getKey(object);
|
||||
if (id != null) {
|
||||
idMap.put(id, value);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get id of object '" + object + "' in AttachedRegistry before unwrapping!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerDeferred(ResourceLocation id, Function<K, V> func) {
|
||||
if (!unwrapped) {
|
||||
deferredRegistrations.put(id, func);
|
||||
} else {
|
||||
K object = objectRegistry.getValue(id);
|
||||
if (object != null) {
|
||||
objectMap.put(object, func.apply(object));
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for id '" + id + "' in AttachedRegistry after unwrapping!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerDeferred(K object, Function<K, V> func) {
|
||||
if (unwrapped) {
|
||||
objectMap.put(object, func.apply(object));
|
||||
} else {
|
||||
ResourceLocation id = objectRegistry.getKey(object);
|
||||
if (id != null) {
|
||||
deferredRegistrations.put(id, func);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get id of object '" + object + "' in AttachedRegistry before unwrapping!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public V get(ResourceLocation id) {
|
||||
if (!unwrapped) {
|
||||
return idMap.get(id);
|
||||
} else {
|
||||
K object = objectRegistry.getValue(id);
|
||||
if (object != null) {
|
||||
return objectMap.get(object);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for id '" + id + "' in AttachedRegistry after unwrapping!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public V get(K object) {
|
||||
if (unwrapped) {
|
||||
return objectMap.get(object);
|
||||
} else {
|
||||
ResourceLocation id = objectRegistry.getKey(object);
|
||||
if (id != null) {
|
||||
return idMap.get(id);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get id of object '" + object + "' in AttachedRegistry before unwrapping!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUnwrapped() {
|
||||
return unwrapped;
|
||||
}
|
||||
|
||||
protected void unwrap() {
|
||||
deferredRegistrations.forEach((id, func) -> {
|
||||
K object = objectRegistry.getValue(id);
|
||||
if (object != null) {
|
||||
objectMap.put(object, func.apply(object));
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for id '" + id + "' in AttachedRegistry during unwrapping!");
|
||||
}
|
||||
});
|
||||
|
||||
idMap.forEach((id, value) -> {
|
||||
K object = objectRegistry.getValue(id);
|
||||
if (object != null) {
|
||||
objectMap.put(object, value);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for id '" + id + "' in AttachedRegistry during unwrapping!");
|
||||
}
|
||||
});
|
||||
|
||||
deferredRegistrations.clear();
|
||||
idMap.clear();
|
||||
unwrapped = true;
|
||||
}
|
||||
|
||||
public static void unwrapAll() {
|
||||
for (AttachedRegistry<?, ?> registry : ALL) {
|
||||
registry.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
//import nl.requios.effortlessbuilding.create.AllBlocks;
|
||||
//import nl.requios.effortlessbuilding.create.AllTags.AllBlockTags;
|
||||
//import nl.requios.effortlessbuilding.create.content.kinetics.base.KineticBlockEntity;
|
||||
//import nl.requios.effortlessbuilding.create.foundation.blockEntity.IMergeableBE;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.SectionPos;
|
||||
@@ -47,6 +38,9 @@ import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.level.BlockEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class BlockHelper {
|
||||
|
||||
public static BlockState setZeroAge(BlockState blockState) {
|
||||
@@ -158,11 +152,11 @@ public class BlockHelper {
|
||||
float effectChance, Consumer<ItemStack> droppedItemCallback) {
|
||||
FluidState fluidState = world.getFluidState(pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
|
||||
if (world.random.nextFloat() < effectChance)
|
||||
world.levelEvent(2001, pos, Block.getId(state));
|
||||
BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
||||
|
||||
BlockEntity tileentity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
||||
|
||||
if (player != null) {
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
@@ -180,7 +174,7 @@ public class BlockHelper {
|
||||
if (world instanceof ServerLevel && world.getGameRules()
|
||||
.getBoolean(GameRules.RULE_DOBLOCKDROPS) && !world.restoringBlockSnapshots
|
||||
&& (player == null || !player.isCreative())) {
|
||||
for (ItemStack itemStack : Block.getDrops(state, (ServerLevel) world, pos, blockEntity, player, usedTool))
|
||||
for (ItemStack itemStack : Block.getDrops(state, (ServerLevel) world, pos, tileentity, player, usedTool))
|
||||
droppedItemCallback.accept(itemStack);
|
||||
|
||||
// Simulating IceBlock#playerDestroy. Not calling method directly as it would drop item
|
||||
@@ -190,15 +184,15 @@ public class BlockHelper {
|
||||
.ultraWarm())
|
||||
return false;
|
||||
|
||||
BlockState blockstate = world.getBlockState(pos.below());
|
||||
if (blockstate.blocksMotion() || blockstate.liquid())
|
||||
BlockState belowState = world.getBlockState(pos.below());
|
||||
if (belowState.getMaterial().blocksMotion() || belowState.getMaterial().isLiquid())
|
||||
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());
|
||||
return true;
|
||||
}
|
||||
|
||||
state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY, true);
|
||||
}
|
||||
|
||||
|
||||
world.setBlockAndUpdate(pos, fluidState.createLegacyBlock());
|
||||
return true;
|
||||
}
|
||||
@@ -219,8 +213,8 @@ public class BlockHelper {
|
||||
int idx = chunk.getSectionIndex(target.getY());
|
||||
LevelChunkSection chunksection = chunk.getSection(idx);
|
||||
if (chunksection == null) {
|
||||
chunksection = new LevelChunkSection(world.registryAccess()
|
||||
.registryOrThrow(Registries.BIOME));
|
||||
chunksection = new LevelChunkSection(chunk.getSectionYFromSectionIndex(idx), world.registryAccess()
|
||||
.registryOrThrow(Registries.BIOME));
|
||||
chunk.getSections()[idx] = chunksection;
|
||||
}
|
||||
BlockState old = chunksection.setBlockState(SectionPos.sectionRelative(target.getX()),
|
||||
@@ -233,24 +227,9 @@ public class BlockHelper {
|
||||
.getBlock(), target.below());
|
||||
}
|
||||
|
||||
public static CompoundTag prepareBlockEntityData(BlockState blockState, BlockEntity blockEntity) {
|
||||
CompoundTag data = null;
|
||||
if (blockEntity == null)
|
||||
return data;
|
||||
/*if (AllBlockTags.SAFE_NBT.matches(blockState)) {
|
||||
data = blockEntity.saveWithFullMetadata();
|
||||
data = NBTProcessors.process(blockEntity, data, true);
|
||||
} else */if (blockEntity instanceof IPartialSafeNBT) {
|
||||
data = new CompoundTag();
|
||||
((IPartialSafeNBT) blockEntity).writeSafe(data);
|
||||
data = NBTProcessors.process(blockEntity, data, true);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static void placeSchematicBlock(Level world, BlockState state, BlockPos target, ItemStack stack,
|
||||
public static boolean placeSchematicBlock(Level world, Player player, BlockState state, BlockPos target, ItemStack stack,
|
||||
@Nullable CompoundTag data) {
|
||||
BlockEntity existingBlockEntity = world.getBlockEntity(target);
|
||||
BlockEntity existingTile = world.getBlockEntity(target);
|
||||
|
||||
// Piston
|
||||
if (state.hasProperty(BlockStateProperties.EXTENDED))
|
||||
@@ -278,42 +257,40 @@ public class BlockHelper {
|
||||
0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
Block.dropResources(state, world, target);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (state.getBlock() instanceof BaseRailBlock) {
|
||||
placeRailWithoutUpdate(world, state, target);
|
||||
} /*else if (AllBlocks.BELT.has(state)) {
|
||||
world.setBlock(target, state, 2);
|
||||
} */else {
|
||||
world.setBlock(target, state, 2); //Changed flag from 18 to 2
|
||||
} else {
|
||||
world.setBlock(target, state, 2); //Changed flag from 18 to 3
|
||||
}
|
||||
|
||||
if (data != null) {
|
||||
// if (existingBlockEntity instanceof IMergeableBE mergeable) {
|
||||
// if (existingTile instanceof IMergeableTE mergeable) {
|
||||
// BlockEntity loaded = BlockEntity.loadStatic(target, state, data);
|
||||
// if (existingBlockEntity.getType()
|
||||
// if (existingTile.getType()
|
||||
// .equals(loaded.getType())) {
|
||||
// mergeable.accept(loaded);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
BlockEntity blockEntity = world.getBlockEntity(target);
|
||||
if (blockEntity != null) {
|
||||
BlockEntity tile = world.getBlockEntity(target);
|
||||
if (tile != null) {
|
||||
data.putInt("x", target.getX());
|
||||
data.putInt("y", target.getY());
|
||||
data.putInt("z", target.getZ());
|
||||
// if (blockEntity instanceof KineticBlockEntity)
|
||||
// ((KineticBlockEntity) blockEntity).warnOfMovement();
|
||||
blockEntity.load(data);
|
||||
// if (tile instanceof KineticTileEntity)
|
||||
// ((KineticTileEntity) tile).warnOfMovement();
|
||||
tile.load(data);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
state.getBlock()
|
||||
.setPlacedBy(world, target, state, null, stack);
|
||||
} catch (Exception e) {
|
||||
state.getBlock().setPlacedBy(world, target, state, null, stack);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static double getBounceMultiplier(Block block) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.foundation.utility.animation.LerpedFloat;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class Color {
|
||||
public final static Color TRANSPARENT_BLACK = new Color(0, 0, 0, 0).setImmutable();
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import nl.requios.effortlessbuilding.create.AllKeys;
|
||||
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Options;
|
||||
|
||||
public class ControlsUtil {
|
||||
|
||||
private static Vector<KeyMapping> standardControls;
|
||||
|
||||
public static Vector<KeyMapping> getControls() {
|
||||
if (standardControls == null) {
|
||||
Options gameSettings = Minecraft.getInstance().options;
|
||||
standardControls = new Vector<>(6);
|
||||
standardControls.add(gameSettings.keyUp);
|
||||
standardControls.add(gameSettings.keyDown);
|
||||
standardControls.add(gameSettings.keyLeft);
|
||||
standardControls.add(gameSettings.keyRight);
|
||||
standardControls.add(gameSettings.keyJump);
|
||||
standardControls.add(gameSettings.keyShift);
|
||||
}
|
||||
return standardControls;
|
||||
}
|
||||
|
||||
public static boolean isActuallyPressed(KeyMapping kb) {
|
||||
InputConstants.Key key = kb.getKey();
|
||||
if (key.getType() == InputConstants.Type.MOUSE) {
|
||||
return AllKeys.isMouseButtonDown(key.getValue());
|
||||
} else {
|
||||
return AllKeys.isKeyDown(key.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,14 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
||||
public class Couple<T> extends Pair<T, T> implements Iterable<T> {
|
||||
|
||||
private static final Couple<Boolean> TRUE_AND_FALSE = Couple.create(true, false);
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CreateRegistry<K, V> {
|
||||
private static final List<CreateRegistry<?, ?>> ALL = new ArrayList<>();
|
||||
|
||||
protected final IForgeRegistry<K> objectRegistry;
|
||||
protected final Map<ResourceLocation, V> locationMap = new HashMap<>();
|
||||
protected final Map<K, V> objectMap = new IdentityHashMap<>();
|
||||
protected boolean unwrapped = false;
|
||||
|
||||
public CreateRegistry(IForgeRegistry<K> objectRegistry) {
|
||||
this.objectRegistry = objectRegistry;
|
||||
ALL.add(this);
|
||||
}
|
||||
|
||||
public void register(ResourceLocation location, V value) {
|
||||
if (!unwrapped) {
|
||||
locationMap.put(location, value);
|
||||
} else {
|
||||
K object = objectRegistry.getValue(location);
|
||||
if (object != null) {
|
||||
objectMap.put(object, value);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for location '" + location + "' in CreateRegistry after unwrapping!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void register(K object, V value) {
|
||||
if (unwrapped) {
|
||||
objectMap.put(object, value);
|
||||
} else {
|
||||
ResourceLocation location = objectRegistry.getKey(object);
|
||||
if (location != null) {
|
||||
locationMap.put(location, value);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get location of object '" + object + "' in CreateRegistry before unwrapping!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public V get(ResourceLocation location) {
|
||||
if (!unwrapped) {
|
||||
return locationMap.get(location);
|
||||
} else {
|
||||
K object = objectRegistry.getValue(location);
|
||||
if (object != null) {
|
||||
return objectMap.get(object);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for location '" + location + "' in CreateRegistry after unwrapping!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public V get(K object) {
|
||||
if (unwrapped) {
|
||||
return objectMap.get(object);
|
||||
} else {
|
||||
ResourceLocation location = objectRegistry.getKey(object);
|
||||
if (location != null) {
|
||||
return locationMap.get(location);
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get location of object '" + object + "' in CreateRegistry before unwrapping!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUnwrapped() {
|
||||
return unwrapped;
|
||||
}
|
||||
|
||||
protected void unwrap() {
|
||||
for (Map.Entry<ResourceLocation, V> entry : locationMap.entrySet()) {
|
||||
ResourceLocation location = entry.getKey();
|
||||
K object = objectRegistry.getValue(location);
|
||||
if (object != null) {
|
||||
objectMap.put(object, entry.getValue());
|
||||
} else {
|
||||
Create.LOGGER.warn("Could not get object for location '" + location + "' in CreateRegistry during unwrapping!");
|
||||
}
|
||||
}
|
||||
unwrapped = true;
|
||||
}
|
||||
|
||||
public static void unwrapAll() {
|
||||
for (CreateRegistry<?, ?> registry : ALL) {
|
||||
registry.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import nl.requios.effortlessbuilding.create.Create;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package nl.requios.effortlessbuilding.create.foundation.utility;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class DyeHelper {
|
||||
|
||||
public static ItemLike getWoolOfDye(DyeColor color) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user