Compare commits

...
131 Commits
Author SHA1 Message Date
Martin Robertz 02f3ed037c Merge pull request #28 from asdflj/dev
add fluid terminal
2022-10-20 18:29:43 +02:00
asdflj 238fd317e4 add fluid terminal 2022-10-20 12:28:01 +08:00
Connor-Colenso 87d7f699e8 Merge pull request #27 from GTNewHorizons/formatted-cell-tooltip
Add filter tooltip to partitioned storage cells
2022-10-10 06:08:18 +01:00
Matej Dipčár 7eb22f8720 Add filter tooltip to partitioned storage cells 2022-10-10 06:17:04 +02:00
Martin Robertz 1a2ba79745 Merge pull request #26 from GTNewHorizons/fix
fix AIOOBE in amount set packet
2022-10-08 19:11:56 +02:00
GlodBlock e6b4917b64 fix AIOOBE 2022-10-09 00:11:03 +08:00
Martin Robertz c29f50214e Merge pull request #25 from GTNewHorizons/fix
fix wrong invert trigger
2022-10-08 17:01:23 +02:00
GlodBlock b2f07d2a02 fix wrong invert trigger 2022-10-08 20:20:11 +08:00
Martin Robertz d8140da431 Merge pull request #23 from GTNewHorizons/fix
fix wrong bytes display when ingrentent isn't enough and a possible d…
2022-10-07 21:38:14 +02:00
Yang Xizhi 47dce05cfa Merge branch 'master' into fix 2022-10-06 23:10:15 +08:00
GlodBlock ab4acbe5eb fix wrong bytes display when ingrentent isn't enough and a possible dupe from fluid packet decoder 2022-10-06 23:07:26 +08:00
Martin Robertz 587fd70876 Merge pull request #22 from GTNewHorizons/craftin-card
crafting card support for fluid export bus
2022-10-04 12:14:07 +02:00
GlodBlock d820b68a7d uh 2022-10-03 20:04:19 +08:00
GlodBlock bce6e35675 crafting card support for fluid export bus 2022-10-03 19:46:57 +08:00
Martin Robertz b6b9f71677 Merge pull request #21 from GTNewHorizons/eio-compact-fix
eio conduct compact and fix transfer item and fluid in different dirs
2022-10-01 12:56:28 +02:00
Martin Robertz 63daee5e56 Merge pull request #20 from asdflj/master
Update and fix some bug
2022-10-01 10:49:50 +02:00
GlodBlock c6f7c17854 eio conduct compact and fix transfer item and fluid in differentdirections 2022-10-01 14:44:34 +08:00
asdflj 61ac42d270 fix MouseRegionManager can't display tooltip.
when ingredient buffer outputting fluid, the current slot is used continuously,not from first slot to start output.
2022-09-30 16:55:11 +08:00
GlodBlock 989cd173fb more sanity asm 2022-09-29 21:42:27 +08:00
asdflj 8cafbceed7 add crafting preview screen support nei bookmark 2022-09-29 19:50:22 +08:00
Martin Robertz 292a70ab6e Merge pull request #18 from asdflj/master
me dual interface add insert mode
2022-09-22 17:25:49 +02:00
Martin Robertz a575e58ac7 Merge pull request #19 from GTNewHorizons/packet
add obs check
2022-09-21 18:16:09 +02:00
GlodBlock b6e7a2f570 add obs check 2022-09-21 22:00:40 +08:00
Martin Robertz 69418714dd Merge pull request #17 from GTNewHorizons/packet
asm packet return to crafting inventory
2022-09-21 09:02:35 +02:00
GlodBlock de89faed70 . 2022-09-21 13:48:32 +08:00
asdflj 2b8c983e8a me dual interface add insert mode 2022-09-21 12:32:45 +08:00
GlodBlock 733774e7a3 asm packet return to crafting inventory 2022-09-21 00:04:41 +08:00
Martin Robertz a63add7bff Merge pull request #16 from asdflj/master
update
2022-09-17 14:17:02 +02:00
zy f6c10901d9 update
add recipe encode pattern crafting blank pattern
add control shift click to encode whole stack
fix import export nane display error
2022-09-17 20:05:30 +08:00
zy c313f51750 update
add recipe encode pattern crafting blank pattern
add control shift click to encode whole stack
fix import export nane display error
2022-09-17 19:05:31 +08:00
Martin Robertz 1d4acb8076 Merge pull request #15 from GTNewHorizons/fix/rename
Display dual interface custom name
2022-09-08 12:08:15 +02:00
DianeXD bdf3ab1a56 Display dual interface custom name 2022-09-07 21:18:19 +08:00
Martin Robertz b51f786f53 Merge pull request #14 from asdflj/master
update zh lang and fix import export bus shift click transfer upgrade card
2022-09-04 17:49:39 +02:00
asdflj 6d5c8ca435 Update zh_CN.lang 2022-09-04 19:03:33 +08:00
zy 9d6c0b4c56 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/main/java/com/glodblock/github/client/gui/container/ContainerFluidConfigurable.java
2022-09-03 20:20:49 +08:00
zy 49181f3df6 add fluid bus shift click transfer upgrade card into the slot 2022-09-03 20:19:38 +08:00
zy 92e5c4adc7 add fluid bus shift click transfer upgrade card into the slot 2022-09-03 18:55:42 +08:00
asdflj 409e1f2a8d Merge branch 'GTNewHorizons:master' into master 2022-09-03 03:47:32 -05:00
asdflj 15c056556d update zh_ch lang 2022-09-02 10:44:29 +08:00
Martin Robertz 76f2ddf18e Merge pull request #13 from GTNewHorizons/overflow
fix int overflow in fluid storage cell
2022-09-01 11:32:26 +02:00
GlodBlock 6a69f807f1 update ec2 dep 2022-08-31 23:33:11 +08:00
GlodBlock b9d82c5da5 fix oversight in nbt load 2022-08-31 23:32:46 +08:00
GlodBlock 72270a3f64 use long for data storage 2022-08-31 23:06:09 +08:00
Yang Xizhi 89ca4b8313 fix oversight
fix https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11138
2022-08-27 17:42:26 +08:00
Martin Robertz 52031271b4 Merge pull request #12 from GTNewHorizons/oc
fix oc driver register crash
2022-08-23 08:20:11 +02:00
GlodBlock 88ccb54fe3 fix oc driver register crash 2022-08-23 10:07:01 +08:00
Martin Robertz bba4eb14cc Merge pull request #11 from GTNewHorizons/render-fix
fix render npe from certain liquids
2022-08-22 10:53:54 +02:00
GlodBlock de3715cbf3 subnet fluid check 2022-08-22 15:11:50 +08:00
GlodBlock acf8ab44d7 remove unnecessary update event 2022-08-22 14:44:46 +08:00
GlodBlock c7925b2b6c fix npe from drops render 2022-08-22 14:38:43 +08:00
Martin Robertz 72c2673768 Merge pull request #10 from GTNewHorizons/GlodBlock-patch-1
fix crash when clicking priority button in dual interface
2022-08-20 09:51:36 +02:00
Yang Xizhi a0e6277a3b fix crash when clicking priority button in dual interface
who adds the 10000 button?
2022-08-20 08:28:30 +08:00
Martin Robertz df5ee936ce Merge pull request #9 from vfyjxf/master
Allows the use of the middle mouse button to modify the number of items in the pattern.
2022-08-14 12:09:57 +02:00
Martin Robertz 19d6bb119c Merge pull request #8 from Runakai1/Terminal
Terminal
2022-08-14 12:09:24 +02:00
Runakai1 05b8538154 added another nullcheck 2022-08-14 11:16:48 +02:00
vfyjxf 48c783dd25 remove useless methods 2022-08-14 17:16:26 +08:00
Runakai1 3f15f9524b Added nullcheck 2022-08-14 11:12:13 +02:00
vfyjxf f53db65b88 Fix build failure 2022-08-14 13:31:44 +08:00
Runakai1 539538d551 Stuff Changed 2022-08-13 19:09:15 +02:00
vfyjxf dbbaea9235 Allows the use of the middle mouse button to modify the number of items in the pattern. 2022-08-14 00:44:55 +08:00
Runakai1 13a23165c2 removed unnecessary var 2022-08-13 16:22:19 +02:00
Runakai1 69fe6b2950 Removed unimportant imports 2022-08-13 15:57:26 +02:00
Runakai1 aff48957cd Merge branch 'Terminal' of https://github.com/Runakai1/AE2FluidCraft-Rework into Terminal 2022-08-13 15:44:24 +02:00
Runakai1 b3f3ecfe2e Made button functional added icon + proper functionality 2022-08-13 15:41:55 +02:00
Runakai1 2fc407ce61 Changed way to see if item is a fluid display 2022-08-13 12:25:37 +02:00
Alexandre Tardif 9834066b4b Button works! 2022-08-13 12:25:37 +02:00
Runakai1 6aa1a877e5 Test
Test
2022-08-13 12:24:07 +02:00
Runakai1 ae7de51dbf Changed way to see if item is a fluid display 2022-08-13 11:56:51 +02:00
Alexandre Tardif 4ec705dd74 Button works! 2022-08-12 18:41:48 -04:00
Runakai1 b51bff6772 Test
Test
2022-08-12 23:29:20 +02:00
Martin Robertz 1998750489 Merge pull request #7 from GlodBlock/npe
fix npe from getItem()
2022-08-05 21:08:45 +07:00
GlodBlock 220eb8016a fix npe from getitem 2022-08-05 21:13:42 +08:00
Martin Robertz a27a6f1609 Merge pull request #6 from GlodBlock/bugfix
fix drops leak to item cell when discretizer go offline
2022-08-01 14:50:45 +07:00
Yang Xizhi d91991482a Merge branch 'master' into bugfix 2022-08-01 14:57:29 +08:00
Yang Xizhi d7d22c1a3e Merge pull request #35 from GlodBlock/bugfix
fix drops leak to item cell when discretizer go offline
2022-08-01 14:53:43 +08:00
GlodBlock e8825d74e7 fix drops leak to item cell when discretizer go offline 2022-08-01 14:52:57 +08:00
Yang Xizhi 0937feb979 comment out the problemaic code
it is more tricky than me thougt...
2022-07-31 22:17:54 +08:00
Martin Robertz 8373bae017 Merge branch 'GlodBlock:1.7.10' into master 2022-07-31 13:25:23 +07:00
Martin Robertz 38accb20fb Merge pull request #5 from GlodBlock/upstream
upstream
2022-07-31 13:25:12 +07:00
Yang Xizhi c961a5d922 Merge pull request #34 from GlodBlock/bugfix
Bugfix
2022-07-30 22:36:09 +08:00
Yang Xizhi 63d12aa759 Merge branch 'upstream' into bugfix 2022-07-30 22:36:03 +08:00
Yang Xizhi 2b94b20e2e Merge pull request #33 from GlodBlock/bugfix
fix 4096k int overflow and drops
2022-07-30 22:33:36 +08:00
GlodBlock ec9f55d17a fix 4096k int overflow and drops 2022-07-30 22:32:42 +08:00
GlodBlock 3e8c507556 clean up 2022-07-30 19:03:37 +08:00
GlodBlock dc6445bb6e check nei 2022-07-29 22:10:58 +08:00
GlodBlock 510bd94c5c add ic2 nei support 2022-07-29 22:07:05 +08:00
Yang Xizhi 5ee263e9de Merge pull request #32 from GlodBlock/1.7.10
upstreamfix
2022-07-29 20:44:20 +08:00
GlodBlock e8133a8522 ignore stack size 0 2022-07-29 20:39:34 +08:00
GlodBlock 411ec67624 wwwaaaaahhh 2022-07-29 17:36:07 +08:00
GlodBlock 26bc19c207 fix craft mode 2022-07-29 17:24:59 +08:00
Yang Xizhi e241b75065 Merge pull request #31 from GlodBlock/fixstream
fix update
2022-07-27 23:29:54 +08:00
Yang Xizhi b97a0f6126 Merge branch 'upstream' into fixstream 2022-07-27 23:29:46 +08:00
GlodBlock 3d2df578a6 make dual interface use the same adpator like normal one 2022-07-27 22:23:39 +08:00
GlodBlock ea9ba2c4cc fix cell byte calulation 2022-07-26 22:05:48 +08:00
GlodBlock 56d81eef56 move block loader to postinit 2022-07-25 22:08:34 +08:00
Yang Xizhi 9fee31d784 Update GregTech5RecipeExtractor.java 2022-07-24 19:46:26 +08:00
Yang Xizhi 079e5e34c4 Merge branch 'master' into upstream 2022-07-24 19:40:51 +08:00
GlodBlock 3ebf64f38b fix wct display drops 2022-07-24 18:29:46 +08:00
GlodBlock 736a4b2051 combine button 2022-07-24 18:00:10 +08:00
GlodBlock 5747b4535b clean up reflection 2022-07-22 19:18:13 +08:00
GlodBlock 3c128450b5 creative tabs 2022-07-22 12:10:04 +08:00
Jason Mitchell 76eeeb1be9 [ci skip] Migrate github actions to GTNH-Actions-Workflows 2022-07-16 10:36:56 -07:00
Yang Xizhi 8cd24b9a3b Merge pull request #29 from mczph/1.7.10
Update zh_cn.lang 1.7.10
2022-07-15 15:48:57 +08:00
mczph f40c6477de Update zh_CN.lang 2022-07-15 15:45:04 +08:00
GlodBlock bc32f7743e update readme 2022-07-15 13:15:36 +08:00
mczph 70f9ffefc3 Update zh_CN.lang 2022-07-15 12:11:42 +08:00
mczph 6cf27b1ba5 Add files via upload 2022-07-15 12:07:11 +08:00
GlodBlock 35f2dd4073 add larger buffer 2022-07-13 21:16:19 +08:00
GlodBlock 61cdd8c487 black essentia gas from ThE 2022-07-13 20:05:14 +08:00
Martin Robertz 43fe8323ff Merge pull request #3 from GlodBlock/upstream
upstream
2022-07-12 08:03:49 +07:00
Yang Xizhi 932bb9eadc Merge branch 'master' into upstream 2022-07-12 00:02:20 +08:00
GlodBlock f39548d97b remove the origin hacky shit 2022-07-11 23:53:15 +08:00
Martin Robertz c5a75cf770 Merge pull request #2 from DianeXD/master
Adapt to gtnh version and add gtpp support
2022-07-09 17:47:17 +07:00
GlodBlock c9ed833e59 optimize tick a bit 2022-07-09 18:21:17 +08:00
DianeXD f08a6ca75c Adapt to gtnh version and add gtpp support 2022-07-09 18:15:23 +08:00
Martin Robertz 7c929f912e Merge pull request #1 from DianeXD/master
Update pattern terminal
2022-07-09 15:45:24 +07:00
DianeXD e3f02860e8 Update pattern terminal
Basically the same as this pr
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial/pull/143
2022-07-09 15:15:42 +08:00
GlodBlock 07b03d1ef1 fix power drain 2022-07-06 13:22:54 +08:00
GlodBlock af42494561 revert the energy consumption when insert/extract fluid 2022-07-06 11:25:44 +08:00
GlodBlock e8b28010b4 fix dual part 2022-07-01 12:03:50 +08:00
GlodBlock 3e5563cbb4 dep 2022-06-30 20:34:03 +08:00
GlodBlock 68bb02b171 recipe for oc pattern editor 2022-06-30 20:27:19 +08:00
GlodBlock e38869f07d ec2 style output rule and oc integration 2022-06-30 19:52:58 +08:00
GlodBlock 19f9dee682 finish the fluid interface 2022-06-25 08:30:30 +08:00
GlodBlock 475842d115 1.12 fluid interface style 2022-06-23 23:54:49 +08:00
Martin Robertz 594fbd7f69 Merge branch 'GlodBlock:1.7.10' into master 2022-06-22 10:05:22 +02:00
GlodBlock 0845c25190 remove unnecessary null fail 2022-06-21 21:12:30 +08:00
GlodBlock bb600eed3f imp inventory for decoder 2022-06-18 17:18:24 +08:00
GlodBlock e1213b2d5a small clean up 2022-06-13 10:36:41 +08:00
GlodBlock 12565b1389 fluid display 2022-06-13 10:24:38 +08:00
GlodBlock 213b43d213 allow code fluid container 2022-06-12 23:30:30 +08:00
146 changed files with 7714 additions and 952 deletions

No files matched your search

-9
View File
@@ -1,9 +0,0 @@
directory="run/crash-reports"
if [ -d $directory ]; then
echo "Crash reports detected:"
cat $directory/*
exit 1
else
echo "No crash reports detected"
exit 0
fi
+2 -34
View File
@@ -1,5 +1,3 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Build and test
@@ -11,35 +9,5 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Run server for 1 minute
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout 60 ./gradlew runServer || true
- name: Test no crashes happend
run: |
chmod +x .github/scripts/test-no-crash-reports.sh
.github/scripts/test-no-crash-reports.sh
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
+7 -44
View File
@@ -1,51 +1,14 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Release tagged build
on:
push:
tags:
- '*'
tags: [ '*' ]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Release under current tag
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
title: "${{ env.RELEASE_VERSION }}"
files: build/libs/*.jar
- name: Publish to Maven
run: ./gradlew publish
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
-3
View File
@@ -1,3 +0,0 @@
# Any Github changes require admin approval
/.github/** @GTNewHorizons/admin
+2 -40
View File
@@ -40,46 +40,8 @@ Unofficial AE2([PAE2](https://www.curseforge.com/minecraft/mc-mods/ae2-extended-
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.
## How to Use It
https://github.com/GlodBlock/AE2FluidCraft-Rework/wiki
## Credited Works
+17 -10
View File
@@ -1,19 +1,26 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.12-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-75-GTNH:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.10-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-116-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:ExtraCells2:2.5.9:dev') {transitive = false}
compile("com.github.GTNewHorizons:ForestryMC:4.4.4:dev")
compile('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false }
compile("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.2:dev")
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev")
compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev")
compileOnly('com.github.GTNewHorizons:ForestryMC:4.4.7:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.27:dev')
compileOnly('com.github.GTNewHorizons:EnderCore:0.2.6:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
compileOnly('com.github.GTNewHorizons:StructureLib:1.0.15:dev')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') {transitive = false}
compileOnly("com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev") {transitive = false}
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') { transitive = false }
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.19-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.29:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.49:dev') {transitive = false}
runtime('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
}
+1 -1
View File
@@ -39,7 +39,7 @@ apiPackage =
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
accessTransformersFile =
accessTransformersFile = ae2fc_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
@@ -4,6 +4,7 @@ import appeng.api.AEApi;
import appeng.api.config.Upgrades;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.FluidCellHandler;
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.loader.ItemAndBlockHolder;
@@ -20,7 +21,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@Mod(modid = FluidCraft.MODID, version = FluidCraft.VERSION, name = FluidCraft.MODNAME)
@Mod(modid = FluidCraft.MODID, version = FluidCraft.VERSION, name = FluidCraft.MODNAME, dependencies = "required-after:appliedenergistics2")
public class FluidCraft {
public static final String MODID = "GRADLETOKEN_MODID";
@@ -43,8 +44,9 @@ public class FluidCraft {
@Mod.EventHandler
public static void init(FMLInitializationEvent event) {
ModAndClassUtil.init();
AEApi.instance().registries().cell().addCellHandler(new FluidCellHandler());
ItemAndBlockHolder.loadSetting();
if (ModAndClassUtil.OC) {
OCDriverInit.run();
}
proxy.init(event);
}
@@ -52,6 +54,9 @@ public class FluidCraft {
public static void postInit(FMLPostInitializationEvent event) {
NetworkRegistry.INSTANCE.registerGuiHandler(FluidCraft.INSTANCE, new InventoryHandler());
AEApi.instance().registries().cell().addCellHandler(new FluidCellHandler());
ItemAndBlockHolder.loadSetting();
if (!Config.removeRecipe) {
(new RecipeLoader()).run();
}
@@ -70,6 +75,7 @@ public class FluidCraft {
Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 1 );
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 4 );
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 4 );
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1 );
}
proxy.postInit(event);
@@ -11,8 +11,6 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainer;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
@@ -30,7 +28,7 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
private static final String CRAFTMODE_CRFTING = "1";
private static final String CRAFTMODE_PROCESSING = "0";
public final FCBasePartContainer container;
public FCBasePartContainer container;
private GuiTabButton tabCraftButton;
private GuiTabButton tabProcessButton;
@@ -40,11 +38,14 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
private GuiImgButton clearBtn;
private GuiImgButton doubleBtn;
private GuiFCImgButton combineEnableBtn;
private GuiFCImgButton combineDisableBtn;
public GuiBaseFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( inventoryPlayer, te, new FCBasePartContainer( inventoryPlayer, te ) );
this.container = (FCBasePartContainer) this.inventorySlots;
Ae2ReflectClient.setReservedSpace(this, 81);
setReservedSpace(81);
}
@Override
@@ -58,7 +59,7 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
}
else if( this.encodeBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Encode", isShiftKeyDown() ? "2" : "1" ) );
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0) ));
}
else if( this.clearBtn == btn )
{
@@ -68,6 +69,10 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
}
else if( this.combineDisableBtn == btn || this.combineEnableBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Combine", this.combineDisableBtn == btn ? "1" : "0" ) );
}
else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn)
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") );
@@ -100,11 +105,22 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE );
this.buttonList.add( this.encodeBtn );
int combineLeft = 74;
if (ModAndClassUtil.isDoubleButton) {
this.doubleBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE );
this.doubleBtn.setHalfSize( true );
this.buttonList.add( this.doubleBtn );
combineLeft = 84;
}
this.combineEnableBtn = new GuiFCImgButton( this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "FORCE_COMBINE", "DO_COMBINE" );
this.combineEnableBtn.setHalfSize( true );
this.buttonList.add( this.combineEnableBtn );
this.combineDisableBtn = new GuiFCImgButton( this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "NOT_COMBINE", "DONT_COMBINE" );
this.combineDisableBtn.setHalfSize( true );
this.buttonList.add( this.combineDisableBtn );
}
@Override
@@ -136,8 +152,27 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
this.substitutionsDisabledBtn.visible = true;
}
if (!this.container.isCraftingMode())
{
if ( this.container.combine )
{
this.combineEnableBtn.visible = true;
this.combineDisableBtn.visible = false;
}
else
{
this.combineEnableBtn.visible = false;
this.combineDisableBtn.visible = true;
}
}
else
{
this.combineEnableBtn.visible = false;
this.combineDisableBtn.visible = false;
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - Ae2ReflectClient.getReservedSpace(this), 4210752 );
this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752 );
}
@Override
@@ -2,44 +2,53 @@ package com.glodblock.github.client.gui;
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.PatternSlotConfig;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.container.slot.AppEngSlot;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainerEx;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
private static final String SUBSITUTION_DISABLE = "0";
private static final String SUBSITUTION_ENABLE = "1";
private static final String CRAFTMODE_CRFTING = "1";
private static final String CRAFTMODE_PROCESSING = "0";
private static final String PRIORITY_DISABLE = "0";
private static final String PRIORITY_ENABLE = "1";
public FCBasePartContainerEx container;
private GuiImgButton substitutionsEnabledBtn;
private GuiImgButton substitutionsDisabledBtn;
private GuiFCImgButton fluidPrioritizedEnabledBtn;
private GuiFCImgButton fluidPrioritizedDisabledBtn;
private GuiImgButton encodeBtn;
private GuiImgButton invertBtn;
private GuiImgButton clearBtn;
private GuiImgButton doubleBtn;
private GuiFCImgButton combineEnableBtn;
private GuiFCImgButton combineDisableBtn;
private final GuiScrollbar processingScrollBar = new GuiScrollbar();
public GuiBaseFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( inventoryPlayer, te, new FCBasePartContainerEx( inventoryPlayer, te ) );
this.container = (FCBasePartContainerEx) this.inventorySlots;
Ae2ReflectClient.setReservedSpace(this, 81);
setReservedSpace(81);
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
@Override
@@ -49,19 +58,31 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
if( this.encodeBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Encode", isShiftKeyDown() ? "2" : "1" ) );
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Encode",(isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)) );
}
else if( this.clearBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Clear", "1" ) );
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Clear", "1" ) );
}
else if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
}
else if( this.fluidPrioritizedEnabledBtn == btn || this.fluidPrioritizedDisabledBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Prioritize", container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE ) );
}
else if( this.invertBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Invert", container.inverted ? "0" : "1" ) );
}
else if( this.combineDisableBtn == btn || this.combineEnableBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Combine", this.combineDisableBtn == btn ? "1" : "0" ) );
}
else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn)
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") );
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") );
}
}
@@ -79,6 +100,18 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
this.substitutionsDisabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsDisabledBtn );
this.fluidPrioritizedEnabledBtn = new GuiFCImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 143, "FORCE_PRIO", "DO_PRIO" );
this.fluidPrioritizedEnabledBtn.setHalfSize( true );
this.buttonList.add( this.fluidPrioritizedEnabledBtn );
this.fluidPrioritizedDisabledBtn = new GuiFCImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 143, "NOT_PRIO", "DONT_PRIO" );
this.fluidPrioritizedDisabledBtn.setHalfSize( true );
this.buttonList.add( this.fluidPrioritizedDisabledBtn );
invertBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 153, Settings.ACTIONS, container.inverted ? PatternSlotConfig.C_4_16 : PatternSlotConfig.C_16_4);
invertBtn.setHalfSize( true );
this.buttonList.add( this.invertBtn );
this.clearBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
this.clearBtn.setHalfSize( true );
this.buttonList.add( this.clearBtn );
@@ -91,6 +124,16 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
this.doubleBtn.setHalfSize( true );
this.buttonList.add( this.doubleBtn );
}
this.combineEnableBtn = new GuiFCImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 143, "FORCE_COMBINE", "DO_COMBINE" );
this.combineEnableBtn.setHalfSize( true );
this.buttonList.add( this.combineEnableBtn );
this.combineDisableBtn = new GuiFCImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 143, "NOT_COMBINE", "DONT_COMBINE" );
this.combineDisableBtn.setHalfSize( true );
this.buttonList.add( this.combineDisableBtn );
processingScrollBar.setTop(this.ySize - 164);
}
@Override
@@ -109,15 +152,37 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
this.substitutionsEnabledBtn.visible = false;
this.substitutionsDisabledBtn.visible = true;
}
if( this.container.prioritize )
{
this.fluidPrioritizedEnabledBtn.visible = false;
this.fluidPrioritizedDisabledBtn.visible = true;
}
else
{
this.fluidPrioritizedEnabledBtn.visible = true;
this.fluidPrioritizedDisabledBtn.visible = false;
}
if ( this.container.combine )
{
this.combineEnableBtn.visible = true;
this.combineDisableBtn.visible = false;
}
else
{
this.combineEnableBtn.visible = false;
this.combineDisableBtn.visible = true;
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString( StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - Ae2ReflectClient.getReservedSpace(this), 4210752 );
this.fontRendererObj.drawString( StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752 );
this.processingScrollBar.draw(this);
}
@Override
protected String getBackground()
{
return "gui/pattern3.png";
return container.inverted ? "gui/pattern4.png" : "gui/pattern3.png";
}
@Override
@@ -133,4 +198,93 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
}
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
if (container.substitute) {
substitutionsEnabledBtn.visible = true;
substitutionsDisabledBtn.visible = false;
} else {
substitutionsEnabledBtn.visible = false;
substitutionsDisabledBtn.visible = true;
}
if (container.prioritize) {
fluidPrioritizedEnabledBtn.visible = true;
fluidPrioritizedDisabledBtn.visible = false;
} else {
fluidPrioritizedEnabledBtn.visible = false;
fluidPrioritizedDisabledBtn.visible = true;
}
final int offset = container.inverted? 18 * -3: 0;
substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
substitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedEnabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedDisabledBtn.xPosition = this.guiLeft + 97 + offset;
doubleBtn.xPosition = this.guiLeft + 97 + offset;
clearBtn.xPosition = this.guiLeft + 87 + offset;
invertBtn.xPosition = this.guiLeft + 87 + offset;
combineEnableBtn.xPosition = this.guiLeft + 87 + offset;
combineDisableBtn.xPosition = this.guiLeft + 87 + offset;
processingScrollBar.setCurrentScroll(container.activePage);
super.drawScreen(mouseX, mouseY, btn);
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn )
{
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop);
super.mouseClicked(xCoord, yCoord, btn);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
protected void mouseClickMove( final int x, final int y, final int c, final long d )
{
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop );
super.mouseClickMove(x, y, c, d);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
public void handleMouseInput()
{
super.handleMouseInput();
final int wheel = Mouse.getEventDWheel();
if (wheel != 0) {
final int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
final int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight;
if (this.processingScrollBar.contains(x - this.guiLeft, y - this.guiTop)) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.wheel(wheel);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
}
}
private void changeActivePage()
{
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.ActivePage", String.valueOf(this.processingScrollBar.getCurrentScroll())));
}
}
@@ -0,0 +1,55 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.ITerminalHost;
import appeng.container.slot.AppEngSlot;
import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiBaseFluidTerminal extends GuiFCBaseFluidMonitor {
protected EntityPlayer player;
public GuiBaseFluidTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te, FCBaseFluidMonitorContain c) {
super(inventoryPlayer, te, new FCBaseFluidMonitorContain(inventoryPlayer, te));
player = inventoryPlayer.player;
}
@Override
protected String getBackground() {
return "gui/terminal.png";
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
}
@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,141 @@
package com.glodblock.github.client.gui;
import appeng.api.config.InsertionMode;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerInterface;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.helpers.IInterfaceHost;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Mouse;
public class GuiDualInterface extends GuiUpgradeable {
private GuiTabButton priority;
private GuiTabButton switcher;
private GuiImgButton BlockMode;
private GuiToggleButton interfaceMode;
private GuiImgButton insertionMode;
private final IInterfaceHost host;
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
super(new ContainerInterface(inventoryPlayer, te));
this.host = te;
this.ySize = 211;
}
@Override
@SuppressWarnings("unchecked")
protected void addButtons()
{
this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender );
this.buttonList.add( this.priority );
this.switcher = new GuiTabButton( this.guiLeft + 132, this.guiTop, host instanceof PartFluidInterface ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.buttonList.add( this.switcher );
this.BlockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
this.buttonList.add( this.BlockMode );
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal() );
this.buttonList.add( this.interfaceMode );
this.insertionMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 44, Settings.INSERTION_MODE, InsertionMode.DEFAULT );
this.buttonList.add( this.insertionMode );
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
if( this.BlockMode != null )
{
this.BlockMode.set( ( (ContainerInterface) this.cvb ).getBlockingMode() );
}
if( this.interfaceMode != null )
{
this.interfaceMode.setState( ( (ContainerInterface) this.cvb ).getInterfaceTerminalMode() == YesNo.YES );
}
if( this.insertionMode != null )
{
this.insertionMode.set( ( (ContainerInterface) this.cvb ).getInsertionMode());
}
this.fontRendererObj.drawString( getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)), 8, 6, 4210752 );
}
@Override
protected String getBackground()
{
if (!ModAndClassUtil.isBigInterface)
return "guis/interface.png";
switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled())
{
case 1:
return "guis/interface2.png";
case 2:
return "guis/interface3.png";
case 3:
return "guis/interface4.png";
}
return "guis/interface.png";
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
final boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.priority )
{
if (host instanceof TileFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY));
}
else if(host instanceof PartFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART));
}
}
if( btn == this.switcher )
{
if (host instanceof TileFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
}
else if (host instanceof PartFluidInterface) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART));
}
}
if( btn == this.interfaceMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
}
if( btn == this.BlockMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) );
}
if( btn == this.insertionMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.insertionMode.getSetting(), backwards ) );
}
}
}
@@ -0,0 +1,689 @@
package com.glodblock.github.client.gui;
import appeng.api.config.*;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME;
import appeng.container.AEBaseContainer;
import appeng.container.slot.*;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain;
import com.glodblock.github.client.me.FluidRepo;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.util.List;
import static com.glodblock.github.common.item.ItemFluidDrop.newStack1;
public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost {
public static int craftingGridOffsetX;
public static int craftingGridOffsetY;
private static String memoryText = "";
private final FluidRepo repo;
private final int offsetX = 9;
private final int lowerTextureOffset = 0;
private final boolean viewCell;
private final ItemStack[] myCurrentViewCells = new ItemStack[5];
public IConfigManager configSrc;
public FCBaseFluidMonitorContain monitorableContainer;
public GuiTabButton craftingStatusBtn;
private GuiImgButton craftingStatusImgBtn;
private FCGuiTextField searchField;
private int perRow = 9;
private int reservedSpace = 0;
private boolean customSortOrder = true;
private int rows = 0;
private int maxRows = Integer.MAX_VALUE;
private int standardSize;
private GuiImgButton ViewBox;
private GuiImgButton SortByBox;
private GuiImgButton SortDirBox;
private GuiImgButton searchBoxSettings;
private GuiImgButton terminalStyleBox;
private GuiImgButton searchStringSave;
public GuiFCBaseFluidMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseFluidMonitorContain c) {
super(c);
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.repo = new FluidRepo(scrollbar, this);
this.xSize = 195;
this.ySize = 204;
this.standardSize = this.xSize;
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
(this.monitorableContainer = (FCBaseFluidMonitorContain) this.inventorySlots).setGui(this);
this.viewCell = te instanceof IViewCellStorage;
}
public void postUpdate(final List<IAEFluidStack> list) {
for (final IAEFluidStack is : list) {
IAEItemStack stack = AEItemStack.create(newStack1(is.getFluidStack()));
stack.setStackSize(is.getStackSize());
this.repo.postUpdate(stack);
}
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar() {
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6));
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
}
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (btn == this.searchBoxSettings) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (ModAndClassUtil.isSaveText && btn == this.searchStringSave) {
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
} else {
try {
NetworkHandler.instance.sendToServer(new PacketValueConfig(iBtn.getSetting().name(), next.name()));
} catch (final IOException e) {
AELog.debug(e);
}
}
iBtn.set(next);
if (next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class) {
this.reinitalize();
}
}
}
}
private void reinitalize() {
this.buttonList.clear();
this.initGui();
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
Keyboard.enableRepeatEvents(true);
this.maxRows = this.getMaxRows();
this.perRow = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL ? 9 : 9 + ((this.width - this.standardSize) / 18);
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEI = hasNEI ? 0 : 0;
int top = hasNEI ? 22 : 0;
final int magicNumber = 114 + 1;
final int extraSpace = this.height - magicNumber - NEI - top - this.reservedSpace;
this.rows = (int) Math.floor(extraSpace / 18.0);
if (this.rows > this.maxRows) {
top += (this.rows - this.maxRows) * 18 / 2;
this.rows = this.maxRows;
}
if (hasNEI) {
this.rows--;
}
if (this.rows < 3) {
this.rows = 3;
}
this.getMeSlots().clear();
for (int y = 0; y < this.rows; y++) {
for (int x = 0; x < this.perRow; x++) {
this.getMeSlots().add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
}
}
if (AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL) {
this.xSize = this.standardSize + ((this.perRow - 9) * 18);
} else {
this.xSize = this.standardSize;
}
super.initGui();
// full size : 204
// extra slots : 72
// slot 18
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
// this.guiTop = top;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
int offset = this.guiTop + 8;
if (this.customSortOrder) {
this.buttonList.add(this.SortByBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
offset += 20;
}
// this.buttonList.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ) ) );
// offset += 20;
this.buttonList.add(this.SortDirBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc.getSetting(Settings.SORT_DIRECTION)));
offset += 20;
this.buttonList.add(this.searchBoxSettings = new GuiImgButton(this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
offset += 20;
if (ModAndClassUtil.isSaveText) {
this.buttonList.add(this.searchStringSave = new GuiImgButton(this.guiLeft - 18, offset, Settings.SAVE_SEARCH, AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
offset += 20;
}
this.buttonList.add(this.terminalStyleBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
offset += 20;
this.searchField = new FCGuiTextField(this.fontRendererObj, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90, 12);
this.searchField.setEnableBackgroundDrawing(false);
this.searchField.setMaxStringLength(25);
this.searchField.setTextColor(0xFFFFFF);
this.searchField.setVisible(true);
if (ModAndClassUtil.isSearchStringTooltip)
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
if (this.viewCell) {
if (ModAndClassUtil.isCraftStatus && AEConfig.instance.getConfigManager().getSetting(Settings.CRAFTING_STATUS).equals(CraftingStatus.BUTTON)) {
this.buttonList.add(this.craftingStatusImgBtn = new GuiImgButton(this.guiLeft - 18, offset, Settings.CRAFTING_STATUS, AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
} else {
this.buttonList.add(this.craftingStatusBtn = new GuiTabButton(this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(), itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
}
}
// Enum setting = AEConfig.INSTANCE.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
final Enum<?> setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString(memoryText, false);
}
if (this.isSubGui()) {
this.repo.updateView();
this.setScrollBar();
}
craftingGridOffsetX = Integer.MAX_VALUE;
craftingGridOffsetY = Integer.MAX_VALUE;
for (final Object s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (((Slot) s).xDisplayPosition < 195) {
this.repositionSlot((AppEngSlot) s);
}
}
if (s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix) {
final Slot g = (Slot) s;
if (g.xDisplayPosition > 0 && g.yDisplayPosition > 0) {
craftingGridOffsetX = Math.min(craftingGridOffsetX, g.xDisplayPosition);
craftingGridOffsetY = Math.min(craftingGridOffsetY, g.yDisplayPosition);
}
}
}
craftingGridOffsetX -= 25;
craftingGridOffsetY -= 6;
}
public void setSearchString(String memoryText, boolean updateView) {
this.searchField.setText(memoryText);
this.repo.setSearchString(memoryText);
if (updateView) {
this.repo.updateView();
this.setScrollBar();
}
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(this.getGuiDisplayName(GuiText.Terminal.getLocal()), 8, 6, 4210752);
this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
if (searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH) {
this.searchField.mouseClicked(xCoord, yCoord, btn);
}
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
setSearchString("", true);
}
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (mouseButton == 3) {
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
if (slot.getHasStack()) {
InventoryAction action = InventoryAction.valueOf("SET_PATTERN_VALUE");
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
return;
}
}
}
if (slot instanceof SlotFake) {
InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
action = InventoryAction.MOVE_REGION;
} else {
action = InventoryAction.PICKUP_SINGLE;
}
}
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
if (slot instanceof SlotPatternTerm) {
if (mouseButton == 6) {
return; // prevent weird double clicks..
}
try {
NetworkHandler.instance.sendToServer(((SlotPatternTerm) slot).getRequest(isShiftKeyDown()));
} catch (final IOException e) {
AELog.debug(e);
}
} else if (slot instanceof SlotCraftingTerm) {
if (mouseButton == 6) {
return; // prevent weird double clicks..
}
InventoryAction action;
if (isShiftKeyDown()) {
action = InventoryAction.CRAFT_SHIFT;
} else {
// Craft stack on right-click, craft single on left-click
action = (mouseButton == 1) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
if (this.enableSpaceClicking() && !(slot instanceof SlotPatternTerm)) {
IAEItemStack stack = null;
if (slot instanceof SlotME) {
stack = ((SlotME) slot).getAEStack();
}
int slotNum = Ae2ReflectClient.getInventorySlots(this).size();
if (!(slot instanceof SlotME) && slot != null) {
slotNum = slot.slotNumber;
}
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
}
if (slot instanceof SlotDisconnected) {
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
InventoryAction action = null;
switch (mouseButton) {
case 0: // pickup / set-down.
{
ItemStack heldStack = player.inventory.getItemStack();
if (slot.getStack() == null && heldStack != null)
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
action = InventoryAction.PICKUP_OR_SET_DOWN;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
break;
case 3: // creative dupe:
if (player.capabilities.isCreativeMode) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
break;
default:
case 4: // drop item:
case 6:
}
if (action != null) {
final PacketInventoryAction p = new PacketInventoryAction(action, slot.getSlotIndex(), ((SlotDisconnected) slot).getSlot().getId());
NetworkHandler.instance.sendToServer(p);
}
return;
}
if (slot instanceof SlotME) {
InventoryAction action = null;
IAEItemStack stack = null;
switch (mouseButton) {
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ((SlotME) slot).getAEStack();
if (stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null) {
action = InventoryAction.AUTO_CRAFT;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
stack = ((SlotME) slot).getAEStack();
break;
case 3: // creative dupe:
stack = ((SlotME) slot).getAEStack();
if (stack.getItem() instanceof ItemFluidDrop) {
stack = ItemFluidDrop.newAeStack(ItemFluidDrop.getAeFluidStack(stack));
}
if (stack != null && stack.isCraftable()) {
action = InventoryAction.AUTO_CRAFT;
} else if (player.capabilities.isCreativeMode) {
final IAEItemStack slotItem = ((SlotME) slot).getAEStack();
if (slotItem != null) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
}
break;
default:
case 4: // drop item:
case 6:
}
if (action == InventoryAction.AUTO_CRAFT) {
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
} else if (action != null) {
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
final PacketInventoryAction p = new PacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0);
NetworkHandler.instance.sendToServer(p);
}
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
memoryText = this.searchField.getText();
}
public void bindTextureBack(final String file) {
final ResourceLocation loc = new ResourceLocation(FluidCraft.MODID, "textures/" + file);
this.mc.getTextureManager().bindTexture(loc);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTextureBack(this.getBackground());
final int x_width = 195;
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18);
if (this.viewCell) {
this.drawTexturedModalRect(offsetX + x_width, offsetY, x_width, 0, 46, 128);
}
for (int x = 0; x < this.rows; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
}
this.drawTexturedModalRect(offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset);
if (this.viewCell) {
boolean update = false;
for (int i = 0; i < 5; i++) {
if (this.myCurrentViewCells[i] != this.monitorableContainer.getCellViewSlot(i).getStack()) {
update = true;
this.myCurrentViewCells[i] = this.monitorableContainer.getCellViewSlot(i).getStack();
}
}
if (update) {
this.repo.setViewCell(this.myCurrentViewCells);
}
}
if (this.searchField != null) {
this.searchField.drawTextBox();
}
}
protected String getBackground() {
return "gui/terminal.png";
}
@Override
protected boolean isPowered() {
return this.repo.hasPower();
}
int getMaxRows() {
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
}
protected void repositionSlot(final AppEngSlot s) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (character == ' ' && this.searchField.getText().isEmpty()) {
return;
}
if (this.searchField.textboxKeyTyped(character, key)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
} else {
super.keyTyped(character, key);
}
}
}
@Override
public void updateScreen() {
this.repo.setPower(this.monitorableContainer.isPowered());
super.updateScreen();
}
@Override
public Enum<?> getSortBy() {
return this.configSrc.getSetting(Settings.SORT_BY);
}
@Override
public Enum<?> getSortDir() {
return this.configSrc.getSetting(Settings.SORT_DIRECTION);
}
@Override
public Enum<?> getSortDisplay() {
return this.configSrc.getSetting(Settings.VIEW_MODE);
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (this.SortByBox != null) {
this.SortByBox.set(this.configSrc.getSetting(Settings.SORT_BY));
}
if (this.SortDirBox != null) {
this.SortDirBox.set(this.configSrc.getSetting(Settings.SORT_DIRECTION));
}
if (this.ViewBox != null) {
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
}
this.repo.updateView();
}
public int getReservedSpace() {
return this.reservedSpace;
}
public void setReservedSpace(final int reservedSpace) {
this.reservedSpace = reservedSpace;
}
public boolean isCustomSortOrder() {
return this.customSortOrder;
}
public void setCustomSortOrder(final boolean customSortOrder) {
this.customSortOrder = customSortOrder;
}
public int getStandardSize() {
return this.standardSize;
}
public void setStandardSize(final int standardSize) {
this.standardSize = standardSize;
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
}
public boolean isOverSearchField(int x, int y) {
return searchField.isMouseIn(x, y);
}
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th) {
if (this.viewCell) {
int rw = 33;
int rh = 14 + myCurrentViewCells.length * 18;
if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
return false;
}
int rx = this.guiLeft + this.xSize;
int ry = this.guiTop + 0;
rw += rx;
rh += ry;
tw += tx;
th += ty;
// overflow || intersect
return (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry);
}
return false;
}
}
@@ -7,7 +7,10 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.widgets.*;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.me.InternalSlotME;
import appeng.client.me.ItemRepo;
import appeng.client.me.SlotDisconnected;
@@ -28,15 +31,12 @@ import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBaseMonitorContain;
import com.glodblock.github.client.gui.container.FCBasePartContainer;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
@@ -64,7 +64,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
private final boolean viewCell;
private final ItemStack[] myCurrentViewCells = new ItemStack[5];
public FCBaseMonitorContain monitorableContainer;
private GuiTabButton craftingStatusBtn;
public GuiTabButton craftingStatusBtn;
private GuiImgButton craftingStatusImgBtn;
private FCGuiTextField searchField;
private int perRow = 9;
@@ -80,11 +80,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
private GuiImgButton terminalStyleBox;
private GuiImgButton searchStringSave;
public GuiFCBaseMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
this( inventoryPlayer, te, new FCBasePartContainer( inventoryPlayer, te ) );
}
public GuiFCBaseMonitor( final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseMonitorContain c )
{
@@ -94,14 +89,9 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
this.setScrollBar( scrollbar );
this.repo = new ItemRepo( scrollbar, this );
this.xSize = 185;
this.xSize = 195;
this.ySize = 204;
if( te instanceof IViewCellStorage)
{
this.xSize += 33;
}
this.standardSize = this.xSize;
this.configSrc = ( (IConfigurableObject) this.inventorySlots ).getConfigManager();
@@ -144,8 +134,8 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
final GuiImgButton iBtn = (GuiImgButton) btn;
if( iBtn.getSetting() != Settings.ACTIONS )
{
final Enum cv = iBtn.getCurrentValue();
final Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
if( btn == this.terminalStyleBox )
{
@@ -188,6 +178,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
Keyboard.enableRepeatEvents( true );
@@ -203,7 +194,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
final int magicNumber = 114 + 1;
final int extraSpace = this.height - magicNumber - NEI - top - this.reservedSpace;
this.rows = (int) Math.floor( extraSpace / 18 );
this.rows = (int) Math.floor( extraSpace / 18.0 );
if( this.rows > this.maxRows )
{
top += ( this.rows - this.maxRows ) * 18 / 2;
@@ -292,7 +283,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
}
// Enum setting = AEConfig.INSTANCE.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
final Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
final Enum<?> setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
this.searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui()))
@@ -312,7 +303,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
{
if( s instanceof AppEngSlot)
{
if( ( (Slot) s ).xDisplayPosition < 197 )
if( ( (Slot) s ).xDisplayPosition < 195 )
{
this.repositionSlot( (AppEngSlot) s );
}
@@ -354,7 +345,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn )
{
final Enum searchMode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
final Enum<?> searchMode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
if( searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH )
{
@@ -374,9 +365,31 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
{
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (mouseButton == 3 ){
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
if (slot.getHasStack()) {
InventoryAction action = InventoryAction.valueOf("SET_PATTERN_VALUE");
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
return;
}
}
}
if( slot instanceof SlotFake)
{
final InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
action = InventoryAction.MOVE_REGION;
}
else {
action = InventoryAction.PICKUP_SINGLE;
}
}
if( Ae2ReflectClient.getDragClick(this).size() > 1 )
{
@@ -412,7 +425,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
return; // prevent weird double clicks..
}
InventoryAction action = null;
InventoryAction action;
if( isShiftKeyDown() )
{
action = InventoryAction.CRAFT_SHIFT;
@@ -580,7 +593,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
{
this.bindTextureBack( this.getBackground() );
final int x_width = 197;
final int x_width = 195;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
if( this.viewCell )
@@ -672,19 +685,19 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
}
@Override
public Enum getSortBy()
public Enum<?> getSortBy()
{
return this.configSrc.getSetting( Settings.SORT_BY );
}
@Override
public Enum getSortDir()
public Enum<?> getSortDir()
{
return this.configSrc.getSetting( Settings.SORT_DIRECTION );
}
@Override
public Enum getSortDisplay()
public Enum<?> getSortDisplay()
{
return this.configSrc.getSetting( Settings.VIEW_MODE );
}
@@ -710,12 +723,12 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
this.repo.updateView();
}
int getReservedSpace()
public int getReservedSpace()
{
return this.reservedSpace;
}
void setReservedSpace( final int reservedSpace )
public void setReservedSpace( final int reservedSpace )
{
this.reservedSpace = reservedSpace;
}
@@ -725,7 +738,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
return this.customSortOrder;
}
void setCustomSortOrder( final boolean customSortOrder )
public void setCustomSortOrder( final boolean customSortOrder )
{
this.customSortOrder = customSortOrder;
}
@@ -735,7 +748,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
return this.standardSize;
}
void setStandardSize( final int standardSize )
public void setStandardSize( final int standardSize )
{
this.standardSize = standardSize;
}
@@ -750,4 +763,31 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
{
return searchField.isMouseIn(x,y);
}
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th)
{
if (this.viewCell) {
int rw = 33;
int rh = 14 + myCurrentViewCells.length * 18;
if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
return false;
}
int rx = this.guiLeft + this.xSize;
int ry = this.guiTop + 0;
rw += rx;
rh += ry;
tw += tx;
th += ty;
// overflow || intersect
return (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry);
}
return false;
}
}
@@ -0,0 +1,300 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.widgets.ITooltip;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
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 String fillVar;
private String currentValue;
private static final String prefix = NameConst.TT_KEY;
public GuiFCImgButton( final int x, final int y, final String idx, final String val ) {
super(0, 0, 16, "");
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" );
}
}
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);
a.displayValue = StatCollector.translateToLocal(prefix + title + ".hint");
a.index = iconIndex;
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;
}
public String getSetting()
{
return this.buttonSetting;
}
public String getCurrentValue()
{
return this.currentValue;
}
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 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 : 16;
}
@Override
public int getHeight()
{
return this.halfSize ? 8 : 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 );
String value = StatCollector.translateToLocal( displayValue );
if( name == null || name.isEmpty() )
{
name = displayName;
}
if( value == null || value.isEmpty() )
{
value = 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 null;
}
@Override
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3 )
{
if( this.visible )
{
final int iconIndex = this.getIconIndex();
if( this.halfSize )
{
this.width = 8;
this.height = 8;
GL11.glPushMatrix();
GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F );
GL11.glScalef( 0.5f / 16 * 3, 0.5f / 16 * 3, 0.5f / 16 * 3 );
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.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;
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();
}
else
{
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.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;
this.drawTexturedModalRect( this.xPosition, this.yPosition, 32, 32, 16, 16 );
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 );
this.mouseDragged( par1Minecraft, par2, par3 );
}
}
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 String displayName;
public String displayValue;
}
}
@@ -0,0 +1,219 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerPriority;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPriorityHost;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import java.io.IOException;
public class GuiFCPriority extends AEBaseGui
{
private GuiNumberBox priority;
private GuiTabButton originalGuiBtn;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiType OriginalGui;
public GuiFCPriority( final InventoryPlayer inventoryPlayer, final IPriorityHost te )
{
super( new ContainerPriority( inventoryPlayer, te ) );
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
super.initGui();
final int a = AEConfig.instance.priorityByStacksAmounts( 0 );
final int b = AEConfig.instance.priorityByStacksAmounts( 1 );
final int c = AEConfig.instance.priorityByStacksAmounts( 2 );
final int d = AEConfig.instance.priorityByStacksAmounts( 3 );
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) );
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) );
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) );
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
ItemStack myIcon = null;
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
if( target instanceof TileFluidInterface)
{
myIcon = ItemAndBlockHolder.INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE;
}
else if (target instanceof PartFluidInterface)
{
myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE_FLUID_PART;
}
if( this.OriginalGui != null && myIcon != null )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
}
this.priority = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Long.class );
this.priority.setEnableBackgroundDrawing( false );
this.priority.setMaxStringLength( 16 );
this.priority.setTextColor( 0xFFFFFF );
this.priority.setVisible( true );
this.priority.setFocused( true );
( (ContainerPriority) this.inventorySlots ).setTextField( this.priority );
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.priority.drawTextBox();
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
if( btn == this.originalGuiBtn )
{
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
{
this.addQty( this.getQty( btn ) );
}
}
private void addQty( final int i )
{
try
{
String out = this.priority.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if( fixed )
{
this.priority.setText( out );
}
if( out.isEmpty() )
{
out = "0";
}
long result = Long.parseLong( out );
result += i;
this.priority.setText( out = Long.toString( result ) );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
}
catch( final NumberFormatException e )
{
// nope..
this.priority.setText( "0" );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
@Override
protected void keyTyped( final char character, final int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.priority.textboxKeyTyped( character, key ) )
{
try
{
String out = this.priority.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
fixed = true;
}
if( fixed )
{
this.priority.setText( out );
}
if( out.isEmpty() )
{
out = "0";
}
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
else
{
super.keyTyped( character, key );
}
}
}
protected String getBackground()
{
return "guis/priority.png";
}
}
@@ -14,6 +14,8 @@ import appeng.core.localization.GuiText;
import appeng.helpers.Reflected;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketCraftRequest;
@@ -73,21 +75,27 @@ public class GuiFluidCraftAmount extends AEBaseGui
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
if( target instanceof PartFluidPatternTerminal)
{
if (target instanceof PartFluidPatternTerminal) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if( this.originalGui != null && myIcon != null )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
if (target instanceof PartFluidPatternTerminalEx) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (target instanceof PartFluidTerminal) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
this.originalGui = GuiType.FLUID_TERMINAL;
}
this.amountToCraft = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class );
this.amountToCraft.setEnableBackgroundDrawing( false );
this.amountToCraft.setMaxStringLength( 16 );
this.amountToCraft.setTextColor( 0xFFFFFF );
if (this.originalGui != null && myIcon != null) {
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
}
this.amountToCraft = new GuiNumberBox(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class);
this.amountToCraft.setEnableBackgroundDrawing(false);
this.amountToCraft.setMaxStringLength(16);
this.amountToCraft.setTextColor(0xFFFFFF);
this.amountToCraft.setVisible( true );
this.amountToCraft.setFocused( true );
this.amountToCraft.setText( "1" );
@@ -250,8 +258,4 @@ public class GuiFluidCraftAmount extends AEBaseGui
}
}
protected String getBackground()
{
return "guis/craftAmt.png";
}
}
@@ -13,6 +13,7 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.coremod.hooker.CoreModHooks;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
@@ -47,6 +48,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
private GuiButton start;
private GuiButton selectCPU;
private int tooltip = -1;
private ItemStack hoveredStack;
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
@@ -201,7 +203,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
final List<String> lineList = new LinkedList<String>();
int toolPosX = 0;
int toolPosY = 0;
hoveredStack = null;
final int offY = 23;
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
@@ -252,7 +254,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
lineList.add( GuiText.FromStorage.getLocal() + ": " + stored.getStackSize());
}
downY += 5;
@@ -277,7 +279,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
lineList.add( GuiText.Missing.getLocal() + ": " + missingStack.getStackSize());
}
red = true;
@@ -310,7 +312,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
final int posY = y * offY + yo;
final ItemStack is = refStack.copy().getItemStack();
final ItemStack is = CoreModHooks.displayFluid(refStack.copy());
if( this.tooltip == z - viewStart )
{
@@ -323,6 +325,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8;
toolPosY = y * offY + yo;
hoveredStack = is;
}
this.drawItem( posX, posY, is );
@@ -550,4 +553,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
}
}
public ItemStack getHoveredStack() {
return hoveredStack;
}
}
@@ -6,6 +6,8 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.container.ContainerFluidIO;
import com.glodblock.github.common.parts.PartFluidImportBus;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFluidIO extends GuiUpgradeable
@@ -29,4 +31,30 @@ public class GuiFluidIO extends GuiUpgradeable
((ContainerFluidIO)this.cvb).getBus().setFluidInSlot(id, stack);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName(I18n.format(this.bus instanceof PartFluidImportBus ? NameConst.GUI_FLUID_IMPORT : NameConst.GUI_FLUID_EXPORT)), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
if( this.redstoneMode != null )
{
this.redstoneMode.set( this.cvb.getRedStoneMode() );
}
if( this.fuzzyMode != null )
{
this.fuzzyMode.set( this.cvb.getFuzzyMode() );
}
if( this.craftMode != null )
{
this.craftMode.set( this.cvb.getCraftingMode() );
}
if( this.schedulingMode != null )
{
this.schedulingMode.set( this.cvb.getSchedulingMode() );
}
}
}
@@ -0,0 +1,145 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
public class GuiFluidInterface extends AEBaseGui {
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 GuiTabButton switcher;
public GuiFluidInterface(InventoryPlayer ipl, TileFluidInterface tile) {
super(new ContainerFluidInterface(ipl, tile));
this.cont = (ContainerFluidInterface) inventorySlots;
this.ySize = 231;
}
public GuiFluidInterface(InventoryPlayer ipl, PartFluidInterface tile) {
super(new ContainerFluidInterface(ipl, tile));
this.cont = (ContainerFluidInterface) inventorySlots;
this.ySize = 231;
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
super.initGui();
this.switcher = new GuiTabButton( this.guiLeft + 154, this.guiTop, isPart() ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.buttonList.add( this.switcher );
}
@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;
if (isPart()) {
fluidInv = ((PartFluidInterface) cont.getTile()).getInternalFluid();
} else {
fluidInv = ((TileFluidInterface) 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);
}
renderFluidIntoGui(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);
}
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 renderFluidIntoGui(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
GL11.glDisable(2896);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity));
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
}
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed(btn);
if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(isPart() ? GuiType.DUAL_INTERFACE_PART : GuiType.DUAL_INTERFACE));
}
}
public void update(int id, IAEFluidStack stack) {
if (id >= 100) {
id -= 100;
if (isPart()) {
((PartFluidInterface) cont.getTile()).setConfig(id, stack);
} else {
((TileFluidInterface) cont.getTile()).setConfig(id, stack);
}
}
else {
if(isPart()) {
((PartFluidInterface) cont.getTile()).setFluidInv(id, stack);
} else {
((TileFluidInterface) cont.getTile()).setFluidInv(id, stack);
}
}
}
private boolean isPart() {
return this.cont.getTile() instanceof PartFluidInterface;
}
}
@@ -12,7 +12,6 @@ import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.slot.SlotFluid;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketEncodePattern;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.FontRenderer;
@@ -11,7 +11,6 @@ import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
@@ -27,13 +26,15 @@ public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal {
ContainerFluidPatternTerminal container = new ContainerFluidPatternTerminal(inventoryPlayer, te);
container.setGui(this);
this.inventorySlots = container;
Ae2ReflectClient.setGuiContainer(this, container);
this.container = container;
this.monitorableContainer = container;
this.configSrc = container.getConfigManager();
}
@Override
public void initGui() {
super.initGui();
craftingStatusBtn = Ae2ReflectClient.getCraftingStatusButton(this);
craftingStatusBtn = super.craftingStatusBtn;
}
@Override
@@ -5,10 +5,10 @@ import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
@@ -30,6 +30,9 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
else if (host instanceof PartFluidPatternTerminalEx)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
else if (host instanceof PartFluidTerminal) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
}
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
@@ -41,6 +44,8 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL);
else if (host instanceof PartFluidPatternTerminalEx)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
else if (host instanceof PartFluidTerminal)
InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
} else {
super.actionPerformed(btn);
}
@@ -11,7 +11,6 @@ import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
@@ -35,7 +34,7 @@ public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx {
@Override
public void initGui() {
super.initGui();
craftingStatusBtn = Ae2ReflectClient.getCraftingStatusButton(this);
craftingStatusBtn = super.craftingStatusBtn;
}
@Override
@@ -0,0 +1,97 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidTerminal;
import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
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 java.util.HashMap;
import java.util.Map;
public class GuiFluidTerminal extends GuiBaseFluidTerminal {
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public ContainerFluidTerminal container;
public GuiFluidTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te, new FCBaseFluidMonitorContain(inventoryPlayer, te));
this.container = new ContainerFluidTerminal(inventoryPlayer, te);
}
@Override
public void initGui() {
super.initGui();
}
@Override
public void func_146977_a(final Slot s) {
if (drawSlot0(s))
super.func_146977_a(s);
}
public boolean drawSlot0(Slot slot) {
if (slot instanceof SlotME) {
AEItemStack stack = AEItemStack.create(slot.getStack());
if (stack == null) return true;
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
this.drawWidget(slot.xDisplayPosition, slot.yDisplayPosition, fluidStack.getFluid());
IAEItemStack fake = stack.copy();
fake.setStackSize(fluidStack.amount);
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
return false;
}
return true;
}
private void drawWidget(int posX, int posY, Fluid fluid) {
Minecraft.getMinecraft().renderEngine
.bindTexture(TextureMap.locationBlocksTexture);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor3f(1, 1, 1);
if (fluid != null && fluid.getIcon() != null) {
GL11.glColor3f((fluid.getColor() >> 16 & 0xFF) / 255.0F, (fluid.getColor() >> 8 & 0xFF) / 255.0F, (fluid.getColor() & 0xFF) / 255.0F);
drawTexturedModelRectFromIcon(posX, posY,
fluid.getIcon(), 16, 16);
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
}
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof SlotME && Util.FluidUtil.isFluidContainer(player.inventory.getItemStack())) {
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
ItemStack itemStack = this.player.inventory.getItemStack().copy();
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
if (!isShiftKeyDown()) {
itemStack.stackSize = 1;
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
public void update(ItemStack itemStack) {
this.player.inventory.setItemStack(itemStack);
}
}
@@ -12,7 +12,6 @@ import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
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;
@@ -0,0 +1,99 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
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 net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
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().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) {
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().getFluidInventory();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 7; i++) {
renderFluidIntoGui(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 renderFluidIntoGui(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
GL11.glDisable(2896);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity));
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
}
}
public void update(int slot, IAEFluidStack aeFluidStack) {
cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack);
}
}
@@ -0,0 +1,33 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.AEBaseGui;
import appeng.core.localization.GuiText;
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 net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
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);
}
}
@@ -0,0 +1,240 @@
package com.glodblock.github.client.gui;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.helpers.Reflected;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketPatternValueSet;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class GuiPatternValueAmount extends AEBaseGui {
private GuiTextField amountToSet;
private GuiTabButton originalGuiBtn;
private GuiButton set;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiType originalGui;
private final int valueIndex;
private final int originalAmount;
@Reflected
public GuiPatternValueAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerPatternValueAmount(inventoryPlayer, te));
GuiContainer gui = (GuiContainer) Minecraft.getMinecraft().currentScreen;
if (gui != null && gui.theSlot != null && gui.theSlot.getHasStack()) {
Slot slot = gui.theSlot;
originalAmount = this.getOriginalAmount(slot.getStack());
valueIndex = slot.slotNumber;
} else {
valueIndex = -1;
originalAmount = 0;
}
}
@Override
public void initGui() {
super.initGui();
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
this.buttonList.add(this.set = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
ItemStack myIcon = null;
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
if (target instanceof PartFluidPatternTerminal) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (target instanceof PartFluidPatternTerminalEx) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (this.originalGui != null && myIcon != null) {
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
}
this.amountToSet = new GuiTextField(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT);
this.amountToSet.setEnableBackgroundDrawing(false);
this.amountToSet.setMaxStringLength(16);
this.amountToSet.setTextColor(0xFFFFFF);
this.amountToSet.setVisible(true);
this.amountToSet.setFocused(true);
this.amountToSet.setText(String.valueOf(originalAmount));
this.amountToSet.setSelectionPos(0);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 0x404040);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.set.displayString = I18n.format("ae2fc.gui.button.set");
this.set.enabled = valueIndex >= 0;
this.bindTexture("guis/craftAmt.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
try {
String out = this.amountToSet.getText();
double resultD = Calculator.conversion(out);
int resultI;
if (resultD <= 0 || Double.isNaN(resultD)) {
resultI = 0;
} else {
resultI = (int) ArithHelper.round(resultD, 0);
}
this.set.enabled = resultI > 0;
} catch (final NumberFormatException e) {
this.set.enabled = false;
}
this.amountToSet.drawTextBox();
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == 28) {
this.actionPerformed(this.set);
}
this.amountToSet.textboxKeyTyped(character, key);
super.keyTyped(character, key);
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
try {
if (btn == this.originalGuiBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
}
if (btn == this.set && btn.enabled) {
double resultD = Calculator.conversion(this.amountToSet.getText());
int resultI;
if (resultD <= 0 || Double.isNaN(resultD)) {
resultI = 1;
} else {
resultI = (int) ArithHelper.round(resultD, 0);
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketPatternValueSet(originalGui.ordinal(), resultI, valueIndex));
}
} catch (final NumberFormatException e) {
// nope..
this.amountToSet.setText("1");
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
private void addQty(final int i) {
try {
String out = this.amountToSet.getText();
double resultD = Calculator.conversion(out);
int resultI;
if (resultD <= 0 || Double.isNaN(resultD)) {
resultI = 0;
} else {
resultI = (int) ArithHelper.round(resultD, 0);
}
if (resultI == 1 && i > 1) {
resultI = 0;
}
resultI += i;
if (resultI < 1) {
resultI = 1;
}
out = Integer.toString(resultI);
this.amountToSet.setText(out);
} catch (final NumberFormatException e) {
// :P
}
}
private int getOriginalAmount(ItemStack stack) {
if (Util.isFluidPacket(stack)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(stack);
return fluidStack.amount;
} else {
return stack.stackSize;
}
}
}
@@ -18,6 +18,8 @@ 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.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
@@ -57,9 +59,22 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
break;
}
}
this.standardDetectAndSendChanges();
return null;
} else {
if(idx < this.availableUpgrades()){
if(!mergeItemStack(tis, this.getFakeFluidInv().getSizeInventory()+this.availableUpgrades(), this.inventorySlots.size(), false)) return null;
}else if(idx>=this.getFakeFluidInv().getSizeInventory()+this.availableUpgrades()){
if(!mergeItemStack(tis, 0, this.availableUpgrades(), false)) return null;
}
if (tis.stackSize == 0) {
clickSlot.putStack(null);
} else {
clickSlot.onSlotChanged();
}
this.standardDetectAndSendChanges();
return tis;
}
this.standardDetectAndSendChanges();
return null;
}
protected void setupConfig()
@@ -69,18 +84,18 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName( "config" );
final int y = 40;
final int x = 80;
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 0, x, y, 0, 0, 0 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 0, x, y, 0, 0, 0 ) );
if( this.supportCapacity() )
{
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 3, x, y, 0, -1, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 4, x, y, 0, 1, 1 ) );
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, this, 5, x, y, -1, -1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 6, x, y, 1, -1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 7, x, y, -1, 1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 8, x, y, 1, 1, 2 ) );
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 ) );
}
}
@@ -128,14 +143,4 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
super.standardDetectAndSendChanges();
}
public void setFluid(int id, IAEFluidStack fluidStack) {
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
if (inv != null && this.isValidForConfig(id, AEFluidStack.create(fluidStack))) {
ItemStack tmp = ItemFluidPacket.newStack(fluidStack.getFluidStack());
if (tmp != null) {
tmp.setStackDisplayName(fluidStack.getFluidStack().getLocalizedName());
}
inv.setInventorySlotContents(id, tmp);
}
}
}
@@ -28,6 +28,8 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import com.google.common.collect.ImmutableSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -39,6 +41,7 @@ import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.concurrent.Future;
public class ContainerFluidCraftConfirm extends AEBaseContainer {
@@ -312,7 +315,7 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
this.setAutoStart( false );
if( g != null && originalGui != null && this.getOpenContext() != null )
{
InventoryHandler.switchGui(originalGui);
InventoryHandler.openGui(this.getInventoryPlayer().player, getWorld(), new BlockPos(this.getOpenContext().getTile()), Objects.requireNonNull(Util.from(this.getOpenContext().getSide())), originalGui);
}
}
}
@@ -1,7 +1,12 @@
package com.glodblock.github.client.gui.container;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.api.util.IConfigManager;
import appeng.tile.inventory.AppEngInternalAEInventory;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import com.glodblock.github.util.Ae2Reflect;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFluidIO extends ContainerFluidConfigurable
@@ -22,4 +27,12 @@ public class ContainerFluidIO extends ContainerFluidConfigurable
public AppEngInternalAEInventory getFakeFluidInv() {
return (AppEngInternalAEInventory) this.bus.getInventoryByName("config");
}
@Override
protected void loadSettingsFromHost(IConfigManager cm) {
super.loadSettingsFromHost(cm);
if (Ae2Reflect.getUpgradeableHost(this) instanceof PartFluidExportBus) {
this.setCraftingMode((YesNo)cm.getSetting(Settings.CRAFT_ONLY));
}
}
}
@@ -0,0 +1,88 @@
package com.glodblock.github.client.gui.container;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.IOptionalSlotHost;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import java.util.HashMap;
import java.util.Map;
public class ContainerFluidInterface extends AEBaseContainer implements IOptionalSlotHost {
private final Object tile;
public ContainerFluidInterface(InventoryPlayer ipl, TileFluidInterface 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 ContainerFluidInterface(InventoryPlayer ipl, PartFluidInterface 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 Object 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<>();
if (tile instanceof TileFluidInterface) {
for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i ++) {
tmp.put(i, ((TileFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i ++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((TileFluidInterface) tile).getConfig().getStackInSlot( i ))));
}
}
else {
for (int i = 0; i < ((PartFluidInterface) tile).getInternalFluid().getSlots(); i ++) {
tmp.put(i, ((PartFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((PartFluidInterface) tile).getConfig().getSizeInventory(); i ++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((PartFluidInterface) tile).getConfig().getStackInSlot( i ))));
}
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
}
@@ -23,15 +23,25 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import java.util.ArrayList;
import java.util.List;
public class ContainerFluidPatternTerminal extends FCBasePartContainer implements PatternConsumer {
public ContainerFluidPatternTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
}
public void encodeAllItemAndMoveToInventory(){
encode();
ItemStack output = this.patternSlotOUT.getStack();
if(output != null){
if(this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory( output )){
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
this.patternSlotIN.putStack(null);
}
}
@Override
public void encode() {
if (!checkHasFluidPattern()) {
@@ -112,23 +122,22 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of FluidPatternDetails
List<IAEItemStack> acc = new ArrayList<>();
for (Slot slot : slots) {
ItemStack stack = slot.getStack();
if (stack == null) {
continue;
}
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
acc.add(dropStack);
continue;
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
acc.add(aeStack);
stacks[i] = aeStack;
}
return acc.toArray(new IAEItemStack[0]);
return stacks;
}
@Override
@@ -148,6 +157,14 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
@@ -177,11 +194,6 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
}
return;
}
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
if (stack == null && slot.getStack() != null && slot.getStack().getItem() instanceof ItemFluidPacket) {
return;
}
}
super.doAction(player, action, slotId, id);
}
@@ -4,8 +4,7 @@ import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs;
import appeng.container.slot.OptionalSlotFake;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
@@ -23,15 +22,25 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import java.util.ArrayList;
import java.util.List;
public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx implements PatternConsumer {
public ContainerFluidPatternTerminalEx(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
}
public void encodeAllItemAndMoveToInventory(){
encode();
ItemStack output = this.patternSlotOUT.getStack();
if(output != null){
if(this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory( output )){
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
this.patternSlotIN.putStack(null);
}
}
@Override
public void encode() {
if (!checkHasFluidPattern()) {
@@ -102,6 +111,7 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
private void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setCombine(this.combine ? 1:0);
pattern.setInputs(collectInventory(craftingSlots));
pattern.setOutputs(collectInventory(outputSlots));
patternSlotOUT.putStack(pattern.writeToStack());
@@ -109,23 +119,22 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of FluidPatternDetails
List<IAEItemStack> acc = new ArrayList<>();
for (Slot slot : slots) {
ItemStack stack = slot.getStack();
if (stack == null) {
continue;
}
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
acc.add(dropStack);
continue;
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
acc.add(aeStack);
stacks[i] = aeStack;
}
return acc.toArray(new IAEItemStack[0]);
return stacks;
}
@Override
@@ -141,14 +150,21 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && stack != null
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
if ((slot instanceof OptionalSlotFake) && stack != null && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
@@ -0,0 +1,10 @@
package com.glodblock.github.client.gui.container;
import appeng.api.storage.ITerminalHost;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFluidTerminal extends FCBaseFluidMonitorContain {
public ContainerFluidTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
}
}
@@ -0,0 +1,67 @@
package com.glodblock.github.client.gui.container;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.TankDumpable;
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
import com.glodblock.github.network.SPacketFluidUpdate;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import java.util.HashMap;
import java.util.Map;
public class ContainerLargeIngredientBuffer extends AEBaseContainer implements TankDumpable {
private final TileLargeIngredientBuffer tile;
public ContainerLargeIngredientBuffer(InventoryPlayer ipl, TileLargeIngredientBuffer tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getInternalInventory();
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));
}
}
bindPlayerInventory(ipl, 0, 140);
}
public TileLargeIngredientBuffer 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);
}
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < tile.getFluidInventory().getSlots(); i ++) {
tmp.put(i, tile.getFluidInventory().getFluidInSlot(i));
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
}
@@ -0,0 +1,23 @@
package com.glodblock.github.client.gui.container;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import com.glodblock.github.common.tile.TileOCPatternEditor;
import net.minecraft.entity.player.InventoryPlayer;
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);
}
}
@@ -0,0 +1,45 @@
package com.glodblock.github.client.gui.container;
import appeng.api.config.SecurityPermissions;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotInaccessible;
import appeng.tile.inventory.AppEngInternalInventory;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
public class ContainerPatternValueAmount extends AEBaseContainer {
private final Slot patternValue;
private int valueIndex;
public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te )
{
super( ip, te );
this.patternValue = new SlotInaccessible( new AppEngInternalInventory( null, 1 ), 0, 34, 53 );
this.addSlotToContainer( patternValue );
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
this.verifyPermissions( SecurityPermissions.CRAFT, false );
}
public Slot getPatternValue()
{
return patternValue;
}
public int getValueIndex()
{
return valueIndex;
}
public void setValueIndex( int valueIndex )
{
this.valueIndex = valueIndex;
}
}
@@ -0,0 +1,455 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.parts.IPart;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Util;
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.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import org.apache.commons.lang3.tuple.MutablePair;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.BufferOverflowException;
import java.util.HashMap;
import java.util.Map;
public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEFluidStack> {
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
private final IMEMonitor<IAEFluidStack> monitor;
private final IItemList<IAEFluidStack> items = AEApi.instance().storage().createFluidList();
private final IConfigManager clientCM;
private final ITerminalHost host;
@GuiSync(99)
public boolean canAccessViewCells = false;
@GuiSync(98)
public boolean hasPower = false;
private IConfigManagerHost gui;
private IConfigManager serverCM;
private IGridNode networkNode;
public FCBaseFluidMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
}
protected FCBaseFluidMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
super(ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null);
this.host = monitorable;
this.clientCM = new ConfigManager(this);
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getFluidInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
// this.setCellInventory( this.monitor );
if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
}
}
}
} else {
this.setValidContainer(false);
}
} else {
this.monitor = null;
}
this.canAccessViewCells = false;
if (monitorable instanceof IViewCellStorage) {
for (int y = 0; y < 5; y++) {
this.cellView[y] = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.VIEW_CELL, ((IViewCellStorage) monitorable).getViewCellStorage(), y, 206, y * 18 + 8, this.getInventoryPlayer());
this.cellView[y].setAllowEdit(this.canAccessViewCells);
this.addSlotToContainer(this.cellView[y]);
}
}
if (bindInventory) {
this.bindPlayerInventory(ip, 0, 0);
}
}
public IGridNode getNetworkNode() {
return this.networkNode;
}
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
if (Platform.isClient()) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack() && Util.FluidUtil.isFluidContainer(clickSlot.getStack())) {
ItemStack tis = clickSlot.getStack();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
tmp.put(0, ItemFluidDrop.getAeFluidStack(AEItemStack.create(tis)));
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
}
}
return super.transferStackInSlot(p, idx);
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
if (this.monitor != this.host.getFluidInventory()) {
this.setValidContainer(false);
}
for (final Settings set : this.serverCM.getSettings()) {
final Enum<?> sideLocal = this.serverCM.getSetting(set);
final Enum<?> sideRemote = this.clientCM.getSetting(set);
if (sideLocal != sideRemote) {
this.clientCM.putSetting(set, sideLocal);
for (final Object crafter : this.crafters) {
try {
NetworkHandler.instance.sendTo(new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter);
} catch (final IOException e) {
AELog.debug(e);
}
}
}
}
if (!this.items.isEmpty()) {
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(true);
for (final IAEFluidStack is : this.items) {
final IAEFluidStack send = monitorCache.findPrecise(is);
if (send == null) {
is.setStackSize(0);
piu.appendFluid(is);
} else {
piu.appendFluid(send);
}
}
if (!piu.isEmpty()) {
this.items.resetStatus();
for (final Object c : this.crafters) {
if (c instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
}
}
this.updatePowerStatus();
final boolean oldAccessible = this.canAccessViewCells;
this.canAccessViewCells =
this.host instanceof WirelessTerminalGuiObject
|| this.hasAccess(SecurityPermissions.BUILD, false);
if (this.canAccessViewCells != oldAccessible) {
for (int y = 0; y < 5; y++) {
if (this.cellView[y] != null) {
this.cellView[y].setAllowEdit(this.canAccessViewCells);
}
}
}
super.detectAndSendChanges();
}
}
protected void updatePowerStatus() {
try {
if (this.networkNode != null) {
this.setPowered(this.networkNode.isActive());
} else if (this.getPowerSource() instanceof IEnergyGrid) {
this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered());
} else {
this.setPowered(this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8);
}
} catch (final Throwable t) {
// :P
}
}
@Override
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
if (field.equals("canAccessViewCells")) {
for (int y = 0; y < 5; y++) {
if (this.cellView[y] != null) {
this.cellView[y].setAllowEdit(this.canAccessViewCells);
}
}
}
super.onUpdate(field, oldValue, newValue);
}
@Override
public void addCraftingToCrafters(final ICrafting c) {
super.addCraftingToCrafters(c);
this.queueInventory(c);
}
private void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(true);
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
for (final IAEFluidStack send : monitorCache) {
try {
piu.appendFluid(send);
} catch (final BufferOverflowException boe) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
piu = new SPacketMEInventoryUpdate(true);
piu.appendFluid(send);
}
}
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
@Override
public void onContainerClosed(final EntityPlayer player) {
super.onContainerClosed(player);
if (this.monitor != null) {
this.monitor.removeListener(this);
}
}
@Override
public IConfigManager getConfigManager() {
if (Platform.isServer()) {
return this.serverCM;
}
return this.clientCM;
}
public ItemStack[] getViewCells() {
final ItemStack[] list = new ItemStack[this.cellView.length];
for (int x = 0; x < this.cellView.length; x++) {
list[x] = this.cellView[x].getStack();
}
return list;
}
public SlotRestrictedInput getCellViewSlot(final int index) {
return this.cellView[index];
}
public boolean isPowered() {
return this.hasPower;
}
private void setPowered(final boolean isPowered) {
this.hasPower = isPowered;
}
private IConfigManagerHost getGui() {
return this.gui;
}
public void setGui(@Nonnull final IConfigManagerHost gui) {
this.gui = gui;
}
@Override
public boolean isValid(Object verificationToken) {
return true;
}
@Override
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, BaseActionSource actionSource) {
for (final IAEFluidStack is : change) {
this.items.add(is);
}
}
private void dropItem(ItemStack is) {
if (is.stackSize <= 0) return;
ItemStack itemStack = is.copy();
int i = itemStack.getMaxStackSize();
while (itemStack.stackSize > 0) {
if (i > itemStack.stackSize) {
if (!getPlayerInv().addItemStackToInventory(itemStack.copy())) {
getPlayerInv().player.entityDropItem(itemStack.copy(), 0);
}
break;
} else {
itemStack.stackSize -= i;
ItemStack item = itemStack.copy();
item.stackSize = i;
if (!getPlayerInv().addItemStackToInventory(item)) {
getPlayerInv().player.entityDropItem(item, 0);
}
}
}
}
private void dropItem(ItemStack itemStack, int stackSize) {
if (itemStack.stackSize <= 0) return;
ItemStack is = itemStack.copy();
is.stackSize = stackSize;
this.dropItem(is);
}
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player, int slotIndex) {
for (IAEFluidStack fluid : change) {
IAEFluidStack nfluid = this.monitor.getStorageList().findPrecise(fluid);
ItemStack out = fluidContainer.copy();
out.stackSize = 1;
if (Util.FluidUtil.isEmpty(fluidContainer) && fluid != null) {
// add fluid to tanks
if (nfluid.getStackSize() <= 0) continue;
final IAEFluidStack toExtract = nfluid.copy();
MutablePair<Integer, ItemStack> fillStack = Util.FluidUtil.fillStack(out, toExtract.getFluidStack());
if (fillStack.right == null || fillStack.left <= 0) continue;
toExtract.setStackSize((long) fillStack.left * fluidContainer.stackSize);
IAEFluidStack tmp = this.host.getFluidInventory().extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
this.dropItem(fillStack.right);
out.stackSize = fillStack.right.stackSize;
if (fillStack.right.getItem() instanceof IFluidContainerItem) {
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if ((int) (tmp.getStackSize() % fillStack.left) > 0) {
((IFluidContainerItem) fillStack.right.getItem()).drain(fillStack.right, fillStack.left - (int) (tmp.getStackSize() % fillStack.left), true);
this.dropItem(fillStack.right, 1);
out.stackSize++;
}
} else if (FluidContainerRegistry.isContainer(fillStack.right)) {
toExtract.setStackSize((long) fillStack.right.stackSize * fillStack.left);
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
}
} else if (!Util.FluidUtil.isEmpty(fluidContainer)) {
// add fluid to ae network
FluidStack fluidStack = Util.getFluidFromItem(fluidContainer);
final AEFluidStack aeFluidStack = AEFluidStack.create(fluidStack);
// simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues
final IAEFluidStack notInserted = this.host.getFluidInventory().injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
MutablePair<Integer, ItemStack> drainStack = Util.FluidUtil.drainStack(out.copy(), aeFluidStack.getFluidStack());
if (notInserted != null && notInserted.getStackSize() > 0) {
if (fluidStack.amount == notInserted.getStackSize()) continue;
aeFluidStack.decStackSize(notInserted.getStackSize());
if (drainStack.left > aeFluidStack.getStackSize() && FluidContainerRegistry.isContainer(drainStack.right)) {
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
this.host.getFluidInventory().extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
continue;
}
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left)); // drop empty item
out.stackSize = ((int) (notInserted.getStackSize()) / drainStack.left);
if (drainStack.right.getItem() instanceof IFluidContainerItem) {
if (notInserted.getStackSize() % drainStack.left > 0) {
fluidStack.amount = (int) (notInserted.getStackSize() % drainStack.left);
((IFluidContainerItem) drainStack.right.getItem()).fill(drainStack.right, fluidStack, true);
this.dropItem(drainStack.right, 1);
}
} else if (FluidContainerRegistry.isContainer(drainStack.right)) {
if (notInserted.getStackSize() % drainStack.left > 0) {
aeFluidStack.setStackSize(aeFluidStack.getStackSize() % drainStack.left);
this.host.getFluidInventory().extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
out.stackSize++;
}
}
if (slotIndex == -1) out.stackSize = fluidContainer.stackSize - out.stackSize;
} else {
out.stackSize = (int) (fluidContainer.stackSize - (aeFluidStack.getStackSize() / drainStack.left));
this.dropItem(drainStack.right, fluidContainer.stackSize); // drop empty item
if (slotIndex == -1) out.stackSize++;
}
} else {
continue;
}
if (slotIndex == -1) {
player.inventory.getItemStack().stackSize = player.inventory.getItemStack().stackSize - out.stackSize;
if (player.inventory.getItemStack().stackSize > 0) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()), (EntityPlayerMP) player);
} else {
player.inventory.setItemStack(null);
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
}
} else {
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
}
}
this.detectAndSendChanges();
}
@Override
public void onListUpdate() {
for (final Object c : this.crafters) {
if (c instanceof ICrafting) {
final ICrafting cr = (ICrafting) c;
this.queueInventory(cr);
}
}
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (this.getGui() != null) {
this.getGui().updateSetting(manager, settingName, newValue);
}
}
}
@@ -58,6 +58,8 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
public boolean craftingMode = true;
@GuiSync( 96 )
public boolean substitute = false;
@GuiSync( 95 )
public boolean combine = false;
public FCBasePartContainer(final InventoryPlayer ip, final ITerminalHost monitorable )
{
@@ -457,6 +459,7 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
}
this.substitute = this.patternTerminal.isSubstitution();
this.combine = this.patternTerminal.shouldCombine();
}
}
@@ -565,7 +568,7 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots = enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream().filter(s-> s.getStack() != null && s.getStack().stackSize * 2 > 127).count();
return fullSlots <= emptyStots;
return fullSlots <= emptyStots && emptyStots < enabledSlots.size();
}
static void doubleStacksInternal(SlotFake[] slots)
@@ -4,9 +4,11 @@ import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.*;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotRestrictedInput;
import appeng.helpers.IContainerCraftingPacket;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
@@ -16,7 +18,9 @@ import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.*;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
@@ -31,38 +35,66 @@ import java.util.stream.Collectors;
public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
private static final int CRAFTING_GRID_PAGES = 2;
private static final int CRAFTING_GRID_WIDTH = 4;
private static final int CRAFTING_GRID_HEIGHT = 4;
private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT;
private static class ProcessingSlotFake extends OptionalSlotFake {
private static final int POSITION_SHIFT = 9000;
private boolean hidden = false;
public ProcessingSlotFake(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
this.setRenderDisabled(false);
}
public void setHidden(boolean hide) {
if (this.hidden != hide) {
this.hidden = hide;
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
}
}
}
private final PartFluidPatternTerminalEx patternTerminal;
private final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 );
private final IInventory crafting;
protected final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[16];
protected final OptionalSlotFake[] outputSlots = new OptionalSlotFake[4];
protected final ProcessingSlotFake[] craftingSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
protected final ProcessingSlotFake[] outputSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
@GuiSync( 96 )
@GuiSync( 96 + (17-9) + 11 )
public boolean combine = false;
@GuiSync( 96 + (17-9) + 12 )
public boolean substitute = false;
@GuiSync( 96 + (17-9) + 16 )
public boolean inverted;
@GuiSync( 96 + (17-9) + 17 )
public int activePage = 0;
@GuiSync( 96 + (17-9) + 13 )
public boolean prioritize = false;
public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable )
{
super( ip, monitorable, false );
this.patternTerminal = (PartFluidPatternTerminalEx) monitorable;
this.inverted = patternTerminal.isInverted();
final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" );
final IInventory output = this.getPatternTerminal().getInventoryByName( "output" );
IInventory crafting = this.getPatternTerminal().getInventoryByName("crafting");
this.crafting = this.getPatternTerminal().getInventoryByName( "crafting" );
for( int y = 0; y < 4; y++ )
{
for( int x = 0; x < 4; x++ )
{
this.addSlotToContainer( this.craftingSlots[x + y * 4] = new SlotFakeCraftingMatrix( this.crafting, x + y * 4, 15 + x * 18, -83 + y * 18 ) );
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.addSlotToContainer(this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(crafting, this, x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS, 15, -83, x, y, x + 4));
}
}
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
this.addSlotToContainer(this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(output, this, x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS, 112, -83, -x, y, x));
}
}
}
for( int y = 0; y < 4; y++ )
{
this.addSlotToContainer( this.outputSlots[y] = new SlotPatternOutputs( output, this, y, 112, -83, 0, y, 1 ) );
this.outputSlots[y].setRenderDisabled( false );
}
this.addSlotToContainer( this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this.getInventoryPlayer() ) );
@@ -180,12 +212,16 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
encodedValue.setTag( "out", tagOut );
encodedValue.setBoolean( "substitute", this.isSubstitute() );
encodedValue.setTag( "in", tagIn );
encodedValue.setTag( "out", tagOut );
encodedValue.setBoolean( "prioritize", this.isPrioritize() );
output.setTagCompound( encodedValue );
}
private ItemStack[] getInputs()
{
final ItemStack[] input = new ItemStack[16];
final ItemStack[] input = new ItemStack[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
boolean hasValue = false;
for( int x = 0; x < this.craftingSlots.length; x++ )
@@ -207,7 +243,7 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
private ItemStack[] getOutputs()
{
final List<ItemStack> list = new ArrayList<>( 4 );
final List<ItemStack> list = new ArrayList<>( CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES );
boolean hasValue = false;
for( final OptionalSlotFake outputSlot : this.outputSlots )
@@ -223,7 +259,7 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
if( hasValue )
{
return list.toArray( new ItemStack[list.size()] );
return list.toArray(new ItemStack[0]);
}
return null;
@@ -261,17 +297,14 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
@Override
public boolean isSlotEnabled( final int idx )
{
if( idx == 1 )
if (idx < 4) // outputs
{
Platform.isServer();
return true;
return inverted || idx == 0;
}
else if( idx == 2 )
else
{
Platform.isServer();
return false;
return !inverted || idx == 4;
}
return false;
}
@Override
@@ -281,6 +314,34 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
if( Platform.isServer() )
{
this.substitute = this.patternTerminal.isSubstitution();
this.combine = this.patternTerminal.shouldCombine(); //Check out
this.prioritize = this.patternTerminal.isPrioritize();
if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) {
inverted = patternTerminal.isInverted();
activePage = patternTerminal.getActivePage();
offsetSlots();
}
}
}
private void offsetSlots()
{
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && inverted);
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && !inverted);
}
}
}
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue) {
super.onUpdate( field, oldValue, newValue );
if (field.equals( "inverted" ) || field.equals( "activePage" )) {
offsetSlots();
}
}
@@ -289,13 +350,15 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
{
if( s == this.patternSlotOUT && Platform.isServer() )
{
inverted = patternTerminal.isInverted();
for( final Object crafter : this.crafters )
{
final ICrafting icrafting = (ICrafting) crafter;
for( final Object g : this.inventorySlots )
{
if( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix )
if( g instanceof OptionalSlotFake )
{
final Slot sri = (Slot) g;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
@@ -323,13 +386,6 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
return false;
}
public void toggleSubstitute()
{
this.substitute = !this.substitute;
this.detectAndSendChanges();
}
public PartFluidPatternTerminalEx getPatternTerminal()
{
return this.patternTerminal;
@@ -340,10 +396,7 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
return this.substitute;
}
public void setSubstitute( final boolean substitute )
{
this.substitute = substitute;
}
private boolean isPrioritize() { return this.prioritize; }
static boolean canDoubleStacks(SlotFake[] slots)
{
@@ -416,4 +469,12 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
return fluid > 0;
}
public void setActivePage(final int activePage) {
this.activePage = activePage;
}
public int getActivePage() {
return this.activePage;
}
}
@@ -0,0 +1,12 @@
package com.glodblock.github.client.gui.container;
import akka.actor.Status;
import java.lang.reflect.Type;
public enum FluidPrioritization {
ENABLED,
DISABLED;
}
@@ -0,0 +1,248 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package com.glodblock.github.client.me;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.widgets.IScrollSource;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.me.ItemRepo;
import appeng.core.AEConfig;
import appeng.items.storage.ItemViewCell;
import appeng.util.item.AEItemStack;
import appeng.util.prioitylist.IPartitionList;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.util.FluidSorters;
import com.glodblock.github.util.Util;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Pattern;
public class FluidRepo extends ItemRepo {
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
private final ArrayList<IAEItemStack> view = new ArrayList<IAEItemStack>();
private final ArrayList<ItemStack> dsp = new ArrayList<ItemStack>();
private final IScrollSource src;
private final ISortSource sortSrc;
private int rowSize = 9;
private String searchString = "";
private IPartitionList<IAEItemStack> myPartitionList;
private String innerSearch = "";
private String NEIWord = null;
private boolean hasPower;
public FluidRepo(final IScrollSource src, final ISortSource sortSrc) {
super(src, sortSrc);
this.src = src;
this.sortSrc = sortSrc;
}
public IAEItemStack getReferenceItem(int idx) {
idx += this.src.getCurrentScroll() * this.rowSize;
if (idx >= this.view.size()) {
return null;
}
return this.view.get(idx);
}
public ItemStack getItem(int idx) {
idx += this.src.getCurrentScroll() * this.rowSize;
if (idx >= this.dsp.size()) {
return null;
}
return this.dsp.get(idx);
}
void setSearch(final String search) {
this.searchString = search == null ? "" : search;
}
public void postUpdate(final IAEItemStack is) {
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(is);
IAEItemStack i = AEItemStack.create(is.getItemStack().setStackDisplayName(fluid.getFluid().getLocalizedName()));
final IAEItemStack st = this.list.findPrecise(i);
if (st != null) {
st.reset();
st.add(i);
} else {
this.list.add(i);
}
}
public void setViewCell(final ItemStack[] list) {
this.myPartitionList = ItemViewCell.createFilter(list);
this.updateView();
}
public void updateView() {
this.view.clear();
this.dsp.clear();
this.view.ensureCapacity(this.list.size());
this.dsp.ensureCapacity(this.list.size());
final Enum viewMode = this.sortSrc.getSortDisplay();
final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
this.updateNEI(this.searchString);
}
this.innerSearch = this.searchString;
final boolean terminalSearchToolTips =
AEConfig.instance.settings.getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
// boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;
boolean searchMod = false;
if (this.innerSearch.startsWith("@")) {
searchMod = true;
this.innerSearch = this.innerSearch.substring(1);
}
Pattern m = null;
try {
m = Pattern.compile(this.innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE);
} catch (final Throwable ignore) {
try {
m = Pattern.compile(Pattern.quote(this.innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE);
} catch (final Throwable __) {
return;
}
}
boolean notDone = false;
for (IAEItemStack is : this.list) {
if (this.myPartitionList != null) {
if (!this.myPartitionList.isListed(is)) {
continue;
}
}
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
continue;
}
if (viewMode == ViewItems.CRAFTABLE) {
is = is.copy();
is.setStackSize(0);
}
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
continue;
}
final String dspName = searchMod ? Util.getFluidModID(ItemFluidDrop.getAeFluidStack(is).getFluid()) : ItemFluidDrop.getAeFluidStack(is).getFluid().getLocalizedName();
if (m.matcher(dspName.toLowerCase()).find()) {
this.view.add(is);
}
/*
* if ( terminalSearchMods && notDone ) { if ( m.matcher( Platform.getMod( is.getItemStack() ) ).find() ) {
* view.add( is ); notDone = false; } }
*/
}
final Enum SortBy = this.sortSrc.getSortBy();
final Enum SortDir = this.sortSrc.getSortDir();
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
FluidSorters.init();
if (SortBy == SortOrder.MOD) {
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_MOD);
} else if (SortBy == SortOrder.AMOUNT) {
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
} else if (SortBy == SortOrder.INVTWEAKS) {
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
} else {
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_NAME);
}
for (final IAEItemStack is : this.view) {
this.dsp.add(is.getItemStack());
}
}
private void updateNEI(final String filter) {
try {
if (this.NEIWord == null || !this.NEIWord.equals(filter)) {
final Class c =
ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager");
final Field fldSearchField = c.getField("searchField");
final Object searchField = fldSearchField.get(c);
final Method a = searchField.getClass().getMethod("setText", String.class);
final Method b = searchField.getClass().getMethod("onTextChange", String.class);
this.NEIWord = filter;
a.invoke(searchField, filter);
b.invoke(searchField, "");
}
} catch (final Throwable ignore) {
}
}
public int size() {
return this.view.size();
}
public void clear() {
this.list.resetStatus();
}
public boolean hasPower() {
return this.hasPower;
}
public void setPower(final boolean hasPower) {
this.hasPower = hasPower;
}
public int getRowSize() {
return this.rowSize;
}
public void setRowSize(final int rowSize) {
this.rowSize = rowSize;
}
public String getSearchString() {
return this.searchString;
}
public void setSearchString(@Nonnull final String searchString) {
this.searchString = searchString;
}
}
@@ -82,8 +82,15 @@ public class ItemDropRender implements IItemRenderer {
}
int colour = fluid.getColor();
if (colour == 0xFFFFFF) {
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks()
.getTextureExtry(fluid.getStillIcon().getIconName());
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;
@@ -2,8 +2,10 @@ package com.glodblock.github.client.render;
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;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
@@ -22,12 +24,12 @@ public class ItemPacketRender implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type == ItemRenderType.INVENTORY;
return type != ItemRenderType.FIRST_PERSON_MAP;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return false;
return type == ItemRenderType.ENTITY;
}
@Override
@@ -50,18 +52,11 @@ public class ItemPacketRender implements IItemRenderer {
GL11.glColor3f((RGB >> 16 & 0xFF) / 255.0F, (RGB >> 8 & 0xFF) / 255.0F, (RGB & 0xFF) / 255.0F);
}
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
// draw a simple rectangle for the inventory icon
final float x_min = icon.getMinU();
final float x_max = icon.getMaxU();
final float y_min = icon.getMinV();
final float y_max = icon.getMaxV();
tess.addVertexWithUV( 0, 16, 0, x_min, y_max);
tess.addVertexWithUV(16, 16, 0, x_max, y_max);
tess.addVertexWithUV(16, 0, 0, x_max, y_min);
tess.addVertexWithUV( 0, 0, 0, x_min, y_min);
tess.draw();
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);
@@ -9,7 +9,7 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
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"), PartTerminalBroad("terminal_broad"),
PartFluidImportBus("fluid_import_face"), PartFluidExportBus("fluid_export_face"),
@@ -19,7 +19,7 @@ public enum FCPartsTexture {
private final String name;
public net.minecraft.util.IIcon IIcon;
FCPartsTexture( final String name )
FCPartsTexture(final String name)
{
this.name = name;
}
@@ -13,6 +13,7 @@ public class Config {
public static boolean noFluidPacket;
public static boolean fluidIOBus;
public static boolean removeRecipe;
public static boolean blacklistEssentiaGas;
public static void run() {
loadCategory();
@@ -21,9 +22,10 @@ public class Config {
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 Fluid Interface.");
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.");
removeRecipe = Config.getBoolean("Disable all recipes", "Fluid Craft for AE2", false, "Disable all recipes, for quick tweaker.");
blacklistEssentiaGas = Config.getBoolean("Blacklist Essentia Gas", "Fluid Craft for AE2", true, "Blacklist Essentia Gas from Thaumic Energistics, so they won't be stored in Fluid Storage Cells.");
if (Config.hasChanged())
Config.save();
@@ -1,6 +1,7 @@
package com.glodblock.github.common.block;
import appeng.block.AEBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileFluidDiscretizer;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -19,6 +20,7 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
public BlockFluidDiscretizer register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_DISCRETIZER);
GameRegistry.registerTileEntity(TileFluidDiscretizer.class, NameConst.BLOCK_FLUID_DISCRETIZER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -3,11 +3,14 @@ package com.glodblock.github.common.block;
import appeng.api.util.IOrientable;
import appeng.block.AEBaseItemBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.tile.misc.TileInterface;
import appeng.util.Platform;
import com.glodblock.github.client.render.RenderBlockFluidInterface;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -15,6 +18,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -38,19 +42,18 @@ public class BlockFluidInterface extends FCBaseBlock {
}
@Override
public boolean onActivated(final World w, final int x, final int y, final int z, final EntityPlayer p, final int side, final float hitX, final float hitY, final float hitZ )
public boolean onActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int facing, final float hitX, final float hitY, final float hitZ )
{
if( p.isSneaking() )
if( player.isSneaking() )
{
return false;
}
final TileInterface tg = this.getTileEntity( w, x, y, z );
final TileInterface tg = this.getTileEntity( world, x, y, z );
if( tg != null )
{
if( Platform.isServer() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INTERFACE );
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.DUAL_INTERFACE);
}
return true;
}
@@ -75,6 +78,7 @@ public class BlockFluidInterface extends FCBaseBlock {
public BlockFluidInterface register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_INTERFACE);
GameRegistry.registerTileEntity(TileFluidInterface.class, NameConst.BLOCK_FLUID_INTERFACE);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -1,6 +1,7 @@
package com.glodblock.github.common.block;
import appeng.block.AEBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
@@ -40,6 +41,7 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
public BlockFluidPacketDecoder register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
GameRegistry.registerTileEntity(TileFluidPacketDecoder.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -1,6 +1,7 @@
package com.glodblock.github.common.block;
import appeng.block.AEBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
@@ -40,6 +41,7 @@ public class BlockFluidPatternEncoder extends FCBaseBlock {
public BlockFluidPatternEncoder register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_PATTERN_ENCODER);
GameRegistry.registerTileEntity(TileFluidPatternEncoder.class, NameConst.BLOCK_FLUID_PATTERN_ENCODER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -1,6 +1,7 @@
package com.glodblock.github.common.block;
import appeng.block.AEBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
@@ -41,6 +42,7 @@ public class BlockIngredientBuffer extends FCBaseBlock {
public BlockIngredientBuffer register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_INGREDIENT_BUFFER);
GameRegistry.registerTileEntity(TileIngredientBuffer.class, NameConst.BLOCK_INGREDIENT_BUFFER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -0,0 +1,57 @@
package com.glodblock.github.common.block;
import appeng.block.AEBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockLargeIngredientBuffer extends FCBaseBlock {
public BlockLargeIngredientBuffer() {
super(Material.iron, NameConst.BLOCK_LARGE_INGREDIENT_BUFFER);
setTileEntity(TileLargeIngredientBuffer.class);
setOpaque(false);
setFullBlock(false);
this.lightOpacity = 4;
}
@Override
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
return false;
}
TileLargeIngredientBuffer tile = getTileEntity(world, x, y, z);
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.LARGE_INGREDIENT_BUFFER);
}
return true;
}
return false;
}
public BlockLargeIngredientBuffer register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_LARGE_INGREDIENT_BUFFER);
GameRegistry.registerTileEntity(TileLargeIngredientBuffer.class, NameConst.BLOCK_LARGE_INGREDIENT_BUFFER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -0,0 +1,60 @@
package com.glodblock.github.common.block;
import appeng.block.AEBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileOCPatternEditor;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockOCPatternEditor extends FCBaseBlock {
public BlockOCPatternEditor() {
super(Material.iron, NameConst.BLOCK_OC_PATTERN_EDITOR);
setTileEntity(TileOCPatternEditor.class);
setFullBlock(true);
setOpaque(true);
}
@Override
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
return false;
}
TileOCPatternEditor tile = getTileEntity(world, x, y, z);
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.OC_PATTERN_EDITOR);
}
return true;
}
return false;
}
public BlockOCPatternEditor register() {
if (ModAndClassUtil.OC) {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_OC_PATTERN_EDITOR);
GameRegistry.registerTileEntity(TileOCPatternEditor.class, NameConst.BLOCK_OC_PATTERN_EDITOR);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
return null;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -23,11 +23,14 @@ import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import com.google.common.base.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -138,6 +141,14 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
{
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded).getLocal();
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
if (GuiScreen.isShiftKeyDown())
{
lines.add(GuiText.Filter.getLocal() + ": ");
for (IAEFluidStack aeFluidStack : handler.getPartitionInv()) {
if (aeFluidStack != null) lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName());
}
}
}
}
}
@@ -157,6 +168,9 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
if (Config.blacklistEssentiaGas && ModAndClassUtil.ThE && requestedAddition != null) {
return ModAndClassUtil.essentiaGas.isInstance(requestedAddition.getFluid());
}
return false;
}
@@ -325,6 +339,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
public ItemBasicFluidStorageCell register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE + this.totalBytes / 1024 , FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -2,6 +2,7 @@ package com.glodblock.github.common.item;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -59,6 +60,7 @@ public class ItemBasicFluidStoragePart extends Item {
public ItemBasicFluidStoragePart register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_PART, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -79,8 +79,19 @@ public class ItemFluidDrop extends Item {
return stack;
}
public static ItemStack newStack1(FluidStack fluid) {
if (fluid == null) {
return null;
}
ItemStack stack = new ItemStack(ItemAndBlockHolder.DROP, fluid.amount);
NBTTagCompound tag = new NBTTagCompound();
tag.setString("Fluid", fluid.getFluid().getName());
stack.setTagCompound(tag);
return stack;
}
public static FluidStack getFluidStack(ItemStack stack) {
if (stack == null|| stack.getItem() != ItemAndBlockHolder.DROP || !stack.hasTagCompound()) {
if (stack == null || stack.getItem() != ItemAndBlockHolder.DROP || !stack.hasTagCompound()) {
return null;
}
NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound());
@@ -1,13 +1,18 @@
package com.glodblock.github.common.item;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.core.localization.GuiText;
import appeng.items.misc.ItemEncodedPattern;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import java.util.List;
public class ItemFluidEncodedPattern extends ItemEncodedPattern {
@@ -28,4 +33,22 @@ public class ItemFluidEncodedPattern extends ItemEncodedPattern {
return this;
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines, final boolean displayMoreInfo )
{
NBTTagCompound data = stack.getTagCompound();
final boolean combine = data.getBoolean("combine");
final boolean prio = data.getBoolean("prioritize");
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
// lines.add(String.format("%s: %s",combine ? StatCollector.translateToLocal(NameConst.TT_KEY+"combine"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_combine"),combine ? GuiText.Yes.getLocal() : GuiText.No.getLocal()));
// lines.add(String.format("%s: %s",prio ? StatCollector.translateToLocal(NameConst.TT_KEY+"prio"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_prio"),prio ? GuiText.Yes.getLocal() : GuiText.No.getLocal()));
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
}
@@ -5,6 +5,7 @@ import appeng.api.parts.IPartItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -39,6 +40,7 @@ public class ItemFluidExportBus extends Item implements IPartItem {
public ItemFluidExportBus register() {
if (!Config.fluidIOBus) return null;
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_EXPORT, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -5,6 +5,7 @@ import appeng.api.parts.IPartItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.parts.PartFluidImportBus;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -39,6 +40,7 @@ public class ItemFluidImportBus extends Item implements IPartItem {
public ItemFluidImportBus register() {
if (!Config.fluidIOBus) return null;
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_IMPORT, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -34,6 +34,10 @@ public class ItemFluidPacket extends Item {
@Override
public String getItemStackDisplayName(ItemStack stack) {
FluidStack fluid = getFluidStack(stack);
boolean display = isDisplay(stack);
if (display) {
return fluid != null ? fluid.getLocalizedName() : super.getItemStackDisplayName(stack);
}
return fluid != null ? String.format("%s, %,d mB", fluid.getLocalizedName(), fluid.amount)
: super.getItemStackDisplayName(stack);
}
@@ -42,6 +46,8 @@ public class ItemFluidPacket extends Item {
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flags) {
FluidStack fluid = getFluidStack(stack);
boolean display = isDisplay(stack);
if (display) return;
if (fluid != null) {
for (String line : StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_PACKET).split("\\\\n")) {
tooltip.add(EnumChatFormatting.GRAY + line);
@@ -51,6 +57,13 @@ public class ItemFluidPacket extends Item {
}
}
public static boolean isDisplay(ItemStack stack) {
if (stack == null || !stack.hasTagCompound() || stack.getTagCompound() == null) {
return false;
}
return stack.getTagCompound().getBoolean("DisplayOnly");
}
public static FluidStack getFluidStack(ItemStack stack) {
if (stack == null || !stack.hasTagCompound()) {
return null;
@@ -76,6 +89,22 @@ public class ItemFluidPacket extends Item {
return stack;
}
public static ItemStack newDisplayStack(@Nullable FluidStack fluid) {
if (fluid == null) {
return null;
}
FluidStack copy = fluid.copy();
copy.amount = 1000;
ItemStack stack = new ItemStack(ItemAndBlockHolder.PACKET);
NBTTagCompound tag = new NBTTagCompound();
NBTTagCompound fluidTag = new NBTTagCompound();
copy.writeToNBT(fluidTag);
tag.setTag("FluidStack", fluidTag);
tag.setBoolean("DisplayOnly", true);
stack.setTagCompound(tag);
return stack;
}
@Nullable
public static IAEItemStack newAeStack(@Nullable FluidStack fluid) {
return AEItemStack.create(newStack(fluid));
@@ -4,6 +4,7 @@ import appeng.api.AEApi;
import appeng.api.parts.IPartItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -37,6 +38,7 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
public ItemPartFluidInterface register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_INTERFACE, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -4,6 +4,7 @@ import appeng.api.AEApi;
import appeng.api.parts.IPartItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -37,6 +38,7 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
public ItemPartFluidPatternTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -4,6 +4,7 @@ import appeng.api.AEApi;
import appeng.api.parts.IPartItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -37,6 +38,7 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
public ItemPartFluidPatternTerminalEx register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL_EX, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -0,0 +1,74 @@
package com.glodblock.github.common.item;
import appeng.api.AEApi;
import appeng.api.parts.IPartItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.List;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
public class ItemPartFluidTerminal extends Item implements IPartItem {
public ItemPartFluidTerminal() {
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_TERMINAL);
AEApi.instance().partHelper().setItemBusRenderer(this);
}
@Nullable
@Override
public PartFluidTerminal createPartFromItemStack(ItemStack is) {
return new PartFluidTerminal(is);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flag) {
if (isShiftKeyDown()) tooltip.add(StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_TERMINAL));
}
public ItemPartFluidTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public void registerIcons(IIconRegister _iconRegister) {
}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -2,6 +2,10 @@ package com.glodblock.github.common.parts;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.ticking.TickRateModulation;
@@ -10,11 +14,21 @@ import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.texture.CableBusTextures;
import appeng.core.AELog;
import appeng.helpers.MultiCraftingTracker;
import appeng.me.GridAccessException;
import appeng.util.InventoryAdaptor;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import com.google.common.collect.ImmutableSet;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.RenderBlocks;
@@ -23,9 +37,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.IFluidHandler;
public class PartFluidExportBus extends PartSharedFluidBus {
public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingRequester {
private final BaseActionSource source;
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker( this, 9 );
public PartFluidExportBus( ItemStack is )
{
@@ -74,6 +89,8 @@ public class PartFluidExportBus extends PartSharedFluidBus {
{
try
{
final InventoryAdaptor destination = this.getHandler(te);
final ICraftingGrid cg = this.getProxy().getCrafting();
final IFluidHandler fh = (IFluidHandler) te;
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
@@ -82,13 +99,20 @@ public class PartFluidExportBus extends PartSharedFluidBus {
IAEFluidStack fluid = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
if( fluid != null )
{
boolean isAllowed = true;
final IAEFluidStack toExtract = fluid.copy();
toExtract.setStackSize( this.calculateAmountToSend() );
if( this.craftOnly() )
{
isAllowed = this.craftingTracker.handleCrafting( i, toExtract.getStackSize(), ItemFluidDrop.newAeStack(toExtract), destination, this.getTile().getWorldObj(), this.getProxy().getGrid(), cg, this.source );
}
final IAEFluidStack out = inv.extractItems( toExtract, Actionable.SIMULATE, this.source );
if( out != null )
if( out != null && isAllowed )
{
int wasInserted = fh.fill( this.getSide().getOpposite(), out.getFluidStack(), true );
@@ -100,6 +124,10 @@ public class PartFluidExportBus extends PartSharedFluidBus {
return TickRateModulation.FASTER;
}
}
if( this.isCraftingEnabled() ) {
this.craftingTracker.handleCrafting( i, toExtract.getStackSize(), ItemFluidDrop.newAeStack(toExtract), destination, this.getTile().getWorldObj(), this.getProxy().getGrid(), cg, this.source );
}
}
}
@@ -169,4 +197,64 @@ public class PartFluidExportBus extends PartSharedFluidBus {
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
private boolean craftOnly() {
return this.getConfigManager().getSetting(Settings.CRAFT_ONLY) == YesNo.YES;
}
private boolean isCraftingEnabled()
{
return this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0;
}
@Override
public ImmutableSet<ICraftingLink> getRequestedJobs() {
return this.craftingTracker.getRequestedJobs();
}
protected InventoryAdaptor getHandler(TileEntity target) {
return target != null ? FluidConvertingInventoryAdaptor.wrap(target, Util.from(this.getSide().getOpposite())) : null;
}
@Override
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
final InventoryAdaptor d = this.getHandler(getConnectedTE());
try
{
if( d != null && this.getProxy().isActive() )
{
final IEnergyGrid energy = this.getProxy().getEnergy();
final double power = Math.ceil(items.getStackSize() / 1000D);
if( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 )
{
ItemStack inputStack = items.getItemStack();
ItemStack remaining;
if( mode == Actionable.SIMULATE )
{
remaining = d.simulateAdd( inputStack );
}
else
{
remaining = d.addItems( inputStack );
}
return AEItemStack.create( remaining );
}
}
}
catch( final GridAccessException e )
{
AELog.debug( e );
}
return items;
}
@Override
public void jobStateChange(ICraftingLink link) {
this.craftingTracker.jobStateChange( link );
}
}
@@ -2,32 +2,58 @@ package com.glodblock.github.common.parts;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
import appeng.parts.misc.PartInterface;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.DualityFluidInterface;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
public class PartFluidInterface extends PartInterface implements IFluidHandler {
import java.io.IOException;
import java.util.Objects;
public class PartFluidInterface extends PartInterface implements IFluidHandler, IAEFluidInventory {
private final BaseActionSource ownActionSource = new MachineSource(this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 6 );
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this);
public PartFluidInterface(ItemStack is) {
super(is);
@@ -72,6 +98,120 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler {
rh.renderInventoryBox( renderer );
}
@MENetworkEventSubscribe
public void stateChange(final MENetworkChannelsChanged c) {
fluidDuality.onChannelStateChange(c);
}
@MENetworkEventSubscribe
public void stateChange(final MENetworkPowerStatusChange c) {
fluidDuality.onPowerStateChange(c);
}
@Override
public void gridChanged() {
super.gridChanged();
fluidDuality.gridChanged();
}
public DualityFluidInterface getDualityFluid() {
return fluidDuality;
}
public AEFluidInventory getInternalFluid() {
return fluidDuality.getTanks();
}
public AppEngInternalAEInventory getConfig() {
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i ++) {
IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i);
if (fluid == null) {
config.setInventorySlotContents(i, null);
}
else {
config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
}
}
return config;
}
@Override
public void writeToStream(ByteBuf data) throws IOException {
super.writeToStream(data);
for (int i = 0; i < config.getSizeInventory(); i++) {
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
for (int j = 0; j < config.getSizeInventory(); j ++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
}
int fluidMask = 0;
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
if (getInternalFluid().getFluidInSlot(i) != null) {
fluidMask |= 1 << i;
}
}
data.writeByte(fluidMask);
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
IAEFluidStack fluid = getInternalFluid().getFluidInSlot(i);
if (fluid != null) {
fluid.writeToPacket(data);
}
}
}
@Override
public boolean readFromStream(ByteBuf data) throws IOException {
super.readFromStream(data);
boolean changed = false;
for (int i = 0; i < config.getSizeInventory(); i++) {
ItemStack stack = ByteBufUtils.readItemStack(data);
if (!ItemStack.areItemStacksEqual(stack, config.getStackInSlot(i))) {
config.setInventorySlotContents(i, stack);
changed = true;
}
for (int j = 0; j < config.getSizeInventory(); j ++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
}
int fluidMask = data.readByte();
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
if ((fluidMask & (1 << i)) != 0) {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
if (fluid != null) { // this shouldn't happen, but better safe than sorry
IAEFluidStack origFluid = getInternalFluid().getFluidInSlot(i);
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
getInternalFluid().setFluidInSlot(i, fluid);
changed = true;
}
}
} else if (getInternalFluid().getFluidInSlot(i) != null) {
getInternalFluid().setFluidInSlot(i, null);
changed = true;
}
}
return changed;
}
@Override
public void readFromNBT( NBTTagCompound data ) {
super.readFromNBT( data );
config.readFromNBT(data, "ConfigInv");
for (int i = 0; i < config.getSizeInventory(); i ++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid));
}
getInternalFluid().readFromNBT(data, "FluidInv");
}
@Override
public void writeToNBT( NBTTagCompound data ) {
super.writeToNBT(data);
config.writeToNBT(data, "ConfigInv");
getInternalFluid().writeToNBT(data, "FluidInv");
}
@Override
public int getInstalledUpgrades( final Upgrades u )
{
@@ -103,7 +243,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler {
int ori = resource.amount;
IAEFluidStack remove;
if (doFill) {
remove = Platform.poweredInsert(energyGrid, fluidGrid, AEFluidStack.create(resource), ownActionSource);
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.MODULATE, ownActionSource);
} else {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
}
@@ -112,12 +252,12 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler {
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return null;
return fluidDuality.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return null;
return fluidDuality.drain(from, maxDrain, doDrain);
}
@Override
@@ -127,11 +267,69 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler {
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return false;
return true;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return new FluidTankInfo[]{new FluidTankInfo(null, 0)};
return fluidDuality.getTankInfo(from);
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos)
{
if( player.isSneaking() )
{
return false;
}
if( Platform.isServer() )
{
InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.DUAL_INTERFACE_PART);
}
return true;
}
@Override
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
saveChanges();
getTileEntity().markDirty();
fluidDuality.onFluidInventoryChanged(inv, slot);
}
public void setConfig(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
config.setInventorySlotContents(id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack()));
fluidDuality.getConfig().setFluidInSlot(id, fluidDuality.getStandardFluid(fluid));
}
}
public void setFluidInv(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
getInternalFluid().setFluidInSlot(id, fluid);
}
}
@Override
public TickingRequest getTickingRequest( final IGridNode node )
{
TickingRequest item = super.getTickingRequest(node);
TickingRequest fluid = fluidDuality.getTickingRequest(node);
return new TickingRequest(
Math.min(item.minTickRate, fluid.minTickRate),
Math.max(item.maxTickRate, fluid.maxTickRate),
item.isSleeping && fluid.isSleeping,
true);
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
TickRateModulation item = super.tickingRequest(node, TicksSinceLastCall);
TickRateModulation fluid = fluidDuality.tickingRequest(node, TicksSinceLastCall);
if (item.ordinal() >= fluid.ordinal()) {
return item;
} else {
return fluid;
}
}
}
@@ -11,8 +11,8 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.client.textures.FCPartsTexture;
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.inventory.BiggerAppEngInventory;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
@@ -34,12 +34,13 @@ public class PartFluidPatternTerminal extends FCBasePart {
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 9 );
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
private final AppEngInternalInventory crafting = new BiggerAppEngInventory( this, 9 );
private final AppEngInternalInventory output = new BiggerAppEngInventory( this, 3 );
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
private boolean craftingMode = true;
private boolean substitute = false;
private boolean combine = false;
public PartFluidPatternTerminal(ItemStack is) {
super(is, true);
@@ -81,6 +82,7 @@ public class PartFluidPatternTerminal extends FCBasePart {
super.readFromNBT( data );
this.setCraftingRecipe( data.getBoolean( "craftingMode" ) );
this.setSubstitution( data.getBoolean( "substitute" ) );
this.setCombineMode( data.getBoolean("combine") );
this.pattern.readFromNBT( data, "pattern" );
this.output.readFromNBT( data, "outputList" );
this.crafting.readFromNBT( data, "craftingGrid" );
@@ -92,6 +94,7 @@ public class PartFluidPatternTerminal extends FCBasePart {
super.writeToNBT( data );
data.setBoolean( "craftingMode", this.craftingMode );
data.setBoolean( "substitute", this.substitute );
data.setBoolean( "combine", this.combine );
this.pattern.writeToNBT( data, "pattern" );
this.output.writeToNBT( data, "outputList" );
this.crafting.writeToNBT( data, "craftingGrid" );
@@ -117,100 +120,57 @@ public class PartFluidPatternTerminal extends FCBasePart {
return GuiBridge.GUI_ME;
}
public void onChangeInventory0(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
if( inv == this.pattern && slot == 1 )
{
final ItemStack is = this.pattern.getStackInSlot( 1 );
if( is != null && is.getItem() instanceof ICraftingPatternItem)
{
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
if( details != null )
{
this.setCraftingRecipe( details.isCraftable() );
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
}
}
}
else if( inv == this.crafting )
{
this.fixCraftingRecipes();
}
this.getHost().markForSave();
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ItemFluidEncodedPattern) {
final ItemFluidEncodedPattern pattern = (ItemFluidEncodedPattern) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
if( details != null )
{
this.setCraftingRecipe( details.isCraftable() );
this.setSubstitution( details.canSubstitute() );
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
final IAEItemStack[] outItems = details.getOutputs();
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
this.setCraftingRecipe(details.isCraftable());
this.setSubstitution(details.canSubstitute());
if(newStack != null){
NBTTagCompound data = newStack.getTagCompound();
this.setCombineMode(data.getInteger("combine") == 1);
}
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
this.crafting.setInventorySlotContents(i, null);
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
for (int i = 0; i < this.output.getSizeInventory(); i++) {
this.output.setInventorySlotContents(i, null);
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(x, packet);
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
if (inItems[i] != null) {
final IAEItemStack item = inItems[i];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(i, packet);
} else
this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack());
}
else this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(x, packet);
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
if (outItems[i] != null) {
final IAEItemStack item = outItems[i];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i, packet);
} else
this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack());
}
else this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
}
this.getHost().markForSave();
return;
}
}
onChangeInventory0(inv, slot, mc, removedStack, newStack);
this.getHost().markForSave();
}
private void fixCraftingRecipes()
@@ -244,11 +204,21 @@ public class PartFluidPatternTerminal extends FCBasePart {
return this.substitute;
}
public boolean shouldCombine()
{
return this.combine;
}
public void setSubstitution( boolean canSubstitute )
{
this.substitute = canSubstitute;
}
public void setCombineMode(boolean shouldCombine)
{
this.combine = shouldCombine;
}
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
IInventory crafting = this.getInventoryByName("crafting");
IInventory output = this.getInventoryByName("output");
@@ -11,8 +11,8 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.client.textures.FCPartsTexture;
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.inventory.BiggerAppEngInventory;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
@@ -34,11 +34,15 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 16 );
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 4 );
private final AppEngInternalInventory crafting = new BiggerAppEngInventory( this, 32 );
private final AppEngInternalInventory output = new BiggerAppEngInventory( this, 32 );
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
private boolean substitute = false;
private boolean combine = false;
private boolean prioritize = false;
private boolean inverted = false;
private int activePage = 0;
public PartFluidPatternTerminalEx(ItemStack is) {
super(is, true);
@@ -78,20 +82,33 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
this.setSubstitution( data.getBoolean( "substitute" ) );
this.setCombineMode( data.getBoolean("combine") );
this.pattern.readFromNBT( data, "pattern" );
this.output.readFromNBT( data, "outputList" );
this.crafting.readFromNBT( data, "craftingGrid" );
this.setSubstitution( data.getBoolean( "substitute" ) );
this.setPrioritization( data.getBoolean( "priorization") );
this.setInverted( data.getBoolean( "inverted" ) );
this.setActivePage( data.getInteger( "activePage" ) );
}
@Override
public void writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
data.setBoolean( "substitute", this.substitute );
data.setBoolean( "combine", this.combine );
this.pattern.writeToNBT( data, "pattern" );
this.output.writeToNBT( data, "outputList" );
this.crafting.writeToNBT( data, "craftingGrid" );
data.setBoolean("priorization", this.prioritize);
data.setBoolean( "substitute", this.substitute );
data.setBoolean( "inverted", this.inverted );
data.setInteger( "activePage", this.activePage );
}
@Override
@@ -114,94 +131,97 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
return GuiBridge.GUI_ME;
}
public void onChangeInventory0(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
if( inv == this.pattern && slot == 1 )
{
final ItemStack is = this.pattern.getStackInSlot( 1 );
if( is != null && is.getItem() instanceof ICraftingPatternItem)
{
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
if( details != null )
{
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
}
}
}
this.getHost().markForSave();
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ItemFluidEncodedPattern) {
final ItemFluidEncodedPattern pattern = (ItemFluidEncodedPattern) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
if( details != null )
{
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj());
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
final IAEItemStack[] outItems = details.getOutputs();
int inputsCount = 0;
int outputCount = 0;
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(x, packet);
for (int i = 0; i < inItems.length; i++) {
if (inItems[i] != null) {
inputsCount++;
}
else this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(x, packet);
for (int i = 0; i < outItems.length; i++) {
if (outItems[i] != null) {
outputCount++;
}
}
this.setSubstitution(details.canSubstitute());
if(newStack != null){
NBTTagCompound data = newStack.getTagCompound();
this.setCombineMode(data.getInteger("combine") == 1);
this.setPrioritization(data.getInteger("prioritize") == 1);
}
this.setInverted(inputsCount <= 8 && outputCount > 8);
this.setActivePage(0);
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
this.crafting.setInventorySlotContents(i, null);
}
for (int i = 0; i < this.output.getSizeInventory(); i++) {
this.output.setInventorySlotContents(i, null);
}
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
final IAEItemStack item = inItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(i, packet);
} else this.crafting.setInventorySlotContents(i, item.getItemStack());
}
}
if (inverted) {
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
final IAEItemStack item = outItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i, packet);
} else this.output.setInventorySlotContents(i, item.getItemStack());
}
}
} else {
for (int i = 0; i < outItems.length && i < 8; i++) {
final IAEItemStack item = outItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, packet);
} else
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack());
}
}
else this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
}
this.getHost().markForSave();
return;
}
}
onChangeInventory0(inv, slot, mc, removedStack, newStack);
this.getHost().markForSave();
}
public boolean shouldCombine()
{
return this.combine;
}
public void setCombineMode(boolean shouldCombine)
{
this.combine = shouldCombine;
}
public boolean isSubstitution()
@@ -209,10 +229,19 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
return this.substitute;
}
public boolean isPrioritize()
{
return this.prioritize;
}
public void setSubstitution( boolean canSubstitute )
{
this.substitute = canSubstitute;
}
public void setPrioritization( boolean canPrioritize )
{
this.prioritize = canPrioritize;
}
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
IInventory crafting = this.getInventoryByName("crafting");
@@ -270,4 +299,20 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
return false;
}
public boolean isInverted() {
return inverted;
}
public void setInverted(boolean inverted) {
this.inverted = inverted;
}
public int getActivePage() {
return this.activePage;
}
public void setActivePage(int activePage) {
this.activePage = activePage;
}
}
@@ -0,0 +1,88 @@
package com.glodblock.github.common.parts;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGridHost;
import appeng.core.sync.GuiBridge;
import appeng.util.Platform;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Vec3;
import java.util.Objects;
public class PartFluidTerminal extends FCBasePart {
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidTerminal_Bright;
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidTerminal_Dark;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidTerminal_Colored;
public PartFluidTerminal(ItemStack is) {
super(is, true);
}
@Override
public FCPartsTexture getFrontBright() {
return FRONT_BRIGHT_ICON;
}
@Override
public FCPartsTexture getFrontColored() {
return FRONT_COLORED_ICON;
}
@Override
public FCPartsTexture getFrontDark() {
return FRONT_DARK_ICON;
}
@Override
public boolean isLightSource() {
return false;
}
@Override
public boolean isBooting() {
return super.isBooting();
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
TileEntity te = this.getTile();
BlockPos tePos = new BlockPos(te);
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
return super.onPartActivate(player, pos);
}
if (Platform.isServer()) {
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this) || Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
InventoryHandler.openGui(player, te.getWorldObj(), tePos, Objects.requireNonNull(Util.from(getSide())), GuiType.FLUID_TERMINAL);
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
}
}
return true;
}
@Override
public GuiBridge getGui(final EntityPlayer p) {
int x = (int) p.posX;
int y = (int) p.posY;
int z = (int) p.posZ;
if (this.getHost().getTile() != null) {
x = this.getTile().xCoord;
y = this.getTile().yCoord;
z = this.getTile().zCoord;
}
if (GuiBridge.GUI_WIRELESS_TERM.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
return GuiBridge.GUI_WIRELESS_TERM;
}
return GuiBridge.GUI_ME;
}
}
@@ -5,10 +5,8 @@ import appeng.api.config.Upgrades;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
import appeng.parts.automation.PartUpgradeable;
import appeng.tile.inventory.AppEngInternalAEInventory;
@@ -18,9 +16,6 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -87,6 +82,10 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos)
{
if( player.isSneaking() )
{
return false;
}
if( Platform.isServer() )
{
InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.FLUID_BUS_IO);
@@ -163,10 +162,7 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
}
public void setFluidInSlot(int id, IAEFluidStack fluid) {
ItemStack tmp = ItemFluidPacket.newStack(fluid == null ? null : fluid.getFluidStack());
if (tmp != null) {
tmp.setStackDisplayName(fluid.getFluidStack().getLocalizedName());
}
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack());
this.config.setInventorySlotContents(id, tmp);
}
@@ -31,7 +31,7 @@ public class FluidCellInventory implements IFluidCellInventory {
private final ItemStack cellItem;
private final ISaveProvider container;
private final static int MAX_TYPE = 1;
private int storedFluidCount;
private long storedFluidCount;
private short storedFluids;
private IItemList<IAEFluidStack> cellItems;
private final NBTTagCompound tagCompound;
@@ -78,7 +78,7 @@ public class FluidCellInventory implements IFluidCellInventory {
this.container = container;
this.tagCompound = Platform.openNbtData( o );
this.storedFluids = this.tagCompound.getShort( FLUID_TYPE_TAG );
this.storedFluidCount = this.tagCompound.getInteger( FLUID_COUNT_TAG );
this.storedFluidCount = this.tagCompound.getLong( FLUID_COUNT_TAG );
this.cellItems = null;
}
@@ -133,9 +133,7 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public boolean canHoldNewFluid() {
final long bytesFree = this.getFreeBytes();
return ( bytesFree > this.getBytesPerType() || ( bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0 ) ) && this.getRemainingFluidTypes() > 0;
return this.getRemainingFluidCount() > 0 && getRemainingFluidTypes() > 0;
}
@Override
@@ -150,8 +148,10 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public long getUsedBytes() {
final long bytesForItemCount = ( this.getStoredFluidCount() + this.getUnusedFluidCount() ) / 8 / 256;
return this.getStoredFluidTypes() * this.getBytesPerType() + bytesForItemCount;
long bytesForItemCount = (this.getStoredFluidCount() + this.getUnusedFluidCount()) / (8 * 256);
long tmp = this.getStoredFluidTypes() * this.getBytesPerType() + bytesForItemCount;
if (this.getUnusedFluidCount() > 0 && tmp < this.getTotalBytes()) tmp++;
return tmp;
}
@Override
@@ -178,8 +178,7 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public long getRemainingFluidCount() {
final long remaining = this.getFreeBytes() * 8 + this.getUnusedFluidCount();
final long remaining = (this.getTotalBytes() - (this.getTotalFluidTypes() * 8)) * 8 * 256 - this.getStoredFluidCount();
return remaining > 0 ? remaining : 0;
}
@@ -222,14 +221,15 @@ public class FluidCellInventory implements IFluidCellInventory {
for( int x = 0; x < types; x++ )
{
final FluidStack t = FluidStack.loadFluidStackFromNBT( this.tagCompound.getCompoundTag( fluidSlots[x] ) );
final AEFluidStack aet = AEFluidStack.create( t );
if( t != null )
if( aet != null )
{
t.amount = this.tagCompound.getInteger( fluidSlotCount[x] );
aet.setStackSize( this.tagCompound.getLong( fluidSlotCount[x] ) );
if( t.amount > 0 )
if( aet.getStackSize() > 0 )
{
this.cellItems.add( AEFluidStack.create( t ) );
this.cellItems.add( aet );
}
}
}
@@ -248,12 +248,12 @@ public class FluidCellInventory implements IFluidCellInventory {
private void updateFluidCount( final long delta )
{
this.storedFluidCount += delta;
this.tagCompound.setInteger( FLUID_COUNT_TAG, this.storedFluidCount );
this.tagCompound.setLong( FLUID_COUNT_TAG, this.storedFluidCount );
}
private void saveChanges()
{
int itemCount = 0;
long itemCount = 0;
int x = 0;
@@ -278,7 +278,7 @@ public class FluidCellInventory implements IFluidCellInventory {
* NBTBase tagSlotCount = tagCompound.getTag( itemSlotCount[x] ); if ( tagSlotCount instanceof
* NBTTagInt ) ((NBTTagInt) tagSlotCount).data = (int) v.getStackSize(); else
*/
this.tagCompound.setInteger( fluidSlotCount[x], (int) v.getStackSize() );
this.tagCompound.setLong( fluidSlotCount[x], v.getStackSize() );
x++;
}
@@ -313,7 +313,7 @@ public class FluidCellInventory implements IFluidCellInventory {
}
else
{
this.tagCompound.setInteger( FLUID_COUNT_TAG, itemCount );
this.tagCompound.setLong( FLUID_COUNT_TAG, itemCount );
}
// clean any old crusty stuff...
@@ -370,7 +370,6 @@ public class FluidCellInventory implements IFluidCellInventory {
this.updateFluidCount( remainingItemSlots );
this.saveChanges();
}
return r;
}
else
@@ -388,19 +387,19 @@ public class FluidCellInventory implements IFluidCellInventory {
if( this.canHoldNewFluid() ) // room for new type, and for at least one item!
{
final int remainingItemCount = (int) this.getRemainingFluidCount() - this.getBytesPerType() * 8;
final long remainingItemCount = this.getRemainingFluidCount() - this.getBytesPerType() * 8;
if( remainingItemCount > 0 )
{
if( input.getStackSize() > remainingItemCount )
{
final FluidStack toReturn = Util.cloneFluidStack(sharedFluidStack);
toReturn.amount = sharedFluidStack.amount - remainingItemCount;
toReturn.amount = (int) (sharedFluidStack.amount - remainingItemCount);
if( mode == Actionable.MODULATE )
{
final FluidStack toWrite = Util.cloneFluidStack( sharedFluidStack );
toWrite.amount = remainingItemCount;
toWrite.amount = (int) remainingItemCount;
this.cellItems.add( AEFluidStack.create( toWrite ) );
this.updateFluidCount( toWrite.amount );
@@ -54,6 +54,11 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
return (IFluidCellInventory) ( o instanceof IFluidCellInventory ? o : null );
}
@Override
public Iterable<IAEFluidStack> getPartitionInv() {
return (Iterable<IAEFluidStack>) Ae2Reflect.getPartitionList(this).getItems();
}
@Override
public boolean isPreformatted()
{
@@ -1,11 +1,14 @@
package com.glodblock.github.common.storage;
import appeng.api.config.IncludeExclude;
import appeng.api.storage.data.IAEFluidStack;
public interface IFluidCellInventoryHandler {
IFluidCellInventory getCellInv();
Iterable<IAEFluidStack> getPartitionInv();
boolean isPreformatted();
IncludeExclude getIncludeExcludeMode();
@@ -0,0 +1,20 @@
package com.glodblock.github.common.tabs;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.loader.ItemAndBlockHolder;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class FluidCraftingTabs extends CreativeTabs {
public static final FluidCraftingTabs INSTANCE = new FluidCraftingTabs(FluidCraft.MODID);
public FluidCraftingTabs(String name){
super(name);
}
@Override
public Item getTabIconItem() {
return ItemAndBlockHolder.DISCRETIZER.stack().getItem();
}
}
@@ -19,7 +19,6 @@ import appeng.me.GridAccessException;
import appeng.me.cache.CraftingGridCache;
import appeng.me.storage.MEInventoryHandler;
import appeng.tile.grid.AENetworkTile;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidDrop;
import java.util.ArrayList;
@@ -48,8 +47,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
@Override
@SuppressWarnings("rawtypes")
public List<IMEInventoryHandler> getCellArray(StorageChannel channel) {
/*conflict = !checkDiscreatizer();
if (conflict) return Collections.emptyList();*/
if (getProxy().isActive()) {
if (channel == StorageChannel.ITEMS) {
return Collections.singletonList(fluidDropInv.invHandler);
@@ -131,11 +128,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
updateState();
}
private boolean checkDiscreatizer() {
int amount = getProxy().getNode().getGrid().getMachines(this.getClass()).size();
return amount <= 1;
}
private class FluidDiscretizingInventory implements IMEInventory<IAEItemStack>, IMEMonitorHandlerReceiver<IAEFluidStack> {
private final MEInventoryHandler<IAEItemStack> invHandler = new MEInventoryHandler<>(this, getChannel());
@@ -147,7 +139,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
@Override
public IAEItemStack injectItems(IAEItemStack request, Actionable type, BaseActionSource src) {
/*if (conflict) return request;*/
IAEFluidStack fluidStack = ItemFluidDrop.getAeFluidStack(request);
if (fluidStack == null) {
return request;
@@ -164,13 +155,12 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.SIMULATE, src));
}
else {
return ItemFluidDrop.newAeStack(Platform.poweredInsert(energyGrid, fluidGrid, fluidStack, ownActionSource));
return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.MODULATE, src));
}
}
@Override
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src) {
/*if (conflict) return null;*/
IAEFluidStack fluidStack = ItemFluidDrop.getAeFluidStack(request);
if (fluidStack == null) {
return null;
@@ -187,13 +177,12 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.SIMULATE, src));
}
else {
return ItemFluidDrop.newAeStack(Platform.poweredExtraction(energyGrid, fluidGrid, fluidStack, ownActionSource));
return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.MODULATE, src));
}
}
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out) {
/*if (conflict) return out;*/
if (itemCache == null) {
itemCache = new ArrayList<>();
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
@@ -258,7 +247,6 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
@Override
@SuppressWarnings("rawtypes")
public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) {
/*if (conflict) return null;*/
ICraftingGrid craftingGrid;
try {
craftingGrid = getProxy().getGrid().getCache(ICraftingGrid.class);
@@ -1,20 +1,28 @@
package com.glodblock.github.common.tile;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.features.IStackSrc;
import appeng.me.GridAccessException;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.misc.TileInterface;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.DualityFluidInterface;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
@@ -22,26 +30,152 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import javax.annotation.Nullable;
import java.io.IOException;
public class TileFluidInterface extends TileInterface implements IFluidHandler
public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory
{
private final BaseActionSource ownActionSource = new MachineSource(this);
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) {
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return this.getTanks().drain(from.ordinal(), maxDrain, doDrain);
}
};
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
private IMEMonitor<IAEFluidStack> getFluidGrid() {
try {
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
} catch (GridAccessException e) {
return null;
@MENetworkEventSubscribe
public void stateChange(final MENetworkChannelsChanged c) {
fluidDuality.onChannelStateChange(c);
super.stateChange(c);
}
@MENetworkEventSubscribe
public void stateChange(final MENetworkPowerStatusChange c) {
fluidDuality.onPowerStateChange(c);
super.stateChange(c);
}
@Override
public void gridChanged() {
super.gridChanged();
fluidDuality.gridChanged();
}
public DualityFluidInterface getDualityFluid() {
return fluidDuality;
}
public AEFluidInventory getInternalFluid() {
return fluidDuality.getTanks();
}
public AppEngInternalAEInventory getConfig() {
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i ++) {
IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i);
if (fluid == null) {
config.setInventorySlotContents(i, null);
}
else {
config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
}
}
return config;
}
@Override
public TickingRequest getTickingRequest(IGridNode node) {
TickingRequest item = super.getTickingRequest(node);
TickingRequest fluid = fluidDuality.getTickingRequest(node);
return new TickingRequest(
Math.min(item.minTickRate, fluid.minTickRate),
Math.max(item.maxTickRate, fluid.maxTickRate),
item.isSleeping && fluid.isSleeping,
true);
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
TickRateModulation item = super.tickingRequest(node, ticksSinceLastCall);
TickRateModulation fluid = fluidDuality.tickingRequest(node, ticksSinceLastCall);
if (item.ordinal() >= fluid.ordinal()) {
return item;
} else {
return fluid;
}
}
private IEnergyGrid getEnergyGrid() {
try {
return getProxy().getGrid().getCache(IEnergyGrid.class);
} catch (GridAccessException e) {
return null;
@TileEvent( TileEventType.NETWORK_WRITE )
protected void writeToStream(ByteBuf data) throws IOException {
for (int i = 0; i < config.getSizeInventory(); i++) {
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
for (int j = 0; j < config.getSizeInventory(); j ++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
}
int fluidMask = 0;
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
if (getInternalFluid().getFluidInSlot(i) != null) {
fluidMask |= 1 << i;
}
}
data.writeByte(fluidMask);
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
IAEFluidStack fluid = getInternalFluid().getFluidInSlot(i);
if (fluid != null) {
fluid.writeToPacket(data);
}
}
}
@TileEvent( TileEventType.NETWORK_READ )
protected boolean readFromStream(ByteBuf data) throws IOException {
boolean changed = false;
for (int i = 0; i < config.getSizeInventory(); i++) {
ItemStack stack = ByteBufUtils.readItemStack(data);
if (!ItemStack.areItemStacksEqual(stack, config.getStackInSlot(i))) {
config.setInventorySlotContents(i, stack);
changed = true;
}
for (int j = 0; j < config.getSizeInventory(); j ++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
}
int fluidMask = data.readByte();
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
if ((fluidMask & (1 << i)) != 0) {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
if (fluid != null) { // this shouldn't happen, but better safe than sorry
IAEFluidStack origFluid = getInternalFluid().getFluidInSlot(i);
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
getInternalFluid().setFluidInSlot(i, fluid);
changed = true;
}
}
} else if (getInternalFluid().getFluidInSlot(i) != null) {
getInternalFluid().setFluidInSlot(i, null);
changed = true;
}
}
return changed;
}
@TileEvent( TileEventType.WORLD_NBT_READ )
public void readFromNBTEvent(NBTTagCompound data) {
config.readFromNBT(data, "ConfigInv");
for (int i = 0; i < config.getSizeInventory(); i ++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid));
}
getInternalFluid().readFromNBT(data, "FluidInv");
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
config.writeToNBT(data, "ConfigInv");
getInternalFluid().writeToNBT(data, "FluidInv");
return data;
}
@Nullable
@@ -61,42 +195,52 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
IEnergyGrid energyGrid = getEnergyGrid();
if (energyGrid == null || fluidGrid == null || resource == null)
return 0;
int ori = resource.amount;
IAEFluidStack remove;
if (doFill) {
remove = Platform.poweredInsert(energyGrid, fluidGrid, AEFluidStack.create(resource), ownActionSource);
} else {
remove = fluidGrid.injectItems(AEFluidStack.create(resource), Actionable.SIMULATE, ownActionSource);
}
return remove == null ? ori : (int) (ori - remove.getStackSize());
return fluidDuality.fill(from, resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return null;
return fluidDuality.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return null;
return fluidDuality.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return true;
return fluidDuality.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return false;
return true;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return new FluidTankInfo[]{new FluidTankInfo(null, 0)};
return fluidDuality.getTankInfo(from);
}
@Override
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
saveChanges();
markForUpdate();
fluidDuality.onFluidInventoryChanged(inv, slot);
}
public void setConfig(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
config.setInventorySlotContents(id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack()));
fluidDuality.getConfig().setFluidInSlot(id, fluidDuality.getStandardFluid(fluid));
}
}
public void setFluidInv(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
getInternalFluid().setFluidInSlot(id, fluid);
}
}
}
@@ -22,12 +22,13 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemFluidPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickable, IAEAppEngInventory {
public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickable, IAEAppEngInventory, IInventory {
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
private final BaseActionSource ownActionSource = new MachineSource(this);
@@ -63,12 +64,13 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab
inventory.setInventorySlotContents(0, null);
return TickRateModulation.SLEEP;
}
IAEFluidStack aeFluid = AEFluidStack.create(fluid);
IAEFluidStack aeFluid = AEFluidStack.create(fluid.copy());
IEnergyGrid energyGrid = node.getGrid().getCache(IEnergyGrid.class);
IMEMonitor<IAEFluidStack> fluidGrid = node.getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
IAEFluidStack remaining = Platform.poweredInsert(energyGrid, fluidGrid, aeFluid, ownActionSource);
if (remaining != null) {
if (remaining.getStackSize() == aeFluid.getStackSize()) {
inventory.setInventorySlotContents(0, ItemFluidPacket.newStack(remaining.getFluidStack()));
return TickRateModulation.SLOWER;
}
inventory.setInventorySlotContents(0, ItemFluidPacket.newStack(remaining.getFluidStack()));
@@ -99,4 +101,63 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab
inventory.readFromNBT(data, "Inventory");
}
@Override
public int getSizeInventory() {
return inventory.getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int slot) {
return inventory.getStackInSlot(slot);
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
return inventory.decrStackSize(slot, amount);
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return inventory.getStackInSlotOnClosing(slot);
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
inventory.setInventorySlotContents(slot, stack);
}
@Override
public String getInventoryName() {
return inventory.getInventoryName();
}
@Override
public boolean hasCustomInventoryName() {
return inventory.hasCustomInventoryName();
}
@Override
public int getInventoryStackLimit() {
return inventory.getInventoryStackLimit();
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return inventory.isUseableByPlayer(player);
}
@Override
public void openInventory() {
inventory.openInventory();
}
@Override
public void closeInventory() {
inventory.openInventory();
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
return inventory.isItemValidForSlot(slot, stack);
}
}
@@ -10,7 +10,6 @@ import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import com.glodblock.github.inventory.AeStackInventory;
import com.glodblock.github.inventory.AeStackInventoryImpl;
import com.glodblock.github.util.BlockPos;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -43,10 +42,6 @@ public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInve
@Override
public void getDrops(final World w, final int x, final int y, final int z, final List<ItemStack> drops ) {
getDrops(w, new BlockPos(x, y, z), drops);
}
public void getDrops(World world, BlockPos pos, List<ItemStack> drops) {
for (ItemStack stack : patternInv) {
if (stack != null) {
drops.add(stack);
@@ -149,6 +149,6 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return invFluids.getTankInfo(ForgeDirection.UNKNOWN);
return invFluids.getTankInfo(from);
}
}
@@ -0,0 +1,154 @@
package com.glodblock.github.common.tile;
import appeng.api.storage.data.IAEFluidStack;
import appeng.tile.AEBaseInvTile;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import javax.annotation.Nonnull;
import java.io.IOException;
public class TileLargeIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler {
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 27);
private final AEFluidInventory invFluids = new AEFluidInventory(this, 7, 64000);
@Nonnull
@Override
public IInventory getInternalInventory() {
return invItems;
}
public IAEFluidTank getFluidInventory() {
return invFluids;
}
@Override
public boolean canBeRotated() {
return false;
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) {
markForUpdate();
}
@Override
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) {
return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
}
@Override
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
saveChanges();
markForUpdate();
}
@TileEvent(TileEventType.NETWORK_WRITE)
protected void writeToStream(ByteBuf data) throws IOException {
for (int i = 0; i < invItems.getSizeInventory(); i++) {
ByteBufUtils.writeItemStack(data, invItems.getStackInSlot(i));
}
int fluidMask = 0;
for (int i = 0; i < invFluids.getSlots(); i++) {
if (invFluids.getFluidInSlot(i) != null) {
fluidMask |= 1 << i;
}
}
data.writeByte(fluidMask);
for (int i = 0; i < invFluids.getSlots(); i++) {
IAEFluidStack fluid = invFluids.getFluidInSlot(i);
if (fluid != null) {
fluid.writeToPacket(data);
}
}
}
@TileEvent(TileEventType.NETWORK_READ)
protected boolean readFromStream(ByteBuf data) throws IOException {
boolean changed = false;
for (int i = 0; i < invItems.getSizeInventory(); i++) {
ItemStack stack = ByteBufUtils.readItemStack(data);
if (!ItemStack.areItemStacksEqual(stack, invItems.getStackInSlot(i))) {
invItems.setInventorySlotContents(i, stack);
changed = true;
}
}
int fluidMask = data.readByte();
for (int i = 0; i < invFluids.getSlots(); i++) {
if ((fluidMask & (1 << i)) != 0) {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
if (fluid != null) { // this shouldn't happen, but better safe than sorry
IAEFluidStack origFluid = invFluids.getFluidInSlot(i);
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
invFluids.setFluidInSlot(i, fluid);
changed = true;
}
}
} else if (invFluids.getFluidInSlot(i) != null) {
invFluids.setFluidInSlot(i, null);
changed = true;
}
}
return changed;
}
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBTEvent(NBTTagCompound data) {
invItems.readFromNBT(data, "ItemInv");
invFluids.readFromNBT(data, "FluidInv");
}
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
invItems.writeToNBT(data, "ItemInv");
invFluids.writeToNBT(data, "FluidInv");
return data;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return invFluids.fill(from, resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return invFluids.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return invFluids.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return invFluids.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return invFluids.canDrain(from, fluid);
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return invFluids.getTankInfo(from);
}
}
@@ -0,0 +1,35 @@
package com.glodblock.github.common.tile;
import appeng.items.misc.ItemEncodedPattern;
import appeng.tile.AEBaseInvTile;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
public class TileOCPatternEditor extends AEBaseInvTile {
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 16);
@Override
public IInventory getInternalInventory() {
return invItems;
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) {
markForUpdate();
}
@Override
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) {
return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
}
@Override
public boolean isItemValidForSlot( final int i, final ItemStack itemstack ) {
return itemstack == null || itemstack.getItem() instanceof ItemEncodedPattern;
}
}
@@ -1,9 +1,6 @@
package com.glodblock.github.coremod;
import com.glodblock.github.coremod.transform.ContainerInterfaceTerminalTransformer;
import com.glodblock.github.coremod.transform.CraftingCpuTransformer;
import com.glodblock.github.coremod.transform.CraftingTreeNodeTransformer;
import com.glodblock.github.coremod.transform.DualityInterfaceTransformer;
import com.glodblock.github.coremod.transform.*;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
@@ -27,10 +24,18 @@ public class FCClassTransformer implements IClassTransformer {
case "appeng.container.implementations.ContainerInterfaceTerminal":
tform = ContainerInterfaceTerminalTransformer.INSTANCE;
break;
case "appeng.client.gui.implementations.GuiCraftingCPU":
case "appeng.client.gui.implementations.GuiCraftConfirm":
case "net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm":
tform = GuiCraftingTransformer.INSTANCE;
break;
case "appeng.integration.modules.NEI":
tform = NEITransfermer.INSTANCE;
break;
default:
return code;
}
System.out.println("[FCAE2] Transforming class: " + transformedName);
System.out.println("[AE2FC] Transforming class: " + transformedName);
return tform.transformClass(code);
}
@@ -1,14 +1,23 @@
package com.glodblock.github.coremod.hooker;
import appeng.api.config.Actionable;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.IMachineSet;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.implementations.GuiCraftConfirm;
import appeng.client.gui.implementations.GuiCraftingCPU;
import appeng.crafting.MECraftingInventory;
import appeng.me.MachineSet;
import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.parts.misc.PartInterface;
import appeng.tile.misc.TileInterface;
import appeng.util.InventoryAdaptor;
import com.glodblock.github.client.gui.GuiFluidCraftConfirm;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidInterface;
@@ -20,9 +29,12 @@ import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.SetBackedMachineSet;
import com.glodblock.github.util.Util;
import com.google.common.collect.Sets;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable;
import java.util.HashSet;
@@ -31,7 +43,7 @@ import java.util.Set;
public class CoreModHooks {
public static InventoryCrafting wrapCraftingBuffer(InventoryCrafting inv) {
return new FluidConvertingInventoryCrafting(Ae2Reflect.getCraftContainer(inv), Ae2Reflect.getCraftWidth(inv), inv.getSizeInventory()/Ae2Reflect.getCraftWidth(inv));
return new FluidConvertingInventoryCrafting(inv.eventHandler, inv.inventoryWidth, inv.getSizeInventory()/inv.inventoryWidth);
}
public static IAEItemStack wrapFluidPacketStack(IAEItemStack stack) {
@@ -44,6 +56,17 @@ public class CoreModHooks {
return stack;
}
public static ItemStack removeFluidPackets(InventoryCrafting inv, int index) {
ItemStack stack = inv.getStackInSlot(index);
if (stack != null && stack.getItem() instanceof ItemFluidPacket) {
FluidStack fluid = ItemFluidPacket.getFluidStack(stack);
return ItemFluidDrop.newStack(fluid);
}
else {
return stack;
}
}
@Nullable
public static InventoryAdaptor wrapInventory(@Nullable TileEntity tile, ForgeDirection face) {
return tile != null ? FluidConvertingInventoryAdaptor.wrap(tile, Util.from(face)) : null;
@@ -51,7 +74,14 @@ public class CoreModHooks {
public static long getCraftingByteCost(IAEItemStack stack) {
return stack.getItem() instanceof ItemFluidDrop
? (long)Math.ceil(stack.getStackSize() / 1000D) : stack.getStackSize();
? (long) Math.ceil(stack.getStackSize() / 1000D) : stack.getStackSize();
}
public static long getFluidDropsByteCost(long totalBytes, long originByte, IAEItemStack stack) {
if (stack != null && stack.getItem() instanceof ItemFluidDrop) {
return (long) Math.ceil(originByte / 1000D) + totalBytes;
}
return originByte + totalBytes;
}
public static IAEItemStack[] flattenFluidPackets(IAEItemStack[] stacks) {
@@ -88,4 +118,80 @@ public class CoreModHooks {
}
}
public static ItemStack displayFluid(IAEItemStack aeStack) {
if (aeStack.getItemStack() != null && aeStack.getItemStack().getItem() instanceof ItemFluidDrop) {
FluidStack fluid = ItemFluidDrop.getFluidStack(aeStack.getItemStack());
return ItemFluidPacket.newDisplayStack(fluid);
}
else return aeStack.getItemStack();
}
public static long getFluidSize(IAEItemStack aeStack) {
if (aeStack.getItemStack() != null && aeStack.getItemStack().getItem() instanceof ItemFluidDrop) {
return (long) Math.max(aeStack.getStackSize() / 1000D, 1);
}
else return aeStack.getStackSize();
}
public static void storeFluidItem(CraftingCPUCluster instance) {
final IGrid g = Ae2Reflect.getGrid(instance);
if( g == null )
{
return;
}
final IStorageGrid sg = g.getCache( IStorageGrid.class );
final IMEInventory<IAEItemStack> ii = sg.getItemInventory();
final IMEInventory<IAEFluidStack> jj = sg.getFluidInventory();
final MECraftingInventory inventory = Ae2Reflect.getCPUInventory(instance);
for( IAEItemStack is : inventory.getItemList() )
{
is = inventory.extractItems( is.copy(), Actionable.MODULATE, Ae2Reflect.getCPUSource(instance) );
if( is != null )
{
Ae2Reflect.postCPUChange(instance, is, Ae2Reflect.getCPUSource(instance));
if (is.getItem() instanceof ItemFluidDrop) {
IAEFluidStack fluidDrop = ItemFluidDrop.getAeFluidStack(is);
fluidDrop = jj.injectItems(fluidDrop, Actionable.MODULATE, Ae2Reflect.getCPUSource(instance));
if (fluidDrop == null) {
is = null;
} else {
is.setStackSize(fluidDrop.getStackSize());
}
} else {
is = ii.injectItems(is, Actionable.MODULATE, Ae2Reflect.getCPUSource(instance));
}
}
if( is != null )
{
inventory.injectItems( is, Actionable.MODULATE, Ae2Reflect.getCPUSource(instance) );
}
}
if( inventory.getItemList().isEmpty() )
{
Ae2Reflect.setCPUInventory(instance, new MECraftingInventory());
}
Ae2Reflect.markCPUDirty(instance);
}
public static ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) {
if (gui instanceof GuiFluidCraftConfirm) {
return ((GuiFluidCraftConfirm) gui).getHoveredStack();
}
return null;
}
public static boolean shouldShowTooltip(GuiContainer gui) {
if (gui instanceof GuiFluidCraftConfirm) {
return ((GuiFluidCraftConfirm)gui).getHoveredStack() == null;
}
return true;
}
}
@@ -6,7 +6,7 @@ import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper {
public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper {
public static final CraftingCpuTransformer INSTANCE = new CraftingCpuTransformer();
@@ -29,6 +29,8 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper {
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals("executeCrafting")) {
return new TransformExecuteCrafting(api, super.visitMethod(access, name, desc, signature, exceptions));
} else if (name.equals("cancel")) {
return new TransformStoreItems(api, super.visitMethod(access, name, desc, signature, exceptions));
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
@@ -38,6 +40,7 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper {
private static class TransformExecuteCrafting extends MethodVisitor {
private boolean gotInventory = false;
private int reach_stack = 0;
TransformExecuteCrafting(int api, MethodVisitor mv) {
super(api, mv);
@@ -58,8 +61,37 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper {
super.visitLineNumber(line, start);
}
@Override
public void visitJumpInsn(int opcode, Label label) {
if (opcode == Opcodes.IFNULL && reach_stack == 0) {
reach_stack = 1;
}
super.visitJumpInsn(opcode, label);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
if (reach_stack == 1) {
if (opcode == Opcodes.INVOKEINTERFACE
&& owner.equals("appeng/api/storage/data/IAEItemStack") && name.equals("getStackSize")) {
reach_stack = 2;
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"getFluidSize",
"(Lappeng/api/storage/data/IAEItemStack;)J",
false);
return;
}
}
if (opcode == Opcodes.INVOKEVIRTUAL
&& owner.equals("net/minecraft/inventory/InventoryCrafting") && (name.equals("getStackInSlot") || name.equals("func_70301_a"))) {
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"removeFluidPackets",
"(Lnet/minecraft/inventory/InventoryCrafting;I)Lnet/minecraft/item/ItemStack;",
false);
return;
}
super.visitMethodInsn(opcode, owner, name, desc, itf);
if (gotInventory) {
if (opcode == Opcodes.INVOKESTATIC
@@ -83,4 +115,27 @@ public class CraftingCpuTransformer extends FCClassTransformer.ClassMapper {
}
private static class TransformStoreItems extends MethodVisitor {
TransformStoreItems(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
if (opcode == Opcodes.INVOKESPECIAL
&& owner.equals("appeng/me/cluster/implementations/CraftingCPUCluster") && name.equals("storeItems")) {
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"storeFluidItem",
"(Lappeng/me/cluster/implementations/CraftingCPUCluster;)V",
false
);
} else {
super.visitMethodInsn(opcode, owner, name, desc, itf);
}
}
}
}
@@ -38,6 +38,7 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper
private static class TransformRequest extends MethodVisitor {
private boolean writingBytes = false;
private int cnt = 0;
TransformRequest(int api, MethodVisitor mv) {
super(api, mv);
@@ -62,6 +63,7 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper
if (writingBytes && opcode == Opcodes.INVOKEINTERFACE
&& owner.equals("appeng/api/storage/data/IAEItemStack") && name.equals("getStackSize")) {
writingBytes = false;
cnt ++;
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"getCraftingByteCost",
@@ -72,6 +74,27 @@ public class CraftingTreeNodeTransformer extends FCClassTransformer.ClassMapper
}
}
@Override
public void visitInsn(int opcode) {
if (writingBytes && cnt == 5 && opcode == Opcodes.LADD) {
super.visitVarInsn(Opcodes.ALOAD, 0);
super.visitFieldInsn(Opcodes.GETFIELD,
"appeng/crafting/CraftingTreeNode",
"what",
"Lappeng/api/storage/data/IAEItemStack;"
);
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"getFluidDropsByteCost",
"(JJLappeng/api/storage/data/IAEItemStack;)J",
false);
writingBytes = false;
cnt ++;
return;
}
super.visitInsn(opcode);
}
}
}
@@ -0,0 +1,58 @@
package com.glodblock.github.coremod.transform;
import com.glodblock.github.coremod.FCClassTransformer;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class GuiCraftingTransformer extends FCClassTransformer.ClassMapper {
public static final GuiCraftingTransformer INSTANCE = new GuiCraftingTransformer();
private GuiCraftingTransformer() {
// NO-OP
}
@Override
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
return new TransformGuiCrafting(Opcodes.ASM5, downstream);
}
private static class TransformGuiCrafting extends ClassVisitor {
TransformGuiCrafting(int api, ClassVisitor cv) {
super(api, cv);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if ("drawFG".equals(name)) {
return new TransformFluidIcon(api, super.visitMethod(access, name, desc, signature, exceptions));
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class TransformFluidIcon extends MethodVisitor {
TransformFluidIcon(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
if (opcode == Opcodes.INVOKEINTERFACE && owner.equals("appeng/api/storage/data/IAEItemStack") && name.equals("getItemStack")) {
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"displayFluid",
"(Lappeng/api/storage/data/IAEItemStack;)Lnet/minecraft/item/ItemStack;",
false);
}
else {
super.visitMethodInsn(opcode, owner, name, desc, itf);
}
}
}
}
@@ -0,0 +1,93 @@
package com.glodblock.github.coremod.transform;
import com.glodblock.github.coremod.FCClassTransformer;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class NEITransfermer extends FCClassTransformer.ClassMapper {
public static final NEITransfermer INSTANCE = new NEITransfermer();
private NEITransfermer() {
// NO-OP
}
@Override
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
return new TransformNEI(Opcodes.ASM5, downstream);
}
private static class TransformNEI extends ClassVisitor {
TransformNEI(int api, ClassVisitor cv) {
super(api, cv);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
switch (name) {
case "getStackUnderMouse":
return new TransformStackUnderMouse(api, super.visitMethod(access, name, desc, signature, exceptions));
case "shouldShowTooltip":
return new TransformShowTooltip(api, super.visitMethod(access, name, desc, signature, exceptions));
default:
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
}
private static class TransformStackUnderMouse extends MethodVisitor {
TransformStackUnderMouse(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitInsn(int opcode) {
if (opcode == Opcodes.ACONST_NULL) {
super.visitVarInsn(Opcodes.ALOAD, 1);
super.visitVarInsn(Opcodes.ILOAD, 2);
super.visitVarInsn(Opcodes.ILOAD, 3);
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"getStackUnderMouse",
"(Lnet/minecraft/client/gui/inventory/GuiContainer;II)Lnet/minecraft/item/ItemStack;",
false
);
return;
}
super.visitInsn(opcode);
}
}
private static class TransformShowTooltip extends MethodVisitor {
int const_1 = 0;
TransformShowTooltip(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitInsn(int opcode) {
if (opcode == Opcodes.ICONST_1 && const_1 == 2) {
super.visitVarInsn(Opcodes.ALOAD, 1);
super.visitMethodInsn(Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooks",
"shouldShowTooltip",
"(Lnet/minecraft/client/gui/inventory/GuiContainer;)Z",
false
);
const_1 ++;
return;
}
if (opcode == Opcodes.ICONST_1) {
const_1 ++;
}
super.visitInsn(opcode);
}
}
}
@@ -0,0 +1,275 @@
package com.glodblock.github.crossmod.opencomputers;
import appeng.items.misc.ItemEncodedPattern;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.tile.TileOCPatternEditor;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import li.cil.oc.api.driver.EnvironmentProvider;
import li.cil.oc.api.driver.NamedBlock;
import li.cil.oc.api.internal.Database;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import li.cil.oc.api.network.Component;
import li.cil.oc.api.network.ManagedEnvironment;
import li.cil.oc.api.network.Node;
import li.cil.oc.api.prefab.DriverSidedTileEntity;
import li.cil.oc.integration.ManagedTileEntityEnvironment;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
public class DriverOCPatternEditor extends DriverSidedTileEntity {
public DriverOCPatternEditor() {
}
@Override
public Class<?> getTileEntityClass() {
return TileOCPatternEditor.class;
}
@Override
public ManagedEnvironment createEnvironment(World world, int x, int y, int z, ForgeDirection forgeDirection) {
return new DriverOCPatternEditor.Environment((TileOCPatternEditor) world.getTileEntity(x, y, z));
}
public static class Environment extends ManagedTileEntityEnvironment<TileOCPatternEditor>
implements NamedBlock {
public Environment(TileOCPatternEditor tileEntity) {
super(tileEntity, NameConst.BLOCK_OC_PATTERN_EDITOR);
}
private int optSlot(Arguments args, IInventory inv, int index, int def) {
if (index >= 0 && index < args.count()) {
int slot = args.checkInteger(index) - 1;
if (slot < 0 || slot >= inv.getSizeInventory()) {
throw new IllegalArgumentException("invalid slot");
}
return slot;
}
else {
return def;
}
}
private int checkSlot(Arguments args, IInventory inv, int index) {
if (index >= 0 && index < args.count()) {
int slot = args.checkInteger(index) - 1;
if (slot < 0 || slot >= inv.getSizeInventory()) {
throw new IllegalArgumentException("invalid slot");
}
return slot;
}
else {
throw new IllegalArgumentException("invalid slot");
}
}
private boolean validPattern(ItemStack pattern) {
if (pattern == null) {
throw new IllegalArgumentException("No pattern here!");
}
if (pattern.getItem() instanceof ItemEncodedPattern && !(pattern.getItem() instanceof ItemFluidEncodedPattern)) {
ItemEncodedPattern iep = (ItemEncodedPattern) pattern.getItem();
return iep.getOutput(pattern) == null;
}
return true;
}
private ItemStack getStack(Arguments args) {
if (args.count() > 1) {
String address;
int entry;
int size;
if (args.isString(0)) {
address = args.checkString(0);
entry = args.checkInteger(1);
size = args.optInteger(2, 1);
}
else {
address = args.checkString(1);
entry = args.checkInteger(2);
size = args.optInteger(3, 1);
}
Node node = node().network().node(address);
if (node instanceof Component) {
if (node.host() instanceof Database) {
ItemStack dbStack = ((Database) node.host()).getStackInSlot(entry - 1);
if (dbStack == null || size < 1) {
return null;
}
else {
dbStack.stackSize = Math.min(size, dbStack.getMaxStackSize());
return dbStack;
}
}
else {
throw new IllegalArgumentException("not a database");
}
}
else {
throw new IllegalArgumentException("no such component");
}
}
else {
return null;
}
}
private Object[] clearInterfacePattern(Context context, Arguments args, String tag) {
IInventory inv = tileEntity.getInternalInventory();
ItemStack pattern = inv.getStackInSlot(checkSlot(args, inv, 0));
if (validPattern(pattern)) {
NBTTagCompound encodedValue = pattern.getTagCompound();
int slot = checkSlot(args, inv, 0);
if (encodedValue == null)
throw new IllegalArgumentException("No pattern here!");
NBTTagList nbt = encodedValue.getTagList(tag, 10);
int index = args.checkInteger(1) - 1;
if (index < 0)
throw new IllegalArgumentException("Invalid index!");
nbt.removeTag(index);
encodedValue.setTag(tag, nbt);
pattern.setTagCompound(encodedValue);
inv.setInventorySlotContents(slot, null);
inv.setInventorySlotContents(slot, pattern);
context.pause(0.1);
return new Object[] {true};
} else {
throw new IllegalArgumentException("Not Fluid Encoded pattern!");
}
}
private Object[] setPatternSlot(Context context, Arguments args, String tag, boolean fluid) {
IInventory inv = tileEntity.getInternalInventory();
int slot = args.isString(0) ? 0 : optSlot(args, inv, 0, 0);
ItemStack stack = getStack(args);
if (fluid) {
FluidStack fluids = Util.getFluidFromItem(stack);
stack = ItemFluidDrop.newStack(fluids);
}
int index = args.checkInteger(4) - 1;
if (index < 0 || index > 511)
throw new IllegalArgumentException("Invalid index!");
ItemStack pattern = inv.getStackInSlot(slot);
if (validPattern(pattern)) {
NBTTagCompound encodedValue = pattern.getTagCompound();
if (encodedValue == null)
throw new IllegalArgumentException("No pattern here!");
NBTTagList inTag = encodedValue.getTagList(tag, 10);
while (inTag.tagCount() <= index)
inTag.appendTag(new NBTTagCompound());
if (stack != null) {
NBTTagCompound nbt = new NBTTagCompound();
AEItemStack aeStack = AEItemStack.create(stack);
aeStack.writeToNBT(nbt);
inTag.func_150304_a(index, nbt);
}
else {
inTag.removeTag(index);
}
encodedValue.setTag(tag, inTag);
pattern.setTagCompound(encodedValue);
inv.setInventorySlotContents(slot, null);
inv.setInventorySlotContents(slot, pattern);
context.pause(0.1);
return new Object[] {true};
} else {
throw new IllegalArgumentException("Not Fluid Encoded pattern!");
}
}
@Callback(doc = "function([slot:number]):table -- Get the configuration of the interface.")
public Object[] getInterfaceConfiguration(Context context, Arguments args) {
IInventory config = tileEntity.getInternalInventory();
int slot = optSlot(args, config, 0, 0);
ItemStack stack = config.getStackInSlot(slot);
if (!validPattern(stack )) {
throw new IllegalArgumentException("Not Fluid Encoded pattern!");
}
return new Object[]{stack};
}
@Callback(doc = "function([slot:number][, database:address, entry:number[, size:number]]):boolean -- Configure the interface.")
public Object[] setInterfaceConfiguration(Context context, Arguments args) {
IInventory config = tileEntity.getInternalInventory();
int slot = args.isString(0) ? 0 : optSlot(args, config, 0, 0);
config.setInventorySlotContents(slot, getStack(args));
context.pause(0.5);
return new Object[] {true};
}
@Callback(doc = "function([slot:number]):table -- Get the given pattern in the interface.")
public Object[] getInterfacePattern(Context context, Arguments args) {
IInventory inv = tileEntity.getInternalInventory();
int slot = optSlot(args, inv, 0, 0);
ItemStack stack = inv.getStackInSlot(slot);
return new Object[] {stack};
}
@Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern item input at the given index.")
public Object[] setInterfacePatternItemInput(Context context, Arguments args) {
return setPatternSlot(context, args, "in", false);
}
@Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern item output at the given index.")
public Object[] setInterfacePatternItemOutput(Context context, Arguments args) {
return setPatternSlot(context, args, "out", false);
}
@Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern fluid input at the given index.")
public Object[] setInterfacePatternFluidInput(Context context, Arguments args) {
return setPatternSlot(context, args, "in", true);
}
@Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern fluid output at the given index.")
public Object[] setInterfacePatternFluidOutput(Context context, Arguments args) {
return setPatternSlot(context, args, "out", true);
}
@Callback(doc = "function(slot:number, index:number):boolean -- Clear pattern input at the given index.")
public Object[] clearInterfacePatternInput(Context context, Arguments args) {
return clearInterfacePattern(context, args, "in");
}
@Callback(doc = "function(slot:number, index:number):boolean -- Clear pattern output at the given index.")
public Object[] clearInterfacePatternOutput(Context context, Arguments args) {
return clearInterfacePattern(context, args, "out");
}
@Override
public String preferredName() {
return NameConst.BLOCK_OC_PATTERN_EDITOR;
}
@Override
public int priority() {
return 5;
}
}
public static class Provider implements EnvironmentProvider {
Provider() {
}
@Override
public Class<?> getEnvironment(ItemStack itemStack) {
if (itemStack != null && itemStack.isItemEqual(ItemAndBlockHolder.OC_EDITOR.stack())) {
return DriverOCPatternEditor.Environment.class;
}
return null;
}
}
}
@@ -0,0 +1,12 @@
package com.glodblock.github.crossmod.opencomputers;
import li.cil.oc.api.Driver;
public class OCDriverInit {
public static void run() {
Driver.add(new DriverOCPatternEditor());
Driver.add(new DriverOCPatternEditor.Provider());
}
}
@@ -5,8 +5,6 @@ import appeng.core.AELog;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.util.Util;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@@ -14,14 +12,12 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidTank;
import java.util.Objects;
public class AEFluidInventory implements IAEFluidTank
{
private final IAEFluidStack[] fluids;
private final IAEFluidInventory handler;
private final int capacity;
private FluidTankInfo[] props = null;
public int lastIndex;
public AEFluidInventory( final IAEFluidInventory handler, final int slots, final int capcity )
{
@@ -40,9 +36,9 @@ public class AEFluidInventory implements IAEFluidTank
{
if( slot >= 0 && slot < this.getSlots() )
{
if( Objects.equals( this.fluids[slot], fluid ) )
if( fluid != null && this.fluids[slot] != null && fluid.getFluidStack().isFluidEqual(this.fluids[slot].getFluidStack()) )
{
if( fluid != null && fluid.getStackSize() != this.fluids[slot].getStackSize() )
if(fluid.getStackSize() != this.fluids[slot].getStackSize())
{
this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) );
this.onContentChanged( slot );
@@ -83,6 +79,15 @@ public class AEFluidInventory implements IAEFluidTank
return null;
}
public FluidStack getFluidStackInSlot( final int slot )
{
if( getFluidInSlot(slot) != null )
{
return getFluidInSlot(slot).getFluidStack();
}
return null;
}
@Override
public int getSlots()
{
@@ -92,16 +97,12 @@ public class AEFluidInventory implements IAEFluidTank
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from)
{
if( this.props == null )
FluidTankInfo[] props = new FluidTankInfo[this.getSlots()];
for( int i = 0; i < this.getSlots(); ++i )
{
this.props = new FluidTankInfo[this.getSlots()];
for( int i = 0; i < this.getSlots(); ++i )
{
this.props[i] = new FluidTankInfo(new FluidTankPropertiesWrapper( i ));
}
props[i] = new FluidTankInfo(new FluidTankPropertiesWrapper( i ));
}
return this.props;
return props;
}
public int fill( final int slot, final FluidStack resource, final boolean doFill )
@@ -146,7 +147,7 @@ public class AEFluidInventory implements IAEFluidTank
public FluidStack drain( final int slot, final FluidStack resource, final boolean doDrain )
{
final IAEFluidStack fluid = this.fluids[slot];
if(fluid == null || !fluid.getFluidStack().equals(resource))
if(fluid == null || !fluid.getFluidStack().isFluidEqual(resource))
{
return null;
}
@@ -217,6 +218,9 @@ public class AEFluidInventory implements IAEFluidTank
FluidStack totalDrained = null;
for( int slot = 0; slot < this.getSlots(); ++slot )
{
if (!fluid.isFluidEqual(getFluidStackInSlot(slot))) {
continue;
}
FluidStack drain = this.drain( slot, resource, doDrain );
if( drain != null )
{
@@ -250,13 +254,19 @@ public class AEFluidInventory implements IAEFluidTank
FluidStack totalDrained = null;
int toDrain = maxDrain;
for( int slot = 0; slot < this.getSlots(); ++slot )
for( int slot = lastIndex; slot < this.getSlots(); ++slot )
{
if (this.getFluidInSlot(slot) == null) {
if(slot == this.getSlots()-1) lastIndex = 0;
continue;
}
if( totalDrained == null )
{
totalDrained = this.drain( slot, toDrain, doDrain );
if( totalDrained != null )
{
lastIndex = slot;
toDrain -= totalDrained.amount;
}
}
@@ -380,7 +390,7 @@ public class AEFluidInventory implements IAEFluidTank
@Override
public int fill(FluidStack resource, boolean doFill) {
if (resource == null || (getFluid() != null && !resource.equals(getFluid()))) return 0;
if (resource == null || (getFluid() != null && !resource.isFluidEqual(getFluid()))) return 0;
int acc = 0;
if (getFluid() == null) {
acc = Math.min(resource.amount, getCapacity());
@@ -0,0 +1,57 @@
package com.glodblock.github.inventory;
import appeng.core.AELog;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/**
* Since there is no ae2 available now for compiling, we copied it over, and it will need to be removed in the future.
*/
@Deprecated
public class BiggerAppEngInventory extends AppEngInternalInventory {
private final ItemStack[] inv;
public BiggerAppEngInventory(IAEAppEngInventory inventory, int size) {
super(inventory, size);
inv = ObfuscationReflectionHelper.getPrivateValue(AppEngInternalInventory.class, this, "inv");
}
protected void writeToNBT(final NBTTagCompound target) {
for (int x = 0; x < this.getSizeInventory(); x++) {
try {
final NBTTagCompound c = new NBTTagCompound();
if (this.inv[x] != null) {
this.inv[x].writeToNBT(c);
c.setInteger("Count", this.inv[x].stackSize);
}
target.setTag("#" + x, c);
} catch (final Exception ignored) {
}
}
}
public void readFromNBT(final NBTTagCompound target) {
for (int x = 0; x < this.getSizeInventory(); x++) {
try {
final NBTTagCompound c = target.getCompoundTag("#" + x);
if (c != null) {
ItemStack stack = ItemStack.loadItemStackFromNBT(c);
if (stack != null) {
stack.stackSize = c.getInteger("Count");
}
this.inv[x] = stack;
}
} catch (final Exception e) {
AELog.debug(e);
}
}
}
}
@@ -1,17 +1,23 @@
package com.glodblock.github.inventory;
import appeng.api.config.FuzzyMode;
import appeng.api.config.InsertionMode;
import appeng.tile.misc.TileInterface;
import appeng.tile.networking.TileCableBus;
import appeng.util.InventoryAdaptor;
import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.ItemSlot;
import cofh.api.transport.IItemDuct;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
@@ -30,28 +36,48 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
// sometimes i wish 1.7.10 has cap system.
ForgeDirection f = Util.from(face);
TileEntity inter = capProvider.getWorldObj().getTileEntity(capProvider.xCoord + f.offsetX, capProvider.yCoord + f.offsetY, capProvider.zCoord + f.offsetZ);
if (!Config.noFluidPacket && !(inter instanceof TileFluidInterface || (inter instanceof TileCableBus && ((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface)))
if (!Config.noFluidPacket && !(inter instanceof TileFluidInterface ||
(inter instanceof TileCableBus && (((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface || ((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidExportBus))))
return InventoryAdaptor.getAdaptor(capProvider, f);
IInventory item = capProvider instanceof IInventory ? (IInventory) capProvider : null;
InventoryAdaptor item = InventoryAdaptor.getAdaptor(capProvider, f);
IFluidHandler fluid = capProvider instanceof IFluidHandler ? (IFluidHandler) capProvider : null;
return new FluidConvertingInventoryAdaptor(item, fluid, face);
boolean onmi = false;
if (inter instanceof TileInterface) {
onmi = ((TileInterface) inter).getTargets().size() > 1;
}
Object conduct = null;
if (ModAndClassUtil.COFH && capProvider instanceof IItemDuct) {
conduct = capProvider;
}
return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi, conduct);
}
private final InventoryAdaptor invItems;
private final IFluidHandler invFluids;
private final ForgeDirection side;
private final BlockPos posInterface;
private final Object eioDuct;
private final boolean onmi;
public FluidConvertingInventoryAdaptor(@Nullable IInventory invItems, @Nullable IFluidHandler invFluids, EnumFacing facing) {
this.invItems = invItems != null ? InventoryAdaptor.getAdaptor(invItems, Util.from(facing)) : null;
public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids, EnumFacing facing, BlockPos pos, boolean isOnmi, Object eioConduct) {
this.invItems = invItems;
this.invFluids = invFluids;
this.side = Util.from(facing);
this.posInterface = pos;
this.eioDuct = eioConduct;
this.onmi = isOnmi;
}
@Override
public ItemStack addItems(ItemStack toBeAdded) {
if (toBeAdded.getItem() instanceof ItemFluidPacket) {
public ItemStack addItems( ItemStack toBeAdded, InsertionMode insertionMode ) {
if (toBeAdded.getItem() instanceof ItemFluidPacket || toBeAdded.getItem() instanceof ItemFluidDrop) {
if (invFluids != null) {
FluidStack fluid = ItemFluidPacket.getFluidStack(toBeAdded);
FluidStack fluid;
if( toBeAdded.getItem() instanceof ItemFluidPacket ) {
fluid = ItemFluidPacket.getFluidStack(toBeAdded);
} else {
fluid = ItemFluidDrop.getFluidStack(toBeAdded);
}
if (fluid != null) {
int filled = invFluids.fill(side, fluid, true);
if (filled > 0) {
@@ -62,14 +88,58 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
return toBeAdded;
}
return invItems != null ? invItems.addItems(toBeAdded) : toBeAdded;
if (eioDuct != null) {
return ((IItemDuct) eioDuct).insertItem(side, toBeAdded);
}
return invItems != null ? invItems.addItems(toBeAdded,insertionMode) : toBeAdded;
}
@Override
public ItemStack addItems(ItemStack toBeAdded) {
return addItems(toBeAdded, InsertionMode.DEFAULT);
}
@Override
public ItemStack simulateAdd(ItemStack toBeSimulated) {
if (toBeSimulated.getItem() instanceof ItemFluidPacket) {
return simulateAdd(toBeSimulated, InsertionMode.DEFAULT);
}
@Override
public ItemStack simulateAdd(ItemStack toBeSimulated, InsertionMode insertionMode) {
if (toBeSimulated.getItem() instanceof ItemFluidPacket || toBeSimulated.getItem() instanceof ItemFluidDrop) {
if (onmi) {
boolean sus = false;
FluidStack fluid;
if( toBeSimulated.getItem() instanceof ItemFluidPacket ) {
fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
} else {
fluid = ItemFluidDrop.getFluidStack(toBeSimulated);
}
if (fluid != null) {
for (ForgeDirection dir : ForgeDirection.values()) {
TileEntity te = posInterface.getOffSet(dir).getTileEntity();
if (te instanceof IFluidHandler) {
int filled = ((IFluidHandler) te).fill(dir.getOpposite(), fluid, false);
if (filled > 0) {
sus = true;
break;
}
}
}
} else {
sus = true;
}
return sus ? null : toBeSimulated;
}
if (invFluids != null) {
FluidStack fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
FluidStack fluid;
if( toBeSimulated.getItem() instanceof ItemFluidPacket ) {
fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
} else {
fluid = ItemFluidDrop.getFluidStack(toBeSimulated);
}
if (fluid != null) {
int filled = invFluids.fill(side, fluid, false);
if (filled > 0) {
@@ -80,7 +150,11 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
return toBeSimulated;
}
return invItems != null ? invItems.simulateAdd(toBeSimulated) : toBeSimulated;
//Assert EIO conduct can hold all item, as it is the origin practice in AE2
if (eioDuct != null) {
return null;
}
return invItems != null ? invItems.simulateAdd(toBeSimulated, insertionMode) : toBeSimulated;
}
@Override
@@ -16,7 +16,7 @@ public class FluidConvertingInventoryCrafting extends InventoryCrafting {
@Override
public void setInventorySlotContents(int index, ItemStack stack) {
if (stack.getItem() instanceof ItemFluidDrop) {
if (stack != null && stack.getItem() instanceof ItemFluidDrop) {
FluidStack fluid = ItemFluidDrop.getFluidStack(stack);
if (fluid != null) {
super.setInventorySlotContents(index, ItemFluidPacket.newStack(new FluidStack(fluid, stack.stackSize)));
@@ -0,0 +1,203 @@
package com.glodblock.github.inventory;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.StorageFilter;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.util.item.AEFluidStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import java.util.*;
public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
private final IFluidHandler handler;
private IItemList<IAEFluidStack> cache = AEApi.instance().storage().createFluidList();
private final HashMap<IMEMonitorHandlerReceiver<IAEFluidStack>, Object> listeners = new HashMap<>();
private BaseActionSource mySource;
private StorageFilter mode;
public MEMonitorIFluidHandler(IFluidHandler handler) {
this.mode = StorageFilter.EXTRACTABLE_ONLY;
this.handler = handler;
}
public void addListener(IMEMonitorHandlerReceiver<IAEFluidStack> l, Object verificationToken) {
this.listeners.put(l, verificationToken);
}
public void removeListener(IMEMonitorHandlerReceiver<IAEFluidStack> l) {
this.listeners.remove(l);
}
public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) {
int filled = this.handler.fill(ForgeDirection.UNKNOWN, input.getFluidStack(), type == Actionable.MODULATE);
if (filled == 0) {
return input.copy();
} else if ((long)filled == input.getStackSize()) {
return null;
} else {
IAEFluidStack o = input.copy();
o.setStackSize(input.getStackSize() - (long)filled);
if (type == Actionable.MODULATE) {
IAEFluidStack added = o.copy();
this.cache.add(added);
this.postDifference(Collections.singletonList(added));
this.onTick();
}
return o;
}
}
public IAEFluidStack extractItems(IAEFluidStack request, Actionable type, BaseActionSource src) {
FluidStack removed = this.handler.drain(ForgeDirection.UNKNOWN, request.getFluidStack(), type == Actionable.MODULATE);
if (removed != null && removed.amount != 0) {
IAEFluidStack o = request.copy();
o.setStackSize(removed.amount);
if (type == Actionable.MODULATE) {
IAEFluidStack cachedStack = this.cache.findPrecise(request);
if (cachedStack != null) {
cachedStack.decStackSize(o.getStackSize());
this.postDifference(Collections.singletonList(o.copy().setStackSize(-o.getStackSize())));
}
}
return o;
} else {
return null;
}
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.FLUIDS;
}
//*Decompiled Stuff*//
public TickRateModulation onTick() {
boolean changed = false;
List<IAEFluidStack> changes = new ArrayList<>();
FluidTankInfo[] tankProperties = this.handler.getTankInfo(ForgeDirection.UNKNOWN);
IItemList<IAEFluidStack> currentlyOnStorage = AEApi.instance().storage().createFluidList();
for (FluidTankInfo tankProperty : tankProperties) {
if (this.mode != StorageFilter.EXTRACTABLE_ONLY || this.handler.drain(ForgeDirection.UNKNOWN, 1, false) != null) {
currentlyOnStorage.add(AEFluidStack.create(tankProperty.fluid));
}
}
Iterator<?> var9 = this.cache.iterator();
IAEFluidStack is;
while(var9.hasNext()) {
is = (IAEFluidStack)var9.next();
is.setStackSize(-is.getStackSize());
}
var9 = currentlyOnStorage.iterator();
while(var9.hasNext()) {
is = (IAEFluidStack)var9.next();
this.cache.add(is);
}
var9 = this.cache.iterator();
while(var9.hasNext()) {
is = (IAEFluidStack)var9.next();
if (is.getStackSize() != 0L) {
changes.add(is);
}
}
this.cache = currentlyOnStorage;
if (!changes.isEmpty()) {
this.postDifference(changes);
changed = true;
}
return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
}
private void postDifference(Iterable<IAEFluidStack> a) {
if (a != null) {
Iterator i = this.listeners.entrySet().iterator();
while(i.hasNext()) {
Map.Entry<IMEMonitorHandlerReceiver<IAEFluidStack>, Object> l = (Map.Entry)i.next();
IMEMonitorHandlerReceiver key = l.getKey();
if (key.isValid(l.getValue())) {
key.postChange(this, a, this.getActionSource());
} else {
i.remove();
}
}
}
}
public AccessRestriction getAccess() {
return AccessRestriction.READ_WRITE;
}
public boolean isPrioritized(IAEFluidStack input) {
return false;
}
public boolean canAccept(IAEFluidStack input) {
return true;
}
public int getPriority() {
return 0;
}
public int getSlot() {
return 0;
}
public boolean validForPass(int i) {
return true;
}
public IItemList<IAEFluidStack> getAvailableItems(IItemList out) {
Iterator var2 = this.cache.iterator();
while(var2.hasNext()) {
IAEFluidStack fs = (IAEFluidStack)var2.next();
out.addStorage(fs);
}
return out;
}
public IItemList<IAEFluidStack> getStorageList() {
return this.cache;
}
private StorageFilter getMode() {
return this.mode;
}
public void setMode(StorageFilter mode) {
this.mode = mode;
}
private BaseActionSource getActionSource() {
return this.mySource;
}
public void setActionSource(BaseActionSource mySource) {
this.mySource = mySource;
}
}
@@ -3,13 +3,15 @@ package com.glodblock.github.inventory.gui;
import appeng.api.storage.ITerminalHost;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.container.implementations.ContainerCraftingStatus;
import appeng.container.implementations.ContainerInterface;
import appeng.container.implementations.ContainerPriority;
import appeng.helpers.IPriorityHost;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.*;
import com.glodblock.github.common.parts.FCBasePart;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.common.tile.*;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
@@ -18,6 +20,90 @@ import java.util.List;
public enum GuiType {
OC_PATTERN_EDITOR(new TileGuiFactory<TileOCPatternEditor>(TileOCPatternEditor.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileOCPatternEditor inv) {
return new ContainerOCPatternEditor(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, TileOCPatternEditor inv) {
return new GuiOCPatternEditor(player.inventory, inv);
}
}),
DUAL_INTERFACE_PART(new PartGuiFactory<PartFluidInterface>(PartFluidInterface.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartFluidInterface inv) {
return new ContainerInterface(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, PartFluidInterface inv) {
return new GuiDualInterface(player.inventory, inv);
}
}),
DUAL_INTERFACE_FLUID_PART(new PartGuiFactory<PartFluidInterface>(PartFluidInterface.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartFluidInterface inv) {
return new ContainerFluidInterface(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, PartFluidInterface inv) {
return new GuiFluidInterface(player.inventory, inv);
}
}),
DUAL_INTERFACE(new TileGuiFactory<TileFluidInterface>(TileFluidInterface.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileFluidInterface inv) {
return new ContainerInterface(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, TileFluidInterface inv) {
return new GuiDualInterface(player.inventory, inv);
}
}),
DUAL_INTERFACE_FLUID(new TileGuiFactory<TileFluidInterface>(TileFluidInterface.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileFluidInterface inv) {
return new ContainerFluidInterface(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, TileFluidInterface inv) {
return new GuiFluidInterface(player.inventory, inv);
}
}),
DUAL_INTERFACE_PRIORITY_PART(new PartGuiFactory<IPriorityHost>(IPriorityHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
return new ContainerPriority(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IPriorityHost inv) {
return new GuiFCPriority(player.inventory, inv);
}
}),
DUAL_INTERFACE_PRIORITY(new TileGuiFactory<IPriorityHost>(IPriorityHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
return new ContainerPriority(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IPriorityHost inv) {
return new GuiFCPriority(player.inventory, inv);
}
}),
FLUID_BUS_IO(new PartGuiFactory<PartSharedFluidBus>(PartSharedFluidBus.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartSharedFluidBus inv) {
@@ -42,6 +128,18 @@ public enum GuiType {
}
}),
LARGE_INGREDIENT_BUFFER(new TileGuiFactory<TileLargeIngredientBuffer>(TileLargeIngredientBuffer.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileLargeIngredientBuffer inv) {
return new ContainerLargeIngredientBuffer(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, TileLargeIngredientBuffer inv) {
return new GuiLargeIngredientBuffer(player.inventory, inv);
}
}),
FLUID_PAT_TERM_CRAFTING_STATUS(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
@Override
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
@@ -54,6 +152,18 @@ public enum GuiType {
}
}),
FLUID_TERMINAL(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
return new ContainerFluidTerminal(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
return new GuiFluidTerminal(player.inventory, inv);
}
}),
FLUID_PATTERN_TERMINAL(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
@@ -124,6 +234,18 @@ public enum GuiType {
protected Object createClientGui(EntityPlayer player, TileFluidPacketDecoder inv) {
return new GuiFluidPacketDecoder(player.inventory, inv);
}
}),
PATTERN_VALUE_SET(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
@Override
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
return new ContainerPatternValueAmount(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, FCBasePart inv) {
return new GuiPatternValueAmount(player.inventory, inv);
}
});
public static final List<GuiType> VALUES = ImmutableList.copyOf(values());
@@ -1,7 +1,6 @@
package com.glodblock.github.inventory.gui;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import appeng.client.gui.AEBaseGui;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.util.ResourceLocation;
@@ -23,8 +22,8 @@ public class MouseRegionManager {
}
public boolean onClick(int mX, int mY, int button) {
mX -= Ae2ReflectClient.getGuiLeft(gui);
mY -= Ae2ReflectClient.getGuiTop(gui);
mX -= gui.guiLeft;
mY -= gui.guiTop;
for (Region region : regions) {
if (region.containsMouse(mX, mY) && region.handler.onClick(button)) {
gui.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1F));
@@ -35,12 +34,13 @@ public class MouseRegionManager {
}
public void render(int mX, int mY) {
mX -= Ae2ReflectClient.getGuiLeft(gui);
mY -= Ae2ReflectClient.getGuiTop(gui);
mX -= gui.guiLeft;
mY -= gui.guiTop;
for (Region region : regions) {
if (region.containsMouse(mX, mY)) {
List<String> tooltip = region.handler.getTooltip();
if (tooltip != null) {
((AEBaseGui)gui).drawTooltip(mX,mY,0,String.join("\n",tooltip));
return;
}
}
@@ -2,7 +2,9 @@ package com.glodblock.github.inventory.slot;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFakeTypeOnly;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.util.Util;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -10,8 +12,11 @@ import net.minecraftforge.fluids.FluidStack;
public class OptionalFluidSlotFakeTypeOnly extends OptionalSlotFakeTypeOnly {
public OptionalFluidSlotFakeTypeOnly(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
AEFluidInventory fluidInv;
public OptionalFluidSlotFakeTypeOnly(IInventory inv, AEFluidInventory fluidInv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
this.fluidInv = fluidInv;
}
@Override
@@ -19,12 +24,19 @@ public class OptionalFluidSlotFakeTypeOnly extends OptionalSlotFakeTypeOnly {
{
FluidStack fluidStack = Util.getFluidFromItem(is);
if (fluidStack != null) {
ItemStack tmp = ItemFluidPacket.newStack(fluidStack);
tmp.setStackDisplayName(fluidStack.getLocalizedName());
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluidStack);
if (fluidInv != null) {
FluidStack standard = fluidStack.copy();
standard.amount = 8000;
fluidInv.setFluidInSlot(getSlotIndex(), AEFluidStack.create(standard));
}
super.putStack(tmp);
}
else {
super.putStack(null);
if (fluidInv != null) {
fluidInv.setFluidInSlot(getSlotIndex(), null);
}
}
}
@@ -20,6 +20,7 @@ public class ChannelLoader implements Runnable {
FluidCraft.proxy.netHandler.registerMessage(new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id ++, Side.SERVER);
FluidCraft.proxy.netHandler.registerMessage(new CPacketDumpTank.Handler(), CPacketDumpTank.class, id ++, Side.SERVER);
FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id ++, Side.CLIENT);
FluidCraft.proxy.netHandler.registerMessage(new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id ++, Side.SERVER);
FluidCraft.proxy.netHandler.registerMessage(new CPacketPatternValueSet.Handler(), CPacketPatternValueSet.class, id++, Side.SERVER);
FluidCraft.proxy.netHandler.registerMessage(new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id++, Side.SERVER);
}
}
Loaded 100 of 146 files, more files were not shown because too many files have changed in this diff. Show more