Compare commits

..
37 Commits
Author SHA1 Message Date
GlodBlock da533d07bd bump version 2022-06-05 01:50:02 +08:00
GlodBlock 51a1821b01 recipe for fluid level maintainer 2022-06-05 01:49:15 +08:00
Yang Xizhi 2f58e74c22 Merge pull request #17 from mczph/1.12.2
Update zh_cn.lang
2022-06-05 01:31:43 +08:00
GlodBlock 802671d504 texture 2022-06-05 01:31:07 +08:00
mczph 3468394b49 Update zh_cn.lang 2022-06-04 16:47:23 +08:00
GlodBlock c6938cc921 gui improvements 2022-06-04 00:59:04 +08:00
GlodBlock 411065ea67 finish fluid level maintainer 2022-05-31 17:27:59 +08:00
GlodBlock 3dcc7a72d1 display every shitttttt! 2022-05-31 02:14:02 +08:00
GlodBlock 12102ed23d bump version 2022-05-30 22:37:42 +08:00
GlodBlock bc6ba7918e make extend pattern actually work 2022-05-30 22:33:19 +08:00
GlodBlock 29907760c3 more gui stuff 2022-05-30 22:29:10 +08:00
GlodBlock 5444d5312c bump version 2022-05-29 16:25:31 +08:00
GlodBlock 201ac78563 begin gui for fluid level maintainer 2022-05-29 16:23:45 +08:00
GlodBlock 808196f3c0 fix crash when running with gtce instead of gtceu 2022-05-28 18:58:24 +08:00
GlodBlock eb41b9d8b4 begin work of fluid leve maintanier 2022-05-28 17:37:08 +08:00
GlodBlock 952cba09e4 readme update 2022-05-23 20:29:46 +08:00
GlodBlock 4bbfd2f68e qf 2022-05-23 20:21:47 +08:00
GlodBlock 531e55a013 bump version 2022-05-23 15:53:28 +08:00
GlodBlock 475c910fa2 fix fluid export bus gui 2022-05-23 15:51:58 +08:00
GlodBlock ff92f7168f begin work to make fluid export bus support craft card 2022-05-22 23:57:07 +08:00
Yang Xizhi 1ad7d5318e Merge pull request #11 from duqingyude/1.12.2
add zh_cn.lang
2022-05-22 18:09:15 +08:00
杜庆玉 fbab434bbc add zh_cn.lang 2022-05-22 11:40:14 +08:00
Yang Xizhi 8b85f2be65 Merge pull request #10 from Xikaro/1.12.2
Update ru_ru.lang
2022-05-22 10:35:31 +08:00
Xikaro 8d77a6ee4c Update ru_ru.lang
fix :)
2022-05-22 04:46:41 +05:00
Yang Xizhi 6a86504e2e Merge pull request #8 from Xikaro/1.12.2
Create ru_ru.lang
2022-05-21 21:05:05 +08:00
Xikaro 6b793c1dc7 Create ru_ru.lang
adding ru translation
2022-05-21 15:24:36 +05:00
GlodBlock 9096734722 bump version 2022-05-20 21:25:46 +08:00
GlodBlock ecde78111d add extended fluid pattern terminal 2022-05-20 21:22:32 +08:00
GlodBlock 1253a9002d fix block mode crash 2022-05-18 01:16:20 +08:00
GlodBlock e7c1e55518 update readme 2022-05-18 00:27:51 +08:00
GlodBlock c13d83f06d make fluid pattern searchable in interface terminal 2022-05-17 23:34:05 +08:00
GlodBlock 0c4063b41b cards for dual interface 2022-05-17 23:18:38 +08:00
GlodBlock 3201e54dc3 pattern transfer in termial 2022-05-17 20:25:58 +08:00
GlodBlock de89555092 fix fluid change sync problem 2022-05-17 19:10:45 +08:00
GlodBlock 5054565fca mult/div/add/sub button now works on fluid 2022-05-17 15:49:38 +08:00
GlodBlock 281620f695 make fluid pattern terminal work like fluid encoder 2022-05-14 17:44:15 +08:00
GlodBlock 632c0c3b8f begin work 2022-05-13 23:09:58 +08:00
519 changed files with 10449 additions and 35937 deletions

No files matched your search

-19
View File
@@ -1,19 +0,0 @@
# This is the universal Text Editor Configuration
# for all GTNewHorizons projects
# See: https://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.{bat,ini}]
end_of_line = crlf
[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}]
indent_size = 2
-2
View File
@@ -1,2 +0,0 @@
# Ignore spotlessApply reformat
69a5c0e6ee71fe714eabe24002f9e39aae3b97be
+2 -44
View File
@@ -1,44 +1,2 @@
* text eol=lf
*.[jJ][aA][rR] binary
*.[pP][nN][gG] binary
*.[jJ][pP][gG] binary
*.[jJ][pP][eE][gG] binary
*.[gG][iI][fF] binary
*.[tT][iI][fF] binary
*.[tT][iI][fF][fF] binary
*.[iI][cC][oO] binary
*.[sS][vV][gG] text
*.[eE][pP][sS] binary
*.[xX][cC][fF] binary
*.[kK][aA][rR] binary
*.[mM]4[aA] binary
*.[mM][iI][dD] binary
*.[mM][iI][dD][iI] binary
*.[mM][pP]3 binary
*.[oO][gG][gG] binary
*.[rR][aA] binary
*.7[zZ] binary
*.[gG][zZ] binary
*.[tT][aA][rR] binary
*.[tT][gG][zZ] binary
*.[zZ][iI][pP] binary
*.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
*.[pP][aA][tT][cC][hH] -text
*.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
# Auto detect text files and perform LF normalization
* text=auto
-13
View File
@@ -1,13 +0,0 @@
name: Build and test
on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]
jobs:
build-and-test:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
-14
View File
@@ -1,14 +0,0 @@
name: Release tagged build
on:
push:
tags: [ '*' ]
permissions:
contents: write
jobs:
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
+19 -33
View File
@@ -1,38 +1,24 @@
.gradle
# eclipse
bin
*.launch
.settings
/.idea/
/.vscode/
/run/
/build/
/eclipse/
.metadata
.classpath
.project
/bin/
/config/
/crash-reports/
/logs/
options.txt
/saves/
usernamecache.json
banned-ips.json
banned-players.json
eula.txt
ops.json
server.properties
servers.dat
usercache.json
whitelist.json
/out/
*.iml
# idea
out
*.ipr
*.iws
src/main/resources/mixins.*([!.]).json
*.bat
*.DS_Store
!gradlew.bat
.factorypath
addon.local.gradle
addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
*.iml
/.idea
# gradle
build
.gradle
# other
/run
classes
logs/debug.log
logs/latest.log
-48
View File
@@ -1,48 +0,0 @@
Port with permission from phantamanta44.
# AE2 Fluid Crafting Rework
[![Downloads](https://cf.way2muchnoise.eu/full_623955_downloads.svg)](https://www.curseforge.com/minecraft/mc-mods/ae2-fluid-crafting-rework) ![MCVsrsion](https://cf.way2muchnoise.eu/versions/623955.svg)
Put fluids in the pattern!
AE2 autocrafting is amazing and everyone loves it, but it is always becoming painful when dealing with fluids. You have to put fluids in a container or use a dummy item to write patterns with fluids.
That's because AE2 doesn't support fluid as valid crafting ingredients before 1.16, so it can't handle fluids directly.
However, it is changed now! With **AE2 Fluid Crafting** you can write patterns with fluids freely. Your AE system can output and accept fluids like items without worrying about how to handle these fluid cells.
This is a rework and ported version of [ae2-fluid-crafting](https://github.com/phantamanta44/ae2-fluid-crafting)
## Features
- You can code fluid patterns on fluid terminal directly.
- Mult/Div/Add/Sub Button also works on fluid.
- An extended fluid terminal with 16 inputs and 4 outputs.
- You can add or decrease fluid's amount by clicking with container.
- Fluid Pattern can display its contents when put on pattern terminal.
- [1.12.2] Fix the fluid amount display error when removing fluid.
- [1.12.2] Upgrade cards can be inserted in Dual Interface.
- [1.12.2] Fluid pattern is searchable in interface terminal.
- [1.12.2] Fix crash when using block mode, fluid will also be considered as blockable.
- [1.12.2] Fluid export bus supports crafting card.
## Installation
### 1.7.10
Any version of AE2(Both Official AE2 and GTNH edition AE2 works).
**Extra Cells isn't needed**
### 1.12.2
Unofficial AE2([PAE2](https://www.curseforge.com/minecraft/mc-mods/ae2-extended-life)).
Official AE2 isn't supported, you can use origin [AE2FC](https://github.com/phantamanta44/ae2-fluid-crafting) if you are playing with Official AE2.
## How to Use It
https://github.com/GlodBlock/AE2FluidCraft-Rework/wiki
## Credited Works
E. Geng(@phantamanta44) and KilaBash (@Yefancy) - Their amazing origin work in 1.12.
+88
View File
@@ -0,0 +1,88 @@
Port with permission from phantamanta44.
# AE2 Fluid Crafting Rework
[![Downloads](https://cf.way2muchnoise.eu/full_623955_downloads.svg)](https://www.curseforge.com/minecraft/mc-mods/ae2-fluid-crafting-rework) ![MCVsrsion](https://cf.way2muchnoise.eu/versions/623955.svg)
Put fluids in the pattern!
AE2 autocrafting is amazing and everyone loves it, but it is always becoming painful when dealing with fluids. You have to put fluids in a container or use a dummy item to write patterns with fluids.
That's because AE2 doesn't support fluid as valid crafting ingredients before 1.16, so it can't handle fluids directly.
However, it is changed now! With **AE2 Fluid Crafting** you can write patterns with fluids freely. Your AE system can output and accept fluids like items without worrying about how to handle these fluid cells.
This is a rework and ported version of [ae2-fluid-crafting](https://github.com/phantamanta44/ae2-fluid-crafting)
## Features
- You can code fluid patterns on fluid terminal directly.
- Mult/Div/Add/Sub Button also works on fluid.
- An extended fluid terminal with 16 inputs and 4 outputs.
- You can add or decrease fluid's amount by clicking with container.
- Fluid Pattern can display its contents when put on pattern terminal.
- [1.12.2] Fix the fluid amount display error when removing fluid.
- [1.12.2] Upgrade cards can be inserted in Dual Interface.
- [1.12.2] Fluid pattern is searchable in interface terminal.
- [1.12.2] Fix crash when using block mode, fluid will also be considered as blockable.
- [1.12.2] Fluid export bus supports crafting card.
## Installation
### 1.7.10
Any version of AE2(Both Official AE2 and GTNH edition AE2 works).
**Extra Cells isn't needed**
### 1.12.2
Unofficial AE2([PAE2](https://www.curseforge.com/minecraft/mc-mods/ae2-extended-life)).
You can directly upgrade origin AE2FC2 in your old save.
Official AE2 isn't supported, you can use origin [AE2FC](https://github.com/phantamanta44/ae2-fluid-crafting) if you are playing with Official AE2.
## Basic Devices
### Fluid Discretizer
The **Fluid Discretizer** is a device that, when attached to ME network, exposes the contents of its fluid storage grid as items, which take the form of "fluid drops".
It does this by functioning as a sort of storage bus: when fluid drops are removed from its storage via the item grid, it extracts the corresponding fluid from the fluid grid.
Conversely, when fluid drops inserted into its storage via the item grid, it injects the corresponding fluid into the fluid grid.
Each fluid drop is equivalent to one mB of its respective fluid, which means a full stack of them is equivalent to 64 mB.
Fluid drops have an important property: when an ME interface attempts to export fluid drops to a machine, it will attempt to convert them to fluid.
This means an interface exporting drops of gelid cryotheum into a fluid transposer will successfully fill the transposer's internal tank rather than inserting the drops as items.
This is the central mechanic that makes fluid autocrafting possible.
Note that the only way to convert between fluids and fluid drops is a discretizer attached to an ME network.
While you could theoretically use this as a very convoluted method of transporting fluids, it is not recomomended to do so.
### Fluid Pattern Encoder
Most crafting recipes involving fluids require far more than 64 mB of a particular fluid, and so the standard pattern terminal will not do for encoding such recipes into patterns.
This problem is solved by the **Fluid Pattern Encoder**, a utility that functions similarly to a pattern terminal.
When a fluid-handling item (e.g. a bucket or tank) is inserted into the crafting ingredient slots, they will be converted into an equivalent stack of the corresponding fluid drops.
Using this, patterns for recipes that require more than a stack of fluid drops can easily be encoded.
AE2 Fluid Crafting also comes with a handy JEI integration module that allows the fluid pattern encoder to encode any JEI recipe involving fluids.
This is the recommended way to play with the mod, since encoding patterns by hand is a little cumbersome.
### Fluid Pattern Terminal
Encoding recipes in a big and bulky workbench separate from the rest of your AE2 equipment can be a little inconvenient.
Luckily, we have the **Fluid Pattern Terminal**, which combines the functionality of the standard pattern terminal and the fluid pattern encoder.
Now, you can encode your fluid recipes using the same familiar interface you know and love!
### Fluid Pattern Interface
The standard ME interface lets you emit items and fluid packets with AE2FC, but it will only accept items, as in vanilla AE2.
This is a little inconvenient when you want to build compact setups for autocrafting with fluid outputs, where you would need to use both an item interface for inputs, and a separate fluid interface for outputs.
To make things easier, we have the **Fluid Pattern Interface**, which functions as a combination of an item interface and a fluid interface!
Its GUI is the same as normal ME interface, but it can emit fluids directly instead of fluid packets! It also accepts fluid and item inputs.
Automating fluid crafting machines has never been this quick and painless!
### Fluid Packets
When putting fluid pattern in a normal ME interface, it will emit fluid packets as fluid.
So if you prefer to deal with item instead of fluids, you can transport these packets and turn them back to fluid with **ME Fluid Packet Decoder**.
Simply connect the decoder to your ME network and insert the fluid packet; the decoder will, if possible, inject the fluid into your fluid storage grid.
## Credited Works
E. Geng(@phantamanta44) and KilaBash (@Yefancy) - Their amazing origin work in 1.12.
+85 -4
View File
@@ -1,5 +1,86 @@
//version: 1707058017
plugins {
id 'com.gtnewhorizons.gtnhconvention'
buildscript {
repositories {
maven {
url 'https://maven.minecraftforge.net/'
}
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}
maven {
name 'jitpack'
url 'https://jitpack.io'
}
maven {
name "forge"
url "http://files.minecraftforge.net/maven"
}
mavenLocal()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'idea'
version = "2.3.0-r"
group = "ae2fc"
archivesBaseName = "Fluid Craft for AE2"
sourceCompatibility = targetCompatibility = '1.8'
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
repositories {
maven { url 'https://dvs1.progwml6.com/files/maven/' }
maven { url 'https://jitpack.io/' }
maven { url 'https://cursemaven.com/' }
maven { url "https://minecraft.curseforge.com/api/maven/" }
}
dependencies {
compile 'com.github.phantamanta44:jsr305:1.0.1'
deobfCompile 'mezz.jei:jei_1.12.2:4.15.0.293' //jei
deobfCompile "curse.maven:ae2-extended-life-570458:3785381" // pae2
deobfCompile "curse.maven:packagedauto-308380:2977147" // 1.0.3.14
deobfCompile "curse.maven:modular-machinery-270790:2761302" // 1.11.1
deobfCompile "curse.maven:codechicken-lib-1-8-242818:2779848" //ccl
deobfCompile "curse.maven:gregtech-ce-unofficial-557242:3784798" // gt
}
minecraft {
version = "1.12.2-14.23.5.2847"
runDir = "run"
mappings = "stable_39"
useDepAts = true
makeObfSourceJar = false
}
jar {
manifest {
attributes 'FMLCorePluginContainsFMLMod': 'true'
attributes 'FMLCorePlugin' : 'com.glodblock.github.coremod.FCCoreMod'
}
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version': project.version, 'mcversion': project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
-62
View File
@@ -1,62 +0,0 @@
/*
* Add your dependencies here. Supported configurations:
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
* Available at runtime and compiletime for mods depending on this mod
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
* Available at runtime but not compiletime for mods depending on this mod
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
* Available at compiletime but not runtime for mods depending on this mod
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
* Not available at all for mods depending on this mod, only visible at runtime for this mod
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
* Available at runtime for mods depending on this mod
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
*
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
* Requires you to enable usesShadowedDependencies in gradle.properties
*
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
*
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
*
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
*
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
*
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.8.60-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-817-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.19.21:dev')
api("com.github.GTNewHorizons:GTNHLib:0.9.10:dev")
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.12.12:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.6-GTNH:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.4:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.10.15:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.258:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.16-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.27-GTNH:dev') { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.4.0:dev")
}
+4 -238
View File
@@ -1,238 +1,4 @@
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
# LOCAL to test local config updates.
gtnh.settings.blowdryerTag = 0.2.0
# Human-readable mod name, available for mcmod.info population.
modName = AE2 Fluid Crafting
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
modId = ae2fc
# Root package of the mod, used to find various classes in other properties,
# mcmod.info substitution, enabling assertions in run tasks, etc.
modGroup = com.glodblock.github
# Whether to use modGroup as the maven publishing group.
# When false, com.github.GTNewHorizons is used.
useModGroupForPublishing = false
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
autoUpdateBuildScript = false
# Version of Minecraft to target
minecraftVersion = 1.7.10
# Version of Minecraft Forge to target
forgeVersion = 10.13.4.1614
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
channel = stable
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
mappingsVersion = 12
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = Developer
# Enables modern Java syntax support. Valid values:
# - false: No modern syntax, Java 8 only
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
# - modern: Native modern Java bytecode, no downgrading
enableModernJavaSyntax = jabel
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
# and should *not* be used in most situations. -1 disables this.
# forceToolchainVersion = -1
# Target JVM version for JVM Downgrader bytecode downgrading.
# Only used when enableModernJavaSyntax = jvmDowngrader
# downgradeTargetVersion = 8
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
# Classes will be available in META-INF/versions/N/ for each version N in this list.
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
# jvmDowngraderMultiReleaseVersions = 21,25
# Specifies how JVM Downgrader API stubs are provided. Options:
# - shade: Shade minimized stubs into the jar
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
# - external: Another dependency provides stubs (no constraint, no warning)
# - (empty): Warning reminding you to configure stubs
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
# jvmDowngraderStubsProvider =
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = true
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass = com.glodblock.github.FCTags
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
# [DEPRECATED] Mod name replacement token.
gradleTokenModName =
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
apiPackage = api
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile = ae2fc_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
# responsibility to check the license and request permission for distribution if required.
usesShadowedDependencies = false
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = true
# Maven repository to publish the mod to.
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish to Modrinth.
modrinthProjectId =
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
#
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations =
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
# versionPattern =
# Uncomment to prevent the source code from being published.
# noPublishedSources = true
# Uncomment this to disable Spotless checks.
# This should only be uncommented to keep it easier to sync with upstream/other forks.
# That is, if there is no other active fork/upstream, NEVER change this.
# disableSpotless = true
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
# disableCheckstyle = true
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
# (force use delegated build).
# This is meant to be set in $HOME/.gradle/gradle.properties.
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
# ideaOverrideBuildType = idea
# Whether IDEA should run spotless checks when pressing the Build button.
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
# Non-GTNH properties
org.gradle.configuration-cache = true
org.gradle.parallel = true
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=7890
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7890
-12
View File
@@ -1,12 +0,0 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/46949723aaa20c7b64d7ecfed7207034/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d6690dfd71c4c91e08577437b5b2beb0/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3cd7045fca9a72cd9bc7d14a385e594c/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/552c7bffe0370c66410a51c55985b511/redirect
toolchainVersion=25
Binary file not shown.
+3 -4
View File
@@ -1,7 +1,6 @@
#Sun May 24 18:34:45 CEST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Vendored Executable → Regular
+116 -192
View File
@@ -1,128 +1,78 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
#!/usr/bin/env sh
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
MAX_FD="maximum"
warn () {
echo "$*"
} >&2
}
die () {
echo
echo "$*"
echo
exit 1
} >&2
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD=$JAVA_HOME/bin/java
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -131,118 +81,92 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+35 -44
View File
@@ -1,22 +1,4 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -27,29 +9,25 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
if "%ERRORLEVEL%" == "0" goto init
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
@@ -57,35 +35,48 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
if exist "%JAVA_EXE%" goto init
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
-5
View File
@@ -1,5 +0,0 @@
// Add any additional repositories for your dependencies here
repositories {
mavenLocal()
}
-23
View File
@@ -1,23 +0,0 @@
pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.19'
}
@@ -0,0 +1,87 @@
package yalter.mousetweaks.api;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
/**
* This is the interface you want to implement in your GuiScreen to make it compatible with Mouse Tweaks.
* If this interface is not enough (for example, you need a custom slot click function, or if you use a custom Container
* which happens to be incompatible), check IMTModGuiContainer2Ex instead.
* If you just need to disable Mouse Tweaks or the wheel tweak, see the MouseTweaksIgnore
* or the MouseTweaksDisableWheelTweak annotations.
*/
public interface IMTModGuiContainer2 {
/**
* If you want to disable Mouse Tweaks in your GuiScreen, return true from this method.
*
* @return True if Mouse Tweaks should be disabled, false otherwise.
*/
boolean MT_isMouseTweaksDisabled();
/**
* If you want to disable the Wheel Tweak in your GuiScreen, return true from this method.
*
* @return True if the Wheel Tweak should be disabled, false otherwise.
*/
boolean MT_isWheelTweakDisabled();
/**
* Returns the Container.
*
* @return Container that is currently in use.
*/
Container MT_getContainer();
/**
* Returns the Slot that is currently selected by the player, or null if no Slot is selected.
*
* @return Slot that is located under the mouse, or null if no Slot it currently under the mouse.
*/
Slot MT_getSlotUnderMouse();
/**
* Return true if the given Slot behaves like the vanilla crafting output slots (inside the crafting table,
* or the furnace output slot, or the anvil output slot, etc.). These slots are handled differently by Mouse Tweaks.
*
* @param slot the slot to check
* @return True if slot is a crafting output slot.
*/
boolean MT_isCraftingOutput(Slot slot);
/**
* Return true if the given Slot should be ignored by Mouse Tweaks. Examples of ignored slots are the item select
* slots and the Destroy Item slot in the vanilla creative inventory.
*
* @param slot the slot to check
* @return Tru if slot should be ignored by Mouse Tweaks.
*/
boolean MT_isIgnored(Slot slot);
/**
* If your container has an RMB dragging functionality (like vanilla containers), disable it inside this method.
* This method is called every frame (render tick), which is after all mouseClicked / mouseClickMove / mouseReleased
* events are handled (although note these events are handled every game tick, which is far less frequent than every
* render tick).<br><br>
*
* If true is returned from this method, Mouse Tweaks (after checking other conditions like isIgnored) will click
* the slot on which the right mouse button was initially pressed (in most cases this is the slot currently under
* mouse). This is needed because the vanilla RMB dragging functionality prevents the initial slot click.<br><br>
*
* For vanilla containers this method looks like this:
* <pre>
* this.ignoreMouseUp = true;
*
* if (this.dragSplitting) {
* if (this.dragSplittingButton == 1) {
* this.dragSplitting = false;
* return true;
* }
* }
*
* return false;
* </pre>
*
* @return True if Mouse Tweaks should click the slot on which the RMB was pressed.
*/
boolean MT_disableRMBDraggingFunctionality();
}
@@ -1,87 +1,59 @@
package com.glodblock.github;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.common.Config;
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
import com.glodblock.github.crossmod.waila.WailaInit;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.loader.RecipeLoader;
import appeng.api.AEApi;
import appeng.api.config.Upgrades;
import com.glodblock.github.loader.FCBlocks;
import com.glodblock.github.loader.FCItems;
import com.glodblock.github.proxy.CommonProxy;
import com.glodblock.github.util.ModAndClassUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import org.apache.logging.log4j.Logger;
@Mod(
modid = FluidCraft.MODID,
version = FluidCraft.VERSION,
name = FluidCraft.MODNAME,
dependencies = "required-after:appliedenergistics2@[rv3-beta-238,);required-after:CoFHCore;after:waila;after:thaumicenergistics;after:ae2wct")
@Mod(modid = FluidCraft.MODID, version = FluidCraft.VERSION, useMetadata = true)
public class FluidCraft {
public static final String MODID = "ae2fc";
public static final String VERSION = FCTags.VERSION;
public static final String MODNAME = "AE2 Fluid Crafting";
public static final String VERSION = "2.3.0-r";
@Mod.Instance(MODID)
public static FluidCraft INSTANCE;
@SidedProxy(
clientSide = "com.glodblock.github.proxy.ClientProxy",
serverSide = "com.glodblock.github.proxy.CommonProxy")
@SidedProxy(clientSide = "com.glodblock.github.proxy.ClientProxy", serverSide = "com.glodblock.github.proxy.CommonProxy")
public static CommonProxy proxy;
public static Logger log;
@Mod.EventHandler
public static void preInit(FMLPreInitializationEvent event) {
Config.run();
ChannelLoader.INSTANCE.run();
public void onPreInit(FMLPreInitializationEvent event) {
log = event.getModLog();
ModAndClassUtil.init();
proxy.preInit(event);
}
@Mod.EventHandler
public static void init(FMLInitializationEvent event) {
if (ModAndClassUtil.OC) {
OCDriverInit.run();
}
if (ModAndClassUtil.WAILA) {
WailaInit.run();
}
public void onInit(FMLInitializationEvent event) {
proxy.init(event);
}
@Mod.EventHandler
public static void postInit(FMLPostInitializationEvent event) {
NetworkRegistry.INSTANCE.registerGuiHandler(FluidCraft.INSTANCE, new InventoryHandler());
ItemAndBlockHolder.loadSetting();
if (!Config.removeRecipe) {
RecipeLoader.INSTANCE.run();
}
if (!ModAndClassUtil.NEW_HORIZONS_CORE_MOD) {
RecipeLoader.addTerminalCards();
RecipeLoader.addInfiniteWaterCell();
}
RecipeLoader.runTerminalRecipe();
RecipeLoader.addDisassembleRecipe();
public void onPostInit(FMLPostInitializationEvent event) {
Upgrades.PATTERN_EXPANSION.registerItem(new ItemStack(FCBlocks.DUAL_INTERFACE), 3 );
Upgrades.CRAFTING.registerItem(new ItemStack(FCBlocks.DUAL_INTERFACE), 1 );
Upgrades.PATTERN_EXPANSION.registerItem(new ItemStack(FCItems.PART_DUAL_INTERFACE), 3 );
Upgrades.CRAFTING.registerItem(new ItemStack(FCItems.PART_DUAL_INTERFACE), 1 );
Upgrades.CRAFTING.registerItem( AEApi.instance().definitions().parts().fluidExportBus(), 1 );
proxy.postInit(event);
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {
proxy.onLoadComplete(event);
}
public static ResourceLocation resource(String path) {
return new ResourceLocation(MODID, path);
}
}
@@ -1,53 +0,0 @@
package com.glodblock.github.api;
import java.util.HashSet;
import java.util.Set;
import net.minecraftforge.fluids.Fluid;
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
import com.glodblock.github.util.LevelTerminalRegistry;
public final class FluidCraftAPI implements IFluidCraftAPI {
private static final FluidCraftAPI API = new FluidCraftAPI();
/**
* These fluids will not be allowed to be stored in fluid storage cells.
*/
private final Set<Class<? extends Fluid>> blacklistedFluids = new HashSet<>();
/**
* These fluids will not be displayed in a fluid terminal.
*/
private final Set<Class<? extends Fluid>> blacklistedDispFluids = new HashSet<>();
public static FluidCraftAPI instance() {
return API;
}
@Override
public void blacklistFluidInStorage(Class<? extends Fluid> fluid) {
blacklistedFluids.add(fluid);
}
@Override
public void blacklistFluidInDisplay(Class<? extends Fluid> fluid) {
blacklistedDispFluids.add(fluid);
}
@Override
public boolean isBlacklistedInStorage(Class<? extends Fluid> fluid) {
return blacklistedFluids.contains(fluid);
}
@Override
public boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid) {
return blacklistedDispFluids.contains(fluid);
}
@Override
public ILevelTerminalRegistry levelTerminalRegistry() {
return LevelTerminalRegistry.instance();
}
}
@@ -1,34 +0,0 @@
package com.glodblock.github.api;
import net.minecraftforge.fluids.Fluid;
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
@SuppressWarnings("unused")
public interface IFluidCraftAPI {
/**
* Blacklisted fluids will not be allowed to be added to a storage cell.
*/
void blacklistFluidInStorage(Class<? extends Fluid> fluid);
/**
* Blacklisted fluids will not be displayed in fluid terminals.
*/
void blacklistFluidInDisplay(Class<? extends Fluid> fluid);
/**
* Mostly for internal use; queries whether the fluid is blacklisted from storage cells.
*/
boolean isBlacklistedInStorage(Class<? extends Fluid> fluid);
/**
* Mostly for internal use; queries whether the fluid is blacklisted from being displayed.
*/
boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid);
/**
* Get instance of `ILevelTerminalRegistry` to add new supported machines into terminal
*/
ILevelTerminalRegistry levelTerminalRegistry();
}
@@ -1,8 +0,0 @@
package com.glodblock.github.api;
import net.minecraftforge.common.util.ForgeDirection;
public interface ISide {
ForgeDirection getSide();
}
@@ -1,21 +0,0 @@
package com.glodblock.github.api.registries;
import java.util.Set;
import appeng.api.features.ILevelViewable;
import appeng.api.networking.IGridHost;
public interface ILevelTerminalRegistry {
void register(Class<? extends ILevelViewable> clazz);
void register(Class<? extends IGridHost> aeClass, ILevelViewableAdapter adapter);
Set<Class<? extends ILevelViewable>> getSupportedClasses();
boolean isAdopted(Class<? extends ILevelViewable> clazz);
Class<? extends IGridHost> getAdopted(Class<? extends ILevelViewable> clazz);
ILevelViewableAdapter getAdapter(Class<? extends ILevelViewable> clazz);
}
@@ -1,9 +0,0 @@
package com.glodblock.github.api.registries;
import appeng.api.features.ILevelViewable;
import appeng.api.networking.IGridHost;
public interface ILevelViewableAdapter extends ILevelViewable {
ILevelViewable adapt(IGridHost gridHost);
}
@@ -1,27 +0,0 @@
package com.glodblock.github.client;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import com.glodblock.github.client.textures.FCPartsTexture;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ClientHelper {
@SubscribeEvent
public void updateTextureSheet(final TextureStitchEvent.Pre ev) {
if (ev.map.getTextureType() == 0) {
for (final FCPartsTexture cb : FCPartsTexture.values()) {
cb.registerIcon(ev.map);
}
}
}
public static void register() {
ClientHelper handler = new ClientHelper();
MinecraftForge.EVENT_BUS.register(handler);
FMLCommonHandler.instance().bus().register(handler);
}
}
@@ -1,98 +0,0 @@
package com.glodblock.github.client;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Mouse;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketCustomButtonUpdate;
import com.glodblock.github.network.CPacketSwitchGuis;
import appeng.api.config.Settings;
import appeng.api.config.SidelessMode;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.helpers.ICustomButtonDataObject;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
public class FluidInterfaceButtons implements ICustomButtonDataObject {
private GuiImgButton sidelessMode;
private GuiTabButton switcher;
private final boolean fullBlock;
public SidelessMode sidelessSate;
public FluidInterfaceButtons(final boolean fullBlock) {
this.fullBlock = fullBlock;
}
@SideOnly(Side.CLIENT)
@Override
public void initCustomButtons(int guiLeft, int guiTop, int xSize, int ySize, int xOffset, int yOffset,
List<GuiButton> buttonList) {
if (fullBlock) {
this.sidelessMode = new GuiImgButton(
guiLeft - 18,
guiTop + yOffset,
Settings.SIDELESS_MODE,
SidelessMode.SIDELESS);
buttonList.add(this.sidelessMode);
}
this.switcher = new GuiTabButton(
guiLeft + 132,
guiTop,
!fullBlock ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(),
StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"),
RenderItem.getInstance());
buttonList.add(this.switcher);
FluidCraft.proxy.netHandler.sendToServer(new CPacketCustomButtonUpdate());
}
@SideOnly(Side.CLIENT)
@Override
public boolean actionPerformedCustomButtons(final GuiButton btn) {
if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis());
return true;
} else if (fullBlock && btn == this.sidelessMode) {
final boolean backwards = Mouse.isButtonDown(1);
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards));
FluidCraft.proxy.netHandler.sendToServer(new CPacketCustomButtonUpdate());
return true;
}
return false;
}
@Override
public void readData(NBTTagCompound tag) {}
@Override
public void writeData(NBTTagCompound tag) {}
@Override
public void readByte(ByteBuf buf) {
this.sidelessMode.set(SidelessMode.values()[buf.readInt()]);
}
@Override
public void writeByte(ByteBuf buf) {
buf.writeInt(this.sidelessSate.ordinal());
}
public void setSidelessMode(SidelessMode sm) {
this.sidelessSate = sm;
}
}
@@ -0,0 +1,119 @@
package com.glodblock.github.client;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.core.localization.GuiText;
import appeng.fluids.util.IAEFluidTank;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.container.ContainerBurette;
import com.glodblock.github.client.render.FluidRenderUtils;
import com.glodblock.github.common.tile.TileBurette;
import com.glodblock.github.handler.ButtonMouseHandler;
import com.glodblock.github.handler.TankMouseHandler;
import com.glodblock.github.network.CPacketTransposeFluid;
import com.glodblock.github.util.MouseRegionManager;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import java.io.IOException;
public class GuiBurette extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/burette.png");
private static final int TANK_X = 52, TANK_Y = 17;
private static final int TANK_WIDTH = 16, TANK_HEIGHT = 32;
private final ContainerBurette cont;
private GuiNumberBox amountField;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
public GuiBurette(InventoryPlayer ipl, TileBurette tile) {
super(new ContainerBurette(ipl, tile));
this.cont = (ContainerBurette)inventorySlots;
mouseRegions.addRegion(TANK_X, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), 0));
mouseRegions.addRegion(70, 16, 7, 7, ButtonMouseHandler.dumpTank(cont, 0));
mouseRegions.addRegion(73, 42, 8, 16, createTransposeButton(true));
mouseRegions.addRegion(81, 42, 8, 16, createTransposeButton(false));
}
@Override
public void initGui() {
super.initGui();
amountField = new GuiNumberBox(fontRenderer, guiLeft + 95, guiTop + 46, 28, fontRenderer.FONT_HEIGHT, Integer.class);
amountField.setEnableBackgroundDrawing(false);
amountField.setMaxStringLength(4);
amountField.setTextColor(0xffffff);
amountField.setVisible(true);
amountField.setFocused(true);
amountField.setText("1000");
}
private ButtonMouseHandler createTransposeButton(boolean into) {
return new ButtonMouseHandler(into ? NameConst.TT_TRANSPOSE_IN : NameConst.TT_TRANSPOSE_OUT, () -> {
try {
int amount = Integer.parseInt(amountField.getText());
if (cont.canTranferFluid(into)) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketTransposeFluid(amount, into));
}
} catch (NumberFormatException e) {
// NO-OP
}
});
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) throws IOException {
if (mouseRegions.onClick(xCoord, yCoord, btn)) {
amountField.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
}
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (!checkHotbarKeys(key)) {
if ((key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit(character))
&& amountField.textboxKeyTyped(character, key)) {
try {
int amount = Integer.parseInt(amountField.getText());
if (amount < 0) {
amountField.setText("1");
} else {
amountField.setText(Long.toString(amount));
}
} catch (final NumberFormatException e) {
// NO-OP
}
} else {
super.keyTyped(character, key);
}
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
amountField.drawTextBox();
GlStateManager.color(1F, 1F, 1F, 1F);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRenderer.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_BURETTE)), 8, 6, 0x404040);
fontRenderer.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GlStateManager.color(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
FluidRenderUtils.renderFluidIntoGuiCleanly(TANK_X, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
fluidInv.getFluidInSlot(0), fluidInv.getTankProperties()[0].getCapacity());
mouseRegions.render(mouseX, mouseY);
}
}
@@ -0,0 +1,53 @@
package com.glodblock.github.client;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiExpandedProcessingPatternTerm;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.StackSizeRenderer;
import appeng.container.slot.SlotFake;
import com.glodblock.github.client.container.ContainerExtendedFluidPatternTerminal;
import com.glodblock.github.client.render.FluidRenderUtils;
import com.glodblock.github.inventory.GuiType;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
public class GuiExtendedFluidPatternTerminal extends GuiExpandedProcessingPatternTerm {
private final StackSizeRenderer stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
private GuiTabButton craftingStatusBtn;
public GuiExtendedFluidPatternTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
ContainerExtendedFluidPatternTerminal container = new ContainerExtendedFluidPatternTerminal(inventoryPlayer, te);
container.setGui(this);
this.inventorySlots = container;
Ae2ReflectClient.setGuiExContainer(this, container);
}
@Override
public void initGui() {
super.initGui();
craftingStatusBtn = Ae2ReflectClient.getCraftingStatusButton(this);
}
@Override
public void drawSlot(Slot slot) {
if (!(slot instanceof SlotFake && FluidRenderUtils.renderFluidPacketIntoGuiSlot(
slot, slot.getStack(), stackSizeRenderer, fontRenderer))) {
super.drawSlot(slot);
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.FLUID_PAT_TERM_CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
}
}
}
@@ -0,0 +1,43 @@
package com.glodblock.github.client;
import appeng.client.gui.implementations.GuiPriority;
import appeng.client.gui.widgets.GuiTabButton;
import com.glodblock.github.interfaces.FCPriorityHost;
import com.glodblock.github.inventory.GuiType;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiFCPriority extends GuiPriority {
private final GuiType originalGui;
private GuiTabButton originalGuiBtn;
public GuiFCPriority(final InventoryPlayer inventoryPlayer, final FCPriorityHost te) {
super(inventoryPlayer, te);
this.originalGui = te.getGuiType();
}
@Override
public void initGui() {
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
if (btn == originalGuiBtn) {
InventoryHandler.switchGui(originalGui);
} else {
super.actionPerformed(btn);
}
}
protected String getBackground() {
return "guis/priority.png";
}
}
@@ -0,0 +1,50 @@
package com.glodblock.github.client;
import appeng.api.AEApi;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.fluids.client.gui.GuiFluidInterface;
import appeng.fluids.helper.IFluidInterfaceHost;
import com.glodblock.github.inventory.GuiType;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import java.io.IOException;
public class GuiFluidDualInterface extends GuiFluidInterface {
private GuiTabButton switchInterface;
private GuiTabButton priorityBtn;
public GuiFluidDualInterface(final InventoryPlayer ip, final IFluidInterfaceHost te) {
super(ip, te);
}
@Override
public void initGui() {
super.initGui();
ItemStack icon = AEApi.instance().definitions().blocks().iface().maybeStack(1).orElse(ItemStack.EMPTY);
switchInterface = new GuiTabButton(guiLeft + 133, guiTop, icon, icon.getDisplayName(), itemRender);
buttonList.add(switchInterface);
priorityBtn = Ae2ReflectClient.getPriorityButton(this);
}
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
if (btn == switchInterface) {
InventoryHandler.switchGui(GuiType.DUAL_ITEM_INTERFACE);
} else if (btn == priorityBtn) {
InventoryHandler.switchGui(GuiType.PRIORITY);
} else {
super.actionPerformed(btn);
}
}
@Override
protected boolean drawUpgrades() {
return false;
}
}
@@ -0,0 +1,40 @@
package com.glodblock.github.client;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.core.localization.GuiText;
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
import appeng.fluids.container.ContainerFluidIO;
import appeng.fluids.parts.PartSharedFluidBus;
import appeng.fluids.util.IAEFluidTank;
import com.glodblock.github.client.container.ContainerFluidExportBus;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFluidExportBus extends GuiUpgradeable {
private final PartSharedFluidBus bus;
public GuiFluidExportBus(InventoryPlayer inventoryPlayer, PartSharedFluidBus te) {
super(new ContainerFluidExportBus(inventoryPlayer, te));
this.bus = te;
}
public void initGui() {
super.initGui();
ContainerFluidIO container = (ContainerFluidIO)this.inventorySlots;
IAEFluidTank inv = this.bus.getConfig();
this.guiSlots.add(new GuiFluidSlot(inv, 0, 0, 80, 40));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 1, 1, 1, 80, 40, -1, 0));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 2, 2, 1, 80, 40, 1, 0));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 3, 3, 1, 80, 40, 0, -1));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 4, 4, 1, 80, 40, 0, 1));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 5, 5, 2, 80, 40, -1, -1));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 6, 6, 2, 80, 40, 1, -1));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 7, 7, 2, 80, 40, -1, 1));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 8, 8, 2, 80, 40, 1, 1));
}
protected GuiText getName() {
return GuiText.ExportBusFluids;
}
}
@@ -0,0 +1,174 @@
package com.glodblock.github.client;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.container.ContainerFluidLevelMaintainer;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidLevelMaintainer;
import com.glodblock.github.network.CPacketUpdateFluidLevel;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.IItemHandler;
import java.io.IOException;
public class GuiFluidLevelMaintainer extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_level_maintainer.png");
private final ContainerFluidLevelMaintainer cont;
private final GuiNumberBox[] maintain = new GuiNumberBox[TileFluidLevelMaintainer.MAX_FLUID];
private final GuiNumberBox[] request = new GuiNumberBox[TileFluidLevelMaintainer.MAX_FLUID];
public GuiFluidLevelMaintainer(InventoryPlayer ipl, TileFluidLevelMaintainer tile) {
super(new ContainerFluidLevelMaintainer(ipl, tile));
this.cont = (ContainerFluidLevelMaintainer) inventorySlots;
this.ySize = 223;
}
public void setMaintainNumber(int id, int size) {
if (id < 0 || id >= TileFluidLevelMaintainer.MAX_FLUID || size < 0)
return;
this.maintain[id].setText(String.valueOf(size));
}
@Override
protected void renderHoveredToolTip(int x, int y) {
if (this.mc.player.inventory.getItemStack().isEmpty() && this.getSlotUnderMouse() != null
&& this.getSlotUnderMouse().getHasStack() && this.getSlotUnderMouse() instanceof ContainerFluidLevelMaintainer.DisplayFluidSlot)
{
ItemStack packet = this.getSlotUnderMouse().getStack();
FluidStack fluid = ItemFluidPacket.getFluidStack(packet);
this.renderToolTip(ItemFluidPacket.newDisplayStack(fluid), x, y);
}
else {
super.renderHoveredToolTip(x, y);
}
}
@Override
protected void keyTyped(char character, int key) throws IOException {
if (!this.checkHotbarKeys(key)) {
GuiNumberBox focus = null;
int id = 0;
for (int i = 0; i < TileFluidLevelMaintainer.MAX_FLUID; i ++) {
if (maintain[i].isFocused()) {
focus = maintain[i];
id = i;
}
if (request[i].isFocused()) {
focus = request[i];
id = i + 10;
}
}
if (focus != null && key != 1) {
if ((key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit(character)) && focus.textboxKeyTyped(character, key)) {
try {
String out = focus.getText();
boolean fixed;
for(fixed = false; out.startsWith("0") && out.length() > 1; fixed = true) {
out = out.substring(1);
}
if (fixed) {
focus.setText(out);
}
if (out.isEmpty()) {
out = "0";
}
long result = Long.parseLong(out);
if (result < 0L) {
focus.setText("1");
result = 1;
}
if (result > Integer.MAX_VALUE) {
result = Integer.MAX_VALUE;
focus.setText(String.valueOf(result));
}
if (id >= 10 || result != 0)
FluidCraft.proxy.netHandler.sendToServer(new CPacketUpdateFluidLevel(id, (int) result));
} catch (NumberFormatException ignored) {
}
}
}
else {
super.keyTyped(character, key);
}
}
}
@Override
public void initGui() {
super.initGui();
for (int i = 0; i < TileFluidLevelMaintainer.MAX_FLUID; i ++) {
maintain[i] = new GuiNumberBox(this.fontRenderer, this.guiLeft + 39, this.guiTop + 33 + i * 20, 51, 10, Integer.class);
request[i] = new GuiNumberBox(this.fontRenderer, this.guiLeft + 102, this.guiTop + 33 + i * 20, 51, 10, Integer.class);
maintain[i].setTextColor(16777215);
request[i].setTextColor(16777215);
maintain[i].setEnableBackgroundDrawing(false);
request[i].setEnableBackgroundDrawing(false);
maintain[i].setMaxStringLength(10);
request[i].setMaxStringLength(10);
}
TileFluidLevelMaintainer tile = this.cont.getTile();
IItemHandler inv = tile.getInventoryHandler();
for (int i = 0; i < inv.getSlots(); i ++) {
if (!inv.getStackInSlot(i).isEmpty()) {
FluidStack fluid = ItemFluidPacket.getFluidStack(inv.getStackInSlot(i));
this.maintain[i].setText(String.valueOf(fluid == null ? "0" : fluid.amount));
}
else {
this.maintain[i].setText("0");
}
this.request[i].setText(String.valueOf(tile.getRequest()[i]));
}
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) throws IOException {
for (int i = 0; i < TileFluidLevelMaintainer.MAX_FLUID; i ++) {
this.configNumberBar(request[i], xCoord, yCoord, btn);
this.configNumberBar(maintain[i], xCoord, yCoord, btn);
}
super.mouseClicked(xCoord, yCoord, btn);
}
private void configNumberBar(GuiNumberBox bar, int xCoord, int yCoord, int btn) {
bar.mouseClicked(xCoord, yCoord, btn);
if (btn == 1 && bar.isFocused()) {
bar.setText("");
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRenderer.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_LEVEL_MAINTAINER)), 8, 6, 0x404040);
fontRenderer.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
fontRenderer.drawString(I18n.format(NameConst.MISC_THRESHOLD), 39, 19, 0x404040);
fontRenderer.drawString(I18n.format(NameConst.MISC_REQ), 102, 19, 0x404040);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
for (int i = 0; i < TileFluidLevelMaintainer.MAX_FLUID ; i ++) {
this.maintain[i].drawTextBox();
this.request[i].drawTextBox();
}
}
}
@@ -1,16 +1,14 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidPacketDecoder;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.util.NameConst;
package com.glodblock.github.client;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.container.ContainerFluidPacketDecoder;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
public class GuiFluidPacketDecoder extends AEBaseGui {
@@ -28,7 +26,8 @@ public class GuiFluidPacketDecoder extends AEBaseGui {
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_PACKET_DECODER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
fontRenderer.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_PACKET_DECODER)), 8, 6, 0x404040);
fontRenderer.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
}
}
}
@@ -0,0 +1,108 @@
package com.glodblock.github.client;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.render.StackSizeRenderer;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.container.ContainerFluidPatternEncoder;
import com.glodblock.github.client.render.FluidRenderUtils;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.interfaces.SlotFluid;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketEncodePattern;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.MouseRegionManager;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class GuiFluidPatternEncoder extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_pattern_encoder.png");
private final ContainerFluidPatternEncoder cont;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
private final StackSizeRenderer stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) {
super(new ContainerFluidPatternEncoder(ipl, tile));
this.cont = (ContainerFluidPatternEncoder)inventorySlots;
mouseRegions.addRegion(141, 38, 10, 10, new MouseRegionManager.Handler() {
@Override
public List<String> getTooltip() {
return Collections.singletonList(I18n.format(NameConst.TT_ENCODE_PATTERN));
}
@Override
public boolean onClick(int button) {
if (button == 0) {
if (cont.canEncodePattern()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketEncodePattern());
}
return true;
}
return false;
}
});
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) throws IOException {
if (mouseRegions.onClick(xCoord, yCoord, btn)) {
super.mouseClicked(xCoord, yCoord, btn);
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRenderer.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_PATTERN_ENCODER)), 8, 6, 0x404040);
fontRenderer.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
mouseRegions.render(mouseX, mouseY);
}
@Override
public void drawSlot(Slot slot) {
if (slot instanceof SlotFluid) {
IAEItemStack stack = ((SlotFluid)slot).getAeStack();
if (FluidRenderUtils.renderFluidPacketIntoGuiSlot(slot, stack, stackSizeRenderer, fontRenderer)) {
return;
}
super.drawSlot(new SlotSingleItem(slot));
stackSizeRenderer.renderStackSize(fontRenderer, stack, slot.xPos, slot.yPos);
} else {
super.drawSlot(slot);
}
}
@Override
@Nonnull
public List<String> getItemToolTip(ItemStack stack) {
if (stack.getItem() instanceof ItemFluidPacket) {
FluidStack fluid = ItemFluidPacket.getFluidStack(stack);
if (fluid != null) {
return Arrays.asList(fluid.getLocalizedName(), String.format(TextFormatting.GRAY + "%,d mB", fluid.amount));
}
}
return super.getItemToolTip(stack);
}
}
@@ -0,0 +1,53 @@
package com.glodblock.github.client;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiPatternTerm;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.StackSizeRenderer;
import appeng.container.slot.SlotFake;
import com.glodblock.github.client.container.ContainerFluidPatternTerminal;
import com.glodblock.github.client.render.FluidRenderUtils;
import com.glodblock.github.inventory.GuiType;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
public class GuiFluidPatternTerminal extends GuiPatternTerm {
private final StackSizeRenderer stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
private GuiTabButton craftingStatusBtn;
public GuiFluidPatternTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
ContainerFluidPatternTerminal container = new ContainerFluidPatternTerminal(inventoryPlayer, te);
container.setGui(this);
this.inventorySlots = container;
Ae2ReflectClient.setGuiContainer(this, container);
}
@Override
public void initGui() {
super.initGui();
craftingStatusBtn = Ae2ReflectClient.getCraftingStatusButton(this);
}
@Override
public void drawSlot(Slot slot) {
if (!(slot instanceof SlotFake && FluidRenderUtils.renderFluidPacketIntoGuiSlot(
slot, slot.getStack(), stackSizeRenderer, fontRenderer))) {
super.drawSlot(slot);
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.FLUID_PAT_TERM_CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
}
}
}
@@ -0,0 +1,44 @@
package com.glodblock.github.client;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;
import com.glodblock.github.common.part.PartExtendedFluidPatternTerminal;
import com.glodblock.github.common.part.PartFluidPatternTerminal;
import com.glodblock.github.inventory.GuiType;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
private GuiTabButton originalGuiBtn;
private final ITerminalHost part;
public GuiFluidPatternTerminalCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
this.part = te;
}
@Override
public void initGui() {
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
if (btn == originalGuiBtn) {
if (part instanceof PartFluidPatternTerminal)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL);
else if (part instanceof PartExtendedFluidPatternTerminal)
InventoryHandler.switchGui(GuiType.FLUID_EXTENDED_PATTERN_TERMINAL);
} else {
super.actionPerformed(btn);
}
}
}
@@ -0,0 +1,77 @@
package com.glodblock.github.client;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
import appeng.fluids.util.IAEFluidTank;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.container.ContainerIngredientBuffer;
import com.glodblock.github.client.render.FluidRenderUtils;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.handler.ButtonMouseHandler;
import com.glodblock.github.handler.TankMouseHandler;
import com.glodblock.github.util.MouseRegionManager;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import java.io.IOException;
public class GuiIngredientBuffer extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/ingredient_buffer.png");
private static final int TANK_X = 47, TANK_X_OFF = 22, TANK_Y = 18;
private static final int TANK_WIDTH = 16, TANK_HEIGHT = 74;
private final ContainerIngredientBuffer cont;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
public GuiIngredientBuffer(InventoryPlayer ipl, TileIngredientBuffer tile) {
super(new ContainerIngredientBuffer(ipl, tile));
this.cont = (ContainerIngredientBuffer) inventorySlots;
this.ySize = 222;
for (int i = 0; i < 4; i++) {
mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
mouseRegions.addRegion(TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7,
ButtonMouseHandler.dumpTank(cont, i));
}
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) throws IOException {
if (mouseRegions.onClick(xCoord, yCoord, btn)) {
super.mouseClicked(xCoord, yCoord, btn);
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRenderer.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_INGREDIENT_BUFFER)), 8, 6, 0x404040);
fontRenderer.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GlStateManager.color(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Tessellator tess = Tessellator.getInstance();
BufferBuilder buf = tess.getBuffer();
for (int i = 0; i < 4; i++) {
FluidRenderUtils.renderFluidIntoGui(tess, buf, TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
fluidInv.getFluidInSlot(i), fluidInv.getTankProperties()[i].getCapacity());
}
GlStateManager.color(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
}
@@ -0,0 +1,50 @@
package com.glodblock.github.client;
import appeng.api.AEApi;
import appeng.client.gui.implementations.GuiInterface;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.helpers.IInterfaceHost;
import com.glodblock.github.inventory.GuiType;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import java.io.IOException;
public class GuiItemDualInterface extends GuiInterface {
private GuiTabButton switchInterface;
private GuiTabButton priorityBtn;
public GuiItemDualInterface(final InventoryPlayer inventoryPlayer, final IInterfaceHost te) {
super(inventoryPlayer, te);
}
@Override
protected void addButtons() {
super.addButtons();
ItemStack icon = AEApi.instance().definitions().blocks().fluidIface().maybeStack(1).orElse(ItemStack.EMPTY);
switchInterface = new GuiTabButton(guiLeft + 133, guiTop, icon, icon.getDisplayName(), itemRender);
buttonList.add(switchInterface);
priorityBtn = Ae2ReflectClient.getPriorityButton(this);
}
@Override
protected String getBackground() {
return "guis/interface.png";
}
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
if (btn == switchInterface) {
InventoryHandler.switchGui(GuiType.DUAL_FLUID_INTERFACE);
} else if (btn == priorityBtn) {
InventoryHandler.switchGui(GuiType.PRIORITY);
} else {
super.actionPerformed(btn);
}
}
}
@@ -1,245 +0,0 @@
package com.glodblock.github.client;
import static appeng.util.Platform.nextEnum;
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.MODE;
import static com.glodblock.github.inventory.item.WirelessMagnet.modeKey;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiFCImgButton;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.item.WirelessMagnet;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.UltraTerminalModes;
import appeng.helpers.ICustomButtonDataObject;
import appeng.util.Platform;
import io.netty.buffer.ByteBuf;
public class UltraTerminalButtons implements ICustomButtonDataObject {
public static String restockItems = "restock";
private ItemStack terminal;
private GuiFCImgButton CraftingTerminal;
private GuiFCImgButton PatternTerminal;
private GuiFCImgButton InterfaceTerminal;
private GuiFCImgButton LevelTerminal;
private GuiFCImgButton PatternTerminalEx;
private GuiFCImgButton magnetOff;
private GuiFCImgButton magnetInv;
private GuiFCImgButton magnetME;
private GuiFCImgButton magnetFilter;
private GuiFCImgButton restockEnableBtn;
private GuiFCImgButton restockDisableBtn;
private WirelessMagnet.Mode magnetMode;
private boolean reStock;
public UltraTerminalModes terminalMode;
private int offset;
public UltraTerminalButtons(ItemStack terminal) {
this.terminal = terminal;
}
public void initCustomButtons(int guiLeft, int guiTop, int xSize, int ySize, int xOffset, int yOffset,
List<GuiButton> buttonList) {
this.offset = yOffset;
buttonList.add(
this.magnetOff = new GuiFCImgButton(guiLeft + xSize - 17, guiTop + ySize - 65, "MAGNET_CARD", "OFF"));
buttonList.add(
this.magnetInv = new GuiFCImgButton(guiLeft + xSize - 17, guiTop + ySize - 65, "MAGNET_CARD", "INV"));
buttonList.add(
this.magnetME = new GuiFCImgButton(guiLeft + xSize - 17, guiTop + ySize - 65, "MAGNET_CARD", "ME"));
buttonList.add(
this.magnetFilter = new GuiFCImgButton(
guiLeft + xSize - 17,
guiTop + ySize - 45,
"MAGNET_CARD",
"FILTER"));
buttonList.add(
this.restockEnableBtn = new GuiFCImgButton(
guiLeft + xSize - 17,
guiTop + ySize - 25,
"RESTOCK",
"ENABLE"));
buttonList.add(
this.restockDisableBtn = new GuiFCImgButton(
guiLeft + xSize - 17,
guiTop + ySize - 25,
"RESTOCK",
"DISABLE"));
buttonList.add(this.CraftingTerminal = new GuiFCImgButton(guiLeft - 18, yOffset, "CRAFT_TEM", "YES"));
buttonList.add(this.PatternTerminal = new GuiFCImgButton(guiLeft - 18, yOffset, "PATTERN_TEM", "YES"));
buttonList.add(this.PatternTerminalEx = new GuiFCImgButton(guiLeft - 18, yOffset, "PATTERN_EX_TEM", "YES"));
buttonList.add(this.InterfaceTerminal = new GuiFCImgButton(guiLeft - 18, yOffset, "INTERFACE_TEM", "YES"));
buttonList.add(this.LevelTerminal = new GuiFCImgButton(guiLeft - 18, yOffset, "LEVEL_TEM", "YES"));
toggleSwitchButtons();
toggleMagnetButtonsVisibility();
toggleRestockVisibility();
}
@Override
public boolean actionPerformedCustomButtons(final GuiButton btn) {
if (btn instanceof GuiFCImgButton) {
UltraTerminalModes mode = null;
if (btn == this.CraftingTerminal) {
mode = UltraTerminalModes.CRAFTING;
} else if (btn == this.PatternTerminal) {
mode = UltraTerminalModes.PATTERN;
} else if (btn == this.InterfaceTerminal) {
mode = UltraTerminalModes.INTERFACE;
} else if (btn == this.LevelTerminal) {
mode = UltraTerminalModes.LEVEL;
} else if (btn == this.PatternTerminalEx) {
mode = UltraTerminalModes.PATTERN_EX;
}
if (mode != null) {
ItemWirelessUltraTerminal.setMode(this.terminal, mode);
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(mode, true));
}
if (btn == this.magnetOff || btn == this.magnetME || btn == this.magnetInv) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
CPacketFluidPatternTermBtns.Command.MAGNET_MODE,
this.magnetMode.ordinal()));
} else if (btn == this.magnetFilter) FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(CPacketFluidPatternTermBtns.Command.MAGNET_OPEN_FILTER, 0));
else if (btn == this.restockDisableBtn || btn == this.restockEnableBtn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns(CPacketFluidPatternTermBtns.Command.RESTOCK, 1));
}
return true;
}
return false;
}
public void toggleRestock() {
this.reStock = !this.reStock;
}
public void toggleRestockVisibility() {
if (Platform.isClient()) {
if (this.reStock) {
this.restockEnableBtn.setVisibility(true);
this.restockDisableBtn.setVisibility(false);
} else {
this.restockEnableBtn.setVisibility(false);
this.restockDisableBtn.setVisibility(true);
}
}
}
public void toggleMagnetMode() {
this.magnetMode = nextEnum(this.magnetMode);
}
public void toggleMagnetButtonsVisibility() {
switch (this.magnetMode) {
case Off -> {
this.magnetME.setVisibility(false);
this.magnetInv.setVisibility(false);
this.magnetOff.setVisibility(true);
}
case ME -> {
this.magnetME.setVisibility(true);
this.magnetInv.setVisibility(false);
this.magnetOff.setVisibility(false);
}
case Inv -> {
this.magnetME.setVisibility(false);
this.magnetInv.setVisibility(true);
this.magnetOff.setVisibility(false);
}
}
}
public void toggleSwitchButtons() {
int offset = this.offset;
CraftingTerminal.setVisibility(false);
PatternTerminal.setVisibility(false);
InterfaceTerminal.setVisibility(false);
LevelTerminal.setVisibility(false);
PatternTerminalEx.setVisibility(false);
if (this.terminalMode != UltraTerminalModes.CRAFTING) {
this.CraftingTerminal.setVisibility(true);
this.CraftingTerminal.yPosition = offset;
offset += 20;
}
if (this.terminalMode != UltraTerminalModes.PATTERN) {
this.PatternTerminal.setVisibility(true);
this.PatternTerminal.yPosition = offset;
offset += 20;
}
if (this.terminalMode != UltraTerminalModes.PATTERN_EX) {
this.PatternTerminalEx.setVisibility(true);
this.PatternTerminalEx.yPosition = offset;
offset += 20;
}
if (this.terminalMode != UltraTerminalModes.INTERFACE) {
this.InterfaceTerminal.setVisibility(true);
this.InterfaceTerminal.yPosition = offset;
offset += 20;
}
if (this.terminalMode != UltraTerminalModes.LEVEL) {
this.LevelTerminal.setVisibility(true);
this.LevelTerminal.yPosition = offset;
offset += 20;
}
}
@Override
public void readData(NBTTagCompound tag) {
this.reStock = tag.getBoolean(restockItems);
this.magnetMode = WirelessMagnet.Mode.values()[tag.getInteger(modeKey)];
this.terminalMode = UltraTerminalModes.values()[tag.getInteger(MODE)];
}
@Override
public void writeData(NBTTagCompound tag) {
tag.setBoolean(restockItems, this.reStock);
tag.setInteger(modeKey, this.magnetMode.ordinal());
tag.setInteger(MODE, this.terminalMode.ordinal());
}
@Override
public void readByte(ByteBuf buf) {
this.reStock = buf.readBoolean();
this.magnetMode = WirelessMagnet.Mode.values()[buf.readInt()];
this.terminalMode = UltraTerminalModes.values()[buf.readInt()];
toggleMagnetButtonsVisibility();
toggleRestockVisibility();
toggleSwitchButtons();
}
@Override
public void writeByte(ByteBuf buf) {
buf.writeBoolean(this.reStock);
buf.writeInt(this.magnetMode.ordinal());
buf.writeInt(this.terminalMode.ordinal());
}
}
@@ -0,0 +1,134 @@
package com.glodblock.github.client.container;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import appeng.fluids.container.IFluidSyncContainer;
import appeng.fluids.helper.FluidSyncHelper;
import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform;
import com.glodblock.github.common.tile.TileBurette;
import com.glodblock.github.interfaces.TankDumpable;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
public class ContainerBurette extends AEBaseContainer implements IFluidSyncContainer, TankDumpable {
private final TileBurette tile;
private final FluidSyncHelper fluidSync;
public ContainerBurette(InventoryPlayer ipl, TileBurette tile) {
super(ipl, tile);
this.tile = tile;
this.fluidSync = new FluidSyncHelper(tile.getFluidInventory(), 0);
addSlotToContainer(new SlotNormal(tile.getInternalInventory(), 0, 52, 53));
bindPlayerInventory(ipl, 0, 84);
}
public TileBurette getTile() {
return tile;
}
public boolean canTranferFluid(boolean into) {
IAEFluidTank tileTank = tile.getFluidInventory();
IFluidTankProperties tileTankInfo = tileTank.getTankProperties()[0];
IAEFluidStack tileFluid = tileTank.getFluidInSlot(0);
if (into) {
if (tileFluid != null && tileFluid.getStackSize() >= tileTankInfo.getCapacity()) {
return false;
}
} else if (tileFluid == null) {
return false;
}
ItemStack stack = tile.getInternalInventory().getStackInSlot(0);
if (stack.isEmpty() || !stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
return false;
}
IFluidHandlerItem itemTank = Objects.requireNonNull(
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null));
for (IFluidTankProperties itemTankInfo : itemTank.getTankProperties()) {
if (into) {
if (itemTankInfo.canDrain() && tileTankInfo.canFillFluidType(itemTankInfo.getContents())) {
return true;
}
} else if (itemTankInfo.canFillFluidType(tileFluid.getFluidStack())) {
return true;
}
}
return false;
}
public void tryTransferFluid(int amount, boolean into) {
ItemStack stack = tile.getInternalInventory().getStackInSlot(0);
if (stack.isEmpty() || !stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
return;
}
IAEFluidTank tileTank = tile.getFluidInventory();
IFluidHandlerItem itemTank = Objects.requireNonNull(
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null));
if (into) {
transferFluidBetween(itemTank, tileTank, amount);
} else {
transferFluidBetween(tileTank, itemTank, amount);
}
tile.getInternalInventory().setStackInSlot(0, itemTank.getContainer());
}
private void transferFluidBetween(IFluidHandler from, IFluidHandler to, int amount) {
// simulated pass to figure out the real amount we can transfer
FluidStack fluid = from.drain(amount, false);
if (fluid == null) {
return;
}
amount = Math.min(amount, to.fill(fluid, false));
// actually do the transfer
fluid = from.drain(amount, true);
if (fluid != null) {
fluid.amount -= to.fill(fluid, true);
if (fluid.amount > 0) { // just in case the tanks don't behave exactly as simulated
from.fill(fluid, true);
}
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (Platform.isServer()) {
fluidSync.sendDiff(listeners);
}
}
@Override
public void addListener(@Nonnull IContainerListener listener) {
super.addListener(listener);
fluidSync.sendFull(Collections.singleton(listener));
}
@Override
public void receiveFluidSlots(Map<Integer, IAEFluidStack> fluids) {
fluidSync.readPacket(fluids);
}
@Override
public boolean canDumpTank(int index) {
return tile.getFluidInventory().getFluidInSlot(0) != null;
}
@Override
public void dumpTank(int index) {
tile.getFluidInventory().setFluidInSlot(0, null);
}
}
@@ -0,0 +1,436 @@
package com.glodblock.github.client.container;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.ContainerExpandedProcessingPatternTerm;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.part.PartExtendedFluidPatternTerminal;
import com.glodblock.github.interfaces.PatternConsumer;
import com.glodblock.github.loader.FCItems;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ContainerExtendedFluidPatternTerminal extends ContainerExpandedProcessingPatternTerm implements PatternConsumer {
private final Slot[] craftingSlots;
private final Slot[] outputSlots;
private final Slot patternSlotIN;
private final Slot patternSlotOUT;
public final ITerminalHost part;
public ContainerExtendedFluidPatternTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
craftingSlots = Ae2Reflect.getExCraftingSlots(this);
outputSlots = Ae2Reflect.getExOutputSlots(this);
patternSlotIN = Ae2Reflect.getExPatternSlotIn(this);
patternSlotOUT = Ae2Reflect.getExPatternSlotOut(this);
part = monitorable;
}
@Override
public void encode() {
if (!checkHasFluidPattern()) {
super.encode();
return;
}
ItemStack stack = this.patternSlotOUT.getStack();
if (stack.isEmpty()) {
stack = this.patternSlotIN.getStack();
if (stack.isEmpty() || !isPattern(stack)) {
return;
}
if (stack.getCount() == 1) {
this.patternSlotIN.putStack(ItemStack.EMPTY);
} else {
stack.shrink(1);
}
encodeFluidPattern();
} else if (isPattern(stack)) {
encodeFluidPattern();
}
}
private static boolean isPattern(final ItemStack output) {
if (output.isEmpty()) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output);
}
private boolean checkHasFluidPattern() {
boolean hasFluid = false, search = false;
for (Slot craftingSlot : this.craftingSlots) {
final ItemStack crafting = craftingSlot.getStack();
if (crafting.isEmpty()) {
continue;
}
search = true;
if (crafting.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
if (!search) { // search=false -> inputs were empty
return false;
}
// `search` should be true at this point
for (Slot outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if (out.isEmpty()) {
continue;
}
search = false;
if (hasFluid) {
break;
} else if (out.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
return hasFluid && !search; // search=true -> outputs were empty
}
private void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(FCItems.DENSE_ENCODED_PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectInventory(craftingSlots));
pattern.setOutputs(collectInventory(outputSlots));
patternSlotOUT.putStack(pattern.writeToStack());
}
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of DensePatternDetails
List<IAEItemStack> acc = new ArrayList<>();
for (Slot slot : slots) {
ItemStack stack = slot.getStack();
if (stack.isEmpty()) {
continue;
}
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
acc.add(dropStack);
continue;
}
}
IAEItemStack aeStack = AEItemStack.fromItemStack(stack);
if (aeStack == null) {
continue;
}
acc.add(aeStack);
}
return acc.toArray(new IAEItemStack[0]);
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
super.doAction(player, action, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && !stack.isEmpty()
&& stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null) && Util.getFluidFromItem(stack) != null) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
case SPLIT_OR_PLACE_SINGLE:
fluid = Util.getFluidFromItem(ItemHandlerHelper.copyStackWithSize(stack, 1));
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.equals(origin)) {
fluid.amount += origin.amount;
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
if (stack.isEmpty() && !slot.getStack().isEmpty() && slot.getStack().getItem() instanceof ItemFluidPacket) {
FluidStack fluid = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.amount - 1000 >= 1) {
fluid.amount -= 1000;
slot.putStack(ItemFluidPacket.newStack(fluid));
}
}
}
super.doAction(player, action, slotId, id);
}
@Override
public void multiply(int multiple) {
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt * multiple > Integer.MAX_VALUE) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt * multiple > slot.getStack().getMaxStackSize()) {
return;
}
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt * multiple > Integer.MAX_VALUE) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt * multiple > slot.getStack().getMaxStackSize()) {
return;
}
}
}
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount *= multiple;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() * multiple);
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount *= multiple;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() * multiple);
}
}
}
@Override
public void divide(int divide) {
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt % divide != 0) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt % divide != 0) {
return;
}
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt % divide != 0) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt % divide != 0) {
return;
}
}
}
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount /= divide;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() / divide);
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount /= divide;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() / divide);
}
}
}
@Override
public void increase(int increase) {
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt + increase * 1000 > Integer.MAX_VALUE) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt + increase > slot.getStack().getMaxStackSize()) {
return;
}
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt + increase * 1000 > Integer.MAX_VALUE) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt + increase > slot.getStack().getMaxStackSize()) {
return;
}
}
}
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount += increase * 1000;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() + increase);
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount += increase * 1000;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() + increase);
}
}
}
@Override
public void decrease(int decrease) {
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt - decrease * 1000 < 1) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt - decrease < 1) {
return;
}
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt - decrease * 1000 < 1) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt - decrease < 1) {
return;
}
}
}
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount -= decrease * 1000;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() - decrease);
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount -= decrease * 1000;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() - decrease);
}
}
}
@Override
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
if (part instanceof PartExtendedFluidPatternTerminal) {
((PartExtendedFluidPatternTerminal) part).onChangeCrafting(inputs, outputs);
}
}
}
@@ -0,0 +1,25 @@
package com.glodblock.github.client.container;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.api.util.IConfigManager;
import appeng.fluids.container.ContainerFluidIO;
import appeng.fluids.parts.PartSharedFluidBus;
import com.glodblock.github.common.part.PartFluidExportBus;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFluidExportBus extends ContainerFluidIO {
public ContainerFluidExportBus(InventoryPlayer ip, PartSharedFluidBus te) {
super(ip, te);
}
@Override
protected void loadSettingsFromHost(IConfigManager cm) {
super.loadSettingsFromHost(cm);
if (this.getUpgradeable() instanceof PartFluidExportBus) {
this.setCraftingMode((YesNo)cm.getSetting(Settings.CRAFT_ONLY));
}
}
}
@@ -0,0 +1,99 @@
package com.glodblock.github.client.container;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.helpers.InventoryAction;
import appeng.tile.inventory.AppEngInternalAEInventory;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidLevelMaintainer;
import com.glodblock.github.network.SPacketSetFluidLevel;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull;
import java.util.Objects;
public class ContainerFluidLevelMaintainer extends AEBaseContainer {
private final TileFluidLevelMaintainer tile;
public ContainerFluidLevelMaintainer(InventoryPlayer ip, TileFluidLevelMaintainer tile) {
super(ip, tile);
this.tile = tile;
IItemHandler inv = tile.getInventoryHandler();
for (int i = 0; i < 5; i++) {
addSlotToContainer(new DisplayFluidSlot(inv, i, 17, 28 + i * 20));
}
bindPlayerInventory(ip, 0, 141);
}
public TileFluidLevelMaintainer getTile() {
return tile;
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
Slot slot = getSlot(slotId);
if (slot instanceof DisplayFluidSlot) {
final ItemStack stack = player.inventory.getItemStack();
FluidStack fluid = Util.getFluidFromItem(stack);
FluidCraft.proxy.netHandler.sendTo(new SPacketSetFluidLevel(slotId, fluid == null ? 0 : fluid.amount), player);
slot.putStack(stack.isEmpty() ? stack : stack.copy());
} else {
super.doAction(player, action, slotId, id);
}
}
public static class DisplayFluidSlot extends SlotFake {
final AppEngInternalAEInventory handler;
public DisplayFluidSlot(IItemHandler inv, int idx, int x, int y) {
super(inv, idx, x, y);
this.handler = (AppEngInternalAEInventory) inv;
}
@Override
public void putStack(ItemStack is) {
if (is.isEmpty()) {
super.putStack(is);
return;
}
if (is.getItem() instanceof ItemFluidPacket) {
super.putStack(is);
return;
}
if (is.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidTankProperties[] tanks = Objects.requireNonNull(
is.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null))
.getTankProperties();
for (IFluidTankProperties tank : tanks) {
ItemStack packet = ItemFluidPacket.newStack(tank.getContents());
super.putStack(packet);
return;
}
}
super.putStack(ItemStack.EMPTY);
}
@Override
public int getSlotStackLimit() {
return Integer.MAX_VALUE;
}
@Override
public int getItemStackLimit(@Nonnull ItemStack stack) {
return Integer.MAX_VALUE;
}
}
}
@@ -1,19 +1,16 @@
package com.glodblock.github.client.gui.container;
import static com.glodblock.github.loader.ItemAndBlockHolder.PACKET;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.inventory.slot.FCSlotRestrictedInput;
package com.glodblock.github.client.container;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFluidPacketDecoder extends AEBaseContainer {
public ContainerFluidPacketDecoder(InventoryPlayer ipl, TileFluidPacketDecoder tile) {
super(ipl, tile);
addSlotToContainer(new FCSlotRestrictedInput(PACKET.stack(), tile.getInventory(), 0, 80, 35, ipl));
addSlotToContainer(new SlotNormal(tile.getInventory(), 0, 80, 35));
bindPlayerInventory(ipl, 0, 84);
}
}
}
@@ -1,33 +1,36 @@
package com.glodblock.github.client.gui.container;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.AeStackInventory;
import com.glodblock.github.inventory.IPatternConsumer;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
package com.glodblock.github.client.container;
import appeng.api.AEApi;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotRestrictedInput;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.handler.AeItemStackHandler;
import com.glodblock.github.interfaces.AeStackInventory;
import com.glodblock.github.interfaces.PatternConsumer;
import com.glodblock.github.interfaces.SlotFluid;
import com.glodblock.github.loader.FCItems;
import com.glodblock.github.util.FluidPatternDetails;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import net.minecraftforge.items.ItemHandlerHelper;
public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPatternConsumer {
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ContainerFluidPatternEncoder extends AEBaseContainer implements PatternConsumer {
private final TileFluidPatternEncoder tile;
@@ -42,22 +45,10 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
}
addSlotToContainer(new SlotFluidConvertingFake(output, y, 113, 17 + y * 18));
}
addSlotToContainer(
new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN,
tile.getInventory(),
0,
138,
20,
ipl));
addSlotToContainer(
new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN,
tile.getInventory(),
1,
138,
50,
ipl));
addSlotToContainer(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, tile.getInventory(), 0, 138, 20, ipl));
addSlotToContainer(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, tile.getInventory(), 1, 138, 50, ipl));
bindPlayerInventory(ipl, 0, 84);
}
@@ -65,17 +56,12 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
return tile;
}
private static boolean isNotPattern(ItemStack stack) {
return stack == null || !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack)
|| (stack.getItem() instanceof ItemFluidEncodedPattern));
}
public boolean canEncodePattern() {
if (isNotPattern(tile.getInventory().getStackInSlot(0))
&& isNotPattern(tile.getInventory().getStackInSlot(1))) {
if (isNotPattern(tile.getInventory().getStackInSlot(0)) && isNotPattern(tile.getInventory().getStackInSlot(1))) {
return false;
}
find_input: {
find_input:
{
for (IAEItemStack stack : tile.getCraftingSlots()) {
if (stack != null && stack.getStackSize() > 0) {
break find_input;
@@ -91,25 +77,27 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
return false;
}
private static boolean isNotPattern(ItemStack stack) {
return stack.isEmpty() || !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack)
|| (stack.getItem() instanceof ItemFluidEncodedPattern));
}
public void encodePattern() {
if (canEncodePattern()) {
// if there is an encoded pattern, overwrite it; otherwise, consume a blank
if (tile.getInventory().getStackInSlot(1) == null) {
tile.getInventory().decrStackSize(0, 1); // this better work
if (tile.getInventory().getStackInSlot(1).isEmpty()) {
tile.getInventory().extractItem(0, 1, false); // this better work
}
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
ItemStack patternStack = new ItemStack(FCItems.DENSE_ENCODED_PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectAeInventory(tile.getCraftingSlots()));
pattern.setOutputs(collectAeInventory(tile.getOutputSlots()));
tile.getInventory().setInventorySlotContents(1, pattern.writeToStack());
tile.getInventory().setStackInSlot(1, pattern.writeToStack());
}
}
private static IAEItemStack[] collectAeInventory(AeStackInventory<IAEItemStack> inv) {
/*
* AE2 API documentation says the input/output arrays can contain nulls, but their use of the API directly
* contradicts that, so we just go by behaviour and filter out nulls.
*/
// see note at top of DensePatternDetails
List<IAEItemStack> acc = new ArrayList<>();
for (IAEItemStack stack : inv) {
if (stack != null) {
@@ -133,39 +121,33 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
if (slot instanceof SlotFluidConvertingFake) {
final ItemStack stack = player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SET_DOWN -> {
if (stack == null) {
slot.putStack(null);
case PICKUP_OR_SET_DOWN:
if (stack.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
((SlotFluidConvertingFake) slot).putConvertedStack(stack.copy());
((SlotFluidConvertingFake)slot).putConvertedStack(stack.copy());
}
}
case PLACE_SINGLE -> {
if (stack != null) {
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
break;
case PLACE_SINGLE:
if (!stack.isEmpty()) {
((SlotFluidConvertingFake)slot).putConvertedStack(ItemHandlerHelper.copyStackWithSize(stack, 1));
}
}
case SPLIT_OR_PLACE_SINGLE -> {
break;
case SPLIT_OR_PLACE_SINGLE:
ItemStack inSlot = slot.getStack();
if (inSlot != null) {
if (stack == null) {
slot.putStack(Util.copyStackWithSize(inSlot, Math.max(1, inSlot.stackSize - 1)));
if (!inSlot.isEmpty()) {
if (stack.isEmpty()) {
slot.putStack(ItemHandlerHelper.copyStackWithSize(inSlot, Math.max(1, inSlot.getCount() - 1)));
} else if (stack.isItemEqual(inSlot)) {
slot.putStack(
Util.copyStackWithSize(
inSlot,
Math.min(inSlot.getMaxStackSize(), inSlot.stackSize + 1)));
slot.putStack(ItemHandlerHelper.copyStackWithSize(inSlot,
Math.min(inSlot.getMaxStackSize(), inSlot.getCount() + 1)));
} else {
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
((SlotFluidConvertingFake)slot).putConvertedStack(ItemHandlerHelper.copyStackWithSize(stack, 1));
}
} else if (stack != null) {
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
} else if (!stack.isEmpty()) {
((SlotFluidConvertingFake)slot).putConvertedStack(ItemHandlerHelper.copyStackWithSize(stack, 1));
}
}
default -> {}
break;
}
} else {
super.doAction(player, action, slotId, id);
@@ -184,4 +166,51 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
dest.setStack(i, src[i]);
}
}
private static class SlotFluidConvertingFake extends SlotFake implements SlotFluid {
private final AeStackInventory<IAEItemStack> inv;
public SlotFluidConvertingFake(AeItemStackHandler inv, int idx, int x, int y) {
super(inv, idx, x, y);
this.inv = inv.getAeInventory();
}
@Override
public void putStack(ItemStack stack) {
inv.setStack(getSlotIndex(), AEItemStack.fromItemStack(stack));
}
@Override
public void setAeStack(@Nullable IAEItemStack stack, boolean sync) {
inv.setStack(getSlotIndex(), stack);
}
public void putConvertedStack(ItemStack stack) {
if (stack.isEmpty()) {
setAeStack(null, false);
return;
} else if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) {
IFluidTankProperties[] tanks = Objects.requireNonNull(
stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null))
.getTankProperties();
for (IFluidTankProperties tank : tanks) {
IAEItemStack aeStack = ItemFluidPacket.newAeStack(tank.getContents());
if (aeStack != null) {
setAeStack(aeStack, false);
return;
}
}
}
putStack(stack);
}
@Nullable
@Override
public IAEItemStack getAeStack() {
return inv.getStack(getSlotIndex());
}
}
}
@@ -0,0 +1,441 @@
package com.glodblock.github.client.container;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.part.PartFluidPatternTerminal;
import com.glodblock.github.interfaces.PatternConsumer;
import com.glodblock.github.loader.FCItems;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ContainerFluidPatternTerminal extends ContainerPatternTerm implements PatternConsumer {
private final Slot[] craftingSlots;
private final Slot[] outputSlots;
private final Slot patternSlotIN;
private final Slot patternSlotOUT;
public ContainerFluidPatternTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
craftingSlots = Ae2Reflect.getCraftingSlots(this);
outputSlots = Ae2Reflect.getOutputSlots(this);
patternSlotIN = Ae2Reflect.getPatternSlotIn(this);
patternSlotOUT = Ae2Reflect.getPatternSlotOut(this);
}
@Override
public void encode() {
if (!checkHasFluidPattern()) {
super.encode();
return;
}
ItemStack stack = this.patternSlotOUT.getStack();
if (stack.isEmpty()) {
stack = this.patternSlotIN.getStack();
if (stack.isEmpty() || !isPattern(stack)) {
return;
}
if (stack.getCount() == 1) {
this.patternSlotIN.putStack(ItemStack.EMPTY);
} else {
stack.shrink(1);
}
encodeFluidPattern();
} else if (isPattern(stack)) {
encodeFluidPattern();
}
}
private static boolean isPattern(final ItemStack output) {
if (output.isEmpty()) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output);
}
private boolean checkHasFluidPattern() {
if (this.craftingMode) {
return false;
}
boolean hasFluid = false, search = false;
for (Slot craftingSlot : this.craftingSlots) {
final ItemStack crafting = craftingSlot.getStack();
if (crafting.isEmpty()) {
continue;
}
search = true;
if (crafting.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
if (!search) { // search=false -> inputs were empty
return false;
}
// `search` should be true at this point
for (Slot outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if (out.isEmpty()) {
continue;
}
search = false;
if (hasFluid) {
break;
} else if (out.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
return hasFluid && !search; // search=true -> outputs were empty
}
private void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(FCItems.DENSE_ENCODED_PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectInventory(craftingSlots));
pattern.setOutputs(collectInventory(outputSlots));
patternSlotOUT.putStack(pattern.writeToStack());
}
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of DensePatternDetails
List<IAEItemStack> acc = new ArrayList<>();
for (Slot slot : slots) {
ItemStack stack = slot.getStack();
if (stack.isEmpty()) {
continue;
}
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
acc.add(dropStack);
continue;
}
}
IAEItemStack aeStack = AEItemStack.fromItemStack(stack);
if (aeStack == null) {
continue;
}
acc.add(aeStack);
}
return acc.toArray(new IAEItemStack[0]);
}
@Override
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
if (getPatternTerminal() instanceof PartFluidPatternTerminal) {
((PartFluidPatternTerminal)getPatternTerminal()).onChangeCrafting(inputs, outputs);
}
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
if (this.isCraftingMode()) {
super.doAction(player, action, slotId, id);
return;
}
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
super.doAction(player, action, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && !stack.isEmpty()
&& stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null) && Util.getFluidFromItem(stack) != null) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
case SPLIT_OR_PLACE_SINGLE:
fluid = Util.getFluidFromItem(ItemHandlerHelper.copyStackWithSize(stack, 1));
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.equals(origin)) {
fluid.amount += origin.amount;
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
if (stack.isEmpty() && !slot.getStack().isEmpty() && slot.getStack().getItem() instanceof ItemFluidPacket) {
FluidStack fluid = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.amount - 1000 >= 1) {
fluid.amount -= 1000;
slot.putStack(ItemFluidPacket.newStack(fluid));
}
}
}
super.doAction(player, action, slotId, id);
}
@Override
public void multiply(int multiple) {
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt * multiple > Integer.MAX_VALUE) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt * multiple > slot.getStack().getMaxStackSize()) {
return;
}
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt * multiple > Integer.MAX_VALUE) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt * multiple > slot.getStack().getMaxStackSize()) {
return;
}
}
}
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount *= multiple;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() * multiple);
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount *= multiple;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() * multiple);
}
}
}
@Override
public void divide(int divide) {
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt % divide != 0) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt % divide != 0) {
return;
}
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt % divide != 0) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt % divide != 0) {
return;
}
}
}
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount /= divide;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() / divide);
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount /= divide;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() / divide);
}
}
}
@Override
public void increase(int increase) {
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt + increase * 1000 > Integer.MAX_VALUE) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt + increase > slot.getStack().getMaxStackSize()) {
return;
}
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt + increase * 1000 > Integer.MAX_VALUE) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt + increase > slot.getStack().getMaxStackSize()) {
return;
}
}
}
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount += increase * 1000;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() + increase);
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount += increase * 1000;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() + increase);
}
}
}
@Override
public void decrease(int decrease) {
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt - decrease * 1000 < 1) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt - decrease < 1) {
return;
}
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
long amt = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack())).amount;
if (amt - decrease * 1000 < 1) {
return;
}
}
else if (!slot.getStack().isEmpty()) {
long amt = slot.getStack().getCount();
if (amt - decrease < 1) {
return;
}
}
}
for (Slot slot : this.craftingSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount -= decrease * 1000;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() - decrease);
}
}
for (Slot slot : this.outputSlots) {
if (ItemFluidPacket.isFluidPacket(slot.getStack()) && ItemFluidPacket.getFluidStack(slot.getStack()) != null) {
FluidStack fluid = Objects.requireNonNull(ItemFluidPacket.getFluidStack(slot.getStack()));
fluid.amount -= decrease * 1000;
ItemStack packet = ItemFluidPacket.newStack(fluid);
slot.putStack(packet);
}
else if (!slot.getStack().isEmpty()) {
ItemStack stack = slot.getStack();
stack.setCount(stack.getCount() - decrease);
}
}
}
}
@@ -0,0 +1,40 @@
package com.glodblock.github.client.container;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.interfaces.TankDumpable;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.items.IItemHandler;
public class ContainerIngredientBuffer extends AEBaseContainer implements TankDumpable {
private final TileIngredientBuffer tile;
public ContainerIngredientBuffer(InventoryPlayer ipl, TileIngredientBuffer tile) {
super(ipl, tile);
this.tile = tile;
IItemHandler inv = tile.getInternalInventory();
for (int i = 0; i < 9; i++) {
addSlotToContainer(new SlotNormal(inv, i, 8 + 18 * i, 108));
}
bindPlayerInventory(ipl, 0, 140);
}
public TileIngredientBuffer getTile() {
return tile;
}
@Override
public boolean canDumpTank(int index) {
return tile.getFluidInventory().getFluidInSlot(index) != null;
}
@Override
public void dumpTank(int index) {
if (index >= 0 && index < tile.getFluidInventory().getSlots()) {
tile.getFluidInventory().setFluidInSlot(index, null);
}
}
}
@@ -1,87 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
// copy from WirelessCraftingTerminal WCTGuiButton
public class FCGuiBaseButton extends GuiButton {
protected static final ResourceLocation buttonTextures = new ResourceLocation(
"minecraft",
"textures/gui/widgets.png");
public FCGuiBaseButton(int id, int xPosition, int yPosition, int width, int height, String displayString) {
super(id, xPosition, yPosition, width, height, displayString);
this.enabled = true;
this.visible = true;
this.id = id;
this.xPosition = xPosition;
this.yPosition = yPosition;
this.width = width;
this.height = height;
this.displayString = displayString;
}
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
FontRenderer fontrenderer = mc.fontRenderer;
mc.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
int k = this.getHoverState(this.field_146123_n);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(
this.xPosition + this.width / 2,
this.yPosition,
200 - this.width / 2,
46 + k * 20,
this.width / 2,
this.height - 2);
this.drawTexturedModalRect(
this.xPosition + 2,
this.yPosition + (this.height - 2),
200 - (this.width - 2),
64 + k * 20,
this.width - 2,
2);
this.drawTexturedModalRect(
this.xPosition,
this.yPosition + (this.height - 1),
200 - this.width,
65 + k * 20,
this.width,
1);
this.mouseDragged(mc, mouseX, mouseY);
int l = 14737632;
if (packedFGColour != 0) {
l = packedFGColour;
} else if (!this.enabled) {
l = 10526880;
} else if (this.field_146123_n) {
l = 16777120;
}
this.drawCenteredString(
fontrenderer,
this.displayString,
this.xPosition + this.width / 2,
this.yPosition + (this.height - 8) / 2,
l);
}
}
}
@@ -1,26 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.FontRenderer;
public class FCGuiLineField extends FCGuiTextField {
private final int _xPos;
private final int _yPos;
public FCGuiLineField(FontRenderer fontRenderer, int xPos, int yPos, int width) {
this(fontRenderer, xPos, yPos, width, 5);
}
public FCGuiLineField(FontRenderer fontRenderer, int xPos, int yPos, int width, int height) {
super(fontRenderer, xPos, yPos, width, height);
this._xPos = xPos;
this._yPos = yPos;
}
@Override
public void drawTextBox() {
if (this.getVisible()) {
drawRect(this._xPos, this._yPos, this.xPosition + this.width, this.yPosition + this.height, getColor());
}
}
}
@@ -1,171 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.ITooltip;
public class FCGuiTextField extends GuiTextField {
private static final int PADDING = 2;
private final FontRenderer _fontRender;
private String tooltip;
private final int _xPos;
private final int _yPos;
private final int _width;
private final int _height;
private int _border;
private int _color;
/**
* Uses the values to instantiate a padded version of a text field. Pays attention to the '_' caret.
*
* @param fontRenderer renderer for the strings
* @param xPos absolute left position
* @param yPos absolute top position
* @param width absolute width
* @param height absolute height
*/
public FCGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width,
final int height) {
super(
fontRenderer,
xPos + PADDING,
yPos + PADDING,
width - 2 * PADDING - fontRenderer.getCharWidth('_'),
height - 2 * PADDING);
this._xPos = xPos;
this._yPos = yPos;
this._width = width;
this._height = height;
this._fontRender = fontRenderer;
}
@Override
public void drawTextBox() {
super.drawTextBox();
if (this.getBorder() > 0 && this.getVisible()) {
drawRect(
this._xPos - getBorder(),
this._yPos - getBorder(),
this.xPosition + this.width + getBorder(),
this.yPosition + this.height + getBorder(),
this.getColor());
}
}
public void handleTooltip(int mouseX, int mouseY, AEBaseGui gui) {
this.handleTooltip(mouseX, mouseY, gui, 0);
}
public void handleTooltip(int mouseX, int mouseY, AEBaseGui gui, int offsetY) {
if (isMouseIn(mouseX, mouseY) && this.tooltip != null && !"".equals(this.tooltip)) {
int length = 0;
for (String s : this.getMessage().split("\n")) {
length = Math.max(this._fontRender.getStringWidth(s), length);
}
if (mouseY < 15) {
mouseY = 15;
}
if (mouseX + length + 20 >= gui.width) {
gui.drawTooltip(mouseX - length - 20, mouseY + 4 + offsetY, this.getMessage());
} else {
gui.drawTooltip(mouseX, mouseY + 4 + offsetY, this.getMessage());
}
}
}
public int getBorder() {
return this._border;
}
public void setBorder(int border) {
this._border = border;
this._color = 0;
}
public void setBorder(int border, int color) {
this._border = border;
this._color = color;
}
public void setBorder() {
this._border = 0;
this._color = 0;
}
public int getColor() {
return this._color;
}
public void setColor(int color) {
this._color = color;
}
@Override
public void mouseClicked(final int xPos, final int yPos, final int button) {
super.mouseClicked(xPos, yPos, button);
final boolean requiresFocus = this.isMouseIn(xPos, yPos);
this.setFocused(requiresFocus);
}
/**
* Checks if the mouse is within the element
*
* @param xCoord current x coord of the mouse
* @param yCoord current y coord of the mouse
* @return true if mouse position is within the text field area
*/
public boolean isMouseIn(final int xCoord, final int yCoord) {
final boolean withinXRange = this._xPos <= xCoord && xCoord < this._xPos + this._width;
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
return withinXRange && withinYRange;
}
public void setMessage(String t) {
tooltip = t;
}
public String getMessage() {
return tooltip;
}
public class TooltipProvider implements ITooltip {
@Override
public String getMessage() {
return tooltip;
}
@Override
public int xPos() {
return _xPos;
}
@Override
public int yPos() {
return _yPos;
}
@Override
public int getHeight() {
return _height;
}
@Override
public int getWidth() {
return _width;
}
@Override
public boolean isVisible() {
return getVisible();
}
}
}
@@ -1,316 +0,0 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.util.NameConst;
import appeng.client.gui.widgets.ITooltip;
public class GuiFCImgButton extends GuiButton implements ITooltip {
private static final Pattern COMPILE = Pattern.compile("%s");
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
private static Map<EnumPair, ButtonAppearance> appearances;
private final String buttonSetting;
private boolean halfSize = false;
private boolean threeFourths = false;
private String fillVar;
private String currentValue;
private final boolean background;
private static final String prefix = NameConst.TT_KEY;
public GuiFCImgButton(final int x, final int y, final String idx, final String val) {
this(x, y, idx, val, true);
}
public GuiFCImgButton(final int x, final int y, final String idx, final String val, boolean background) {
super(0, 0, 16, "");
this.background = background;
this.buttonSetting = idx;
this.currentValue = val;
this.xPosition = x;
this.yPosition = y;
this.width = 16;
this.height = 16;
if (appearances == null) {
appearances = new HashMap<>();
this.registerApp(0, "NOT_COMBINE", "DONT_COMBINE", "not_combine");
this.registerApp(1, "FORCE_COMBINE", "DO_COMBINE", "combine");
this.registerApp(2, "FORCE_PRIO", "DO_PRIO", "prio");
this.registerApp(3, "NOT_PRIO", "DONT_PRIO", "not_prio");
this.registerApp(4, "SUBMIT", "SUBMIT", "submit");
this.registerApp(5, "EDIT", "YES", "edit");
this.registerApp(6, "DISABLE", "DISABLE", "disable");
this.registerApp(7, "ENABLE", "ENABLE", "enable");
this.registerApp(10, "FLUID_TEM", "YES", "fluid_terminal_w");
this.registerApp(11, "CRAFT_TEM", "YES", "craft_terminal_w");
this.registerApp(12, "PATTERN_TEM", "YES", "pattern_terminal_w");
this.registerApp(13, "ESSENTIA_TEM", "YES", "essentia_terminal_w");
this.registerApp(14, "INTERFACE_TEM", "YES", "interface_terminal_w");
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
this.registerApp(20, "LEVEL_TEM", "YES", "level_terminal_w");
this.registerApp(21, "SWITCH", "ON", "edit");
this.registerApp(22, "SWITCH", "OFF", "view");
this.registerApp(21, "SWITCH", "ENABLE", "enable");
this.registerApp(22, "SWITCH", "DISABLE", "disable");
this.registerApp(23, "CONFIG", "YES", "open_configuration");
this.registerApp(24, "HIGHLIGHT", "YES", "block_highlight");
this.registerApp(30, "MAGNET_CARD", "INV", "magnet_card.inv");
this.registerApp(30, "MAGNET_CARD", "ME", "magnet_card.me");
this.registerApp(30, "MAGNET_CARD", "FILTER", "magnet_card.filter");
this.registerApp(31, "MAGNET_CARD", "OFF", "magnet_card.off");
this.registerApp(32, "ENABLE_12x", "ENABLE", "enable");
this.registerApp(33, "DISABLE_12x", "DISABLE", "disable");
this.registerApp(34, "RESTOCK", "ENABLE", "restock.on");
this.registerApp(35, "RESTOCK", "DISABLE", "restock.off");
}
}
private void registerApp(final int iconIndex, final String setting, final String val, final String title) {
final ButtonAppearance a = new ButtonAppearance();
a.displayName = StatCollector.translateToLocal(prefix + title);
if (StatCollector.translateToLocal(prefix + title + ".hint").equals(prefix + title + ".hint")) {
a.displayValue = null;
} else {
a.displayValue = StatCollector.translateToLocal(prefix + title + ".hint");
}
a.index = iconIndex % 10;
a.page = iconIndex / 10;
appearances.put(new EnumPair(setting, val), a);
}
public void setVisibility(final boolean vis) {
this.visible = vis;
this.enabled = vis;
}
private int getIconIndex() {
if (this.buttonSetting != null && this.currentValue != null) {
final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue));
if (app == null) {
return 8;
}
return app.index;
}
return 8;
}
private int getIconPage() {
if (this.buttonSetting != null && this.currentValue != null) {
final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue));
if (app == null) {
return 0;
}
return app.page;
}
return 0;
}
public String getSetting() {
return this.buttonSetting;
}
public String getCurrentValue() {
return this.currentValue;
}
public boolean getMouseIn() {
return this.field_146123_n;
}
public void set(final String e) {
if (!this.currentValue.equals(e)) {
this.currentValue = e;
}
}
public boolean isHalfSize() {
return this.halfSize;
}
public void setHalfSize(final boolean halfSize) {
this.halfSize = halfSize;
}
public boolean isThreeFourths() {
return threeFourths;
}
public void setThreeFourths(boolean threeFourths) {
this.threeFourths = threeFourths;
}
public String getFillVar() {
return this.fillVar;
}
public void setFillVar(final String fillVar) {
this.fillVar = fillVar;
}
@Override
public int xPos() {
return this.xPosition;
}
@Override
public int yPos() {
return this.yPosition;
}
@Override
public int getWidth() {
return this.halfSize ? 8 : threeFourths ? 12 : 16;
}
@Override
public int getHeight() {
return this.halfSize ? 8 : threeFourths ? 12 : 16;
}
@Override
public boolean isVisible() {
return this.visible;
}
@Override
public String getMessage() {
String displayName = null;
String displayValue = null;
if (this.buttonSetting != null && this.currentValue != null) {
final ButtonAppearance buttonAppearance = appearances
.get(new EnumPair(this.buttonSetting, this.currentValue));
if (buttonAppearance == null) {
return "No Such Message";
}
displayName = buttonAppearance.displayName;
displayValue = buttonAppearance.displayValue;
}
if (displayName != null) {
String name = StatCollector.translateToLocal(displayName);
if (name == null || name.isEmpty()) {
name = displayName;
}
if (displayValue != null) {
String value = StatCollector.translateToLocal(displayValue);
if (this.fillVar != null) {
value = COMPILE.matcher(value).replaceFirst(this.fillVar);
}
value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n");
final StringBuilder sb = new StringBuilder(value);
int i = sb.lastIndexOf("\n");
if (i <= 0) {
i = 0;
}
while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) {
sb.replace(i, i + 1, "\n");
}
return name + '\n' + sb;
}
return name;
}
return null;
}
@Override
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3) {
if (this.visible) {
final int iconIndex = this.getIconIndex();
final int iconPage = this.getIconPage();
this.width = getWidth();
this.height = getHeight();
float scaleFactor = halfSize ? 3 : threeFourths ? 4.5f : 6;
GL11.glPushMatrix();
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
GL11.glScalef(0.5f / 16 * scaleFactor, 0.5f / 16 * scaleFactor, 0.5f / 16 * scaleFactor);
if (this.enabled) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} else {
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states" + iconPage + ".png"));
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
final int uv_y = (int) Math.floor(iconIndex / 3.0);
final int uv_x = iconIndex - uv_y * 3;
if (this.background) {
this.drawTexturedModalRect(
0,
0,
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
}
this.drawTexturedModalRect(
0,
0,
Math.round(uv_x * 16F * 16F / 3F),
Math.round(uv_y * 16F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
this.mouseDragged(par1Minecraft, par2, par3);
GL11.glPopMatrix();
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
private static final class EnumPair {
final String setting;
final String value;
EnumPair(final String a, final String b) {
this.setting = a;
this.value = b;
}
@Override
public int hashCode() {
return this.setting.hashCode() ^ this.value.hashCode();
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (this.getClass() != obj.getClass()) {
return false;
}
final EnumPair other = (EnumPair) obj;
return other.setting.equals(this.setting) && other.value.equals(this.value);
}
}
private static class ButtonAppearance {
public int index;
public int page;
public String displayName;
public String displayValue;
}
}
@@ -1,37 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidAutoFiller;
import com.glodblock.github.common.tile.TileFluidAutoFiller;
import com.glodblock.github.util.NameConst;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
public class GuiFluidAutoFiller extends AEBaseGui {
protected EntityPlayer player;
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_auto_filler.png");
public GuiFluidAutoFiller(InventoryPlayer ipl, TileFluidAutoFiller tile) {
super(new ContainerFluidAutoFiller(ipl, tile));
this.player = ipl.player;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_AUTO_FILLER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
}
}
@@ -1,98 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.GuiSub;
import appeng.core.localization.GuiText;
public class GuiFluidInterface extends GuiSub {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/interface_fluid.png");
private static final int TANK_X = 35, TANK_X_OFF = 18, TANK_Y = 53;
private static final int TANK_WIDTH = 16, TANK_HEIGHT = 68;
private final ContainerFluidInterface cont;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
public GuiFluidInterface(InventoryPlayer ipl, IDualHost tile) {
super(new ContainerFluidInterface(ipl, tile));
this.cont = (ContainerFluidInterface) inventorySlots;
this.ySize = 231;
this.addMouseRegin();
}
private void addMouseRegin() {
for (int i = 0; i < 6; i++) {
mouseRegions.addRegion(
TANK_X + TANK_X_OFF * i,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_INTERFACE)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 6; i++) {
if (!isPart()) {
fontRendererObj.drawString(dirName(i), TANK_X + i * TANK_X_OFF + 5, 22, 0x404040);
}
RenderUtil.renderFluidIntoGui(
this,
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
fluidInv.getFluidInSlot(i),
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public String dirName(int face) {
return I18n.format(NameConst.GUI_FLUID_INTERFACE + "." + face);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
public void update(int id, IAEFluidStack stack) {
if (id >= 100) {
cont.getTile().setConfig(id - 100, stack);
} else {
cont.getTile().setFluidInv(id, stack);
}
}
private boolean isPart() {
return this.cont.getTile() instanceof PartFluidInterface;
}
}
@@ -1,137 +0,0 @@
package com.glodblock.github.client.gui;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.slot.ISlotFluid;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.util.NameConst;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
public class GuiFluidPatternEncoder extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_pattern_encoder.png");
private final ContainerFluidPatternEncoder cont;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) {
super(new ContainerFluidPatternEncoder(ipl, tile));
this.cont = (ContainerFluidPatternEncoder) inventorySlots;
mouseRegions.addRegion(141, 38, 10, 10, new MouseRegionManager.Handler() {
@Override
public List<String> getTooltip() {
return Collections.singletonList(I18n.format(NameConst.TT_ENCODE_PATTERN));
}
@Override
public boolean onClick(int button) {
if (button == 0) {
if (cont.canEncodePattern()) {
// FluidCraft.proxy.netHandler.sendToServer(new CPacketEncodePattern());
}
return true;
}
return false;
}
});
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) {
if (mouseRegions.onClick(xCoord, yCoord, btn)) {
super.mouseClicked(xCoord, yCoord, btn);
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_PATTERN_ENCODER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
mouseRegions.render(mouseX, mouseY);
}
@Override
public void func_146977_a(final Slot s) {
this.drawSlot0(s);
}
public void drawSlot0(Slot slot) {
if (slot instanceof ISlotFluid) {
IAEItemStack stack = ((ISlotFluid) slot).getAeStack();
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return;
IAEItemStack fake = stack.copy();
if (fake.getItemStack().getItem() instanceof ItemFluidPacket) {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
}
aeRenderItem.setAeStack(fake);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
} else {
super.func_146977_a(slot);
}
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void renderToolTip(ItemStack stack, int x, int y) {
List list;
if (stack.getItem() instanceof ItemFluidPacket) {
FluidStack fluid = ItemFluidPacket.getFluidStack(stack);
if (fluid != null) {
list = Arrays.asList(
fluid.getLocalizedName(),
String.format(EnumChatFormatting.GRAY + "%,d mB", fluid.amount));
} else {
list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
}
} else {
list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
}
for (int k = 0; k < list.size(); ++k) {
if (k == 0) {
list.set(k, stack.getRarity().rarityColor + (String) list.get(k));
} else {
list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
}
}
FontRenderer font = stack.getItem().getFontRenderer(stack);
drawHoveringText(list, x, y, (font == null ? fontRendererObj : font));
}
}
@@ -1,92 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerIngredientBuffer;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.gui.ButtonMouseHandler;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
public class GuiIngredientBuffer extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/ingredient_buffer.png");
private static final int TANK_X = 47, TANK_X_OFF = 22, TANK_Y = 18;
private static final int TANK_WIDTH = 16, TANK_HEIGHT = 74;
private final ContainerIngredientBuffer cont;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
public GuiIngredientBuffer(InventoryPlayer ipl, TileIngredientBuffer tile) {
super(new ContainerIngredientBuffer(ipl, tile));
this.cont = (ContainerIngredientBuffer) inventorySlots;
this.ySize = 222;
for (int i = 0; i < 4; i++) {
mouseRegions.addRegion(
TANK_X + TANK_X_OFF * i,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
mouseRegions.addRegion(
TANK_X + 10 + 22 * i,
TANK_Y + TANK_HEIGHT + 2,
7,
7,
ButtonMouseHandler.dumpTank(cont, i));
}
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) {
if (mouseRegions.onClick(xCoord, yCoord, btn)) {
super.mouseClicked(xCoord, yCoord, btn);
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_INGREDIENT_BUFFER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 4; i++) {
RenderUtil.renderFluidIntoGui(
this,
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
fluidInv.getFluidInSlot(i),
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public void update(int slot, IAEFluidStack aeFluidStack) {
cont.getTile().getInternalFluid().setFluidInSlot(slot, aeFluidStack);
}
}
@@ -1,93 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerLargeIngredientBuffer;
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.gui.ButtonMouseHandler;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.RenderUtil;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
public class GuiLargeIngredientBuffer extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/large_ingredient_buffer.png");
private static final int TANK_X = 13, TANK_X_OFF = 22, TANK_Y = 18;
private static final int TANK_WIDTH = 16, TANK_HEIGHT = 37;
private final ContainerLargeIngredientBuffer cont;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
public GuiLargeIngredientBuffer(InventoryPlayer ipl, TileLargeIngredientBuffer tile) {
super(new ContainerLargeIngredientBuffer(ipl, tile));
this.cont = (ContainerLargeIngredientBuffer) inventorySlots;
this.ySize = 222;
for (int i = 0; i < 7; i++) {
mouseRegions.addRegion(
TANK_X + TANK_X_OFF * i,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
mouseRegions.addRegion(
TANK_X + 10 + 22 * i,
TANK_Y + TANK_HEIGHT + 2,
7,
7,
ButtonMouseHandler.dumpTank(cont, i));
}
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) {
if (mouseRegions.onClick(xCoord, yCoord, btn)) {
super.mouseClicked(xCoord, yCoord, btn);
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj
.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_LARGE_INGREDIENT_BUFFER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 7; i++) {
RenderUtil.renderFluidIntoGui(
this,
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
fluidInv.getFluidInSlot(i),
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public void update(int slot, IAEFluidStack aeFluidStack) {
cont.getTile().getInternalFluid().setFluidInSlot(slot, aeFluidStack);
}
}
@@ -1,48 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.parts.ILevelEmitter;
import appeng.client.gui.IGuiSub;
import appeng.client.gui.implementations.GuiLevelEmitter;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.interfaces.IContainerSubGui;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
public class GuiLevelEmitterProxy extends GuiLevelEmitter implements IGuiSub {
protected final IContainerSubGui container;
protected GuiTabButton originalGuiBtn;;
public GuiLevelEmitterProxy(final InventoryPlayer inventoryPlayer, final ILevelEmitter te) {
super(inventoryPlayer, te);
this.container = (IContainerSubGui) inventorySlots;
this.container.setGuiLink(this);
}
@Override
public void initGui() {
super.initGui();
if (container.getPrimaryGuiIcon() != null) initPrimaryGuiButton();
}
public void initPrimaryGuiButton() {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + this.xSize - 57,
this.guiTop,
container.getPrimaryGuiIcon(),
container.getPrimaryGuiIcon().getDisplayName(),
itemRender));
}
@Override
protected void actionPerformed(GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.originalGuiBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
}
}
}
@@ -1,455 +0,0 @@
package com.glodblock.github.client.gui;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.network.CPacketLevelMaintainer;
import com.glodblock.github.network.CPacketLevelMaintainer.Action;
import com.glodblock.github.util.FCGuiColors;
import com.glodblock.github.util.NameConst;
import appeng.api.features.LevelState;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IAEStackType;
import appeng.client.gui.GuiSub;
import appeng.client.gui.slots.VirtualMEPhantomSlot;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import cofh.core.render.CoFHFontRenderer;
public class GuiLevelMaintainer extends GuiSub {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/level_maintainer.png");
private final ContainerLevelMaintainer cont;
private final Component[] component = new Component[TileLevelMaintainer.REQ_COUNT];
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
private Widget focusedWidget;
private final CoFHFontRenderer render;
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(new ContainerLevelMaintainer(ipl, tile));
this.cont = (ContainerLevelMaintainer) inventorySlots;
this.xSize = 195;
this.ySize = 214;
this.render = new CoFHFontRenderer(
Minecraft.getMinecraft().gameSettings,
TEX_BG,
Minecraft.getMinecraft().getTextureManager(),
true);
}
@Override
public void initGui() {
super.initGui();
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
VirtualMEPhantomSlot slot = new VirtualMEPhantomSlot(
27,
20 + i * 19,
this.cont.getTile().getAEStackInventory(),
i,
GuiLevelMaintainer::acceptType);
slot.setShowAmount(true);
slot.setShowAmountAlways(true);
this.registerVirtualSlots(slot);
}
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
component[i] = new Component(
new Widget(
new FCGuiTextField(this.fontRendererObj, guiLeft + 46, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE,
i,
Action.Quantity),
new Widget(
new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE,
i,
Action.Batch),
new GuiFCImgButton(guiLeft + 105 + 47, guiTop + 17 + 19 * i, "SUBMIT", "SUBMIT", false),
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "ENABLE", "ENABLE", false),
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "DISABLE", "DISABLE", false),
new FCGuiLineField(fontRendererObj, guiLeft + 47, guiTop + 33 + 19 * i, 120),
this.buttonList,
this.cont);
}
}
@Override
public void initPrimaryGuiButton() {
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 151,
this.guiTop - 4,
this.cont.getPrimaryGuiIcon(),
this.cont.getPrimaryGuiIcon().getDisplayName(),
itemRender);
this.originalGuiBtn.setHideEdge(13);
this.buttonList.add(originalGuiBtn);
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
for (Component com : this.component) {
com.getQty().textField.handleTooltip(mouseX, mouseY, this);
com.getBatch().textField.handleTooltip(mouseX, mouseY, this);
com.getLine().handleTooltip(mouseX, mouseY, this);
}
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
this.component[i].draw();
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_LEVEL_MAINTAINER)), 8, 6, 0x404040);
mouseRegions.render(mouseX, mouseY);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
if (btn == 0) {
if (focusedWidget != null) {
focusedWidget.textField.setFocused(false);
}
for (Component com : this.component) {
Widget textField = com.isMouseIn(xCoord, yCoord);
if (textField != null) {
textField.textField.setFocused(true);
this.focusedWidget = textField;
super.mouseClicked(xCoord, yCoord, btn);
return;
}
}
this.focusedWidget = null;
}
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void keyTyped(final char character, final int key) {
if (this.focusedWidget == null) {
super.keyTyped(character, key);
return;
}
if (!this.checkHotbarKeys(key)) {
if (!((character == ' ') && this.focusedWidget.textField.getText().isEmpty())) {
this.focusedWidget.textField.textboxKeyTyped(character, key);
}
super.keyTyped(character, key);
this.focusedWidget.validate();
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.component[this.focusedWidget.componentIndex].submit();
this.focusedWidget.textField.setFocused(false);
this.focusedWidget = null;
}
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
for (Component com : this.component) {
if (com.sendToServer(btn)) {
return;
}
}
super.actionPerformed(btn);
}
public void updateComponent(int index, long quantity, long batchSize, boolean isEnabled, LevelState state) {
if (index < 0 || index >= TileLevelMaintainer.REQ_COUNT) return;
component[index].setEnable(isEnabled);
component[index].setState(state);
component[index].getQty().textField.setText(String.valueOf(quantity));
component[index].getBatch().textField.setText(String.valueOf(batchSize));
component[index].getQty().validate();
component[index].getBatch().validate();
}
public void updateComponent(int index, LevelState state) {
if (index < 0 || index >= TileLevelMaintainer.REQ_COUNT) return;
component[index].setState(state);
}
private static boolean acceptType(VirtualMEPhantomSlot slot, IAEStackType<?> type, int mouseButton) {
return true;
}
private class Component {
public boolean isEnable = false;
private final Widget qty;
private final Widget batch;
private final GuiFCImgButton disable;
private final GuiFCImgButton enable;
private final GuiFCImgButton submit;
private final FCGuiLineField line;
private LevelState state;
private final ContainerLevelMaintainer container;
public Component(Widget qtyInput, Widget batchInput, GuiFCImgButton submitBtn, GuiFCImgButton enableBtn,
GuiFCImgButton disableBtn, FCGuiLineField line, List<GuiButton> buttonList,
ContainerLevelMaintainer container) {
this.qty = qtyInput;
this.batch = batchInput;
this.enable = enableBtn;
this.disable = disableBtn;
this.submit = submitBtn;
this.line = line;
this.state = LevelState.None;
this.container = container;
buttonList.add(this.submit);
buttonList.add(this.enable);
buttonList.add(this.disable);
}
public int getIndex() {
return this.qty.componentIndex;
}
public void setEnable(boolean enable) {
this.isEnable = enable;
}
public IAEStack<?> getStack() {
return this.container.getTile().getAEStackInventory().getAEStackInSlot(this.getIndex());
}
private void send(Widget widget) {
if (this.getStack() != null && widget.getAmount() != null) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelMaintainer(widget.action, widget.componentIndex, widget.getAmount()));
}
}
public void submit() {
this.sendToServer(this.submit);
}
protected boolean sendToServer(GuiButton btn) {
boolean didSomething = false;
if (this.submit == btn) {
final Widget qty = this.getQty();
final Widget batch = this.getBatch();
qty.validate();
batch.validate();
if (qty.getAmount() != null) {
this.send(qty);
qty.textField.setText(String.valueOf(qty.getAmount()));
}
if (batch.getAmount() != null) {
this.send(batch);
batch.textField.setText(String.valueOf(batch.getAmount()));
}
didSomething = true;
} else if (this.enable == btn) {
this.setEnable(false);
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Enable, this.getIndex()));
didSomething = true;
} else if (this.disable == btn) {
if (this.getStack() != null) {
this.setEnable(true);
FluidCraft.proxy.netHandler
.sendToServer(new CPacketLevelMaintainer(Action.Disable, this.getIndex()));
didSomething = true;
}
}
return didSomething;
}
public Widget isMouseIn(final int xCoord, final int yCoord) {
if (this.qty.textField.isMouseIn(xCoord, yCoord)) return this.getQty();
if (this.batch.textField.isMouseIn(xCoord, yCoord)) return this.getBatch();
return null;
}
public Widget getQty() {
return this.qty;
}
public Widget getBatch() {
return this.batch;
}
public FCGuiLineField getLine() {
return this.line;
}
public void draw() {
this.qty.draw();
this.batch.draw();
ArrayList<String> message = new ArrayList<>();
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_TITLE) + "\n");
switch (this.state) {
case Idle -> {
this.line.setColor(FCGuiColors.StateIdle.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
}
case Craft -> {
this.line.setColor(FCGuiColors.StateCraft.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
}
case Export -> {
this.line.setColor(FCGuiColors.StateExport.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
}
case Error -> {
this.line.setColor(FCGuiColors.StateError.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
}
case NotFound -> {
this.line.setColor(FCGuiColors.StateError.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NOT_FOUND));
}
case CantCraft -> {
this.line.setColor(FCGuiColors.StateError.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CANT_CRAFT));
}
default -> {
this.line.setColor(FCGuiColors.StateNone.getColor());
message.add(
NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NONE));
}
}
message.add("");
if (isShiftKeyDown()) {
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_ERROR_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NOT_FOUND));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NOT_FOUND_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CANT_CRAFT));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CANT_CRAFT_DESC));
} else {
message.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
this.line.setMessage(
render.wrapFormattedStringToWidth(String.join("\n", message), (int) Math.floor(xSize * 0.8)));
this.line.drawTextBox();
if (this.isEnable) {
this.enable.visible = true;
this.disable.visible = false;
} else {
this.enable.visible = false;
this.disable.visible = true;
}
}
public void setState(LevelState state) {
this.state = state;
}
}
private class Widget {
public final int componentIndex;
public final Action action;
public final FCGuiTextField textField;
private final String tooltip;
private Long amount;
public Widget(FCGuiTextField textField, String tooltip, int componentIndex, Action action) {
this.textField = textField;
this.textField.setEnableBackgroundDrawing(false);
this.textField.setText("0");
this.textField.setMaxStringLength(16); // this length is enough to be useful
this.componentIndex = componentIndex;
this.action = action;
this.tooltip = tooltip;
}
public void draw() {
String current = amount != null
? StatCollector.translateToLocal(NameConst.TT_LEVEL_MAINTAINER_CURRENT) + " "
+ NumberFormat.getNumberInstance().format(amount)
+ "\n"
: "";
if (isShiftKeyDown()) {
this.setTooltip(
render.wrapFormattedStringToWidth(
StatCollector.translateToLocal(this.tooltip) + "\n"
+ current
+ "\n"
+ StatCollector.translateToLocal(this.tooltip + ".hint"),
xSize / 2));
} else {
this.setTooltip(
render.wrapFormattedStringToWidth(
NameConst.i18n(this.tooltip, "\n", false) + "\n"
+ current
+ NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE),
(int) Math.floor(xSize * 0.8)));
}
this.textField.drawTextBox();
}
public void setTooltip(String message) {
this.textField.setMessage(message);
}
public void validate() {
final double result = Calculator.conversion(this.textField.getText());
if (Double.isNaN(result) || result < 0) {
this.amount = null;
this.textField.setTextColor(0xFF0000);
} else {
this.amount = (long) ArithHelper.round(result, 0);
this.textField.setTextColor(0xFFFFFF);
}
IAEStack<?> stack = component[this.componentIndex].getStack();
if (stack != null) {
Long amount = component[this.componentIndex].getQty().getAmount();
stack.setStackSize(amount != null ? amount : 0);
}
}
@Nullable
public Long getAmount() {
return this.amount;
}
}
}
File diff suppressed because it is too large. Load diff
@@ -1,24 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.client.gui.container.ContainerLevelWireless;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import appeng.container.slot.AppEngSlot;
public class GuiLevelWireless extends GuiLevelTerminal {
public GuiLevelWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, new ContainerLevelWireless(inventoryPlayer, te));
}
@Override
protected void repositionSlots() {
for (final Object obj : this.inventorySlots.inventorySlots) {
if (obj instanceof final AppEngSlot slot) {
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 4;
}
}
}
}
@@ -1,199 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerMagnetFilter;
import com.glodblock.github.inventory.item.WirelessMagnet;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.NameConst;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.GuiSub;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.MEGuiTextField;
public class GuiMagnetFilter extends GuiSub {
protected FCGuiBaseButton listModeBtn;
protected ContainerMagnetFilter cont;
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/magnet_filter.png");
protected Component[] components = new Component[4];
protected MEGuiTextField oreDict;
protected GuiImgButton clearBtn;
public GuiMagnetFilter(InventoryPlayer ip, ITerminalHost container) {
super(new ContainerMagnetFilter(ip, container));
this.xSize = 176;
this.ySize = 214;
this.cont = (ContainerMagnetFilter) this.inventorySlots;
oreDict = new MEGuiTextField(149, 12, NameConst.i18n(NameConst.TT_MAGNET_CARD_OREDICT));
}
private class Component {
private final GuiFCImgButton enable;
private final GuiFCImgButton disable;
private final CPacketFluidPatternTermBtns.Command action;
private boolean var;
public Component(int x, int y, boolean var, CPacketFluidPatternTermBtns.Command action) {
this.enable = new GuiFCImgButton(x, y, "ENABLE_12x", "ENABLE", false);
this.disable = new GuiFCImgButton(x, y, "DISABLE_12x", "DISABLE", false);
this.var = var;
this.action = action;
enable.setThreeFourths(true);
disable.setThreeFourths(true);
buttonList.add(this.enable);
buttonList.add(this.disable);
}
public boolean sameBtn(GuiButton btn) {
return btn == this.enable || btn == this.disable;
}
public boolean getVar() {
return this.var;
}
public void setVar(boolean var) {
this.var = var;
}
public void send() {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(this.action, !this.getVar()));
}
public void draw() {
if (var) {
this.enable.visible = true;
this.disable.visible = false;
} else {
this.enable.visible = false;
this.disable.visible = true;
}
}
}
@Override
public void initGui() {
super.initGui();
this.buttonList.clear();
this.buttonList.add(
this.listModeBtn = new FCGuiBaseButton(
0,
this.guiLeft + 86,
this.guiTop + 4,
64,
14,
NameConst.i18n(
this.cont.listMode == WirelessMagnet.ListMode.WhiteList
? NameConst.GUI_MAGNET_CARD_WhiteList
: NameConst.GUI_MAGNET_CARD_BlackList)));
this.components[0] = new Component(
this.guiLeft + 157,
this.guiTop + 18,
this.cont.nbt,
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_NBT);
this.components[1] = new Component(
this.guiLeft + 157,
this.guiTop + 31,
this.cont.meta,
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_META);
this.components[2] = new Component(
this.guiLeft + 157,
this.guiTop + 44,
this.cont.ore,
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_ORE);
this.components[3] = new Component(
this.guiLeft + 157,
this.guiTop + 112,
this.cont.oreDict,
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_OREDICT_STATE);
oreDict.x = this.guiLeft + 7;
oreDict.y = this.guiTop + 112;
oreDict.setText(this.cont.oreDictFilter);
this.clearBtn = new GuiImgButton(this.guiLeft + 7, this.guiTop + 48, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
this.buttonList.add(this.clearBtn);
}
@Override
public void drawScreen(int mouseX, int mouseY, float btn) {
handleTooltip(mouseX, mouseY, oreDict);
super.drawScreen(mouseX, mouseY, btn);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRendererObj.drawString(NameConst.i18n(NameConst.GUI_MAGNET_CARD), 8, 6, 0x404040);
this.fontRendererObj.drawString(NameConst.i18n(NameConst.GUI_MAGNET_CARD_NBT), 61, 22, 0x404040);
this.fontRendererObj.drawString(NameConst.i18n(NameConst.GUI_MAGNET_CARD_META), 61, 34, 0x404040);
this.fontRendererObj.drawString(NameConst.i18n(NameConst.GUI_MAGNET_CARD_ORE), 61, 46, 0x404040);
this.components[0].setVar(this.cont.nbt);
this.components[1].setVar(this.cont.meta);
this.components[2].setVar(this.cont.ore);
this.components[3].setVar(this.cont.oreDict);
for (Component c : components) {
c.draw();
}
this.listModeBtn.displayString = NameConst.i18n(
this.cont.listMode == WirelessMagnet.ListMode.WhiteList ? NameConst.GUI_MAGNET_CARD_WhiteList
: NameConst.GUI_MAGNET_CARD_BlackList);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, ySize);
oreDict.drawTextBox();
}
@Override
protected void keyTyped(char typedChar, int keyCode) {
if (oreDict.isFocused() && (Keyboard.KEY_NUMPADENTER == keyCode || Keyboard.KEY_RETURN == keyCode)) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_OREDICT_FILTER,
oreDict.getText()));
}
if (!oreDict.textboxKeyTyped(typedChar, keyCode)) super.keyTyped(typedChar, keyCode);
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) {
oreDict.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void actionPerformed(GuiButton btn) {
for (Component c : components) {
if (c.sameBtn(btn)) {
c.send();
break;
}
}
if (btn == this.listModeBtn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_MODE,
this.cont.listMode != WirelessMagnet.ListMode.WhiteList));
} else if (btn == this.clearBtn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(CPacketFluidPatternTermBtns.Command.MAGNET_FILTER_CLEAR, 1));
}
super.actionPerformed(btn);
}
}
@@ -1,35 +0,0 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerOCPatternEditor;
import com.glodblock.github.common.tile.TileOCPatternEditor;
import com.glodblock.github.util.NameConst;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
public class GuiOCPatternEditor extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/oc_pattern_editor.png");
public GuiOCPatternEditor(InventoryPlayer ipl, TileOCPatternEditor tile) {
super(new ContainerOCPatternEditor(ipl, tile));
this.ySize = 186;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_OC_PATTERN_EDITOR)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
}
}
@@ -1,121 +0,0 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerSuperStockReplenisher;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileSuperStockReplenisher;
import appeng.api.storage.StorageName;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.client.gui.AEBaseGui;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketVirtualSlot;
import appeng.util.item.AEItemStack;
public class GuiSuperStockReplenisher extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/superStockReplenisher.png");
private Map<Integer, IAEStack<?>> list = new HashMap<>();
public GuiSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) {
super(new ContainerSuperStockReplenisher(ipl, tile));
this.ySize = 251;
this.xSize = 216;
}
@Override
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int mouseButton) {
if (mouseButton == 3) {
if (slot instanceof SlotFake) {
if (slot.getHasStack()) {
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) {
if (slot.equals(this.inventorySlots.inventorySlots.get(i))) {
NetworkHandler.instance
.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PATTERN_VALUE_AMOUNT));
NetworkHandler.instance
.sendToServer(new PacketVirtualSlot(StorageName.CRAFTING_INPUT, i, stack));
}
}
return;
}
}
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
public void func_146977_a(Slot s) {
if (s instanceof SlotFake) {
this.drawFillStatus(s);
}
super.func_146977_a(s);
}
private void drawFillStatus(Slot slotIn) {
int offsetX = slotIn.xDisplayPosition - 8;
int offsetY = slotIn.yDisplayPosition - 11;
ItemStack itemstack = slotIn.getStack();
int slotInt = slotIn.slotNumber;
if (itemstack != null) {
String s = "0%";
if (slotInt > 0 && slotInt < 10) {
IAEStack<?> aeStack = list.get(slotInt - 1);
if (aeStack != null)
s = (int) (((float) aeStack.getStackSize() / ItemFluidPacket.getFluidAmount(itemstack)) * 100)
+ "%";
} else if (slotInt > 9 && slotInt < 73) {
IAEStack<?> aeStack = list.get(slotInt + 90);
if (aeStack != null && itemstack.stackSize > 0) {
long i = aeStack.getStackSize();
s = (int) (((float) i / itemstack.stackSize) * 100) + "%";
}
}
float scale = 0.5f;
float shiftX = 2;
float shiftY = 1;
final float inverseScaleFactor = 1.0f / scale;
final int X = (int) (((float) offsetX - shiftX + 10.0f) * inverseScaleFactor);
final int Y = (int) (((float) offsetY - shiftY + 16.0f - 7.0f * scale) * inverseScaleFactor);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
GL11.glScaled(scale, scale, scale);
this.fontRendererObj.drawStringWithShadow(s, X, Y, 16777215);
GL11.glScaled(inverseScaleFactor, inverseScaleFactor, inverseScaleFactor);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
}
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture(TEX_BG);
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, ySize);
}
public void update(Map<Integer, IAEStack<?>> map) {
this.list = map;
}
}
@@ -1,8 +0,0 @@
package com.glodblock.github.client.gui;
public interface ITankDump {
boolean canDumpTank(int index);
void dumpTank(int index);
}
@@ -1,40 +0,0 @@
package com.glodblock.github.client.gui.base;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import appeng.client.gui.AEBaseGui;
public abstract class FCBaseMEGui extends AEBaseGui {
public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
super(container);
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
}
private boolean scheduleGuiResize;
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) {
super.mouseClicked(xCoord, yCoord, btn);
if (scheduleGuiResize) {
// in the GuiScreen class, the implementation of super.mouseClicked
// ends up looping on the button list and execute the action for any
// button below the mouse.
// Therefore, if we initGui() the terminal in the actionPerformed method below
// it will run the actionPerformed a second time for the new button
// that will end up being below the mouse (if any) after the initGui()
buttonList.clear();
initGui();
scheduleGuiResize = false;
}
}
protected final void scheduleGuiResize() {
scheduleGuiResize = true;
}
}
@@ -1,64 +0,0 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
import com.glodblock.github.common.tile.TileFluidAutoFiller;
import com.glodblock.github.util.Util;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
public class ContainerFluidAutoFiller extends AEBaseContainer {
public static class FakeSlot extends SlotFake {
public FakeSlot(IInventory inv, int idx, int x, int y) {
super(inv, idx, x, y);
}
@Override
public void putStack(ItemStack is) {
MutablePair<Boolean, ItemStack> result = ContainerFluidAutoFiller.isItemValid(is);
if (result.left) {
if (super.getHasStack()) super.clearStack();
hasChange = true;
super.putStack(result.right);
}
}
}
private final TileFluidAutoFiller tile;
private static boolean hasChange;
public ContainerFluidAutoFiller(InventoryPlayer ipl, TileFluidAutoFiller tile) {
super(ipl, tile);
this.tile = tile;
addSlotToContainer(new FakeSlot(tile.getInventory(), 0, 80, 35));
bindPlayerInventory(ipl, 0, 84);
}
public static MutablePair<Boolean, ItemStack> isItemValid(ItemStack itemStack) {
boolean result = Util.FluidUtil.isFluidContainer(itemStack);
if (!result) return new MutablePair<>(false, null);
ItemStack tank = itemStack.copy();
tank.stackSize = 1;
if (Util.FluidUtil.isFilled(tank)) {
return new MutablePair<>(true, Util.FluidUtil.clearFluid(tank));
} else {
return new MutablePair<>(true, tank);
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (hasChange) {
tile.updatePattern();
hasChange = false;
}
}
}
@@ -1,64 +0,0 @@
package com.glodblock.github.client.gui.container;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.ContainerSubGui;
import appeng.container.slot.IOptionalSlotHost;
import appeng.util.item.AEFluidStack;
public class ContainerFluidInterface extends ContainerSubGui implements IOptionalSlotHost {
private final IDualHost tile;
public ContainerFluidInterface(InventoryPlayer ipl, IDualHost tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getConfig();
final int y = 35;
final int x = 35;
for (int i = 0; i < 6; i++) {
addSlotToContainer(
new OptionalFluidSlotFakeTypeOnly(inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
}
bindPlayerInventory(ipl, 0, 149);
}
public IDualHost getTile() {
return tile;
}
@Override
public boolean isSlotEnabled(int idx) {
return idx >= 0 && idx < 6;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < tile.getConfig().getSizeInventory(); i++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(tile.getConfig().getStackInSlot(i))));
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
}
@@ -1,67 +0,0 @@
package com.glodblock.github.client.gui.container;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.ITankDump;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.network.SPacketFluidUpdate;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
public class ContainerIngredientBuffer extends AEBaseContainer implements ITankDump {
private final TileIngredientBuffer tile;
public ContainerIngredientBuffer(InventoryPlayer ipl, TileIngredientBuffer tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getInternalInventory();
addSlots(inv);
bindPlayerInventory(ipl, 0, 140);
}
protected void addSlots(IInventory inv) {
for (int i = 0; i < 9; i++) {
addSlotToContainer(new SlotNormal(inv, i, 8 + 18 * i, 108));
}
}
public TileIngredientBuffer getTile() {
return tile;
}
@Override
public boolean canDumpTank(int index) {
return tile.getInternalFluid().getFluidInSlot(index) != null;
}
@Override
public void dumpTank(int index) {
if (index >= 0 && index < tile.getInternalFluid().getSlots()) {
tile.getInternalFluid().setFluidInSlot(index, null);
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
}
@@ -1,23 +0,0 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
import appeng.container.slot.SlotNormal;
public class ContainerLargeIngredientBuffer extends ContainerIngredientBuffer {
public ContainerLargeIngredientBuffer(InventoryPlayer ipl, TileLargeIngredientBuffer tile) {
super(ipl, tile);
}
protected void addSlots(IInventory inv) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new SlotNormal(inv, i * 9 + j, 8 + 18 * j, 72 + 18 * i));
}
}
}
}
@@ -1,134 +0,0 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.network.SPacketLevelMaintainerGuiUpdate;
import appeng.api.config.SecurityPermissions;
import appeng.api.storage.StorageName;
import appeng.api.storage.data.IAEStack;
import appeng.container.ContainerSubGui;
import appeng.container.interfaces.IVirtualSlotHolder;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketVirtualSlot;
import appeng.helpers.InventoryAction;
import appeng.tile.inventory.IAEStackInventory;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class ContainerLevelMaintainer extends ContainerSubGui implements IVirtualSlotHolder {
private final TileLevelMaintainer tile;
private static final int UPDATE_INTERVAL = 20;
private boolean isFirstUpdate = true;
private int updateCount = UPDATE_INTERVAL;
public ContainerLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(ipl, tile);
this.tile = tile;
bindPlayerInventory(ipl, 0, 130);
}
public TileLevelMaintainer getTile() {
return tile;
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
if (getSlot(slotId) instanceof SlotFluidConvertingFake slot) {
final ItemStack stack = player.inventory.getItemStack();
switch (action) {
case PICKUP_OR_SET_DOWN, PLACE_SINGLE, SPLIT_OR_PLACE_SINGLE -> {
if (stack == null) {
slot.putStack(null);
} else {
slot.putConvertedStack(stack);
}
}
default -> {}
}
} else {
super.doAction(player, action, slotId, id);
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int idx) {
if (Platform.isClient()) {
return null;
}
ItemStack clickedStack = this.inventorySlots.get(idx).getStack();
if (clickedStack != null) {
IAEStackInventory inventory = this.getTile().getAEStackInventory();
for (int i = 0; i < inventory.getSizeInventory(); i++) {
IAEStack<?> stack = inventory.getAEStackInSlot(i);
if (stack == null) {
tile.updateStack(i, AEItemStack.create(clickedStack));
break;
}
}
}
this.detectAndSendChanges();
return null;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (Platform.isClient()) {
return;
}
this.verifyPermissions(SecurityPermissions.BUILD, false);
if (this.updateCount++ >= UPDATE_INTERVAL) {
this.updateGui();
}
}
public void updateGui() {
if (this.isFirstUpdate) {
Int2ObjectMap<IAEStack<?>> list = new Int2ObjectOpenHashMap<>();
for (int i = 0; i < this.tile.requests.length; i++) {
TileLevelMaintainer.RequestInfo info = this.tile.requests[i];
list.put(i, info != null ? info.getAEStack() : null);
}
NetworkHandler.instance.sendTo(
new PacketVirtualSlot(StorageName.NONE, list),
(EntityPlayerMP) this.getInventoryPlayer().player);
}
FluidCraft.proxy.netHandler.sendTo(
new SPacketLevelMaintainerGuiUpdate(this.tile.requests, !this.isFirstUpdate),
(EntityPlayerMP) this.getInventoryPlayer().player);
this.isFirstUpdate = false;
this.updateCount = 0;
}
@Override
public void receiveSlotStacks(StorageName invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
for (var entry : slotStacks.int2ObjectEntrySet()) {
this.tile.updateStack(entry.getIntKey(), entry.getValue());
}
if (!this.tile.getWorldObj().isRemote) {
for (var player : this.crafters) {
NetworkHandler.instance
.sendTo(new PacketVirtualSlot(StorageName.NONE, slotStacks), (EntityPlayerMP) player);
FluidCraft.proxy.netHandler.sendTo(
new SPacketLevelMaintainerGuiUpdate(this.tile.requests, false),
(EntityPlayerMP) player);
}
}
}
}
@@ -1,255 +0,0 @@
package com.glodblock.github.client.gui.container;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.common.util.ForgeDirection;
import org.jetbrains.annotations.Nullable;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
import com.glodblock.github.util.FluidPrimaryGui;
import com.glodblock.github.util.LevelTerminalRegistry;
import appeng.api.features.ILevelViewable;
import appeng.api.features.LevelItemInfo;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.ITerminalHost;
import appeng.api.util.DimensionalCoord;
import appeng.container.ContainerOpenContext;
import appeng.container.PrimaryGui;
import appeng.util.Platform;
public class ContainerLevelTerminal extends FCBaseContainer {
/**
* this stuff is all server side
*/
private int nextId = 0;
private final Map<IGridHost, ContainerLevelTerminal.InvTracker> tracked = new HashMap<>();
private final Map<Long, ContainerLevelTerminal.InvTracker> trackedById = new HashMap<>();
private IGrid grid;
private SPacketLevelTerminalUpdate updatePacket;
private boolean isPacketDirty;
private boolean wasOff;
private int ticks = 0;
public ContainerLevelTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
if (Platform.isServer()) {
if (monitorable instanceof PartLevelTerminal terminal) {
grid = terminal.getActionableNode().getGrid();
} else if (monitorable instanceof IWirelessTerminal wirelessTerminal) {
grid = wirelessTerminal.getActionableNode().getGrid();
}
updatePacket = this.updateList();
if (updatePacket != null) {
this.isPacketDirty = true;
} else {
updatePacket = new SPacketLevelTerminalUpdate();
this.isPacketDirty = false;
}
}
this.bindPlayerInventory(ip, 14, 0);
}
@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
return;
}
super.detectAndSendChanges();
if (this.grid == null) {
return;
}
final IActionHost host = this.getActionHost();
if (!host.getActionableNode().isActive()) {
if (!wasOff) {
SPacketLevelTerminalUpdate update = new SPacketLevelTerminalUpdate();
update.addDisconnectEntry();
wasOff = true;
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
}
return;
}
wasOff = false;
if (isPacketDirty) {
FluidCraft.proxy.netHandler.sendTo(updatePacket, (EntityPlayerMP) this.getPlayerInv().player);
updatePacket = new SPacketLevelTerminalUpdate();
isPacketDirty = false;
} else if (++ticks % 20 == 0) {
ticks = 0;
SPacketLevelTerminalUpdate updateNew = this.updateList();
if (updateNew != null) {
FluidCraft.proxy.netHandler.sendTo(updateNew, (EntityPlayerMP) this.getPlayerInv().player);
}
}
}
@Nullable
private SPacketLevelTerminalUpdate updateList() {
SPacketLevelTerminalUpdate update = null;
var supported = LevelTerminalRegistry.instance().getSupportedClasses();
Set<IGridHost> visited = new HashSet<>();
for (Class<? extends ILevelViewable> clz : supported) {
boolean isAdopted = LevelTerminalRegistry.instance().isAdopted(clz);
Class<? extends IGridHost> machineClass = isAdopted ? LevelTerminalRegistry.instance().getAdopted(clz)
: clz;
for (IGridNode gridNode : grid.getMachines(machineClass)) {
final IGridHost gridHost = gridNode.getMachine();
final ILevelViewable machine = isAdopted
? LevelTerminalRegistry.instance().getAdapter(clz).adapt(gridHost)
: (ILevelViewable) gridHost;
visited.add(gridHost);
/* First check if we are already tracking this node */
if (tracked.containsKey(gridHost)) {
ContainerLevelTerminal.InvTracker knownTracker = tracked.get(gridHost);
/* Name changed? */
String name = machine.getCustomName();
if (!Objects.equals(knownTracker.name, name)) {
knownTracker.name = name;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addRenameEntry(knownTracker.id, name);
}
LevelItemInfo[] prev = knownTracker.infoList;
LevelItemInfo[] curr = machine.getLevelItemInfoList();
if (prev.length == curr.length) {
for (int i = 0; i < prev.length; i++) {
if (prev[i] == null && curr[i] == null) continue;
if (prev[i] == null) {
knownTracker.infoList[i] = curr[i];
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteSlotEntry(knownTracker.id, i, curr[i]);
} else if (curr[i] == null) {
knownTracker.infoList[i] = null;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteSlotEntry(knownTracker.id, i, null);
} else if (!Platform.isStacksIdentical(prev[i].stack, curr[i].stack)
|| prev[i].quantity == curr[i].quantity
|| prev[i].batchSize == curr[i].batchSize
|| prev[i].state == curr[i].state) {
knownTracker.infoList[i] = curr[i];
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteSlotEntry(knownTracker.id, i, curr[i]);
}
}
} else {
knownTracker.infoList = curr;
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addOverwriteAllSlotEntry(knownTracker.id, curr);
}
} else {
/* Add a new entry */
if (update == null) update = new SPacketLevelTerminalUpdate();
ContainerLevelTerminal.InvTracker entry = new ContainerLevelTerminal.InvTracker(nextId++, machine);
update.addNewEntry(
entry.id,
entry.x,
entry.y,
entry.z,
entry.dim,
entry.side.ordinal(),
entry.rows,
entry.rowSize,
entry.name,
entry.infoList);
tracked.put(gridHost, entry);
trackedById.put(entry.id, entry);
}
}
}
/* Now find any entries that we need to remove */
Iterator<Map.Entry<IGridHost, ContainerLevelTerminal.InvTracker>> it = tracked.entrySet().iterator();
while (it.hasNext()) {
var entry = it.next();
if (visited.contains(entry.getKey())) {
continue;
}
if (update == null) update = new SPacketLevelTerminalUpdate();
update.addRemoveEntry(entry.getValue().id);
trackedById.remove(entry.getValue().id);
it.remove();
}
return update;
}
@Override
protected boolean isWirelessTerminal() {
return false;
}
private static class InvTracker {
private final long id;
private String name;
private final int rowSize;
private final int rows;
private final int x;
private final int y;
private final int z;
private final int dim;
private final ForgeDirection side;
private LevelItemInfo[] infoList;
public InvTracker(long id, ILevelViewable machine) {
DimensionalCoord location = machine.getLocation();
this.id = id;
this.name = machine.getCustomName();
this.rowSize = machine.rowSize();
this.rows = machine.rows();
this.x = location.x;
this.y = location.y;
this.z = location.z;
this.dim = location.getDimension();
this.side = machine.getSide();
this.infoList = machine.getLevelItemInfoList();
}
}
@Override
public PrimaryGui createPrimaryGui() {
ContainerOpenContext context = getOpenContext();
return new FluidPrimaryGui(
GuiType.LEVEL_TERMINAL,
ItemAndBlockHolder.LEVEL_TERMINAL.stack(),
context.getTile(),
context.getSide());
}
}
@@ -1,33 +0,0 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPrimaryGui;
import appeng.container.ContainerOpenContext;
import appeng.container.PrimaryGui;
public class ContainerLevelWireless extends ContainerLevelTerminal {
public ContainerLevelWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
@Override
public PrimaryGui createPrimaryGui() {
ContainerOpenContext context = getOpenContext();
return new FluidPrimaryGui(
GuiType.WIRELESS_LEVEL_TERMINAL,
ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack(),
context.getTile(),
context.getSide());
}
}
@@ -1,103 +0,0 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import com.glodblock.github.inventory.item.IWirelessMagnetFilter;
import com.glodblock.github.inventory.item.WirelessMagnet;
import com.glodblock.github.inventory.item.WirelessMagnetCardFilterInventory;
import appeng.api.storage.ITerminalHost;
import appeng.container.ContainerSubGui;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotPatternOutputs;
import appeng.util.Platform;
public class ContainerMagnetFilter extends ContainerSubGui implements IOptionalSlotHost {
@GuiSync(101)
public WirelessMagnet.ListMode listMode;
@GuiSync(102)
public boolean nbt;
@GuiSync(103)
public boolean meta;
@GuiSync(104)
public boolean ore;
@GuiSync(105)
public boolean oreDict;
@GuiSync(106)
public String oreDictFilter;
protected OptionalSlotFake[] filterSlots;
protected final IInventory filter;
private final IWirelessMagnetFilter object;
public ContainerMagnetFilter(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
this.object = (WirelessMagnetCardFilterInventory) monitorable;
this.filter = object.getInventoryByName("config");
this.filterSlots = new OptionalSlotFake[27];
oreDictFilter = object.getOreDictFilter();
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
this.addSlotToContainer(
this.filterSlots[x + y * 9] = new SlotPatternOutputs(
this.filter,
this,
x + y * 9,
8 + x * 18,
58 + y * 18,
0,
0,
1));
this.filterSlots[x + y * 9].setRenderDisabled(false);
}
}
this.lockPlayerInventorySlot(this.object.getInventorySlot());
bindPlayerInventory(ip, 0, 126);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx);
if (clickSlot == null || !clickSlot.getHasStack()) return null;
ItemStack tis = clickSlot.getStack();
for (SlotFake slot : this.filterSlots) {
if (!slot.getHasStack()) {
slot.putStack(tis);
detectAndSendChanges();
break;
}
}
return super.transferStackInSlot(p, idx);
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
this.listMode = this.object.getListMode();
this.meta = this.object.getMetaMode();
this.nbt = this.object.getNBTMode();
this.ore = this.object.getOreMode();
this.oreDict = this.object.getOreDictMode();
this.oreDictFilter = this.object.getOreDictFilter();
}
super.detectAndSendChanges();
}
@Override
public boolean isSlotEnabled(int idx) {
return true;
}
}
@@ -1,28 +0,0 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.common.tile.TileOCPatternEditor;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
public class ContainerOCPatternEditor extends AEBaseContainer {
public ContainerOCPatternEditor(InventoryPlayer ipl, TileOCPatternEditor tile) {
super(ipl, tile);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
addSlotToContainer(
new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.PATTERN,
tile.getInternalInventory(),
j * 4 + i,
55 + i * 18,
17 + j * 18,
ipl));
}
}
bindPlayerInventory(ipl, 0, 104);
}
}
@@ -1,220 +0,0 @@
package com.glodblock.github.client.gui.container;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.FCBaseItemCell;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileSuperStockReplenisher;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFake;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.SPacketSuperStockReplenisherUpdate;
import com.glodblock.github.util.FluidPrimaryGui;
import appeng.api.storage.StorageName;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.client.gui.implementations.GuiPatternItemRenamer;
import appeng.client.gui.implementations.GuiPatternValueAmount;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerOpenContext;
import appeng.container.PrimaryGui;
import appeng.container.interfaces.IVirtualSlotHolder;
import appeng.container.interfaces.IVirtualSlotSource;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.SlotPatternOutputs;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketVirtualSlot;
import appeng.items.storage.ItemBasicStorageCell;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
public class ContainerSuperStockReplenisher extends AEBaseContainer
implements IOptionalSlotHost, IVirtualSlotHolder, IVirtualSlotSource {
private final TileSuperStockReplenisher tile;
private final IInventory configFluids;
private final IInventory configItems;
private int lastUpdated = 0;
public ContainerSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) {
super(ipl, tile);
this.tile = tile;
configFluids = tile.getConfigFluid();
configItems = tile.getConfigItems();
final IInventory cell = tile.getCell();
final int x = 8;
final int fy = 8;
this.addSlotToContainer(
new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL,
cell,
0,
173,
fy,
this.getInventoryPlayer()));
for (int i = 0; i < 9; i++) {
addSlotToContainer(new OptionalFluidSlotFake(configFluids, this, i, x, fy, i, 0, 0));
}
final int io = 29;
for (int y = 0; y < 7; y++) {
for (int ix = 0; ix < 9; ix++) {
this.addSlotToContainer(new SlotPatternOutputs(configItems, this, y * 9 + ix, x, io, ix, y, y));
}
}
bindPlayerInventory(ipl, 0, 251 - 82);
}
@Override
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
if (slotId == 0 && player.inventory.getItemStack() == null && isConfigurated()) {
return null;
}
return super.slotClick(slotId, clickedButton, mode, player);
}
@Override
public boolean isSlotEnabled(int idx) {
return true;
}
@Override
public void addCraftingToCrafters(ICrafting p_75132_1_) {
super.addCraftingToCrafters(p_75132_1_);
lastUpdated = 24;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (lastUpdated > 20) {
lastUpdated = 0;
Map<Integer, IAEStack<?>> tmp = new HashMap<>();
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < tile.getInternalInventory().getSizeInventory(); i++) {
tmp.put(i + 100, AEItemStack.create(tile.getInternalInventory().getStackInSlot(i)));
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketSuperStockReplenisherUpdate(tmp), (EntityPlayerMP) g);
}
}
}
lastUpdated++;
}
private boolean isConfigurated() {
for (int i = 0; i < configItems.getSizeInventory(); i++) {
if (configItems.getStackInSlot(i) != null) {
return true;
}
}
for (int i = 0; i < configFluids.getSizeInventory(); i++) {
if (configFluids.getStackInSlot(i) != null) {
return true;
}
}
return false;
}
@Override
public boolean isValidForSlot(Slot s, ItemStack is) {
if (s.slotNumber == 0 && s.getHasStack() && isConfigurated()) {
long currentBytes = 0;
long newBytes = -1;
if (s.getStack().getItem() instanceof ItemBasicStorageCell ibsc) {
currentBytes = ibsc.getBytesLong(is);
} else if (s.getStack().getItem() instanceof FCBaseItemCell fcbic) {
currentBytes = fcbic.getBytes(is);
}
if (is.getItem() instanceof ItemBasicStorageCell ibsc) {
newBytes = ibsc.getBytesLong(is);
} else if (is.getItem() instanceof FCBaseItemCell fcbic) {
newBytes = fcbic.getBytes(is);
}
if (currentBytes > newBytes) {
return false;
}
}
return super.isValidForSlot(s, is);
}
public TileSuperStockReplenisher getTile() {
return tile;
}
@Override
public PrimaryGui createPrimaryGui() {
ContainerOpenContext context = getOpenContext();
return new FluidPrimaryGui(
GuiType.GUI_SUPER_STOCK_REPLENISHER,
ItemAndBlockHolder.SUPER_STOCK_RERPLENISHER.stack(),
context.getTile(),
context.getSide());
}
@Override
public void receiveSlotStacks(StorageName invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
var entry = slotStacks.int2ObjectEntrySet().iterator().next();
IAEStack<?> aes = entry.getValue();
int slotIndex = entry.getIntKey();
if (Platform.isServer()) {
for (ICrafting crafter : this.crafters) {
final EntityPlayerMP emp = (EntityPlayerMP) crafter;
NetworkHandler.instance.sendTo(new PacketVirtualSlot(invName, slotIndex, aes), emp);
}
} else {
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiPatternValueAmount gpva) {
gpva.update();
} else if (gs instanceof GuiPatternItemRenamer gpir) {
gpir.update();
}
}
}
@Override
public void updateVirtualSlot(StorageName invName, int slotId, IAEStack<?> aes) {
if (aes instanceof IAEItemStack ais) {
ItemStack newIs;
if (ais.getItem() instanceof ItemFluidPacket) {
newIs = ais.getItemStack();
newIs.stackSize = 1;
ItemFluidPacket.setFluidAmount(newIs, aes.getStackSize());
} else {
newIs = ais.getItemStack();
}
this.inventorySlots.get(slotId).putStack(newIs);
}
}
}
@@ -1,80 +0,0 @@
package com.glodblock.github.client.gui.container.base;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.inventory.item.WirelessMagnet;
import com.glodblock.github.util.Util;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
public abstract class FCBaseContainer extends AEBaseContainer {
private int ticks;
private final double powerMultiplier = 0.5;
private ITerminalHost host;
private int slot = -1;
private final InventoryPlayer ip;
@GuiSync(105)
public boolean restock = false;
@GuiSync(106)
public WirelessMagnet.Mode mode = WirelessMagnet.Mode.Off;
public FCBaseContainer(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
this.ip = ip;
this.host = monitorable;
if (isWirelessTerminal()) {
this.slot = lockSlot();
}
}
private int lockSlot() {
if (isWirelessTerminal()) {
if (this.host instanceof IFluidPortableCell) {
final int slotIndex = ((IFluidPortableCell) this.host).getInventorySlot();
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
this.lockPlayerInventorySlot(slotIndex);
}
return slotIndex;
} else {
this.lockPlayerInventorySlot(ip.currentItem);
}
}
return -1;
}
protected abstract boolean isWirelessTerminal();
public void detectAndSendChanges() {
if (isWirelessTerminal()) {
this.ticks = Util.drainItemPower(
this,
this.getPlayerInv(),
this.slot,
this.ticks,
this.getPowerMultiplier(),
((IFluidPortableCell) this.host));
}
super.detectAndSendChanges();
}
public double getPowerMultiplier() {
return this.powerMultiplier;
}
public ITerminalHost getHost() {
return this.host;
}
public IFluidPortableCell getPortableCell() {
if (this.host instanceof IFluidPortableCell fpc) {
return fpc;
}
return null;
}
}
@@ -1,119 +0,0 @@
package com.glodblock.github.client.gui.container.base;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.util.Util;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.slot.AppEngSlot;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
public abstract class FCContainerFluidConfigurable extends ContainerUpgradeable {
public FCContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te) {
super(ip, te);
}
public abstract AppEngInternalAEInventory getFakeFluidInv();
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx);
if (clickSlot == null || !clickSlot.getHasStack()) return null;
ItemStack tis = clickSlot.getStack();
FluidStack fs = Util.getFluidFromItem(tis);
if (fs != null) {
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
final IAEFluidStack stack = AEFluidStack.create(fs);
for (int i = 0; i < inv.getSizeInventory(); ++i) {
if (inv.getStackInSlot(i) == null && this.isValidForConfig(i, stack)) {
ItemStack tmp = ItemFluidPacket.newStack(fs);
if (tmp != null) {
tmp.setStackDisplayName(fs.getLocalizedName());
}
inv.setInventorySlotContents(i, tmp);
break;
}
}
this.standardDetectAndSendChanges();
return null;
} else {
return super.transferStackInSlot(p, idx);
}
}
protected void setupConfig() {
this.setupUpgrades();
final IInventory inv = getUpgradeable().getInventoryByName("config");
final int y = 40;
final int x = 80;
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 0, x, y, 0, 0, 0));
if (this.supportCapacity()) {
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 1, x, y, -1, 0, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 2, x, y, 1, 0, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 3, x, y, 0, -1, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 4, x, y, 0, 1, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 5, x, y, -1, -1, 2));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 6, x, y, 1, -1, 2));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 7, x, y, -1, 1, 2));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 8, x, y, 1, 1, 2));
}
}
protected boolean isValidForConfig(int slot, IAEFluidStack fs) {
if (this.supportCapacity()) {
// assumes 4 slots per upgrade
final int upgrades = getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
if (slot > 0 && upgrades < 1) {
return false;
}
return slot <= 4 || upgrades >= 2;
}
return true;
}
@Override
protected void standardDetectAndSendChanges() {
if (Platform.isServer()) {
// clear out config items that are no longer valid (for instance, capacity upgrade removed)
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
final Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < inv.getSizeInventory(); ++i) {
if (inv.getStackInSlot(i) != null && !this.isValidForConfig(
i,
AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot(i))))) {
inv.setInventorySlotContents(i, null);
}
tmp.put(i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot(i))));
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
super.standardDetectAndSendChanges();
}
}
@@ -0,0 +1,67 @@
package com.glodblock.github.client.model;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ICustomModelLoader;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.PerspectiveMapWrapper;
import net.minecraftforge.common.model.IModelState;
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
public class DenseEncodedPatternModel implements IModel {
private static final ResourceLocation BASE_MODEL = FluidCraft.resource("item/dense_encoded_pattern");
@Override
@Nonnull
public Collection<ResourceLocation> getDependencies() {
return Collections.singletonList(BASE_MODEL);
}
// adapted from ae2's ItemEncodedPatternModel#bake
@Override
@Nonnull
public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format, @Nonnull Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
IBakedModel baseModel;
try {
baseModel = ModelLoaderRegistry.getModel(BASE_MODEL).bake(state, format, bakedTextureGetter);
} catch (Exception e) {
throw new RuntimeException(e);
}
return Ae2ReflectClient.bakeEncodedPatternModel(baseModel, PerspectiveMapWrapper.getTransforms(state));
}
public static class Loader implements ICustomModelLoader {
@Override
public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) {
// NO-OP
}
@Override
public boolean accepts(ResourceLocation modelLocation) {
// modelLocation will probably be a ModelResourceLocation, so using compareTo lets us bypass the
// ModelResourceLocation equality behaviour and fall back to that of ResourceLocation
return modelLocation.compareTo(NameConst.MODEL_DENSE_ENCODED_PATTERN) == 0;
}
@Override
@Nonnull
public IModel loadModel(@Nonnull ResourceLocation modelLocation) {
return new DenseEncodedPatternModel();
}
}
}
@@ -0,0 +1,234 @@
package com.glodblock.github.client.model;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.util.FluidKey;
import com.glodblock.github.util.NameConst;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.*;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ICustomModelLoader;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ItemLayerModel;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.util.vector.Vector3f;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
public class FluidPacketModel implements IModel {
@SuppressWarnings("deprecation")
private static final ItemCameraTransforms CAMERA_TRANSFORMS = new ItemCameraTransforms(
new ItemTransformVec3f(new Vector3f(0F, 0F, 0F), new Vector3f(0F, 0.1875F, 0.0625F), new Vector3f(0.55F, 0.55F, 0.55F)),
new ItemTransformVec3f(new Vector3f(0F, 0F, 0F), new Vector3f(0F, 0.1875F, 0.0625F), new Vector3f(0.55F, 0.55F, 0.55F)),
new ItemTransformVec3f(new Vector3f(0F, -90F, 25F), new Vector3f(0.070625F, 0.2F, 0.070625F), new Vector3f(0.68F, 0.68F, 0.68F)),
new ItemTransformVec3f(new Vector3f(0F, -90F, 25F), new Vector3f(0.070625F, 0.2F, 0.070625F), new Vector3f(0.68F, 0.68F, 0.68F)),
new ItemTransformVec3f(new Vector3f(0F, 180F, 0F), new Vector3f(0F, 0.8125F, 0.4375F), new Vector3f(1F, 1F, 1F)),
ItemTransformVec3f.DEFAULT,
new ItemTransformVec3f(new Vector3f(0F, 0F, 0F), new Vector3f(0F, 0.125F, 0F), new Vector3f(0.5F, 0.5F, 0.5F)),
new ItemTransformVec3f(new Vector3f(0F, 180F, 0F), new Vector3f(0F, 0F, 0F), new Vector3f(1F, 1F, 1F)));
@Override
@Nonnull
public IBakedModel bake(@Nonnull IModelState state, @Nonnull VertexFormat format, @Nonnull Function<ResourceLocation, TextureAtlasSprite> textureBakery) {
return new BakedFluidPacketModel(state, format);
}
public static class Loader implements ICustomModelLoader {
@Override
public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) {
// NO-OP
}
@Override
public boolean accepts(ResourceLocation modelLocation) {
// modelLocation will probably be a ModelResourceLocation, so using compareTo lets us bypass the
// ModelResourceLocation equality behaviour and fall back to that of ResourceLocation
return modelLocation.compareTo(NameConst.MODEL_FLUID_PACKET) == 0;
}
@Override
@Nonnull
public IModel loadModel(@Nonnull ResourceLocation modelLocation) {
return new FluidPacketModel();
}
}
private static class BakedFluidPacketModel implements IBakedModel {
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private final Optional<TRSRTransformation> modelTransform;
private final VertexFormat vertexFormat;
private final OverrideCache overrides;
private final OverrideCache.OverrideModel defaultOverride;
public BakedFluidPacketModel(IModelState modelState, VertexFormat vertexFormat) {
this.modelTransform = modelState.apply(Optional.empty());
this.vertexFormat = vertexFormat;
this.overrides = new OverrideCache();
this.defaultOverride = overrides.resolve(new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME));
}
@Override
@Nonnull
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
return defaultOverride.getQuads(state, side, rand);
}
@Override
public boolean isAmbientOcclusion() {
return defaultOverride.isAmbientOcclusion();
}
@Override
public boolean isGui3d() {
return defaultOverride.isGui3d();
}
@Override
public boolean isBuiltInRenderer() {
return defaultOverride.isBuiltInRenderer();
}
@Override
@Nonnull
public TextureAtlasSprite getParticleTexture() {
return defaultOverride.getParticleTexture();
}
@Override
public boolean isAmbientOcclusion(@Nonnull IBlockState state) {
return defaultOverride.isAmbientOcclusion(state);
}
@SuppressWarnings("deprecation")
@Override
@Nonnull
public ItemCameraTransforms getItemCameraTransforms() {
return defaultOverride.getItemCameraTransforms();
}
@Override
@Nonnull
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(@Nonnull ItemCameraTransforms.TransformType cameraTransformType) {
return defaultOverride.handlePerspective(cameraTransformType);
}
@Override
@Nonnull
public ItemOverrideList getOverrides() {
return overrides;
}
private class OverrideCache extends ItemOverrideList {
private final Cache<FluidKey, OverrideModel> cache = CacheBuilder.newBuilder()
.maximumSize(1000) // cache params borrowed from Tinkers' Construct model system, which is under MIT
.expireAfterWrite(5, TimeUnit.MINUTES)
.build();
OverrideCache() {
super(Collections.emptyList());
}
@Override
@Nonnull
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack,
@Nullable World world, @Nullable EntityLivingBase entity) {
if (!(stack.getItem() instanceof ItemFluidPacket)) {
return originalModel;
}
FluidStack fluid = ItemFluidPacket.getFluidStack(stack);
return fluid != null ? resolve(fluid) : originalModel;
}
OverrideModel resolve(FluidStack fluid) {
try {
return cache.get(new FluidKey(fluid), () -> new OverrideModel(fluid));
} catch (ExecutionException e) {
throw new IllegalStateException(e);
}
}
class OverrideModel implements IBakedModel {
private final TextureAtlasSprite texture;
private final List<BakedQuad> quads;
OverrideModel(FluidStack fluidStack) {
this.texture = Minecraft.getMinecraft().getTextureMapBlocks()
.getAtlasSprite(fluidStack.getFluid().getStill(fluidStack).toString());
this.quads = ItemLayerModel.getQuadsForSprite(1, texture, vertexFormat, modelTransform);
}
@Override
@Nonnull
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
return quads;
}
@Override
public boolean isAmbientOcclusion() {
return false;
}
@Override
public boolean isGui3d() {
return false;
}
@Override
public boolean isBuiltInRenderer() {
return false;
}
@Override
@Nonnull
public TextureAtlasSprite getParticleTexture() {
return texture;
}
@Override
@Nonnull
@SuppressWarnings("deprecation")
public ItemCameraTransforms getItemCameraTransforms() {
return CAMERA_TRANSFORMS;
}
@Override
@Nonnull
public ItemOverrideList getOverrides() {
return OverrideCache.this;
}
}
}
}
}
@@ -0,0 +1,74 @@
package com.glodblock.github.client.render;
import com.glodblock.github.util.ModAndClassUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.HashMap;
import java.util.Map;
public class DropColourHandler {
private final Map<String, Integer> colourCache = new HashMap<>();
@SubscribeEvent
public void onTextureMapStitch(TextureStitchEvent event) {
if (event.getMap() == Minecraft.getMinecraft().getTextureMapBlocks()) {
colourCache.clear();
}
}
public int getColour(FluidStack fluidStack) {
Fluid fluid = fluidStack.getFluid();
int colour = fluid.getColor(fluidStack);
if (ModAndClassUtil.GT && colour == 0xFFFFFFFF)
return runBidAidFix(fluidStack);
return colour != 0xFFFFFFFF ? colour : getColour(fluid);
}
public int getColour(Fluid fluid) {
Integer cached = colourCache.get(fluid.getName());
if (cached != null) {
return cached;
}
int colour = fluid.getColor();
if (colour == 0xFFFFFFFF) {
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks()
.getTextureExtry(fluid.getStill().toString());
if (sprite != null && sprite.getFrameCount() > 0) {
int[][] image = sprite.getFrameTextureData(0);
int r = 0, g = 0, b = 0, count = 0;
for (int[] row : image) {
for (int pixel : row) {
if (((pixel >> 24) & 0xFF) > 127) { // is alpha above 50%?
r += (pixel >> 16) & 0xFF;
g += (pixel >> 8) & 0xFF;
b += pixel & 0xFF;
++count;
}
}
}
if (count > 0) {
// probably shouldn't need to mask each component by 0xFF
colour = ((r / count) << 16) | ((g / count) << 8) | (b / count);
}
}
}
colourCache.put(fluid.getName(), colour);
return colour;
}
//Need to find a better way to replace this.
private int runBidAidFix(FluidStack fluidStack) {
if (fluidStack.isFluidEqual(FluidRegistry.getFluidStack("helium", 1))) {
return 0xFFFCFF90;
}
return getColour(fluidStack.getFluid());
}
}
@@ -0,0 +1,127 @@
package com.glodblock.github.client.render;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.render.StackSizeRenderer;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
public class FluidRenderUtils {
@Nullable
public static TextureAtlasSprite prepareRender(@Nullable FluidStack fluidStack) {
if (fluidStack == null) {
return null;
}
Fluid fluid = fluidStack.getFluid();
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks()
.getAtlasSprite(fluid.getStill(fluidStack).toString());
int colour = fluid.getColor(fluidStack);
GlStateManager.color(
((colour >> 16) & 0xFF) / 255F,
((colour >> 8) & 0xFF) / 255F,
(colour & 0xFF) / 255F,
((colour >> 24) & 0xFF) / 255F);
return sprite;
}
private static void doRenderFluid(Tessellator tess, BufferBuilder buf, int x, int y, int width, int height,
TextureAtlasSprite sprite, double fraction) {
GlStateManager.enableBlend();
GlStateManager.blendFunc(
GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
int fluidHeight = Math.round(height * (float)Math.min(1D, Math.max(0D, fraction)));
double x2 = x + width;
while (fluidHeight > 0) {
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
double y1 = y + height - fluidHeight, y2 = y1 + Math.min(fluidHeight, width);
double u1 = sprite.getMinU(), v1 = sprite.getMinV(), u2 = sprite.getMaxU(), v2 = sprite.getMaxV();
if (fluidHeight < width) {
v2 = v1 + (v2 - v1) * (fluidHeight / (double)width);
fluidHeight = 0;
} else {
//noinspection SuspiciousNameCombination
fluidHeight -= width;
}
buf.pos(x, y1, 0D).tex(u1, v1).endVertex();
buf.pos(x, y2, 0D).tex(u1, v2).endVertex();
buf.pos(x2, y2, 0D).tex(u2, v2).endVertex();
buf.pos(x2, y1, 0D).tex(u2, v1).endVertex();
tess.draw();
}
}
public static void renderFluidIntoGui(Tessellator tess, BufferBuilder buf, int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
TextureAtlasSprite sprite = FluidRenderUtils.prepareRender(aeFluidStack.getFluidStack());
if (sprite != null) {
doRenderFluid(tess, buf, x, y, width, height, sprite, aeFluidStack.getStackSize() / (double)capacity);
}
}
}
public static void renderFluidIntoGui(Tessellator tess, BufferBuilder buf, int x, int y, int width, int height,
@Nullable FluidStack fluidStack, int capacity) {
if (fluidStack != null) {
TextureAtlasSprite sprite = FluidRenderUtils.prepareRender(fluidStack);
if (sprite != null) {
doRenderFluid(tess, buf, x, y, width, height, sprite, fluidStack.amount / (double)capacity);
}
}
}
public static void renderFluidIntoGuiCleanly(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Tessellator tess = Tessellator.getInstance();
renderFluidIntoGui(tess, tess.getBuffer(), x, y, width, height, aeFluidStack, capacity);
GlStateManager.color(1F, 1F, 1F, 1F);
}
public static void renderFluidIntoGuiCleanly(int x, int y, int width, int height,
@Nullable FluidStack fluidStack, int capacity) {
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Tessellator tess = Tessellator.getInstance();
renderFluidIntoGui(tess, tess.getBuffer(), x, y, width, height, fluidStack, capacity);
GlStateManager.color(1F, 1F, 1F, 1F);
}
public static boolean renderFluidIntoGuiSlot(Slot slot, @Nullable FluidStack fluid,
StackSizeRenderer stackSizeRenderer, FontRenderer fontRenderer) {
if (fluid == null || fluid.amount <= 0) {
return false;
}
renderFluidIntoGuiCleanly(slot.xPos, slot.yPos, 16, 16, fluid, fluid.amount);
stackSizeRenderer.renderStackSize(fontRenderer, ItemFluidDrop.newAeStack(fluid), slot.xPos, slot.yPos);
return true;
}
public static boolean renderFluidPacketIntoGuiSlot(Slot slot, @Nullable IAEItemStack stack,
StackSizeRenderer stackSizeRenderer, FontRenderer fontRenderer) {
return stack != null && stack.getItem() instanceof ItemFluidPacket
&& renderFluidIntoGuiSlot(slot, ItemFluidPacket.getFluidStack(stack), stackSizeRenderer, fontRenderer);
}
public static boolean renderFluidPacketIntoGuiSlot(Slot slot, ItemStack stack,
StackSizeRenderer stackSizeRenderer, FontRenderer fontRenderer) {
return !stack.isEmpty() && stack.getItem() instanceof ItemFluidPacket
&& renderFluidIntoGuiSlot(slot, ItemFluidPacket.getFluidStack(stack), stackSizeRenderer, fontRenderer);
}
}
@@ -1,114 +0,0 @@
package com.glodblock.github.client.render;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.render.tank.ModelCertusTank;
import com.glodblock.github.common.item.ItemCertusQuartzTank;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.loader.ItemAndBlockHolder;
import cpw.mods.fml.client.registry.ClientRegistry;
public class ItemCertusQuartzTankRender implements IItemRenderer {
private final ModelCertusTank model = new ModelCertusTank();
public ItemCertusQuartzTankRender() {
ClientRegistry.bindTileEntitySpecialRenderer(TileCertusQuartzTank.class, new RenderBlockCertusQuartzTank());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.CERTUS_QUARTZ_TANK), this);
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Minecraft.getMinecraft().renderEngine
.bindTexture(FluidCraft.resource("textures/blocks/certus_quartz_tank/map.png"));
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
GL11.glRotatef(180F, 1F, 0F, 0F);
this.model.render(0.0625f);
GL11.glRotatef(180F, 1F, 0F, 0F);
if (item.getItem() instanceof ItemCertusQuartzTank itemCertusQuartzTank) {
FluidStack storedFluid = itemCertusQuartzTank.getFluid(item);
int tankCapacity = itemCertusQuartzTank.getCapacity(item);
if (storedFluid != null && storedFluid.getFluid() != null) {
IIcon fluidIcon = storedFluid.getFluid().getIcon();
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
Tessellator tessellator = Tessellator.instance;
RenderBlocks renderer = new RenderBlocks();
Block waterBlock = FluidRegistry.WATER.getBlock();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
renderer.setRenderBounds(
0.08F,
0.001F,
0.08F,
0.92F,
(float) storedFluid.amount / (float) tankCapacity * 0.999F,
0.92F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(
(storedFluid.getFluid().getColor() >> 16 & 0xFF) / 255.0F,
(storedFluid.getFluid().getColor() >> 8 & 0xFF) / 255.0F,
(storedFluid.getFluid().getColor() & 0xFF) / 255.0F,
1.0F);
tessellator.setNormal(0.0F, -1F, 0.0F);
renderer.renderFaceYNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, -1F);
renderer.renderFaceZNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderer.renderFaceXNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.draw();
}
}
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}
@@ -1,127 +0,0 @@
package com.glodblock.github.client.render;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.RenderUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ItemDropRender implements IItemRenderer {
private final Map<String, Integer> colourCache = new HashMap<>();
public ItemDropRender() {
MinecraftForgeClient.registerItemRenderer(ItemAndBlockHolder.DROP, this);
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type != ItemRenderType.FIRST_PERSON_MAP;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return type == ItemRenderType.ENTITY;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
IIcon shape = ItemAndBlockHolder.DROP.shape;
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
if (type.equals(ItemRenderType.ENTITY)) {
GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D);
GL11.glTranslated(-0.5D, -0.6D, 0.0D);
}
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
FluidStack fluid = ItemFluidDrop.getFluidStack(item);
if (fluid != null) {
int RGB = getColour(fluid);
GL11.glColor3f((RGB >> 16 & 0xFF) / 255.0F, (RGB >> 8 & 0xFF) / 255.0F, (RGB & 0xFF) / 255.0F);
}
if (type.equals(ItemRenderType.INVENTORY)) {
RenderUtil.renderItemIcon(shape, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
} else {
ItemRenderer.renderItemIn2D(
Tessellator.instance,
shape.getMaxU(),
shape.getMinV(),
shape.getMinU(),
shape.getMaxV(),
shape.getIconWidth(),
shape.getIconHeight(),
0.0625F);
}
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
}
public int getColour(FluidStack fluidStack) {
Fluid fluid = fluidStack.getFluid();
int colour = fluid.getColor(fluidStack);
return colour != 0xFFFFFF ? colour : getColour(fluid);
}
public int getColour(Fluid fluid) {
Integer cached = colourCache.get(fluid.getName());
if (cached != null) {
return cached;
}
int colour = fluid.getColor();
if (colour == 0xFFFFFF) {
TextureAtlasSprite sprite;
try {
sprite = Minecraft.getMinecraft().getTextureMapBlocks()
.getTextureExtry(fluid.getStillIcon().getIconName());
} catch (NullPointerException e) {
colourCache.put(fluid.getName(), colour);
return colour;
}
if (sprite != null && sprite.getFrameCount() > 0) {
int[][] image = sprite.getFrameTextureData(0);
int r = 0, g = 0, b = 0, count = 0;
for (int[] row : image) {
for (int pixel : row) {
if (((pixel >> 24) & 0xFF) > 127) { // is alpha above 50%?
r += (pixel >> 16) & 0xFF;
g += (pixel >> 8) & 0xFF;
b += pixel & 0xFF;
++count;
}
}
}
if (count > 0) {
// probably shouldn't need to mask each component by 0xFF
colour = ((r / count) << 16) | ((g / count) << 8) | (b / count);
}
}
}
colourCache.put(fluid.getName(), colour);
return colour;
}
}
@@ -1,71 +0,0 @@
package com.glodblock.github.client.render;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.RenderUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ItemPacketRender implements IItemRenderer {
public ItemPacketRender() {
MinecraftForgeClient.registerItemRenderer(ItemAndBlockHolder.PACKET, this);
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type != ItemRenderType.FIRST_PERSON_MAP;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return type == ItemRenderType.ENTITY;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if (item == null || item.getItem() == null || !(item.getItem() instanceof ItemFluidPacket)) return;
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
FluidStack fluid = ItemFluidPacket.getFluidStack(item);
int RGB = fluid == null ? 0xFFFFFF : fluid.getFluid().getColor(fluid);
IIcon icon = fluid == null ? FluidRegistry.WATER.getStillIcon() : fluid.getFluid().getStillIcon();
if (RGB != 0xFFFFFF) {
GL11.glColor3f((RGB >> 16 & 0xFF) / 255.0F, (RGB >> 8 & 0xFF) / 255.0F, (RGB & 0xFF) / 255.0F);
}
if (type.equals(ItemRenderType.INVENTORY)) {
RenderUtil.renderItemIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
} else {
ItemRenderer.renderItemIn2D(
Tessellator.instance,
icon.getMaxU(),
icon.getMinV(),
icon.getMinU(),
icon.getMaxV(),
icon.getIconWidth(),
icon.getIconHeight(),
0.0625F);
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
}
}
@@ -1,55 +0,0 @@
package com.glodblock.github.client.render;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tile.TileWalrus;
import com.glodblock.github.loader.ItemAndBlockHolder;
import cpw.mods.fml.client.registry.ClientRegistry;
public class ItemWalrusRender implements IItemRenderer {
IModelCustom modelWalrus = AdvancedModelLoader.loadModel(FluidCraft.resource("models/walrus.obj"));
ResourceLocation textureWalrus = FluidCraft.resource("textures/blocks/walrus.png");
public ItemWalrusRender() {
ClientRegistry.bindTileEntitySpecialRenderer(TileWalrus.class, new RenderBlockWalrus());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.WALRUS), this);
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
GL11.glPushMatrix();
switch (type) {
case EQUIPPED_FIRST_PERSON -> {
GL11.glRotated(180, 0, 1, 0);
GL11.glTranslatef(-1F, 0.5F, -0.5F);
}
case INVENTORY -> GL11.glTranslatef(-0.5F, -0.5F, -0.1F);
default -> {}
}
this.modelWalrus.renderAll();
GL11.glPopMatrix();
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
return true;
}
}
@@ -1,54 +0,0 @@
package com.glodblock.github.client.render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.client.render.tank.FluidTankRenderer;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.util.RenderUtil;
import com.glodblock.github.util.Util;
public class RenderBlockCertusQuartzTank extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
TileCertusQuartzTank tank = (TileCertusQuartzTank) tileentity;
FluidStack liquid = tank.tank.getFluid();
if (liquid == null || liquid.getFluid() == null || liquid.amount <= 0) {
return;
}
int color = liquid.getFluid().getColor(liquid);
int[] displayList = FluidTankRenderer.getFluidDisplayLists(liquid, tileentity.getWorldObj(), false);
if (displayList == null) {
return;
}
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
bindTexture(TextureMap.locationBlocksTexture);
RenderUtil.setGLColorFromInt(color);
GL11.glTranslatef((float) x + 0.0625F, (float) y + 0.5F, (float) z + 0.0625F);
GL11.glScalef(0.875F, 0.99F, 0.875F);
GL11.glTranslatef(0, -0.5F, 0);
int dl = (int) ((float) liquid.amount / (float) (tank.tank.getCapacity())
* (FluidTankRenderer.DISPLAY_STAGES - 1));
GL11.glCallList(displayList[Util.clamp(dl, 0, FluidTankRenderer.DISPLAY_STAGES - 1)]);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}
@@ -1,62 +0,0 @@
package com.glodblock.github.client.render;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import com.glodblock.github.common.block.BlockFluidBuffer;
import com.glodblock.github.common.tile.TileFluidBuffer;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.BlockRenderInfo;
public class RenderBlockFluidBuffer extends BaseBlockRender<BlockFluidBuffer, TileFluidBuffer> {
public RenderBlockFluidBuffer() {
super(false, 20);
}
@Override
public boolean renderInWorld(final BlockFluidBuffer block, final IBlockAccess world, final int x, final int y,
final int z, final RenderBlocks renderer) {
final TileFluidBuffer ti = block.getTileEntity(world, x, y, z);
final BlockRenderInfo info = block.getRendererInstance();
this.renderFluid(ti, x, y, z, renderer);
final boolean fz = super.renderInWorld(block, world, x, y, z, renderer);
info.setTemporaryRenderIcon(null);
return fz;
}
private void renderFluid(TileFluidBuffer tileEntity, double x, double y, double z, RenderBlocks renderer) {
Tessellator tessellator = Tessellator.instance;
if (tileEntity != null && tileEntity.getFluidStack() != null) {
Fluid storedFluid = tileEntity.getFluidStack().getFluid();
if (storedFluid != null) {
Block id = Block.getBlockById(FluidRegistry.WATER.getID());
IIcon fluidIcon = storedFluid.getIcon();
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
tessellator.setColorRGBA_F(
(storedFluid.getColor() >> 16 & 0xFF) / 255.0F,
(storedFluid.getColor() >> 8 & 0xFF) / 255.0F,
(storedFluid.getColor() & 0xFF) / 255.0F,
1.0F);
tessellator.setNormal(0.0F, -1F, 0.0F);
renderer.renderFaceYNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(id, x, y, z, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, -1F);
renderer.renderFaceZNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(id, x, y, z, fluidIcon);
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderer.renderFaceXNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(id, x, y, z, fluidIcon);
}
}
}
}
@@ -1,45 +0,0 @@
package com.glodblock.github.client.render;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.block.BlockFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.BlockRenderInfo;
import appeng.tile.misc.TileInterface;
public class RenderBlockFluidInterface extends BaseBlockRender<BlockFluidInterface, TileFluidInterface> {
public RenderBlockFluidInterface() {
super(false, 20);
}
@Override
public boolean renderInWorld(final BlockFluidInterface block, final IBlockAccess world, final int x, final int y,
final int z, final RenderBlocks renderer) {
final TileInterface ti = block.getTileEntity(world, x, y, z);
final BlockRenderInfo info = block.getRendererInstance();
if (ti != null && ti.getForward() != ForgeDirection.UNKNOWN) {
final IIcon side = FCPartsTexture.BlockFluidInterfaceAlternate_Arrow.getIcon();
info.setTemporaryRenderIcons(
FCPartsTexture.BlockInterfaceAlternate.getIcon(),
block.getIcon(0, 0),
side,
side,
side,
side);
}
final boolean fz = super.renderInWorld(block, world, x, y, z, renderer);
info.setTemporaryRenderIcon(null);
return fz;
}
}
@@ -1,38 +0,0 @@
package com.glodblock.github.client.render;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.block.BlockLevelMaintainer;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.BlockRenderInfo;
public class RenderBlockLevelMaintainer extends BaseBlockRender<BlockLevelMaintainer, TileLevelMaintainer> {
public RenderBlockLevelMaintainer() {
super(false, 20);
}
@Override
public boolean renderInWorld(final BlockLevelMaintainer block, final IBlockAccess world, final int x, final int y,
final int z, final RenderBlocks renderer) {
final TileLevelMaintainer ti = block.getTileEntity(world, x, y, z);
final BlockRenderInfo info = block.getRendererInstance();
if (ti != null && ti.isActive()) {
final IIcon activeIcon = FCPartsTexture.BlockLevelMaintainer_Active.getIcon();
final IIcon side = FCPartsTexture.BlockLevelMaintainer.getIcon();
info.setTemporaryRenderIcons(side, side, activeIcon, side, side, side);
}
final boolean fz = super.renderInWorld(block, world, x, y, z, renderer);
info.setTemporaryRenderIcon(null);
return fz;
}
}
@@ -1,48 +0,0 @@
package com.glodblock.github.client.render;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tile.TileWalrus;
public class RenderBlockWalrus extends TileEntitySpecialRenderer {
IModelCustom modelWalrus = AdvancedModelLoader.loadModel(FluidCraft.resource("models/walrus.obj"));
ResourceLocation textureWalrus = FluidCraft.resource("textures/blocks/walrus.png");
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime) {
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
if (!(tileentity instanceof TileWalrus Tile)) return;
float scale = Tile.getWalrusScale();
GL11.glPushMatrix();
int orientation = Tile.getBlockMetadata();
switch (orientation) {
case 2:
GL11.glTranslated(x + 0.5, y, z + 1 - scale * .655); // centering walrus model
break;
case 3:
GL11.glTranslated(x + 0.5, y, z + scale * .655);
GL11.glRotatef(180, 0, 1, 0);
break;
case 4:
GL11.glTranslated(x + 1 - scale * .655, y, z + 0.5);
GL11.glRotatef(90, 0, 1, 0);
break;
case 5:
GL11.glTranslated(x + scale * .655, y, z + 0.5);
GL11.glRotatef(-90, 0, 1, 0);
break;
}
GL11.glScalef(scale, scale, scale);
this.modelWalrus.renderAll();
GL11.glPopMatrix();
}
}
@@ -0,0 +1,81 @@
package com.glodblock.github.client.render;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import net.minecraftforge.items.IItemHandler;
import org.lwjgl.opengl.GL11;
public class RenderIngredientBuffer extends TileEntitySpecialRenderer<TileIngredientBuffer> {
private static final double d = 0.45D;
@Override
public void render(TileIngredientBuffer tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.enableLighting();
GlStateManager.pushMatrix();
GlStateManager.translate(x + 0.5D, y + 0.5D, z + 0.5D);
bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
IItemHandler inv = tile.getInternalInventory();
for (int i = 0; i < inv.getSlots(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (!stack.isEmpty()) {
GlStateManager.pushMatrix();
float scale = stack.getItem() instanceof ItemBlock ? 0.36F : 0.64F;
GlStateManager.scale(scale, scale, scale);
GlStateManager.rotate((getWorld().getTotalWorldTime() + partialTicks) * 6F, 0F, 1F, 0F);
RenderItem renderer = Minecraft.getMinecraft().getRenderItem();
renderer.renderItem(stack, renderer.getItemModelWithOverrides(stack, getWorld(), null));
GlStateManager.popMatrix();
break;
}
}
for (IFluidTankProperties tank : tile.getFluidInventory().getTankProperties()) {
TextureAtlasSprite fluidSprite = FluidRenderUtils.prepareRender(tank.getContents());
if (fluidSprite != null) {
Tessellator tess = Tessellator.getInstance();
BufferBuilder buf = tess.getBuffer();
// not necessarily the most efficient way to draw a cube, but probably the least tedious
GlStateManager.pushMatrix();
drawFace(tess, buf, fluidSprite);
for (int i = 0; i < 3; i++) {
GlStateManager.rotate(90F, 1F, 0F, 0F);
drawFace(tess, buf, fluidSprite);
}
GlStateManager.rotate(90F, 0F, 0F, 1F);
drawFace(tess, buf, fluidSprite);
GlStateManager.rotate(180F, 0F, 0F, 1F);
drawFace(tess, buf, fluidSprite);
GlStateManager.popMatrix();
break;
}
}
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.popMatrix();
}
private static void drawFace(Tessellator tess, BufferBuilder buf, TextureAtlasSprite sprite) {
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
buf.pos(-d, d, -d).tex(sprite.getMinU(), sprite.getMinV()).endVertex();
buf.pos(-d, d, d).tex(sprite.getMinU(), sprite.getMaxV()).endVertex();
buf.pos(d, d, d).tex(sprite.getMaxU(), sprite.getMaxV()).endVertex();
buf.pos(d, d, -d).tex(sprite.getMaxU(), sprite.getMinV()).endVertex();
tess.draw();
}
}
@@ -1,122 +0,0 @@
package com.glodblock.github.client.render.tank;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.util.RenderUtil;
public class FluidTankRenderer {
public static final int DISPLAY_STAGES = 100;
private static final Map<Fluid, int[]> flowingRenderCache = new HashMap<>();
private static final Map<Fluid, int[]> stillRenderCache = new HashMap<>();
private static final RenderEntityBlock.RenderInfo liquidBlock = new RenderEntityBlock.RenderInfo();
public static void onTextureReload() {
for (int[] ia : flowingRenderCache.values()) {
for (int i : ia) {
GL11.glDeleteLists(i, 1);
}
}
flowingRenderCache.clear();
for (int[] ia : stillRenderCache.values()) {
for (int i : ia) {
GL11.glDeleteLists(i, 1);
}
}
stillRenderCache.clear();
}
public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) {
if (fluidStack == null) {
return null;
}
return getFluidTexture(fluidStack.getFluid(), flowing);
}
public static IIcon getFluidTexture(Fluid fluid, boolean flowing) {
if (fluid == null) {
return null;
}
IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
if (icon == null) {
icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager()
.getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
}
return icon;
}
public static void setColorForFluidStack(FluidStack fluidstack) {
if (fluidstack == null) {
return;
}
int color = fluidstack.getFluid().getColor(fluidstack);
RenderUtil.setGLColorFromInt(color);
}
public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing) {
if (fluidStack == null) {
return null;
}
Fluid fluid = fluidStack.getFluid();
if (fluid == null) {
return null;
}
Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
int[] diplayLists = cache.get(fluid);
if (diplayLists != null) {
return diplayLists;
}
diplayLists = new int[DISPLAY_STAGES];
if (fluid.getBlock() != null) {
liquidBlock.baseBlock = fluid.getBlock();
} else {
liquidBlock.baseBlock = Blocks.water;
}
liquidBlock.texture = getFluidTexture(fluidStack, flowing);
cache.put(fluid, diplayLists);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_CULL_FACE);
for (int s = 0; s < DISPLAY_STAGES; ++s) {
diplayLists[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(diplayLists[s], GL11.GL_COMPILE);
liquidBlock.minX = 0.01f;
liquidBlock.minY = 0;
liquidBlock.minZ = 0.01f;
liquidBlock.maxX = 0.99f;
liquidBlock.maxY = Math.max(s, 1) / (float) DISPLAY_STAGES;
liquidBlock.maxZ = 0.99f;
RenderEntityBlock.INSTANCE.renderBlock(liquidBlock);
GL11.glEndList();
}
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
return diplayLists;
}
}
@@ -1,143 +0,0 @@
package com.glodblock.github.client.render.tank;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
public class ModelCertusTank extends ModelBase {
ModelRenderer Shape1;
public ModelCertusTank() {
this.textureWidth = 64;
this.textureHeight = 64;
this.Shape1 = new ModelRenderer(this, 0, 0);
this.Shape1.addBox(-7F, -8F, -7F, 14, 16, 14);
this.Shape1.setTextureSize(this.textureWidth, this.textureHeight);
this.Shape1.mirror = true;
setRotation(this.Shape1, 0F, 0F, 0F);
}
public void render(float f) {
this.Shape1.render(f);
}
public void renderFluid(TileEntity tileEntity, double x, double y, double z, RenderBlocks renderer) {
Tessellator tessellator = Tessellator.instance;
if (tileEntity != null
&& ((TileCertusQuartzTank) tileEntity).getTankInfo(ForgeDirection.UNKNOWN)[0].fluid != null) {
Fluid storedFluid = ((TileCertusQuartzTank) tileEntity).getRenderFluid();
float scale = ((TileCertusQuartzTank) tileEntity).getRenderScale();
if (storedFluid != null && scale > 0) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Block id = Block.getBlockById(FluidRegistry.WATER.getID());
IIcon fluidIcon = storedFluid.getIcon();
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
renderer.setRenderBounds(0.08F, 0.001F, 0.08F, 0.92, scale * 0.999F, 0.92F);
tessellator.setColorRGBA_F(
(storedFluid.getColor() >> 16 & 0xFF) / 255.0F,
(storedFluid.getColor() >> 8 & 0xFF) / 255.0F,
(storedFluid.getColor() & 0xFF) / 255.0F,
1.0F);
tessellator.setNormal(0.0F, -1F, 0.0F);
renderer.renderFaceYNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(id, x, y, z, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, -1F);
renderer.renderFaceZNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(id, x, y, z, fluidIcon);
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderer.renderFaceXNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(id, x, y, z, fluidIcon);
}
}
}
public void renderInnerBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) {
Tessellator tessellator = Tessellator.instance;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
tessellator.setBrightness(15728640);
boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank;
boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank;
int meta = 0;
if (tankUp && tankDown) meta = 3;
else if (tankUp) meta = 2;
else if (tankDown) meta = 1;
if (!tankUp) {
tessellator.setNormal(0, -1, 0);
renderer.renderFaceYNeg(block, x, y + 0.99F, z, block.getIcon(1, 0));
}
if (!tankDown) {
tessellator.setNormal(0, 1, 0);
renderer.renderFaceYPos(block, x, y - 0.99F, z, block.getIcon(0, 0));
}
IIcon sideIcon = block.getIcon(3, meta);
tessellator.setNormal(0, 0, -1);
renderer.renderFaceZNeg(block, x, y, z + 0.875F, sideIcon);
tessellator.setNormal(0, 0, 1);
renderer.renderFaceZPos(block, x, y, z - 0.875F, sideIcon);
tessellator.setNormal(-1, 0, 0);
renderer.renderFaceXNeg(block, x + 0.875F, y, z, sideIcon);
tessellator.setNormal(1, 0, 0);
renderer.renderFaceXPos(block, x - 0.875F, y, z, sideIcon);
GL11.glPopMatrix();
}
public void renderOuterBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) {
Tessellator tessellator = Tessellator.instance;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank;
boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank;
int meta = 0;
if (tankUp && tankDown) meta = 3;
else if (tankUp) meta = 2;
else if (tankDown) meta = 1;
if (!tankDown) {
tessellator.setNormal(0.0F, -1F, 0.0F);
renderer.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0));
}
if (!tankUp) {
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(block, x, y, z, block.getIcon(1, 0));
}
IIcon sideIcon = block.getIcon(3, meta);
tessellator.setNormal(0.0F, 0.0F, -1F);
renderer.renderFaceZNeg(block, x, y, z, sideIcon);
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(block, x, y, z, sideIcon);
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderer.renderFaceXNeg(block, x, y, z, sideIcon);
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(block, x, y, z, sideIcon);
GL11.glPopMatrix();
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}
@@ -1,169 +0,0 @@
package com.glodblock.github.client.render.tank;
import java.util.Arrays;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class RenderEntityBlock extends Render {
public static RenderEntityBlock INSTANCE = new RenderEntityBlock();
protected RenderBlocks renderBlocks;
private RenderEntityBlock() {
renderBlocks = field_147909_c;
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
throw new UnsupportedOperationException("Not supported yet.");
}
public static class RenderInfo {
public double minX = 0.0F;
public double minY = 0.0F;
public double minZ = 0.0F;
public double maxX = 1.0F;
public double maxY = 1.0F;
public double maxZ = 1.0F;
public Block baseBlock = Blocks.sand;
public IIcon texture = null;
public IIcon[] textureArray = null;
public boolean[] renderSide = new boolean[] { true, true, true, true, true, true };
public int light = -1;
public int brightness = -1;
public RenderInfo() {}
public RenderInfo(Block template, IIcon[] texture) {
this();
this.baseBlock = template;
this.textureArray = texture;
}
public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
this();
setBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
public void setSkyBlockLight(World world, int x, int y, int z, int light) {
this.brightness = world.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, x, y, z) << 16 | light;
}
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) {
return baseBlock.getMixedBrightnessForBlock(iblockaccess, i, j, k);
}
public final void setBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
this.minX = minX;
this.minY = minY;
this.minZ = minZ;
this.maxX = maxX;
this.maxY = maxY;
this.maxZ = maxZ;
}
public final void setRenderSingleSide(int side) {
Arrays.fill(renderSide, false);
renderSide[side] = true;
}
public final void setRenderAllSides() {
Arrays.fill(renderSide, true);
}
public void rotate() {
double temp = minX;
minX = minZ;
minZ = temp;
temp = maxX;
maxX = maxZ;
maxZ = temp;
}
public void reverseX() {
double temp = minX;
minX = 1 - maxX;
maxX = 1 - temp;
}
public void reverseZ() {
double temp = minZ;
minZ = 1 - maxZ;
maxZ = 1 - temp;
}
public IIcon getBlockTextureFromSide(int i) {
if (texture != null) {
return texture;
}
int index = i;
if (textureArray == null || textureArray.length == 0) {
return baseBlock.getBlockTextureFromSide(index);
} else {
if (index >= textureArray.length) {
index = 0;
}
return textureArray[index];
}
}
}
@Override
public void doRender(Entity entity, double x, double y, double z, float f, float f1) {
// NO-OP
}
public void renderBlock(RenderInfo info) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ);
if (info.light != -1) {
tessellator.setBrightness(info.light << 20 | info.light << 4);
} else if (info.brightness != -1) {
tessellator.setBrightness(info.brightness << 4);
}
if (info.renderSide[0]) {
tessellator.setNormal(0, -1, 0);
renderBlocks.renderFaceYNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(0));
}
if (info.renderSide[1]) {
tessellator.setNormal(0, 1, 0);
renderBlocks.renderFaceYPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(1));
}
if (info.renderSide[2]) {
tessellator.setNormal(0, 0, -1);
renderBlocks.renderFaceZNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(2));
}
if (info.renderSide[3]) {
tessellator.setNormal(0, 0, 1);
renderBlocks.renderFaceZPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(3));
}
if (info.renderSide[4]) {
tessellator.setNormal(-1, 0, 0);
renderBlocks.renderFaceXNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(4));
}
if (info.renderSide[5]) {
tessellator.setNormal(1, 0, 0);
renderBlocks.renderFaceXPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(5));
}
tessellator.draw();
}
}
@@ -1,63 +0,0 @@
package com.glodblock.github.client.textures;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public enum FCPartsTexture {
PartFluidTerminal_Bright("fluid_terminal_bright"),
PartFluidTerminal_Dark("fluid_terminal_dark"),
PartFluidTerminal_Colored("fluid_terminal_medium"),
PartFluidPatternTerminal_Bright("pattern_terminal_bright"),
PartFluidPatternTerminal_Dark("pattern_terminal_dark"),
PartFluidPatternTerminal_Colored("pattern_terminal_medium"),
PartLevelTerminal_Bright("level_terminal_bright"),
PartLevelTerminal_Dark("level_terminal_dark"),
PartLevelTerminal_Colored("level_terminal_medium"),
PartTerminalBroad("terminal_broad"),
PartFluidImportBus("fluid_import_face"),
PartFluidExportBus("fluid_export_face"),
PartFluidStorageBus("fluid_storage_bus"),
BlockFluidInterfaceAlternate_Arrow("fluid_interface_arrow"),
BlockInterfaceAlternate("fluid_interface_a"),
BlockInterface_Face("fluid_interface"),
PartFluidLevelEmitter("fluid_level_emitter"),
BlockLevelMaintainer("level_maintainer"),
BlockLevelMaintainer_Active("level_maintainer_active");
private final String name;
public net.minecraft.util.IIcon IIcon;
FCPartsTexture(final String name) {
this.name = name;
}
public static ResourceLocation GuiTexture(final String string) {
return null;
}
@SideOnly(Side.CLIENT)
public static IIcon getMissing() {
return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture))
.getAtlasSprite("missingno");
}
public String getName() {
return this.name;
}
public IIcon getIcon() {
return this.IIcon;
}
public void registerIcon(final TextureMap map) {
this.IIcon = map.registerIcon(NameConst.RES_KEY + this.name);
}
}
@@ -1,88 +0,0 @@
package com.glodblock.github.common;
import java.io.File;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.relauncher.FMLInjectionData;
public class Config {
private static final Configuration Config = new Configuration(
new File(new File((File) FMLInjectionData.data()[6], "config"), "ae2fc.cfg"));
public static boolean fluidCells;
public static boolean noFluidPacket;
public static boolean fluidIOBus;
public static boolean removeRecipe;
public static double portableCellBattery;
public static boolean fluidP2PInterface;
public static int packetSize;
public static int packetRate;
public static boolean replaceEC2;
public static int levelMaintainerMinTicks;
public static int levelMaintainerMaxTicks;
public static int reStockTime;
public static int magnetRange;
public static void run() {
loadCategory();
loadProperty();
}
private static void loadProperty() {
fluidCells = Config.getBoolean(
"Enable Fluid Storage Cell",
"Fluid Craft for AE2",
true,
"Enable this to generate the fluid storage cells. If you are playing with EC2, you can turn it off.");
noFluidPacket = Config.getBoolean(
"No Fluid Packet",
"Fluid Craft for AE2",
false,
"Enable this to make normal ME Interface can emit fluid with fluid pattern, like the ME Dual Interface.");
fluidIOBus = Config.getBoolean(
"Enable AE2FC's Fluid I/O Bus",
"Fluid Craft for AE2",
true,
"Enable this to add Fluid Import/Export Bus like EC2's one.");
fluidP2PInterface = Config.getBoolean(
"fluidP2PInterface",
"Fluid Craft for AE2",
true,
"Enable the P2P Tunnel - ME Dual Interface feature.");
removeRecipe = Config.getBoolean(
"Disable all recipes",
"Fluid Craft for AE2",
false,
"Disable all recipes, for quick tweaker.");
portableCellBattery = Config.get("Fluid Craft for AE2", "Portable Fluid Cell Battery Capacity", 20000D)
.getDouble();
packetSize = Config.get("Fluid Craft for AE2", "packetSize", 256, "Number of items to be sent per packet")
.getInt();
if (packetSize <= 0) packetSize = 256;
packetRate = Config
.get("Fluid Craft for AE2", "packetRate", 50, "Period at which packets are dispatched, in ms.")
.getInt();
if (packetRate <= 0) packetRate = 50;
replaceEC2 = Config.getBoolean(
"replaceEC2",
"Fluid Craft for AE2",
true,
"Set true to handle missing item mappings from EC2. Note to work properly, you must have all relevant parts.");
levelMaintainerMinTicks = Config.get("LevelMaintainer", "minTick", 5, "Number on ticks for minimal request")
.getInt();
levelMaintainerMaxTicks = Config.get("LevelMaintainer", "maxTick", 120, "Number on ticks for maximal request")
.getInt();
reStockTime = Config.get("UltraWireless", "reStockTime", 1000, "Time between restocks").getInt();
magnetRange = Config.get("UltraWireless", "magnetRange", 16, "Magnet pick up radius").getInt();
if (Config.hasChanged()) Config.save();
}
private static void loadCategory() {
Config.addCustomCategoryComment("Fluid Craft for AE2", "Settings for AE2FC.");
}
}
@@ -1,22 +0,0 @@
package com.glodblock.github.common.block;
import java.util.List;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public abstract class BaseBlockContainer extends BlockContainer {
public BaseBlockContainer(Material material) {
super(material);
}
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> toolTip,
boolean advancedToolTips) {}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -0,0 +1,38 @@
package com.glodblock.github.common.block;
import appeng.block.AEBaseTileBlock;
import com.glodblock.github.common.tile.TileBurette;
import com.glodblock.github.inventory.GuiType;
import com.glodblock.github.inventory.InventoryHandler;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockBurette extends AEBaseTileBlock {
public BlockBurette() {
super(Material.IRON);
setTileEntity(TileBurette.class);
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
EnumFacing facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
return super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ);
}
TileBurette tile = getTileEntity(world, pos);
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(player, world, pos, facing, GuiType.PRECISION_BURETTE);
}
return true;
}
return super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ);
}
}
@@ -1,264 +0,0 @@
package com.glodblock.github.common.block;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem;
import com.glodblock.github.common.item.ItemCertusQuartzTank;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
import appeng.api.implementations.items.IAEWrench;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegister<BlockCertusQuartzTank> {
IIcon breakIcon;
IIcon topIcon;
IIcon bottomIcon;
IIcon sideIcon;
IIcon sideMiddleIcon;
IIcon sideTopIcon;
IIcon sideBottomIcon;
public BlockCertusQuartzTank() {
super(Material.glass);
setBlockName(NameConst.BLOCK_CERTUS_QUARTZ_TANK);
setResistance(10.0F);
setHardness(2.0F);
setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
}
@Override
public boolean canRenderInPass(int pass) {
return true;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCertusQuartzTank();
}
public ItemStack getDropWithNBT(World world, int x, int y, int z) {
NBTTagCompound tileEntity = new NBTTagCompound();
TileEntity worldTE = world.getTileEntity(x, y, z);
if (worldTE instanceof TileCertusQuartzTank) {
ItemStack dropStack = new ItemStack(ItemAndBlockHolder.CERTUS_QUARTZ_TANK, 1);
((TileCertusQuartzTank) worldTE).writeToNBTWithoutCoords(tileEntity);
if (!tileEntity.hasKey("Empty")) {
dropStack.setTagCompound(new NBTTagCompound());
dropStack.stackTagCompound.setTag("tileEntity", tileEntity);
}
return dropStack;
}
return null;
}
@Override
public IIcon getIcon(int side, int meta) {
return switch (meta) {
case 1 -> this.sideTopIcon;
case 2 -> this.sideBottomIcon;
case 3 -> this.sideMiddleIcon;
default -> side == 0 ? this.bottomIcon : side == 1 ? this.topIcon : this.sideIcon;
};
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return getDropWithNBT(world, x, y, z);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileCertusQuartzTank tank) {
return tank.getFluidLightLevel();
}
return super.getLightValue(world, x, y, z);
}
@Override
public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int side, float offsetX,
float offsetY, float offsetZ) {
ItemStack itemInHand = player.inventory.getCurrentItem();
if (itemInHand == null || itemInHand.getItem() == null) {
return false;
}
// In case if we're holding a IFluidContainerItem which is also a block we'll just allow to place a block
// instead of trying to fill or drain it. In other cases we don't need to handle blocks either way
if (itemInHand.getItem() instanceof ItemBlock) {
return false;
}
if (player.isSneaking()) {
if (itemInHand.getItem() instanceof IAEWrench wrench && wrench.canWrench(itemInHand, player, x, y, z)) {
dropBlockAsItem(worldObj, x, y, z, getDropWithNBT(worldObj, x, y, z));
worldObj.setBlockToAir(x, y, z);
return true;
}
}
TileCertusQuartzTank tank = (TileCertusQuartzTank) worldObj.getTileEntity(x, y, z);
boolean isCreativeMode = player.capabilities.isCreativeMode;
if (FluidContainerRegistry.isFilledContainer(itemInHand)) {
// Fill the tank from the container in hand
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(itemInHand);
if (fluid == null) {
return false;
}
int amountFilled = tank.fill(ForgeDirection.UNKNOWN, fluid, true);
if (amountFilled > 0 && !isCreativeMode) {
ItemStack empty = FluidContainerRegistry.drainFluidContainer(itemInHand);
replaceItemInInventory(worldObj, player, itemInHand, empty);
}
return true;
} else if (FluidContainerRegistry.isEmptyContainer(itemInHand)) {
// Fill the container in hand from the tank
FluidStack available = tank.getTankInfo(true)[0].fluid;
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, itemInHand);
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(filled);
if (fluid == null) {
return false;
}
tank.drain(ForgeDirection.UNKNOWN, fluid.amount, true);
if (!isCreativeMode) {
replaceItemInInventory(worldObj, player, itemInHand, filled);
}
return true;
} else if (itemInHand.getItem() instanceof IFluidContainerItem) {
ItemStack singleContainerItem = itemInHand.copy();
singleContainerItem.stackSize = 1;
IFluidContainerItem fluidContainer = (IFluidContainerItem) singleContainerItem.getItem();
assert fluidContainer != null;
FluidStack fluid = fluidContainer.getFluid(itemInHand);
if (fluid != null && fluid.amount > 0) {
// Fill the tank from the container in hand
int filled = tank.fill(ForgeDirection.UNKNOWN, fluid, true);
if (filled > 0 && !isCreativeMode) {
fluidContainer.drain(singleContainerItem, filled, true);
replaceItemInInventory(worldObj, player, itemInHand, singleContainerItem);
}
} else {
// Fill the container in hand from the tank
int containerCapacity = fluidContainer.getCapacity(itemInHand);
FluidStack drained = tank.drain(ForgeDirection.UNKNOWN, containerCapacity, true);
if (drained != null && drained.amount > 0 && !isCreativeMode) {
fluidContainer.fill(singleContainerItem, drained, true);
replaceItemInInventory(worldObj, player, itemInHand, singleContainerItem);
}
}
return true;
}
return false;
}
private void replaceItemInInventory(World world, EntityPlayer player, ItemStack item, ItemStack replacement) {
if (item.stackSize > 1) {
item.stackSize--;
// This method meant to be called both from client and server side, and trying to drop an item
// from the client side would create a doubled ghost item, so we don't allow to do that
if (!player.inventory.addItemStackToInventory(replacement) && !world.isRemote) {
player.entityDropItem(replacement, 0);
}
} else {
player.inventory.setInventorySlotContents(player.inventory.currentItem, replacement);
}
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
if (stack != null && stack.hasTagCompound()) {
if (FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("tileEntity")) != null) list.add(
FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("tileEntity")).amount
+ "mB");
}
}
@Override
public void registerBlockIcons(IIconRegister iconregister) {
String folder = NameConst.RES_KEY + "certus_quartz_tank/";
this.breakIcon = iconregister.registerIcon(folder + "cube");
this.topIcon = iconregister.registerIcon(folder + "top");
this.bottomIcon = iconregister.registerIcon(folder + "bottom");
this.sideIcon = iconregister.registerIcon(folder + "side");
this.sideMiddleIcon = iconregister.registerIcon(folder + "side_mid");
this.sideTopIcon = iconregister.registerIcon(folder + "side_top");
this.sideBottomIcon = iconregister.registerIcon(folder + "side_bottom");
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public BlockCertusQuartzTank register() {
GameRegistry.registerBlock(this, ItemCertusQuartzTank.class, NameConst.BLOCK_CERTUS_QUARTZ_TANK);
GameRegistry.registerTileEntity(TileCertusQuartzTank.class, NameConst.BLOCK_CERTUS_QUARTZ_TANK);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int getComparatorInputOverride(World worldIn, int x, int y, int z, int side) {
TileEntity tileEntity = worldIn.getTileEntity(x, y, z);
if (tileEntity instanceof TileCertusQuartzTank tileCertusQuartzTank) {
FluidTankInfo info = tileCertusQuartzTank.getTankInfo(false)[0];
if (info.fluid != null) {
int nonEmptyBump = info.fluid.amount > 0 ? 1 : 0;
return (int) (14.0 * info.fluid.amount / info.capacity) + nonEmptyBump;
}
}
return 0;
}
}
Loaded 100 of 519 files, more files were not shown because too many files have changed in this diff. Show more