mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-26 21:28:35 +01:00
Compare commits
6 commits
c2b2204696
...
c8c0db6aa9
Author | SHA1 | Date | |
---|---|---|---|
c8c0db6aa9 | |||
ad9f228ba4 | |||
1fde0cce24 | |||
fe1010a4d6 | |||
05b815ac97 | |||
3d3b1465c5 |
40 changed files with 506 additions and 369 deletions
285
build.gradle
285
build.gradle
|
@ -1,82 +1,111 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
|
||||
maven { url = 'https://maven.minecraftforge.net' }
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
|
||||
}
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.13.6'
|
||||
group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'PrettyPipes'
|
||||
|
||||
if (System.getenv('BUILD_NUMBER') != null) {
|
||||
version += "." + System.getenv('BUILD_NUMBER')
|
||||
plugins {
|
||||
id 'eclipse'
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
||||
}
|
||||
|
||||
version = mod_version
|
||||
group = mod_group_id
|
||||
|
||||
base {
|
||||
archivesName = mod_name
|
||||
}
|
||||
|
||||
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
|
||||
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
|
||||
minecraft {
|
||||
mappings channel: 'official', version: '1.19'
|
||||
// The mappings can be changed at any time and must be in the following format.
|
||||
// Channel: Version:
|
||||
// official MCVersion Official field/method names from Mojang mapping files
|
||||
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
|
||||
//
|
||||
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
//
|
||||
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
|
||||
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
|
||||
//
|
||||
// Use non-default mappings at your own risk. They may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: mapping_channel, version: mapping_version
|
||||
|
||||
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
|
||||
// In most cases, it is not necessary to enable.
|
||||
// enableEclipsePrepareRuns = true
|
||||
// enableIdeaPrepareRuns = true
|
||||
|
||||
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
|
||||
// It is REQUIRED to be set to true for this template to function.
|
||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||
copyIdeResources = true
|
||||
|
||||
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
|
||||
// The folder name can be set on a run configuration using the "folderName" property.
|
||||
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
|
||||
// generateRunFolders = true
|
||||
|
||||
// This property enables access transformers for use in development.
|
||||
// They will be applied to the Minecraft artifact.
|
||||
// The access transformer file can be anywhere in the project.
|
||||
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
|
||||
// This default location is a best practice to automatically put the file in the right place in the final jar.
|
||||
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
client {
|
||||
// applies to all the run configs below
|
||||
configureEach {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||
// The markers can be added/remove as needed separated by commas.
|
||||
// "SCAN": For mods scan.
|
||||
// "REGISTRIES": For firing of registry events.
|
||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
property 'forge.logging.console.level', 'info'
|
||||
|
||||
mods {
|
||||
prettypipes {
|
||||
"${mod_id}" {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client {
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
}
|
||||
|
||||
server {
|
||||
workingDirectory project.file('run')
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
args '--nogui'
|
||||
}
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'info'
|
||||
|
||||
mods {
|
||||
prettypipes {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||
// By default, the server will crash when no gametests are provided.
|
||||
// The gametest system is also enabled by default for other run configs under the /test command.
|
||||
gameTestServer {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
}
|
||||
|
||||
data {
|
||||
workingDirectory project.file('run')
|
||||
// example of overriding the workingDirectory set in configureEach above
|
||||
workingDirectory project.file('run-data')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'info'
|
||||
|
||||
args '--mod', 'prettypipes', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/'), '--existing', file('src/generated/resources')
|
||||
|
||||
mods {
|
||||
prettypipes {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
}
|
||||
|
||||
|
||||
all {
|
||||
lazyToken('minecraft_classpath') {
|
||||
configurations.embed.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
|
||||
|
@ -85,90 +114,110 @@ minecraft {
|
|||
}
|
||||
}
|
||||
|
||||
sourceSets.main.resources {
|
||||
srcDir 'src/generated/resources'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = "https://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
maven {
|
||||
url = "https://www.cursemaven.com"
|
||||
}
|
||||
}
|
||||
// Include resources generated by data generators.
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
configurations {
|
||||
embed
|
||||
implementation.extendsFrom(embed)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.minecraftforge:forge:1.19.2-43.1.1'
|
||||
embed 'org.jgrapht:jgrapht-core:1.5.1'
|
||||
repositories {
|
||||
// Put repositories for dependencies here
|
||||
// ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.19.2-common-api:11.3.0.260")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.19.2-forge:11.3.0.260")
|
||||
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
|
||||
// flatDir {
|
||||
// dir 'libs'
|
||||
// }
|
||||
|
||||
// test storage drawers
|
||||
runtimeOnly fg.deobf("curse.maven:storage-drawers-223852:3884263")
|
||||
// it says this gets included automatically but apparently it doesn't
|
||||
mavenCentral()
|
||||
|
||||
// to test the rf requiring and crafting stuff
|
||||
/* runtimeOnly fg.deobf("curse.maven:powah-352656:3057732")
|
||||
runtimeOnly fg.deobf("curse.maven:lollipop-347954:3057731")
|
||||
runtimeOnly fg.deobf("curse.maven:mcjtylib-233105:3131241")
|
||||
runtimeOnly fg.deobf("curse.maven:rftools-base-326041:3140147")
|
||||
runtimeOnly fg.deobf("curse.maven:rftools-utility-342466:3152948")*/
|
||||
maven {
|
||||
url = "https://maven.blamejared.com"
|
||||
}
|
||||
maven {
|
||||
url = "https://www.cursemaven.com"
|
||||
}
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
jar {
|
||||
dependencies {
|
||||
// Specify the version of Minecraft to use.
|
||||
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
|
||||
// The "userdev" classifier will be requested and setup by ForgeGradle.
|
||||
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
|
||||
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
embed "org.jgrapht:jgrapht-core:${jgt_version}"
|
||||
|
||||
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
|
||||
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
||||
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
|
||||
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}")
|
||||
|
||||
// Example mod dependency using a mod jar from ./libs with a flat dir repository
|
||||
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
|
||||
// The group id is ignored when searching -- in this case, it is "blank"
|
||||
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
||||
|
||||
// For more info:
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
}
|
||||
|
||||
// This block of code expands all declared replace properties in the specified resource targets.
|
||||
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
|
||||
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
|
||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||
tasks.named('processResources', ProcessResources).configure {
|
||||
var replaceProperties = [
|
||||
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||
forge_version : forge_version, forge_version_range: forge_version_range,
|
||||
loader_version_range: loader_version_range,
|
||||
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
||||
mod_authors : mod_authors, mod_description: mod_description,
|
||||
]
|
||||
inputs.properties replaceProperties
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
||||
expand replaceProperties + [project: project]
|
||||
}
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading at runtime.
|
||||
tasks.named('jar', Jar).configure {
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title" : "prettypipes",
|
||||
"Specification-Vendor" : "Ellpeck",
|
||||
"Specification-Version" : "1", // We are version 1 of ourselves
|
||||
"Implementation-Title" : project.name,
|
||||
"Implementation-Version" : "${version}",
|
||||
"Implementation-Vendor" : "Ellpeck",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
'Specification-Title' : mod_id,
|
||||
'Specification-Vendor' : mod_authors,
|
||||
'Specification-Version' : '1', // We are version 1 of ourselves
|
||||
'Implementation-Title' : project.name,
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_authors,
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
])
|
||||
}
|
||||
from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
|
||||
// TODO figure out if leaving this out causes jgrapht to be left out of the jar
|
||||
// from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
|
||||
// This is the preferred method to reobfuscate your jar file
|
||||
finalizedBy 'reobfJar'
|
||||
}
|
||||
|
||||
task deobfJar(type: Jar) {
|
||||
from(sourceSets.main.output)
|
||||
archiveName = "${baseName}-${version}-deobf.${extension}"
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from(sourceSets.main.allSource)
|
||||
archiveName = "${baseName}-${version}-sources.${extension}"
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives deobfJar
|
||||
archives sourcesJar
|
||||
}
|
||||
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
|
||||
// tasks.named('publish').configure {
|
||||
// dependsOn 'reobfJar'
|
||||
// }
|
||||
|
||||
// Example configuration to allow publishing using the maven-publish plugin
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
groupId project.group
|
||||
artifactId project.archivesBaseName
|
||||
version project.version
|
||||
from components.java
|
||||
|
||||
artifact deobfJar {
|
||||
classifier 'deobf'
|
||||
}
|
||||
|
||||
artifact sourcesJar {
|
||||
classifier 'sources'
|
||||
}
|
||||
|
||||
register('mavenJava', MavenPublication) {
|
||||
artifact jar
|
||||
pom.withXml {
|
||||
def node = asNode()
|
||||
if (node.dependencies.size() > 0)
|
||||
|
@ -182,3 +231,7 @@ publishing {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||
}
|
||||
|
|
|
@ -1,4 +1,61 @@
|
|||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
org.gradle.daemon=false
|
||||
|
||||
|
||||
## Environment Properties
|
||||
|
||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||
minecraft_version=1.20.1
|
||||
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||
# as they do not follow standard versioning conventions.
|
||||
minecraft_version_range=[1.20.1,1.21)
|
||||
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||
forge_version=47.1.0
|
||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||
forge_version_range=[47,)
|
||||
# The loader version range can only use the major version of Forge/FML as bounds
|
||||
loader_version_range=[47,)
|
||||
# The mapping channel to use for mappings.
|
||||
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
||||
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
||||
#
|
||||
# | Channel | Version | |
|
||||
# |-----------|----------------------|--------------------------------------------------------------------------------|
|
||||
# | official | MCVersion | Official field/method names from Mojang mapping files |
|
||||
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
|
||||
#
|
||||
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
#
|
||||
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
|
||||
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
|
||||
mapping_channel=official
|
||||
# The mapping version to query from the mapping channel.
|
||||
# This must match the format required by the mapping channel.
|
||||
mapping_version=1.20.1
|
||||
jei_version=15.2.0.22
|
||||
jgt_version=1.5.2
|
||||
|
||||
|
||||
## Mod Properties
|
||||
|
||||
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
||||
# Must match the String constant located in the main mod class annotated with @Mod.
|
||||
mod_id=prettypipes
|
||||
# The human-readable display name for the mod.
|
||||
mod_name=PrettyPipes
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=MIT
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.13.6
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
mod_group_id=de.ellpeck.prettypipes
|
||||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||
mod_authors=Ellpeck
|
||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||
mod_description=wow pipes, how creative
|
||||
|
|
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,6 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
13
settings.gradle
Normal file
13
settings.gradle
Normal file
|
@ -0,0 +1,13 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
name = 'MinecraftForge'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
|
||||
}
|
|
@ -48,10 +48,10 @@ import de.ellpeck.prettypipes.terminal.containers.CraftingTerminalGui;
|
|||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalContainer;
|
||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
|
@ -74,19 +74,13 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Bus.MOD)
|
||||
public final class Registry {
|
||||
|
||||
public static final CreativeModeTab TAB = new CreativeModeTab(PrettyPipes.ID) {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return new ItemStack(Registry.wrenchItem);
|
||||
}
|
||||
};
|
||||
|
||||
public static Capability<PipeNetwork> pipeNetworkCapability = CapabilityManager.get(new CapabilityToken<>() {
|
||||
});
|
||||
public static Capability<IPipeConnectable> pipeConnectableCapability = CapabilityManager.get(new CapabilityToken<>() {
|
||||
|
@ -132,7 +126,7 @@ public final class Registry {
|
|||
|
||||
event.register(ForgeRegistries.Keys.ITEMS, h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "wrench"), Registry.wrenchItem = new WrenchItem());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "blank_module"), new Item(new Item.Properties().tab(Registry.TAB)));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "blank_module"), new Item(new Item.Properties()));
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "pipe_frame"), Registry.pipeFrameItem = new PipeFrameItem());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "stack_size_module"), new StackSizeModuleItem());
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "redstone_module"), new RedstoneModuleItem());
|
||||
|
@ -157,7 +151,7 @@ public final class Registry {
|
|||
|
||||
ForgeRegistries.BLOCKS.getEntries().stream()
|
||||
.filter(b -> b.getKey().location().getNamespace().equals(PrettyPipes.ID))
|
||||
.forEach(b -> h.register(b.getKey().location(), new BlockItem(b.getValue(), new Item.Properties().tab(Registry.TAB))));
|
||||
.forEach(b -> h.register(b.getKey().location(), new BlockItem(b.getValue(), new Item.Properties())));
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.BLOCK_ENTITY_TYPES, h -> {
|
||||
|
@ -184,11 +178,22 @@ public final class Registry {
|
|||
Registry.craftingModuleContainer = Registry.registerPipeContainer(h, "crafting_module");
|
||||
Registry.filterModifierModuleContainer = Registry.registerPipeContainer(h, "filter_modifier_module");
|
||||
});
|
||||
|
||||
event.register(BuiltInRegistries.CREATIVE_MODE_TAB.key(), h -> {
|
||||
h.register(new ResourceLocation(PrettyPipes.ID, "tab"), CreativeModeTab.builder()
|
||||
.title(Component.translatable("item_group." + PrettyPipes.ID + ".tab"))
|
||||
.icon(() -> new ItemStack(Registry.wrenchItem))
|
||||
.displayItems((params, output) -> ForgeRegistries.ITEMS.getEntries().stream()
|
||||
.filter(b -> b.getKey().location().getNamespace().equals(PrettyPipes.ID))
|
||||
.sorted(Comparator.comparing(b -> b.getValue().getClass().getSimpleName()))
|
||||
.forEach(b -> output.accept(b.getValue()))).build()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private static <T extends AbstractPipeContainer<?>> MenuType<T> registerPipeContainer(RegisterEvent.RegisterHelper<MenuType<?>> helper, String name) {
|
||||
var type = (MenuType<T>) IForgeMenuType.create((windowId, inv, data) -> {
|
||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, inv.player.level, data.readBlockPos());
|
||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, inv.player.level(), data.readBlockPos());
|
||||
var moduleIndex = data.readInt();
|
||||
var moduleStack = tile.modules.getStackInSlot(moduleIndex);
|
||||
return ((IModule) moduleStack.getItem()).getContainer(moduleStack, tile, windowId, inv, inv.player, moduleIndex);
|
||||
|
|
|
@ -48,7 +48,7 @@ public final class Utility {
|
|||
|
||||
public static Direction getDirectionFromOffset(BlockPos pos, BlockPos other) {
|
||||
var diff = pos.subtract(other);
|
||||
return Direction.fromNormal(diff.getX(), diff.getY(), diff.getZ());
|
||||
return Direction.fromDelta(diff.getX(), diff.getY(), diff.getZ());
|
||||
}
|
||||
|
||||
public static void addTooltip(String name, List<Component> tooltip) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class CraftingTerminalTransferHandler implements IRecipeTransferHandler<C
|
|||
List<PacketGhostSlot.Entry> stacks = new ArrayList<>();
|
||||
var ingredients = slots.getSlotViews(RecipeIngredientRole.INPUT);
|
||||
for (var entry : ingredients)
|
||||
stacks.add(new PacketGhostSlot.Entry(entry.getIngredients(VanillaTypes.ITEM_STACK).collect(Collectors.toList())));
|
||||
stacks.add(new PacketGhostSlot.Entry(player.level(), entry.getIngredients(VanillaTypes.ITEM_STACK).collect(Collectors.toList())));
|
||||
PacketHandler.sendToServer(new PacketGhostSlot(container.getTile().getBlockPos(), stacks));
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -73,12 +73,12 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
|||
var screen = event.getScreen();
|
||||
if (!(screen instanceof ItemTerminalGui terminal))
|
||||
return;
|
||||
terminal.addRenderableWidget(this.jeiSyncButton = new Button(terminal.getGuiLeft() - 22, terminal.getGuiTop() + 44, 20, 20, Component.literal(""), button -> {
|
||||
terminal.addRenderableWidget(this.jeiSyncButton = Button.builder(Component.literal(""), button -> {
|
||||
var preferences = PlayerPrefs.get();
|
||||
preferences.syncJei = !preferences.syncJei;
|
||||
preferences.save();
|
||||
terminal.updateWidgets();
|
||||
}));
|
||||
}).bounds(terminal.getGuiLeft() - 22, terminal.getGuiTop() + 44, 20, 20).build());
|
||||
if (PlayerPrefs.get().syncJei)
|
||||
terminal.search.setValue(this.runtime.getIngredientFilter().getFilterText());
|
||||
}
|
||||
|
@ -90,8 +90,8 @@ public class JEIPrettyPipesPlugin implements IModPlugin {
|
|||
return;
|
||||
var sync = PlayerPrefs.get().syncJei;
|
||||
if (event instanceof ScreenEvent.Render.Post) {
|
||||
if (this.jeiSyncButton.isHoveredOrFocused())
|
||||
terminal.renderTooltip(event.getPoseStack(), Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
|
||||
if (this.jeiSyncButton.isHovered())
|
||||
event.getGuiGraphics().renderTooltip(terminal.getMinecraft().font, Component.translatable("info." + PrettyPipes.ID + ".sync_jei." + (sync ? "on" : "off")), event.getMouseX(), event.getMouseY());
|
||||
} else if (event instanceof ScreenEvent.Render.Pre) {
|
||||
this.jeiSyncButton.setMessage(Component.literal((sync ? ChatFormatting.GREEN : ChatFormatting.RED) + "J"));
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.network.syncher.EntityDataAccessor;
|
|||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.tags.DamageTypeTags;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
|
@ -48,19 +49,19 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.level.isClientSide)
|
||||
if (this.level().isClientSide)
|
||||
return;
|
||||
if (this.tickCount % 40 != 0)
|
||||
return;
|
||||
var network = PipeNetwork.get(this.level);
|
||||
var attached = PipeFrameEntity.getAttachedPipe(this.level, this.pos, this.direction);
|
||||
var network = PipeNetwork.get(this.level());
|
||||
var attached = PipeFrameEntity.getAttachedPipe(this.level(), this.pos, this.direction);
|
||||
if (attached != null) {
|
||||
var node = network.getNodeFromPipe(attached);
|
||||
if (node != null) {
|
||||
var stack = this.getItem();
|
||||
if (!stack.isEmpty()) {
|
||||
var items = network.getOrderedNetworkItems(node);
|
||||
var amount = items.stream().mapToInt(i -> i.getItemAmount(this.level, stack)).sum();
|
||||
var amount = items.stream().mapToInt(i -> i.getItemAmount(this.level(), stack)).sum();
|
||||
this.entityData.set(PipeFrameEntity.AMOUNT, amount);
|
||||
return;
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
|
||||
@Override
|
||||
public boolean survives() {
|
||||
return super.survives() && PipeFrameEntity.canPlace(this.level, this.pos, this.direction);
|
||||
return super.survives() && PipeFrameEntity.canPlace(this.level(), this.pos, this.direction);
|
||||
}
|
||||
|
||||
private static BlockPos getAttachedPipe(Level world, BlockPos pos, Direction direction) {
|
||||
|
@ -96,8 +97,8 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
public boolean hurt(DamageSource source, float amount) {
|
||||
if (this.isInvulnerableTo(source)) {
|
||||
return false;
|
||||
} else if (!source.isExplosion() && !this.getItem().isEmpty()) {
|
||||
if (!this.level.isClientSide) {
|
||||
} else if (!source.is(DamageTypeTags.IS_EXPLOSION) && !this.getItem().isEmpty()) {
|
||||
if (!this.level().isClientSide) {
|
||||
this.dropItemOrSelf(source.getDirectEntity(), false);
|
||||
this.playSound(SoundEvents.ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F);
|
||||
}
|
||||
|
@ -115,7 +116,7 @@ public class PipeFrameEntity extends ItemFrame implements IEntityAdditionalSpawn
|
|||
}
|
||||
|
||||
private void dropItemOrSelf(@Nullable Entity entityIn, boolean b) {
|
||||
if (!this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
if (!this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
if (entityIn == null)
|
||||
this.getItem().setEntityRepresentation(null);
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package de.ellpeck.prettypipes.entities;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
|
||||
|
@ -20,17 +21,17 @@ public class PipeFrameRenderer extends ItemFrameRenderer<PipeFrameEntity> {
|
|||
var vec3d = this.getRenderOffset(entityIn, partialTicks);
|
||||
matrixStackIn.translate(-vec3d.x, -vec3d.y, -vec3d.z);
|
||||
matrixStackIn.translate(direction.getStepX() * 0.46875, direction.getStepY() * 0.46875, direction.getStepZ() * 0.46875);
|
||||
matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(entityIn.getXRot()));
|
||||
matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(180.0F - entityIn.getYRot()));
|
||||
matrixStackIn.mulPose(Axis.XP.rotationDegrees(entityIn.getXRot()));
|
||||
matrixStackIn.mulPose(Axis.YP.rotationDegrees(180.0F - entityIn.getYRot()));
|
||||
|
||||
var font = this.getFont();
|
||||
var amount = entityIn.getAmount();
|
||||
var ammountStrg = amount < 0 ? "?" : String.valueOf(amount);
|
||||
var x = 0.5F - font.width(ammountStrg) / 2F;
|
||||
var amountStrg = amount < 0 ? "?" : String.valueOf(amount);
|
||||
var x = 0.5F - font.width(amountStrg) / 2F;
|
||||
var matrix4f = matrixStackIn.last().pose();
|
||||
matrixStackIn.translate(0, 0.285F, 0.415F);
|
||||
matrixStackIn.scale(-0.02F, -0.02F, 0.02F);
|
||||
font.drawInBatch(ammountStrg, x, 0, 0xFFFFFF, true, matrix4f, bufferIn, false, 0, packedLightIn);
|
||||
font.drawInBatch(amountStrg, x, 0, 0xFFFFFF, true, matrix4f, bufferIn, Font.DisplayMode.NORMAL, 0, packedLightIn);
|
||||
|
||||
matrixStackIn.popPose();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.ellpeck.prettypipes.items;
|
||||
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.Utility;
|
||||
import de.ellpeck.prettypipes.misc.DirectionSelector;
|
||||
import de.ellpeck.prettypipes.misc.ItemFilter;
|
||||
|
@ -30,7 +29,7 @@ public abstract class ModuleItem extends Item implements IModule {
|
|||
private final String name;
|
||||
|
||||
public ModuleItem(String name) {
|
||||
super(new Properties().tab(Registry.TAB).stacksTo(16));
|
||||
super(new Properties().stacksTo(16));
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
public class PipeFrameItem extends Item {
|
||||
|
||||
public PipeFrameItem() {
|
||||
super(new Properties().tab(Registry.TAB));
|
||||
super(new Properties());
|
||||
}
|
||||
|
||||
// HangingEntityItem copypasta mostly, since it hardcodes the entities bleh
|
||||
|
@ -60,7 +60,7 @@ public class PipeFrameItem extends Item {
|
|||
}
|
||||
|
||||
protected boolean canPlace(Player playerIn, Direction directionIn, ItemStack itemStackIn, BlockPos posIn) {
|
||||
return !directionIn.getAxis().isVertical() && playerIn.mayUseItemAt(posIn, directionIn, itemStackIn) && PipeFrameEntity.canPlace(playerIn.level, posIn, directionIn);
|
||||
return !directionIn.getAxis().isVertical() && playerIn.mayUseItemAt(posIn, directionIn, itemStackIn) && PipeFrameEntity.canPlace(playerIn.level(), posIn, directionIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.ellpeck.prettypipes.items;
|
||||
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.Utility;
|
||||
import de.ellpeck.prettypipes.pipe.ConnectionType;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlock;
|
||||
|
@ -27,7 +26,7 @@ import java.util.List;
|
|||
public class WrenchItem extends Item {
|
||||
|
||||
public WrenchItem() {
|
||||
super(new Item.Properties().stacksTo(1).tab(Registry.TAB));
|
||||
super(new Item.Properties().stacksTo(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class Events {
|
|||
var dump = PipeNetwork.get(source.getLevel()).toString();
|
||||
try {
|
||||
Files.writeString(file, dump, StandardCharsets.UTF_8);
|
||||
source.sendSuccess(Component.literal("Wrote network dump to file " + file.toAbsolutePath()), true);
|
||||
source.sendSuccess(() -> Component.literal("Wrote network dump to file " + file.toAbsolutePath()), true);
|
||||
} catch (IOException e) {
|
||||
source.sendFailure(Component.literal("Failed to write network dump to file " + file.toAbsolutePath()));
|
||||
return -1;
|
||||
|
@ -43,13 +43,13 @@ public final class Events {
|
|||
.then(Commands.literal("uncache").executes(c -> {
|
||||
var source = c.getSource();
|
||||
PipeNetwork.get(source.getLevel()).clearCaches();
|
||||
source.sendSuccess(Component.literal("Cleared all pipe caches in the world"), true);
|
||||
source.sendSuccess(() -> Component.literal("Cleared all pipe caches in the world"), true);
|
||||
return 0;
|
||||
}))
|
||||
.then(Commands.literal("unlock").executes(c -> {
|
||||
var source = c.getSource();
|
||||
PipeNetwork.get(source.getLevel()).unlock();
|
||||
source.sendSuccess(Component.literal("Resolved all network locks in the world"), true);
|
||||
source.sendSuccess(() -> Component.literal("Resolved all network locks in the world"), true);
|
||||
return 0;
|
||||
})));
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ import java.util.function.Supplier;
|
|||
public class ItemEquality {
|
||||
|
||||
public static final ItemEquality DAMAGE = new ItemEquality((stack, filter) -> stack.getDamageValue() == filter.getDamageValue(), false, Type.DAMAGE);
|
||||
public static final ItemEquality NBT = new ItemEquality(ItemStack::tagMatches, false, Type.NBT);
|
||||
// TODO see if this tagMatches replacement is good enough?
|
||||
public static final ItemEquality NBT = new ItemEquality(ItemStack::areShareTagsEqual, false, Type.NBT);
|
||||
public static final ItemEquality MOD = new ItemEquality((stack, filter) -> stack.getItem().getCreatorModId(stack).equals(filter.getItem().getCreatorModId(filter)), true, Type.MOD);
|
||||
|
||||
public final Type type;
|
||||
|
@ -28,7 +29,7 @@ public class ItemEquality {
|
|||
}
|
||||
|
||||
public static boolean compareItems(ItemStack stack, ItemStack filter, ItemEquality... types) {
|
||||
var equal = ItemStack.isSameIgnoreDurability(stack, filter);
|
||||
var equal = ItemStack.isSameItem(stack, filter);
|
||||
if (types.length <= 0)
|
||||
return equal;
|
||||
for (var type : types) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.ellpeck.prettypipes.misc;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
|
@ -8,6 +7,7 @@ import de.ellpeck.prettypipes.pipe.modules.modifier.FilterModifierModuleItem;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.Tooltip;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -52,23 +52,13 @@ public class ItemFilter extends ItemStackHandler {
|
|||
List<AbstractWidget> buttons = new ArrayList<>();
|
||||
if (this.canModifyWhitelist) {
|
||||
var whitelistText = (Supplier<String>) () -> "info." + PrettyPipes.ID + "." + (this.isWhitelist ? "whitelist" : "blacklist");
|
||||
buttons.add(new Button(x - 20, y, 20, 20, Component.translatable(whitelistText.get()), button -> {
|
||||
buttons.add(Button.builder(Component.translatable(whitelistText.get()), button -> {
|
||||
PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 0);
|
||||
button.setMessage(Component.translatable(whitelistText.get()));
|
||||
}) {
|
||||
@Override
|
||||
public void renderToolTip(PoseStack matrix, int x, int y) {
|
||||
gui.renderTooltip(matrix, Component.translatable(whitelistText.get() + ".description").withStyle(ChatFormatting.GRAY), x, y);
|
||||
}
|
||||
});
|
||||
}).bounds(x - 20, y, 20, 20).tooltip(Tooltip.create(Component.translatable(whitelistText.get() + ".description").withStyle(ChatFormatting.GRAY))).build());
|
||||
}
|
||||
if (this.canPopulateFromInventories) {
|
||||
buttons.add(new Button(x - 42, y, 20, 20, Component.translatable("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)) {
|
||||
@Override
|
||||
public void renderToolTip(PoseStack matrix, int x, int y) {
|
||||
gui.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY), x, y);
|
||||
}
|
||||
});
|
||||
buttons.add(Button.builder(Component.translatable("info." + PrettyPipes.ID + ".populate"), button -> PacketButton.sendAndExecute(this.pipe.getBlockPos(), PacketButton.ButtonResult.FILTER_CHANGE, 1)).bounds(x - 42, y, 20, 20).tooltip(Tooltip.create(Component.translatable("info." + PrettyPipes.ID + ".populate.description").withStyle(ChatFormatting.GRAY))).build());
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package de.ellpeck.prettypipes.misc;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -37,46 +37,44 @@ public class ItemTerminalWidget extends AbstractWidget {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(PoseStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
protected void renderWidget(GuiGraphics graphics, int p_268034_, int p_268009_, float p_268085_) {
|
||||
var mc = this.screen.getMinecraft();
|
||||
var renderer = mc.getItemRenderer();
|
||||
this.setBlitOffset(100);
|
||||
renderer.blitOffset = 100;
|
||||
// TODO test this new blit offset replacement?
|
||||
graphics.pose().translate(0, 0, 100);
|
||||
if (this.selected)
|
||||
GuiComponent.fill(matrix, this.x, this.y, this.x + 16, this.y + 16, -2130706433);
|
||||
graphics.fill(this.getX(), this.getY(), this.getX() + 16, this.getY() + 16, -2130706433);
|
||||
RenderSystem.enableDepthTest();
|
||||
renderer.renderGuiItem(this.stack, this.x, this.y);
|
||||
graphics.renderItem(this.stack, this.getX(), this.getY());
|
||||
var amount = !this.craftable ? this.stack.getCount() : 0;
|
||||
var amountStrg = this.stack.getCount() >= 1000 ? amount / 1000 + "k" : String.valueOf(amount);
|
||||
renderer.renderGuiItemDecorations(mc.font, this.stack, this.x, this.y, amountStrg);
|
||||
renderer.blitOffset = 0;
|
||||
this.setBlitOffset(0);
|
||||
graphics.renderItemDecorations(mc.font, this.stack, this.getX(), this.getY(), amountStrg);
|
||||
graphics.pose().translate(0, 0, -100);
|
||||
|
||||
if (this.isHoveredOrFocused()) {
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.colorMask(true, true, true, false);
|
||||
this.fillGradient(matrix, this.x, this.y, this.x + 16, this.y + 16, -2130706433, -2130706433);
|
||||
graphics.fillGradient(this.getX(), this.getY(), this.getX() + 16, this.getY() + 16, -2130706433, -2130706433);
|
||||
RenderSystem.colorMask(true, true, true, true);
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderToolTip(PoseStack matrix, int mouseX, int mouseY) {
|
||||
if (this.visible && this.isHoveredOrFocused()) {
|
||||
var tooltip = this.screen.getTooltipFromItem(this.stack);
|
||||
public void renderToolTip(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
if (this.visible && this.isHovered()) {
|
||||
var tooltip = Screen.getTooltipFromItem(this.screen.getMinecraft(), this.stack);
|
||||
if (this.stack.getCount() >= 1000) {
|
||||
var comp = tooltip.get(0);
|
||||
if (comp instanceof MutableComponent m) {
|
||||
if (comp instanceof MutableComponent m)
|
||||
tooltip.set(0, m.append(Component.literal(" (" + this.stack.getCount() + ')').withStyle(ChatFormatting.BOLD)));
|
||||
}
|
||||
}
|
||||
this.screen.renderTooltip(matrix, tooltip, Optional.empty(), mouseX, mouseY);
|
||||
graphics.renderTooltip(this.screen.getMinecraft().font, tooltip, Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNarration(NarrationElementOutput output) {
|
||||
public void updateWidgetNarration(NarrationElementOutput output) {
|
||||
this.defaultButtonNarrationText(output);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.prettypipes.pipe.IPipeItem;
|
|||
import de.ellpeck.prettypipes.pipe.PipeBlockEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.block.model.ItemTransforms;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
@ -18,6 +17,7 @@ import net.minecraft.util.Mth;
|
|||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -104,7 +104,7 @@ public class PipeItem implements IPipeItem {
|
|||
var currSpeed = Math.min(0.25F, motionLeft);
|
||||
motionLeft -= currSpeed;
|
||||
|
||||
var myPos = new BlockPos(this.x, this.y, this.z);
|
||||
var myPos = BlockPos.containing(this.x, this.y, this.z);
|
||||
if (!myPos.equals(currPipe.getBlockPos()) && (currPipe.getBlockPos().equals(this.getDestPipe()) || !myPos.equals(this.startInventory))) {
|
||||
// we're done with the current pipe, so switch to the next one
|
||||
currPipe.getItems().remove(this);
|
||||
|
@ -196,7 +196,7 @@ public class PipeItem implements IPipeItem {
|
|||
@Override
|
||||
public void drop(Level world, ItemStack stack) {
|
||||
var item = new ItemEntity(world, this.x, this.y, this.z, stack.copy());
|
||||
item.level.addFreshEntity(item);
|
||||
item.level().addFreshEntity(item);
|
||||
}
|
||||
|
||||
protected ItemStack store(PipeBlockEntity currPipe) {
|
||||
|
@ -312,7 +312,7 @@ public class PipeItem implements IPipeItem {
|
|||
(random.nextFloat() * 2.0F - 1.0F) * 0.25F * 0.5F,
|
||||
(random.nextFloat() * 2.0F - 1.0F) * 0.25F * 0.5F);
|
||||
}
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(this.stack, ItemTransforms.TransformType.GROUND, light, overlay, matrixStack, source, 0);
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(this.stack, ItemDisplayContext.GROUND, light, overlay, matrixStack, source, tile.getLevel(), 0);
|
||||
matrixStack.popPose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class PacketButton {
|
|||
|
||||
public enum ButtonResult {
|
||||
PIPE_TAB((pos, data, player) -> {
|
||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level, pos);
|
||||
var tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level(), pos);
|
||||
if (data[0] < 0) {
|
||||
NetworkHooks.openScreen((ServerPlayer) player, tile, pos);
|
||||
} else {
|
||||
|
@ -113,11 +113,11 @@ public class PacketButton {
|
|||
StackSizeModuleItem.setMaxStackSize(container.moduleStack, data[0]);
|
||||
}),
|
||||
CRAFT_TERMINAL_REQUEST((pos, data, player) -> {
|
||||
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, player.level, pos);
|
||||
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, player.level(), pos);
|
||||
tile.requestCraftingItems(player, data[0], data[1] > 0);
|
||||
}),
|
||||
CANCEL_CRAFTING((pos, data, player) -> {
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level, pos);
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level(), pos);
|
||||
tile.cancelCrafting();
|
||||
}),
|
||||
TAG_FILTER((pos, data, player) -> {
|
||||
|
|
|
@ -6,7 +6,7 @@ import de.ellpeck.prettypipes.Utility;
|
|||
import de.ellpeck.prettypipes.terminal.CraftingTerminalBlockEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
@ -14,6 +14,7 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -55,7 +56,7 @@ public class PacketGhostSlot {
|
|||
@SuppressWarnings("Convert2Lambda")
|
||||
public static void onMessage(PacketGhostSlot message, Supplier<NetworkEvent.Context> ctx) {
|
||||
var doIt = (Consumer<Player>) p -> {
|
||||
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, p.level, message.pos);
|
||||
var tile = Utility.getBlockEntity(CraftingTerminalBlockEntity.class, p.level(), message.pos);
|
||||
if (tile != null)
|
||||
tile.setGhostItems(message.stacks);
|
||||
};
|
||||
|
@ -88,8 +89,8 @@ public class PacketGhostSlot {
|
|||
private final List<ItemStack> stacks;
|
||||
private final TagKey<Item> tag;
|
||||
|
||||
public Entry(List<ItemStack> stacks) {
|
||||
var tag = Entry.getTagForStacks(stacks);
|
||||
public Entry(Level level, List<ItemStack> stacks) {
|
||||
var tag = Entry.getTagForStacks(level, stacks);
|
||||
if (tag != null) {
|
||||
this.stacks = null;
|
||||
this.tag = tag;
|
||||
|
@ -107,14 +108,14 @@ public class PacketGhostSlot {
|
|||
this.stacks.add(buf.readItem());
|
||||
} else {
|
||||
this.stacks = null;
|
||||
this.tag = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(buf.readUtf()));
|
||||
this.tag = TagKey.create(Registries.ITEM, new ResourceLocation(buf.readUtf()));
|
||||
}
|
||||
}
|
||||
|
||||
public List<ItemStack> getStacks() {
|
||||
public List<ItemStack> getStacks(Level level) {
|
||||
if (this.stacks != null)
|
||||
return this.stacks;
|
||||
return Streams.stream(Registry.ITEM.getTagOrEmpty(this.tag).iterator())
|
||||
return Streams.stream(level.registryAccess().registry(Registries.ITEM).get().getTagOrEmpty(this.tag).iterator())
|
||||
.filter(h -> h.value() != null & h.value() != Items.AIR)
|
||||
.map(h -> new ItemStack(h.value())).collect(Collectors.toList());
|
||||
}
|
||||
|
@ -132,8 +133,8 @@ public class PacketGhostSlot {
|
|||
return buf;
|
||||
}
|
||||
|
||||
private static TagKey<Item> getTagForStacks(List<ItemStack> stacks) {
|
||||
return Registry.ITEM.getTags().filter(e -> {
|
||||
private static TagKey<Item> getTagForStacks(Level level, List<ItemStack> stacks) {
|
||||
return level.registryAccess().registry(Registries.ITEM).get().getTags().filter(e -> {
|
||||
var tag = e.getSecond();
|
||||
if (tag.size() != stacks.size())
|
||||
return false;
|
||||
|
|
|
@ -51,7 +51,7 @@ public class PacketRequest {
|
|||
@Override
|
||||
public void run() {
|
||||
Player player = ctx.get().getSender();
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level, message.pos);
|
||||
var tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level(), message.pos);
|
||||
message.stack.setCount(message.amount);
|
||||
tile.requestItem(player, message.stack, message.nbtHash);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|||
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.BooleanOp;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
|
@ -66,7 +65,7 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
}
|
||||
|
||||
public PipeBlock() {
|
||||
super(Block.Properties.of(Material.STONE).strength(2).sound(SoundType.STONE).noOcclusion());
|
||||
super(Block.Properties.of().strength(2).sound(SoundType.STONE).noOcclusion());
|
||||
|
||||
var state = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, false);
|
||||
for (var prop : PipeBlock.DIRECTIONS.values())
|
||||
|
@ -225,8 +224,9 @@ public class PipeBlock extends BaseEntityBlock {
|
|||
protected static boolean hasLegsTo(Level world, BlockState state, BlockPos pos, Direction direction) {
|
||||
if (state.getBlock() instanceof WallBlock || state.getBlock() instanceof FenceBlock)
|
||||
return direction == Direction.DOWN;
|
||||
if (state.getMaterial() == Material.STONE || state.getMaterial() == Material.METAL)
|
||||
return Block.canSupportCenter(world, pos, direction.getOpposite());
|
||||
// TODO figure out new condition for legs now that materials are gone
|
||||
/* if (state.getMaterial() == Material.STONE || state.getMaterial() == Material.METAL)
|
||||
return Block.canSupportCenter(world, pos, direction.getOpposite());*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ import de.ellpeck.prettypipes.pipe.containers.MainPipeContainer;
|
|||
import de.ellpeck.prettypipes.pressurizer.PressurizerBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
|
@ -116,7 +118,7 @@ public class PipeBlockEntity extends BlockEntity implements MenuProvider, IPipeC
|
|||
public void load(CompoundTag compound) {
|
||||
this.modules.deserializeNBT(compound.getCompound("modules"));
|
||||
this.moduleDropCheck = compound.getInt("module_drop_check");
|
||||
this.cover = compound.contains("cover") ? NbtUtils.readBlockState(compound.getCompound("cover")) : null;
|
||||
this.cover = compound.contains("cover") ? NbtUtils.readBlockState(this.level != null ? this.level.holderLookup(Registries.BLOCK) : BuiltInRegistries.BLOCK.asLookup(), compound.getCompound("cover")) : null;
|
||||
this.craftIngredientRequests.clear();
|
||||
this.craftIngredientRequests.addAll(Utility.deserializeAll(compound.getList("requests", Tag.TAG_COMPOUND), NetworkLock::new));
|
||||
this.craftResultRequests.clear();
|
||||
|
|
|
@ -24,7 +24,7 @@ public abstract class AbstractPipeContainer<T extends IModule> extends AbstractC
|
|||
|
||||
public AbstractPipeContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos, int moduleIndex) {
|
||||
super(type, id);
|
||||
this.tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level, pos);
|
||||
this.tile = Utility.getBlockEntity(PipeBlockEntity.class, player.level(), pos);
|
||||
this.moduleStack = moduleIndex < 0 ? null : this.tile.modules.getStackInSlot(moduleIndex);
|
||||
this.module = moduleIndex < 0 ? null : (T) this.moduleStack.getItem();
|
||||
this.moduleIndex = moduleIndex;
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package de.ellpeck.prettypipes.pipe.containers;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.Registry;
|
||||
import de.ellpeck.prettypipes.items.IModule;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -56,39 +53,38 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(matrix);
|
||||
super.render(matrix, mouseX, mouseY, partialTicks);
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(graphics);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
for (var widget : this.renderables) {
|
||||
if (widget instanceof AbstractWidget abstractWidget) {
|
||||
// TDOO render widget tooltips?
|
||||
/* if (widget instanceof AbstractWidget abstractWidget) {
|
||||
if (abstractWidget.isHoveredOrFocused())
|
||||
abstractWidget.renderToolTip(matrix, mouseX, mouseY);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
this.renderTooltip(matrix, mouseX, mouseY);
|
||||
this.renderTooltip(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
this.font.draw(matrix, this.playerInventoryTitle.getString(), 8, this.imageHeight - 96 + 2, 4210752);
|
||||
this.font.draw(matrix, this.title.getString(), 8, 6 + 32, 4210752);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
graphics.drawString(this.font, this.playerInventoryTitle.getString(), 8, this.imageHeight - 96 + 2, 4210752, false);
|
||||
graphics.drawString(this.font, this.title.getString(), 8, 6 + 32, 4210752, false);
|
||||
for (var tab : this.tabs)
|
||||
tab.drawForeground(matrix, mouseX, mouseY);
|
||||
tab.drawForeground(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE);
|
||||
this.blit(matrix, this.leftPos, this.topPos + 32, 0, 0, 176, 171);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) {
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos, this.topPos + 32, 0, 0, 176, 171);
|
||||
|
||||
for (var tab : this.tabs)
|
||||
tab.draw(matrix);
|
||||
tab.draw(graphics);
|
||||
|
||||
// draw the slots since we're using a blank ui
|
||||
for (var slot : this.menu.slots) {
|
||||
if (slot instanceof SlotItemHandler)
|
||||
this.blit(matrix, this.leftPos + slot.x - 1, this.topPos + slot.y - 1, 176, 62, 18, 18);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + slot.x - 1, this.topPos + slot.y - 1, 176, 62, 18, 18);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +124,7 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
this.y = AbstractPipeGui.this.topPos;
|
||||
}
|
||||
|
||||
private void draw(PoseStack matrix) {
|
||||
private void draw(GuiGraphics graphics) {
|
||||
var y = 2;
|
||||
var v = 0;
|
||||
var height = 30;
|
||||
|
@ -139,17 +135,14 @@ public abstract class AbstractPipeGui<T extends AbstractPipeContainer<?>> extend
|
|||
height = 32;
|
||||
itemOffset = 7;
|
||||
}
|
||||
AbstractPipeGui.this.blit(matrix, this.x, this.y + y, 176, v, 28, height);
|
||||
|
||||
AbstractPipeGui.this.itemRenderer.renderGuiItem(this.moduleStack, this.x + 6, this.y + itemOffset);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.x, this.y + y, 176, v, 28, height);
|
||||
graphics.renderItem(this.moduleStack, this.x + 6, this.y + itemOffset);
|
||||
}
|
||||
|
||||
private void drawForeground(PoseStack matrix, int mouseX, int mouseY) {
|
||||
private void drawForeground(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
if (mouseX < this.x || mouseY < this.y || mouseX >= this.x + 28 || mouseY >= this.y + 32)
|
||||
return;
|
||||
AbstractPipeGui.this.renderTooltip(matrix, this.moduleStack.getHoverName(), mouseX - AbstractPipeGui.this.leftPos, mouseY - AbstractPipeGui.this.topPos);
|
||||
graphics.renderTooltip(AbstractPipeGui.this.font, this.moduleStack.getHoverName(), mouseX - AbstractPipeGui.this.leftPos, mouseY - AbstractPipeGui.this.topPos);
|
||||
}
|
||||
|
||||
private boolean onClicked(double mouseX, double mouseY, int button) {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.craft;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
||||
|
@ -14,10 +12,8 @@ public class CraftingModuleGui extends AbstractPipeGui<CraftingModuleContainer>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
super.renderBg(matrix, partialTicks, mouseX, mouseY);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE);
|
||||
this.blit(matrix, this.leftPos + 176 / 2 - 16 / 2, this.topPos + 32 + 18 * 2, 176, 80, 16, 16);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) {
|
||||
super.renderBg(graphics, partialTicks, mouseX, mouseY);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + 176 / 2 - 16 / 2, this.topPos + 32 + 18 * 2, 176, 80, 16, 16);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.modifier;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -28,18 +28,18 @@ public class FilterModifierModuleGui extends AbstractPipeGui<FilterModifierModul
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
super.renderBg(matrix, partialTicks, mouseX, mouseY);
|
||||
this.blit(matrix, this.leftPos + 7, this.topPos + 32 + 15, 0, 196, 162, 60);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) {
|
||||
super.renderBg(graphics, partialTicks, mouseX, mouseY);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + 7, this.topPos + 32 + 15, 0, 196, 162, 60);
|
||||
|
||||
for (var tag : this.tagButtons)
|
||||
tag.draw(matrix, mouseX, mouseY);
|
||||
tag.draw(graphics, mouseX, mouseY);
|
||||
|
||||
if (this.tags.size() >= 6) {
|
||||
var percentage = this.scrollOffset / (float) (this.tags.size() - 5);
|
||||
this.blit(matrix, this.leftPos + 156, this.topPos + 32 + 16 + (int) (percentage * (58 - 15)), 232, 241, 12, 15);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + 156, this.topPos + 32 + 16 + (int) (percentage * (58 - 15)), 232, 241, 12, 15);
|
||||
} else {
|
||||
this.blit(matrix, this.leftPos + 156, this.topPos + 32 + 16, 244, 241, 12, 15);
|
||||
graphics.blit(AbstractPipeGui.TEXTURE, this.leftPos + 156, this.topPos + 32 + 16, 244, 241, 12, 15);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,14 +117,14 @@ public class FilterModifierModuleGui extends AbstractPipeGui<FilterModifierModul
|
|||
this.y = y;
|
||||
}
|
||||
|
||||
private void draw(PoseStack matrix, double mouseX, double mouseY) {
|
||||
private void draw(GuiGraphics graphics, double mouseX, double mouseY) {
|
||||
var color = 4210752;
|
||||
var text = this.tag.toString();
|
||||
if (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 140 && mouseY < this.y + 12)
|
||||
color = 0xFFFFFF;
|
||||
if (this.tag.equals(FilterModifierModuleItem.getFilterTag(FilterModifierModuleGui.this.menu.moduleStack)))
|
||||
text = ChatFormatting.BOLD + text;
|
||||
FilterModifierModuleGui.this.font.draw(matrix, text, this.x, this.y, color);
|
||||
graphics.drawString(FilterModifierModuleGui.this.font, text, this.x, this.y, color, false);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, AbstractPipeGui.TEXTURE);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.ellpeck.prettypipes.pipe.modules.stacksize;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton.ButtonResult;
|
||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
|
@ -43,16 +43,16 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
|
|||
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_AMOUNT, amount);
|
||||
});
|
||||
Supplier<Component> buttonText = () -> Component.translatable("info." + PrettyPipes.ID + ".limit_to_max_" + (StackSizeModuleItem.getLimitToMaxStackSize(this.menu.moduleStack) ? "on" : "off"));
|
||||
this.addRenderableWidget(new Button(this.leftPos + 7, this.topPos + 17 + 32 + 10 + 22, 120, 20, buttonText.get(), b -> {
|
||||
this.addRenderableWidget(Button.builder(buttonText.get(), b -> {
|
||||
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_MODULE_BUTTON);
|
||||
b.setMessage(buttonText.get());
|
||||
}));
|
||||
}).bounds(this.leftPos + 7, this.topPos + 17 + 32 + 10 + 22, 120, 20).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
super.renderLabels(matrix, mouseX, mouseY);
|
||||
this.font.draw(matrix, I18n.get("info." + PrettyPipes.ID + ".max_stack_size") + ":", 7, 17 + 32, 4210752);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
super.renderLabels(graphics, mouseX, mouseY);
|
||||
graphics.drawString(this.font, I18n.get("info." + PrettyPipes.ID + ".max_stack_size") + ":", 7, 17 + 32, 4210752, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
|||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
@ -31,7 +30,7 @@ import java.util.List;
|
|||
public class PressurizerBlock extends BaseEntityBlock {
|
||||
|
||||
public PressurizerBlock() {
|
||||
super(BlockBehaviour.Properties.of(Material.STONE).strength(3).sound(SoundType.STONE));
|
||||
super(BlockBehaviour.Properties.of().strength(3).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class PressurizerContainer extends AbstractContainerMenu {
|
|||
|
||||
public PressurizerContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos) {
|
||||
super(type, id);
|
||||
this.tile = Utility.getBlockEntity(PressurizerBlockEntity.class, player.level, pos);
|
||||
this.tile = Utility.getBlockEntity(PressurizerBlockEntity.class, player.level(), pos);
|
||||
|
||||
for (var l = 0; l < 3; ++l)
|
||||
for (var j1 = 0; j1 < 9; ++j1)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package de.ellpeck.prettypipes.pressurizer;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
@ -20,26 +18,24 @@ public class PressurizerGui extends AbstractContainerScreen<PressurizerContainer
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(matrix);
|
||||
super.render(matrix, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(matrix, mouseX, mouseY);
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(graphics);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(graphics, mouseX, mouseY);
|
||||
if (mouseX >= this.leftPos + 26 && mouseY >= this.topPos + 22 && mouseX < this.leftPos + 26 + 124 && mouseY < this.topPos + 22 + 12)
|
||||
this.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + ".energy", this.menu.tile.getEnergy(), this.menu.tile.getMaxEnergy()), mouseX, mouseY);
|
||||
graphics.renderTooltip(this.font, Component.translatable("info." + PrettyPipes.ID + ".energy", this.menu.tile.getEnergy(), this.menu.tile.getMaxEnergy()), mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
this.font.draw(matrix, this.playerInventoryTitle.getString(), 8, this.imageHeight - 96 + 2, 4210752);
|
||||
this.font.draw(matrix, this.title.getString(), 8, 6, 4210752);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
graphics.drawString(this.font, this.playerInventoryTitle.getString(), 8, this.imageHeight - 96 + 2, 4210752, false);
|
||||
graphics.drawString(this.font, this.title.getString(), 8, 6, 4210752, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrixStack, float partialTicks, int x, int y) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, PressurizerGui.TEXTURE);
|
||||
this.blit(matrixStack, this.leftPos, this.topPos, 0, 0, 176, 137);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int x, int y) {
|
||||
graphics.blit(PressurizerGui.TEXTURE, this.leftPos, this.topPos, 0, 0, 176, 137);
|
||||
var energy = (int) (this.menu.tile.getEnergyPercentage() * 124);
|
||||
this.blit(matrixStack, this.leftPos + 26, this.topPos + 22, 0, 137, energy, 12);
|
||||
graphics.blit(PressurizerGui.TEXTURE, this.leftPos + 26, this.topPos + 22, 0, 137, energy, 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
|
|||
public void setGhostItems(List<PacketGhostSlot.Entry> stacks) {
|
||||
this.updateItems();
|
||||
for (var i = 0; i < this.ghostItems.getSlots(); i++) {
|
||||
var items = stacks.get(i).getStacks();
|
||||
var items = stacks.get(i).getStacks(this.level);
|
||||
if (items.isEmpty()) {
|
||||
this.ghostItems.setStackInSlot(i, ItemStack.EMPTY);
|
||||
continue;
|
||||
|
@ -97,7 +97,7 @@ public class CraftingTerminalBlockEntity extends ItemTerminalBlockEntity {
|
|||
if (!this.level.isClientSide) {
|
||||
List<PacketGhostSlot.Entry> clients = new ArrayList<>();
|
||||
for (var i = 0; i < this.ghostItems.getSlots(); i++)
|
||||
clients.add(new PacketGhostSlot.Entry(Collections.singletonList(this.ghostItems.getStackInSlot(i))));
|
||||
clients.add(new PacketGhostSlot.Entry(this.level, Collections.singletonList(this.ghostItems.getStackInSlot(i))));
|
||||
PacketHandler.sendToAllLoaded(this.level, this.getBlockPos(), new PacketGhostSlot(this.getBlockPos(), clients));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
@ -31,7 +30,7 @@ import java.util.List;
|
|||
public class ItemTerminalBlock extends BaseEntityBlock {
|
||||
|
||||
public ItemTerminalBlock() {
|
||||
super(Properties.of(Material.STONE).strength(3).sound(SoundType.STONE));
|
||||
super(Properties.of().strength(3).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,11 +46,11 @@ public class CraftingTerminalContainer extends ItemTerminalContainer {
|
|||
@Override
|
||||
public void slotsChanged(Container inventoryIn) {
|
||||
super.slotsChanged(inventoryIn);
|
||||
if (!this.player.level.isClientSide) {
|
||||
if (!this.player.level().isClientSide) {
|
||||
var ret = ItemStack.EMPTY;
|
||||
var optional = this.player.level.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.craftInventory, this.player.level);
|
||||
var optional = this.player.level().getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.craftInventory, this.player.level());
|
||||
if (optional.isPresent())
|
||||
ret = optional.get().assemble(this.craftInventory);
|
||||
ret = optional.get().assemble(this.craftInventory, this.player.level().registryAccess());
|
||||
this.craftResult.setItem(0, ret);
|
||||
((ServerPlayer) this.player).connection.send(new ClientboundContainerSetSlotPacket(this.containerId, 0, 0, ret));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.ellpeck.prettypipes.terminal.containers;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -24,12 +24,12 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
this.requestButton = this.addRenderableWidget(new Button(this.leftPos + 8, this.topPos + 100, 50, 20, Component.translatable("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
this.requestButton = this.addRenderableWidget(Button.builder(Component.translatable("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
var amount = ItemTerminalGui.requestModifier();
|
||||
// also allow holding backspace instead of alt for people whose alt key is inaccessible (linux?)
|
||||
var force = Screen.hasAltDown() || InputConstants.isKeyDown(this.minecraft.getWindow().getWindow(), 259) ? 1 : 0;
|
||||
PacketHandler.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CRAFT_TERMINAL_REQUEST, amount, force));
|
||||
}));
|
||||
}).bounds(this.leftPos + 8, this.topPos + 100, 50, 20).build());
|
||||
this.tick();
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,10 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
super.renderLabels(matrix, mouseX, mouseY);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
super.renderLabels(graphics, mouseX, mouseY);
|
||||
|
||||
var container = this.getCraftingContainer();
|
||||
var tile = container.getTile();
|
||||
|
@ -63,8 +64,8 @@ public class CraftingTerminalGui extends ItemTerminalGui {
|
|||
var slot = container.slots.stream().filter(s -> s.container == container.craftInventory && s.getSlotIndex() == finalI).findFirst().orElse(null);
|
||||
if (slot == null)
|
||||
continue;
|
||||
this.minecraft.getItemRenderer().renderGuiItem(ghost, slot.x, slot.y);
|
||||
this.minecraft.getItemRenderer().renderGuiItemDecorations(this.font, ghost, slot.x, slot.y, "0");
|
||||
graphics.renderItem(ghost, slot.x, slot.y);
|
||||
graphics.renderItemDecorations(this.font, ghost, slot.x, slot.y, "0");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ItemTerminalContainer extends AbstractContainerMenu {
|
|||
|
||||
public ItemTerminalContainer(@Nullable MenuType<?> type, int id, Player player, BlockPos pos) {
|
||||
super(type, id);
|
||||
this.tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level, pos);
|
||||
this.tile = Utility.getBlockEntity(ItemTerminalBlockEntity.class, player.level(), pos);
|
||||
|
||||
this.addOwnSlots(player);
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package de.ellpeck.prettypipes.terminal.containers;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import de.ellpeck.prettypipes.PrettyPipes;
|
||||
import de.ellpeck.prettypipes.misc.ItemTerminalWidget;
|
||||
import de.ellpeck.prettypipes.misc.PlayerPrefs;
|
||||
|
@ -10,14 +8,14 @@ import de.ellpeck.prettypipes.packets.PacketButton;
|
|||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||
import de.ellpeck.prettypipes.packets.PacketRequest;
|
||||
import joptsimple.internal.Strings;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
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.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -70,7 +68,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
if (this.items != null)
|
||||
this.updateWidgets();
|
||||
|
||||
this.plusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 + 12, this.topPos + 103, 12, 12, Component.literal("+"), button -> {
|
||||
this.plusButton = this.addRenderableWidget(Button.builder(Component.literal("+"), button -> {
|
||||
var modifier = ItemTerminalGui.requestModifier();
|
||||
if (modifier > 1 && this.requestAmount == 1) {
|
||||
this.requestAmount = modifier;
|
||||
|
@ -80,14 +78,14 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
// 384 items is 6 stacks, which is what fits into the terminal slots
|
||||
if (this.requestAmount > 384)
|
||||
this.requestAmount = 384;
|
||||
}));
|
||||
this.minusButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 24, this.topPos + 103, 12, 12, Component.literal("-"), button -> {
|
||||
}).bounds(this.leftPos + this.getXOffset() + 95 - 7 + 12, this.topPos + 103, 12, 12).build());
|
||||
this.minusButton = this.addRenderableWidget(Button.builder(Component.literal("-"), button -> {
|
||||
this.requestAmount -= ItemTerminalGui.requestModifier();
|
||||
if (this.requestAmount < 1)
|
||||
this.requestAmount = 1;
|
||||
}));
|
||||
}).bounds(this.leftPos + this.getXOffset() + 95 - 7 - 24, this.topPos + 103, 12, 12).build());
|
||||
this.minusButton.active = false;
|
||||
this.requestButton = this.addRenderableWidget(new Button(this.leftPos + this.getXOffset() + 95 - 7 - 25, this.topPos + 115, 50, 20, Component.translatable("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
this.requestButton = this.addRenderableWidget(Button.builder(Component.translatable("info." + PrettyPipes.ID + ".request"), button -> {
|
||||
var widget = this.streamWidgets().filter(w -> w.selected).findFirst();
|
||||
if (!widget.isPresent())
|
||||
return;
|
||||
|
@ -95,26 +93,25 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
stack.setCount(1);
|
||||
PacketHandler.sendToServer(new PacketRequest(this.menu.tile.getBlockPos(), stack, this.requestAmount));
|
||||
this.requestAmount = 1;
|
||||
}));
|
||||
}).bounds(this.leftPos + this.getXOffset() + 95 - 7 - 25, this.topPos + 115, 50, 20).build());
|
||||
this.requestButton.active = false;
|
||||
this.orderButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos, 20, 20, Component.literal(""), button -> {
|
||||
this.orderButton = this.addRenderableWidget(Button.builder(Component.literal(""), button -> {
|
||||
if (this.sortedItems == null)
|
||||
return;
|
||||
var prefs = PlayerPrefs.get();
|
||||
prefs.terminalItemOrder = prefs.terminalItemOrder.next();
|
||||
prefs.save();
|
||||
this.updateWidgets();
|
||||
}));
|
||||
this.ascendingButton = this.addRenderableWidget(new Button(this.leftPos - 22, this.topPos + 22, 20, 20, Component.literal(""), button -> {
|
||||
}).bounds(this.leftPos - 22, this.topPos, 20, 20).build());
|
||||
this.ascendingButton = this.addRenderableWidget(Button.builder(Component.literal(""), button -> {
|
||||
if (this.sortedItems == null)
|
||||
return;
|
||||
var prefs = PlayerPrefs.get();
|
||||
prefs.terminalAscending = !prefs.terminalAscending;
|
||||
prefs.save();
|
||||
this.updateWidgets();
|
||||
}));
|
||||
this.cancelCraftingButton = this.addRenderableWidget(new Button(this.leftPos + this.imageWidth + 4, this.topPos + 4 + 64, 54, 20, Component.translatable("info." + PrettyPipes.ID + ".cancel_all"), b -> {
|
||||
}));
|
||||
}).bounds(this.leftPos - 22, this.topPos + 22, 20, 20).build());
|
||||
this.cancelCraftingButton = this.addRenderableWidget(Button.builder(Component.translatable("info." + PrettyPipes.ID + ".cancel_all"), b -> {}).bounds(this.leftPos + this.imageWidth + 4, this.topPos + 4 + 64, 54, 20).build());
|
||||
this.cancelCraftingButton.visible = false;
|
||||
for (var y = 0; y < 4; y++) {
|
||||
for (var x = 0; x < 9; x++)
|
||||
|
@ -148,9 +145,9 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
if (button == 0 && mouseX >= this.leftPos + this.getXOffset() + 172 && this.topPos + mouseY >= 18 && mouseX < this.leftPos + this.getXOffset() + 172 + 12 && mouseY < this.topPos + 18 + 70) {
|
||||
this.isScrolling = true;
|
||||
return true;
|
||||
} else if (button == 1 && mouseX >= this.search.x && mouseX <= this.search.x + this.search.getWidth() && mouseY >= this.search.y && mouseY <= this.search.y + 8) {
|
||||
} else if (button == 1 && mouseX >= this.search.getX() && mouseX <= this.search.getX() + this.search.getWidth() && mouseY >= this.search.getY() && mouseY <= this.search.getY() + 8) {
|
||||
this.search.setValue("");
|
||||
this.search.setFocus(true);
|
||||
this.search.setFocused(true);
|
||||
this.setFocused(this.search);
|
||||
return true;
|
||||
}
|
||||
|
@ -161,7 +158,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
// we have to do the click logic here because JEI is activated when letting go of the mouse button
|
||||
// and vanilla buttons are activated when the click starts, so we'll always invoke jei accidentally by default
|
||||
if (button == 0 && this.cancelCraftingButton.visible && this.cancelCraftingButton.isHoveredOrFocused()) {
|
||||
if (button == 0 && this.cancelCraftingButton.visible && this.cancelCraftingButton.isHovered()) {
|
||||
if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) {
|
||||
PacketHandler.sendToServer(new PacketButton(this.menu.tile.getBlockPos(), PacketButton.ButtonResult.CANCEL_CRAFTING));
|
||||
return true;
|
||||
|
@ -268,72 +265,70 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(matrix);
|
||||
super.render(matrix, mouseX, mouseY, partialTicks);
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(graphics);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
for (var widget : this.renderables) {
|
||||
if (widget instanceof ItemTerminalWidget terminal)
|
||||
terminal.renderToolTip(matrix, mouseX, mouseY);
|
||||
terminal.renderToolTip(graphics, mouseX, mouseY);
|
||||
}
|
||||
if (this.sortedItems != null) {
|
||||
var prefs = PlayerPrefs.get();
|
||||
if (this.orderButton.isHoveredOrFocused())
|
||||
this.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + ".order", I18n.get("info." + PrettyPipes.ID + ".order." + prefs.terminalItemOrder.name().toLowerCase(Locale.ROOT))), mouseX, mouseY);
|
||||
if (this.ascendingButton.isHoveredOrFocused())
|
||||
this.renderTooltip(matrix, Component.translatable("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
|
||||
if (this.orderButton.isHovered())
|
||||
graphics.renderTooltip(this.font, Component.translatable("info." + PrettyPipes.ID + ".order", I18n.get("info." + PrettyPipes.ID + ".order." + prefs.terminalItemOrder.name().toLowerCase(Locale.ROOT))), mouseX, mouseY);
|
||||
if (this.ascendingButton.isHovered())
|
||||
graphics.renderTooltip(this.font, Component.translatable("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
|
||||
}
|
||||
if (this.cancelCraftingButton.visible && this.cancelCraftingButton.isHoveredOrFocused()) {
|
||||
if (this.cancelCraftingButton.visible && this.cancelCraftingButton.isHovered()) {
|
||||
var tooltip = I18n.get("info." + PrettyPipes.ID + ".cancel_all.desc").split("\n");
|
||||
this.renderComponentTooltip(matrix, Arrays.stream(tooltip).map(Component::literal).collect(Collectors.toList()), mouseX, mouseY);
|
||||
graphics.renderTooltip(this.font, Arrays.stream(tooltip).map(Component::literal).collect(Collectors.toList()), Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
if (!this.hoveredCrafting.isEmpty())
|
||||
this.renderTooltip(matrix, this.hoveredCrafting, mouseX, mouseY);
|
||||
this.renderTooltip(matrix, mouseX, mouseY);
|
||||
graphics.renderTooltip(this.font, this.hoveredCrafting, mouseX, mouseY);
|
||||
this.renderTooltip(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderLabels(PoseStack matrix, int mouseX, int mouseY) {
|
||||
this.font.draw(matrix, this.playerInventoryTitle.getString(), 8 + this.getXOffset(), this.imageHeight - 96 + 2, 4210752);
|
||||
this.font.draw(matrix, this.title.getString(), 8, 6, 4210752);
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
graphics.drawString(this.font, this.playerInventoryTitle.getString(), 8 + this.getXOffset(), this.imageHeight - 96 + 2, 4210752, false);
|
||||
graphics.drawString(this.font, this.title.getString(), 8, 6, 4210752, false);
|
||||
|
||||
var amount = String.valueOf(this.requestAmount);
|
||||
this.font.draw(matrix, amount, (176 + 15 - this.font.width(amount)) / 2F - 7 + this.getXOffset(), 106, 4210752);
|
||||
graphics.drawString(this.font, amount, (176 + 15 - this.font.width(amount)) / 2 - 7 + this.getXOffset(), 106, 4210752, false);
|
||||
|
||||
if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) {
|
||||
this.font.draw(matrix, I18n.get("info." + PrettyPipes.ID + ".crafting"), this.imageWidth + 4, 4 + 6, 4210752);
|
||||
graphics.drawString(this.font, I18n.get("info." + PrettyPipes.ID + ".crafting"), this.imageWidth + 4, 4 + 6, 4210752, false);
|
||||
if (this.currentlyCrafting.size() > 6)
|
||||
this.font.draw(matrix, ". . .", this.imageWidth + 24, 4 + 51, 4210752);
|
||||
graphics.drawString(this.font, ". . .", this.imageWidth + 24, 4 + 51, 4210752, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(PoseStack matrix, float partialTicks, int mouseX, int mouseY) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, this.getTexture());
|
||||
this.blit(matrix, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
||||
protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) {
|
||||
graphics.blit(this.getTexture(), this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight);
|
||||
|
||||
if (this.sortedItems != null && this.sortedItems.size() >= 9 * 4) {
|
||||
var percentage = this.scrollOffset / (float) (this.sortedItems.size() / 9 - 3);
|
||||
this.blit(matrix, this.leftPos + this.getXOffset() + 172, this.topPos + 18 + (int) (percentage * (70 - 15)), 232, 241, 12, 15);
|
||||
graphics.blit(this.getTexture(), this.leftPos + this.getXOffset() + 172, this.topPos + 18 + (int) (percentage * (70 - 15)), 232, 241, 12, 15);
|
||||
} else {
|
||||
this.blit(matrix, this.leftPos + this.getXOffset() + 172, this.topPos + 18, 244, 241, 12, 15);
|
||||
graphics.blit(this.getTexture(), this.leftPos + this.getXOffset() + 172, this.topPos + 18, 244, 241, 12, 15);
|
||||
}
|
||||
|
||||
// draw the items that are currently crafting
|
||||
this.hoveredCrafting = ItemStack.EMPTY;
|
||||
if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.setShaderTexture(0, ItemTerminalGui.TEXTURE);
|
||||
this.blit(matrix, this.leftPos + this.imageWidth, this.topPos + 4, 191, 0, 65, 89);
|
||||
graphics.blit(ItemTerminalGui.TEXTURE, this.leftPos + this.imageWidth, this.topPos + 4, 191, 0, 65, 89);
|
||||
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
for (var stack : this.currentlyCrafting) {
|
||||
var itemX = this.leftPos + this.imageWidth + 4 + x * 18;
|
||||
var itemY = this.topPos + 4 + 16 + y * 18;
|
||||
this.itemRenderer.renderGuiItem(stack, itemX, itemY);
|
||||
this.itemRenderer.renderGuiItemDecorations(this.font, stack, itemX, itemY, String.valueOf(stack.getCount()));
|
||||
graphics.renderItem(stack, itemX, itemY);
|
||||
graphics.renderItemDecorations(this.font, stack, itemX, itemY, String.valueOf(stack.getCount()));
|
||||
if (mouseX >= itemX && mouseY >= itemY && mouseX < itemX + 16 && mouseY < itemY + 18)
|
||||
this.hoveredCrafting = stack;
|
||||
x++;
|
||||
|
@ -364,7 +359,7 @@ public class ItemTerminalGui extends AbstractContainerScreen<ItemTerminalContain
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T extends GuiEventListener & Widget & NarratableEntry> T addRenderableWidget(T p_169406_) {
|
||||
public <T extends GuiEventListener & Renderable & NarratableEntry> T addRenderableWidget(T p_169406_) {
|
||||
// overriding to public for JEIPrettyPipesPlugin
|
||||
return super.addRenderableWidget(p_169406_);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package de.ellpeck.prettypipes.terminal.containers;
|
||||
|
||||
import net.minecraft.world.entity.player.StackedContents;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.inventory.TransientCraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class WrappedCraftingInventory extends CraftingContainer {
|
||||
public class WrappedCraftingInventory extends TransientCraftingContainer {
|
||||
|
||||
private final ItemStackHandler items;
|
||||
private final CraftingTerminalContainer eventHandler;
|
||||
|
|
|
@ -4,30 +4,67 @@
|
|||
# Note that there are a couple of TOML lists in this file.
|
||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader = "javafml" #mandatory
|
||||
modLoader="javafml" #mandatory
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
loaderVersion = "[28,)" #mandatory (28 is current forge version)
|
||||
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||
license="${mod_license}"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
issueTrackerURL = "https://github.com/Ellpeck/PrettyPipes" #optional
|
||||
license = "MIT"
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId = "prettypipes" #mandatory
|
||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
version = "${file.jarVersion}"
|
||||
modId="${mod_id}" #mandatory
|
||||
# The version number of the mod
|
||||
version="${mod_version}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName = "Pretty Pipes" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification <here>
|
||||
#updateJSONURL="http://myurl.me/" #optional
|
||||
displayName="${mod_name}" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
#displayURL="http://example.com/" #optional
|
||||
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
|
||||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
#logoFile="examplemod.png" #optional
|
||||
# A text field displayed in the mod UI
|
||||
#credits="" #optional
|
||||
# A text field displayed in the mod UI
|
||||
authors = "Ellpeck" #optional
|
||||
authors="${mod_authors}" #optional
|
||||
# Display Test controls the display for your mod in the server connection screen
|
||||
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
||||
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
||||
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
|
||||
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
|
||||
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
|
||||
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
|
||||
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
description = '''
|
||||
wow pipes, how creative'''
|
||||
description='''${mod_description}'''
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies.${mod_id}]] #optional
|
||||
# the modid of the dependency
|
||||
modId="forge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange="${forge_version_range}" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
|
||||
# BEFORE - This mod is loaded BEFORE the dependency
|
||||
# AFTER - This mod is loaded AFTER the dependency
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
||||
side="BOTH"
|
||||
# Here's another dependency
|
||||
[[dependencies.${mod_id}]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="${minecraft_version_range}"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
|
||||
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
|
||||
# stop your mod loading on the server for example.
|
||||
#[features.${mod_id}]
|
||||
#openGLVersion="[3.2,)"
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
"block.prettypipes.item_terminal": "Item Terminal",
|
||||
"block.prettypipes.crafting_terminal": "Crafting Terminal",
|
||||
"block.prettypipes.pressurizer": "Pipe Pressurizer",
|
||||
"itemGroup.prettypipes": "Pretty Pipes",
|
||||
"item_group.prettypipes.tab": "Pretty Pipes",
|
||||
"container.prettypipes.pipe": "Pipe",
|
||||
"container.prettypipes.item_terminal": "Item Terminal",
|
||||
"container.prettypipes.crafting_terminal": "Crafting Terminal",
|
||||
|
@ -98,4 +98,4 @@
|
|||
"dir.prettypipes.south": "South",
|
||||
"dir.prettypipes.west": "West",
|
||||
"dir.prettypipes.all": "All Sides"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue