Compare commits

...
Author SHA1 Message Date
Martin Robertz 0e774f4e66 Merge pull request #91 from GTNewHorizons/master
merge master
2023-02-20 23:04:14 +01:00
Martin Robertz 25763691ca Merge pull request #90 from asdflj/master
fix fluid storage bus npe
2023-02-20 12:18:22 +01:00
asdflj bc053b2690 fix fluid storage bus crash 2023-02-20 18:19:47 +08:00
Martin Robertz 9761008907 Merge pull request #89 from GTNewHorizons/master
merge master
2023-02-18 23:25:05 +01:00
Martin Robertz 1a7acf4d28 Merge pull request #88 from asdflj/master
pattern terminal add auto fill blank pattern
2023-02-18 19:09:26 +01:00
asdflj c21752b80d fix bug 2023-02-18 14:18:22 +08:00
asdflj 80c364455d add Avaritia crafting table support 2023-02-18 14:16:40 +08:00
asdflj aef677868b add hotkey and baubles support 2023-02-17 22:34:06 +08:00
asdflj 09c1c49529 pattern terminal add auto fill blank pattern 2023-02-17 12:04:11 +08:00
Martin Robertz 18fb84de69 Merge branch 'master' into blockingfix 2023-02-16 20:41:21 +01:00
Yang Xizhi 271917c765 Merge pull request #85 from asdflj/nee
add nee support
2023-02-16 20:14:06 +08:00
GlodBlock e9c6c75ac9 ignore eio conduit in blocking check 2023-02-16 12:28:43 +08:00
asdflj 7d09bf606f add nee support 2023-02-16 11:29:34 +08:00
Martin Robertz 098561a01d Merge pull request #87 from GTNewHorizons/master
merge master
2023-02-15 17:36:17 +01:00
Yang Xizhi e292a4d35c Merge pull request #84 from asdflj/master
remove keep mouse pos
2023-02-15 18:02:13 +08:00
GlodBlock 52a985765c remove dep 2023-02-15 17:58:18 +08:00
GlodBlock 4f8811d376 make eio conduit consistant with ae2 2023-02-15 17:56:51 +08:00
asdflj bfcf33975c remove keep mouse pos 2023-02-15 09:30:13 +08:00
Yang Xizhi f3052c3353 Merge pull request #83 from asdflj/master
fix bug
2023-02-14 22:28:34 +08:00
GlodBlock b4a5c070e2 check every side in blocking mode 2023-02-14 22:20:47 +08:00
asdflj c8457bb7d3 fix bug 2023-02-14 22:12:40 +08:00
GlodBlock 0734dc4d0b add fluid name in certus tank name 2023-02-14 12:34:32 +08:00
GlodBlock 9f53884572 split client side hook code 2023-02-13 19:11:32 +08:00
Martin Robertz c9033aa93e Merge pull request #82 from asdflj/master
update zh language
2023-02-13 09:22:26 +01:00
GlodBlock 09df769db8 e 2023-02-13 15:02:04 +08:00
GlodBlock a5f7d8bed2 fix wireless terminal not usable at server 2023-02-13 14:59:31 +08:00
asdflj f66330d878 update zh language 2023-02-13 09:30:25 +08:00
Yang Xizhi 273ac040de Merge pull request #81 from GTNewHorizons/cell-housing
cell housing and multi fluid cell
2023-02-12 20:18:36 +08:00
GlodBlock 4f54c9bb28 add 5 type fluid cell 2023-02-12 20:12:23 +08:00
GlodBlock 96c7032523 add fluid cell housing 2023-02-12 19:04:04 +08:00
Yang Xizhi 7910578318 Merge pull request #80 from asdflj/cell
add cells
2023-02-12 17:10:38 +08:00
asdflj f7001d205e fix bug 2023-02-12 15:54:35 +08:00
asdflj a28bbe6e34 wireless interface terminal add switch crafting status button 2023-02-12 11:55:43 +08:00
asdflj 56a9dc1524 update dependencies.gradle 2023-02-11 22:42:34 +08:00
asdflj eb293ceb63 add ME Fluid Quantum Storage Cell
add ME Fluid Digital Singularity Storage Cell
2023-02-11 21:57:05 +08:00
Yang Xizhi 45e0dcbc05 Merge pull request #79 from asdflj/master
Universal wireless terminal support processing pattern terminal mode
2023-02-10 19:16:14 +08:00
asdflj e92cffd2b2 Merge remote-tracking branch 'origin/master' 2023-02-10 16:19:59 +08:00
asdflj 56b8683686 update wireless interface recipe 2023-02-10 16:19:34 +08:00
asdflj 879993cf22 add Creative ME Fluid Storage Cell 2023-02-10 16:03:51 +08:00
asdflj 8d14239c53 refactor 2023-02-10 11:05:19 +08:00
asdflj 5ada5ddec3 add Wireless Pattern Terminal Ex 2023-02-09 15:40:14 +08:00
Yang Xizhi 2812153280 Merge pull request #78 from asdflj/master
add wireless interface terminal
2023-02-09 12:38:03 +08:00
asdflj 95f34a7c29 fix bug 2023-02-08 21:10:32 +08:00
asdflj 7693487343 update language 2023-02-08 20:58:21 +08:00
asdflj a7d8d5db39 Merge remote-tracking branch 'origin/master' 2023-02-08 20:51:28 +08:00
asdflj c935e85a2f fix interface terminal bug 2023-02-08 20:51:08 +08:00
asdflj 417574fb3c wireless interface terminal add edit button 2023-02-08 18:16:27 +08:00
asdflj d2c420d193 add wireless interface terminal 2023-02-08 12:07:15 +08:00
asdflj c2ccede395 Switching terminal does not blink 2023-02-06 16:56:10 +08:00
asdflj 5f6a826ed9 keep mouse pos 2023-02-06 11:33:18 +08:00
Yang Xizhi 8e230af664 Merge pull request #76 from GTNewHorizons/wireless-terminals
Wireless terminals
2023-02-05 20:37:07 +08:00
Yang Xizhi b34192182e Merge pull request #77 from GTNewHorizons/wireless-terminals-spotless-fixes
Spotless apply for branch wireless-terminals for #76
2023-02-05 20:31:48 +08:00
GitHub GTNH Actions ee1c260d3d spotlessApply 2023-02-05 12:31:16 +00:00
GlodBlock 62b23e8102 remove 2023-02-05 20:26:47 +08:00
GlodBlock 2632a9b1cd fix crafting terminal 2023-02-05 20:25:23 +08:00
Yang Xizhi e8e27d421a Merge pull request #75 from asdflj/wireless
fix bug
2023-02-05 18:18:05 +08:00
asdflj 92213031f8 fix bug 2023-02-05 18:12:58 +08:00
asdflj d04aac3b29 fix bug 2023-02-05 16:52:16 +08:00
Yang Xizhi 66ac56434a Merge pull request #74 from asdflj/wireless
Wireless
2023-02-05 15:34:36 +08:00
asdflj ba45bd5606 Merge remote-tracking branch 'origin/wireless' into wireless 2023-02-05 15:18:17 +08:00
asdflj d1316f1309 spotless apply 2023-02-05 15:18:02 +08:00
asdflj fe6a4ba9de Merge branch 'wireless-terminals' into wireless 2023-02-05 15:11:09 +08:00
asdflj f81fab984a update 2023-02-05 15:06:06 +08:00
asdflj 1bbc575f6e spotless apply 2023-02-05 01:59:57 +08:00
GlodBlock f1c11fcd06 E 2023-02-05 01:31:27 +08:00
GlodBlock 6edad9fae0 more fixes 2023-02-05 01:23:00 +08:00
GlodBlock c1b2400549 fix bugs 2023-02-05 01:03:59 +08:00
GlodBlock f22bebbf21 wireless crafting terminal 2023-02-04 18:27:16 +08:00
GlodBlock 513af871aa wireless universal terminal 2023-02-03 22:38:33 +08:00
GlodBlock e1aa537670 make wct recipe not removed 2023-02-03 13:03:55 +08:00
Yang Xizhi 86551892e3 Merge pull request #73 from asdflj/bookmark
add NEI Highlighting for Text on AE2FC Fluid Storage Cells
2023-02-02 22:35:47 +08:00
asdflj b2eafe5c88 add NEI Highlighting for Text on AE2FC Fluid Storage Cells 2023-02-02 22:15:04 +08:00
Yang Xizhi f14e168555 Merge pull request #72 from asdflj/bookmark
fix bug
2023-02-02 15:41:13 +08:00
asdflj a8155c8b17 fix when open the auto filler, always to try update pattern
add using exists item to fill pattern slot
2023-02-02 11:13:59 +08:00
Yang Xizhi f40e088bc0 Merge pull request #71 from asdflj/bookmark
add fluid auto filler & wireless fluid pattern terminal
2023-02-01 21:19:23 +08:00
Yang Xizhi 7ecd7d246f Merge branch 'master' into bookmark 2023-02-01 21:19:09 +08:00
GlodBlock dadf2784a8 fixes 2023-02-01 21:15:44 +08:00
asdflj 8081eb2c2c all done? 2023-02-01 16:25:42 +08:00
Raven Szewczyk 72c1d37225 [ci skip] upgraded build system 2023-01-31 09:50:38 +00:00
asdflj 5ea7f44058 Merge remote-tracking branch 'origin/bookmark' into bookmark 2023-01-31 15:51:29 +08:00
asdflj 7f53e01184 add wireless fluid pattern terminal 2023-01-31 15:50:45 +08:00
GlodBlock 2eb1854eda network update flag 2023-01-31 10:49:19 +08:00
asdflj a22814940b add wireless fluid terminal 2023-01-30 22:52:25 +08:00
GlodBlock 482298021e tank 2023-01-30 18:07:57 +08:00
155 changed files with 8068 additions and 776 deletions

No files matched your search

+1
View File
@@ -6,3 +6,4 @@ out/
*.ipr
*.iws
run/
build/
+101 -21
View File
@@ -1,4 +1,4 @@
//version: 1674943145
//version: 1675173326
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -55,9 +55,9 @@ plugins {
id 'eclipse'
id 'scala'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false
id 'org.jetbrains.kotlin.jvm' version '1.8.0' apply false
id 'org.jetbrains.kotlin.kapt' version '1.8.0' apply false
id 'com.google.devtools.ksp' version '1.8.0-1.0.9' apply false
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version ,unused, available for addon.gradle
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
id 'com.palantir.git-version' version '0.13.0' apply false // 0.13.0 is the last jvm8 supporting version
@@ -66,7 +66,7 @@ plugins {
id 'com.diffplug.spotless' version '6.7.2' apply false
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.0.16'
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.3'
}
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
@@ -113,6 +113,7 @@ propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnset("curseForgeProjectId", "")
propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnset("minimizeShadowedDependencies", true)
propertyDefaultIfUnset("relocateShadowedDependencies", true)
// Deprecated properties (kept for backwards compat)
propertyDefaultIfUnset("gradleTokenModId", "")
propertyDefaultIfUnset("gradleTokenModName", "")
@@ -149,6 +150,33 @@ java {
}
}
pluginManager.withPlugin('org.jetbrains.kotlin.jvm') {
// If Kotlin is enabled in the project
kotlin {
jvmToolchain(8)
}
// Kotlin hacks our source sets, so we hack Kotlin's tasks
def disabledKotlinTaskList = [
"kaptGenerateStubsMcLauncherKotlin",
"kaptGenerateStubsPatchedMcKotlin",
"kaptGenerateStubsInjectedTagsKotlin",
"compileMcLauncherKotlin",
"compilePatchedMcKotlin",
"compileInjectedTagsKotlin",
"kaptMcLauncherKotlin",
"kaptPatchedMcKotlin",
"kaptInjectedTagsKotlin",
"kspMcLauncherKotlin",
"kspPatchedMcKotlin",
"kspInjectedTagsKotlin",
]
tasks.configureEach { task ->
if (task.name in disabledKotlinTaskList) {
task.enabled = false
}
}
}
configurations {
create("runtimeOnlyNonPublishable") {
description = "Runtime only dependencies that are not published alongside the jar"
@@ -212,6 +240,25 @@ if (accessTransformersFile) {
}
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(targetFile)
tasks.srgifyBinpatchedJar.accessTransformerFiles.from(targetFile)
} else {
boolean atsFound = false
for (File at : sourceSets.getByName("main").resources.files) {
if (at.name.toLowerCase().endsWith("_at.cfg")) {
atsFound = true
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at)
tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at)
}
}
for (File at : sourceSets.getByName("api").resources.files) {
if (at.name.toLowerCase().endsWith("_at.cfg")) {
atsFound = true
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from(at)
tasks.srgifyBinpatchedJar.accessTransformerFiles.from(at)
}
}
if (atsFound) {
logger.warn("Found and added access transformers in the resources folder, please configure gradle.properties to explicitly mention them by name")
}
}
if (usesMixins.toBoolean()) {
@@ -290,7 +337,7 @@ if (identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}
group = modGroup
group = "com.github.GTNewHorizons"
if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName
} else {
@@ -356,6 +403,16 @@ configurations.configureEach {
}
}
// Ensure tests have access to minecraft classes
sourceSets {
test {
java {
compileClasspath += sourceSets.patchedMc.output + sourceSets.mcLauncher.output
runtimeClasspath += sourceSets.patchedMc.output + sourceSets.mcLauncher.output
}
}
}
if (file('addon.gradle').exists()) {
apply from: 'addon.gradle'
}
@@ -363,7 +420,7 @@ if (file('addon.gradle').exists()) {
// Allow unsafe repos but warn
repositories.configureEach { repo ->
if (repo instanceof org.gradle.api.artifacts.repositories.UrlArtifactRepository) {
if (repo.getUrl().getScheme() == "http" && !repo.allowInsecureProtocol) {
if (repo.getUrl() != null && repo.getUrl().getScheme() == "http" && !repo.allowInsecureProtocol) {
logger.warn("Deprecated: Allowing insecure connections for repo '${repo.name}' - add 'allowInsecureProtocol = true'")
repo.allowInsecureProtocol = true
}
@@ -473,6 +530,14 @@ dependencies {
}
}
pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
if (usesMixins.toBoolean()) {
dependencies {
kapt('com.gtnewhorizon:gtnhmixins:2.1.10:processor')
}
}
}
apply from: 'dependencies.gradle'
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
@@ -513,9 +578,11 @@ if (usesMixins.toBoolean()) {
tasks.named("reobfJar", ReobfuscatedJar).configure {
extraSrgFiles.from(mixinSrg)
}
}
if (usesMixins.toBoolean()) {
tasks.named("processResources").configure {
dependsOn("generateAssets")
}
tasks.named("compileJava", JavaCompile).configure {
doFirst {
new File(mixinTmpDir).mkdirs()
@@ -529,6 +596,25 @@ if (usesMixins.toBoolean()) {
"-XDignore.symbol.file"
]
}
pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
kapt {
correctErrorTypes = true
javacOptions {
option("-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}")
option("-AoutSrgFile=$mixinSrg")
option("-AoutRefMapFile=$refMap")
}
}
tasks.configureEach { task ->
if (task.name == "kaptKotlin") {
task.doFirst {
new File(mixinTmpDir).mkdirs()
}
}
}
}
}
tasks.named("processResources", ProcessResources).configure {
@@ -584,6 +670,7 @@ if (usesShadowedDependencies.toBoolean()) {
tasks.register('relocateShadowJar', ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = modGroup + ".shadow"
enabled = minimizeShadowedDependencies.toBoolean()
}
tasks.named("shadowJar", ShadowJar).configure {
manifest {
@@ -599,7 +686,9 @@ if (usesShadowedDependencies.toBoolean()) {
project.configurations.shadeCompile
]
archiveClassifier.set('dev')
dependsOn(relocateShadowJar)
if (minimizeShadowedDependencies.toBoolean()) {
dependsOn(relocateShadowJar)
}
}
configurations.runtimeElements.outgoing.artifacts.clear()
configurations.apiElements.outgoing.artifacts.clear()
@@ -625,16 +714,6 @@ if (usesShadowedDependencies.toBoolean()) {
ext.publishableDevJar = usesShadowedDependencies.toBoolean() ? tasks.shadowJar : tasks.jar
ext.publishableObfJar = tasks.reobfJar
tasks.named('extractForgeUserdev', Copy).configure { efu ->
doLast {
// Fix CoFH-repackaged CCL not finding mappings
project.copy {
from(mcpTasks.userdevDir("conf"))
into(new File(project.buildDir, "unpacked/conf"))
}
}
}
tasks.register('apiJar', Jar) {
from(sourceSets.main.allSource) {
include modGroupPath + "/" + apiPackagePath + '/**'
@@ -664,6 +743,7 @@ idea {
module {
downloadJavadoc = true
downloadSources = true
inheritOutputDirs = true
}
project {
settings {
@@ -739,7 +819,7 @@ publishing {
artifact apiJar
}
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: project.group
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
// Using the identified version, not project.version as it has the prepended 1.7.10
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
+4 -4
View File
@@ -1,11 +1,11 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-149-GTNH:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.32-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-158-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:waila:1.5.22:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.32:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.2:dev")
compileOnly('com.github.GTNewHorizons:ForestryMC:4.5.6:dev')
@@ -23,5 +23,5 @@ dependencies {
compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.191:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:KekzTech:0.6.25:dev')
runtimeOnly('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
compile('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
}
@@ -28,7 +28,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
modid = FluidCraft.MODID,
version = FluidCraft.VERSION,
name = FluidCraft.MODNAME,
dependencies = "required-after:appliedenergistics2;after:waila")
dependencies = "required-after:appliedenergistics2;required-after:CoFHCore;after:waila;after:thaumicenergistics;after:ae2wct")
public class FluidCraft {
public static final String MODID = "GRADLETOKEN_MODID";
@@ -46,7 +46,7 @@ public class FluidCraft {
@Mod.EventHandler
public static void preInit(FMLPreInitializationEvent event) {
Config.run();
(new ChannelLoader()).run();
ChannelLoader.INSTANCE.run();
proxy.preInit(event);
}
@@ -70,8 +70,9 @@ public class FluidCraft {
ItemAndBlockHolder.loadSetting();
if (!Config.removeRecipe) {
(new RecipeLoader()).run();
RecipeLoader.INSTANCE.run();
}
RecipeLoader.runTerminalRecipe();
if (ModAndClassUtil.isV2) {
CalculatorV2PluginLoader.installCalculatorV2Plugins();
@@ -0,0 +1,109 @@
package com.glodblock.github.client.gui;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
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.minecraftforge.fluids.FluidStack;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerEssentiaMonitor;
import com.glodblock.github.client.me.EssentiaRepo;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.crossmod.thaumcraft.AspectRender;
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.Ae2ReflectClient;
public class GuiEssentiaTerminal extends GuiFluidMonitor {
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
protected EntityPlayer player;
public GuiEssentiaTerminal(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerEssentiaMonitor(inventoryPlayer, te));
this.repo = new EssentiaRepo(getScrollBar(), this);
this.player = inventoryPlayer.player;
}
@Override
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
if (AspectUtil.getAspectFromJar(stack) != null) {
setSearchString(Objects.requireNonNull(AspectUtil.getAspectFromJar(stack)).getName(), true);
}
}
@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) {
IAEItemStack stack = ((SlotME) slot).getAEStack();
if (stack == null) return true;
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
AspectRender.drawAspect(
this.player,
slot.xDisplayPosition,
slot.yDisplayPosition,
this.zLevel,
AspectUtil.getAspectFromGas(fluidStack),
fluidStack.amount);
IAEItemStack gas = stack.copy().setStackSize(stack.getStackSize() / AspectUtil.R);
stackSizeRenderer.setAeStack(gas);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
gas.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
}
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof SlotME && AspectUtil.isEssentiaContainer(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));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
}
}
public void update(ItemStack itemStack) {
this.player.inventory.setItemStack(itemStack);
}
}
@@ -48,8 +48,17 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.registerApp(2, "FORCE_PRIO", "DO_PRIO", "prio");
this.registerApp(3, "NOT_PRIO", "DONT_PRIO", "not_prio");
this.registerApp(4, "SUBMIT", "SUBMIT", "submit");
this.registerApp(5, "EDIT", "YES", "edit");
this.registerApp(6, "DISABLE", "DISABLE", "disable");
this.registerApp(7, "ENABLE", "ENABLE", "enable");
this.registerApp(10, "FLUID_TEM", "YES", "fluid_terminal_w");
this.registerApp(11, "CRAFT_TEM", "YES", "craft_terminal_w");
this.registerApp(12, "PATTERN_TEM", "YES", "pattern_terminal_w");
this.registerApp(13, "ESSENTIA_TEM", "YES", "essentia_terminal_w");
this.registerApp(14, "INTERFACE_TEM", "YES", "interface_terminal_w");
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
}
}
@@ -61,7 +70,8 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
} else {
a.displayValue = StatCollector.translateToLocal(prefix + title + ".hint");
}
a.index = iconIndex;
a.index = iconIndex % 10;
a.page = iconIndex / 10;
appearances.put(new EnumPair(setting, val), a);
}
@@ -81,6 +91,17 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
return 8;
}
private int getIconPage() {
if (this.buttonSetting != null && this.currentValue != null) {
final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue));
if (app == null) {
return 0;
}
return app.page;
}
return 0;
}
public String getSetting() {
return this.buttonSetting;
}
@@ -184,6 +205,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3) {
if (this.visible) {
final int iconIndex = this.getIconIndex();
final int iconPage = this.getIconPage();
if (this.halfSize) {
this.width = 8;
@@ -199,7 +221,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states.png"));
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states" + iconPage + ".png"));
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
@@ -235,7 +257,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states.png"));
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states" + iconPage + ".png"));
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
@@ -296,6 +318,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
private static class ButtonAppearance {
public int index;
public int page;
public String displayName;
public String displayValue;
}
@@ -10,10 +10,13 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
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.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketCraftRequest;
@@ -64,14 +67,18 @@ public class GuiFluidCraftAmount extends FCGuiAmount {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (target instanceof PartFluidPatternTerminalEx) {
} else if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (target instanceof PartFluidTerminal) {
} else if (target instanceof PartFluidTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
} else if (target instanceof WirelessPatternTerminalInventory) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
this.originalGui = GuiType.FLUID_TERMINAL;
}
}
@@ -23,10 +23,13 @@ import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
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.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
@@ -62,9 +65,12 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
if (te instanceof PartFluidPatternTerminal) {
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (te instanceof PartFluidPatternTerminalEx) {
} else if (te instanceof PartFluidPatternTerminalEx) {
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (te instanceof IWirelessTerminal && ((IWirelessTerminal) te).isUniversal(te)) {
this.OriginalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) te).getItemStack());
} else if (te instanceof WirelessPatternTerminalInventory) {
this.OriginalGui = GuiType.FLUID_TERMINAL;
}
}
@@ -0,0 +1,85 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.InventoryAction;
import com.glodblock.github.client.gui.container.ContainerCraftingWireless;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class GuiFluidCraftingWireless extends GuiItemMonitor {
private GuiImgButton clearBtn;
public GuiFluidCraftingWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerCraftingWireless(inventoryPlayer, te));
this.setReservedSpace(73);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
if (this.clearBtn == btn) {
Slot s = null;
final Container c = this.inventorySlots;
for (final Object j : c.inventorySlots) {
if (j instanceof SlotCraftingMatrix) {
s = (Slot) j;
}
}
if (s != null) {
final PacketInventoryAction p = new PacketInventoryAction(
InventoryAction.MOVE_REGION,
s.slotNumber,
0);
NetworkHandler.instance.sendToServer(p);
}
}
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.buttonList.add(
this.clearBtn = new GuiImgButton(
this.guiLeft + 92,
this.guiTop + this.ySize - 156,
Settings.ACTIONS,
ActionItems.STASH));
this.clearBtn.setHalfSize(true);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawFG(offsetX, offsetY, mouseX, mouseY);
this.fontRendererObj.drawString(
GuiText.CraftingTerminal.getLocal(),
8,
this.ySize - 96 + 1 - this.getReservedSpace(),
GuiColors.CraftingTerminalTitle.getColor());
}
@Override
protected String getBackground() {
return "gui/crafting.png";
}
}
@@ -0,0 +1,24 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {
public GuiFluidPatternExWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -20,6 +20,8 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternWireless;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -29,6 +31,10 @@ public class GuiFluidPatternTerminal extends FCGuiEncodeTerminal {
super(inventoryPlayer, te, new ContainerFluidPatternTerminal(inventoryPlayer, te));
}
public GuiFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternWireless(inventoryPlayer, te));
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
@@ -8,11 +8,16 @@ import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
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.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2ReflectClient;
@@ -34,6 +39,14 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
else if (host instanceof PartFluidTerminal) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
} else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1));
} else if (host instanceof WirelessFluidTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_FLUID_TERM, 1));
} else if (host instanceof WirelessPatternTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1));
} else if (host instanceof WirelessInterfaceTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_INTERFACE_TERM, 1));
}
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
@@ -46,6 +59,14 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
else if (host instanceof PartFluidPatternTerminalEx)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) InventoryHandler
.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
else if (host instanceof WirelessFluidTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_TERMINAL);
else if (host instanceof WirelessPatternTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
else if (host instanceof WirelessInterfaceTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
} else {
super.actionPerformed(btn);
}
@@ -11,7 +11,9 @@ import appeng.client.gui.widgets.GuiImgButton;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternExWireless;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -24,6 +26,12 @@ public class GuiFluidPatternTerminalEx extends FCGuiEncodeTerminal {
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
public GuiFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternExWireless(inventoryPlayer, te));
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
@@ -0,0 +1,24 @@
package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class GuiFluidPatternWireless extends GuiFluidPatternTerminal {
public GuiFluidPatternWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -6,6 +6,7 @@ import appeng.container.slot.AppEngSlot;
import com.glodblock.github.client.gui.container.ContainerFluidPortableCell;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class GuiFluidPortableCell extends GuiFluidTerminal {
@@ -20,6 +21,10 @@ public class GuiFluidPortableCell extends GuiFluidTerminal {
@Override
protected int getMaxRows() {
return 3;
if (this.container.getHost() instanceof IWirelessTerminal) {
return super.getMaxRows();
} else {
return 3;
}
}
}
@@ -0,0 +1,751 @@
package com.glodblock.github.client.gui;
import java.util.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.client.gui.widgets.*;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.client.render.BlockPosHighlighter;
import appeng.container.slot.AppEngSlot;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.PatternHelper;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCBaseMEGui;
import com.glodblock.github.client.gui.container.ContainerInterfaceWireless;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketRenamer;
import com.glodblock.github.util.ModAndClassUtil;
import com.google.common.collect.HashMultimap;
public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
protected int offsetY;
private static final int MAGIC_HEIGHT_NUMBER = 52 + 99;
private static final int offsetX = 21;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
private final HashMap<ClientDCInternalInv, DimensionalCoordSide> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
private final Set<Object> matchedStacks = new HashSet<>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
protected static String searchFieldOutputsText = "";
protected static String searchFieldInputsText = "";
protected static String searchFieldNamesText = "";
private final MEGuiTextField searchFieldOutputs;
private final MEGuiTextField searchFieldInputs;
private final MEGuiTextField searchFieldNames;
private final GuiImgButton guiButtonHideFull;
private final GuiImgButton guiButtonAssemblersOnly;
private final GuiImgButton guiButtonBrokenRecipes;
private GuiImgButton searchStringSave;
private GuiImgButton terminalStyleBox;
private boolean refreshList = false;
protected static boolean onlyMolecularAssemblers = false;
protected static boolean onlyBrokenRecipes = false;
protected GuiTabButton craftingStatusBtn;
// private final IConfigManager configSrc;
private int rows = 3;
private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.BlockMolecularAssembler";
public GuiInterfaceTerminalWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, new ContainerInterfaceWireless(inventoryPlayer, te));
this.setScrollBar(new GuiScrollbar());
this.xSize = 208;
this.ySize = 255;
searchFieldInputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldInputs.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldOutputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldOutputs.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldNames = new MEGuiTextField(71, 12, ButtonToolTips.SearchFieldNames.getLocal()) {
@Override
public void onTextChange(final String oldText) {
refreshList();
}
};
searchFieldNames.setFocused(true);
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
}
@Override
public int getOffsetY() {
return this.offsetY;
}
@Override
public void setOffsetY(int y) {
this.offsetY = y;
}
private void setScrollBar() {
this.getScrollBar().setTop(52).setLeft(189).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(0, this.lines.size() - this.rows, 2);
}
@Override
public void initGui() {
super.initGui();
this.rows = calculateRowsCount();
this.ySize = MAGIC_HEIGHT_NUMBER + this.rows * 18;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
this.offsetY = this.guiTop + 8;
this.buttonList.add(
this.terminalStyleBox = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.TERMINAL_STYLE,
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
this.offsetY += 20;
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
this.offsetY,
Settings.SAVE_SEARCH,
AEConfig.instance.settings.getSetting(Settings.SAVE_SEARCH)));
this.offsetY += 20;
searchFieldInputs.x = guiLeft + Math.max(32, offsetX);
searchFieldInputs.y = guiTop + 25;
searchFieldOutputs.x = guiLeft + Math.max(32, offsetX);
searchFieldOutputs.y = guiTop + 38;
searchFieldNames.x = guiLeft + Math.max(32, offsetX) + 99;
searchFieldNames.y = guiTop + 38;
guiButtonAssemblersOnly.xPosition = guiLeft + Math.max(32, offsetX) + 99;
guiButtonAssemblersOnly.yPosition = guiTop + 20;
guiButtonHideFull.xPosition = guiButtonAssemblersOnly.xPosition + 18;
guiButtonHideFull.yPosition = guiTop + 20;
guiButtonBrokenRecipes.xPosition = guiButtonHideFull.xPosition + 18;
guiButtonBrokenRecipes.yPosition = guiTop + 20;
terminalStyleBox.xPosition = guiLeft - 18;
terminalStyleBox.yPosition = guiTop + 8;
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
this.guiLeft + this.xSize - 24,
this.guiTop - 4,
2 + 11 * 16,
GuiText.CraftingStatus.getLocal(),
itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString();
}
this.setScrollBar();
this.repositionSlots();
this.initGuiDone();
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
searchFieldOutputsText = this.searchFieldOutputs.getText();
searchFieldInputsText = this.searchFieldInputs.getText();
searchFieldNamesText = this.searchFieldNames.getText();
}
public void setSearchString() {
this.searchFieldOutputs.setText(searchFieldOutputsText);
this.searchFieldInputs.setText(searchFieldInputsText);
this.searchFieldNames.setText(searchFieldNamesText);
}
protected void repositionSlots() {
for (final Object obj : this.inventorySlots.inventorySlots) {
if (obj instanceof AppEngSlot) {
final AppEngSlot slot = (AppEngSlot) obj;
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 7;
}
}
}
protected int calculateRowsCount() {
final int maxRows = this.getMaxRows();
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEIPadding = hasNEI ? 22 /* input */ + 18 /* top panel */ : 0;
final int extraSpace = this.height - MAGIC_HEIGHT_NUMBER - NEIPadding;
return Math.max(3, Math.min(maxRows, extraSpace / 18));
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
fontRendererObj.drawString(
getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()),
8,
6,
GuiColors.InterfaceTerminalTitle.getColor());
fontRendererObj.drawString(
GuiText.inventory.getLocal(),
GuiInterfaceTerminalWireless.offsetX + 2,
this.ySize - 96,
GuiColors.InterfaceTerminalInventory.getColor());
int offset = 51;
final int ex = getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof ClientDCInternalInv) {
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z))) drawRect(
z * 18 + 22,
1 + offset,
z * 18 + 22 + 16,
1 + offset + 16,
GuiColors.InterfaceTerminalMatch.getColor());
}
} else if (lineObj instanceof String) {
String name = (String) lineObj;
final int rows = this.byName.get(name).size();
String postfix = "";
if (rows > 1) {
postfix = " (" + rows + ')';
}
while (name.length() > 2 && this.fontRendererObj.getStringWidth(name + postfix) > 158) {
name = name.substring(0, name.length() - 1);
}
this.fontRendererObj.drawString(
name + postfix,
GuiInterfaceTerminalWireless.offsetX + 3,
6 + offset,
GuiColors.InterfaceTerminalName.getColor());
}
offset += 18;
}
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
buttonList.clear();
inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
guiButtonAssemblersOnly.set(
onlyMolecularAssemblers ? ActionItems.MOLECULAR_ASSEMBLEERS_ON : ActionItems.MOLECULAR_ASSEMBLEERS_OFF);
guiButtonHideFull.set(
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF
: ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
guiButtonBrokenRecipes.set(
onlyBrokenRecipes ? ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_OFF
: ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_ON);
terminalStyleBox.set(AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE));
buttonList.add(guiButtonAssemblersOnly);
buttonList.add(guiButtonHideFull);
buttonList.add(guiButtonBrokenRecipes);
buttonList.add(terminalStyleBox);
buttonList.add(searchStringSave);
buttonList.add(craftingStatusBtn);
addSwitchGuiBtns();
int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof ClientDCInternalInv) {
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z, z * 18 + 22, 1 + offset));
}
GuiButton guiButton = new GuiImgButton(
guiLeft + 4,
guiTop + offset + 1,
Settings.ACTIONS,
ActionItems.HIGHLIGHT_INTERFACE);
GuiFCImgButton editButton = new GuiFCImgButton(guiLeft + 4, guiTop + offset + 1, "EDIT", "YES");
guiButtonHashMap.put(guiButton, inv);
guiButtonHashMap.put(editButton, inv);
if (isShiftKeyDown()) {
buttonList.add(editButton);
} else {
buttonList.add(guiButton);
}
}
offset += 18;
}
super.drawScreen(mouseX, mouseY, btn);
handleTooltip(mouseX, mouseY, searchFieldInputs);
handleTooltip(mouseX, mouseY, searchFieldOutputs);
handleTooltip(mouseX, mouseY, searchFieldNames);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
searchFieldInputs.mouseClicked(xCoord, yCoord, btn);
searchFieldOutputs.mouseClicked(xCoord, yCoord, btn);
searchFieldNames.mouseClicked(xCoord, yCoord, btn);
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (guiButtonHashMap.containsKey(btn)) {
DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
if (btn instanceof GuiFCImgButton) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketRenamer(blockPos.x, blockPos.y, blockPos.z, blockPos.getDimension(), blockPos.side));
} else {
WorldCoord blockPos2 = new WorldCoord(
(int) mc.thePlayer.posX,
(int) mc.thePlayer.posY,
(int) mc.thePlayer.posZ);
if (mc.theWorld.provider.dimensionId != blockPos.getDimension()) {
mc.thePlayer.addChatMessage(
new ChatComponentTranslation(
PlayerMessages.InterfaceInOtherDim.getName(),
blockPos.getDimension()));
} else {
BlockPosHighlighter.highlightBlock(
blockPos,
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
mc.thePlayer.addChatMessage(
new ChatComponentTranslation(
PlayerMessages.InterfaceHighlighted.getName(),
blockPos.x,
blockPos.y,
blockPos.z));
}
mc.thePlayer.closeScreen();
}
} else if (btn == guiButtonHideFull) {
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal = !AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal;
this.refreshList();
} else if (btn == guiButtonAssemblersOnly) {
onlyMolecularAssemblers = !onlyMolecularAssemblers;
this.refreshList();
} else if (btn == guiButtonBrokenRecipes) {
onlyBrokenRecipes = !onlyBrokenRecipes;
this.refreshList();
} else if (ModAndClassUtil.isSaveText && btn == searchStringSave) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
AEConfig.instance.settings.putSetting(Settings.SAVE_SEARCH, next);
this.searchStringSave.set(next);
} else if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else if (btn instanceof GuiImgButton) {
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum cv = iBtn.getCurrentValue();
final boolean backwards = Mouse.isButtonDown(1);
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
this.reinitialize();
}
iBtn.set(next);
}
}
super.actionPerformed(btn);
}
private void reinitialize() {
this.buttonList.clear();
this.initGui();
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/newinterfaceterminal.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 53);
int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll();
for (int x = 0; x < this.rows; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 53 + x * 18, 0, 52, this.xSize, 18);
}
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof ClientDCInternalInv) {
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
GL11.glColor4f(1, 1, 1, 1);
final int width = inv.getInventory().getSizeInventory() * 18;
this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 173, width, 18);
}
offset += 18;
}
this.drawTexturedModalRect(offsetX, offsetY + 50 + this.rows * 18, 0, 158, this.xSize, 99);
searchFieldInputs.drawTextBox();
searchFieldOutputs.drawTextBox();
searchFieldNames.drawTextBox();
}
@Override
protected void keyTyped(final char character, final int key) {
if (!checkHotbarKeys(key)) {
if (character == ' ') {
if ((searchFieldInputs.getText().isEmpty() && searchFieldInputs.isFocused())
|| (searchFieldOutputs.getText().isEmpty() && searchFieldOutputs.isFocused())
|| (searchFieldNames.getText().isEmpty() && searchFieldNames.isFocused()))
return;
} else if (character == '\t') {
if (handleTab()) return;
}
if (searchFieldInputs.textboxKeyTyped(character, key) || searchFieldOutputs.textboxKeyTyped(character, key)
|| searchFieldNames.textboxKeyTyped(character, key)) {
refreshList();
} else {
super.keyTyped(character, key);
}
}
}
private boolean handleTab() {
if (searchFieldInputs.isFocused()) {
searchFieldInputs.setFocused(false);
if (isShiftKeyDown()) searchFieldNames.setFocused(true);
else searchFieldOutputs.setFocused(true);
return true;
} else if (searchFieldOutputs.isFocused()) {
searchFieldOutputs.setFocused(false);
if (isShiftKeyDown()) searchFieldInputs.setFocused(true);
else searchFieldNames.setFocused(true);
return true;
} else if (searchFieldNames.isFocused()) {
searchFieldNames.setFocused(false);
if (isShiftKeyDown()) searchFieldOutputs.setFocused(true);
else searchFieldInputs.setFocused(true);
return true;
}
return false;
}
private static class DimensionalCoordSide extends DimensionalCoord {
private ForgeDirection side = ForgeDirection.UNKNOWN;
public DimensionalCoordSide(final int _x, final int _y, final int _z, final int _dim, ForgeDirection side) {
super(_x, _y, _z, _dim);
this.side = side;
}
}
public void postUpdate(final NBTTagCompound in) {
if (in.getBoolean("clear")) {
this.byId.clear();
this.refreshList = true;
}
for (final Object oKey : in.func_150296_c()) {
final String key = (String) oKey;
if (key.startsWith("=")) {
try {
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
final NBTTagCompound invData = in.getCompoundTag(key);
final ClientDCInternalInv current = this
.getById(id, invData.getLong("sortBy"), invData.getString("un"));
int X = invData.getInteger("x");
int Y = invData.getInteger("y");
int Z = invData.getInteger("z");
int dim = invData.getInteger("dim");
ForgeDirection side = ForgeDirection.getOrientation(invData.getInteger("side"));
blockPosHashMap.put(current, new DimensionalCoordSide(X, Y, Z, dim, side));
for (int x = 0; x < current.getInventory().getSizeInventory(); x++) {
final String which = Integer.toString(x);
if (invData.hasKey(which)) {
current.getInventory().setInventorySlotContents(
x,
ItemStack.loadItemStackFromNBT(invData.getCompoundTag(which)));
}
}
} catch (final NumberFormatException ignored) {}
}
}
if (this.refreshList) {
this.refreshList = false;
// invalid caches on refresh
this.cachedSearches.clear();
this.refreshList();
}
}
/**
* Rebuilds the list of interfaces.
* <p>
* Respects a search term if present (ignores case) and adding only matching patterns.
*/
private void refreshList() {
this.byName.clear();
this.buttonList.clear();
this.matchedStacks.clear();
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
final String searchFieldNames = this.searchFieldNames.getText().toLowerCase();
final Set<Object> cachedSearch = this.getCacheForSearchTerm(
"IN:" + searchFieldInputs
+ "OUT:"
+ searchFieldOutputs
+ "NAME:"
+ searchFieldNames
+ AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
+ onlyMolecularAssemblers
+ onlyBrokenRecipes);
final boolean rebuild = cachedSearch.isEmpty();
for (final ClientDCInternalInv entry : this.byId.values()) {
// ignore inventory if not doing a full rebuild and cache already marks it as miss.
if (!rebuild && !cachedSearch.contains(entry)) {
continue;
}
// Shortcut to skip any filter if search term is ""/empty
boolean found = searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty();
boolean interfaceHasFreeSlots = false;
boolean interfaceHasBrokenRecipes = false;
// Search if the current inventory holds a pattern containing the search term.
if (!found || AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || onlyBrokenRecipes) {
for (final ItemStack itemStack : entry.getInventory()) {
// If only Interfaces with empty slots should be shown, check that here
if (itemStack == null) {
interfaceHasFreeSlots = true;
continue;
}
if (onlyBrokenRecipes && recipeIsBroken(itemStack)) {
interfaceHasBrokenRecipes = true;
}
if ((!searchFieldInputs.isEmpty() && itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0))
|| (!searchFieldOutputs.isEmpty()
&& itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1))) {
found = true;
matchedStacks.add(itemStack);
}
}
}
if ((found && entry.getName().toLowerCase().contains(searchFieldNames))
&& (!onlyMolecularAssemblers || entry.getUnlocalizedName().contains(MOLECULAR_ASSEMBLER))
&& (!AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || interfaceHasFreeSlots)
&& (!onlyBrokenRecipes || interfaceHasBrokenRecipes)) {
this.byName.put(entry.getName(), entry);
cachedSearch.add(entry);
} else {
cachedSearch.remove(entry);
}
}
this.names.clear();
this.names.addAll(this.byName.keySet());
Collections.sort(this.names);
this.lines.clear();
this.lines.ensureCapacity(this.names.size() + this.byId.size());
for (final String n : this.names) {
this.lines.add(n);
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>(this.byName.get(n));
Collections.sort(clientInventories);
this.lines.addAll(clientInventories);
}
this.setScrollBar();
}
private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm, int pass) {
if (itemStack == null) {
return false;
}
final NBTTagCompound encodedValue = itemStack.getTagCompound();
if (encodedValue == null) {
return false;
}
final NBTTagList tags = encodedValue.getTagList(pass == 0 ? "in" : "out", 10);
final boolean containsInvalidDisplayName = GuiText.UnknownItem.getLocal().toLowerCase().contains(searchTerm);
for (int i = 0; i < tags.tagCount(); i++) {
final NBTTagCompound tag = tags.getCompoundTagAt(i);
final ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT(tag);
if (parsedItemStack != null) {
final String displayName = Platform
.getItemDisplayName(AEApi.instance().storage().createItemStack(parsedItemStack)).toLowerCase();
if (displayName.contains(searchTerm)) {
return true;
}
} else if (containsInvalidDisplayName && !tag.hasNoTags()) {
return true;
}
}
return false;
}
private boolean recipeIsBroken(final ItemStack itemStack) {
if (itemStack == null) {
return false;
}
final NBTTagCompound encodedValue = itemStack.getTagCompound();
if (encodedValue == null) {
return true;
}
final World w = CommonHelper.proxy.getWorld();
if (w == null) {
return false;
}
try {
new PatternHelper(itemStack, w);
return false;
} catch (final Throwable t) {
return true;
}
}
/**
* Tries to retrieve a cache for a with search term as keyword.
* <p>
* If this cache should be empty, it will populate it with an earlier cache if available or at least the cache for
* the empty string.
*
* @param searchTerm the corresponding search
* @return a Set matching a superset of the search term
*/
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
if (!this.cachedSearches.containsKey(searchTerm)) {
this.cachedSearches.put(searchTerm, new HashSet<>());
}
final Set<Object> cache = this.cachedSearches.get(searchTerm);
if (cache.isEmpty() && searchTerm.length() > 1) {
cache.addAll(this.getCacheForSearchTerm(searchTerm.substring(0, searchTerm.length() - 1)));
return cache;
}
return cache;
}
private int getMaxRows() {
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
? AEConfig.instance.InterfaceTerminalSmallSize
: Integer.MAX_VALUE;
}
private ClientDCInternalInv getById(final long id, final long sortBy, final String unlocalizedName) {
ClientDCInternalInv o = this.byId.get(id);
if (o == null) {
this.byId.put(id, o = new ClientDCInternalInv(9, id, sortBy, unlocalizedName));
this.refreshList = true;
}
return o;
}
public boolean isOverTextField(final int mousex, final int mousey) {
return searchFieldInputs.isMouseIn(mousex, mousey) || searchFieldOutputs.isMouseIn(mousex, mousey)
|| searchFieldNames.isMouseIn(mousex, mousey);
}
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
if (searchFieldInputs.isMouseIn(mousex, mousey)) {
searchFieldInputs.setText(displayName);
} else if (searchFieldOutputs.isMouseIn(mousex, mousey)) {
searchFieldOutputs.setText(displayName);
} else if (searchFieldNames.isMouseIn(mousex, mousey)) {
searchFieldNames.setText(displayName);
}
}
}
@@ -10,9 +10,12 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
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.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketPatternValueSet;
@@ -66,10 +69,15 @@ public class GuiPatternValueAmount extends FCGuiAmount {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (target instanceof PartFluidPatternTerminalEx) {
} else if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
} else if (target instanceof WirelessPatternTerminalInventory) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
this.originalGui = GuiType.WIRELESS_FLUID_PATTERN_TERMINAL;
}
}
@@ -0,0 +1,144 @@
package com.glodblock.github.client.gui.base;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import appeng.client.gui.AEBaseMEGui;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
public abstract class FCBaseMEGui extends AEBaseMEGui {
protected GuiFCImgButton FluidTerminal;
protected GuiFCImgButton CraftingTerminal;
protected GuiFCImgButton PatternTerminal;
protected GuiFCImgButton EssentiaTerminal;
protected GuiFCImgButton InterfaceTerminal;
protected GuiFCImgButton PatternTerminaleEx;
protected List<GuiFCImgButton> termBtns = new ArrayList<>();
protected boolean drawSwitchGuiBtn;
public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
super(container);
if (container instanceof FCBaseContainer) {
Object target = ((FCBaseContainer) container).getTarget();
if (target instanceof IWirelessTerminal
&& ((IWirelessTerminal) target).getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
this.drawSwitchGuiBtn = true;
}
}
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
}
protected void initGuiDone() {
if (drawSwitchGuiBtn) {
drawSwitchGuiBtns();
}
}
public abstract int getOffsetY();
public abstract void setOffsetY(int y);
@SuppressWarnings("unchecked")
protected void drawSwitchGuiBtns() {
if (!drawSwitchGuiBtn) return;
if (!termBtns.isEmpty()) {
this.termBtns.clear();
}
if (!(this instanceof GuiFluidCraftingWireless)) {
this.buttonList.add(
this.CraftingTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"CRAFT_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.CraftingTerminal);
}
if (!(this instanceof GuiFluidPatternWireless)) {
this.buttonList.add(
this.PatternTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"PATTERN_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.PatternTerminal);
}
if (!(this instanceof GuiFluidPatternExWireless)) {
this.buttonList.add(
this.PatternTerminaleEx = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"PATTERN_EX_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.PatternTerminaleEx);
}
if (!(this instanceof GuiFluidPortableCell)) {
this.buttonList.add(
this.FluidTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "FLUID_TEM", "YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.FluidTerminal);
}
if (!(this instanceof GuiInterfaceTerminalWireless)) {
this.buttonList.add(
this.InterfaceTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"INTERFACE_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.InterfaceTerminal);
}
if (ModAndClassUtil.ThE && !(this instanceof GuiEssentiaTerminal)) {
this.buttonList.add(
this.EssentiaTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.getOffsetY(),
"ESSENTIA_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.EssentiaTerminal);
}
}
protected void addSwitchGuiBtns() {
if (!drawSwitchGuiBtn) return;
this.buttonList.addAll(termBtns);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn instanceof GuiFCImgButton) {
if (btn == this.FluidTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_TERMINAL);
} else if (btn == this.CraftingTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_CRAFTING_TERMINAL);
} else if (btn == this.EssentiaTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_ESSENTIA_TERMINAL);
} else if (btn == this.PatternTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
} else if (btn == this.InterfaceTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_INTERFACE_TERMINAL);
} else if (btn == this.PatternTerminaleEx) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
}
}
super.actionPerformed(btn);
}
}
@@ -51,6 +51,8 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
protected GuiImgButton beSubstitutionsDisabledBtn;
protected GuiFCImgButton combineEnableBtn;
protected GuiFCImgButton combineDisableBtn;
protected GuiFCImgButton autoFillPatternEnableBtn;
protected GuiFCImgButton autoFillPatternDisableBtn;
protected final GuiScrollbar processingScrollBar = new GuiScrollbar();
protected final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
@@ -62,6 +64,24 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
setReservedSpace(81);
}
@Override
public void initGui() {
super.initGui();
this.buttonList.add(
this.autoFillPatternEnableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"FILL_PATTERN",
"DO_FILL"));
this.buttonList.add(
this.autoFillPatternDisableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"NOT_FILL_PATTERN",
"DONT_FILL"));
this.offsetY += 20;
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
@@ -108,6 +128,11 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "0"));
} else if (this.autoFillPatternDisableBtn == btn || this.autoFillPatternEnableBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.AutoFillerPattern",
this.autoFillPatternDisableBtn == btn ? "1" : "0"));
}
}
@@ -124,6 +149,8 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
updateButton(this.beSubstitutionsDisabledBtn, !this.container.beSubstitute);
updateButton(this.fluidPrioritizedEnabledBtn, this.container.prioritize);
updateButton(this.fluidPrioritizedDisabledBtn, !this.container.prioritize);
updateButton(this.autoFillPatternEnableBtn, this.container.autoFillPattern);
updateButton(this.autoFillPatternDisableBtn, !this.container.autoFillPattern);
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@@ -22,7 +22,6 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.widgets.*;
import appeng.client.me.InternalSlotME;
import appeng.client.me.ItemRepo;
@@ -34,10 +33,8 @@ 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;
@@ -49,13 +46,15 @@ import codechicken.nei.LayoutManager;
import codechicken.nei.util.TextHistory;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.FCGuiTextField;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
implements ISortSource, IConfigManagerHost, IDropToFillTextField {
public static int craftingGridOffsetX;
@@ -78,6 +77,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
protected int rows = 0;
protected int maxRows = Integer.MAX_VALUE;
protected int standardSize;
protected int offsetY;
protected GuiImgButton ViewBox;
protected GuiImgButton SortByBox;
protected GuiImgButton SortDirBox;
@@ -87,7 +87,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
@SuppressWarnings("unchecked")
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
super(c);
super(inventoryPlayer, c);
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.xSize = 195;
@@ -98,6 +98,14 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
this.viewCell = te instanceof IViewCellStorage;
}
public int getOffsetY() {
return offsetY;
}
public void setOffsetY(int y) {
offsetY = y;
}
public abstract void postUpdate(final List<T> list);
protected void setScrollBar() {
@@ -111,9 +119,8 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
}
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
@@ -140,6 +147,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
}
}
}
super.actionPerformed(btn);
}
protected void reInitalize() {
@@ -200,60 +208,60 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
int offset = this.guiTop + 8;
this.offsetY = this.guiTop + 8;
if (this.customSortOrder) {
this.buttonList.add(
this.SortByBox = new GuiImgButton(
this.guiLeft - 18,
offset,
this.offsetY,
Settings.SORT_BY,
this.configSrc.getSetting(Settings.SORT_BY)));
offset += 20;
this.offsetY += 20;
}
if (this.showViewBtn) {
this.buttonList.add(
this.ViewBox = new GuiImgButton(
this.guiLeft - 18,
offset,
this.offsetY,
Settings.VIEW_MODE,
this.configSrc.getSetting(Settings.VIEW_MODE)));
offset += 20;
this.offsetY += 20;
}
this.buttonList.add(
this.SortDirBox = new GuiImgButton(
this.guiLeft - 18,
offset,
this.offsetY,
Settings.SORT_DIRECTION,
this.configSrc.getSetting(Settings.SORT_DIRECTION)));
offset += 20;
this.offsetY += 20;
this.buttonList.add(
this.searchBoxSettings = new GuiImgButton(
this.guiLeft - 18,
offset,
this.offsetY,
Settings.SEARCH_MODE,
AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
offset += 20;
this.offsetY += 20;
if (ModAndClassUtil.isSaveText) {
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
offset,
this.offsetY,
Settings.SAVE_SEARCH,
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
offset += 20;
this.offsetY += 20;
}
this.buttonList.add(
this.terminalStyleBox = new GuiImgButton(
this.guiLeft - 18,
offset,
this.offsetY,
Settings.TERMINAL_STYLE,
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
offset += 20;
this.offsetY += 20;
this.searchField = new FCGuiTextField(
this.fontRendererObj,
@@ -274,9 +282,10 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
this.buttonList.add(
this.craftingStatusImgBtn = new GuiImgButton(
this.guiLeft - 18,
offset,
this.offsetY,
Settings.CRAFTING_STATUS,
AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
this.offsetY += 20;
} else {
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
@@ -305,7 +314,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
for (final Object s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (((Slot) s).xDisplayPosition < 195) {
if (((Slot) s).xDisplayPosition < 195 || s instanceof SlotDisabled) {
this.repositionSlot((AppEngSlot) s);
}
}
@@ -321,6 +330,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
craftingGridOffsetX -= 25;
craftingGridOffsetY -= 6;
initGuiDone();
}
public void setSearchString(String memoryText, boolean updateView) {
@@ -375,7 +385,6 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
}
@Override
@SuppressWarnings("unchecked")
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (mouseButton == 3) {
@@ -0,0 +1,99 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import appeng.container.ContainerNull;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotCraftingTerm;
import appeng.helpers.IContainerCraftingPacket;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import com.glodblock.github.inventory.item.IWirelessCraftTerminal;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class ContainerCraftingWireless extends ContainerItemMonitor
implements IAEAppEngInventory, IContainerCraftingPacket {
private final IWirelessCraftTerminal it;
private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
private final SlotCraftingTerm outputSlot;
public ContainerCraftingWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
super(ip, monitorable, false);
this.it = (IWirelessCraftTerminal) monitorable;
final IInventory crafting = this.it.getInventoryByName("crafting");
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
this.addSlotToContainer(
this.craftingSlots[x + y * 3] = new SlotCraftingMatrix(
this,
crafting,
x + y * 3,
37 + x * 18,
-72 + y * 18));
}
}
AppEngInternalInventory output = new AppEngInternalInventory(this, 1);
this.addSlotToContainer(
this.outputSlot = new SlotCraftingTerm(
this.getPlayerInv().player,
this.getActionSource(),
this.getPowerSource(),
monitorable,
crafting,
crafting,
output,
131,
-72 + 18,
this));
this.bindPlayerInventory(ip, 0, 0);
this.onCraftMatrixChanged(crafting);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
@Override
public void onCraftMatrixChanged(final IInventory par1IInventory) {
final ContainerNull cn = new ContainerNull();
final InventoryCrafting ic = new InventoryCrafting(cn, 3, 3);
for (int x = 0; x < 9; x++) {
ic.setInventorySlotContents(x, this.craftingSlots[x].getStack());
}
this.outputSlot
.putStack(CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj));
}
@Override
public void saveChanges() {
// NO-OP
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
final ItemStack removedStack, final ItemStack newStack) {
// NO-OP
}
@Override
public IInventory getInventoryByName(final String name) {
if (name.equals("player")) {
return this.getInventoryPlayer();
}
return this.it.getInventoryByName(name);
}
@Override
public boolean useRealItems() {
return true;
}
}
@@ -0,0 +1,159 @@
package com.glodblock.github.client.gui.container;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.MutablePair;
import appeng.api.config.Actionable;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.util.Util;
public class ContainerEssentiaMonitor extends ContainerFluidPortableCell {
public ContainerEssentiaMonitor(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}
@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()
&& AspectUtil.isEssentiaContainer(clickSlot.getStack())) {
ItemStack tis = clickSlot.getStack();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
tmp.put(0, null);
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
}
}
return super.transferStackInSlot(p, idx);
}
@Override
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 (AspectUtil.isEmptyEssentiaContainer(fluidContainer) && AspectUtil.isEssentiaGas(fluid)) {
// add essentia to jars
if (nfluid.getStackSize() / AspectUtil.R <= 0) continue;
final IAEFluidStack toExtract = nfluid.copy();
MutablePair<Integer, ItemStack> fillStack = AspectUtil
.fillEssentiaFromGas(out, toExtract.getFluidStack());
if (fillStack == null || 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());
if (tmp == null) continue;
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
this.dropItem(fillStack.right);
out.stackSize = fillStack.right.stackSize;
if (AspectUtil.isEssentiaContainer(fillStack.right)) {
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if ((int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R > 0) {
this.dropItem(
AspectUtil.setAspectAmount(
fillStack.right,
(int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R,
AspectUtil.getAspectFromGas(toExtract)),
1);
out.stackSize++;
}
}
} else if (!AspectUtil.isEmptyEssentiaContainer(fluidContainer)) {
// add essentia to ae network
AEFluidStack fluidStack = AspectUtil.getAEGasFromContainer(fluidContainer);
if (fluidStack == null) {
continue;
}
final IAEFluidStack aeFluidStack = fluidStack.copy();
// 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 = AspectUtil
.drainEssentiaFromGas(out.copy(), aeFluidStack.getFluidStack());
if (notInserted != null && notInserted.getStackSize() > 0 && drainStack != null) {
if (fluidStack.getStackSize() == notInserted.getStackSize()) continue;
aeFluidStack.decStackSize(notInserted.getStackSize());
if (drainStack.left > aeFluidStack.getStackSize()
&& AspectUtil.isEssentiaContainer(drainStack.right)) {
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
this.host.getFluidInventory()
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
continue;
}
// drop empty item
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left));
out.stackSize = (int) (notInserted.getStackSize() / drainStack.left);
if (AspectUtil.isEssentiaContainer(drainStack.right)) {
if (notInserted.getStackSize() % drainStack.left > 0) {
fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left));
AspectUtil.fillEssentiaFromGas(drainStack.right, fluidStack.getFluidStack());
this.dropItem(drainStack.right, 1);
}
}
if (slotIndex == -1) out.stackSize = fluidContainer.stackSize - out.stackSize;
} else if (drainStack != null) {
if (slotIndex == -1) {
out.stackSize = fluidContainer.stackSize;
} else {
if (drainStack != null) {
System.out.print("---------\n");
System.out.print(drainStack.right + "\n");
System.out.print(drainStack.left + "\n");
System.out.print(aeFluidStack.getStackSize() + "\n");
}
out.stackSize = (int) (fluidContainer.stackSize
- (aeFluidStack.getStackSize() / drainStack.left));
}
this.dropItem(drainStack.right, fluidContainer.stackSize); // drop empty item
}
} 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
protected boolean isEssentiaMode() {
return true;
}
}
@@ -25,12 +25,14 @@ public class ContainerFluidAutoFiller extends AEBaseContainer {
MutablePair<Boolean, ItemStack> result = ContainerFluidAutoFiller.isItemValid(is);
if (result.left) {
if (super.getHasStack()) super.clearStack();
hasChange = true;
super.putStack(result.right);
}
}
}
private final TileFluidAutoFiller tile;
private static boolean hasChange;
public ContainerFluidAutoFiller(InventoryPlayer ipl, TileFluidAutoFiller tile) {
super(ipl, tile);
@@ -54,6 +56,9 @@ public class ContainerFluidAutoFiller extends AEBaseContainer {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
tile.updatePattern();
if (hasChange) {
tile.updatePattern();
hasChange = false;
}
}
}
@@ -11,8 +11,10 @@ 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.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -37,10 +39,12 @@ import appeng.core.AELog;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.BlockPos;
@@ -269,6 +273,12 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (ah instanceof IWirelessTerminal) {
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
originalGui = ((ItemBaseWirelessTerminal) terminal.getItem()).guiGuiType(terminal);
}
}
if (this.result != null && !this.isSimulation() && getGrid() != null) {
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
@@ -279,13 +289,22 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
true,
this.getActionSrc());
this.setAutoStart(false);
if (g != null && originalGui != null && this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
originalGui);
if (g != null && originalGui != null) {
if (ah instanceof IWirelessTerminal) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(((IWirelessTerminal) ah).getInventorySlot(), 0, 0),
ForgeDirection.UNKNOWN,
originalGui);
} else if (this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
originalGui);
}
}
}
}
@@ -50,7 +50,7 @@ import com.glodblock.github.util.Util;
public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
protected final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
public ContainerFluidMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
@@ -109,7 +109,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
if (Platform.isClient()) {
if (Platform.isClient() && !isEssentiaMode()) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
&& Util.FluidUtil.isFluidContainer(clickSlot.getStack())) {
@@ -183,7 +183,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
}
}
private void dropItem(ItemStack is) {
protected void dropItem(ItemStack is) {
if (is == null || is.stackSize <= 0) return;
ItemStack itemStack = is.copy();
int i = itemStack.getMaxStackSize();
@@ -204,7 +204,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
}
}
private void dropItem(ItemStack itemStack, int stackSize) {
protected void dropItem(ItemStack itemStack, int stackSize) {
if (itemStack == null || itemStack.stackSize <= 0) return;
ItemStack is = itemStack.copy();
is.stackSize = stackSize;
@@ -314,4 +314,13 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
}
this.detectAndSendChanges();
}
protected boolean isEssentiaMode() {
return false;
}
@Override
protected boolean isWirelessTerminal() {
return false;
}
}
@@ -0,0 +1,17 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class ContainerFluidPatternExWireless extends ContainerFluidPatternTerminalEx {
public ContainerFluidPatternExWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
}
@@ -0,0 +1,17 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class ContainerFluidPatternWireless extends ContainerFluidPatternTerminal {
public ContainerFluidPatternWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
super(ip, monitorable);
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
}
@@ -1,71 +1,19 @@
package com.glodblock.github.client.gui.container;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.util.Platform;
import com.glodblock.github.inventory.item.IFluidPortableCell;
public class ContainerFluidPortableCell extends ContainerFluidMonitor {
private double powerMultiplier = 0.5;
private final IFluidPortableCell civ;
private int ticks = 0;
private final int slot;
public ContainerFluidPortableCell(final InventoryPlayer ip, final IFluidPortableCell monitorable) {
super(ip, monitorable, false);
if (monitorable != null) {
final int slotIndex = monitorable.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
this.slot = slotIndex;
} else {
this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem);
}
this.civ = monitorable;
this.bindPlayerInventory(ip, 0, 0);
}
@Override
public void detectAndSendChanges() {
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem()
: this.getPlayerInv().getStackInSlot(this.slot);
if (this.civ != null) {
if (currentItem != this.civ.getItemStack()) {
if (currentItem != null) {
if (Platform.isSameItem(this.civ.getItemStack(), currentItem)) {
this.getPlayerInv()
.setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack());
} else {
this.setValidContainer(false);
}
} else {
this.setValidContainer(false);
}
}
} else {
this.setValidContainer(false);
}
this.ticks++;
if (this.ticks > 10 && this.civ != null) {
this.civ.extractAEPower(
this.getPowerMultiplier() * this.ticks,
Actionable.MODULATE,
PowerMultiplier.CONFIG);
this.ticks = 0;
}
super.detectAndSendChanges();
protected boolean isWirelessTerminal() {
return true;
}
private double getPowerMultiplier() {
return this.powerMultiplier;
}
void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
}
@@ -0,0 +1,424 @@
package com.glodblock.github.client.gui.container;
import java.io.IOException;
import java.util.*;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketCompressedNBT;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.parts.AEBasePart;
import appeng.parts.misc.PartInterface;
import appeng.parts.p2p.PartP2PInterface;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.misc.TileInterface;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorIInventory;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.ItemSlot;
import appeng.util.inv.WrapperInvSlot;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
public class ContainerInterfaceWireless extends FCBaseContainer {
/**
* this stuff is all server side..
*/
private static long autoBase = Long.MIN_VALUE;
private final Multimap<IInterfaceHost, ContainerInterfaceWireless.InvTracker> diList = HashMultimap.create();
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<Long, ContainerInterfaceWireless.InvTracker>();
// private final Map<Long, InvTracker> byId = new HashMap<>();
private IGrid grid;
private NBTTagCompound data = new NBTTagCompound();
public ContainerInterfaceWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
super(ip, monitorable);
if (Platform.isServer()) {
this.grid = monitorable.getActionableNode().getGrid();
}
this.bindPlayerInventory(ip, 14, 0);
}
private Set<IGridNode> getMachineNodes() {
Set<IGridNode> union = new HashSet<>();
this.grid.getMachines(TileFluidInterface.class).forEach(union::add);
this.grid.getMachines(TileInterface.class).forEach(union::add);
this.grid.getMachines(PartFluidInterface.class).forEach(union::add);
this.grid.getMachines(PartInterface.class).forEach(union::add);
this.grid.getMachines(PartP2PInterface.class).forEach(union::add);
return union;
}
@Override
public void detectAndSendChanges() {
if (Platform.isClient()) {
return;
}
super.detectAndSendChanges();
if (this.grid == null) {
return;
}
int total = 0;
boolean missing = false;
final IActionHost host = this.getActionHost();
if (host != null) {
final IGridNode agn = host.getActionableNode();
if (agn != null && agn.isActive()) {
for (final IGridNode gn : this.getMachineNodes()) {
ContainerInterfaceWireless.InterfaceCheck interfaceCheck = new ContainerInterfaceWireless.InterfaceCheck()
.invoke(gn);
total += interfaceCheck.getTotal();
missing |= interfaceCheck.isMissing();
}
}
}
if (total != this.diList.size() || missing) {
this.regenList(this.data);
} else {
for (final ContainerInterfaceWireless.InvTracker inv : diList.values()) {
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
if (this.isDifferent(inv.server.getStackInSlot(inv.offset + x), inv.client.getStackInSlot(x))) {
this.addItems(this.data, inv, x, 1);
}
}
}
}
if (!this.data.hasNoTags()) {
try {
NetworkHandler.instance
.sendTo(new PacketCompressedNBT(this.data), (EntityPlayerMP) this.getPlayerInv().player);
} catch (final IOException e) {
// :P
}
this.data = new NBTTagCompound();
}
}
@Override
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slot, final long id) {
final ContainerInterfaceWireless.InvTracker inv = this.byId.get(id);
if (inv != null) {
final ItemStack is = inv.server.getStackInSlot(slot + inv.offset);
final boolean hasItemInHand = player.inventory.getItemStack() != null;
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
final WrapperInvSlot slotInv = new ContainerInterfaceWireless.PatternInvSlot(inv.server);
final IInventory theSlot = slotInv.getWrapper(slot + inv.offset);
final InventoryAdaptor interfaceSlot = new AdaptorIInventory(theSlot);
IInventory interfaceHandler = inv.server;
boolean canInsert = true;
switch (action) {
case PICKUP_OR_SET_DOWN:
if (hasItemInHand) {
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
if (Platform.isSameItemPrecise(
interfaceHandler.getStackInSlot(s),
player.inventory.getItemStack())) {
canInsert = false;
break;
}
}
if (canInsert) {
ItemStack inSlot = theSlot.getStackInSlot(0);
if (inSlot == null) {
player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack()));
} else {
inSlot = inSlot.copy();
final ItemStack inHand = player.inventory.getItemStack().copy();
theSlot.setInventorySlotContents(0, null);
player.inventory.setItemStack(null);
player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy()));
if (player.inventory.getItemStack() == null) {
player.inventory.setItemStack(inSlot);
} else {
player.inventory.setItemStack(inHand);
theSlot.setInventorySlotContents(0, inSlot);
}
}
}
} else {
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
mySlot.setInventorySlotContents(0, playerHand.addItems(mySlot.getStackInSlot(0)));
}
break;
case SPLIT_OR_PLACE_SINGLE:
if (hasItemInHand) {
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
if (Platform.isSameItemPrecise(
interfaceHandler.getStackInSlot(s),
player.inventory.getItemStack())) {
canInsert = false;
break;
}
}
if (canInsert) {
ItemStack extra = playerHand.removeItems(1, null, null);
if (extra != null && !interfaceSlot.containsItems()) {
extra = interfaceSlot.addItems(extra);
}
if (extra != null) {
playerHand.addItems(extra);
}
}
} else if (is != null) {
ItemStack extra = interfaceSlot.removeItems((is.stackSize + 1) / 2, null, null);
if (extra != null) {
extra = playerHand.addItems(extra);
}
if (extra != null) {
interfaceSlot.addItems(extra);
}
}
break;
case SHIFT_CLICK:
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
mySlot.setInventorySlotContents(0, mergeToPlayerInventory(playerInv, mySlot.getStackInSlot(0)));
break;
case MOVE_REGION:
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
inv.server.setInventorySlotContents(
x + inv.offset,
mergeToPlayerInventory(playerInvAd, inv.server.getStackInSlot(x + inv.offset)));
}
break;
case CREATIVE_DUPLICATE:
if (player.capabilities.isCreativeMode && !hasItemInHand) {
player.inventory.setItemStack(is == null ? null : is.copy());
}
break;
default:
return;
}
this.updateHeld(player);
}
}
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack) {
if (stack == null) return null;
for (ItemSlot slot : playerInv) {
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
++slot.getItemStack().stackSize;
return null;
}
}
}
return playerInv.addItems(stack);
}
private void regenList(final NBTTagCompound data) {
this.byId.clear();
this.diList.clear();
final IActionHost host = this.getActionHost();
if (host != null) {
final IGridNode agn = host.getActionableNode();
if (agn != null && agn.isActive()) {
for (final IGridNode gn : this.getMachineNodes()) {
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
final DualityInterface dual = ih.getInterfaceDuality();
if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) {
for (int i = 0; i <= dual.getInstalledUpgrades(Upgrades.PATTERN_CAPACITY); ++i) {
this.diList.put(
ih,
new ContainerInterfaceWireless.InvTracker(
dual,
dual.getPatterns(),
dual.getTermName(),
i * 9,
9));
}
}
}
}
}
data.setBoolean("clear", true);
for (final ContainerInterfaceWireless.InvTracker inv : this.diList.values()) {
this.byId.put(inv.which, inv);
this.addItems(data, inv, 0, inv.client.getSizeInventory());
}
}
@Override
protected boolean isWirelessTerminal() {
return true;
}
private boolean isDifferent(final ItemStack a, final ItemStack b) {
if (a == null && b == null) {
return false;
}
if (a == null || b == null) {
return true;
}
return !ItemStack.areItemStacksEqual(a, b);
}
private void addItems(final NBTTagCompound data, final ContainerInterfaceWireless.InvTracker inv, final int offset,
final int length) {
final String name = '=' + Long.toString(inv.which, Character.MAX_RADIX);
final NBTTagCompound tag = data.getCompoundTag(name);
if (tag.hasNoTags()) {
tag.setLong("sortBy", inv.sortBy);
tag.setString("un", inv.unlocalizedName);
tag.setInteger("x", inv.X);
tag.setInteger("y", inv.Y);
tag.setInteger("z", inv.Z);
tag.setInteger("dim", inv.dim);
tag.setInteger("side", inv.side.ordinal());
}
for (int x = 0; x < length; x++) {
final NBTTagCompound itemNBT = new NBTTagCompound();
final ItemStack is = inv.server.getStackInSlot(x + offset + inv.offset);
// "update" client side.
inv.client.setInventorySlotContents(offset + x, is == null ? null : is.copy());
if (is != null) {
is.writeToNBT(itemNBT);
}
tag.setTag(Integer.toString(x + offset), itemNBT);
}
data.setTag(name, tag);
}
private static class InvTracker {
private final long sortBy;
private final long which = autoBase++;
private final String unlocalizedName;
private final IInventory client;
private final IInventory server;
private final int offset;
private final int X;
private final int Y;
private final int Z;
private final int dim;
private final ForgeDirection side;
public InvTracker(final DualityInterface dual, final IInventory patterns, final String unlocalizedName,
int offset, int size) {
this.server = patterns;
this.client = new AppEngInternalInventory(null, size);
this.unlocalizedName = unlocalizedName;
this.sortBy = dual.getSortValue() + offset << 16;
this.offset = offset;
X = dual.getLocation().x;
Y = dual.getLocation().y;
Z = dual.getLocation().z;
dim = dual.getLocation().getDimension();
if (dual.getHost() instanceof AEBasePart) {
side = ((AEBasePart) dual.getHost()).getSide();
} else {
side = ForgeDirection.UNKNOWN;
}
}
}
private static class PatternInvSlot extends WrapperInvSlot {
public PatternInvSlot(final IInventory inv) {
super(inv);
}
@Override
public boolean isItemValid(final ItemStack itemstack) {
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
}
}
private class InterfaceCheck {
int total = 0;
boolean missing = false;
public InterfaceCheck() {}
public int getTotal() {
return total;
}
public boolean isMissing() {
return missing;
}
public ContainerInterfaceWireless.InterfaceCheck invoke(IGridNode gn) {
if (gn.isActive()) {
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
if (ih.getInterfaceDuality().getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO
|| ih instanceof PartP2PInterface && ((PartP2PInterface) ih).isOutput()) {
return this;
}
final Collection<ContainerInterfaceWireless.InvTracker> t = ContainerInterfaceWireless.this.diList
.get(ih);
if (t.isEmpty()) {
missing = true;
} else {
final DualityInterface dual = ih.getInterfaceDuality();
for (ContainerInterfaceWireless.InvTracker it : t) {
if (!it.unlocalizedName.equals(dual.getTermName())) {
missing = true;
}
}
}
total += (ih.getInterfaceDuality().getInstalledUpgrades(Upgrades.PATTERN_CAPACITY) + 1);
}
return this;
}
}
}
@@ -150,4 +150,9 @@ public class ContainerItemMonitor extends FCContainerMonitor<IAEItemStack> {
this.items.add(is);
}
}
@Override
protected boolean isWirelessTerminal() {
return false;
}
}
@@ -0,0 +1,62 @@
package com.glodblock.github.client.gui.container.base;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.util.Util;
public abstract class FCBaseContainer extends AEBaseContainer {
private int ticks;
private final double powerMultiplier = 0.5;
private IFluidPortableCell host;
private int slot = -1;
private final InventoryPlayer ip;
public FCBaseContainer(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
this.ip = ip;
if (isWirelessTerminal()) {
host = (IFluidPortableCell) monitorable;
this.slot = lockSlot();
}
}
private int lockSlot() {
if (isWirelessTerminal()) {
if (this.host != null) {
final int slotIndex = this.host.getInventorySlot();
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
this.lockPlayerInventorySlot(slotIndex);
}
return slotIndex;
} else {
this.lockPlayerInventorySlot(ip.currentItem);
}
}
return -1;
}
protected abstract boolean isWirelessTerminal();
public void detectAndSendChanges() {
if (isWirelessTerminal()) {
this.ticks = Util.drainItemPower(
this,
this.getPlayerInv(),
this.slot,
this.ticks,
this.getPowerMultiplier(),
this.host);
}
super.detectAndSendChanges();
}
public double getPowerMultiplier() {
return this.powerMultiplier;
}
}
@@ -18,6 +18,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
@@ -36,8 +37,8 @@ import com.glodblock.github.client.gui.container.ContainerItemMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
import com.glodblock.github.inventory.IPatternConsumer;
import com.glodblock.github.inventory.item.IItemPatternTerminal;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
@@ -45,7 +46,7 @@ import com.glodblock.github.util.Util;
public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket, IPatternConsumer {
protected final FCFluidEncodeTerminal patternTerminal;
protected final IItemPatternTerminal patternTerminal;
protected final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
protected final IInventory crafting;
protected final SlotRestrictedInput patternSlotIN;
@@ -75,9 +76,12 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
@GuiSync(91)
public boolean prioritize = false;
@GuiSync(90)
public boolean autoFillPattern = false;
public FCContainerEncodeTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
this.patternTerminal = (FCFluidEncodeTerminal) monitorable;
this.patternTerminal = (IItemPatternTerminal) monitorable;
this.inverted = patternTerminal.isInverted();
final IInventory patternInv = this.patternTerminal.getInventoryByName("pattern");
this.crafting = this.patternTerminal.getInventoryByName("crafting");
@@ -170,7 +174,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
}
}
public FCFluidEncodeTerminal getPatternTerminal() {
public IItemPatternTerminal getPatternTerminal() {
return this.patternTerminal;
}
@@ -302,6 +306,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
}
this.patternSlotOUT.putStack(null);
}
fillPattern();
}
public void encodeAllItemAndMoveToInventory() {
@@ -315,9 +320,38 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
fillPattern();
}
private void fillPattern() {
if (this.autoFillPattern && this.getHost().getItemInventory() != null) {
// try to use me network item to fill pattern input slot
final IDefinitions definitions = AEApi.instance().definitions();
int fillStackSize = this.patternSlotIN.getHasStack() ? 64 - this.patternSlotIN.getStack().stackSize : 64;
if (fillStackSize == 0) return;
for (ItemStack blankPattern : definitions.materials().blankPattern().maybeStack(fillStackSize).asSet()) {
IAEItemStack iBlankPattern = AEApi.instance().storage().createItemStack(blankPattern);
if (this.patternSlotIN.getHasStack() && !iBlankPattern.isSameType(this.patternSlotIN.getStack()))
continue;
IAEItemStack out = this.getHost().getItemInventory()
.extractItems(iBlankPattern, Actionable.MODULATE, this.getActionSource());
if (out != null) {
ItemStack outPattern;
if (this.patternSlotIN.getHasStack()) {
outPattern = this.patternSlotIN.getStack().copy();
outPattern.stackSize += out.getItemStack().stackSize;
} else {
outPattern = out.getItemStack();
}
this.patternSlotIN.putStack(outPattern);
return;
}
}
}
}
public void encode() {
fillPattern();
if (!checkHasFluidPattern()) {
encodeItemPattern();
return;
@@ -368,13 +402,11 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
for (final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern()
.maybeStack(1).asSet()) {
output = encodedPatternStack;
this.patternSlotOUT.putStack(output);
}
} else if (output.getItem() instanceof ItemFluidEncodedPattern) {
for (final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern()
.maybeStack(1).asSet()) {
output = encodedPatternStack;
this.patternSlotOUT.putStack(output);
}
}
@@ -399,6 +431,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
encodedValue.setBoolean("beSubstitute", this.beSubstitute);
encodedValue.setBoolean("prioritize", this.prioritize);
output.setTagCompound(encodedValue);
this.patternSlotOUT.putStack(output);
}
protected ItemStack[] getInputs() {
@@ -455,6 +488,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
this.combine = this.patternTerminal.shouldCombine();
this.beSubstitute = this.patternTerminal.canBeSubstitute();
this.prioritize = this.patternTerminal.isPrioritize();
this.autoFillPattern = this.patternTerminal.isAutoFillPattern();
}
}
@@ -9,19 +9,16 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
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.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AELog;
@@ -32,7 +29,9 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseContainer
import com.glodblock.github.inventory.item.IWirelessTerminal;
public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseContainer
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<T> {
protected final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
@@ -56,10 +55,7 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseCo
protected FCContainerMonitor(final InventoryPlayer ip, final ITerminalHost monitorable,
final boolean bindInventory) {
super(
ip,
monitorable instanceof TileEntity ? (TileEntity) monitorable : null,
monitorable instanceof IPart ? (IPart) monitorable : null);
super(ip, monitorable);
this.host = monitorable;
this.clientCM = new ConfigManager(this);
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
@@ -77,19 +73,21 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseCo
if (isInvalid()) {
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 (this.serverCM != null) {
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 (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);
}
}
}
}
@@ -98,6 +96,7 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseCo
this.updatePowerStatus();
final boolean oldAccessible = this.canAccessViewCells;
this.canAccessViewCells = this.host instanceof WirelessTerminalGuiObject
|| this.host instanceof IWirelessTerminal
|| this.hasAccess(SecurityPermissions.BUILD, false);
if (this.canAccessViewCells != oldAccessible) {
for (int y = 0; y < 5; y++) {
@@ -214,4 +213,8 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseCo
this.getGui().updateSetting(manager, settingName, newValue);
}
}
public ITerminalHost getHost() {
return this.host;
}
}
@@ -0,0 +1,41 @@
package com.glodblock.github.client.me;
import java.util.Iterator;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.IScrollSource;
import appeng.client.gui.widgets.ISortSource;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
public class EssentiaRepo extends FluidRepo {
public EssentiaRepo(final IScrollSource src, final ISortSource sortSrc) {
super(src, sortSrc);
}
@Override
public void updateView() {
super.updateView();
Iterator<IAEItemStack> it1 = this.view.iterator();
while (it1.hasNext()) {
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(it1.next());
if (!AspectUtil.isEssentiaGas(fluid)) {
it1.remove();
}
}
Iterator<ItemStack> it2 = this.dsp.iterator();
while (it2.hasNext()) {
FluidStack fluid = ItemFluidDrop.getFluidStack(it2.next());
if (!AspectUtil.isEssentiaGas(fluid)) {
it2.remove();
}
}
}
}
@@ -39,8 +39,8 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
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>();
protected final ArrayList<IAEItemStack> view = new ArrayList<>();
protected final ArrayList<ItemStack> dsp = new ArrayList<>();
private final IScrollSource src;
private final ISortSource sortSrc;
@@ -182,7 +182,7 @@ public class FluidRepo extends ItemRepo {
private void updateNEI(final String filter) {
try {
if (this.NEIWord == null || !this.NEIWord.equals(filter)) {
final Class c = ReflectionHelper
final Class<?> c = ReflectionHelper
.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager");
final Field fldSearchField = c.getField("searchField");
final Object searchField = fldSearchField.get(c);
@@ -1,20 +1,38 @@
package com.glodblock.github.client.render;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.render.tank.ModelCertusTank;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.loader.ItemAndBlockHolder;
import cpw.mods.fml.client.registry.ClientRegistry;
public class ItemCertusQuartzTankRender implements IItemRenderer {
public ItemCertusQuartzTankRender() {
private final ModelCertusTank model = new ModelCertusTank();
//
// MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.CERTUS_QUARTZ_TANK),
// this);
public ItemCertusQuartzTankRender() {
ClientRegistry.bindTileEntitySpecialRenderer(TileCertusQuartzTank.class, new RenderBlockCertusQuartzTank());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.CERTUS_QUARTZ_TANK), this);
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
return type != ItemRenderType.EQUIPPED_FIRST_PERSON;
}
@Override
@@ -23,5 +41,65 @@ public class ItemCertusQuartzTankRender implements IItemRenderer {
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {}
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Minecraft.getMinecraft().renderEngine
.bindTexture(FluidCraft.resource("textures/blocks/certus_quartz_tank/map.png"));
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GL11.glScalef(1, -1, -1);
this.model.render(0.0625f);
GL11.glScalef(1, -1, 1);
this.model.render(0.0625f);
if (item != null && item.hasTagCompound()) {
FluidStack storedFluid = FluidStack
.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("tileEntity"));
int tankCapacity = 32000;
if (storedFluid != null && storedFluid.getFluid() != null) {
IIcon fluidIcon = storedFluid.getFluid().getIcon();
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
Tessellator tessellator = Tessellator.instance;
RenderBlocks renderer = new RenderBlocks();
GL11.glScalef(1, 1, -1);
renderer.setRenderBounds(
0.08F,
0.001F,
0.08F,
0.92F,
(float) storedFluid.amount / (float) tankCapacity * 0.999F,
0.92F);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
Block waterBlock = FluidRegistry.WATER.getBlock();
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(
(storedFluid.getFluid().getColor() >> 16 & 0xFF) / 255.0F,
(storedFluid.getFluid().getColor() >> 8 & 0xFF) / 255.0F,
(storedFluid.getFluid().getColor() & 0xFF) / 255.0F,
1.0F);
tessellator.setNormal(0.0F, -1F, 0.0F);
renderer.renderFaceYNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, -1F);
renderer.renderFaceZNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderer.renderFaceXNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
tessellator.draw();
}
}
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}
@@ -27,25 +27,19 @@ public class ItemWalrusRender implements IItemRenderer {
}
@Override
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
}
@Override
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
GL11.glPushMatrix();
switch (type) {
case ENTITY:
break;
case EQUIPPED:
break;
case EQUIPPED_FIRST_PERSON:
GL11.glRotated(180, 0, 1, 0);
GL11.glTranslatef(-1F, 0.5F, -0.5F);
break;
case FIRST_PERSON_MAP:
break;
case INVENTORY:
GL11.glTranslatef(-0.5F, -0.5F, -0.1F);
break;
@@ -57,8 +51,7 @@ public class ItemWalrusRender implements IItemRenderer {
}
@Override
public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item,
IItemRenderer.ItemRendererHelper helper) {
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
return true;
}
}
@@ -0,0 +1,54 @@
package com.glodblock.github.client.render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.client.render.tank.FluidTankRenderer;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.util.RenderUtil;
import com.glodblock.github.util.Util;
public class RenderBlockCertusQuartzTank extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
TileCertusQuartzTank tank = (TileCertusQuartzTank) tileentity;
FluidStack liquid = tank.tank.getFluid();
if (liquid == null || liquid.getFluid() == null || liquid.amount <= 0) {
return;
}
int color = liquid.getFluid().getColor(liquid);
int[] displayList = FluidTankRenderer.getFluidDisplayLists(liquid, tileentity.getWorldObj(), false);
if (displayList == null) {
return;
}
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
bindTexture(TextureMap.locationBlocksTexture);
RenderUtil.setGLColorFromInt(color);
GL11.glTranslatef((float) x + 0.0625F, (float) y + 0.5F, (float) z + 0.0625F);
GL11.glScalef(0.875F, 0.99F, 0.875F);
GL11.glTranslatef(0, -0.5F, 0);
int dl = (int) ((float) liquid.amount / (float) (tank.tank.getCapacity())
* (FluidTankRenderer.DISPLAY_STAGES - 1));
GL11.glCallList(displayList[Util.clamp(dl, 0, FluidTankRenderer.DISPLAY_STAGES - 1)]);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}
@@ -0,0 +1,121 @@
package com.glodblock.github.client.render.tank;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.util.RenderUtil;
public class FluidTankRenderer {
public static final int DISPLAY_STAGES = 100;
private static final Map<Fluid, int[]> flowingRenderCache = new HashMap<>();
private static final Map<Fluid, int[]> stillRenderCache = new HashMap<>();
private static final RenderEntityBlock.RenderInfo liquidBlock = new RenderEntityBlock.RenderInfo();
public static void onTextureReload() {
for (int[] ia : flowingRenderCache.values()) {
for (int i : ia) {
GL11.glDeleteLists(i, 1);
}
}
flowingRenderCache.clear();
for (int[] ia : stillRenderCache.values()) {
for (int i : ia) {
GL11.glDeleteLists(i, 1);
}
}
stillRenderCache.clear();
}
public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) {
if (fluidStack == null) {
return null;
}
return getFluidTexture(fluidStack.getFluid(), flowing);
}
public static IIcon getFluidTexture(Fluid fluid, boolean flowing) {
if (fluid == null) {
return null;
}
IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
if (icon == null) {
icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager()
.getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
}
return icon;
}
public static void setColorForFluidStack(FluidStack fluidstack) {
if (fluidstack == null) {
return;
}
int color = fluidstack.getFluid().getColor(fluidstack);
RenderUtil.setGLColorFromInt(color);
}
public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing) {
if (fluidStack == null) {
return null;
}
Fluid fluid = fluidStack.getFluid();
if (fluid == null) {
return null;
}
Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
int[] diplayLists = cache.get(fluid);
if (diplayLists != null) {
return diplayLists;
}
diplayLists = new int[DISPLAY_STAGES];
if (fluid.getBlock() != null) {
liquidBlock.baseBlock = fluid.getBlock();
} else {
liquidBlock.baseBlock = Blocks.water;
}
liquidBlock.texture = getFluidTexture(fluidStack, flowing);
cache.put(fluid, diplayLists);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_CULL_FACE);
for (int s = 0; s < DISPLAY_STAGES; ++s) {
diplayLists[s] = GLAllocation.generateDisplayLists(1);
GL11.glNewList(diplayLists[s], 4864 /* GL_COMPILE */);
liquidBlock.minX = 0.01f;
liquidBlock.minY = 0;
liquidBlock.minZ = 0.01f;
liquidBlock.maxX = 0.99f;
liquidBlock.maxY = Math.max(s, 1) / (float) DISPLAY_STAGES;
liquidBlock.maxZ = 0.99f;
RenderEntityBlock.INSTANCE.renderBlock(liquidBlock);
GL11.glEndList();
}
GL11.glColor4f(1, 1, 1, 1);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
return diplayLists;
}
}
@@ -0,0 +1,144 @@
package com.glodblock.github.client.render.tank;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
public class ModelCertusTank extends ModelBase {
ModelRenderer Shape1;
public ModelCertusTank() {
this.textureWidth = 64;
this.textureHeight = 64;
this.Shape1 = new ModelRenderer(this, 0, 0);
this.Shape1.addBox(0F, 0F, 0F, 14, 16, 14);
this.Shape1.setRotationPoint(-7F, -8F, -7F);
this.Shape1.setTextureSize(this.textureWidth, this.textureHeight);
this.Shape1.mirror = true;
setRotation(this.Shape1, 0F, 0F, 0F);
}
public void render(float f) {
this.Shape1.render(f);
}
public void renderFluid(TileEntity tileEntity, double x, double y, double z, RenderBlocks renderer) {
Tessellator tessellator = Tessellator.instance;
if (tileEntity != null
&& ((TileCertusQuartzTank) tileEntity).getTankInfo(ForgeDirection.UNKNOWN)[0].fluid != null) {
Fluid storedFluid = ((TileCertusQuartzTank) tileEntity).getRenderFluid();
float scale = ((TileCertusQuartzTank) tileEntity).getRenderScale();
if (storedFluid != null && scale > 0) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Block id = Block.getBlockById(FluidRegistry.WATER.getID());
IIcon fluidIcon = storedFluid.getIcon();
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
renderer.setRenderBounds(0.08F, 0.001F, 0.08F, 0.92, scale * 0.999F, 0.92F);
tessellator.setColorRGBA_F(
(storedFluid.getColor() >> 16 & 0xFF) / 255.0F,
(storedFluid.getColor() >> 8 & 0xFF) / 255.0F,
(storedFluid.getColor() & 0xFF) / 255.0F,
1.0F);
tessellator.setNormal(0.0F, -1F, 0.0F);
renderer.renderFaceYNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(id, x, y, z, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, -1F);
renderer.renderFaceZNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(id, x, y, z, fluidIcon);
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderer.renderFaceXNeg(id, x, y, z, fluidIcon);
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(id, x, y, z, fluidIcon);
}
}
}
public void renderInnerBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) {
Tessellator tessellator = Tessellator.instance;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
tessellator.setBrightness(15728640);
boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank;
boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank;
int meta = 0;
if (tankUp && tankDown) meta = 3;
else if (tankUp) meta = 2;
else if (tankDown) meta = 1;
if (!tankUp) {
tessellator.setNormal(0, -1, 0);
renderer.renderFaceYNeg(block, x, y + 0.99F, z, block.getIcon(1, 0));
}
if (!tankDown) {
tessellator.setNormal(0, 1, 0);
renderer.renderFaceYPos(block, x, y - 0.99F, z, block.getIcon(0, 0));
}
IIcon sideIcon = block.getIcon(3, meta);
tessellator.setNormal(0, 0, -1);
renderer.renderFaceZNeg(block, x, y, z + 0.875F, sideIcon);
tessellator.setNormal(0, 0, 1);
renderer.renderFaceZPos(block, x, y, z - 0.875F, sideIcon);
tessellator.setNormal(-1, 0, 0);
renderer.renderFaceXNeg(block, x + 0.875F, y, z, sideIcon);
tessellator.setNormal(1, 0, 0);
renderer.renderFaceXPos(block, x - 0.875F, y, z, sideIcon);
GL11.glPopMatrix();
}
public void renderOuterBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) {
Tessellator tessellator = Tessellator.instance;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank;
boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank;
int meta = 0;
if (tankUp && tankDown) meta = 3;
else if (tankUp) meta = 2;
else if (tankDown) meta = 1;
if (!tankDown) {
tessellator.setNormal(0.0F, -1F, 0.0F);
renderer.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0));
}
if (!tankUp) {
tessellator.setNormal(0.0F, 1.0F, 0.0F);
renderer.renderFaceYPos(block, x, y, z, block.getIcon(1, 0));
}
IIcon sideIcon = block.getIcon(3, meta);
tessellator.setNormal(0.0F, 0.0F, -1F);
renderer.renderFaceZNeg(block, x, y, z, sideIcon);
tessellator.setNormal(0.0F, 0.0F, 1.0F);
renderer.renderFaceZPos(block, x, y, z, sideIcon);
tessellator.setNormal(-1F, 0.0F, 0.0F);
renderer.renderFaceXNeg(block, x, y, z, sideIcon);
tessellator.setNormal(1.0F, 0.0F, 0.0F);
renderer.renderFaceXPos(block, x, y, z, sideIcon);
GL11.glPopMatrix();
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}
@@ -0,0 +1,169 @@
package com.glodblock.github.client.render.tank;
import java.util.Arrays;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class RenderEntityBlock extends Render {
public static RenderEntityBlock INSTANCE = new RenderEntityBlock();
protected RenderBlocks renderBlocks;
private RenderEntityBlock() {
renderBlocks = field_147909_c;
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
throw new UnsupportedOperationException("Not supported yet.");
}
public static class RenderInfo {
public double minX = 0.0F;
public double minY = 0.0F;
public double minZ = 0.0F;
public double maxX = 1.0F;
public double maxY = 1.0F;
public double maxZ = 1.0F;
public Block baseBlock = Blocks.sand;
public IIcon texture = null;
public IIcon[] textureArray = null;
public boolean[] renderSide = new boolean[] { true, true, true, true, true, true };
public int light = -1;
public int brightness = -1;
public RenderInfo() {}
public RenderInfo(Block template, IIcon[] texture) {
this();
this.baseBlock = template;
this.textureArray = texture;
}
public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
this();
setBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
public void setSkyBlockLight(World world, int x, int y, int z, int light) {
this.brightness = world.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, x, y, z) << 16 | light;
}
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) {
return baseBlock.getMixedBrightnessForBlock(iblockaccess, i, j, k);
}
public final void setBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
this.minX = minX;
this.minY = minY;
this.minZ = minZ;
this.maxX = maxX;
this.maxY = maxY;
this.maxZ = maxZ;
}
public final void setRenderSingleSide(int side) {
Arrays.fill(renderSide, false);
renderSide[side] = true;
}
public final void setRenderAllSides() {
Arrays.fill(renderSide, true);
}
public void rotate() {
double temp = minX;
minX = minZ;
minZ = temp;
temp = maxX;
maxX = maxZ;
maxZ = temp;
}
public void reverseX() {
double temp = minX;
minX = 1 - maxX;
maxX = 1 - temp;
}
public void reverseZ() {
double temp = minZ;
minZ = 1 - maxZ;
maxZ = 1 - temp;
}
public IIcon getBlockTextureFromSide(int i) {
if (texture != null) {
return texture;
}
int index = i;
if (textureArray == null || textureArray.length == 0) {
return baseBlock.getBlockTextureFromSide(index);
} else {
if (index >= textureArray.length) {
index = 0;
}
return textureArray[index];
}
}
}
@Override
public void doRender(Entity entity, double x, double y, double z, float f, float f1) {
// NO-OP
}
public void renderBlock(RenderInfo info) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ);
if (info.light != -1) {
tessellator.setBrightness(info.light << 20 | info.light << 4);
} else if (info.brightness != -1) {
tessellator.setBrightness(info.brightness << 4);
}
if (info.renderSide[0]) {
tessellator.setNormal(0, -1, 0);
renderBlocks.renderFaceYNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(0));
}
if (info.renderSide[1]) {
tessellator.setNormal(0, 1, 0);
renderBlocks.renderFaceYPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(1));
}
if (info.renderSide[2]) {
tessellator.setNormal(0, 0, -1);
renderBlocks.renderFaceZNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(2));
}
if (info.renderSide[3]) {
tessellator.setNormal(0, 0, 1);
renderBlocks.renderFaceZPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(3));
}
if (info.renderSide[4]) {
tessellator.setNormal(-1, 0, 0);
renderBlocks.renderFaceXNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(4));
}
if (info.renderSide[5]) {
tessellator.setNormal(1, 0, 0);
renderBlocks.renderFaceXPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(5));
}
tessellator.draw();
}
}
@@ -9,10 +9,14 @@ import net.minecraft.item.ItemStack;
public abstract class BaseBlockContainer extends BlockContainer {
public BaseBlockContainer(Material p_i45386_1_) {
super(p_i45386_1_);
public BaseBlockContainer(Material material) {
super(material);
}
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> toolTip,
boolean advancedToolTips) {}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -1,11 +1,16 @@
package com.glodblock.github.common.block;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -13,13 +18,11 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.implementations.items.IAEWrench;
import buildcraft.api.tools.IToolWrench;
import buildcraft.factory.BlockTank;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemCertusQuartzTank;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
@@ -28,98 +31,116 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCertusQuartzTank extends BlockTank implements IRegister<BlockTank> {
public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegister<BlockCertusQuartzTank> {
private IIcon textureStackedSide;
IIcon breakIcon;
IIcon topIcon;
IIcon bottomIcon;
IIcon sideIcon;
IIcon sideMiddleIcon;
IIcon sideTopIcon;
IIcon sideBottomIcon;
public BlockCertusQuartzTank() {
super(Material.glass);
setBlockName(NameConst.BLOCK_CERTUS_QUARTZ_TANK);
setResistance(1.0F);
setHardness(0.5F);
setResistance(10.0F);
setHardness(2.0F);
setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
}
public ItemStack getDropWithNBT(World world, int x, int y, int z) {
NBTTagCompound nbt = new NBTTagCompound();
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileCertusQuartzTank) {
ItemStack dropStack = new ItemStack(ItemAndBlockHolder.CERTUS_QUARTZ_TANK, 1);
((TileCertusQuartzTank) te).writeToNBTWithoutCoords(nbt);
if (!nbt.getCompoundTag("tank").hasKey("Empty")) {
dropStack.setTagCompound(nbt);
}
@Override
public boolean canRenderInPass(int pass) {
return true;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCertusQuartzTank();
}
public ItemStack getDropWithNBT(World world, int x, int y, int z) {
NBTTagCompound tileEntity = new NBTTagCompound();
TileEntity worldTE = world.getTileEntity(x, y, z);
if (worldTE instanceof TileCertusQuartzTank) {
ItemStack dropStack = new ItemStack(ItemAndBlockHolder.CERTUS_QUARTZ_TANK, 1);
((TileCertusQuartzTank) worldTE).writeToNBTWithoutCoords(tileEntity);
if (!tileEntity.hasKey("Empty")) {
dropStack.setTagCompound(new NBTTagCompound());
dropStack.stackTagCompound.setTag("tileEntity", tileEntity);
}
return dropStack;
}
return null;
}
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileCertusQuartzTank();
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister) {
super.registerBlockIcons(par1IconRegister);
textureStackedSide = par1IconRegister.registerIcon(FluidCraft.MODID + ":certus_quartz_tank/side_stacked");
}
@Override
public IIcon getIconAbsolute(IBlockAccess iblockaccess, int x, int y, int z, int side, int metadata) {
if (side >= 2 && (iblockaccess.getBlock(x, y - 1, z) instanceof BlockCertusQuartzTank)) {
return textureStackedSide;
} else {
return super.getIconAbsolute(side, metadata);
public IIcon getIcon(int side, int meta) {
switch (meta) {
case 1:
return this.sideTopIcon;
case 2:
return this.sideBottomIcon;
case 3:
return this.sideMiddleIcon;
default:
return side == 0 ? this.bottomIcon : side == 1 ? this.topIcon : this.sideIcon;
}
}
@Override
public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer p, int blockID, float offsetX,
float offsetY, float offsetZ) {
ItemStack current = p.inventory.getCurrentItem();
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return getDropWithNBT(world, x, y, z);
}
if (p.isSneaking() && current != null) {
try {
if (current.getItem() instanceof IToolWrench
&& ((IToolWrench) current.getItem()).canWrench(p, x, y, z)) {
dropBlockAsItem(worldObj, x, y, z, getDropWithNBT(worldObj, x, y, z));
worldObj.setBlockToAir(x, y, z);
((IToolWrench) current.getItem()).wrenchUsed(p, x, y, z);
return true;
}
} catch (Throwable e) {
// No IToolWrench
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileCertusQuartzTank) {
TileCertusQuartzTank tank = (TileCertusQuartzTank) tile;
return tank.getFluidLightLevel();
}
return super.getLightValue(world, x, y, z);
}
@Override
public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer entityplayer, int blockID,
float offsetX, float offsetY, float offsetZ) {
ItemStack current = entityplayer.inventory.getCurrentItem();
if (entityplayer.isSneaking() && current != null) {
if (current.getItem() instanceof IAEWrench
&& ((IAEWrench) current.getItem()).canWrench(current, p, x, y, z)) {
&& ((IAEWrench) current.getItem()).canWrench(current, entityplayer, x, y, z)) {
dropBlockAsItem(worldObj, x, y, z, getDropWithNBT(worldObj, x, y, z));
worldObj.setBlockToAir(x, y, z);
return true;
}
}
if (current != null) {
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);
TileCertusQuartzTank tank = (TileCertusQuartzTank) worldObj.getTileEntity(x, y, z);
if (liquid != null) {
int amountFilled = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if (amountFilled != 0 && !p.capabilities.isCreativeMode) {
if (amountFilled != 0 && !entityplayer.capabilities.isCreativeMode && current.getItem() != null) {
if (current.stackSize > 1) {
p.inventory.mainInventory[p.inventory.currentItem].stackSize -= 1;
p.inventory.addItemStackToInventory(current.getItem().getContainerItem(current));
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1;
entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItem(current));
} else {
p.inventory.mainInventory[p.inventory.currentItem] = current.getItem()
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = current.getItem()
.getContainerItem(current);
}
}
return true;
// Handle empty containers
} else {
FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
if (available != null) {
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current);
@@ -128,12 +149,13 @@ public class BlockCertusQuartzTank extends BlockTank implements IRegister<BlockT
if (liquid != null) {
tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);
if (!p.capabilities.isCreativeMode) {
if (!entityplayer.capabilities.isCreativeMode) {
if (current.stackSize == 1) {
p.inventory.mainInventory[p.inventory.currentItem] = filled;
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = filled;
} else {
p.inventory.mainInventory[p.inventory.currentItem].stackSize--;
if (!p.inventory.addItemStackToInventory(filled)) p.entityDropItem(filled, 0);
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize--;
if (!entityplayer.inventory.addItemStackToInventory(filled))
entityplayer.entityDropItem(filled, 0);
}
}
return true;
@@ -144,6 +166,41 @@ public class BlockCertusQuartzTank extends BlockTank implements IRegister<BlockT
return false;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock) {
if (!world.isRemote) {
ChannelLoader.sendPacketToAllPlayers(world.getTileEntity(x, y, z).getDescriptionPacket(), world);
}
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
if (stack != null && stack.hasTagCompound()) {
if (FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("tileEntity")) != null) list.add(
FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("tileEntity")).amount
+ "mB");
}
}
@Override
public void registerBlockIcons(IIconRegister iconregister) {
String folder = NameConst.RES_KEY + "certus_quartz_tank/";
this.breakIcon = iconregister.registerIcon(folder + "cube");
this.topIcon = iconregister.registerIcon(folder + "top");
this.bottomIcon = iconregister.registerIcon(folder + "bottom");
this.sideIcon = iconregister.registerIcon(folder + "side");
this.sideMiddleIcon = iconregister.registerIcon(folder + "side_mid");
this.sideTopIcon = iconregister.registerIcon(folder + "side_top");
this.sideBottomIcon = iconregister.registerIcon(folder + "side_bottom");
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public BlockCertusQuartzTank register() {
GameRegistry.registerBlock(this, ItemCertusQuartzTank.class, NameConst.BLOCK_CERTUS_QUARTZ_TANK);
@@ -151,8 +208,4 @@ public class BlockCertusQuartzTank extends BlockTank implements IRegister<BlockT
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -1,8 +1,14 @@
package com.glodblock.github.common.block;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -16,8 +22,12 @@ 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 com.glodblock.github.util.RenderUtil;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockFluidAutoFiller extends FCBaseBlock {
@@ -61,4 +71,17 @@ public class BlockFluidAutoFiller extends FCBaseBlock {
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List<String> toolTip,
final boolean advancedToolTips) {
if (isShiftKeyDown()) {
toolTip.addAll(
RenderUtil.listFormattedStringToWidth(
StatCollector.translateToLocal(NameConst.TT_FLUID_AUTO_FILLER)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -0,0 +1,270 @@
package com.glodblock.github.common.item;
import java.text.NumberFormat;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import com.glodblock.github.common.Config;
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.loader.ItemAndBlockHolder;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import com.google.common.base.Optional;
public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluidCell {
protected CellType component;
protected long totalBytes;
protected int perType;
protected double idleDrain;
protected int maxType = 1;
private final ReadableNumberConverter format = ReadableNumberConverter.INSTANCE;
@SuppressWarnings("Guava")
public FCBaseItemCell(long bytes, int perType, int totalType, double drain) {
super(Optional.of(bytes / 1024 + "k"));
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
this.totalBytes = bytes;
this.perType = perType;
this.idleDrain = drain;
this.maxType = totalType;
this.component = null;
}
@SuppressWarnings("all")
public FCBaseItemCell(final Optional<String> subName) {
super(subName);
}
public ItemStack getHousing() {
return ItemAndBlockHolder.CELL_HOUSING.stack();
}
public ItemStack getComponent() {
return component.stack(1);
}
@Override
public long getBytes(ItemStack cellItem) {
return this.totalBytes;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
return this.perType;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
if (Config.blacklistEssentiaGas && ModAndClassUtil.ThE && requestedAddition != null) {
return ModAndClassUtil.essentiaGas.isInstance(requestedAddition.getFluid());
}
return false;
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ NumberFormat.getInstance().format(cellInventory.getTotalBytes())
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ cellInventory.getTotalFluidTypes()
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.Types.getLocal());
if (GuiScreen.isCtrlKeyDown()) {
if (cellInventory.getStoredFluidTypes() > 0) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(
String.format(
" %s x%s mB",
fluid.getFluidStack().getLocalizedName(),
format.toWideReadableForm(fluid.getStackSize())));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
if (handler.isPreformatted()) {
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());
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
}
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain() {
return this.idleDrain;
}
@Override
public int getTotalTypes(final ItemStack cellItem) {
return this.maxType;
}
@Override
public boolean isEditable(ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public IInventory getConfigInventory(ItemStack is) {
return new CellConfig(is);
}
@Override
public FuzzyMode getFuzzyMode(ItemStack is) {
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
try {
return FuzzyMode.valueOf(fz);
} catch (final Throwable t) {
return FuzzyMode.IGNORE_ALL;
}
}
@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
@SuppressWarnings("unchecked")
protected boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
if (player.isSneaking()) {
if (Platform.isClient()) {
return false;
}
final InventoryPlayer playerInventory = player.inventory;
final IMEInventoryHandler<?> inv = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inv != null && playerInventory.getCurrentItem() == stack) {
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
final IItemList<IAEFluidStack> list = inv.getAvailableItems(StorageChannel.FLUIDS.createList());
if (list.isEmpty() && ia != null) {
playerInventory.setInventorySlotContents(playerInventory.currentItem, null);
// drop core
final ItemStack extraB = ia.addItems(this.component.stack(1));
if (extraB != null) {
player.dropPlayerItemWithRandomChoice(extraB, false);
}
// drop upgrades
final IInventory upgradesInventory = this.getUpgradesInventory(stack);
for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++) {
final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex);
final ItemStack leftStack = ia.addItems(upgradeStack);
if (leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule) {
player.dropPlayerItemWithRandomChoice(upgradeStack, false);
}
}
// drop empty storage cell case
final ItemStack extraA = ia.addItems(this.getHousing());
if (extraA != null) {
player.dropPlayerItemWithRandomChoice(this.getHousing(), false);
}
if (player.inventoryContainer != null) {
player.inventoryContainer.detectAndSendChanges();
}
return true;
}
}
}
return false;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -0,0 +1,125 @@
package com.glodblock.github.common.item;
import static com.glodblock.github.loader.recipe.WirelessTerminalRecipe.getInfinityBoosterCard;
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
import appeng.api.AEApi;
import appeng.api.features.ILocatable;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.features.IWirelessTermRegistry;
import appeng.core.localization.PlayerMessages;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.util.Platform;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IItemInventory;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements IItemInventory {
protected GuiType type;
public static String infinityBoosterCard = "infinityBoosterCard";
public ItemBaseWirelessTerminal(GuiType t) {
super();
this.type = t;
}
@Override
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
if (player.isSneaking()) return removeInfinityBoosterCard(player, item);
if (ForgeEventFactory.onItemUseStart(player, item, 1) > 0) {
if (Platform.isClient()) {
return item;
}
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
if (!term.isWirelessTerminal(item)) {
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.get());
return item;
}
final IWirelessTermHandler handler = term.getWirelessTerminalHandler(item);
final String unparsedKey = handler.getEncryptionKey(item);
if (unparsedKey.isEmpty()) {
player.addChatMessage(PlayerMessages.DeviceNotLinked.get());
return item;
}
final long parsedKey = Long.parseLong(unparsedKey);
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
if (securityStation == null) {
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.get());
return item;
}
if (handler.hasPower(player, 0.5, item)) {
InventoryHandler.openGui(
player,
w,
new BlockPos(player.inventory.currentItem, 0, 0),
ForgeDirection.UNKNOWN,
this.guiGuiType(item));
} else {
player.addChatMessage(PlayerMessages.DeviceNotPowered.get());
}
}
return item;
}
private ItemStack removeInfinityBoosterCard(final EntityPlayer player, ItemStack is) {
if (hasInfinityBoosterCard(is)) {
if (!player.inventory.addItemStackToInventory(getInfinityBoosterCard())) {
player.entityDropItem(getInfinityBoosterCard(), 0);
}
is.getTagCompound().setBoolean(infinityBoosterCard, false);
}
return is;
}
@SideOnly(Side.CLIENT)
@Override
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines,
boolean displayMoreInfo) {
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
if (GuiScreen.isCtrlKeyDown()) {
lines.add(NameConst.i18n(NameConst.TT_WIRELESS_INSTALLED));
if (hasInfinityBoosterCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getInfinityBoosterCard().getDisplayName());
}
} else {
lines.add(NameConst.i18n(NameConst.TT_CTRL_FOR_MORE));
}
}
@Override
public boolean canHandle(final ItemStack is) {
return is.getItem() instanceof ItemBaseWirelessTerminal;
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
return null;
}
public GuiType guiGuiType(ItemStack stack) {
return this.type;
}
}
@@ -2,49 +2,27 @@ package com.glodblock.github.common.item;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
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;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
import appeng.api.exceptions.MissingDefinition;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
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.loader.IRegister;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.NameConst;
import com.google.common.base.Optional;
@@ -52,24 +30,21 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBasicFluidStorageCell extends AEBaseItem
public class ItemBasicFluidStorageCell extends FCBaseItemCell
implements IStorageFluidCell, IRegister<ItemBasicFluidStorageCell> {
private final CellType component;
private final int totalBytes;
private final int perType;
private final double idleDrain;
private final ReadableNumberConverter format = ReadableNumberConverter.INSTANCE;
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
private final int housingValue;
@SuppressWarnings("Guava")
public ItemBasicFluidStorageCell(final CellType whichCell, final int kilobytes) {
public ItemBasicFluidStorageCell(final CellType whichCell, final int housingValue, final long kilobytes) {
super(Optional.of(kilobytes + "k"));
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE + kilobytes);
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
this.totalBytes = kilobytes * 1024;
this.component = whichCell;
this.housingValue = housingValue;
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE + kilobytes);
switch (this.component) {
case Cell1kPart:
@@ -110,8 +85,9 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
}
}
public ItemStack getComponent() {
return component.stack(1);
@Override
public ItemStack getHousing() {
return ItemAndBlockHolder.CELL_HOUSING.stack(1, this.housingValue);
}
@Override
@@ -126,7 +102,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
icon.put(
this.totalBytes / 1024,
(int) (this.totalBytes / 1024),
iconRegister
.registerIcon(NameConst.RES_KEY + NameConst.ITEM_FLUID_STORAGE + "." + this.totalBytes / 1024));
}
@@ -134,204 +110,16 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
int id = this.totalBytes / 1024;
int id = (int) (this.totalBytes / 1024);
return icon.get(id);
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getUsedBytes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ cellInventory.getTotalBytes()
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.BytesUsed.getLocal());
lines.add(
EnumChatFormatting.WHITE + String.valueOf(cellInventory.getStoredFluidTypes())
+ EnumChatFormatting.GRAY
+ " "
+ GuiText.Of.getLocal()
+ " "
+ EnumChatFormatting.DARK_GREEN
+ cellInventory.getTotalFluidTypes()
+ " "
+ EnumChatFormatting.GRAY
+ GuiText.Types.getLocal());
if (GuiScreen.isCtrlKeyDown()) {
if (cellInventory.getStoredFluidTypes() > 0) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(
String.format(
" %s x%s mB",
fluid.getFluidStack().getLocalizedName(),
format.toWideReadableForm(fluid.getStackSize())));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
if (handler.isPreformatted()) {
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());
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
}
}
@Override
public int getBytes(final ItemStack cellItem) {
return this.totalBytes;
}
@Override
public int getBytesPerType(final ItemStack cellItem) {
return this.perType;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
if (Config.blacklistEssentiaGas && ModAndClassUtil.ThE && requestedAddition != null) {
return ModAndClassUtil.essentiaGas.isInstance(requestedAddition.getFluid());
}
return false;
}
@Override
public int getTotalTypes(final ItemStack cellItem) {
return 1;
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(final ItemStack i) {
return true;
}
@Override
public double getIdleDrain() {
return this.idleDrain;
}
@Override
public boolean isEditable(final ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(final ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public IInventory getConfigInventory(final ItemStack is) {
return new CellConfig(is);
}
@Override
public FuzzyMode getFuzzyMode(final ItemStack is) {
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
try {
return FuzzyMode.valueOf(fz);
} catch (final Throwable t) {
return FuzzyMode.IGNORE_ALL;
}
}
@Override
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
this.disassembleDrive(stack, world, player);
return stack;
}
@SuppressWarnings("unchecked")
private boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
if (player.isSneaking()) {
if (Platform.isClient()) {
return false;
}
final InventoryPlayer playerInventory = player.inventory;
final IMEInventoryHandler<?> inv = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inv != null && playerInventory.getCurrentItem() == stack) {
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
final IItemList<IAEFluidStack> list = inv.getAvailableItems(StorageChannel.FLUIDS.createList());
if (list.isEmpty() && ia != null) {
playerInventory.setInventorySlotContents(playerInventory.currentItem, null);
// drop core
final ItemStack extraB = ia.addItems(this.component.stack(1));
if (extraB != null) {
player.dropPlayerItemWithRandomChoice(extraB, false);
}
// drop upgrades
final IInventory upgradesInventory = this.getUpgradesInventory(stack);
for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++) {
final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex);
final ItemStack leftStack = ia.addItems(upgradeStack);
if (leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule) {
player.dropPlayerItemWithRandomChoice(upgradeStack, false);
}
}
// drop empty storage cell case
for (final ItemStack storageCellStack : AEApi.instance().definitions().materials()
.emptyStorageCell().maybeStack(1).asSet()) {
final ItemStack extraA = ia.addItems(storageCellStack);
if (extraA != null) {
player.dropPlayerItemWithRandomChoice(extraA, false);
}
}
if (player.inventoryContainer != null) {
player.inventoryContainer.detectAndSendChanges();
}
return true;
}
}
}
return false;
}
@Override
public boolean onItemUseFirst(final ItemStack stack, final EntityPlayer player, final World world, final int x,
final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ) {
@@ -341,9 +129,8 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
@Override
public ItemStack getContainerItem(final ItemStack itemStack) {
for (final ItemStack stack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack(1)
.asSet()) {
return stack;
if (this.getHousing() != null) {
return this.getHousing();
}
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
}
@@ -360,12 +147,4 @@ public class ItemBasicFluidStorageCell extends AEBaseItem
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -34,7 +34,7 @@ public class ItemBasicFluidStoragePart extends FCBaseItem {
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < types; ++i) {
list.add(new ItemStack(item, 1, i));
@@ -1,54 +1,42 @@
package com.glodblock.github.common.item;
import static com.glodblock.github.common.tile.TileCertusQuartzTank.CAPACITY;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import com.glodblock.github.common.tile.TileCertusQuartzTank;
import com.glodblock.github.crossmod.waila.Tooltip;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemCertusQuartzTank extends BaseItemBlockContainer implements IFluidContainerItem {
public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerItem {
private final String tagKey = "tank";
private final int capacity = CAPACITY;
private final int capacity = 32000;
public ItemCertusQuartzTank(Block block) {
super(block);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
if (stack != null && stack.hasTagCompound()) {
if (FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag(tagKey)) != null) {
FluidStack fs = FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag(tagKey));
list.add(Tooltip.fluidFormat(fs.getFluid().getLocalizedName(fs), fs.amount));
}
public String getItemStackDisplayName(ItemStack stack) {
FluidStack fluid = getFluid(stack);
if (fluid == null) {
return StatCollector.translateToLocal("tile.certus_quartz_tank_empty.name");
}
return StatCollector.translateToLocalFormatted("tile.certus_quartz_tank.name", fluid.getLocalizedName());
}
@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey(tagKey)
|| container.stackTagCompound.getCompoundTag(tagKey).hasKey("Empty")) {
if (container.stackSize != 1 || container.stackTagCompound == null
|| !container.stackTagCompound.hasKey("tileEntity")
|| container.stackTagCompound.getCompoundTag("tileEntity").hasKey("Empty")) {
return null;
}
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag(tagKey));
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("tileEntity"));
if (stack == null) {
return null;
}
@@ -57,7 +45,7 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
stack.amount = Math.min(stack.amount, maxDrain);
if (doDrain) {
if (currentAmount == stack.amount) {
container.stackTagCompound.removeTag(tagKey);
container.stackTagCompound.removeTag("tileEntity");
if (container.stackTagCompound.hasNoTags()) {
container.stackTagCompound = null;
@@ -65,25 +53,26 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
return stack;
}
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag(tagKey);
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("tileEntity");
fluidTag.setInteger("Amount", currentAmount - stack.amount);
container.stackTagCompound.setTag(tagKey, fluidTag);
container.stackTagCompound.setTag("tileEntity", fluidTag);
}
return stack;
}
@Override
public int fill(ItemStack container, FluidStack resource, boolean doFill) {
if (resource == null) {
if (resource == null || container.stackSize != 1) {
return 0;
}
if (!doFill) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey(tagKey)) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("tileEntity")) {
return Math.min(this.capacity, resource.amount);
}
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag(tagKey));
FluidStack stack = FluidStack
.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("tileEntity"));
if (stack == null) {
return Math.min(this.capacity, resource.amount);
@@ -100,21 +89,21 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
container.stackTagCompound = new NBTTagCompound();
}
if (!container.stackTagCompound.hasKey(tagKey)
|| container.stackTagCompound.getCompoundTag(tagKey).hasKey("Empty")) {
if (!container.stackTagCompound.hasKey("tileEntity")
|| container.stackTagCompound.getCompoundTag("tileEntity").hasKey("Empty")) {
NBTTagCompound fluidTag = resource.writeToNBT(new NBTTagCompound());
if (this.capacity < resource.amount) {
fluidTag.setInteger("Amount", this.capacity);
container.stackTagCompound.setTag(tagKey, fluidTag);
container.stackTagCompound.setTag("tileEntity", fluidTag);
return this.capacity;
}
container.stackTagCompound.setTag(tagKey, fluidTag);
container.stackTagCompound.setTag("tileEntity", fluidTag);
return resource.amount;
}
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag(tagKey);
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("tileEntity");
FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidTag);
if (!stack.isFluidEqual(resource)) {
@@ -129,7 +118,7 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
stack.amount = this.capacity;
}
container.stackTagCompound.setTag(tagKey, stack.writeToNBT(fluidTag));
container.stackTagCompound.setTag("tileEntity", stack.writeToNBT(fluidTag));
return filled;
}
@@ -140,10 +129,10 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
@Override
public FluidStack getFluid(ItemStack container) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey(tagKey)) {
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("tileEntity")) {
return null;
}
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag(tagKey));
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("tileEntity"));
}
@Override
@@ -159,7 +148,8 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
}
if (stack != null && stack.hasTagCompound()) {
((TileCertusQuartzTank) world.getTileEntity(x, y, z)).readFromNBTWithoutCoords(stack.getTagCompound());
((TileCertusQuartzTank) world.getTileEntity(x, y, z))
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
}
return true;
}
@@ -0,0 +1,146 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.features.AEFeature;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
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.loader.IRegister;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemCreativeFluidStorageCell extends AEBaseItem
implements IStorageFluidCell, IRegister<ItemCreativeFluidStorageCell> {
public ItemCreativeFluidStorageCell() {
super();
setUnlocalizedName(NameConst.ITEM_CREATIVE_FLUID_STORAGE);
setTextureName(FluidCraft.resource(NameConst.ITEM_CREATIVE_FLUID_STORAGE).toString());
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
}
@Override
public long getBytes(ItemStack cellItem) {
return 0;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
return 0;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
if (Config.blacklistEssentiaGas && ModAndClassUtil.ThE && requestedAddition != null) {
return ModAndClassUtil.essentiaGas.isInstance(requestedAddition.getFluid());
}
return false;
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain() {
return 0;
}
@Override
public int getTotalTypes(ItemStack cellItem) {
return 0;
}
@Override
public boolean isEditable(ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public IInventory getConfigInventory(ItemStack is) {
return new CellConfig(is);
}
@Override
public FuzzyMode getFuzzyMode(ItemStack is) {
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
try {
return FuzzyMode.valueOf(fz);
} catch (final Throwable t) {
return FuzzyMode.IGNORE_ALL;
}
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
final IFluidCellInventory cellInventory = handler.getCellInv();
if (GuiScreen.isCtrlKeyDown()) {
if (cellInventory.getContents().size() > 0) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(String.format(" %s", fluid.getFluidStack().getLocalizedName()));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
}
}
@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
@Override
public ItemCreativeFluidStorageCell register() {
GameRegistry.registerItem(this, NameConst.ITEM_CREATIVE_FLUID_STORAGE, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -0,0 +1,55 @@
package com.glodblock.github.common.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemFluidExtremeStorageCell extends FCBaseItemCell
implements IStorageFluidCell, IRegister<ItemFluidExtremeStorageCell> {
private final String name;
public ItemFluidExtremeStorageCell(String name, long bytes, int perType, int totalTypes, double drain) {
super(bytes, perType, totalTypes, drain);
setUnlocalizedName(name);
this.name = name;
setTextureName(FluidCraft.resource(name).toString());
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
return stack;
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float hitX, float hitY, float hitZ) {
return false;
}
@Override
public ItemStack getContainerItem(final ItemStack itemStack) {
return null;
}
@Override
public boolean hasContainerItem(final ItemStack stack) {
return false;
}
@Override
public ItemFluidExtremeStorageCell register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, this.name, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -0,0 +1,70 @@
package com.glodblock.github.common.item;
import java.util.HashMap;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
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;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemFluidStorageHousing extends FCBaseItem {
public static final int types = 4;
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
public ItemFluidStorageHousing() {
super();
setHasSubtypes(true);
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE_HOUSING);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < types; ++i) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
int meta = stack.getItemDamage();
return StatCollector.translateToLocalFormatted("item.fluid_storage_housing." + meta + ".name");
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
for (int i = 0; i < types; i++) {
icon.put(i, iconRegister.registerIcon(NameConst.RES_KEY + NameConst.ITEM_FLUID_STORAGE_HOUSING + "." + i));
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
return icon.get(meta);
}
@Override
public ItemFluidStorageHousing register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE_HOUSING, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -0,0 +1,151 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import java.util.HashMap;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;
import appeng.api.exceptions.MissingDefinition;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.loader.ItemAndBlockHolder;
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;
public class ItemMultiFluidStorageCell extends FCBaseItemCell
implements IStorageFluidCell, IRegister<ItemMultiFluidStorageCell> {
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
private final int housingValue;
@SuppressWarnings("Guava")
public ItemMultiFluidStorageCell(final CellType whichCell, final int housingValue, final long kilobytes) {
super(Optional.of(kilobytes + "k"));
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
this.totalBytes = kilobytes * 1024;
this.component = whichCell;
this.housingValue = housingValue;
this.maxType = 5;
setUnlocalizedName(NameConst.ITEM_MULTI_FLUID_STORAGE + kilobytes);
switch (this.component) {
case Cell1kPart:
this.idleDrain = 0.5;
this.perType = 8;
break;
case Cell4kPart:
this.idleDrain = 1.0;
this.perType = 32;
break;
case Cell16kPart:
this.idleDrain = 1.5;
this.perType = 128;
break;
case Cell64kPart:
this.idleDrain = 2.0;
this.perType = 512;
break;
case Cell256kPart:
this.idleDrain = 2.5;
this.perType = 2048;
break;
case Cell1024kPart:
this.idleDrain = 3.0;
this.perType = 8192;
break;
case Cell4096kPart:
this.idleDrain = 3.5;
this.perType = 32768;
break;
case Cell16384kPart:
this.idleDrain = 4.0;
this.perType = 131072;
break;
default:
this.idleDrain = 0.0;
this.perType = 8;
}
}
@Override
public ItemStack getHousing() {
return ItemAndBlockHolder.CELL_HOUSING.stack(1, this.housingValue);
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return StatCollector.translateToLocalFormatted(
"item.multi_fluid_storage." + this.totalBytes / 1024 + ".name",
CellType.getTypeColor(this.component),
EnumChatFormatting.RESET);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
icon.put(
(int) (this.totalBytes / 1024),
iconRegister.registerIcon(
NameConst.RES_KEY + NameConst.ITEM_MULTI_FLUID_STORAGE + "." + this.totalBytes / 1024));
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {
int id = (int) (this.totalBytes / 1024);
return icon.get(id);
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
this.disassembleDrive(stack, world, player);
return stack;
}
@Override
public boolean onItemUseFirst(final ItemStack stack, final EntityPlayer player, final World world, final int x,
final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ) {
if (ForgeEventFactory.onItemUseStart(player, stack, 1) <= 0) return true;
return this.disassembleDrive(stack, world, player);
}
@Override
public boolean hasContainerItem(final ItemStack stack) {
return AEConfig.instance.isFeatureEnabled(AEFeature.EnableDisassemblyCrafting);
}
@Override
public ItemStack getContainerItem(final ItemStack itemStack) {
if (this.getHousing() != null) {
return this.getHousing();
}
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
}
@Override
public ItemMultiFluidStorageCell register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, NameConst.ITEM_MULTI_FLUID_STORAGE + this.totalBytes / 1024, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -117,7 +117,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
}
@Override
public int getBytes(final ItemStack cellItem) {
public long getBytes(final ItemStack cellItem) {
return 256;
}
@@ -192,7 +192,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
}
@Override
public Object getInventory(ItemStack stack, World world, int x, int y, int z) {
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
return new PortableFluidCellInventory(stack, x);
}
@@ -0,0 +1,52 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemWirelessFluidTerminal extends ItemBaseWirelessTerminal
implements IRegister<ItemWirelessFluidTerminal> {
public ItemWirelessFluidTerminal() {
super(GuiType.WIRELESS_FLUID_TERMINAL);
AEApi.instance().registries().wireless().registerWirelessHandler(this);
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
setUnlocalizedName(NameConst.ITEM_WIRELESS_FLUID_TERMINAL);
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_FLUID_TERMINAL).toString());
}
@Override
public ItemWirelessFluidTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_FLUID_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
}
@@ -0,0 +1,51 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemWirelessInterfaceTerminal extends ItemBaseWirelessTerminal
implements IRegister<ItemWirelessInterfaceTerminal> {
public ItemWirelessInterfaceTerminal() {
super(GuiType.WIRELESS_INTERFACE_TERMINAL);
AEApi.instance().registries().wireless().registerWirelessHandler(this);
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
setUnlocalizedName(NameConst.ITEM_WIRELESS_INTERFACE_TERMINAL);
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_INTERFACE_TERMINAL).toString());
}
@Override
public ItemWirelessInterfaceTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_INTERFACE_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
}
@@ -0,0 +1,51 @@
package com.glodblock.github.common.item;
import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemWirelessPatternTerminal extends ItemBaseWirelessTerminal
implements IRegister<ItemWirelessPatternTerminal> {
public ItemWirelessPatternTerminal() {
super(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
AEApi.instance().registries().wireless().registerWirelessHandler(this);
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
setUnlocalizedName(NameConst.ITEM_WIRELESS_FLUID_PATTERN_TERMINAL);
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_FLUID_PATTERN_TERMINAL).toString());
}
@Override
public ItemWirelessPatternTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_FLUID_PATTERN_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
}
@@ -0,0 +1,230 @@
package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
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 net.minecraftforge.common.util.ForgeDirection;
import org.apache.commons.lang3.tuple.ImmutablePair;
import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
import baubles.api.BaubleType;
import baubles.api.IBauble;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.*;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
implements IBauble, IRegister<ItemWirelessUltraTerminal> {
public final static String MODE = "mode_main";
private final static List<GuiType> guis = new ArrayList<>();
public ItemWirelessUltraTerminal() {
super(null);
AEApi.instance().registries().wireless().registerWirelessHandler(this);
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
setUnlocalizedName(NameConst.ITEM_WIRELESS_ULTRA_TERMINAL);
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_ULTRA_TERMINAL).toString());
guis.add(GuiType.WIRELESS_CRAFTING_TERMINAL);
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
guis.add(GuiType.WIRELESS_FLUID_TERMINAL);
guis.add(GuiType.WIRELESS_INTERFACE_TERMINAL);
if (ModAndClassUtil.ThE) {
guis.add(GuiType.WIRELESS_ESSENTIA_TERMINAL);
}
}
@Override
public ItemWirelessUltraTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_ULTRA_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@SideOnly(Side.CLIENT)
@Override
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines,
boolean displayMoreInfo) {
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
if (isShiftKeyDown()) {
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL));
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL + "." + guiGuiType(stack)));
} else {
lines.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return StatCollector.translateToLocalFormatted("item.wireless_ultra_terminal." + guiGuiType(stack) + ".name");
}
@Override
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
try {
IGridNode gridNode = Util.getWirelessGrid(stack);
final GuiType gui;
if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z > 0) {
gui = getGuis().get(Util.GuiHelper.decodeType(y).getRight());
} else {
gui = readMode(stack);
}
if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL) {
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_CRAFTING_TERMINAL) {
return new WirelessCraftingTerminalInventory(stack, x, gridNode, player);
} else if (ModAndClassUtil.ThE && gui == GuiType.WIRELESS_ESSENTIA_TERMINAL) {
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_FLUID_TERMINAL) {
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_INTERFACE_TERMINAL) {
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
} else if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX) {
return new WirelessPatternTerminalExInventory(stack, x, gridNode, player);
} else {
this.setMode(GuiType.WIRELESS_FLUID_TERMINAL, stack); // set as default mode
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
}
} catch (Exception e) {
player.addChatMessage(PlayerMessages.OutOfRange.get());
}
return null;
}
@Override
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
if (player.isSneaking()) {
setNext(readMode(item), item);
return item;
}
readMode(item);
return super.onItemRightClick(item, w, player);
}
public static GuiType readMode(ItemStack stack) {
NBTTagCompound data = Platform.openNbtData(stack);
if (data.hasKey(MODE)) {
String GUI = data.getString(MODE);
try {
return GuiType.valueOf(GUI);
} catch (IllegalArgumentException e) {
return GuiType.WIRELESS_CRAFTING_TERMINAL;
}
} else {
return GuiType.WIRELESS_CRAFTING_TERMINAL;
}
}
public void setNext(GuiType type, ItemStack stack) {
boolean f = false;
for (GuiType g : guis) {
if (f) {
setMode(g.toString(), stack);
return;
}
if (g == type) {
f = true;
}
}
setMode(guis.get(0).toString(), stack);
}
public void setMode(String mode, ItemStack stack) {
NBTTagCompound data = Platform.openNbtData(stack);
data.setString(MODE, mode);
}
public void setMode(GuiType mode, ItemStack stack) {
this.setMode(mode.toString(), stack);
}
public static void switchTerminal(EntityPlayer player, GuiType guiType) {
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
if (term == null) return;
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
((ItemWirelessUltraTerminal) term.getRight().getItem()).setMode(guiType, term.getRight());
}
if (Platform.isClient()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType, true));
} else {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
term.getLeft(),
Util.GuiHelper.encodeType(
guis.indexOf(GuiType.valueOf(guiType.toString())),
Util.GuiHelper.GuiType.ITEM),
1),
ForgeDirection.UNKNOWN,
guiType);
}
}
public static List<GuiType> getGuis() {
return guis;
}
@Override
public GuiType guiGuiType(ItemStack stack) {
return readMode(stack);
}
@Override
public BaubleType getBaubleType(ItemStack itemStack) {
return BaubleType.RING;
}
@Override
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
}
@Override
public void onEquipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
}
@Override
public void onUnequipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
}
@Override
public boolean canEquip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
return true;
}
@Override
public boolean canUnequip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
return true;
}
}
@@ -88,6 +88,9 @@ public class PartFluidPatternTerminal extends FCFluidEncodeTerminal {
}
}
}
if (inv == this.crafting) {
this.fixCraftingRecipes();
}
this.getHost().markForSave();
}
@@ -259,7 +259,9 @@ public class PartFluidStorageBus extends PartUpgradeable
@Override
public void onNeighborChanged() {
BlockPos neighbor = new BlockPos(this.getTile()).getOffSet(this.getSide());
TileEntity tile = this.getTile();
if (tile == null || this.getProxy() == null || !this.getProxy().isActive()) return;
BlockPos neighbor = new BlockPos(tile).getOffSet(this.getSide());
final TileEntity te = neighbor.getTileEntity();
// In case the TE was destroyed, we have to do a full reset immediately.
if (te instanceof TileCableBus) {
@@ -288,6 +290,7 @@ public class PartFluidStorageBus extends PartUpgradeable
} else {
this.resetCache(false);
}
}
@Override
@@ -11,8 +11,9 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.tile.inventory.AppEngInternalInventory;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.item.IItemPatternTerminal;
public abstract class FCFluidEncodeTerminal extends FCPart {
public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatternTerminal {
protected AppEngInternalInventory crafting;
protected AppEngInternalInventory output;
@@ -24,6 +25,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart {
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
public FCFluidEncodeTerminal(ItemStack is) {
@@ -50,6 +52,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart {
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
this.pattern.readFromNBT(data, "pattern");
this.output.readFromNBT(data, "outputList");
this.crafting.readFromNBT(data, "craftingGrid");
@@ -65,67 +68,83 @@ public abstract class FCFluidEncodeTerminal extends FCPart {
data.setBoolean("substitute", this.substitute);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
this.pattern.writeToNBT(data, "pattern");
this.output.writeToNBT(data, "outputList");
this.crafting.writeToNBT(data, "craftingGrid");
}
@Override
public boolean shouldCombine() {
return this.combine;
}
@Override
public void setCombineMode(boolean shouldCombine) {
this.combine = shouldCombine;
}
@Override
public boolean isSubstitution() {
return this.substitute;
}
@Override
public boolean isPrioritize() {
return this.prioritize;
}
@Override
public void setBeSubstitute(boolean canBeSubstitute) {
this.beSubstitute = canBeSubstitute;
}
@Override
public boolean canBeSubstitute() {
return this.beSubstitute;
}
@Override
public void setSubstitution(boolean canSubstitute) {
this.substitute = canSubstitute;
}
@Override
public void setPrioritization(boolean canPrioritize) {
this.prioritize = canPrioritize;
}
@Override
public boolean isInverted() {
return inverted;
}
@Override
public void setInverted(boolean inverted) {
this.inverted = inverted;
}
@Override
public int getActivePage() {
return this.activePage;
}
@Override
public void setActivePage(int activePage) {
this.activePage = activePage;
}
@Override
public void setCraftingRecipe(final boolean craftingMode) {
this.craftingMode = craftingMode;
}
@Override
public boolean isCraftingRecipe() {
return this.craftingMode;
}
@Override
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
IInventory crafting = this.getInventoryByName("crafting");
IInventory output = this.getInventoryByName("output");
@@ -158,6 +177,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart {
return super.getInventoryByName(name);
}
@Override
public void sortCraftingItems() {
List<ItemStack> items = new ArrayList<ItemStack>();
List<ItemStack> fluids = new ArrayList<ItemStack>();
@@ -187,4 +207,14 @@ public abstract class FCFluidEncodeTerminal extends FCPart {
}
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
}
@@ -111,14 +111,16 @@ public abstract class FCPartMonitor extends AbstractPartDisplay implements IPart
boolean needRedraw = super.readFromStream(data);
final boolean isLocked = data.readBoolean();
needRedraw = this.isLocked != isLocked;
needRedraw |= this.isLocked != isLocked;
this.isLocked = isLocked;
final boolean val = data.readBoolean();
if (val) {
needRedraw |= this.configuredFluid == null;
this.configuredFluid = AEFluidStack.loadFluidStackFromPacket(data);
} else {
needRedraw |= this.configuredFluid != null;
this.configuredFluid = null;
}
@@ -0,0 +1,70 @@
package com.glodblock.github.common.storage;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.exceptions.AppEngException;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.data.IAEFluidStack;
import com.glodblock.github.util.Util;
public class CreativeFluidCellInventory extends FluidCellInventory {
public CreativeFluidCellInventory(ItemStack o, ISaveProvider container) throws AppEngException {
super(o, container);
}
@Override
public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActionSource src) {
if (input == null || input.getStackSize() == 0) {
return null;
}
if (this.cellType.isBlackListed(this.cellItem, input)) {
return input;
}
if (this.getCellFluids().findPrecise(input) != null) {
return null;
} else {
return input;
}
}
@Override
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) {
if (request == null) {
return null;
}
if (this.getCellFluids().findPrecise(request) != null) {
return request.copy();
} else {
return null;
}
}
@Override
protected void loadCellFluids() {
if (this.cellFluids == null) {
this.cellFluids = AEApi.instance().storage().createFluidList();
}
this.cellFluids.resetStatus(); // clears totals and stuff.
IInventory inv = this.cellType.getConfigInventory(this.cellItem);
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack is = inv.getStackInSlot(i);
if (Util.FluidUtil.isFluidContainer(is)) {
FluidStack fs = Util.getFluidFromItem(is);
if (fs == null) continue;
IAEFluidStack iaeFluidStack = Util.FluidUtil.createAEFluidStack(fs);
if (this.cellFluids.findPrecise(iaeFluidStack) == null) {
iaeFluidStack.setStackSize(Integer.MAX_VALUE);
this.cellFluids.add(iaeFluidStack);
}
}
}
}
}
@@ -22,21 +22,23 @@ import appeng.api.storage.data.IItemList;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
public class FluidCellInventory implements IFluidCellInventory {
private static final String FLUID_TYPE_TAG = "ft";
private static final String FLUID_COUNT_TAG = "fc";
private static final String FLUID_SLOT = "#";
private static final String FLUID_SLOT_COUNT = "@";
private IStorageFluidCell cellType;
protected IStorageFluidCell cellType;
private static String[] fluidSlots;
private static String[] fluidSlotCount;
private final ItemStack cellItem;
protected final ItemStack cellItem;
private final ISaveProvider container;
private final int MAX_TYPE = 63;
private long storedFluidCount;
private short storedFluids;
private IItemList<IAEFluidStack> cellFluids;
protected IItemList<IAEFluidStack> cellFluids;
private final NBTTagCompound tagCompound;
public static final int singleByteAmount = 256 * 8;
@@ -76,7 +78,11 @@ public class FluidCellInventory implements IFluidCellInventory {
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
try {
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
if (o.getItem() instanceof ItemCreativeFluidStorageCell) {
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
} else {
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
}
} catch (final AppEngException e) {
return null;
}
@@ -185,7 +191,7 @@ public class FluidCellInventory implements IFluidCellInventory {
return 3;
}
private void loadCellFluids() {
protected void loadCellFluids() {
if (this.cellFluids == null) {
this.cellFluids = AEApi.instance().storage().createFluidList();
}
@@ -203,7 +209,7 @@ public class FluidCellInventory implements IFluidCellInventory {
}
}
private IItemList<IAEFluidStack> getCellFluids() {
protected IItemList<IAEFluidStack> getCellFluids() {
if (this.cellFluids == null) {
this.loadCellFluids();
}
@@ -7,7 +7,7 @@ import appeng.api.storage.data.IAEFluidStack;
public interface IStorageFluidCell extends ICellWorkbenchItem {
int getBytes(ItemStack cellItem);
long getBytes(ItemStack cellItem);
int getBytesPerType(ItemStack cellItem);
@@ -1,36 +1,274 @@
package com.glodblock.github.common.tile;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*;
import buildcraft.factory.TileTank;
import com.glodblock.github.loader.ChannelLoader;
public class TileCertusQuartzTank extends TileTank {
public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
public static final int CAPACITY = FluidContainerRegistry.BUCKET_VOLUME * 32;
private FluidStack lastBeforeUpdate = null;
public FluidTank tank = new FluidTank(32000) {
public TileCertusQuartzTank() {
super();
this.setCapacity();
@Override
public FluidTank readFromNBT(NBTTagCompound nbt) {
if (!nbt.hasKey("Empty")) {
FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt);
setFluid(fluid);
} else {
setFluid(null);
}
return this;
}
};
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return this.tank.getFluid() == null || this.tank.getFluid().getFluid() == fluid;
}
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
readFromNBTWithoutCoords(data);
this.setCapacity();
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return this.tank.getFluid() == null || this.tank.getFluid().getFluid() == fluid;
}
public int getFluidLightLevel() {
FluidStack tankFluid = tank.getFluid();
return tankFluid == null || tankFluid.amount == 0 ? 0 : tankFluid.getFluid().getLuminosity(tankFluid);
}
public void compareAndUpdate() {
if (!this.worldObj.isRemote) {
FluidStack current = this.tank.getFluid();
if (current != null) {
if (this.lastBeforeUpdate != null) {
if (Math.abs(current.amount - this.lastBeforeUpdate.amount) >= 500) {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = current.copy();
} else if (this.lastBeforeUpdate.amount < this.tank.getCapacity()
&& current.amount == this.tank.getCapacity()
|| this.lastBeforeUpdate.amount == this.tank.getCapacity()
&& current.amount < this.tank.getCapacity()) {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = current.copy();
}
} else {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = current.copy();
}
} else if (this.lastBeforeUpdate != null) {
ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj);
this.lastBeforeUpdate = null;
}
}
}
public FluidStack drain(FluidStack fluid, boolean doDrain, boolean findMainTank) {
if (findMainTank) {
int yOff = 0;
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
TileCertusQuartzTank mainTank = this;
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
Fluid offFluid = ((TileCertusQuartzTank) offTE).getFluid();
if (offFluid != null && offFluid == fluid.getFluid()) {
mainTank = (TileCertusQuartzTank) this.worldObj
.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
yOff++;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
continue;
}
}
break;
}
return mainTank != null ? mainTank.drain(fluid, doDrain, false) : null;
}
FluidStack drained = this.tank.drain(fluid.amount, doDrain);
compareAndUpdate();
if (drained == null || drained.amount < fluid.amount) {
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
if (offTE instanceof TileCertusQuartzTank) {
TileCertusQuartzTank tank = (TileCertusQuartzTank) offTE;
FluidStack externallyDrained = tank.drain(
new FluidStack(fluid.getFluid(), fluid.amount - (drained != null ? drained.amount : 0)),
doDrain,
false);
if (externallyDrained != null) return new FluidStack(
fluid.getFluid(),
(drained != null ? drained.amount : 0) + externallyDrained.amount);
else return drained;
}
}
return drained;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
if (this.tank.getFluid() == null || resource == null || resource.getFluid() != this.tank.getFluid().getFluid())
return null;
return drain(resource, doDrain, true);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
if (this.tank.getFluid() == null) return null;
return drain(from, new FluidStack(this.tank.getFluid(), maxDrain), doDrain);
}
public int fill(FluidStack fluid, boolean doFill, boolean findMainTank) {
if (findMainTank) {
int yOff = 0;
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
TileCertusQuartzTank mainTank = this;
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
Fluid offFluid = ((TileCertusQuartzTank) offTE).getFluid();
if (offFluid == null || offFluid == fluid.getFluid()) {
mainTank = (TileCertusQuartzTank) this.worldObj
.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
yOff++;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
continue;
}
}
break;
}
return mainTank != null ? mainTank.fill(fluid, doFill, false) : 0;
}
int filled = this.tank.fill(fluid, doFill);
compareAndUpdate();
if (filled < fluid.amount) {
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);
if (offTE instanceof TileCertusQuartzTank) {
TileCertusQuartzTank tank = (TileCertusQuartzTank) offTE;
return filled + tank.fill(new FluidStack(fluid.getFluid(), fluid.amount - filled), doFill, false);
}
}
return filled;
}
/* IFluidHandler */
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
if (resource == null || this.tank.getFluid() != null && resource.getFluid() != this.tank.getFluid().getFluid())
return 0;
return fill(resource, doFill, true);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbtTag = new NBTTagCompound();
writeToNBT(nbtTag);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
}
public Fluid getFluid() {
FluidStack tankFluid = this.tank.getFluid();
return tankFluid != null && tankFluid.amount > 0 ? tankFluid.getFluid() : null;
}
public Fluid getRenderFluid() {
return this.tank.getFluid() != null ? this.tank.getFluid().getFluid() : null;
}
public float getRenderScale() {
return (float) this.tank.getFluidAmount() / this.tank.getCapacity();
}
public FluidTankInfo[] getTankInfo(boolean goToMainTank) {
if (!goToMainTank) return new FluidTankInfo[] { this.tank.getInfo() };
int amount = 0, capacity = 0;
Fluid fluid = null;
int yOff = 0;
TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
TileCertusQuartzTank mainTank;
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
if (((TileCertusQuartzTank) offTE).getFluid() == null
|| ((TileCertusQuartzTank) offTE).getFluid() == getFluid()) {
yOff++;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord);
continue;
}
}
break;
}
yOff = 0;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
while (true) {
if (offTE instanceof TileCertusQuartzTank) {
mainTank = (TileCertusQuartzTank) offTE;
if (mainTank.getFluid() == null || mainTank.getFluid() == getFluid()) {
FluidTankInfo info = mainTank.getTankInfo(false)[0];
if (info != null) {
capacity += info.capacity;
if (info.fluid != null) {
amount += info.fluid.amount;
if (info.fluid.getFluid() != null) fluid = info.fluid.getFluid();
}
}
yOff++;
offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord);
continue;
}
}
break;
}
return new FluidTankInfo[] {
new FluidTankInfo(fluid != null ? new FluidStack(fluid, amount) : null, capacity) };
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return getTankInfo(true);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
this.worldObj.markBlockRangeForRenderUpdate(
this.xCoord,
this.yCoord,
this.zCoord,
this.xCoord,
this.yCoord,
this.zCoord);
readFromNBT(packet.func_148857_g());
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
readFromNBTWithoutCoords(tag);
}
public void readFromNBTWithoutCoords(NBTTagCompound tag) {
this.tank.readFromNBT(tag);
}
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
writeToNBTWithoutCoords(data);
}
public void setCapacity() {
this.tank.setCapacity(CAPACITY);
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
writeToNBTWithoutCoords(tag);
}
public void writeToNBTWithoutCoords(NBTTagCompound tag) {
@@ -60,7 +60,6 @@ public class TileFluidAutoFiller extends AENetworkInvTile
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
private final BaseActionSource source = new MachineSource(this);
private IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
public ItemStack containerItem;
private final Item encodedPattern = AEApi.instance().definitions().items().encodedPattern().maybeItem().orNull();
private IAEItemStack returnStack;
private boolean isPowered;
@@ -74,7 +73,14 @@ public class TileFluidAutoFiller extends AENetworkInvTile
getProxy().setIdlePowerUsage(1D);
getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
inventory.setInventorySlotContents(0, BUCKET);
this.containerItem = getInventory().getStackInSlot(0);
}
public ItemStack getContainerItem() {
return getInventory().getStackInSlot(0);
}
public void setContainerItem(ItemStack is) {
getInventory().setInventorySlotContents(0, is);
}
@Override
@@ -92,14 +98,17 @@ public class TileFluidAutoFiller extends AENetworkInvTile
public void updatePattern() {
ItemStack is = inventory.getStackInSlot(0);
if (is == null || this.containerItem.isItemEqual(is)) return;
this.containerItem = is;
if (is == null) return;
this.setContainerItem(is);
postEvent();
}
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBTEvent(NBTTagCompound data) {
inventory.readFromNBT(data, "Inv");
if (inventory.getStackInSlot(0) == null) {
inventory.setInventorySlotContents(0, BUCKET);
}
}
@TileEvent(TileEventType.WORLD_NBT_WRITE)
@@ -141,12 +150,12 @@ public class TileFluidAutoFiller extends AENetworkInvTile
for (IAEFluidStack fluidStack : fluidStorage) {
Fluid fluid = fluidStack.getFluid();
if (fluid == null) continue;
int maxCapacity = Util.FluidUtil.getCapacity(this.containerItem, fluid);
int maxCapacity = Util.FluidUtil.getCapacity(this.getContainerItem(), fluid);
if (maxCapacity == 0) continue;
MutablePair<Integer, ItemStack> filled = Util.FluidUtil
.fillStack(this.containerItem.copy(), new FluidStack(fluid, maxCapacity));
.fillStack(this.getContainerItem().copy(), new FluidStack(fluid, maxCapacity));
if (filled.right == null) continue;
ItemStack pattern = getPattern(this.containerItem, filled.right);
ItemStack pattern = getPattern(this.getContainerItem(), filled.right);
ICraftingPatternItem patter = (ICraftingPatternItem) pattern.getItem();
craftingTracker.addCraftingOption(this, patter.getPatternForItem(pattern, getWorldObj()));
}
@@ -204,8 +213,7 @@ public class TileFluidAutoFiller extends AENetworkInvTile
BaseActionSource source) {
if (this.getProxy().isActive() && this.getStorageGrid() != null) {
boolean hasChanged = false;
IItemList<IAEFluidStack> stored = this.getStorageGrid().getFluidInventory()
.getAvailableItems(AEApi.instance().storage().createFluidList());
IItemList<IAEFluidStack> stored = this.getStorageGrid().getFluidInventory().getStorageList();
for (IAEFluidStack tmp : change) {
if (stored.findPrecise(tmp) == null || this.fluids.findPrecise(tmp) == null) {
hasChanged = true;
@@ -37,6 +37,12 @@ public class FCClassTransformer implements IClassTransformer {
case "appeng.core.features.registries.ExternalStorageRegistry":
tform = ExternalStorageRegistryTransformer.INSTANCE;
break;
case "appeng.core.sync.packets.PacketCompressedNBT":
tform = PacketCompressedNBTTransformer.INSTANCE;
break;
case "appeng.client.gui.implementations.GuiRenamer":
tform = GuiRenamerTransformer.INSTANCE;
break;
default:
return code;
}
@@ -0,0 +1,37 @@
package com.glodblock.github.coremod.hooker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
import com.glodblock.github.common.item.ItemWirelessInterfaceTerminal;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketSwitchGuis;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class CoreModHooksClient {
public static void clientPacketData(NBTTagCompound data) {
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiInterfaceTerminalWireless) {
((GuiInterfaceTerminalWireless) gs).postUpdate(data);
}
}
public static void reopenInterfaceTerminal() {
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
ItemStack c = p.getCurrentEquippedItem();
if (c.getItem() instanceof ItemWirelessInterfaceTerminal || c.getItem() instanceof ItemWirelessUltraTerminal) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.WIRELESS_INTERFACE_TERMINAL, true));
}
}
}
@@ -0,0 +1,59 @@
package com.glodblock.github.coremod.transform;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import com.glodblock.github.coremod.FCClassTransformer;
public class GuiRenamerTransformer extends FCClassTransformer.ClassMapper {
public static final GuiRenamerTransformer INSTANCE = new GuiRenamerTransformer();
private GuiRenamerTransformer() {
// NO-OP
}
@Override
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
return new GuiRenamerTransformer.TransformGuiRenamer(Opcodes.ASM5, downstream);
}
private static class TransformGuiRenamer extends ClassVisitor {
TransformGuiRenamer(int api, ClassVisitor cv) {
super(api, cv);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals("keyTyped")) {
return new GuiRenamerTransformer.TransformKeyTyped(
api,
super.visitMethod(access, name, desc, signature, exceptions));
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class TransformKeyTyped extends MethodVisitor {
TransformKeyTyped(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
super.visitMethodInsn(opcode, owner, name, desc, itf);
if (owner.equals("net/minecraft/client/entity/EntityClientPlayerMP") && name.equals("closeScreen")) {
super.visitMethodInsn(
Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooksClient",
"reopenInterfaceTerminal",
"()V",
false);
}
}
}
}
@@ -0,0 +1,61 @@
package com.glodblock.github.coremod.transform;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import com.glodblock.github.coremod.FCClassTransformer;
public class PacketCompressedNBTTransformer extends FCClassTransformer.ClassMapper {
public static final PacketCompressedNBTTransformer INSTANCE = new PacketCompressedNBTTransformer();
private PacketCompressedNBTTransformer() {
// NO-OP
}
@Override
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
return new TransformPacketCompressedNBT(Opcodes.ASM5, downstream);
}
private static class TransformPacketCompressedNBT extends ClassVisitor {
TransformPacketCompressedNBT(int api, ClassVisitor cv) {
super(api, cv);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (name.equals("clientPacketData")) {
return new TransformClientPacketData(api, super.visitMethod(access, name, desc, signature, exceptions));
}
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
private static class TransformClientPacketData extends MethodVisitor {
TransformClientPacketData(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitInsn(int opcode) {
super.visitVarInsn(Opcodes.ALOAD, 0);
super.visitFieldInsn(
Opcodes.GETFIELD,
"appeng/core/sync/packets/PacketCompressedNBT",
"in",
"Lnet/minecraft/nbt/NBTTagCompound;");
super.visitMethodInsn(
Opcodes.INVOKESTATIC,
"com/glodblock/github/coremod/hooker/CoreModHooksClient",
"clientPacketData",
"(Lnet/minecraft/nbt/NBTTagCompound;)V",
false);
super.visitInsn(opcode);
}
}
}
@@ -0,0 +1,38 @@
package com.glodblock.github.crossmod.thaumcraft;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.client.lib.UtilsFX;
import com.glodblock.github.util.RenderUtil;
public class AspectRender {
public static final ResourceLocation UNKNOWN_TEXTURE = new ResourceLocation(
"thaumcraft",
"textures/aspects/_unknown.png");
public static void drawAspect(EntityPlayer player, int posX, int posY, float zLevel, Aspect aspect, long amount) {
if (aspect == null || amount <= 0) {
return;
}
if (AspectUtil.isPlayerDiscoveredAspect(player, aspect)) {
UtilsFX.drawTag(posX, posY, aspect, 0, 0, zLevel);
} else {
Minecraft.getMinecraft().renderEngine.bindTexture(UNKNOWN_TEXTURE);
RenderUtil.setGLColorFromInt(aspect.getColor());
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
UtilsFX.drawTexturedQuadFull(posX, posY, zLevel);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
}
}
}
@@ -0,0 +1,142 @@
package com.glodblock.github.crossmod.thaumcraft;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.MutablePair;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.IEssentiaContainerItem;
import thaumcraft.common.Thaumcraft;
import thaumicenergistics.api.storage.IAspectStack;
import thaumicenergistics.common.fluids.GaseousEssentia;
import thaumicenergistics.common.integration.tc.EssentiaItemContainerHelper;
import thaumicenergistics.common.storage.AspectStack;
import appeng.api.storage.data.IAEFluidStack;
import appeng.util.item.AEFluidStack;
public class AspectUtil {
public static final EssentiaItemContainerHelper HELPER = EssentiaItemContainerHelper.INSTANCE;
public static final int R = 128;
public static boolean isPlayerDiscoveredAspect(final EntityPlayer player, final Aspect aspect) {
if (player != null && aspect != null) {
return Thaumcraft.proxy.getPlayerKnowledge().hasDiscoveredAspect(player.getCommandSenderName(), aspect);
}
return false;
}
public static boolean isEssentiaGas(FluidStack fluid) {
return fluid != null && fluid.getFluid() instanceof GaseousEssentia;
}
public static boolean isEssentiaGas(IAEFluidStack fluid) {
return fluid != null && fluid.getFluid() instanceof GaseousEssentia;
}
public static Aspect getAspectFromGas(FluidStack fluid) {
if (!isEssentiaGas(fluid)) {
return null;
}
GaseousEssentia gas = (GaseousEssentia) fluid.getFluid();
return gas.getAspect();
}
public static Aspect getAspectFromJar(ItemStack stack) {
if (isEssentiaContainer(stack)) {
return HELPER.getAspectInContainer(stack);
}
return null;
}
public static Aspect getAspectFromGas(IAEFluidStack fluid) {
if (isEssentiaGas(fluid)) {
return null;
}
GaseousEssentia gas = (GaseousEssentia) fluid.getFluid();
return gas.getAspect();
}
public static FluidStack getGasFromAspect(IAspectStack aspectStack) {
if (aspectStack == null || aspectStack.isEmpty()) return null;
return new FluidStack(
GaseousEssentia.getGasFromAspect(aspectStack.getAspect()),
(int) aspectStack.getStackSize() * R);
}
public static boolean isEssentiaContainer(ItemStack stack) {
return HELPER.getItemType(stack) != EssentiaItemContainerHelper.AspectItemType.Invalid
&& HELPER.getItemType(stack) != EssentiaItemContainerHelper.AspectItemType.ItemAspect;
}
public static AEFluidStack getAEGasFromContainer(ItemStack stack) {
if (isEssentiaContainer(stack) && !isEmptyEssentiaContainer(stack)) {
IAspectStack aspectStack = HELPER.getAspectStackFromContainer(stack);
aspectStack.setStackSize(stack.stackSize * aspectStack.getStackSize());
FluidStack gas = getGasFromAspect(aspectStack);
return AEFluidStack.create(gas);
}
return null;
}
public static boolean isEmptyEssentiaContainer(ItemStack stack) {
return HELPER.isContainerEmpty(stack) && isEssentiaContainer(stack);
}
public static ItemStack setAspectAmount(ItemStack itemStack, int amount, Aspect aspect) {
if (isEssentiaContainer(itemStack)) {
IEssentiaContainerItem container = (IEssentiaContainerItem) itemStack.getItem();
assert container != null;
container.getAspects(itemStack).aspects.put(aspect, amount);
return itemStack;
}
return null;
}
public static MutablePair<Integer, ItemStack> fillEssentiaFromGas(ItemStack itemStack, FluidStack fluid) {
if (isEssentiaContainer(itemStack) && isEssentiaGas(fluid)) {
if (itemStack.stackSize != 1) {
return null;
}
Aspect aspect = getAspectFromGas(fluid);
int amount = fluid.amount / R;
EssentiaItemContainerHelper.AspectItemType iType = HELPER.getItemType(itemStack);
if (iType == EssentiaItemContainerHelper.AspectItemType.JarLabel) {
ItemStack label = itemStack.copy();
HELPER.setLabelAspect(label, aspect);
}
int cap = HELPER.getContainerCapacity(itemStack);
int tryFill = Math.min(cap, amount);
ImmutablePair<Integer, ItemStack> result = HELPER
.injectIntoContainer(itemStack, new AspectStack(aspect, tryFill));
return result != null ? new MutablePair<>(result.left * R, result.right) : null;
}
return null;
}
public static MutablePair<Integer, ItemStack> drainEssentiaFromGas(ItemStack itemStack, FluidStack fluid) {
if (isEssentiaContainer(itemStack) && isEssentiaGas(fluid)) {
Aspect aspect = getAspectFromGas(fluid);
int amount = fluid.amount / R;
IAspectStack contents = HELPER.getAspectStackFromContainer(itemStack);
int drained;
ItemStack stack = null;
if (contents == null || !Objects.equals(contents.getAspect(), aspect)) {
drained = 0;
} else {
ImmutablePair<Integer, ItemStack> result = HELPER
.extractFromContainer(itemStack, new AspectStack(aspect, amount));
drained = result == null ? 0 : result.left;
stack = result == null ? null : result.right;
}
return stack == null ? null : new MutablePair<>(drained * R, stack);
}
return null;
}
}
@@ -16,9 +16,14 @@ import net.minecraftforge.fluids.IFluidHandler;
import appeng.api.config.FuzzyMode;
import appeng.api.config.InsertionMode;
import appeng.api.parts.IPart;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
import appeng.parts.p2p.PartP2PLiquids;
import appeng.tile.misc.TileInterface;
import appeng.tile.networking.TileCableBus;
import appeng.util.InventoryAdaptor;
import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.ItemSlot;
@@ -36,21 +41,24 @@ import com.glodblock.github.util.Util;
public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
// facing is the target TE direction
// |T|-facing->|I|
public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids,
ForgeDirection facing, BlockPos pos, boolean isOnmi, Object eioConduct) {
ForgeDirection facing, BlockPos pos, boolean isOnmi) {
this.invItems = invItems;
this.invFluids = invFluids;
this.side = facing;
this.posInterface = pos;
this.eioDuct = eioConduct;
this.onmi = isOnmi;
this.selfInterface = getInterfaceTE(pos.getTileEntity(), facing.getOpposite());
}
private final InventoryAdaptor invItems;
private final IFluidHandler invFluids;
private final ForgeDirection side;
private final BlockPos posInterface;
private final Object eioDuct;
@Nullable
private final IInterfaceHost selfInterface;
private final boolean onmi;
public static InventoryAdaptor wrap(TileEntity capProvider, ForgeDirection face) {
@@ -69,31 +77,69 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
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);
return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi);
}
public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) {
FluidStack fluid = Util.getFluidFromVirtual(toBeAdded);
if (fluid != null) {
if (invFluids != null) {
if (invFluids.canFill(side, fluid.getFluid())) {
int filled = invFluids.fill(side, fluid, true);
if (filled > 0) {
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
}
}
if (!this.onmi) {
if (!checkValidSide(
this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity(),
this.side.getOpposite())) {
return toBeAdded;
}
if (fluid != null) {
int filled = fillSideFluid(fluid, this.invFluids, this.side, true);
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
} else {
ItemStack notFilled = fillSideItem(toBeAdded, this.invItems, insertionMode, true);
if (notFilled != null) {
// Fill EIO Conduit at last.
return fillEIOConduit(
notFilled,
this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity(),
this.side);
}
return null;
}
} else {
if (fluid != null) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (fluid.amount <= 0) {
return null;
}
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
int filled = fillSideFluid(fluid, getSideFluid(dir), dir.getOpposite(), true);
fluid.amount -= filled;
}
return ItemFluidPacket.newStack(fluid);
} else {
ItemStack item = toBeAdded.copy();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (item == null || item.stackSize <= 0) {
return null;
}
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
item = fillSideItem(item, getSideItem(dir), insertionMode, true);
}
// Fill EIO Conduit at last.
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (item == null || item.stackSize <= 0) {
return null;
}
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
item = fillEIOConduit(item, this.posInterface.getOffSet(dir).getTileEntity(), dir.getOpposite());
}
return item;
}
return toBeAdded;
}
if (eioDuct != null) {
return ((IItemDuct) eioDuct).insertItem(side, toBeAdded);
}
return invItems != null ? invItems.addItems(toBeAdded, insertionMode) : toBeAdded;
}
@Override
@@ -109,35 +155,56 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public ItemStack simulateAdd(ItemStack toBeSimulated, InsertionMode insertionMode) {
FluidStack fluid = Util.getFluidFromVirtual(toBeSimulated);
if (fluid != null) {
if (onmi) {
boolean sus = false;
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;
}
if (!this.onmi) {
if (!checkValidSide(
this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity(),
this.side.getOpposite())) {
return toBeSimulated;
}
if (fluid != null) {
int filled = fillSideFluid(fluid, this.invFluids, this.side, false);
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
} else {
// Assert EIO conduit can hold all item, as it is the origin practice in AE2
if (isConduit(this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity())) {
return null;
} else {
return fillSideItem(toBeSimulated, this.invItems, insertionMode, false);
}
}
} else {
// In onmi mode, fluid/item only need to be partly inserted.
boolean sus = false;
if (fluid != null) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
int filled = fillSideFluid(fluid, getSideFluid(dir), dir.getOpposite(), false);
if (filled > 0) {
sus = true;
break;
}
}
return sus ? null : toBeSimulated;
}
if (invFluids != null) {
int filled = invFluids.fill(side, fluid, false);
if (filled > 0) {
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
} else {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
// Assert EIO conduit can hold all item, as it is the origin practice in AE2
if (isConduit(this.posInterface.getOffSet(dir).getTileEntity())) {
return null;
}
ItemStack notFilled = fillSideItem(toBeSimulated, getSideItem(dir), insertionMode, false);
if (notFilled == null || notFilled.stackSize < toBeSimulated.stackSize) {
sus = true;
break;
}
}
}
return toBeSimulated;
return sus ? null : 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
@@ -164,15 +231,94 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public boolean containsItems() {
if (invFluids == null && invItems == null) {
// If this entity doesn't have fluid or item inventory, we just view it as full of things.
return true;
if (!this.onmi) {
// If there is no fluid tank or item inventory, it shouldn't send stuff here.
return checkItemFluids(this.invFluids, this.invItems, this.side) > 0;
}
if (invFluids != null && invFluids.getTankInfo(this.side) != null) {
boolean anyValid = false;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
// Avoid sending stuff into itself me network
if (checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)
&& !isConduit(this.posInterface.getOffSet(dir).getTileEntity())) {
final int result = checkItemFluids(this.getSideFluid(dir), this.getSideItem(dir), dir.getOpposite());
if (result == 1) {
return true;
}
if (result != 2) {
anyValid = true;
}
}
}
// Same here. if there is no fluid tank or item inventory existed, it shouldn't send stuff here.
return !anyValid;
}
public boolean hasSlots() {
return (invFluids != null && invFluids.getTankInfo(side).length > 0) || (invItems != null);
}
@Override
public Iterator<ItemSlot> iterator() {
return new SlotIterator(
invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0],
invItems != null ? invItems.iterator() : Collections.emptyIterator());
}
private IFluidHandler getSideFluid(ForgeDirection direction) {
TileEntity te = this.posInterface.getOffSet(direction).getTileEntity();
if (te instanceof IFluidHandler) {
return (IFluidHandler) te;
}
return null;
}
private int fillSideFluid(FluidStack fluid, IFluidHandler tank, ForgeDirection direction, boolean doFill) {
if (tank != null) {
return tank.fill(direction, fluid, doFill);
}
return 0;
}
// EIO conduit isn't considered here
private ItemStack fillSideItem(ItemStack item, InventoryAdaptor inv, InsertionMode mode, boolean doFill) {
if (inv != null) {
if (doFill) {
return inv.addItems(item, mode);
} else {
return inv.simulateAdd(item, mode);
}
}
return item;
}
private boolean isConduit(TileEntity te) {
return ModAndClassUtil.COFH && te instanceof IItemDuct;
}
private ItemStack fillEIOConduit(ItemStack item, TileEntity te, ForgeDirection direction) {
if (isConduit(te)) {
return ((IItemDuct) te).insertItem(direction, item);
}
return item;
}
private InventoryAdaptor getSideItem(ForgeDirection direction) {
TileEntity te = this.posInterface.getOffSet(direction).getTileEntity();
return InventoryAdaptor.getAdaptor(te, direction.getOpposite());
}
// 0 - It is empty
// 1 - It contains item/fluid
// 2 - It doesn't exist
private int checkItemFluids(IFluidHandler tank, InventoryAdaptor inv, ForgeDirection direction) {
if (tank == null && inv == null) {
return 2;
}
if (tank != null && tank.getTankInfo(direction) != null) {
List<FluidTankInfo[]> tankInfos = new LinkedList<>();
if (Util.getPart(invFluids, this.side) instanceof PartP2PLiquids) {
if (Util.getPart(tank, direction) instanceof PartP2PLiquids) {
// read other ends of p2p for blocking mode
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) Util.getPart(invFluids, this.side);
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) Util.getPart(tank, direction);
try {
Iterator<PartP2PLiquids> it = invFluidsP2P.getOutputs().iterator();
boolean checkedInput = false;
@@ -191,35 +337,56 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
} catch (GridAccessException ignore) {}
} else {
tankInfos.add(invFluids.getTankInfo(this.side));
tankInfos.add(tank.getTankInfo(direction));
}
boolean hasTank = false;
for (FluidTankInfo[] tankInfoArray : tankInfos) {
for (FluidTankInfo tank : tankInfoArray) {
for (FluidTankInfo tankInfo : tankInfoArray) {
hasTank = true;
FluidStack fluid = tank.fluid;
FluidStack fluid = tankInfo.fluid;
if (fluid != null && fluid.amount > 0) {
return true;
return 1;
}
}
}
if (!hasTank && invItems == null) {
// If this entity doesn't have fluid or item inventory, we just view it as full of things.
if (!hasTank && inv == null) {
return 2;
}
}
return inv != null && inv.containsItems() ? 1 : 0;
}
private boolean checkValidSide(TileEntity te, ForgeDirection direction) {
return isDifferentGrid(getInterfaceTE(te, direction.getOpposite()));
}
private static IInterfaceHost getInterfaceTE(TileEntity te, ForgeDirection face) {
if (te instanceof IInterfaceHost) {
return (IInterfaceHost) te;
} else if (te instanceof TileCableBus) {
IPart part = ((TileCableBus) te).getPart(face);
if (part instanceof IInterfaceHost) {
return (IInterfaceHost) part;
}
}
return null;
}
private boolean isDifferentGrid(IInterfaceHost target) {
if (this.selfInterface != null && target != null) {
DualityInterface other = target.getInterfaceDuality();
DualityInterface self = this.selfInterface.getInterfaceDuality();
try {
AENetworkProxy proxy1 = Ae2Reflect.getInterfaceProxy(other);
AENetworkProxy proxy2 = Ae2Reflect.getInterfaceProxy(self);
if (proxy1.getGrid() == proxy2.getGrid()) {
return false;
}
} catch (GridAccessException e) {
return true;
}
}
return invItems != null && invItems.containsItems();
}
public boolean hasSlots() {
return (invFluids != null && invFluids.getTankInfo(side).length > 0) || (invItems != null);
}
@Override
public Iterator<ItemSlot> iterator() {
return new SlotIterator(
invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0],
invItems != null ? invItems.iterator() : Collections.emptyIterator());
return true;
}
private static class SlotIterator implements Iterator<ItemSlot> {
@@ -6,6 +6,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketSwitchGuis;
@@ -22,6 +24,9 @@ public class InventoryHandler implements IGuiHandler {
}
public static void openGui(EntityPlayer player, World world, BlockPos pos, ForgeDirection face, GuiType guiType) {
if (Platform.isClient()) {
return;
}
player.openGui(
FluidCraft.INSTANCE,
(guiType.ordinal() << 3) | face.ordinal(),
@@ -0,0 +1,38 @@
package com.glodblock.github.inventory;
import net.minecraft.item.ItemStack;
import appeng.tile.inventory.BiggerAppEngInventory;
import appeng.util.Platform;
import com.glodblock.github.inventory.gui.GuiType;
public class ItemBiggerAppEngInventory extends BiggerAppEngInventory {
private final ItemStack is;
private final String name;
public ItemBiggerAppEngInventory(ItemStack is, String name, int size) {
super(null, size);
this.name = name;
this.is = is;
this.readFromNBT(Platform.openNbtData(is), name);
}
@Override
public void markDirty() {
boolean isCraft = Platform.openNbtData(is).getBoolean("craftingMode");
boolean isCraftingTerm = Platform.openNbtData(is).getString("mode_main")
.equals(GuiType.WIRELESS_CRAFTING_TERMINAL.toString());
if (!isCraftingTerm && isCraft) {
for (int x = 0; x < this.getSizeInventory(); x++) {
final ItemStack is = this.getStackInSlot(x);
if (is != null) {
is.stackSize = 1;
}
}
}
this.writeToNBT(Platform.openNbtData(is), this.name);
}
}
@@ -0,0 +1,56 @@
package com.glodblock.github.inventory;
import net.minecraft.item.ItemStack;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.inventory.item.IWirelessPatternTerminal;
public class WirelessFluidPatternTerminalPatterns extends AppEngInternalInventory {
private final ItemStack is;
private final IWirelessPatternTerminal terminal;
public WirelessFluidPatternTerminalPatterns(final ItemStack is, final IWirelessPatternTerminal term) {
super(null, 2);
this.is = is;
this.terminal = term;
this.readFromNBT(Platform.openNbtData(is), "pattern");
}
@Override
public void markDirty() {
this.writeToNBT(Platform.openNbtData(is), "pattern");
}
@Override
public void setInventorySlotContents(final int slot, final ItemStack newItemStack) {
final ItemStack oldStack = this.inv[slot];
this.inv[slot] = newItemStack;
if (this.eventsEnabled()) {
ItemStack removed = oldStack;
ItemStack added = newItemStack;
if (oldStack != null && newItemStack != null && Platform.isSameItemPrecise(oldStack, newItemStack)) {
if (oldStack.stackSize > newItemStack.stackSize) {
removed = removed.copy();
removed.stackSize -= newItemStack.stackSize;
added = null;
} else if (oldStack.stackSize < newItemStack.stackSize) {
added = added.copy();
added.stackSize -= oldStack.stackSize;
removed = null;
} else {
removed = added = null;
}
}
this.terminal.onChangeInventory(this, slot, InvOperation.setInventorySlotContents, removed, added);
}
this.markDirty();
}
}
@@ -22,6 +22,7 @@ import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.common.tile.*;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.item.IFluidPortableCell;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.google.common.collect.ImmutableList;
public enum GuiType {
@@ -169,15 +170,15 @@ public enum GuiType {
}
}),
CRAFTING_STATUS(new PartGuiFactory<FCPart>(FCPart.class) {
CRAFTING_STATUS(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, FCPart inv) {
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
return new ContainerCraftingStatus(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, FCPart inv) {
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
return new GuiFluidPatternTerminalCraftingStatus(player.inventory, inv);
}
}),
@@ -208,6 +209,82 @@ public enum GuiType {
}
}),
WIRELESS_FLUID_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerFluidPortableCell(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiFluidPortableCell(player.inventory, inv);
}
}),
WIRELESS_ESSENTIA_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerEssentiaMonitor(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiEssentiaTerminal(player.inventory, inv);
}
}),
WIRELESS_FLUID_PATTERN_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerFluidPatternWireless(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiFluidPatternWireless(player.inventory, inv);
}
}),
WIRELESS_FLUID_PATTERN_TERMINAL_EX(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerFluidPatternExWireless(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiFluidPatternExWireless(player.inventory, inv);
}
}),
WIRELESS_INTERFACE_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerInterfaceWireless(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiInterfaceTerminalWireless(player.inventory, inv);
}
}),
WIRELESS_CRAFTING_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerCraftingWireless(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiFluidCraftingWireless(player.inventory, inv);
}
}),
FLUID_PATTERN_TERMINAL(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
@@ -260,15 +337,28 @@ public enum GuiType {
}
}),
FLUID_CRAFTING_AMOUNT(new PartGuiFactory<FCPart>(FCPart.class) {
FLUID_CRAFTING_CONFIRM_ITEM(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, FCPart inv) {
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerFluidCraftConfirm(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiFluidCraftConfirm(player.inventory, inv);
}
}),
FLUID_CRAFTING_AMOUNT(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
return new ContainerCraftAmount(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, FCPart inv) {
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
return new GuiFluidCraftAmount(player.inventory, inv);
}
}),
@@ -286,15 +376,15 @@ public enum GuiType {
}
}),
PATTERN_VALUE_SET(new PartGuiFactory<FCPart>(FCPart.class) {
PATTERN_VALUE_SET(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, FCPart inv) {
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
return new ContainerPatternValueAmount(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, FCPart inv) {
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
return new GuiPatternValueAmount(player.inventory, inv);
}
});
@@ -2,6 +2,7 @@ package com.glodblock.github.inventory.gui;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@@ -11,6 +12,7 @@ import appeng.container.AEBaseContainer;
import appeng.container.ContainerOpenContext;
import com.glodblock.github.inventory.item.IItemInventory;
import com.glodblock.github.util.Util;
public abstract class ItemGuiFactory<T> implements IGuiFactory {
@@ -28,11 +30,11 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
@Nullable
@Override
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z));
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z, player));
if (inv == null) {
return null;
}
@@ -55,11 +57,14 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
@Nullable
@Override
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z));
T inv = getInventory(((IItemInventory) item.getItem()).getInventory(item, world, x, y, z, player));
if (inv == null && Minecraft.getMinecraft().currentScreen != null) {
player.closeScreen();
}
return inv != null ? createClientGui(player, inv) : null;
}
@@ -0,0 +1,78 @@
package com.glodblock.github.inventory.gui;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.apache.commons.lang3.tuple.ImmutablePair;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerOpenContext;
import com.glodblock.github.inventory.item.IItemInventory;
import com.glodblock.github.util.Util;
public abstract class PartOrItemGuiFactory<T> extends PartGuiFactory<T> {
PartOrItemGuiFactory(Class<T> invClass) {
super(invClass);
}
@Nullable
protected T getItemInventory(Object inv) {
return invClass.isInstance(inv) ? invClass.cast(inv) : null;
}
@Nullable
@Override
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
if (result.getLeft() == Util.GuiHelper.GuiType.ITEM) {
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
T inv = getItemInventory(
((IItemInventory) item.getItem()).getInventory(item, world, x, result.getRight(), z, player));
if (inv == null) {
return null;
}
Object gui = createServerGui(player, inv);
if (gui instanceof AEBaseContainer) {
ContainerOpenContext ctx = new ContainerOpenContext(inv);
ctx.setWorld(world);
ctx.setX(x);
ctx.setY(y);
ctx.setZ(z);
ctx.setSide(face);
((AEBaseContainer) gui).setOpenContext(ctx);
}
return gui;
} else {
return super.createServerGui(player, world, x, result.getRight(), z, face);
}
}
@Nullable
@Override
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
if (result.left == Util.GuiHelper.GuiType.ITEM) {
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
T inv = getItemInventory(
((IItemInventory) item.getItem()).getInventory(item, world, x, result.getRight(), z, player));
return inv != null ? createClientGui(player, inv) : null;
} else {
return super.createClientGui(player, world, x, result.getRight(), z, face);
}
}
}
@@ -1,9 +1,10 @@
package com.glodblock.github.inventory.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IItemInventory {
Object getInventory(ItemStack stack, World world, int x, int y, int z);
Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player);
}
@@ -0,0 +1,42 @@
package com.glodblock.github.inventory.item;
import appeng.api.storage.data.IAEItemStack;
public interface IItemPatternTerminal extends IItemTerminal {
boolean isInverted();
boolean canBeSubstitute();
boolean isPrioritize();
boolean isSubstitution();
boolean shouldCombine();
void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput);
void setCraftingRecipe(final boolean craftingMode);
void setSubstitution(boolean canSubstitute);
void setBeSubstitute(boolean canBeSubstitute);
void setCombineMode(boolean shouldCombine);
void setPrioritization(boolean canPrioritize);
void setInverted(boolean inverted);
int getActivePage();
void setActivePage(int activePage);
boolean isCraftingRecipe();
void sortCraftingItems();
boolean isAutoFillPattern();
void setAutoFillPattern(boolean canFill);
}
@@ -0,0 +1,11 @@
package com.glodblock.github.inventory.item;
import net.minecraft.inventory.IInventory;
public interface IItemTerminal {
IInventory getInventoryByName(final String name);
default void saveSettings() {}
}
@@ -0,0 +1,5 @@
package com.glodblock.github.inventory.item;
public interface IWirelessCraftTerminal extends IWirelessTerminal, IItemTerminal {
}
@@ -0,0 +1,4 @@
package com.glodblock.github.inventory.item;
public interface IWirelessInterfaceTerminal extends IWirelessTerminal {
}
@@ -0,0 +1,5 @@
package com.glodblock.github.inventory.item;
public interface IWirelessPatternTerminal extends IWirelessTerminal, IItemPatternTerminal {
}
@@ -0,0 +1,24 @@
package com.glodblock.github.inventory.item;
import net.minecraft.item.ItemStack;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGridHost;
import appeng.api.networking.security.IActionHost;
import appeng.tile.inventory.IAEAppEngInventory;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
public interface IWirelessTerminal
extends IFluidPortableCell, IViewCellStorage, IAEAppEngInventory, IGridHost, IActionHost {
default boolean isUniversal(Object holder) {
if (holder instanceof IGuiItemObject) {
ItemStack stack = ((IGuiItemObject) holder).getItemStack();
return stack != null && stack.getItem() instanceof ItemWirelessUltraTerminal;
}
return false;
}
}
@@ -0,0 +1,155 @@
package com.glodblock.github.inventory.item;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IGridNode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.items.contents.WirelessTerminalViewCells;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
import com.glodblock.github.util.Util;
public class WirelessCraftingTerminalInventory extends MEMonitorHandler<IAEItemStack>
implements IWirelessCraftTerminal {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final int inventorySlot;
private final AppEngInternalInventory viewCell;
private final StorageChannel channel;
private final IGridNode grid;
protected AppEngInternalInventory crafting;
protected AppEngInternalInventory output;
@SuppressWarnings("unchecked")
public WirelessCraftingTerminalInventory(final ItemStack is, final int slot, IGridNode gridNode,
EntityPlayer player) {
super(
(IMEInventoryHandler<IAEItemStack>) Objects
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS)));
this.ips = (ToolWirelessTerminal) is.getItem();
this.grid = gridNode;
this.target = is;
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.ITEMS;
this.crafting = new ItemBiggerAppEngInventory(is, "crafting_c", 9);
this.output = new ItemBiggerAppEngInventory(is, "output_c", 3);
}
public StorageChannel getChannel() {
return this.channel;
}
@Override
public ItemStack getItemStack() {
return this.target;
}
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
amt = usePowerMultiplier.multiply(amt);
if (mode == Actionable.SIMULATE) {
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
}
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return this;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return null;
}
@Override
public IConfigManager getConfigManager() {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final NBTTagCompound data = Platform.openNbtData(this.target);
manager.writeToNBT(data);
});
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
return out;
}
@Override
public int getInventorySlot() {
return this.inventorySlot;
}
@Override
public IInventory getViewCellStorage() {
return this.viewCell;
}
@Override
public IGridNode getGridNode(ForgeDirection dir) {
return this.grid;
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir) {
return AECableType.NONE;
}
@Override
public void securityBreak() {
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
}
@Override
public void saveChanges() {
// NO-OP
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
// NO-OP
}
@Override
public IInventory getInventoryByName(String name) {
if (name.equals("crafting")) {
return this.crafting;
}
if (name.equals("output")) {
return this.output;
}
return null;
}
@Override
public IGridNode getActionableNode() {
return this.grid;
}
}
@@ -0,0 +1,133 @@
package com.glodblock.github.inventory.item;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IGridNode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.items.contents.WirelessTerminalViewCells;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.util.Util;
public class WirelessFluidTerminalInventory extends MEMonitorHandler<IAEFluidStack> implements IWirelessTerminal {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final int inventorySlot;
private final AppEngInternalInventory viewCell;
private final StorageChannel channel;
private final IGridNode grid;
@SuppressWarnings("unchecked")
public WirelessFluidTerminalInventory(final ItemStack is, final int slot, IGridNode gridNode, EntityPlayer player) {
super(
(IMEInventoryHandler<IAEFluidStack>) Objects
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.FLUIDS)));
this.ips = (ToolWirelessTerminal) is.getItem();
this.grid = gridNode;
this.target = is;
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.FLUIDS;
}
public StorageChannel getChannel() {
return this.channel;
}
@Override
public ItemStack getItemStack() {
return this.target;
}
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
amt = usePowerMultiplier.multiply(amt);
if (mode == Actionable.SIMULATE) {
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
}
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return null;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return this;
}
@Override
public IConfigManager getConfigManager() {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final NBTTagCompound data = Platform.openNbtData(this.target);
manager.writeToNBT(data);
});
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
out.putSetting(Settings.VIEW_MODE, ViewItems.ALL);
return out;
}
@Override
public int getInventorySlot() {
return this.inventorySlot;
}
@Override
public IInventory getViewCellStorage() {
return this.viewCell;
}
@Override
public IGridNode getGridNode(ForgeDirection dir) {
return this.grid;
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir) {
return AECableType.NONE;
}
@Override
public void securityBreak() {
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
}
@Override
public void saveChanges() {
}
@Override
public IGridNode getActionableNode() {
return this.grid;
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {}
}
@@ -0,0 +1,111 @@
package com.glodblock.github.inventory.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IGridNode;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
public class WirelessInterfaceTerminalInventory implements IWirelessInterfaceTerminal {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final int inventorySlot;
private final IGridNode grid;
public WirelessInterfaceTerminalInventory(ItemStack is, int slot, IGridNode gridNode, EntityPlayer player) {
this.ips = (ToolWirelessTerminal) is.getItem();
this.grid = gridNode;
this.target = is;
this.inventorySlot = slot;
}
@Override
public IGridNode getActionableNode() {
return this.grid;
}
@Override
public IGridNode getGridNode(ForgeDirection dir) {
return this.grid;
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir) {
return AECableType.NONE;
}
@Override
public void securityBreak() {
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
}
@Override
public ItemStack getItemStack() {
return this.target;
}
@Override
public IInventory getViewCellStorage() {
return null;
}
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
amt = usePowerMultiplier.multiply(amt);
if (mode == Actionable.SIMULATE) {
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
}
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return null;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return null;
}
@Override
public IConfigManager getConfigManager() {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final NBTTagCompound data = Platform.openNbtData(this.target);
manager.writeToNBT(data);
});
out.registerSetting(Settings.TERMINAL_STYLE, TerminalStyle.SMALL);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
return out;
}
@Override
public int getInventorySlot() {
return this.inventorySlot;
}
@Override
public void saveChanges() {
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
}
}
@@ -0,0 +1,421 @@
package com.glodblock.github.inventory.item;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.items.contents.WirelessTerminalViewCells;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
import com.glodblock.github.inventory.WirelessFluidPatternTerminalPatterns;
import com.glodblock.github.util.Util;
public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItemStack>
implements IWirelessPatternTerminal {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final int inventorySlot;
private final AppEngInternalInventory viewCell;
private final StorageChannel channel;
private final IGridNode grid;
protected AppEngInternalInventory crafting;
protected AppEngInternalInventory output;
protected final WirelessFluidPatternTerminalPatterns pattern;
protected boolean craftingMode = false;
protected boolean substitute = false;
protected boolean combine = false;
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
@SuppressWarnings("unchecked")
public WirelessPatternTerminalExInventory(final ItemStack is, final int slot, IGridNode gridNode,
EntityPlayer player) {
super(
(IMEInventoryHandler<IAEItemStack>) Objects
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS)));
this.ips = (ToolWirelessTerminal) is.getItem();
this.grid = gridNode;
this.target = is;
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.ITEMS;
this.pattern = new WirelessFluidPatternTerminalPatterns(is, this);
this.crafting = new ItemBiggerAppEngInventory(is, "crafting_ex", 32);
this.output = new ItemBiggerAppEngInventory(is, "output_ex", 32);
}
public StorageChannel getChannel() {
return this.channel;
}
@Override
public ItemStack getItemStack() {
return this.target;
}
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
amt = usePowerMultiplier.multiply(amt);
if (mode == Actionable.SIMULATE) {
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
}
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return this;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return null;
}
public void readFromNBT() {
NBTTagCompound data = Platform.openNbtData(this.target);
this.setSubstitution(data.getBoolean("substitute"));
this.setCombineMode(data.getBoolean("combine"));
this.setBeSubstitute(data.getBoolean("beSubstitute"));
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
}
public void writeToNBT() {
NBTTagCompound data = Platform.openNbtData(this.target);
data.setBoolean("substitute", this.substitute);
data.setBoolean("combine", this.combine);
data.setBoolean("beSubstitute", this.beSubstitute);
data.setBoolean("priorization", this.prioritize);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
}
@Override
public IConfigManager getConfigManager() {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final NBTTagCompound data = Platform.openNbtData(this.target);
manager.writeToNBT(data);
});
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
this.readFromNBT();
return out;
}
@Override
public int getInventorySlot() {
return this.inventorySlot;
}
@Override
public IInventory getViewCellStorage() {
return this.viewCell;
}
@Override
public IGridNode getGridNode(ForgeDirection dir) {
return this.grid;
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir) {
return AECableType.NONE;
}
@Override
public void securityBreak() {
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
}
@Override
public void saveChanges() {
// NO-OP
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
.getPatternForItem(is, this.getActionableNode().getWorld());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
final IAEItemStack[] outItems = details.getOutputs();
int inputsCount = 0;
int outputCount = 0;
for (IAEItemStack inItem : inItems) {
if (inItem != null) {
inputsCount++;
}
}
for (IAEItemStack outItem : outItems) {
if (outItem != null) {
outputCount++;
}
}
this.setSubstitution(details.canSubstitute());
if (newStack != null) {
NBTTagCompound data = newStack.getTagCompound();
this.setCombineMode(data.getInteger("combine") == 1);
this.setBeSubstitute(details.canBeSubstitute());
}
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());
}
}
}
}
}
}
}
private void fixCraftingRecipes() {
if (this.craftingMode) {
for (int x = 0; x < this.crafting.getSizeInventory(); x++) {
final ItemStack is = this.crafting.getStackInSlot(x);
if (is != null) {
is.stackSize = 1;
}
}
}
}
@Override
public boolean isInverted() {
return this.inverted;
}
@Override
public IInventory getInventoryByName(String name) {
if (name.equals("crafting")) {
return this.crafting;
}
if (name.equals("output")) {
return this.output;
}
if (name.equals("pattern")) {
return this.pattern;
}
return null;
}
@Override
public boolean canBeSubstitute() {
return this.beSubstitute;
}
@Override
public boolean isPrioritize() {
return this.prioritize;
}
@Override
public boolean isSubstitution() {
return this.substitute;
}
@Override
public boolean shouldCombine() {
return this.combine;
}
@Override
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
IInventory crafting = this.getInventoryByName("crafting");
IInventory output = this.getInventoryByName("output");
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
final IAEItemStack item = newCrafting[x];
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
}
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
final IAEItemStack item = newOutput[x];
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
}
}
}
@Override
public void setCraftingRecipe(boolean craftingMode) {
this.craftingMode = craftingMode;
this.fixCraftingRecipes();
}
@Override
public void setSubstitution(boolean canSubstitute) {
this.substitute = canSubstitute;
}
@Override
public void setBeSubstitute(boolean canBeSubstitute) {
this.beSubstitute = canBeSubstitute;
}
@Override
public void setCombineMode(boolean shouldCombine) {
this.combine = shouldCombine;
}
@Override
public void setPrioritization(boolean canPrioritize) {
this.prioritize = canPrioritize;
}
@Override
public void setInverted(boolean inverted) {
this.inverted = inverted;
}
@Override
public int getActivePage() {
return this.activePage;
}
@Override
public void setActivePage(int activePage) {
this.activePage = activePage;
}
@Override
public boolean isCraftingRecipe() {
return this.craftingMode;
}
@Override
public void sortCraftingItems() {
List<ItemStack> items = new ArrayList<ItemStack>();
List<ItemStack> fluids = new ArrayList<ItemStack>();
for (ItemStack is : this.crafting) {
if (is == null) continue;
if (is.getItem() instanceof ItemFluidPacket) {
fluids.add(is);
} else {
items.add(is);
}
}
if (this.prioritize) {
fluids.addAll(items);
items.clear();
} else {
items.addAll(fluids);
fluids.clear();
}
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
if (this.crafting.getStackInSlot(i) == null) break;
if (items.isEmpty()) {
this.crafting.setInventorySlotContents(i, fluids.get(i));
} else {
this.crafting.setInventorySlotContents(i, items.get(i));
}
}
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
@Override
public void saveSettings() {
this.writeToNBT();
}
@Override
public IGridNode getActionableNode() {
return this.grid;
}
}
@@ -0,0 +1,394 @@
package com.glodblock.github.inventory.item;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.items.contents.WirelessTerminalViewCells;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
import com.glodblock.github.inventory.WirelessFluidPatternTerminalPatterns;
import com.glodblock.github.util.Util;
public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemStack>
implements IWirelessPatternTerminal {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final int inventorySlot;
private final AppEngInternalInventory viewCell;
private final StorageChannel channel;
private final IGridNode grid;
protected AppEngInternalInventory crafting;
protected AppEngInternalInventory output;
protected final WirelessFluidPatternTerminalPatterns pattern;
protected boolean craftingMode = true;
protected boolean substitute = false;
protected boolean combine = false;
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
@SuppressWarnings("unchecked")
public WirelessPatternTerminalInventory(final ItemStack is, final int slot, IGridNode gridNode,
EntityPlayer player) {
super(
(IMEInventoryHandler<IAEItemStack>) Objects
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS)));
this.ips = (ToolWirelessTerminal) is.getItem();
this.grid = gridNode;
this.target = is;
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.ITEMS;
this.pattern = new WirelessFluidPatternTerminalPatterns(is, this);
this.crafting = new ItemBiggerAppEngInventory(is, "crafting", 9);
this.output = new ItemBiggerAppEngInventory(is, "output", 3);
}
public StorageChannel getChannel() {
return this.channel;
}
@Override
public ItemStack getItemStack() {
return this.target;
}
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
amt = usePowerMultiplier.multiply(amt);
if (mode == Actionable.SIMULATE) {
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
}
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return this;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return null;
}
public void readFromNBT() {
NBTTagCompound data = Platform.openNbtData(this.target);
this.setCraftingRecipe(data.getBoolean("craftingMode"));
this.setSubstitution(data.getBoolean("substitute"));
this.setCombineMode(data.getBoolean("combine"));
this.setBeSubstitute(data.getBoolean("beSubstitute"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
}
public void writeToNBT() {
NBTTagCompound data = Platform.openNbtData(this.target);
data.setBoolean("craftingMode", this.craftingMode);
data.setBoolean("substitute", this.substitute);
data.setBoolean("combine", this.combine);
data.setBoolean("beSubstitute", this.beSubstitute);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
}
@Override
public IConfigManager getConfigManager() {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final NBTTagCompound data = Platform.openNbtData(this.target);
manager.writeToNBT(data);
});
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
this.readFromNBT();
return out;
}
@Override
public int getInventorySlot() {
return this.inventorySlot;
}
@Override
public IInventory getViewCellStorage() {
return this.viewCell;
}
@Override
public IGridNode getGridNode(ForgeDirection dir) {
return this.grid;
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir) {
return AECableType.NONE;
}
@Override
public void securityBreak() {
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
}
@Override
public void saveChanges() {
// NO-OP
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
.getPatternForItem(is, this.getActionableNode().getWorld());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
final IAEItemStack[] outItems = details.getOutputs();
this.setCraftingRecipe(details.isCraftable());
this.setSubstitution(details.canSubstitute());
if (newStack != null) {
NBTTagCompound data = newStack.getTagCompound();
this.setCombineMode(data.getInteger("combine") == 1);
this.setBeSubstitute(details.canBeSubstitute());
}
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++) {
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());
}
}
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());
}
}
}
}
}
if (inv == this.crafting) {
this.fixCraftingRecipes();
}
}
private void fixCraftingRecipes() {
if (this.craftingMode) {
for (int x = 0; x < this.crafting.getSizeInventory(); x++) {
final ItemStack is = this.crafting.getStackInSlot(x);
if (is != null) {
is.stackSize = 1;
}
}
}
}
@Override
public boolean isInverted() {
return false;
}
@Override
public IInventory getInventoryByName(String name) {
if (name.equals("crafting")) {
return this.crafting;
}
if (name.equals("output")) {
return this.output;
}
if (name.equals("pattern")) {
return this.pattern;
}
return null;
}
@Override
public boolean canBeSubstitute() {
return this.beSubstitute;
}
@Override
public boolean isPrioritize() {
return false;
}
@Override
public boolean isSubstitution() {
return this.substitute;
}
@Override
public boolean shouldCombine() {
return this.combine;
}
@Override
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
IInventory crafting = this.getInventoryByName("crafting");
IInventory output = this.getInventoryByName("output");
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
final IAEItemStack item = newCrafting[x];
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
}
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
final IAEItemStack item = newOutput[x];
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
}
}
}
@Override
public void setCraftingRecipe(boolean craftingMode) {
this.craftingMode = craftingMode;
this.fixCraftingRecipes();
}
@Override
public void setSubstitution(boolean canSubstitute) {
this.substitute = canSubstitute;
}
@Override
public void setBeSubstitute(boolean canBeSubstitute) {
this.beSubstitute = canBeSubstitute;
}
@Override
public void setCombineMode(boolean shouldCombine) {
this.combine = shouldCombine;
}
@Override
public void setPrioritization(boolean canPrioritize) {
this.prioritize = canPrioritize;
}
@Override
public void setInverted(boolean inverted) {
this.inverted = inverted;
}
@Override
public int getActivePage() {
return this.activePage;
}
@Override
public void setActivePage(int activePage) {
this.activePage = activePage;
}
@Override
public boolean isCraftingRecipe() {
return this.craftingMode;
}
@Override
public void sortCraftingItems() {
List<ItemStack> items = new ArrayList<ItemStack>();
List<ItemStack> fluids = new ArrayList<ItemStack>();
for (ItemStack is : this.crafting) {
if (is == null) continue;
if (is.getItem() instanceof ItemFluidPacket) {
fluids.add(is);
} else {
items.add(is);
}
}
if (this.prioritize) {
fluids.addAll(items);
items.clear();
} else {
items.addAll(fluids);
fluids.clear();
}
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
if (this.crafting.getStackInSlot(i) == null) break;
if (items.isEmpty()) {
this.crafting.setInventorySlotContents(i, fluids.get(i));
} else {
this.crafting.setInventorySlotContents(i, items.get(i));
}
}
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
@Override
public void saveSettings() {
this.writeToNBT();
}
@Override
public IGridNode getActionableNode() {
return this.grid;
}
}
@@ -1,11 +1,17 @@
package com.glodblock.github.loader;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.Packet;
import net.minecraft.world.World;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.network.*;
import cpw.mods.fml.relauncher.Side;
public class ChannelLoader implements Runnable {
public static final ChannelLoader INSTANCE = new ChannelLoader();
@Override
@SuppressWarnings("all")
public void run() {
@@ -46,5 +52,15 @@ public class ChannelLoader implements Runnable {
.registerMessage(new CPacketLevelMaintainer.Handler(), CPacketLevelMaintainer.class, id++, Side.SERVER);
FluidCraft.proxy.netHandler
.registerMessage(new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT);
FluidCraft.proxy.netHandler
.registerMessage(new CPacketRenamer.Handler(), CPacketRenamer.class, id++, Side.SERVER);
}
public static void sendPacketToAllPlayers(Packet packet, World world) {
for (Object player : world.playerEntities) {
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(packet);
}
}
}
}
@@ -1,9 +1,12 @@
package com.glodblock.github.loader;
import static com.glodblock.github.common.storage.FluidCellInventory.singleByteAmount;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.block.*;
import com.glodblock.github.common.item.*;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.util.NameConst;
public class ItemAndBlockHolder {
@@ -32,22 +35,63 @@ public class ItemAndBlockHolder {
public static ItemFluidStorageMonitor FLUID_STORAGE_MONITOR = new ItemFluidStorageMonitor().register();
public static ItemFluidConversionMonitor FLUID_CONVERSION_MONITOR = new ItemFluidConversionMonitor().register();
public static ItemPortableFluidCell PORTABLE_FLUID_CELL = new ItemPortableFluidCell().register();
public static ItemWirelessFluidTerminal WIRELESS_FLUID_TERM = new ItemWirelessFluidTerminal().register();
public static ItemWirelessUltraTerminal WIRELESS_ULTRA_TERM = new ItemWirelessUltraTerminal().register();
public static ItemWirelessPatternTerminal WIRELESS_PATTERN_TERM = new ItemWirelessPatternTerminal().register();
public static ItemWirelessInterfaceTerminal WIRELESS_INTERFACE_TERM = new ItemWirelessInterfaceTerminal()
.register();
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 4).register();
public static ItemBasicFluidStorageCell CELL16K = new ItemBasicFluidStorageCell(CellType.Cell16kPart, 16)
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 0, 1)
.register();
public static ItemBasicFluidStorageCell CELL64K = new ItemBasicFluidStorageCell(CellType.Cell64kPart, 64)
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 0, 4)
.register();
public static ItemBasicFluidStorageCell CELL256K = new ItemBasicFluidStorageCell(CellType.Cell256kPart, 256)
public static ItemBasicFluidStorageCell CELL16K = new ItemBasicFluidStorageCell(CellType.Cell16kPart, 0, 16)
.register();
public static ItemBasicFluidStorageCell CELL1024K = new ItemBasicFluidStorageCell(CellType.Cell1024kPart, 1024)
public static ItemBasicFluidStorageCell CELL64K = new ItemBasicFluidStorageCell(CellType.Cell64kPart, 0, 64)
.register();
public static ItemBasicFluidStorageCell CELL4096K = new ItemBasicFluidStorageCell(CellType.Cell4096kPart, 4096)
public static ItemBasicFluidStorageCell CELL256K = new ItemBasicFluidStorageCell(CellType.Cell256kPart, 1, 256)
.register();
public static ItemBasicFluidStorageCell CELL16384K = new ItemBasicFluidStorageCell(CellType.Cell16384kPart, 16384)
public static ItemBasicFluidStorageCell CELL1024K = new ItemBasicFluidStorageCell(CellType.Cell1024kPart, 1, 1024)
.register();
public static ItemBasicFluidStorageCell CELL4096K = new ItemBasicFluidStorageCell(CellType.Cell4096kPart, 1, 4096)
.register();
public static ItemBasicFluidStorageCell CELL16384K = new ItemBasicFluidStorageCell(
CellType.Cell16384kPart,
1,
16384).register();
public static ItemMultiFluidStorageCell CELL1KM = new ItemMultiFluidStorageCell(CellType.Cell1kPart, 2, 1)
.register();
public static ItemMultiFluidStorageCell CELL4KM = new ItemMultiFluidStorageCell(CellType.Cell4kPart, 2, 4)
.register();
public static ItemMultiFluidStorageCell CELL16KM = new ItemMultiFluidStorageCell(CellType.Cell16kPart, 2, 16)
.register();
public static ItemMultiFluidStorageCell CELL64KM = new ItemMultiFluidStorageCell(CellType.Cell64kPart, 2, 64)
.register();
public static ItemMultiFluidStorageCell CELL256KM = new ItemMultiFluidStorageCell(CellType.Cell256kPart, 3, 256)
.register();
public static ItemMultiFluidStorageCell CELL1024KM = new ItemMultiFluidStorageCell(CellType.Cell1024kPart, 3, 1024)
.register();
public static ItemMultiFluidStorageCell CELL4096KM = new ItemMultiFluidStorageCell(CellType.Cell4096kPart, 3, 4096)
.register();
public static ItemMultiFluidStorageCell CELL16384KM = new ItemMultiFluidStorageCell(
CellType.Cell16384kPart,
3,
16384).register();
public static ItemFluidExtremeStorageCell QUANTUM_CELL = new ItemFluidExtremeStorageCell(
NameConst.ITEM_QUANTUM_FLUID_STORAGE,
Integer.MAX_VALUE / 16,
8,
5,
4.5).register();
public static ItemFluidExtremeStorageCell SINGULARITY_CELL = new ItemFluidExtremeStorageCell(
NameConst.ITEM_SINGULARITY_FLUID_STORAGE,
Long.MAX_VALUE / (singleByteAmount * 2),
8,
1,
5).register();
public static ItemCreativeFluidStorageCell CREATIVE_CELL = new ItemCreativeFluidStorageCell().register();
public static ItemBasicFluidStoragePart CELL_PART = new ItemBasicFluidStoragePart().register();
public static ItemFluidStorageHousing CELL_HOUSING = new ItemFluidStorageHousing().register();
public static void loadSetting() {
if (!Config.fluidCells) return;
@@ -0,0 +1,50 @@
package com.glodblock.github.loader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.util.Util;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class KeybindLoader implements Runnable {
public static KeyBinding openTerminal;
@Override
public void run() {
openTerminal = new KeyBinding("key.OpenTerminal", Keyboard.CHAR_NONE, "itemGroup.ae2fc");
ClientRegistry.registerKeyBinding(openTerminal);
FMLCommonHandler.instance().bus().register(this);
}
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
if (Minecraft.getMinecraft().currentScreen != null) return;
EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer;
if (p.openContainer == null) {
return;
}
if (openTerminal.isPressed()) {
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(p);
if (term != null && term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
ItemWirelessUltraTerminal.switchTerminal(
p,
((ItemWirelessUltraTerminal) term.getRight().getItem()).guiGuiType(term.getRight()));
}
}
}
}
@@ -1,9 +1,14 @@
package com.glodblock.github.loader;
import static com.glodblock.github.common.storage.CellType.Cell16384kPart;
import static com.glodblock.github.loader.ItemAndBlockHolder.*;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4KM;
import static net.minecraft.init.Blocks.redstone_torch;
import static net.minecraft.init.Items.fish;
import java.util.Arrays;
import java.util.Objects;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -12,8 +17,9 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.item.ItemBasicFluidStorageCell;
import com.glodblock.github.common.item.FCBaseItemCell;
import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.loader.recipe.WirelessTerminalRecipe;
import com.glodblock.github.util.ModAndClassUtil;
import cpw.mods.fml.common.registry.GameRegistry;
@@ -21,6 +27,8 @@ import extracells.registries.ItemEnum;
public class RecipeLoader implements Runnable {
public static final RecipeLoader INSTANCE = new RecipeLoader();
public static final ItemStack AE2_INTERFACE = GameRegistry
.findItemStack("appliedenergistics2", "tile.BlockInterface", 1);
public static final ItemStack AE2_PROCESS_ENG = new ItemStack(
@@ -59,10 +67,6 @@ public class RecipeLoader implements Runnable {
.findItemStack("appliedenergistics2", "tile.BlockQuartzGlass", 1);
public static final ItemStack AE2_LAMP_GLASS = GameRegistry
.findItemStack("appliedenergistics2", "tile.BlockQuartzLamp", 1);
public static final ItemStack AE2_CELL_HOUSING = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
1,
39);
public static final ItemStack AE2_CELL_1K = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
1,
@@ -85,6 +89,10 @@ public class RecipeLoader implements Runnable {
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"),
1,
380);
public static final ItemStack AE2_INTERFACE_TERMINAL = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"),
1,
480);
public static final ItemStack AE2_CRAFTING_CP_UNIT = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "tile.BlockCraftingUnit"),
1,
@@ -93,10 +101,22 @@ public class RecipeLoader implements Runnable {
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
1,
54);
public static final ItemStack AE2_WIRELESS_TERMINAL = GameRegistry
.findItemStack("appliedenergistics2", "item.ToolWirelessTerminal", 1);
public static final ItemStack AE2_ME_CHEST = GameRegistry
.findItemStack("appliedenergistics2", "tile.BlockChest", 1);
public static final ItemStack AE2_ENERGY_CELL = GameRegistry
.findItemStack("appliedenergistics2", "tile.BlockEnergyCell", 1);
public static final ItemStack AE2_MATTER_CONDENSER = GameRegistry
.findItemStack("appliedenergistics2", "tile.BlockCondenser", 1);
public static final ItemStack AE2_QUANTUM_RING = GameRegistry
.findItemStack("appliedenergistics2", "tile.BlockQuantumRing", 1);
public static final ItemStack AE2_DENSE_ENERGY_CELL = GameRegistry
.findItemStack("appliedenergistics2", "tile.BlockDenseEnergyCell", 1);
public static final ItemStack THE_WIRELESS_TERM = GameRegistry
.findItemStack("thaumicenergistics", "wireless.essentia.terminal", 1);
private static final ItemStack WCT_WIRELESS_TERM = GameRegistry
.findItemStack("ae2wct", "wirelessCraftingTerminal", 1);
public static final ItemStack BUCKET = new ItemStack(Items.bucket, 1);
public static final ItemStack IRON_BAR = new ItemStack(Blocks.iron_bars, 1);
@@ -128,6 +148,9 @@ public class RecipeLoader implements Runnable {
AE2_INTERFACE));
GameRegistry.addShapelessRecipe(FLUID_INTERFACE.stack(), INTERFACE.stack());
GameRegistry.addShapelessRecipe(INTERFACE.stack(), FLUID_INTERFACE.stack());
GameRegistry.addShapelessRecipe(WIRELESS_FLUID_TERM.stack(), AE2_WIRELESS_TERMINAL, BUCKET);
GameRegistry.addShapelessRecipe(WIRELESS_PATTERN_TERM.stack(), WIRELESS_FLUID_TERM, FLUID_TERMINAL);
GameRegistry.addShapelessRecipe(WIRELESS_INTERFACE_TERM.stack(), AE2_WIRELESS_TERMINAL, AE2_INTERFACE_TERMINAL);
GameRegistry
.addRecipe(new ShapedOreRecipe(CERTUS_QUARTZ_TANK.stack(), "GGG", "G G", "GGG", 'G', AE2_QUARTZ_GLASS));
GameRegistry.addShapelessRecipe(FLUID_AUTO_FILLER.stack(), FLUID_TERMINAL, ENCODER);
@@ -371,26 +394,143 @@ public class RecipeLoader implements Runnable {
'G',
AE2_LAMP_GLASS));
ItemBasicFluidStorageCell[] cells = new ItemBasicFluidStorageCell[] { CELL1K, CELL4K, CELL16K, CELL64K,
CELL256K, CELL1024K, CELL4096K, CELL16384K };
for (ItemBasicFluidStorageCell cell : cells) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dustRedstone",
'G',
AE2_QUARTZ_GLASS,
'C',
cell.getComponent(),
'I',
"ingotIron"));
GameRegistry.addRecipe(new ShapelessOreRecipe(cell, AE2_CELL_HOUSING, cell.getComponent()));
FCBaseItemCell[] cells = new FCBaseItemCell[] { CELL1K, CELL4K, CELL16K, CELL64K, CELL256K, CELL1024K,
CELL4096K, CELL16384K, CELL1KM, CELL4KM, CELL16KM, CELL64KM, CELL256KM, CELL1024KM, CELL4096KM,
CELL16384KM };
GameRegistry.addRecipe(
new ShapedOreRecipe(
QUANTUM_CELL.stack(),
"RCR",
"CEC",
"RCR",
'C',
Cell16384kPart.stack(1),
'E',
AE2_DENSE_ENERGY_CELL,
'R',
AE2_QUANTUM_RING));
GameRegistry.addRecipe(
new ShapedOreRecipe(
SINGULARITY_CELL.stack(),
"CCC",
"CMC",
"CCC",
'C',
QUANTUM_CELL,
'M',
AE2_MATTER_CONDENSER));
for (FCBaseItemCell cell : cells) {
if (cell.getHousing().getItemDamage() == 0) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dyeRed",
'G',
AE2_QUARTZ_GLASS,
'C',
cell.getComponent(),
'I',
"ingotIron"));
} else if (cell.getHousing().getItemDamage() == 1) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dustRedstone",
'G',
AE2_LAMP_GLASS,
'C',
cell.getComponent(),
'I',
"gemDiamond"));
} else if (cell.getHousing().getItemDamage() == 2) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dyeBlue",
'G',
AE2_QUARTZ_GLASS,
'C',
cell.getComponent(),
'I',
"ingotIron"));
} else if (cell.getHousing().getItemDamage() == 3) {
GameRegistry.addRecipe(
new ShapedOreRecipe(
cell,
"GDG",
"DCD",
"III",
'D',
"dustGlowstone",
'G',
AE2_LAMP_GLASS,
'C',
cell.getComponent(),
'I',
"gemDiamond"));
}
GameRegistry.addRecipe(new ShapelessOreRecipe(cell, cell.getHousing(), cell.getComponent()));
}
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL_HOUSING.stack(1, 0),
"GDG",
"D D",
"III",
'D',
"dyeRed",
'G',
AE2_QUARTZ_GLASS,
'I',
"ingotIron"));
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL_HOUSING.stack(1, 1),
"GDG",
"D D",
"III",
'D',
"dustRedstone",
'G',
AE2_LAMP_GLASS,
'I',
"gemDiamond"));
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL_HOUSING.stack(1, 2),
"GDG",
"D D",
"III",
'D',
"dyeBlue",
'G',
AE2_QUARTZ_GLASS,
'I',
"ingotIron"));
GameRegistry.addRecipe(
new ShapedOreRecipe(
CELL_HOUSING.stack(1, 3),
"GDG",
"D D",
"III",
'D',
"dustGlowstone",
'G',
AE2_LAMP_GLASS,
'I',
"gemDiamond"));
}
if (Config.fluidIOBus) {
@@ -442,4 +582,20 @@ public class RecipeLoader implements Runnable {
AE2_BLANK_PATTERN));
}
}
public static void runTerminalRecipe() {
if (ModAndClassUtil.WCT) {
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_PATTERN_TERM.stack()));
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_FLUID_TERM.stack()));
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_ULTRA_TERM.stack()));
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_INTERFACE_TERM.stack()));
}
ItemStack[] term = { AE2_WIRELESS_TERMINAL, WIRELESS_FLUID_TERM.stack(), WIRELESS_PATTERN_TERM.stack(),
WIRELESS_INTERFACE_TERM.stack(), THE_WIRELESS_TERM, WCT_WIRELESS_TERM };
GameRegistry.addShapelessRecipe(
WIRELESS_ULTRA_TERM.stack(),
Arrays.stream(term).filter(Objects::nonNull).toArray());
}
}
@@ -0,0 +1,66 @@
package com.glodblock.github.loader.recipe;
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
import java.util.Arrays;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
import net.p455w0rd.wirelesscraftingterminal.items.ItemInfinityBooster;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
public class WirelessTerminalRecipe extends ShapelessRecipes {
private static final ItemStack infinityBoosterCard = ItemEnum.BOOSTER_CARD.getStack();
private final ItemStack installedTerm;
public WirelessTerminalRecipe(ItemStack term) {
super(term, Arrays.asList(term, infinityBoosterCard));
this.installedTerm = installInfinityBoosterCard(term);
}
@Override
public boolean matches(InventoryCrafting inv, World w) {
ItemStack term = inv.getStackInSlot(0);
ItemStack infinityBoosterCard = inv.getStackInSlot(1);
return term != null && term.getItem() instanceof ItemBaseWirelessTerminal
&& !hasInfinityBoosterCard(term)
&& infinityBoosterCard != null
&& infinityBoosterCard.getItem() instanceof ItemInfinityBooster;
}
public static ItemStack getInfinityBoosterCard() {
return infinityBoosterCard.copy();
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
return installInfinityBoosterCard(inv.getStackInSlot(0));
}
@Override
public int getRecipeSize() {
return 2;
}
private ItemStack installInfinityBoosterCard(ItemStack is) {
is = is.copy();
NBTTagCompound data = Platform.openNbtData(is);
data.setBoolean(ItemBaseWirelessTerminal.infinityBoosterCard, true);
is.setTagCompound(data);
return is;
}
@Override
public ItemStack getRecipeOutput() {
return installedTerm;
}
}
@@ -0,0 +1,76 @@
package com.glodblock.github.nei;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketNEIRecipe;
import appeng.util.Platform;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.recipe.IRecipeHandler;
import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
public class FluidCraftingTransferHandler implements IOverlayHandler {
public static final FluidCraftingTransferHandler INSTANCE = new FluidCraftingTransferHandler();
@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
try {
final List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
if (firstGui instanceof GuiFluidCraftingWireless
&& FluidPatternTerminalRecipeTransferHandler.craftSet.contains(recipe.getOverlayIdentifier())) {
PacketNEIRecipe packet = new PacketNEIRecipe(packIngredients(firstGui, ingredients));
NetworkHandler.instance.sendToServer(packet);
}
} catch (final Exception | Error ignored) {
// NO-OP
}
}
private NBTTagCompound packIngredients(GuiContainer gui, List<PositionedStack> ingredients) throws IOException {
final NBTTagCompound recipe = new NBTTagCompound();
for (final PositionedStack positionedStack : ingredients) {
final int col = (positionedStack.relx - 25) / 18;
final int row = (positionedStack.rely - 6) / 18;
if (positionedStack.items != null && positionedStack.items.length > 0) {
for (final Object o : gui.inventorySlots.inventorySlots) {
if (o instanceof SlotCraftingMatrix || o instanceof SlotFakeCraftingMatrix) {
Slot slot = (Slot) o;
if (slot.getSlotIndex() == col + row * 3) {
final NBTTagList tags = new NBTTagList();
final List<ItemStack> list = new LinkedList<ItemStack>();
// prefer pure crystals.
for (int x = 0; x < positionedStack.items.length; x++) {
if (Platform.isRecipePrioritized(positionedStack.items[x])) {
list.add(0, positionedStack.items[x]);
} else {
list.add(positionedStack.items[x]);
}
}
for (final ItemStack is : list) {
final NBTTagCompound tag = new NBTTagCompound();
is.writeToNBT(tag);
tags.appendTag(tag);
}
recipe.setTag("#" + slot.getSlotIndex(), tags);
break;
}
}
}
}
}
return recipe;
}
}
@@ -35,7 +35,7 @@ public class FluidPatternTerminalRecipeTransferHandler implements IOverlayHandle
List<OrderStack<?>> in = FluidRecipe.getPackageInputs(recipe, recipeIndex, priority);
List<OrderStack<?>> out = FluidRecipe.getPackageOutputs(recipe, recipeIndex, !notUseOther(recipe));
boolean craft = shouldCraft(recipe);
FluidCraft.proxy.netHandler.sendToServer(new CPacketTransferRecipe(in, out, craft));
FluidCraft.proxy.netHandler.sendToServer(new CPacketTransferRecipe(in, out, craft, shift));
}
}
@@ -0,0 +1,62 @@
package com.glodblock.github.nei;
import java.util.regex.Pattern;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import codechicken.nei.SearchField;
import codechicken.nei.api.ItemFilter;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
public class NEIItemFilter implements SearchField.ISearchProvider {
@Override
public ItemFilter getFilter(String searchText) {
Pattern pattern = SearchField.getPattern(searchText);
return pattern == null ? null : new Filter(pattern);
}
@Override
public boolean isPrimary() {
return false;
}
public static class Filter implements ItemFilter {
Pattern pattern;
public Filter(Pattern pattern) {
this.pattern = pattern;
}
@Override
public boolean matches(ItemStack itemStack) {
if (itemStack.getItem() instanceof IStorageFluidCell) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(itemStack, null, StorageChannel.FLUIDS);
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
final IFluidCellInventory cellInventory = handler.getCellInv();
if (cellInventory != null) {
for (IAEFluidStack fluid : cellInventory.getContents()) {
boolean result = pattern.matcher(fluid.getFluidStack().getLocalizedName().toLowerCase())
.find();
if (result) return true;
}
}
}
}
return false;
}
}
}
Loaded 100 of 155 files, more files were not shown because too many files have changed in this diff. Show more