Compare commits

...

92 Commits

Author SHA1 Message Date
PrototypeTrousers da39d81d5f optimize JEI transfer handler so it doesnt lock up the client 2023-06-26 16:13:33 -03:00
PrototypeTrousers 1442248ec3 bump version 2023-06-17 08:12:34 -03:00
PrototypeTrousers 1500661e43 fix wireless terminals duping and voiding issues.
fixes #270
2023-06-16 17:57:13 -03:00
PrototypeTrousers a7c2824624 replace ItemEncodedPattern cache with something that actually works 2023-06-15 21:43:27 -03:00
PrototypeTrousers 9d2549bdd8 bump version 2023-05-26 19:46:34 -03:00
PrototypeTrousers a37a2b4e89 blindly attempt to fix wireless terminal voiding/duping 2023-05-26 19:46:34 -03:00
miozune aa6bad7a72 Fix CPU Clusters consisting only of addon blocks not being recognized (#274) 2023-05-24 07:27:20 -03:00
Rongmario e2e5eed351 Properly discard caches when reloading models (#278)
* Properly discard caches when reloading models

* Singleton reloading multiple AutoRotatingModels
2023-05-24 07:26:24 -03:00
Caedis b6de4ebf18 Fix single slabs and stairs to allow chest opening (#268) 2023-05-24 07:25:56 -03:00
PrototypeTrousers 4545d78a51 bump version 2023-04-24 09:43:23 -03:00
PrototypeTrousers 6dc75fe26e attempt to fix #253 2023-04-24 09:29:10 -03:00
Florian Kostenzer 0552282d9d fix: fix crash when requester node is removed (#262) 2023-04-24 09:18:17 -03:00
Hikari_Nova 8be01dfb87 Try to fix https://github.com/PrototypeTrousers/Applied-Energistics-2/issues/265. (#266) 2023-04-24 09:17:53 -03:00
PrototypeTrousers 4c5803b986 check if baubles mod is installed when using keybinds to open terminals 2023-04-24 09:17:18 -03:00
PrototypeTrousers 3b4b9a1bd5 add recursion check to item p2ps 2023-04-15 08:32:27 -03:00
osimon 2c7959e399 Interface shift-clicking QOL improvements (#248) 2023-03-28 18:27:36 -03:00
PrototypeTrousers 4649841341 Use anatawa's fork of forgegradel 2.3 2023-03-28 18:25:22 -03:00
PrototypeTrousers 3d4cfb2ee8 add the quantum link card to the quantum chamber tooltip 2023-03-28 18:24:51 -03:00
PrototypeTrousers 8092d0d354 Allow the quantum linking card to be disabled by config
Clean up some wrong tooltip
2023-03-28 18:02:36 -03:00
PrototypeTrousers ceee1f181f bump version. copy/paste some lang entries 2023-03-20 16:07:47 -03:00
Domi eefb11544e Add craftable items QOL features (tooltips / hold ALT to toggle craft request) (#241) 2023-03-20 16:01:06 -03:00
Xikaro af5921f9e8 fix ME Chest rendering (#246)
* Update dependencies.gradle

* fix ME Chest rendering
2023-03-20 15:58:40 -03:00
Domi 75be2ff039 Refresh crafting plan when job submission fails (#243) 2023-03-20 15:53:23 -03:00
Domi b6f4bdb64d Fix being unable to clear selected text in number boxes (#242) 2023-03-20 15:53:11 -03:00
PrototypeTrousers b76c9f1371 null check 2023-03-07 14:54:38 -03:00
PrototypeTrousers 50bf591418 bump version 2023-03-05 14:07:36 -03:00
RuiXuqi b077aff1f8 New cells models (#227)
new cells
2023-03-05 14:06:15 -03:00
PrototypeTrousers 8debd6c499 fix invisible interface config slots on servers 2023-02-28 20:00:31 -03:00
PrototypeTrousers 53ad6c776b fix magnet card crashing servers 2023-02-21 20:33:27 -03:00
PrototypeTrousers e37f8ef65d bump version 2023-02-21 10:19:36 -03:00
PrototypeTrousers d8b20f53a9 fix portable cell not working 2023-02-21 10:09:31 -03:00
PrototypeTrousers bf1a3b7751 fix outputs in processing terminal slowly migrating upwards 2023-02-21 09:58:54 -03:00
PrototypeTrousers c8a6d50ce3 fix wireless crafting terminal not loading sorting configs properly 2023-02-20 01:16:41 -03:00
PrototypeTrousers 13af30f657 try to fix the fix 2023-02-18 23:11:43 -03:00
PrototypeTrousers 5d7f552643 attempt to fix wireless terminals overwriting items in hand 2023-02-18 21:06:41 -03:00
Roman Hubenkov 82be548fc7 Update ru_ru.lang (#223)
Small fix
2023-02-18 21:06:13 -03:00
Roman Hubenkov 38249608e4 Update ru_ru.lang (#222) 2023-02-14 20:26:49 -03:00
mczph 8f66765696 Update zh_cn.lang (#221) 2023-02-14 20:26:29 -03:00
PrototypeTrousers fd5f9263d8 fix wireless pattern terminal not encoding processing outputs from JEI
bump version
2023-02-14 20:25:09 -03:00
PrototypeTrousers 36d94a17aa close wireless terminals if they run out of power instead of not working 2023-02-14 19:10:42 -03:00
PrototypeTrousers ede2b4ce25 fix OOB crash 2023-02-13 01:02:59 -03:00
PrototypeTrousers e09ec8c420 bump version 2023-02-10 06:32:35 -03:00
tier940 3d4c03e184 Update ja_jp.lang (#220)
* Update ja_jp.lang

* 組立室から組立機に変更

* 表記揺れの修正

* 記載揺れと誤字脱字の修正
2023-02-10 06:29:15 -03:00
PrototypeTrousers 17119fd990 more gui fixes... 2023-02-10 06:28:44 -03:00
PrototypeTrousers 9a00185b6d backport some security changes 2023-02-10 06:21:39 -03:00
PrototypeTrousers 2c7b239914 bump version 2023-02-09 19:20:17 -03:00
PrototypeTrousers 4039188712 more fixes yay 2023-02-09 13:02:55 -03:00
PrototypeTrousers ecb697ab11 fix terminal/netwoork tool (please) 2023-02-09 12:16:40 -03:00
PrototypeTrousers ab1f519401 allow wireless pattern terminal to switch substitution modes 2023-02-08 21:17:56 -03:00
Roman Hubenkov d06a70ee22 Update ru_ru.lang (#218)
* Update ru_ru.lang
2023-02-08 13:58:54 -03:00
PrototypeTrousers 422f9faf76 fix jei and tall interface terminal button overlapping 2023-02-08 13:58:04 -03:00
PrototypeTrousers 96ab73001b fix craftables not working when wireless terminal not being held
remove wrong imports
add missing lang entries
2023-02-08 12:14:36 -03:00
PrototypeTrousers 854676a33c terminal fixes + better formatting 2023-02-06 18:38:44 -03:00
PrototypeTrousers 7f76723da5 Merge branch 'WiFi-Terminals' into AE2-Omnifactory 2023-02-06 13:28:27 -03:00
PrototypeTrousers 3fc7cf0247 Merge branch 'cell-tooltips' into AE2-Omnifactory 2023-02-06 13:28:23 -03:00
PrototypeTrousers b377dfdd69 Merge branch 'bogofix' into AE2-Omnifactory 2023-02-06 13:28:17 -03:00
PrototypeTrousers 51522019ca fix wireless terminals not opening again 2023-02-06 13:27:52 -03:00
PrototypeTrousers 15dff5d53d fix JEI integration 2023-02-05 23:04:20 -03:00
PrototypeTrousers 7ab89a0657 update bogosort compat 2023-02-05 23:03:34 -03:00
PrototypeTrousers dcd36b3b2f wip 2023-02-03 23:08:13 -03:00
PrototypeTrousers 7b985c72bd fix slots and texture 2023-02-03 22:33:14 -03:00
PrototypeTrousers 269d3766db implement tall interface terminal (part, not wireless) 2023-02-03 20:56:17 -03:00
PrototypeTrousers d7e7ef0cb4 wip 2023-02-03 15:07:55 -03:00
PrototypeTrousers 472f1e65a2 more autocrafting fixes 2023-02-03 13:49:27 -03:00
PrototypeTrousers 56268aba79 fix autocrafting gui not opening 2023-02-03 12:53:04 -03:00
PrototypeTrousers 9d7dacdc29 Toggle magnet on/off from container/gui 2023-02-02 21:48:01 -03:00
PrototypeTrousers fb2aa21337 cleaning 2023-02-02 20:00:56 -03:00
PrototypeTrousers 8bad14f982 cursed recipes 2023-02-02 19:24:03 -03:00
PrototypeTrousers 0e797b2120 GUI/Container fixes Ugh 2023-02-02 18:22:20 -03:00
PrototypeTrousers 17c38a6418 wip 2023-02-02 16:19:56 -03:00
PrototypeTrousers 58a6dabb20 wip 2023-02-02 14:50:23 -03:00
PrototypeTrousers 329e613c99 recipes 2023-02-02 11:39:16 -03:00
PrototypeTrousers 11a4783881 more textures 2023-02-02 11:23:51 -03:00
PrototypeTrousers e230440cba add some textures 2023-02-01 22:27:01 -03:00
PrototypeTrousers 149e7d251a clean up 2023-02-01 21:43:47 -03:00
PrototypeTrousers 405f14bd13 safer comparisons 2023-02-01 21:19:09 -03:00
PrototypeTrousers acd77ff3f2 lock quantumbridge inventory to 1 card or singularity 2023-02-01 21:10:41 -03:00
PrototypeTrousers a0ec9ceb51 keybinds work 2023-01-31 23:24:27 -03:00
PrototypeTrousers d6f2ed30e5 make them bauble trinkets 2023-01-31 16:52:00 -03:00
PrototypeTrousers 9785e38e3f magnet filtering 2023-01-31 15:29:43 -03:00
PrototypeTrousers 1759bd898e magnetize magnet 2023-01-31 12:40:41 -03:00
PrototypeTrousers ae0d02e7d5 linking kinda works 2023-01-30 23:41:13 -03:00
PrototypeTrousers d76eec2145 wip 2023-01-30 21:56:31 -03:00
PrototypeTrousers d7e1554e41 save upgrades 2023-01-30 20:40:16 -03:00
PrototypeTrousers 9dee7f6c0e cards 2023-01-30 17:45:41 -03:00
PrototypeTrousers 13c3067068 add upgrade slots 2023-01-30 15:41:42 -03:00
PrototypeTrousers 7c4e5679a3 fluid terminal 2023-01-29 21:55:01 -03:00
PrototypeTrousers 03ed421331 more fixes 2023-01-29 21:55:01 -03:00
PrototypeTrousers 36197a5dc6 refresh status if a encoded pattern is put in the output slot 2023-01-29 21:55:01 -03:00
PrototypeTrousers f407a26a8f work on wireless pattern terminal 2023-01-29 21:55:01 -03:00
PrototypeTrousers cb1011295c wip 2023-01-29 21:55:01 -03:00
PrototypeTrousers 55a56ad79d Start implementing wireless terminals. 2023-01-29 21:55:01 -03:00
161 changed files with 5337 additions and 1524 deletions
+25
View File
@@ -0,0 +1,25 @@
name: Build mod
on: [ push, pull_request, workflow_dispatch ]
jobs:
build:
name: Build mod
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew -Pnet.minecraftforge.gradle.disableUpdateChecker=true build
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: appliedenergistics2
path: build/libs
-15
View File
@@ -1,15 +0,0 @@
name: 'Lock threads'
on:
schedule:
- cron: '0 0 * * *'
jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: '180'
pr-lock-inactive-days: '180'
+3 -1
View File
@@ -28,7 +28,9 @@ buildscript {
} }
} }
dependencies { dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' classpath("com.anatawa12.forge:ForgeGradle:2.3-1.0.+") {
changing = true
}
} }
} }
+1 -1
View File
@@ -4,7 +4,7 @@ aebuild=7
aegroup=appeng aegroup=appeng
aebasename=appliedenergistics2 aebasename=appliedenergistics2
extended=extended_life extended=extended_life
extendedversion=v0.54.20 extendedversion=v0.55.15
######################################################### #########################################################
# Versions # # Versions #
######################################################### #########################################################
+3 -4
View File
@@ -23,12 +23,10 @@ repositories {
url "https://cursemaven.com" url "https://cursemaven.com"
} }
/*
maven { maven {
name = "CurseForge" name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/" url = "https://minecraft.curseforge.com/api/maven/"
} }
*/
maven { maven {
name "Mobius" name "Mobius"
@@ -83,10 +81,11 @@ configurations {
dependencies { dependencies {
// deobfCompile "gregtechce:gregtech:1.12.2:1.15.1.735" // deobfCompile "gregtechce:gregtech:1.12.2:1.15.1.735"
// installable runtime dependencies // installable runtime dependencies
deobfCompile "curse.maven:gregtechceu-557242:3949406" deobfCompile "curse.maven:gregtechceu-557242:4429261"
compileOnly "curse.maven:chisel-235279:2915375" compileOnly "curse.maven:chisel-235279:2915375"
deobfCompile "curse.maven:baubles-227083:2518667"
//mods "mcp.mobius.waila:Hwyla:${hwyla_version}" //mods "mcp.mobius.waila:Hwyla:${hwyla_version}"
mods "curse.maven:hwyla-253449:2568751" mods "curse.maven:hwyla-253449:2568751"
mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev" mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev"
@@ -108,7 +107,7 @@ dependencies {
compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf" compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf"
compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}" compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}"
compileOnly "curse.maven:inventory-tweaks-223094:2482482" compileOnly "curse.maven:inventory-tweaks-223094:2482482"
compileOnly "curse.maven:inventory-bogo-sorter-632327:3975184" compileOnly "curse.maven:inventory-bogo-sorter-632327:4399738"
compileOnly "team.chisel.ctm:CTM:${ctm_version}" compileOnly "team.chisel.ctm:CTM:${ctm_version}"
compileOnly "de.ellpeck.actuallyadditions:ActuallyAdditions:1.12.2-r152.16:api" compileOnly "de.ellpeck.actuallyadditions:ActuallyAdditions:1.12.2-r152.16:api"
deobfCompile "net.sengir.forestry:forestry_${minecraft_version}:$forestry_version" deobfCompile "net.sengir.forestry:forestry_${minecraft_version}:$forestry_version"
+50 -55
View File
@@ -32,66 +32,61 @@ import net.minecraft.item.ItemStack;
import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItemDefinition;
public enum Upgrades public enum Upgrades {
{ /**
/** * Gold Tier Upgrades.
* Gold Tier Upgrades. */
*/ CAPACITY(0),
CAPACITY( 0 ), REDSTONE(0),
REDSTONE( 0 ), CRAFTING(0),
CRAFTING( 0 ), MAGNET(0),
/** /**
* Diamond Tier Upgrades. * Diamond Tier Upgrades.
*/ */
FUZZY( 1 ), FUZZY(1),
SPEED( 1 ), SPEED(1),
INVERTER( 1 ), INVERTER(1),
PATTERN_EXPANSION(1); PATTERN_EXPANSION(1),
QUANTUM_LINK(1);
private final int tier; private final int tier;
private final Map<ItemStack, Integer> supportedMax = new HashMap<>(); private final Map<ItemStack, Integer> supportedMax = new HashMap<>();
Upgrades( final int tier ) Upgrades(final int tier) {
{ this.tier = tier;
this.tier = tier; }
}
/** /**
* @return list of Items/Blocks that support this upgrade, and how many it supports. * @return list of Items/Blocks that support this upgrade, and how many it supports.
*/ */
public Map<ItemStack, Integer> getSupported() public Map<ItemStack, Integer> getSupported() {
{ return this.supportedMax;
return this.supportedMax; }
}
/** /**
* Registers a specific amount of this upgrade into a specific machine * Registers a specific amount of this upgrade into a specific machine
* *
* @param item machine in which this upgrade can be installed * @param item machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed * @param maxSupported amount how many upgrades can be installed
*/ */
public void registerItem( final IItemDefinition item, final int maxSupported ) public void registerItem(final IItemDefinition item, final int maxSupported) {
{ item.maybeStack(1).ifPresent(is -> this.registerItem(is, maxSupported));
item.maybeStack( 1 ).ifPresent( is -> this.registerItem( is, maxSupported ) ); }
}
/** /**
* Registers a specific amount of this upgrade into a specific machine * Registers a specific amount of this upgrade into a specific machine
* *
* @param stack machine in which this upgrade can be installed * @param stack machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed * @param maxSupported amount how many upgrades can be installed
*/ */
public void registerItem( final ItemStack stack, final int maxSupported ) public void registerItem(final ItemStack stack, final int maxSupported) {
{ if (stack != null) {
if( stack != null ) this.supportedMax.put(stack, maxSupported);
{ }
this.supportedMax.put( stack, maxSupported ); }
}
}
public int getTier() public int getTier() {
{ return this.tier;
return this.tier; }
}
} }
@@ -30,8 +30,7 @@ import appeng.api.util.AEColoredItemDefinition;
/** /**
* A list of all items in AE * A list of all items in AE
*/ */
public interface IItems public interface IItems {
{
IItemDefinition certusQuartzAxe(); IItemDefinition certusQuartzAxe();
IItemDefinition certusQuartzHoe(); IItemDefinition certusQuartzHoe();
@@ -64,6 +63,12 @@ public interface IItems
IItemDefinition wirelessTerminal(); IItemDefinition wirelessTerminal();
IItemDefinition wirelessCraftingTerminal();
IItemDefinition wirelessPatternTerminal();
IItemDefinition wirelessFluidTerminal();
IItemDefinition biometricCard(); IItemDefinition biometricCard();
IItemDefinition chargedStaff(); IItemDefinition chargedStaff();
@@ -27,121 +27,124 @@ package appeng.api.definitions;
/** /**
* A list of all materials in AE * A list of all materials in AE
*/ */
public interface IMaterials public interface IMaterials {
{ IItemDefinition cell2SpatialPart();
IItemDefinition cell2SpatialPart();
IItemDefinition cell16SpatialPart(); IItemDefinition cell16SpatialPart();
IItemDefinition cell128SpatialPart(); IItemDefinition cell128SpatialPart();
IItemDefinition silicon(); IItemDefinition silicon();
IItemDefinition skyDust(); IItemDefinition skyDust();
IItemDefinition calcProcessorPress(); IItemDefinition calcProcessorPress();
IItemDefinition engProcessorPress(); IItemDefinition engProcessorPress();
IItemDefinition logicProcessorPress(); IItemDefinition logicProcessorPress();
IItemDefinition calcProcessorPrint(); IItemDefinition calcProcessorPrint();
IItemDefinition engProcessorPrint(); IItemDefinition engProcessorPrint();
IItemDefinition logicProcessorPrint(); IItemDefinition logicProcessorPrint();
IItemDefinition siliconPress(); IItemDefinition siliconPress();
IItemDefinition siliconPrint(); IItemDefinition siliconPrint();
IItemDefinition namePress(); IItemDefinition namePress();
IItemDefinition logicProcessor(); IItemDefinition logicProcessor();
IItemDefinition calcProcessor(); IItemDefinition calcProcessor();
IItemDefinition engProcessor(); IItemDefinition engProcessor();
IItemDefinition basicCard(); IItemDefinition basicCard();
IItemDefinition advCard(); IItemDefinition advCard();
IItemDefinition purifiedCertusQuartzCrystal(); IItemDefinition purifiedCertusQuartzCrystal();
IItemDefinition purifiedNetherQuartzCrystal(); IItemDefinition purifiedNetherQuartzCrystal();
IItemDefinition purifiedFluixCrystal(); IItemDefinition purifiedFluixCrystal();
IItemDefinition cell1kPart(); IItemDefinition cell1kPart();
IItemDefinition cell4kPart(); IItemDefinition cell4kPart();
IItemDefinition cell16kPart(); IItemDefinition cell16kPart();
IItemDefinition cell64kPart(); IItemDefinition cell64kPart();
IItemDefinition emptyStorageCell(); IItemDefinition emptyStorageCell();
IItemDefinition cardRedstone(); IItemDefinition cardRedstone();
IItemDefinition cardSpeed(); IItemDefinition cardSpeed();
IItemDefinition cardCapacity(); IItemDefinition cardCapacity();
IItemDefinition cardPatternExpansion(); IItemDefinition cardPatternExpansion();
IItemDefinition cardFuzzy(); IItemDefinition cardQuantumLink();
IItemDefinition cardInverter(); IItemDefinition cardMagnet();
IItemDefinition cardCrafting(); IItemDefinition cardFuzzy();
IItemDefinition enderDust(); IItemDefinition cardInverter();
IItemDefinition flour(); IItemDefinition cardCrafting();
IItemDefinition goldDust(); IItemDefinition enderDust();
IItemDefinition ironDust(); IItemDefinition flour();
IItemDefinition fluixDust(); IItemDefinition goldDust();
IItemDefinition certusQuartzDust(); IItemDefinition ironDust();
IItemDefinition netherQuartzDust(); IItemDefinition fluixDust();
IItemDefinition matterBall(); IItemDefinition certusQuartzDust();
IItemDefinition certusQuartzCrystal(); IItemDefinition netherQuartzDust();
IItemDefinition certusQuartzCrystalCharged(); IItemDefinition matterBall();
IItemDefinition fluixCrystal(); IItemDefinition certusQuartzCrystal();
IItemDefinition fluixPearl(); IItemDefinition certusQuartzCrystalCharged();
IItemDefinition woodenGear(); IItemDefinition fluixCrystal();
IItemDefinition wirelessReceiver(); IItemDefinition fluixPearl();
IItemDefinition wirelessBooster(); IItemDefinition woodenGear();
IItemDefinition annihilationCore(); IItemDefinition wirelessReceiver();
IItemDefinition formationCore(); IItemDefinition wirelessBooster();
IItemDefinition singularity(); IItemDefinition annihilationCore();
IItemDefinition qESingularity(); IItemDefinition formationCore();
IItemDefinition blankPattern(); IItemDefinition singularity();
IItemDefinition fluidCell1kPart(); IItemDefinition qESingularity();
IItemDefinition fluidCell4kPart(); IItemDefinition blankPattern();
IItemDefinition fluidCell16kPart(); IItemDefinition fluidCell1kPart();
IItemDefinition fluidCell64kPart(); IItemDefinition fluidCell4kPart();
IItemDefinition fluidCell16kPart();
IItemDefinition fluidCell64kPart();
} }
@@ -28,47 +28,45 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import net.minecraftforge.fml.common.network.IGuiHandler;
/** /**
* A handler for a wireless terminal. * A handler for a wireless terminal.
*/ */
public interface IWirelessTermHandler extends INetworkEncodable public interface IWirelessTermHandler extends INetworkEncodable {
{
/** /**
* @param is wireless terminal * @param is wireless terminal
* * @return true, if usePower, hasPower, etc... can be called for the provided item
* @return true, if usePower, hasPower, etc... can be called for the provided item */
*/ boolean canHandle(ItemStack is);
boolean canHandle( ItemStack is );
/** /**
* use an amount of power, in AE units * use an amount of power, in AE units
* *
* @param amount is in AE units ( 5 per MJ ), if you return false, the item should be dead and return false for * @param amount is in AE units ( 5 per MJ ), if you return false, the item should be dead and return false for
* hasPower * hasPower
* @param is wireless terminal * @param is wireless terminal
* * @return true if wireless terminal uses power
* @return true if wireless terminal uses power */
*/ boolean usePower(EntityPlayer player, double amount, ItemStack is);
boolean usePower( EntityPlayer player, double amount, ItemStack is );
/** /**
* gets the power status of the item. * gets the power status of the item.
* *
* @param is wireless terminal * @param is wireless terminal
* * @return returns true if there is any power left.
* @return returns true if there is any power left. */
*/ boolean hasPower(EntityPlayer player, double amount, ItemStack is);
boolean hasPower( EntityPlayer player, double amount, ItemStack is );
/** /**
* Return the config manager for the wireless terminal. * Return the config manager for the wireless terminal.
* *
* @param is wireless terminal * @param is wireless terminal
* * @return config manager of wireless terminal
* @return config manager of wireless terminal */
*/ IConfigManager getConfigManager(ItemStack is);
IConfigManager getConfigManager( ItemStack is );
IGuiHandler getGuiHandler(ItemStack is);
} }
@@ -0,0 +1,7 @@
package appeng.api.implementations;
public interface IUpgradeableCellContainer {
int availableUpgrades();
void setupUpgrades();
}
@@ -0,0 +1,41 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.implementations;
import appeng.api.config.Upgrades;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.util.IConfigurableObject;
public interface IUpgradeableCellHost extends IConfigurableObject, ISegmentedInventory {
/**
* determine how many of an upgrade are installed.
*/
default int getInstalledUpgrades(Upgrades u) {
return 0;
}
}
@@ -22,6 +22,12 @@ package appeng.block;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs; import net.minecraft.block.BlockStairs;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import javax.annotation.Nonnull;
public abstract class AEBaseStairBlock extends BlockStairs { public abstract class AEBaseStairBlock extends BlockStairs {
@@ -43,4 +49,9 @@ public abstract class AEBaseStairBlock extends BlockStairs {
return this.getClass().getSimpleName() + "[" + regName + "]"; return this.getClass().getSimpleName() + "[" + regName + "]";
} }
@Override
public boolean doesSideBlockChestOpening(@Nonnull IBlockState blockState, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing side) {
return false;
}
} }
@@ -25,21 +25,31 @@ import appeng.bootstrap.components.StateMapperComponent;
import appeng.bootstrap.components.TesrComponent; import appeng.bootstrap.components.TesrComponent;
import appeng.client.render.model.AutoRotatingModel; import appeng.client.render.model.AutoRotatingModel;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.IStateMapper; import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.resource.IResourceType;
import net.minecraftforge.client.resource.ISelectiveResourceReloadListener;
import net.minecraftforge.client.resource.VanillaResourceType;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Predicate;
class BlockRendering implements IBlockRendering { class BlockRendering implements IBlockRendering, ISelectiveResourceReloadListener {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> modelCustomizer; private BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> modelCustomizer;
@@ -56,6 +66,13 @@ class BlockRendering implements IBlockRendering {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private final Map<String, IModel> builtInModels = new HashMap<>(); private final Map<String, IModel> builtInModels = new HashMap<>();
@SideOnly(Side.CLIENT)
private final List<IResourceManagerReloadListener> reloads = new ArrayList<>();
BlockRendering() {
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(this);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IBlockRendering modelCustomizer(BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer) { public IBlockRendering modelCustomizer(BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer) {
@@ -103,7 +120,11 @@ class BlockRendering implements IBlockRendering {
} else if (block instanceof AEBaseTileBlock) { } else if (block instanceof AEBaseTileBlock) {
// This is a default rotating model if the base-block uses an AE tile entity which exposes UP/FRONT as // This is a default rotating model if the base-block uses an AE tile entity which exposes UP/FRONT as
// extended props // extended props
factory.addModelOverride(block.getRegistryName().getResourcePath(), (l, m) -> new AutoRotatingModel(m)); factory.addModelOverride(block.getRegistryName().getResourcePath(), (l, m) -> {
AutoRotatingModel model = new AutoRotatingModel(m);
BlockRendering.this.reloads.add(model);
return model;
});
} }
// TODO : 1.12 // TODO : 1.12
@@ -117,4 +138,13 @@ class BlockRendering implements IBlockRendering {
factory.addBootstrapComponent(new StateMapperComponent(block, this.stateMapper)); factory.addBootstrapComponent(new StateMapperComponent(block, this.stateMapper));
} }
} }
@Override
@SideOnly(Side.CLIENT)
public void onResourceManagerReload(IResourceManager resourceManager, Predicate<IResourceType> resourcePredicate) {
if (resourcePredicate.test(VanillaResourceType.MODELS)) {
this.reloads.forEach(listener -> listener.onResourceManagerReload(resourceManager));
}
}
} }
+39 -1
View File
@@ -35,6 +35,7 @@ import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation; import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketTerminalUse;
import appeng.core.sync.packets.PacketValueConfig; import appeng.core.sync.packets.PacketValueConfig;
import appeng.entity.EntityFloatingItem; import appeng.entity.EntityFloatingItem;
import appeng.entity.EntityTinyTNTPrimed; import appeng.entity.EntityTinyTNTPrimed;
@@ -44,6 +45,8 @@ import appeng.helpers.HighlighterHandler;
import appeng.helpers.IMouseWheelItem; import appeng.helpers.IMouseWheelItem;
import appeng.hooks.TickHandler; import appeng.hooks.TickHandler;
import appeng.hooks.TickHandler.PlayerColor; import appeng.hooks.TickHandler.PlayerColor;
import appeng.items.tools.powered.Terminal;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.server.ServerHelper; import appeng.server.ServerHelper;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -59,12 +62,19 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.event.*; import net.minecraftforge.client.event.*;
import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.client.settings.KeyModifier;
import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import java.io.IOException; import java.io.IOException;
@@ -73,11 +83,17 @@ import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import static appeng.client.KeyBindings.WCT;
import static appeng.client.KeyBindings.WFT;
import static appeng.client.KeyBindings.WPT;
import static appeng.client.KeyBindings.WT;
public class ClientHelper extends ServerHelper { public class ClientHelper extends ServerHelper {
private final static String KEY_CATEGORY = "key.appliedenergistics2.category"; public final static String KEY_CATEGORY = "key.appliedenergistics2.category";
private final EnumMap<ActionKey, KeyBinding> bindings = new EnumMap<>(ActionKey.class); private final EnumMap<ActionKey, KeyBinding> bindings = new EnumMap<>(ActionKey.class);
private final List<KeyBinding> keyBindings = new ArrayList<>();
@Override @Override
public void preinit() { public void preinit() {
@@ -99,6 +115,11 @@ public class ClientHelper extends ServerHelper {
this.bindings.put(key, binding); this.bindings.put(key, binding);
} }
for (KeyBindings k : KeyBindings.values()) {
ClientRegistry.registerKeyBinding(k.getKeyBinding());
this.keyBindings.add(k.getKeyBinding());
}
Api.INSTANCE.definitions().items().encodedPattern().maybeItem().ifPresent(pattern -> Api.INSTANCE.definitions().items().encodedPattern().maybeItem().ifPresent(pattern ->
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(ItemEncodedPatternBakedModel.PATTERN_ITEM_COLOR_HANDLER, pattern)); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(ItemEncodedPatternBakedModel.PATTERN_ITEM_COLOR_HANDLER, pattern));
} }
@@ -319,6 +340,23 @@ public class ClientHelper extends ServerHelper {
} }
} }
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onInputEvent(final InputEvent.KeyInputEvent event) {
for (KeyBinding k : keyBindings) {
if (k.isPressed()) {
if (k == WT.getKeyBinding()) {
NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_TERMINAL));
} else if (k == WCT.getKeyBinding()) {
NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_CRAFTING_TERMINAL));
} else if (k == WPT.getKeyBinding()) {
NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_PATTERN_TERMINAL));
} else if (k == WFT.getKeyBinding()) {
NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_FLUID_TERMINAL));
}
}
}
}
@SubscribeEvent @SubscribeEvent
public void onTextureStitch(final TextureStitchEvent.Pre event) { public void onTextureStitch(final TextureStitchEvent.Pre event) {
ParticleTextures.registerSprite(event); ParticleTextures.registerSprite(event);
@@ -0,0 +1,28 @@
package appeng.client;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.client.settings.KeyModifier;
import org.lwjgl.input.Keyboard;
import static appeng.client.ClientHelper.KEY_CATEGORY;
public enum KeyBindings {
WT(new KeyBinding("key.open_wireless_terminal.desc", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_T, KEY_CATEGORY)),
WCT(new KeyBinding("key.open_wireless_crafting_terminal.desc", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_E, KEY_CATEGORY)),
WPT(new KeyBinding("key.open_wireless_pattern_terminal.desc", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_R, KEY_CATEGORY)),
WFT(new KeyBinding("key.open_wireless_fluid_terminal.desc", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_F, KEY_CATEGORY));
private KeyBinding keyBinding;
KeyBindings(KeyBinding keyBinding) {
this.keyBinding = keyBinding;
}
;
public KeyBinding getKeyBinding() {
return keyBinding;
}
}
@@ -49,6 +49,7 @@ import mezz.jei.api.gui.IGhostIngredientHandler;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@@ -568,7 +569,10 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
action = (mouseButton == 1) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; action = (mouseButton == 1) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ((SlotME) slot).getAEStack(); stack = ((SlotME) slot).getAEStack();
if (stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack().isEmpty()) { if (stack != null
&& action == InventoryAction.PICKUP_OR_SET_DOWN
&& (stack.getStackSize() == 0 || GuiScreen.isAltKeyDown())
&& player.inventory.getItemStack().isEmpty()) {
action = InventoryAction.AUTO_CRAFT; action = InventoryAction.AUTO_CRAFT;
} }
@@ -76,6 +76,11 @@ public abstract class AEBaseMEGui extends AEBaseGui {
currentToolTip.add(format); currentToolTip.add(format);
} }
if (myStack.isCraftable() && AEConfig.instance().isShowCraftableTooltip()) {
final String local = ButtonToolTips.ItemsCraftable.getLocal();
currentToolTip.add(TextFormatting.GRAY + local);
}
this.drawHoveringText(currentToolTip, x, y, this.fontRenderer); this.drawHoveringText(currentToolTip, x, y, this.fontRenderer);
return; return;
@@ -22,6 +22,7 @@ package appeng.client.gui.implementations;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts; import appeng.api.definitions.IParts;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui; import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox; import appeng.client.gui.widgets.GuiNumberBox;
@@ -97,9 +98,8 @@ public class GuiCraftAmount extends AEBaseGui {
final IParts parts = definitions.parts(); final IParts parts = definitions.parts();
if (target instanceof WirelessTerminalGuiObject) { if (target instanceof WirelessTerminalGuiObject) {
myIcon = definitions.items().wirelessTerminal().maybeStack(1).orElse(myIcon); myIcon = ((WirelessTerminalGuiObject) target).getItemStack();
this.originalGui = (GuiBridge) AEApi.instance().registries().wireless().getWirelessTerminalHandler(myIcon).getGuiHandler(myIcon);
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
} }
if (target instanceof PartTerminal) { if (target instanceof PartTerminal) {
@@ -20,6 +20,7 @@ package appeng.client.gui.implementations;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
@@ -84,7 +85,8 @@ public class GuiCraftConfirm extends AEBaseGui {
this.ccc.setGui(this); this.ccc.setGui(this);
if (te instanceof WirelessTerminalGuiObject) { if (te instanceof WirelessTerminalGuiObject) {
this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM; ItemStack itemStack = ((WirelessTerminalGuiObject) te).getItemStack();
this.OriginalGui = (GuiBridge) AEApi.instance().registries().wireless().getWirelessTerminalHandler(itemStack).getGuiHandler(itemStack);
} }
if (te instanceof PartTerminal) { if (te instanceof PartTerminal) {
@@ -26,6 +26,7 @@ package appeng.client.gui.implementations;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts; import appeng.api.definitions.IParts;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiScrollbar; import appeng.client.gui.widgets.GuiScrollbar;
@@ -33,6 +34,7 @@ import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerCraftingStatus; import appeng.container.implementations.ContainerCraftingStatus;
import appeng.container.implementations.CraftingCPUStatus; import appeng.container.implementations.CraftingCPUStatus;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.features.registries.WirelessRegistry;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
@@ -84,9 +86,8 @@ public class GuiCraftingStatus extends GuiCraftingCPU {
final IParts parts = definitions.parts(); final IParts parts = definitions.parts();
if (target instanceof WirelessTerminalGuiObject) { if (target instanceof WirelessTerminalGuiObject) {
this.myIcon = definitions.items().wirelessTerminal().maybeStack(1).orElse(ItemStack.EMPTY); myIcon = ((WirelessTerminalGuiObject) target).getItemStack();
this.originalGui = (GuiBridge) AEApi.instance().registries().wireless().getWirelessTerminalHandler(myIcon).getGuiHandler(myIcon);
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
} }
if (target instanceof PartTerminal) { if (target instanceof PartTerminal) {
@@ -82,8 +82,4 @@ public class GuiCraftingTerm extends GuiMEMonitorable {
protected String getBackground() { protected String getBackground() {
return "guis/crafting.png"; return "guis/crafting.png";
} }
public ItemRepo getRepo() {
return this.repo;
}
} }
@@ -22,6 +22,7 @@ package appeng.client.gui.implementations;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.ActionItems; import appeng.api.config.ActionItems;
import appeng.api.config.Settings; import appeng.api.config.Settings;
import appeng.api.config.TerminalStyle;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.client.gui.AEBaseGui; import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton; import appeng.client.gui.widgets.GuiImgButton;
@@ -30,6 +31,8 @@ import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.me.ClientDCInternalInv; import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected; import appeng.client.me.SlotDisconnected;
import appeng.container.implementations.ContainerInterfaceTerminal; import appeng.container.implementations.ContainerInterfaceTerminal;
import appeng.container.slot.AppEngSlot;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.helpers.DualityInterface; import appeng.helpers.DualityInterface;
import appeng.parts.reporting.PartInterfaceTerminal; import appeng.parts.reporting.PartInterfaceTerminal;
@@ -39,6 +42,7 @@ import com.google.common.collect.HashMultimap;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
@@ -46,10 +50,19 @@ import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.common.Loader;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import java.awt.*;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import static appeng.client.render.BlockPosHighlighter.hilightBlock; import static appeng.client.render.BlockPosHighlighter.hilightBlock;
import static appeng.helpers.ItemStackHelper.stackFromNBT; import static appeng.helpers.ItemStackHelper.stackFromNBT;
@@ -57,10 +70,15 @@ import static appeng.helpers.ItemStackHelper.stackFromNBT;
public class GuiInterfaceTerminal extends AEBaseGui { public class GuiInterfaceTerminal extends AEBaseGui {
private static final int LINES_ON_PAGE = 6; private int rows = 6;
// TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded? // TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded?
private final int offsetX = 21; private final int offsetX = 21;
private int maxRows = Integer.MAX_VALUE;
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
private int reservedSpace = 0;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>(); private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create(); private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
@@ -79,7 +97,10 @@ public class GuiInterfaceTerminal extends AEBaseGui {
private final PartInterfaceTerminal partInterfaceTerminal; private final PartInterfaceTerminal partInterfaceTerminal;
private GuiButton guiButtonHide; private GuiButton guiButtonHide;
private GuiButton guiButtonNextAssembler; private GuiButton guiButtonNextAssembler;
private GuiImgButton terminalStyleBox;
private final HashMap<ClientDCInternalInv, Integer> dimHashMap = new HashMap<>(); private final HashMap<ClientDCInternalInv, Integer> dimHashMap = new HashMap<>();
private int drawnRows = 0;
public GuiInterfaceTerminal(final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te) { public GuiInterfaceTerminal(final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te) {
super(new ContainerInterfaceTerminal(inventoryPlayer, te)); super(new ContainerInterfaceTerminal(inventoryPlayer, te));
@@ -89,10 +110,33 @@ public class GuiInterfaceTerminal extends AEBaseGui {
this.setScrollBar(scrollbar); this.setScrollBar(scrollbar);
this.xSize = 208; this.xSize = 208;
this.ySize = 255; this.ySize = 255;
this.setReservedSpace(82);
} }
@Override @Override
public void initGui() { public void initGui() {
this.maxRows = AEConfig.instance()
.getConfigManager()
.getSetting(
Settings.TERMINAL_STYLE) != TerminalStyle.TALL ? 6 : Integer.MAX_VALUE;
final int magicNumber = 82 + 14;
final int extraSpace = this.height - magicNumber - this.reservedSpace;
this.rows = (int) Math.floor(extraSpace / 18);
if (this.rows > this.maxRows) {
this.rows = this.maxRows;
}
if (this.rows < 6) {
this.rows = 6;
}
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
// this.guiTop = top;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
super.initGui(); super.initGui();
this.getScrollBar().setLeft(189); this.getScrollBar().setLeft(189);
@@ -115,6 +159,17 @@ public class GuiInterfaceTerminal extends AEBaseGui {
this.searchFieldInputs.setText(partInterfaceTerminal.in); this.searchFieldInputs.setText(partInterfaceTerminal.in);
this.searchFieldOutputs.setText(partInterfaceTerminal.out); this.searchFieldOutputs.setText(partInterfaceTerminal.out);
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), this.offsetX + 2, this.ySize - 96 + 3, 4210752);
}
protected void repositionSlot(final AppEngSlot s) {
this.ySize = 82 + 14 + this.drawnRows * 18 + this.reservedSpace;
s.yPos = s.getY() + this.ySize - 112;
s.xPos = s.getX() + 14;
} }
@Override @Override
@@ -123,13 +178,18 @@ public class GuiInterfaceTerminal extends AEBaseGui {
super.onGuiClosed(); super.onGuiClosed();
} }
@Override
public List<Rectangle> getJEIExclusionArea() {
Rectangle tallButton = new Rectangle(this.guiLeft - 18, this.guiTop + 24 + jeiOffset, 18, 18);
List<Rectangle> area = new ArrayList<>();
area.add(tallButton);
return area;
}
@Override @Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.buttonList.clear(); this.buttonList.clear();
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), this.offsetX + 2, this.ySize - 96 + 3, 4210752);
final int currentScroll = this.getScrollBar().getCurrentScroll(); final int currentScroll = this.getScrollBar().getCurrentScroll();
this.guiButtonNextAssembler = new GuiImgButton(guiLeft + 123, guiTop + 25, Settings.ACTIONS, ActionItems.FREE_MOLECULAR_SLOT_SHORTCUT); this.guiButtonNextAssembler = new GuiImgButton(guiLeft + 123, guiTop + 25, Settings.ACTIONS, ActionItems.FREE_MOLECULAR_SLOT_SHORTCUT);
@@ -138,11 +198,23 @@ public class GuiInterfaceTerminal extends AEBaseGui {
guiButtonHide = new GuiImgButton(guiLeft + 141, guiTop + 25, Settings.ACTIONS, this.partInterfaceTerminal.onlyInterfacesWithFreeSlots ? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF : ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON); guiButtonHide = new GuiImgButton(guiLeft + 141, guiTop + 25, Settings.ACTIONS, this.partInterfaceTerminal.onlyInterfacesWithFreeSlots ? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF : ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
this.buttonList.add(guiButtonHide); this.buttonList.add(guiButtonHide);
this.buttonList.add(this.terminalStyleBox = new GuiImgButton(this.guiLeft - 18, guiTop + 24 + jeiOffset, Settings.TERMINAL_STYLE, AEConfig.instance()
.getConfigManager()
.getSetting(Settings.TERMINAL_STYLE)));
this.inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected); this.inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
for (final Slot s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (s.xPos < 197) {
this.repositionSlot((AppEngSlot) s);
}
}
}
int offset = 52; int offset = 52;
int linesDraw = 0; int linesDraw = 0;
for (int x = 0; x < LINES_ON_PAGE && linesDraw < LINES_ON_PAGE && currentScroll + x < this.lines.size(); x++) { for (int x = 0; x < rows && linesDraw < rows && currentScroll + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(currentScroll + x); final Object lineObj = this.lines.get(currentScroll + x);
if (lineObj instanceof ClientDCInternalInv) { if (lineObj instanceof ClientDCInternalInv) {
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj; final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
@@ -152,7 +224,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
this.buttonList.add(guiButton); this.buttonList.add(guiButton);
int extraLines = numUpgradesMap.get(inv); int extraLines = numUpgradesMap.get(inv);
for (int row = 0; row < 1 + extraLines && linesDraw < LINES_ON_PAGE; ++row) { for (int row = 0; row < 1 + extraLines && linesDraw < rows; ++row) {
for (int z = 0; z < 9; z++) { for (int z = 0; z < 9; z++) {
this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), (z * 18 + 22), offset)); this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), (z * 18 + 22), offset));
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) { if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) {
@@ -227,6 +299,25 @@ public class GuiInterfaceTerminal extends AEBaseGui {
mc.player.closeScreen(); mc.player.closeScreen();
} }
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum cv = iBtn.getCurrentValue();
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance().getConfigManager().putSetting(iBtn.getSetting(), next);
}
iBtn.set(next);
if (next.getClass() == TerminalStyle.class) {
this.reinitalize();
}
}
}
if (btn == guiButtonHide) { if (btn == guiButtonHide) {
partInterfaceTerminal.onlyInterfacesWithFreeSlots = !partInterfaceTerminal.onlyInterfacesWithFreeSlots; partInterfaceTerminal.onlyInterfacesWithFreeSlots = !partInterfaceTerminal.onlyInterfacesWithFreeSlots;
this.refreshList(); this.refreshList();
@@ -247,15 +338,21 @@ public class GuiInterfaceTerminal extends AEBaseGui {
} }
} }
private void reinitalize() {
this.buttonList.clear();
this.initGui();
}
@Override @Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/newinterfaceterminal.png"); this.bindTexture("guis/newinterfaceterminal.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize); //split the texture for the top
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 166);
int offset = 51; int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll(); final int ex = this.getScrollBar().getCurrentScroll();
int linesDraw = 0; int linesDraw = 0;
for (int x = 0; x < LINES_ON_PAGE && linesDraw < LINES_ON_PAGE && ex + x < this.lines.size(); x++) { for (int x = 0; x < rows && linesDraw < rows && ex + x < this.lines.size(); x++) {
final Object lineObj = this.lines.get(ex + x); final Object lineObj = this.lines.get(ex + x);
if (lineObj instanceof ClientDCInternalInv) { if (lineObj instanceof ClientDCInternalInv) {
GlStateManager.color(1, 1, 1, 1); GlStateManager.color(1, 1, 1, 1);
@@ -263,16 +360,38 @@ public class GuiInterfaceTerminal extends AEBaseGui {
int extraLines = numUpgradesMap.get(lineObj); int extraLines = numUpgradesMap.get(lineObj);
for (int row = 0; row < 1 + extraLines && linesDraw < LINES_ON_PAGE; ++row) { for (int row = 0; row < 1 + extraLines && linesDraw < rows; ++row) {
if (linesDraw == 6) {
this.drawTexturedModalRect(offsetX, offsetY + offset + 7, 0, 166, 190, 7);
this.drawTexturedModalRect(offsetX, offsetY + offset + 14, 0, 166, 190, 4);
} else if (linesDraw >= 7) {
this.drawTexturedModalRect(offsetX, offsetY + offset, 0, 173, 190, 18);
}
this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 173, width, 18); this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 173, width, 18);
offset += 18; offset += 18;
linesDraw++; linesDraw++;
} }
} else { } else {
if (linesDraw == 6) {
this.drawTexturedModalRect(offsetX, offsetY + offset + 7, 0, 166, 190, 7);
this.drawTexturedModalRect(offsetX, offsetY + offset + 14, 0, 166, 190, 4);
this.drawTexturedModalRect(offsetX, offsetY + offset, 0, 53, 183, 18);
} else if (linesDraw >= 7) {
this.drawTexturedModalRect(offsetX, offsetY + offset, 0, 53, 183, 18);
this.drawTexturedModalRect(offsetX + 183, offsetY + offset, 183, 166, 7, 18);
}
offset += 18; offset += 18;
linesDraw++; linesDraw++;
} }
} }
offset = 51 + Math.max(6 * 18, linesDraw * 18);
if (linesDraw > 6) {
this.drawTexturedModalRect(offsetX, offsetY + offset, 0, 166, 190, 7);
}
this.drawTexturedModalRect(offsetX, offsetY + offset + 7, 0, 166, this.xSize, 90);
this.drawnRows = Math.max(6, linesDraw);
if (this.searchFieldInputs != null) { if (this.searchFieldInputs != null) {
this.searchFieldInputs.drawTextBox(); this.searchFieldInputs.drawTextBox();
@@ -445,7 +564,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
final NBTTagCompound encodedValue = itemStack.getTagCompound(); final NBTTagCompound encodedValue = itemStack.getTagCompound();
if (encodedValue == null) { if (encodedValue == null) {
return false; return searchTerm.matches(GuiText.InvalidPattern.getLocal());
} }
NBTTagList tag = new NBTTagList(); NBTTagList tag = new NBTTagList();
@@ -523,4 +642,12 @@ public class GuiInterfaceTerminal extends AEBaseGui {
return o; return o;
} }
int getReservedSpace() {
return this.reservedSpace;
}
void setReservedSpace(final int reservedSpace) {
this.reservedSpace = reservedSpace;
}
} }
@@ -442,7 +442,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
return this.repo.hasPower(); return this.repo.hasPower();
} }
int getMaxRows() { protected int getMaxRows() {
return AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE; return AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
} }
@@ -20,22 +20,17 @@ package appeng.client.gui.implementations;
import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.implementations.ContainerMEPortableCell;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
public class GuiMEPortableCell extends GuiMEMonitorable { public class GuiMEPortableCell extends GuiMEMonitorable {
public GuiMEPortableCell(final InventoryPlayer inventoryPlayer, final IPortableCell te) { public GuiMEPortableCell(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
super(inventoryPlayer, te, new ContainerMEPortableCell(inventoryPlayer, te)); super(inventoryPlayer, te);
}
int defaultGetMaxRows() {
return super.getMaxRows();
} }
@Override @Override
int getMaxRows() { protected int getMaxRows() {
return 3; return 3;
} }
} }
@@ -25,7 +25,9 @@ import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton; import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton; import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerPatternEncoder;
import appeng.container.implementations.ContainerPatternTerm; import appeng.container.implementations.ContainerPatternTerm;
import appeng.container.implementations.ContainerWirelessPatternTerminal;
import appeng.container.interfaces.IJEIGhostIngredients; import appeng.container.interfaces.IJEIGhostIngredients;
import appeng.container.slot.AppEngSlot; import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotFake; import appeng.container.slot.SlotFake;
@@ -35,6 +37,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction; import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketValueConfig; import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.InventoryAction; import appeng.helpers.InventoryAction;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import mezz.jei.api.gui.IGhostIngredientHandler.Target; import mezz.jei.api.gui.IGhostIngredientHandler.Target;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
@@ -60,7 +63,7 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
private static final String CRAFTMODE_CRFTING = "1"; private static final String CRAFTMODE_CRFTING = "1";
private static final String CRAFTMODE_PROCESSING = "0"; private static final String CRAFTMODE_PROCESSING = "0";
private final ContainerPatternTerm container; private final ContainerPatternEncoder container;
private GuiTabButton tabCraftButton; private GuiTabButton tabCraftButton;
private GuiTabButton tabProcessButton; private GuiTabButton tabProcessButton;
@@ -83,6 +86,12 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
this.setReservedSpace(81); this.setReservedSpace(81);
} }
public GuiPatternTerm(final InventoryPlayer inventoryPlayer, WirelessTerminalGuiObject te, final ContainerWirelessPatternTerminal wpt) {
super(inventoryPlayer, te, wpt);
this.container = (ContainerWirelessPatternTerminal) this.inventorySlots;
this.setReservedSpace(81);
}
@Override @Override
protected void actionPerformed(final GuiButton btn) { protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn); super.actionPerformed(btn);
@@ -41,7 +41,7 @@ public class GuiQNB extends AEBaseGui {
@Override @Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture("guis/chest.png"); this.bindTexture("guis/qbgui.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize); this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
} }
} }
@@ -0,0 +1,93 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.gui.implementations;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.me.ItemRepo;
import appeng.container.implementations.ContainerWirelessCraftingTerminal;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.InventoryAction;
import appeng.helpers.WirelessTerminalGuiObject;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
public class GuiWirelessCraftingTerminal extends GuiMEMonitorable {
private GuiImgButton clearBtn;
public GuiWirelessCraftingTerminal(final InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject te) {
super(inventoryPlayer, te, new ContainerWirelessCraftingTerminal(inventoryPlayer, te));
this.setReservedSpace(73);
}
@Override
protected void actionPerformed(final GuiButton btn) {
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
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.fontRenderer.drawString(GuiText.CraftingTerminal.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(), 4210752);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/wirelessupgrades.png");
Gui.drawModalRectWithCustomSizedTexture(offsetX + 198, offsetY + 127, 0, 0, 32, 32, 32, 32);
super.drawBG(offsetX, offsetY, mouseX, mouseY);
}
@Override
protected String getBackground() {
return "guis/crafting.png";
}
}
@@ -0,0 +1,41 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.gui.implementations;
import appeng.container.implementations.ContainerWirelessPatternTerminal;
import appeng.helpers.WirelessTerminalGuiObject;
import net.minecraft.client.gui.Gui;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiWirelessPatternTerminal extends GuiPatternTerm {
public GuiWirelessPatternTerminal(final InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject te) {
super(inventoryPlayer, te, new ContainerWirelessPatternTerminal(inventoryPlayer, te));
this.setReservedSpace(81);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/wirelessupgrades.png");
Gui.drawModalRectWithCustomSizedTexture(offsetX + 198, offsetY + 127, 0, 0, 32, 32, 32, 32);
super.drawBG(offsetX, offsetY, mouseX, mouseY);
}
}
@@ -20,17 +20,22 @@ package appeng.client.gui.implementations;
import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.implementations.ContainerWirelessTerm;
import appeng.helpers.WirelessTerminalGuiObject;
import net.minecraft.client.gui.Gui;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
public class GuiWirelessTerm extends GuiMEPortableCell { public class GuiWirelessTerm extends GuiMEMonitorable {
public GuiWirelessTerm(final InventoryPlayer inventoryPlayer, final IPortableCell te) { public GuiWirelessTerm(final InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject te) {
super(inventoryPlayer, te); super(inventoryPlayer, te, new ContainerWirelessTerm(inventoryPlayer, te));
} }
@Override @Override
int getMaxRows() { public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
return this.defaultGetMaxRows(); this.bindTexture("guis/wirelessupgrades.png");
Gui.drawModalRectWithCustomSizedTexture(offsetX + 198, offsetY + 127, 0, 0, 32, 32, 32, 32);
super.drawBG(offsetX, offsetY, mouseX, mouseY);
} }
} }
@@ -37,6 +37,9 @@ public class GuiNumberBox extends GuiTextField {
final String original = this.getText(); final String original = this.getText();
super.writeText(selectedText); super.writeText(selectedText);
if (this.getText().isEmpty()) {
return;
}
try { try {
if (this.type == int.class || this.type == Integer.class) { if (this.type == int.class || this.type == Integer.class) {
Integer.parseInt(this.getText()); Integer.parseInt(this.getText());
@@ -26,6 +26,7 @@ import appeng.util.ISlimReadableNumberConverter;
import appeng.util.IWideReadableNumberConverter; import appeng.util.IWideReadableNumberConverter;
import appeng.util.ReadableNumberConverter; import appeng.util.ReadableNumberConverter;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@@ -48,7 +49,7 @@ public class StackSizeRenderer {
final boolean unicodeFlag = fontRenderer.getUnicodeFlag(); final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
fontRenderer.setUnicodeFlag(false); fontRenderer.setUnicodeFlag(false);
if (aeStack.getStackSize() == 0 && aeStack.isCraftable()) { if ((aeStack.getStackSize() == 0 || GuiScreen.isAltKeyDown()) && aeStack.isCraftable()) {
final String craftLabelText = AEConfig.instance().useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft final String craftLabelText = AEConfig.instance().useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft
.getLocal(); .getLocal();
GlStateManager.disableLighting(); GlStateManager.disableLighting();
@@ -64,8 +65,7 @@ public class StackSizeRenderer {
GlStateManager.enableDepth(); GlStateManager.enableDepth();
GlStateManager.enableBlend(); GlStateManager.enableBlend();
} }
else if (aeStack.getStackSize() > 0) {
if (aeStack.getStackSize() > 0) {
final String stackSize = this.getToBeRenderedStackSize(aeStack.getStackSize()); final String stackSize = this.getToBeRenderedStackSize(aeStack.getStackSize());
GlStateManager.disableLighting(); GlStateManager.disableLighting();
@@ -45,7 +45,7 @@ import java.util.Map.Entry;
public class CableBusBakedModel implements IBakedModel { public class CableBusBakedModel implements IBakedModel {
private static final Map<CableBusRenderState, List<BakedQuad>> CABLE_MODEL_CACHE = new HashMap<>(); static final Map<CableBusRenderState, List<BakedQuad>> CABLE_MODEL_CACHE = new HashMap<>();
private final CableBuilder cableBuilder; private final CableBuilder cableBuilder;
@@ -27,21 +27,26 @@ import com.google.common.collect.ImmutableMap;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.resource.IResourceType;
import net.minecraftforge.client.resource.ISelectiveResourceReloadListener;
import net.minecraftforge.client.resource.VanillaResourceType;
import net.minecraftforge.common.model.IModelState; import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.common.model.TRSRTransformation;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate;
/** /**
* The built-in model for the cable bus block. * The built-in model for the cable bus block.
*/ */
public class CableBusModel implements IModel { public class CableBusModel implements IModel, ISelectiveResourceReloadListener {
private final PartModels partModels; private final PartModels partModels;
@@ -101,4 +106,12 @@ public class CableBusModel implements IModel {
public IModelState getDefaultState() { public IModelState getDefaultState() {
return TRSRTransformation.identity(); return TRSRTransformation.identity();
} }
@Override
public void onResourceManagerReload(IResourceManager resourceManager, Predicate<IResourceType> resourcePredicate) {
if (resourcePredicate.test(VanillaResourceType.MODELS)) {
CableBusBakedModel.CABLE_MODEL_CACHE.clear();
}
}
} }
@@ -33,6 +33,8 @@ import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.Vec3i; import net.minecraft.util.math.Vec3i;
import net.minecraftforge.client.model.pipeline.IVertexConsumer; import net.minecraftforge.client.model.pipeline.IVertexConsumer;
@@ -46,7 +48,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class AutoRotatingModel implements IBakedModel { public class AutoRotatingModel implements IBakedModel, IResourceManagerReloadListener {
private final IBakedModel parent; private final IBakedModel parent;
private final LoadingCache<AutoRotatingCacheKey, List<BakedQuad>> quadCache; private final LoadingCache<AutoRotatingCacheKey, List<BakedQuad>> quadCache;
@@ -152,6 +154,11 @@ public class AutoRotatingModel implements IBakedModel {
return this.quadCache.getUnchecked(key); return this.quadCache.getUnchecked(key);
} }
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
this.quadCache.invalidateAll();
}
public static class VertexRotator extends QuadGatheringTransformer { public static class VertexRotator extends QuadGatheringTransformer {
private final FacingToRotation f2r; private final FacingToRotation f2r;
private final EnumFacing face; private final EnumFacing face;
@@ -18,7 +18,6 @@
package appeng.client.render.model; package appeng.client.render.model;
import appeng.block.storage.BlockDrive; import appeng.block.storage.BlockDrive;
import appeng.block.storage.DriveSlotState; import appeng.block.storage.DriveSlotState;
import appeng.block.storage.DriveSlotsState; import appeng.block.storage.DriveSlotsState;
@@ -39,7 +38,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class DriveBakedModel implements IBakedModel { public class DriveBakedModel implements IBakedModel {
private final IBakedModel bakedBase; private final IBakedModel bakedBase;
private final Map<DriveSlotState, IBakedModel> bakedCells; private final Map<DriveSlotState, IBakedModel> bakedCells;
@@ -72,9 +70,10 @@ public class DriveBakedModel implements IBakedModel {
Matrix4f transform = new Matrix4f(); Matrix4f transform = new Matrix4f();
transform.setIdentity(); transform.setIdentity();
// Position this drive model copy at the correct slot. The transform is based on the // Position this drive model copy at the correct slot. The transform is based on
// the
// cell-model being in slot 0,0 at the top left of the drive. // cell-model being in slot 0,0 at the top left of the drive.
float xOffset = -col * 7 / 16.0f; float xOffset = -col * 8 / 16.0f;
float yOffset = -row * 3 / 16.0f; float yOffset = -row * 3 / 16.0f;
transform.setTranslation(new Vector3f(xOffset, yOffset, 0)); transform.setTranslation(new Vector3f(xOffset, yOffset, 0));
@@ -32,6 +32,7 @@ import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.JsonUtils; import net.minecraft.util.JsonUtils;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.EnumHelperClient;
import net.minecraftforge.client.model.ICustomModelLoader; import net.minecraftforge.client.model.ICustomModelLoader;
import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoader;
@@ -54,7 +55,6 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@@ -74,11 +74,7 @@ public enum UVLModelLoader implements ICustomModelLoader {
static { static {
try { try {
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
faceBakery = ReflectionHelper.findField(ModelBakery.class, "faceBakery", "field_177607_l"); faceBakery = ReflectionHelper.findField(ModelBakery.class, "faceBakery", "field_177607_l");
modifiers.set(faceBakery, faceBakery.getModifiers() & (~Modifier.FINAL));
Class clas = Class.forName(ModelLoader.class.getName() + "$VanillaModelWrapper"); Class clas = Class.forName(ModelLoader.class.getName() + "$VanillaModelWrapper");
vanillaModelWrapper = clas.getDeclaredConstructor(ModelLoader.class, ResourceLocation.class, ModelBlock.class, boolean.class, vanillaModelWrapper = clas.getDeclaredConstructor(ModelLoader.class, ResourceLocation.class, ModelBlock.class, boolean.class,
@@ -118,7 +114,7 @@ public enum UVLModelLoader implements ICustomModelLoader {
private static void setFaceBakery(ModelBakery modelBakery, FaceBakery faceBakery) { private static void setFaceBakery(ModelBakery modelBakery, FaceBakery faceBakery) {
try { try {
UVLModelLoader.faceBakery.set(modelBakery, faceBakery); EnumHelperClient.setFailsafeFieldValue(UVLModelLoader.faceBakery, modelBakery, faceBakery);
} catch (Exception e) { } catch (Exception e) {
throw Throwables.propagate(e); throw Throwables.propagate(e);
} }
@@ -22,6 +22,7 @@ package appeng.container;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.implementations.guiobjects.IGuiItemObject; import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
@@ -37,7 +38,17 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME; import appeng.client.me.SlotME;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.guisync.SyncData; import appeng.container.guisync.SyncData;
import appeng.container.slot.*; import appeng.container.implementations.ContainerInterface;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotCraftingTerm;
import appeng.container.slot.SlotDisabled;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotInaccessible;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlacableItemType;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction; import appeng.core.sync.packets.PacketInventoryAction;
@@ -48,7 +59,6 @@ import appeng.helpers.InventoryAction;
import appeng.me.helpers.PlayerSource; import appeng.me.helpers.PlayerSource;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.WrapperCursorItemHandler; import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
@@ -78,7 +88,7 @@ public abstract class AEBaseContainer extends Container {
private final HashSet<Integer> locked = new HashSet<>(); private final HashSet<Integer> locked = new HashSet<>();
private final TileEntity tileEntity; private final TileEntity tileEntity;
private final IPart part; private final IPart part;
private final IGuiItemObject obj; protected final IGuiItemObject obj;
private final HashMap<Integer, SyncData> syncData = new HashMap<>(); private final HashMap<Integer, SyncData> syncData = new HashMap<>();
private boolean isContainerValid = true; private boolean isContainerValid = true;
private String customName; private String customName;
@@ -317,6 +327,9 @@ public abstract class AEBaseContainer extends Container {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
IItemDefinition expansionCard = AEApi.instance().definitions().materials().cardPatternExpansion();
ContainerInterface casted;
final List<Slot> selectedSlots = new ArrayList<>(); final List<Slot> selectedSlots = new ArrayList<>();
/** /**
@@ -326,6 +339,10 @@ public abstract class AEBaseContainer extends Container {
tis = this.transferStackToContainer(tis); tis = this.transferStackToContainer(tis);
if (!tis.isEmpty()) { if (!tis.isEmpty()) {
if (this instanceof ContainerInterface && expansionCard.isSameAs(tis) && (casted = (ContainerInterface) this).getPatternUpgrades() == casted.availableUpgrades() - 1) {
return ItemStack.EMPTY; // Don't insert more pattern expansions than maximum useful
}
// target slots in the container... // target slots in the container...
for (final Object inventorySlot : this.inventorySlots) { for (final Object inventorySlot : this.inventorySlots) {
final AppEngSlot cs = (AppEngSlot) inventorySlot; final AppEngSlot cs = (AppEngSlot) inventorySlot;
@@ -388,6 +405,10 @@ public abstract class AEBaseContainer extends Container {
if (Platform.itemComparisons().isSameItem(tis, t)) // t.isItemEqual(tis)) if (Platform.itemComparisons().isSameItem(tis, t)) // t.isItemEqual(tis))
{ {
if (d instanceof SlotRestrictedInput && ((SlotRestrictedInput) d).getPlaceableItemType() == PlacableItemType.ENCODED_PATTERN) {
return ItemStack.EMPTY; // don't insert duplicate encoded patterns to interfaces
}
int maxSize = t.getMaxStackSize(); int maxSize = t.getMaxStackSize();
if (maxSize > d.getSlotStackLimit()) { if (maxSize > d.getSlotStackLimit()) {
maxSize = d.getSlotStackLimit(); maxSize = d.getSlotStackLimit();
@@ -449,6 +470,13 @@ public abstract class AEBaseContainer extends Container {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} else { } else {
this.updateSlot(d); this.updateSlot(d);
if (
(d instanceof SlotRestrictedInput && ((SlotRestrictedInput) d).getPlaceableItemType() == PlacableItemType.ENCODED_PATTERN) ||
(this instanceof ContainerInterface && expansionCard.isSameAs(tis) && (casted = (ContainerInterface) this).getPatternUpgrades() == casted.availableUpgrades() - 1)
) {
break; // Only insert one pattern when shift-clicking into interfaces, and don't insert more pattern expansions than maximum useful
}
} }
} }
} }
@@ -38,6 +38,7 @@ import appeng.api.storage.data.IItemList;
import appeng.client.gui.implementations.GuiCraftConfirm; import appeng.client.gui.implementations.GuiCraftConfirm;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
@@ -54,6 +55,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.IContainerListener;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World; import net.minecraft.world.World;
@@ -279,7 +281,8 @@ public class ContainerCraftConfirm extends AEBaseContainer {
final IActionHost ah = this.getActionHost(); final IActionHost ah = this.getActionHost();
if (ah instanceof WirelessTerminalGuiObject) { if (ah instanceof WirelessTerminalGuiObject) {
originalGui = GuiBridge.GUI_WIRELESS_TERM; ItemStack myIcon = ((WirelessTerminalGuiObject) ah).getItemStack();
originalGui = (GuiBridge) AEApi.instance().registries().wireless().getWirelessTerminalHandler(myIcon).getGuiHandler(myIcon);
} }
if (ah instanceof PartTerminal) { if (ah instanceof PartTerminal) {
@@ -302,9 +305,18 @@ public class ContainerCraftConfirm extends AEBaseContainer {
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class); final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
final ICraftingLink g = cc.submitJob(this.result, null, this.getSelectedCpu() == -1 ? null : this.cpus.get(this.getSelectedCpu()).getCpu(), true, this.getActionSrc()); final ICraftingLink g = cc.submitJob(this.result, null, this.getSelectedCpu() == -1 ? null : this.cpus.get(this.getSelectedCpu()).getCpu(), true, this.getActionSrc());
this.setAutoStart(false); this.setAutoStart(false);
if (g != null && originalGui != null && this.getOpenContext() != null) { if (g == null) {
this.setJob(cc.beginCraftingJob(this.getWorld(), this.getGrid(), this.getActionSrc(), this.result.getOutput(), null));
} else if (originalGui != null && this.getOpenContext() != null) {
final TileEntity te = this.getOpenContext().getTile(); final TileEntity te = this.getOpenContext().getTile();
Platform.openGUI(this.getInventoryPlayer().player, te, this.getOpenContext().getSide(), originalGui); if (te != null) {
Platform.openGUI(this.getInventoryPlayer().player, te, this.getOpenContext().getSide(), originalGui);
} else {
if (ah instanceof IInventorySlotAware) {
IInventorySlotAware i = ((IInventorySlotAware) ah);
Platform.openGUI(this.getInventoryPlayer().player, i.getInventorySlot(), originalGui, i.isBaubleSlot());
}
}
} }
} }
} }
@@ -79,7 +79,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
this.grid = anchor.getActionableNode().getGrid(); this.grid = anchor.getActionableNode().getGrid();
} }
this.bindPlayerInventory(ip, 14, 256 - /* height of player inventory */82); this.bindPlayerInventory(ip, 0, 0);
} }
@Override @Override
@@ -21,6 +21,7 @@ package appeng.container.implementations;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.*; import appeng.api.config.*;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest; import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage; import appeng.api.implementations.tiles.IViewCellStorage;
@@ -50,6 +51,7 @@ import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketMEInventoryUpdate; import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.core.sync.packets.PacketValueConfig; import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.me.helpers.ChannelPowerSrc; import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.ConfigManager; import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost; import appeng.util.IConfigManagerHost;
@@ -70,7 +72,7 @@ import java.util.List;
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack> { public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack> {
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5]; protected final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
private final IMEMonitor<IAEItemStack> monitor; private final IMEMonitor<IAEItemStack> monitor;
public final IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); public final IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
private final IConfigManager clientCM; private final IConfigManager clientCM;
@@ -90,7 +92,11 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
} }
protected ContainerMEMonitorable(final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) { protected ContainerMEMonitorable(final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
super(ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null); this(ip, monitorable, null, bindInventory);
}
protected ContainerMEMonitorable(final InventoryPlayer ip, final ITerminalHost monitorable, final IGuiItemObject iGuiItemObject, final boolean bindInventory) {
super(ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null, iGuiItemObject);
this.host = monitorable; this.host = monitorable;
this.clientCM = new ConfigManager(this); this.clientCM = new ConfigManager(this);
@@ -110,6 +116,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
if (monitorable instanceof IPortableCell) { if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable); this.setPowerSource((IEnergySource) monitorable);
if (monitorable instanceof WirelessTerminalGuiObject) {
this.networkNode = ((WirelessTerminalGuiObject) monitorable).getActionableNode();
}
} else if (monitorable instanceof IMEChest) { } else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable); this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost || monitorable instanceof IActionHost) { } else if (monitorable instanceof IGridHost || monitorable instanceof IActionHost) {
@@ -372,6 +381,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
} }
public void postUpdate(final List<IAEItemStack> list) { public void postUpdate(final List<IAEItemStack> list) {
for (final IAEItemStack is : list) {
this.items.add(is);
}
((GuiMEMonitorable) this.gui).postUpdate(list); ((GuiMEMonitorable) this.gui).postUpdate(list);
} }
} }
@@ -23,42 +23,41 @@ import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier; import appeng.api.config.PowerMultiplier;
import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.interfaces.IInventorySlotAware; import appeng.container.interfaces.IInventorySlotAware;
import appeng.util.inv.IAEAppEngInventory;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class ContainerMEPortableCell extends ContainerMEMonitorable { public class ContainerMEPortableCell extends ContainerMEMonitorable implements IInventorySlotAware {
private double powerMultiplier = 0.5; protected final IPortableCell portableCell;
private final IPortableCell civ;
private int ticks = 0;
private final int slot; private final int slot;
private double powerMultiplier = 0.5;
private int ticks = 0;
public ContainerMEPortableCell(final InventoryPlayer ip, final IPortableCell monitorable) { public ContainerMEPortableCell(InventoryPlayer ip, IPortableCell guiObject) {
super(ip, monitorable, false); super(ip, guiObject, guiObject, true);
if (monitorable instanceof IInventorySlotAware) { if (guiObject != null) {
final int slotIndex = ((IInventorySlotAware) monitorable).getInventorySlot(); final int slotIndex = ((IInventorySlotAware) guiObject).getInventorySlot();
this.lockPlayerInventorySlot(slotIndex); if (!((IInventorySlotAware) guiObject).isBaubleSlot()) {
this.lockPlayerInventorySlot(slotIndex);
}
this.slot = slotIndex; this.slot = slotIndex;
} else { } else {
this.slot = -1; this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem); this.lockPlayerInventorySlot(ip.currentItem);
} }
this.civ = monitorable; this.portableCell = guiObject;
this.bindPlayerInventory(ip, 0, 0);
} }
@Override @Override
public void detectAndSendChanges() { public void detectAndSendChanges() {
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot); final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
if (this.civ == null || currentItem.isEmpty()) { if (this.portableCell == null || currentItem.isEmpty()) {
this.setValidContainer(false); this.setValidContainer(false);
} else if (this.civ != null && !this.civ.getItemStack().isEmpty() && currentItem != this.civ.getItemStack()) { } else if (!this.portableCell.getItemStack().isEmpty() && currentItem != this.portableCell.getItemStack()) {
if (ItemStack.areItemsEqual(this.civ.getItemStack(), currentItem)) { if (!ItemStack.areItemsEqual(this.portableCell.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack());
} else {
this.setValidContainer(false); this.setValidContainer(false);
} }
} }
@@ -66,7 +65,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable {
// drain 1 ae t // drain 1 ae t
this.ticks++; this.ticks++;
if (this.ticks > 10) { if (this.ticks > 10) {
this.civ.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG); this.portableCell.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.ticks = 0; this.ticks = 0;
} }
super.detectAndSendChanges(); super.detectAndSendChanges();
@@ -79,4 +78,9 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable {
void setPowerMultiplier(final double powerMultiplier) { void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier; this.powerMultiplier = powerMultiplier;
} }
@Override
public int getInventorySlot() {
return this.slot;
}
} }
@@ -0,0 +1,232 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.container.implementations;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.implementations.IUpgradeableCellContainer;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.networking.security.IActionHost;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.automation.StackUpgradeInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import baubles.api.BaublesApi;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ClickType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.IItemHandler;
public class ContainerMEPortableTerminal extends ContainerMEMonitorable implements IUpgradeableCellContainer, IAEAppEngInventory, IInventorySlotAware {
protected final WirelessTerminalGuiObject wirelessTerminalGUIObject;
private final int slot;
private double powerMultiplier = 0.5;
private int ticks = 0;
protected AppEngInternalInventory upgrades;
protected SlotRestrictedInput magnetSlot;
public ContainerMEPortableTerminal(InventoryPlayer ip, WirelessTerminalGuiObject guiObject, boolean bindInventory) {
super(ip, guiObject, guiObject, bindInventory);
if (guiObject != null) {
final int slotIndex = ((IInventorySlotAware) guiObject).getInventorySlot();
if (!((IInventorySlotAware) guiObject).isBaubleSlot()) {
this.lockPlayerInventorySlot(slotIndex);
}
this.slot = slotIndex;
} else {
this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem);
}
this.wirelessTerminalGUIObject = guiObject;
this.upgrades = new StackUpgradeInventory(wirelessTerminalGUIObject.getItemStack(), this, 2);
this.loadFromNBT();
this.setupUpgrades();
}
public ContainerMEPortableTerminal(InventoryPlayer ip, IPortableCell guiObject) {
super(ip, guiObject, guiObject, true);
if (guiObject != null) {
final int slotIndex = ((IInventorySlotAware) guiObject).getInventorySlot();
if (!((IInventorySlotAware) guiObject).isBaubleSlot()) {
this.lockPlayerInventorySlot(slotIndex);
}
this.slot = slotIndex;
} else {
this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem);
}
this.wirelessTerminalGUIObject = (WirelessTerminalGuiObject) guiObject;
this.upgrades = new StackUpgradeInventory(wirelessTerminalGUIObject.getItemStack(), this, 2);
this.loadFromNBT();
this.setupUpgrades();
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
final ItemStack currentItem;
if (wirelessTerminalGUIObject.isBaubleSlot()) {
currentItem = BaublesApi.getBaublesHandler(this.getPlayerInv().player).getStackInSlot(this.slot);
} else {
currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
}
if (currentItem.isEmpty()) {
this.setValidContainer(false);
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
if (wirelessTerminalGUIObject.isBaubleSlot()) {
BaublesApi.getBaublesHandler(this.getPlayerInv().player).setStackInSlot(this.slot, this.wirelessTerminalGUIObject.getItemStack());
} else {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
}
} else {
this.setValidContainer(false);
}
}
// drain 1 ae t
this.ticks++;
if (this.ticks > 10) {
double ext = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
if (ext < this.getPowerMultiplier() * this.ticks) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.DeviceNotPowered.get());
}
this.setValidContainer(false);
}
this.ticks = 0;
}
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
}
super.detectAndSendChanges();
}
}
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
if (slotId >= 0 && slotId < this.inventorySlots.size()) {
if (clickTypeIn == ClickType.PICKUP && dragType == 1) {
if (this.inventorySlots.get(slotId) == magnetSlot) {
ItemStack itemStack = magnetSlot.getStack();
if (!magnetSlot.getStack().isEmpty()) {
NBTTagCompound tag = itemStack.getTagCompound();
if (tag == null) {
tag = new NBTTagCompound();
}
if (tag.hasKey("enabled")) {
boolean e = tag.getBoolean("enabled");
tag.setBoolean("enabled", !e);
} else {
tag.setBoolean("enabled", false);
}
magnetSlot.getStack().setTagCompound(tag);
magnetSlot.onSlotChanged();
return ItemStack.EMPTY;
}
}
}
}
return super.slotClick(slotId, dragType, clickTypeIn, player);
}
@Override
protected IActionHost getActionHost() {
return this.wirelessTerminalGUIObject;
}
private double getPowerMultiplier() {
return this.powerMultiplier;
}
void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
@Override
public int availableUpgrades() {
return 1;
}
@Override
public void setupUpgrades() {
if (wirelessTerminalGUIObject != null) {
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.magnetSlot = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 206, 135 + upgradeSlot * 18, this.getInventoryPlayer());
this.magnetSlot.setNotDraggable();
this.addSlotToContainer(magnetSlot);
}
}
}
@Override
public void saveChanges() {
if (Platform.isServer()) {
NBTTagCompound tag = new NBTTagCompound();
this.upgrades.writeToNBT(tag, "upgrades");
this.wirelessTerminalGUIObject.saveChanges(tag);
}
}
protected void loadFromNBT() {
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
if (data != null) {
upgrades.readFromNBT(wirelessTerminalGUIObject.getItemStack().getTagCompound().getCompoundTag("upgrades"));
}
}
@Override
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
}
@Override
public int getInventorySlot() {
return wirelessTerminalGUIObject.getInventorySlot();
}
@Override
public boolean isBaubleSlot() {
return wirelessTerminalGUIObject.isBaubleSlot();
}
}
@@ -1,8 +1,16 @@
package appeng.container.implementations; package appeng.container.implementations;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.slot.AppEngSlot; import appeng.container.slot.AppEngSlot;
import appeng.container.slot.IOptionalSlotHost; import appeng.container.slot.IOptionalSlotHost;
@@ -12,18 +20,23 @@ import appeng.container.slot.SlotPatternTerm;
import appeng.container.slot.SlotPlayerHotBar; import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv; import appeng.container.slot.SlotPlayerInv;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput;
import appeng.core.sync.packets.PacketPatternSlot;
import appeng.helpers.IContainerCraftingPacket; import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.me.helpers.MachineSource;
import appeng.parts.reporting.AbstractPartEncoder; import appeng.parts.reporting.AbstractPartEncoder;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.item.AEItemStack;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.*;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
@@ -42,7 +55,9 @@ import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
public abstract class ContainerPatternEncoder extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket { public abstract class ContainerPatternEncoder extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
private final AbstractPartEncoder patternTerminal; protected AbstractPartEncoder patternTerminal = null;
protected IGuiItemObject iGuiItemObject = null;
final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1); final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
@@ -50,7 +65,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
protected SlotPatternTerm craftSlot; protected SlotPatternTerm craftSlot;
protected SlotRestrictedInput patternSlotIN; protected SlotRestrictedInput patternSlotIN;
protected SlotRestrictedInput patternSlotOUT; protected SlotRestrictedInput patternSlotOUT;
private IRecipe currentRecipe; protected IRecipe currentRecipe;
protected SlotFakeCraftingMatrix[] craftingSlots; protected SlotFakeCraftingMatrix[] craftingSlots;
protected OptionalSlotFake[] outputSlots; protected OptionalSlotFake[] outputSlots;
@@ -60,16 +75,19 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
@GuiSync(96) @GuiSync(96)
public boolean substitute = false; public boolean substitute = false;
public ContainerPatternEncoder(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
patternTerminal = (AbstractPartEncoder) monitorable;
}
protected ContainerPatternEncoder(InventoryPlayer ip, ITerminalHost monitorable, boolean bindInventory) { protected ContainerPatternEncoder(InventoryPlayer ip, ITerminalHost monitorable, boolean bindInventory) {
super(ip, monitorable, bindInventory); super(ip, monitorable, bindInventory);
patternTerminal = (AbstractPartEncoder) monitorable; patternTerminal = (AbstractPartEncoder) monitorable;
} }
protected ContainerPatternEncoder(InventoryPlayer ip, ITerminalHost monitorable, IGuiItemObject iGuiItemObject, boolean bindInventory) {
super(ip, monitorable, iGuiItemObject, bindInventory);
if (monitorable instanceof AbstractPartEncoder) {
patternTerminal = (AbstractPartEncoder) monitorable;
}
this.iGuiItemObject = iGuiItemObject;
}
@Override @Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) { public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
if (Platform.isClient()) { if (Platform.isClient()) {
@@ -99,7 +117,10 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
if (name.equals("player")) { if (name.equals("player")) {
return new PlayerInvWrapper(this.getInventoryPlayer()); return new PlayerInvWrapper(this.getInventoryPlayer());
} }
return this.getPart().getInventoryByName(name); if (this.getPart() != null) {
return this.getPart().getInventoryByName(name);
}
return null;
} }
@Override @Override
@@ -114,7 +135,20 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
@Override @Override
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) { public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
if (inv == this.crafting) {
this.fixCraftingRecipes();
}
}
void fixCraftingRecipes() {
if (this.isCraftingMode()) {
for (int x = 0; x < this.crafting.getSlots(); x++) {
final ItemStack is = this.crafting.getStackInSlot(x);
if (!is.isEmpty()) {
is.setCount(1);
}
}
}
} }
@Override @Override
@@ -201,7 +235,6 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1); Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1);
if (maybePattern.isPresent()) { if (maybePattern.isPresent()) {
output = maybePattern.get(); output = maybePattern.get();
this.patternSlotOUT.putStack(output);
} }
} }
@@ -225,6 +258,8 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
encodedValue.setBoolean("substitute", this.isSubstitute()); encodedValue.setBoolean("substitute", this.isSubstitute());
output.setTagCompound(encodedValue); output.setTagCompound(encodedValue);
patternSlotOUT.putStack(output);
} }
public void multiply(int multiple) { public void multiply(int multiple) {
@@ -475,8 +510,20 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
return this.craftingMode; return this.craftingMode;
} }
void setCraftingMode(final boolean craftingMode) { public void setCraftingMode(final boolean craftingMode) {
this.craftingMode = craftingMode; this.craftingMode = craftingMode;
if (getPart() != null) {
getPart().setCraftingRecipe(craftingMode);
} else if (iGuiItemObject != null) {
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
if (nbtTagCompound != null) {
nbtTagCompound.setBoolean("isCraftingMode", craftingMode);
this.updateOrderOfOutputSlots();
}
}
if (craftingMode) {
this.fixCraftingRecipes();
}
} }
@@ -486,18 +533,59 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
public void setSubstitute(final boolean substitute) { public void setSubstitute(final boolean substitute) {
this.substitute = substitute; this.substitute = substitute;
if (getPart() != null) {
getPart().setSubstitution(substitute);
} else if (iGuiItemObject != null) {
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
if (nbtTagCompound != null) {
nbtTagCompound.setBoolean("isSubstitute", substitute);
}
}
} }
@Override @Override
public void detectAndSendChanges() { public void detectAndSendChanges() {
super.detectAndSendChanges(); super.detectAndSendChanges();
if (Platform.isServer()) { if (Platform.isServer()) {
if (this.isCraftingMode() != this.getPart().isCraftingRecipe()) { if (getPart() != null) {
this.setCraftingMode(this.getPart().isCraftingRecipe()); if (this.isCraftingMode() != this.getPart().isCraftingRecipe()) {
this.updateOrderOfOutputSlots(); this.setCraftingMode(this.getPart().isCraftingRecipe());
this.updateOrderOfOutputSlots();
}
this.substitute = this.getPart().isSubstitution();
} else if (iGuiItemObject != null) {
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
if (nbtTagCompound != null) {
if (nbtTagCompound.hasKey("isCraftingMode")) {
boolean crafting = nbtTagCompound.getBoolean("isCraftingMode");
if (this.isCraftingMode() != crafting) {
this.setCraftingMode(crafting);
this.updateOrderOfOutputSlots();
}
} else {
nbtTagCompound.setBoolean("isCraftingMode", false);
}
} else {
nbtTagCompound = new NBTTagCompound();
nbtTagCompound.setBoolean("isCraftingMode", false);
iGuiItemObject.getItemStack().setTagCompound(nbtTagCompound);
}
nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
if (nbtTagCompound != null) {
if (nbtTagCompound.hasKey("isSubstitute")) {
boolean substitute = nbtTagCompound.getBoolean("isSubstitute");
if (this.isSubstitute() != substitute) {
this.setSubstitute(substitute);
}
} else {
nbtTagCompound.setBoolean("isSubstitute", false);
}
} else {
nbtTagCompound = new NBTTagCompound();
nbtTagCompound.setBoolean("isSubstitute", false);
iGuiItemObject.getItemStack().setTagCompound(nbtTagCompound);
}
} }
this.substitute = this.getPart().isSubstitution();
} }
} }
@@ -546,4 +634,98 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
this.detectAndSendChanges(); this.detectAndSendChanges();
this.getAndUpdateOutput(); this.getAndUpdateOutput();
} }
public void craftOrGetItem(final PacketPatternSlot packetPatternSlot) {
if (packetPatternSlot.slotItem != null && this.getCellInventory() != null) {
final IAEItemStack out = packetPatternSlot.slotItem.copy();
InventoryAdaptor inv = new AdaptorItemHandler(new WrapperCursorItemHandler(this.getPlayerInv().player.inventory));
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(this.getPlayerInv().player);
if (packetPatternSlot.shift) {
inv = playerInv;
}
if (!inv.simulateAdd(out.createItemStack()).isEmpty()) {
return;
}
final IAEItemStack extracted = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), out, this.getActionSource());
final EntityPlayer p = this.getPlayerInv().player;
if (extracted != null) {
inv.addItems(extracted.createItemStack());
if (p instanceof EntityPlayerMP) {
this.updateHeld((EntityPlayerMP) p);
}
this.detectAndSendChanges();
return;
}
final InventoryCrafting ic = new InventoryCrafting(new ContainerNull(), 3, 3);
final InventoryCrafting real = new InventoryCrafting(new ContainerNull(), 3, 3);
for (int x = 0; x < 9; x++) {
ic.setInventorySlotContents(x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].createItemStack());
}
final IRecipe r = CraftingManager.findMatchingRecipe(ic, p.world);
if (r == null) {
return;
}
IMEMonitor<IAEItemStack> storage = null;
if (getPart() != null) {
storage = this.getPart()
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
} else if (iGuiItemObject != null) {
storage = ((ITerminalHost) iGuiItemObject).getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
}
final IItemList<IAEItemStack> all = storage.getStorageList();
final ItemStack is = r.getCraftingResult(ic);
for (int x = 0; x < ic.getSizeInventory(); x++) {
if (!ic.getStackInSlot(x).isEmpty()) {
final ItemStack pulled = Platform.extractItemsByRecipe(this.getPowerSource(), this.getActionSource(), storage, p.world, r, is, ic,
ic.getStackInSlot(x), x, all, Actionable.MODULATE, ItemViewCell.createFilter(this.getViewCells()));
real.setInventorySlotContents(x, pulled);
}
}
final IRecipe rr = CraftingManager.findMatchingRecipe(real, p.world);
if (rr == r && Platform.itemComparisons().isSameItem(rr.getCraftingResult(real), is)) {
final InventoryCraftResult craftingResult = new InventoryCraftResult();
craftingResult.setRecipeUsed(rr);
final SlotCrafting sc = new SlotCrafting(p, real, craftingResult, 0, 0, 0);
sc.onTake(p, is);
for (int x = 0; x < real.getSizeInventory(); x++) {
final ItemStack failed = playerInv.addItems(real.getStackInSlot(x));
if (!failed.isEmpty()) {
p.dropItem(failed, false);
}
}
inv.addItems(is);
if (p instanceof EntityPlayerMP) {
this.updateHeld((EntityPlayerMP) p);
}
this.detectAndSendChanges();
} else {
for (int x = 0; x < real.getSizeInventory(); x++) {
final ItemStack failed = real.getStackInSlot(x);
if (!failed.isEmpty()) {
this.getCellInventory()
.injectItems(AEItemStack.fromItemStack(failed), Actionable.MODULATE,
new MachineSource(this.getPart() != null ? this.getPart() : (IActionHost) iGuiItemObject));
}
}
}
}
}
} }
@@ -19,43 +19,14 @@
package appeng.container.implementations; package appeng.container.implementations;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake; import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix; import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs; import appeng.container.slot.SlotPatternOutputs;
import appeng.container.slot.SlotPatternTerm; import appeng.container.slot.SlotPatternTerm;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput;
import appeng.core.sync.packets.PacketPatternSlot;
import appeng.items.storage.ItemViewCell;
import appeng.me.helpers.MachineSource;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.item.AEItemStack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@@ -114,91 +85,4 @@ public class ContainerPatternTerm extends ContainerPatternEncoder {
} }
} }
public void craftOrGetItem(final PacketPatternSlot packetPatternSlot) {
if (packetPatternSlot.slotItem != null && this.getCellInventory() != null) {
final IAEItemStack out = packetPatternSlot.slotItem.copy();
InventoryAdaptor inv = new AdaptorItemHandler(new WrapperCursorItemHandler(this.getPlayerInv().player.inventory));
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(this.getPlayerInv().player);
if (packetPatternSlot.shift) {
inv = playerInv;
}
if (!inv.simulateAdd(out.createItemStack()).isEmpty()) {
return;
}
final IAEItemStack extracted = Platform.poweredExtraction(this.getPowerSource(), this.getCellInventory(), out, this.getActionSource());
final EntityPlayer p = this.getPlayerInv().player;
if (extracted != null) {
inv.addItems(extracted.createItemStack());
if (p instanceof EntityPlayerMP) {
this.updateHeld((EntityPlayerMP) p);
}
this.detectAndSendChanges();
return;
}
final InventoryCrafting ic = new InventoryCrafting(new ContainerNull(), 3, 3);
final InventoryCrafting real = new InventoryCrafting(new ContainerNull(), 3, 3);
for (int x = 0; x < 9; x++) {
ic.setInventorySlotContents(x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].createItemStack());
}
final IRecipe r = CraftingManager.findMatchingRecipe(ic, p.world);
if (r == null) {
return;
}
final IMEMonitor<IAEItemStack> storage = this.getPart()
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
final IItemList<IAEItemStack> all = storage.getStorageList();
final ItemStack is = r.getCraftingResult(ic);
for (int x = 0; x < ic.getSizeInventory(); x++) {
if (!ic.getStackInSlot(x).isEmpty()) {
final ItemStack pulled = Platform.extractItemsByRecipe(this.getPowerSource(), this.getActionSource(), storage, p.world, r, is, ic,
ic.getStackInSlot(x), x, all, Actionable.MODULATE, ItemViewCell.createFilter(this.getViewCells()));
real.setInventorySlotContents(x, pulled);
}
}
final IRecipe rr = CraftingManager.findMatchingRecipe(real, p.world);
if (rr == r && Platform.itemComparisons().isSameItem(rr.getCraftingResult(real), is)) {
final InventoryCraftResult craftingResult = new InventoryCraftResult();
craftingResult.setRecipeUsed(rr);
final SlotCrafting sc = new SlotCrafting(p, real, craftingResult, 0, 0, 0);
sc.onTake(p, is);
for (int x = 0; x < real.getSizeInventory(); x++) {
final ItemStack failed = playerInv.addItems(real.getStackInSlot(x));
if (!failed.isEmpty()) {
p.dropItem(failed, false);
}
}
inv.addItems(is);
if (p instanceof EntityPlayerMP) {
this.updateHeld((EntityPlayerMP) p);
}
this.detectAndSendChanges();
} else {
for (int x = 0; x < real.getSizeInventory(); x++) {
final ItemStack failed = real.getStackInSlot(x);
if (!failed.isEmpty()) {
this.getCellInventory()
.injectItems(AEItemStack.fromItemStack(failed), Actionable.MODULATE,
new MachineSource(this.getPart()));
}
}
}
}
}
} }
@@ -20,19 +20,43 @@ package appeng.container.implementations;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.qnb.TileQuantumBridge; import appeng.tile.qnb.TileQuantumBridge;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
public class ContainerQNB extends AEBaseContainer { public class ContainerQNB extends AEBaseContainer implements IOptionalSlotHost {
OptionalSlotRestrictedInput SINGULARITY;
OptionalSlotRestrictedInput QUANTUM_CARD;
public ContainerQNB(final InventoryPlayer ip, final TileQuantumBridge quantumBridge) { public ContainerQNB(final InventoryPlayer ip, final TileQuantumBridge quantumBridge) {
super(ip, quantumBridge, null); super(ip, quantumBridge, null);
this.addSlotToContainer((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge SINGULARITY = new OptionalSlotRestrictedInput(SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
.getInternalInventory(), 0, 80, 37, this.getInventoryPlayer())).setStackLimit(1)); .getInternalInventory(), this, 0, 80, 37, 0, this.getInventoryPlayer());
this.addSlotToContainer(SINGULARITY.setStackLimit(1));
QUANTUM_CARD = new OptionalSlotRestrictedInput(SlotRestrictedInput.PlacableItemType.CARD_QUANTUM, quantumBridge
.getInternalInventory(), this, 1, 80, 55, 1, this.getInventoryPlayer());
this.addSlotToContainer((QUANTUM_CARD).setStackLimit(1));
this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82); this.bindPlayerInventory(ip, 0, 166 - /* height of player inventory */82);
} }
@Override
public boolean isSlotEnabled(int idx) {
if (QUANTUM_CARD.getItemHandler().getStackInSlot(QUANTUM_CARD.slotNumber).isEmpty() &&
SINGULARITY.getItemHandler().getStackInSlot(SINGULARITY.slotNumber).isEmpty()) {
return true;
} else if (idx == 0) {
return QUANTUM_CARD.getItemHandler().getStackInSlot(QUANTUM_CARD.slotNumber).isEmpty();
} else if (idx == 1) {
return SINGULARITY.getItemHandler().getStackInSlot(SINGULARITY.slotNumber).isEmpty();
}
return false;
}
} }
@@ -0,0 +1,134 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.container.implementations;
import appeng.container.ContainerNull;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotCraftingTerm;
import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperInvItemHandler;
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 net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
public class ContainerWirelessCraftingTerminal extends ContainerMEPortableTerminal implements IContainerCraftingPacket {
private final AppEngInternalInventory output = new AppEngInternalInventory(this, 1);
private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
private final SlotCraftingTerm outputSlot;
private AppEngInternalInventory craftingGrid;
private IRecipe currentRecipe;
public ContainerWirelessCraftingTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
super(ip, gui, true);
final IItemHandler crafting = this.craftingGrid;
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));
}
}
this.addSlotToContainer(this.outputSlot = new SlotCraftingTerm(this.getPlayerInv().player, this.getActionSource(), this
.getPowerSource(), this.wirelessTerminalGUIObject, crafting, crafting, this.output, 131, -72 + 18, this));
this.onCraftMatrixChanged(new WrapperInvItemHandler(crafting));
}
@Override
public void onCraftMatrixChanged(IInventory inventory) {
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());
}
if (this.currentRecipe == null || !this.currentRecipe.matches(ic, this.getPlayerInv().player.world)) {
this.currentRecipe = CraftingManager.findMatchingRecipe(ic, this.getPlayerInv().player.world);
}
if (this.currentRecipe == null) {
this.outputSlot.putStack(ItemStack.EMPTY);
} else {
final ItemStack craftingResult = this.currentRecipe.getCraftingResult(ic);
this.outputSlot.putStack(craftingResult);
}
this.saveChanges();
}
@Override
public void saveChanges() {
if (Platform.isServer()) {
NBTTagCompound tag = new NBTTagCompound();
this.craftingGrid.writeToNBT(tag, "craftingGrid");
this.upgrades.writeToNBT(tag, "upgrades");
this.wirelessTerminalGUIObject.saveChanges(tag);
}
}
@Override
protected void loadFromNBT() {
super.loadFromNBT();
this.craftingGrid = new AppEngInternalInventory(this, 9);
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
if (data != null) {
this.craftingGrid.readFromNBT(data, "craftingGrid");
}
}
@Override
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) {
if (inv == craftingGrid) {
saveChanges();
}
}
@Override
public IItemHandler getInventoryByName(final String name) {
if (name.equals("player")) {
return new PlayerInvWrapper(this.getInventoryPlayer());
} else if (name.equals("crafting")) {
return this.craftingGrid;
}
return null;
}
@Override
public boolean useRealItems() {
return true;
}
}
@@ -0,0 +1,326 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.container.implementations;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.IUpgradeableCellContainer;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs;
import appeng.container.slot.SlotPatternTerm;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.automation.StackUpgradeInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.InvOperation;
import baubles.api.BaublesApi;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ClickType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.IItemHandler;
import static appeng.helpers.PatternHelper.CRAFTING_GRID_DIMENSION;
public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder implements IUpgradeableCellContainer, IInventorySlotAware {
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
private final int slot;
protected AppEngInternalInventory output;
protected AppEngInternalInventory pattern;
protected AppEngInternalInventory upgrades;
protected SlotRestrictedInput magnetSlot;
private double powerMultiplier = 0.5;
private int ticks = 0;
public ContainerWirelessPatternTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
super(ip, gui, gui, false);
this.crafting = new AppEngInternalInventory(this, CRAFTING_GRID_DIMENSION * CRAFTING_GRID_DIMENSION);
this.output = new AppEngInternalInventory(this, 3);
this.pattern = new AppEngInternalInventory(this, 2);
this.craftingSlots = new SlotFakeCraftingMatrix[9];
this.outputSlots = new OptionalSlotFake[3];
if (gui != null) {
final int slotIndex = gui.getInventorySlot();
if (!((IInventorySlotAware) gui).isBaubleSlot()) {
this.lockPlayerInventorySlot(slotIndex);
}
this.slot = slotIndex;
} else {
this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem);
}
this.wirelessTerminalGUIObject = gui;
upgrades = new StackUpgradeInventory(wirelessTerminalGUIObject.getItemStack(), this, 2);
this.loadFromNBT();
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
this.addSlotToContainer(this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix(this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18));
}
}
this.addSlotToContainer(this.craftSlot = new SlotPatternTerm(ip.player, this.getActionSource(), this
.getPowerSource(), gui, this.crafting, pattern, this.cOut, 110, -76 + 18, this, 2, this));
this.craftSlot.setIIcon(-1);
for (int y = 0; y < this.outputSlots.length; y++) {
this.addSlotToContainer(this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
this.outputSlots[y].setRenderDisabled(false);
this.outputSlots[y].setIIcon(-1);
}
this.addSlotToContainer(
this.patternSlotIN = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, pattern, 0, 147, -72 - 9, this
.getInventoryPlayer()));
this.addSlotToContainer(
this.patternSlotOUT = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, pattern, 1, 147, -72 + 34, this
.getInventoryPlayer()));
this.patternSlotOUT.setStackLimit(1);
this.updateOrderOfOutputSlots();
this.bindPlayerInventory(ip, 0, 0);
this.setupUpgrades();
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
final ItemStack currentItem;
if (wirelessTerminalGUIObject.isBaubleSlot()) {
currentItem = BaublesApi.getBaublesHandler(this.getPlayerInv().player).getStackInSlot(this.slot);
} else {
currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
}
if (currentItem.isEmpty()) {
this.setValidContainer(false);
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
if (wirelessTerminalGUIObject.isBaubleSlot()) {
BaublesApi.getBaublesHandler(this.getPlayerInv().player).setStackInSlot(this.slot, this.wirelessTerminalGUIObject.getItemStack());
} else {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
}
} else {
this.setValidContainer(false);
}
}
// drain 1 ae t
this.ticks++;
if (this.ticks > 10) {
double ext = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
if (ext < this.getPowerMultiplier() * this.ticks) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.DeviceNotPowered.get());
}
this.setValidContainer(false);
}
this.ticks = 0;
}
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
}
super.detectAndSendChanges();
}
}
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
if (slotId >= 0 && slotId < this.inventorySlots.size()) {
if (clickTypeIn == ClickType.PICKUP && dragType == 1) {
if (this.inventorySlots.get(slotId) == magnetSlot) {
ItemStack itemStack = magnetSlot.getStack();
if (!magnetSlot.getStack().isEmpty()) {
NBTTagCompound tag = itemStack.getTagCompound();
if (tag == null) {
tag = new NBTTagCompound();
}
if (tag.hasKey("enabled")) {
boolean e = tag.getBoolean("enabled");
tag.setBoolean("enabled", !e);
} else {
tag.setBoolean("enabled", false);
}
magnetSlot.getStack().setTagCompound(tag);
magnetSlot.onSlotChanged();
return ItemStack.EMPTY;
}
}
}
}
return super.slotClick(slotId, dragType, clickTypeIn, player);
}
private double getPowerMultiplier() {
return this.powerMultiplier;
}
void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
@Override
public boolean isSlotEnabled(final int idx) {
boolean crafting = false;
if (Platform.isServer()) {
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
if (nbtTagCompound != null) {
if (nbtTagCompound.hasKey("isCraftingMode")) {
crafting = nbtTagCompound.getBoolean("isCraftingMode");
}
}
}
if (idx == 1) {
return Platform.isServer() ? !crafting : !this.isCraftingMode();
} else if (idx == 2) {
return Platform.isServer() ? crafting : this.isCraftingMode();
} else {
return false;
}
}
@Override
public void saveChanges() {
if (Platform.isServer()) {
NBTTagCompound tag = new NBTTagCompound();
((AppEngInternalInventory) crafting).writeToNBT(tag, "craftingGrid");
this.output.writeToNBT(tag, "output");
this.pattern.writeToNBT(tag, "patterns");
this.upgrades.writeToNBT(tag, "upgrades");
this.wirelessTerminalGUIObject.saveChanges(tag);
}
}
private void loadFromNBT() {
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
if (data != null) {
((AppEngInternalInventory) crafting).readFromNBT(data, "craftingGrid");
this.output.readFromNBT(data, "output");
this.pattern.readFromNBT(data, "patterns");
upgrades.readFromNBT(wirelessTerminalGUIObject.getItemStack().getTagCompound().getCompoundTag("upgrades"));
}
}
@Override
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) {
if (inv == this.pattern && slot == 1) {
final ItemStack is = this.pattern.getStackInSlot(1);
if (!is.isEmpty() && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getPlayerInv().player.world);
if (details != null) {
this.setCraftingMode(details.isCraftable());
this.setSubstitute(details.canSubstitute());
for (int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++) {
final IAEItemStack item = details.getInputs()[x];
ItemHandlerUtil.setStackInSlot(this.crafting, x, item == null ? ItemStack.EMPTY : item.createItemStack());
}
for (int x = 0; x < this.output.getSlots(); x++) {
final IAEItemStack item;
if (x < details.getOutputs().length) {
item = details.getOutputs()[x];
} else {
item = null;
}
this.output.setStackInSlot(x, item == null ? ItemStack.EMPTY : item.createItemStack());
}
}
}
}
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
}
@Override
public IItemHandler getInventoryByName(String name) {
if (name.equals("crafting")) {
return this.crafting;
} else if (name.equals("output")) {
return this.output;
}
return super.getInventoryByName(name);
}
@Override
public boolean useRealItems() {
return false;
}
@Override
public int availableUpgrades() {
return 1;
}
@Override
public void setupUpgrades() {
if (wirelessTerminalGUIObject != null) {
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.magnetSlot = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 206, 135 + upgradeSlot * 18, this.getInventoryPlayer());
this.magnetSlot.setNotDraggable();
this.addSlotToContainer(magnetSlot);
}
}
}
@Override
public int getInventorySlot() {
return wirelessTerminalGUIObject.getInventorySlot();
}
@Override
public boolean isBaubleSlot() {
return wirelessTerminalGUIObject.isBaubleSlot();
}
}
@@ -19,34 +19,13 @@
package appeng.container.implementations; package appeng.container.implementations;
import appeng.core.AEConfig;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject; import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.Platform;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
public class ContainerWirelessTerm extends ContainerMEPortableCell { public class ContainerWirelessTerm extends ContainerMEPortableTerminal {
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
public ContainerWirelessTerm(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) { public ContainerWirelessTerm(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
super(ip, gui); super(ip, gui, true);
this.wirelessTerminalGUIObject = gui;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
}
} }
} }
@@ -32,4 +32,8 @@ public interface IInventorySlotAware {
* @return the inventory index of this portable cell. * @return the inventory index of this portable cell.
*/ */
int getInventorySlot(); int getInventorySlot();
default boolean isBaubleSlot() {
return false;
}
} }
@@ -20,6 +20,7 @@ package appeng.container.slot;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.Upgrades;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItems; import appeng.api.definitions.IItems;
import appeng.api.definitions.IMaterials; import appeng.api.definitions.IMaterials;
@@ -64,6 +65,10 @@ public class SlotRestrictedInput extends AppEngSlot {
this.p = p; this.p = p;
} }
public PlacableItemType getPlaceableItemType() {
return which;
}
@Override @Override
public int getSlotStackLimit() { public int getSlotStackLimit() {
if (this.stackLimit != -1) { if (this.stackLimit != -1) {
@@ -200,6 +205,11 @@ public class SlotRestrictedInput extends AppEngSlot {
return i.getItem() instanceof IBiometricCard; return i.getItem() instanceof IBiometricCard;
case UPGRADES: case UPGRADES:
return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType(i) != null; return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType(i) != null;
case CARD_QUANTUM:
if (AEApi.instance().definitions().materials().cardQuantumLink().maybeItem().isPresent()) {
return AEApi.instance().definitions().materials().cardQuantumLink().maybeItem().get() == i.getItem();
}
return false;
default: default:
break; break;
} }
@@ -269,6 +279,8 @@ public class SlotRestrictedInput extends AppEngSlot {
RANGE_BOOSTER(6 * 16 + 15), RANGE_BOOSTER(6 * 16 + 15),
QE_SINGULARITY(10 * 16 + 15), QE_SINGULARITY(10 * 16 + 15),
CARD_QUANTUM(13 * 16 + 15),
SPATIAL_STORAGE_CELLS(11 * 16 + 15), SPATIAL_STORAGE_CELLS(11 * 16 + 15),
FUEL(12 * 16 + 15), FUEL(12 * 16 + 15),
+6
View File
@@ -82,6 +82,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
private boolean disableColoredCableRecipesInJEI = true; private boolean disableColoredCableRecipesInJEI = true;
private int craftingCalculationTimePerTick = 5; private int craftingCalculationTimePerTick = 5;
private PowerUnits selectedPowerUnit = PowerUnits.AE; private PowerUnits selectedPowerUnit = PowerUnits.AE;
private boolean showCraftableTooltip = true;
// Spatial IO/Dimension // Spatial IO/Dimension
private int storageProviderID = -1; private int storageProviderID = -1;
private int storageDimensionID = -1; private int storageDimensionID = -1;
@@ -248,6 +249,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
this.enableEffects = this.get("Client", "enableEffects", true).getBoolean(true); this.enableEffects = this.get("Client", "enableEffects", true).getBoolean(true);
this.useLargeFonts = this.get("Client", "useTerminalUseLargeFont", false).getBoolean(false); this.useLargeFonts = this.get("Client", "useTerminalUseLargeFont", false).getBoolean(false);
this.useColoredCraftingStatus = this.get("Client", "useColoredCraftingStatus", true).getBoolean(true); this.useColoredCraftingStatus = this.get("Client", "useColoredCraftingStatus", true).getBoolean(true);
this.showCraftableTooltip = this.get("Client", "showCraftableTooltip", true, "Whether to add \"Craftable\" to item tooltips when they can be crafted automatically.").getBoolean(true);
// load buttons.. // load buttons..
for (int btnNum = 0; btnNum < 4; btnNum++) { for (int btnNum = 0; btnNum < 4; btnNum++) {
@@ -501,6 +503,10 @@ public final class AEConfig extends Configuration implements IConfigurableObject
return this.useColoredCraftingStatus; return this.useColoredCraftingStatus;
} }
public boolean isShowCraftableTooltip() {
return this.showCraftableTooltip;
}
public boolean isDisableColoredCableRecipesInJEI() { public boolean isDisableColoredCableRecipesInJEI() {
return this.disableColoredCableRecipesInJEI; return this.disableColoredCableRecipesInJEI;
} }
+5 -1
View File
@@ -72,7 +72,11 @@ public final class AppEng {
private static final String FORGE_CURRENT_VERSION = ForgeVersion.majorVersion + "." + ForgeVersion.minorVersion + "." + ForgeVersion.revisionVersion + "." + ForgeVersion.buildVersion; private static final String FORGE_CURRENT_VERSION = ForgeVersion.majorVersion + "." + ForgeVersion.minorVersion + "." + ForgeVersion.revisionVersion + "." + ForgeVersion.buildVersion;
private static final String FORGE_MAX_VERSION = (ForgeVersion.majorVersion + 1) + ".0.0.0"; private static final String FORGE_MAX_VERSION = (ForgeVersion.majorVersion + 1) + ".0.0.0";
public static final String MOD_DEPENDENCIES = "required-after:forge@[" + FORGE_CURRENT_VERSION + "," + FORGE_MAX_VERSION + ");after:ctm@[" + CTM.VERSION + ",);after:itemstages;after:recipestages"; public static final String MOD_DEPENDENCIES = "required-after:forge@[" + FORGE_CURRENT_VERSION + "," + FORGE_MAX_VERSION + ");" +
"after:ctm@[" + CTM.VERSION + ",);" +
"after:itemstages;" +
"after:recipestages;" +
"before:bogosorter@[1.2.2,);";
@Nonnull @Nonnull
private static final AppEng INSTANCE = new AppEng(); private static final AppEng INSTANCE = new AppEng();
+21 -1
View File
@@ -19,8 +19,10 @@
package appeng.core; package appeng.core;
import appeng.api.AEApi;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
import appeng.api.definitions.IBlocks; import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems; import appeng.api.definitions.IItems;
import appeng.api.definitions.IParts; import appeng.api.definitions.IParts;
import appeng.api.features.IRecipeHandlerRegistry; import appeng.api.features.IRecipeHandlerRegistry;
@@ -105,7 +107,9 @@ import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
@@ -377,6 +381,9 @@ final class Registration {
Upgrades.FUZZY.registerItem(items.viewCell(), 1); Upgrades.FUZZY.registerItem(items.viewCell(), 1);
Upgrades.INVERTER.registerItem(items.viewCell(), 1); Upgrades.INVERTER.registerItem(items.viewCell(), 1);
Upgrades.FUZZY.registerItem(AEApi.instance().definitions().materials().cardMagnet(), 1);
Upgrades.INVERTER.registerItem(AEApi.instance().definitions().materials().cardMagnet(), 1);
// Storage Bus // Storage Bus
Upgrades.FUZZY.registerItem(parts.storageBus(), 1); Upgrades.FUZZY.registerItem(parts.storageBus(), 1);
Upgrades.INVERTER.registerItem(parts.storageBus(), 1); Upgrades.INVERTER.registerItem(parts.storageBus(), 1);
@@ -402,8 +409,21 @@ final class Registration {
// Inscriber // Inscriber
Upgrades.SPEED.registerItem(blocks.inscriber(), 3); Upgrades.SPEED.registerItem(blocks.inscriber(), 3);
Upgrades.QUANTUM_LINK.registerItem(blocks.quantumLink(), 1);
// Wireless Terminal Handler // Wireless Terminal Handler
items.wirelessTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal)); ArrayList<IItemDefinition> iids = new ArrayList<>();
iids.add(items.wirelessTerminal());
iids.add(items.wirelessCraftingTerminal());
iids.add(items.wirelessPatternTerminal());
for (IItemDefinition id : iids) {
id.maybeItem().ifPresent(terminal -> {
registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal);
Upgrades.MAGNET.registerItem(id, 1);
});
}
items.wirelessFluidTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
// Charge Rates // Charge Rates
items.chargedStaff().maybeItem().ifPresent(chargedStaff -> registries.charger().addChargeRate(chargedStaff, 320d)); items.chargedStaff().maybeItem().ifPresent(chargedStaff -> registries.charger().addChargeRate(chargedStaff, 320d));
@@ -14,6 +14,7 @@ import appeng.api.util.IClientHelper;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.fluids.items.FluidDummyItem; import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.util.AEFluidStack; import appeng.fluids.util.AEFluidStack;
import appeng.util.ReadableNumberConverter;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -22,11 +23,17 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
public class ApiClientHelper implements IClientHelper { public class ApiClientHelper implements IClientHelper {
private static final String[] NUMBER_FORMATS = new String[]{"#.000", "#.00", "#.0", "#"};
@Override @Override
public <T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler, List<String> lines) { public <T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler, List<String> lines) {
if (handler == null) { if (handler == null) {
@@ -63,7 +70,7 @@ public class ApiClientHelper implements IClientHelper {
if (!handler.isFuzzy()) { if (!handler.isFuzzy()) {
final IAEItemStack ais = AEItemStack.fromItemStack(is); final IAEItemStack ais = AEItemStack.fromItemStack(is);
IAEItemStack stocked = ((IItemList<IAEItemStack>) itemList).findPrecise(ais); IAEItemStack stocked = ((IItemList<IAEItemStack>) itemList).findPrecise(ais);
lines.add("[" + is.getDisplayName() + "]" + ": " + (stocked == null ? "0" : String.valueOf(stocked.getStackSize()))); lines.add("[" + is.getDisplayName() + "]" + ": " + (stocked == null ? "0" : ReadableNumberConverter.INSTANCE.toWideReadableForm(stocked.getStackSize())));
} else { } else {
final IAEItemStack ais = AEItemStack.fromItemStack(is); final IAEItemStack ais = AEItemStack.fromItemStack(is);
Collection<IAEItemStack> stocked = ((IItemList<IAEItemStack>) itemList).findFuzzy(ais, handler.getCellInv().getFuzzyMode()); Collection<IAEItemStack> stocked = ((IItemList<IAEItemStack>) itemList).findFuzzy(ais, handler.getCellInv().getFuzzyMode());
@@ -81,7 +88,7 @@ public class ApiClientHelper implements IClientHelper {
for (int j : ids) { for (int j : ids) {
sb.append(OreDictionary.getOreName(j)).append(", "); sb.append(OreDictionary.getOreName(j)).append(", ");
} }
lines.add("[{" + sb.substring(0, sb.length() - 2) + "}]" + ": " + size); lines.add("[{" + sb.substring(0, sb.length() - 2) + "}]" + ": " + ReadableNumberConverter.INSTANCE.toWideReadableForm(size));
} }
} }
} else if (cellInventory.getChannel() instanceof IFluidStorageChannel) { } else if (cellInventory.getChannel() instanceof IFluidStorageChannel) {
@@ -92,7 +99,7 @@ public class ApiClientHelper implements IClientHelper {
ais = AEFluidStack.fromFluidStack(FluidUtil.getFluidContained(is)); ais = AEFluidStack.fromFluidStack(FluidUtil.getFluidContained(is));
} }
IAEFluidStack stocked = ((IItemList<IAEFluidStack>) itemList).findPrecise(ais); IAEFluidStack stocked = ((IItemList<IAEFluidStack>) itemList).findPrecise(ais);
lines.add("[" + is.getDisplayName() + "]" + ": " + (stocked == null ? "0" : String.valueOf(stocked.getStackSize()))); lines.add("[" + is.getDisplayName() + "]" + ": " + (stocked == null ? "0" : fluidStackSize(stocked.getStackSize())));
} }
} }
} }
@@ -102,12 +109,35 @@ public class ApiClientHelper implements IClientHelper {
cellInventory.getAvailableItems((IItemList) itemList); cellInventory.getAvailableItems((IItemList) itemList);
for (IAEStack<?> s : itemList) { for (IAEStack<?> s : itemList) {
if (s instanceof IAEItemStack) { if (s instanceof IAEItemStack) {
lines.add(((IAEItemStack) s).getDefinition().getDisplayName() + ": " + s.getStackSize()); lines.add(((IAEItemStack) s).getDefinition().getDisplayName() + ": " + ReadableNumberConverter.INSTANCE.toWideReadableForm(s.getStackSize()));
} else if (s instanceof IAEFluidStack) { } else if (s instanceof IAEFluidStack) {
lines.add(((IAEFluidStack) s).getFluidStack().getLocalizedName() + ": " + s.getStackSize() + "mB"); lines.add(((IAEFluidStack) s).getFluidStack().getLocalizedName() + ": " + fluidStackSize(s.getStackSize()));
} }
} }
} }
} }
} }
private String fluidStackSize(long size) {
String unit;
if (size >= 1000) {
unit = "B";
} else {
unit = "mB";
}
final int log = (int) Math.floor(Math.log10(size)) / 2;
final int index = Math.max(0, Math.min(3, log));
final DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator('.');
final DecimalFormat format = new DecimalFormat(NUMBER_FORMATS[index]);
format.setDecimalFormatSymbols(symbols);
format.setRoundingMode(RoundingMode.DOWN);
String formatted = format.format(size / 1000d);
return formatted.concat(unit);
}
} }
+2 -2
View File
@@ -41,8 +41,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.commons.ClassRemapper;
import org.objectweb.asm.commons.Remapper; import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.commons.RemappingClassAdapter;
import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodInsnNode;
@@ -150,7 +150,7 @@ public class ApiPart implements IPartHelper {
final DefaultPackageClassNameRemapper remapper = new DefaultPackageClassNameRemapper(); final DefaultPackageClassNameRemapper remapper = new DefaultPackageClassNameRemapper();
remapper.inputOutput.put("appeng/api/parts/LayerBase", n.superName); remapper.inputOutput.put("appeng/api/parts/LayerBase", n.superName);
remapper.inputOutput.put(originalName, n.name); remapper.inputOutput.put(originalName, n.name);
n.accept(new RemappingClassAdapter(cw, remapper)); n.accept(new ClassRemapper(cw, remapper));
// n.accept( cw ); // n.accept( cw );
// n.accept( new TraceClassVisitor( new PrintWriter( System.out ) ) ); // n.accept( new TraceClassVisitor( new PrintWriter( System.out ) ) );
@@ -521,6 +521,10 @@ public final class ApiBlocks implements IBlocks {
.disableItem() .disableItem()
.build(); .build();
if (!doubleSlabDef.maybeBlock().isPresent()) {
return new BlockDefinition(slabId, null, null);
}
Verify.verify(doubleSlabDef.maybeBlock().isPresent()); Verify.verify(doubleSlabDef.maybeBlock().isPresent());
BlockSlab doubleSlabBlock = (BlockSlab) doubleSlabDef.maybeBlock().get(); BlockSlab doubleSlabBlock = (BlockSlab) doubleSlabDef.maybeBlock().get();
@@ -530,6 +534,10 @@ public final class ApiBlocks implements IBlocks {
.features(AEFeature.DECORATIVE_BLOCKS) .features(AEFeature.DECORATIVE_BLOCKS)
.build(); .build();
if (!itemDef.maybeItem().isPresent()) {
return new BlockDefinition(slabId, null, null);
}
Verify.verify(itemDef.maybeItem().isPresent()); Verify.verify(itemDef.maybeItem().isPresent());
// Return a new composite block definition that combines the single slab block with the slab item // Return a new composite block definition that combines the single slab block with the slab item
@@ -78,6 +78,9 @@ public final class ApiItems implements IItems {
private final IItemDefinition entropyManipulator; private final IItemDefinition entropyManipulator;
private final IItemDefinition wirelessTerminal; private final IItemDefinition wirelessTerminal;
private final IItemDefinition wirelessCraftingTerminal;
private final IItemDefinition wirelessPatternTerminal;
private final IItemDefinition wirelessFluidTerminal;
private final IItemDefinition biometricCard; private final IItemDefinition biometricCard;
private final IItemDefinition chargedStaff; private final IItemDefinition chargedStaff;
private final IItemDefinition massCannon; private final IItemDefinition massCannon;
@@ -178,6 +181,10 @@ public final class ApiItems implements IItems {
.dispenserBehavior(DispenserBlockTool::new) .dispenserBehavior(DispenserBlockTool::new)
.build(); .build();
this.wirelessTerminal = powerTools.item("wireless_terminal", ToolWirelessTerminal::new).addFeatures(AEFeature.WIRELESS_ACCESS_TERMINAL).build(); this.wirelessTerminal = powerTools.item("wireless_terminal", ToolWirelessTerminal::new).addFeatures(AEFeature.WIRELESS_ACCESS_TERMINAL).build();
this.wirelessCraftingTerminal = powerTools.item("wireless_crafting_terminal", ToolWirelessCraftingTerminal::new).addFeatures(AEFeature.WIRELESS_CRAFTING_TERMINAL).build();
this.wirelessPatternTerminal = powerTools.item("wireless_pattern_terminal", ToolWirelessPatternTerminal::new).addFeatures(AEFeature.WIRELESS_PATTERN_TERMINAL).build();
this.wirelessFluidTerminal = powerTools.item("wireless_fluid_terminal", ToolWirelessFluidTerminal::new).addFeatures(AEFeature.WIRELESS_FLUID_TERMINAL).build();
this.chargedStaff = powerTools.item("charged_staff", ToolChargedStaff::new).addFeatures(AEFeature.CHARGED_STAFF).build(); this.chargedStaff = powerTools.item("charged_staff", ToolChargedStaff::new).addFeatures(AEFeature.CHARGED_STAFF).build();
this.massCannon = powerTools.item("matter_cannon", ToolMatterCannon::new) this.massCannon = powerTools.item("matter_cannon", ToolMatterCannon::new)
.addFeatures(AEFeature.MATTER_CANNON) .addFeatures(AEFeature.MATTER_CANNON)
@@ -343,6 +350,21 @@ public final class ApiItems implements IItems {
return this.wirelessTerminal; return this.wirelessTerminal;
} }
@Override
public IItemDefinition wirelessCraftingTerminal() {
return wirelessCraftingTerminal;
}
@Override
public IItemDefinition wirelessFluidTerminal() {
return wirelessFluidTerminal;
}
@Override
public IItemDefinition wirelessPatternTerminal() {
return wirelessPatternTerminal;
}
@Override @Override
public IItemDefinition biometricCard() { public IItemDefinition biometricCard() {
return this.biometricCard; return this.biometricCard;
@@ -85,6 +85,8 @@ public final class ApiMaterials implements IMaterials {
private final IItemDefinition cardSpeed; private final IItemDefinition cardSpeed;
private final IItemDefinition cardCapacity; private final IItemDefinition cardCapacity;
private final IItemDefinition cardPatternExpansion; private final IItemDefinition cardPatternExpansion;
private final IItemDefinition cardQuantumLink;
private final IItemDefinition cardMagnet;
private final IItemDefinition cardFuzzy; private final IItemDefinition cardFuzzy;
private final IItemDefinition cardInverter; private final IItemDefinition cardInverter;
private final IItemDefinition cardCrafting; private final IItemDefinition cardCrafting;
@@ -201,6 +203,8 @@ public final class ApiMaterials implements IMaterials {
this.cardSpeed = new DamagedItemDefinition("material.card.acceleration", materials.createMaterial(MaterialType.CARD_SPEED)); this.cardSpeed = new DamagedItemDefinition("material.card.acceleration", materials.createMaterial(MaterialType.CARD_SPEED));
this.cardCapacity = new DamagedItemDefinition("material.card.capacity", materials.createMaterial(MaterialType.CARD_CAPACITY)); this.cardCapacity = new DamagedItemDefinition("material.card.capacity", materials.createMaterial(MaterialType.CARD_CAPACITY));
this.cardPatternExpansion = new DamagedItemDefinition("material.card.pattern.expansion", materials.createMaterial(MaterialType.CARD_PATTERN_EXPANSION)); this.cardPatternExpansion = new DamagedItemDefinition("material.card.pattern.expansion", materials.createMaterial(MaterialType.CARD_PATTERN_EXPANSION));
this.cardQuantumLink = new DamagedItemDefinition("material.card.quantum.link", materials.createMaterial(MaterialType.CARD_QUANTUM_LINK));
this.cardMagnet = new DamagedItemDefinition("material.card.magnet", materials.createMaterial(MaterialType.CARD_MAGNET));
this.cardFuzzy = new DamagedItemDefinition("material.card.fuzzy", materials.createMaterial(MaterialType.CARD_FUZZY)); this.cardFuzzy = new DamagedItemDefinition("material.card.fuzzy", materials.createMaterial(MaterialType.CARD_FUZZY));
this.cardInverter = new DamagedItemDefinition("material.card.inverter", materials.createMaterial(MaterialType.CARD_INVERTER)); this.cardInverter = new DamagedItemDefinition("material.card.inverter", materials.createMaterial(MaterialType.CARD_INVERTER));
this.cardCrafting = new DamagedItemDefinition("material.card.crafting", materials.createMaterial(MaterialType.CARD_CRAFTING)); this.cardCrafting = new DamagedItemDefinition("material.card.crafting", materials.createMaterial(MaterialType.CARD_CRAFTING));
@@ -396,6 +400,16 @@ public final class ApiMaterials implements IMaterials {
return this.cardPatternExpansion; return this.cardPatternExpansion;
} }
@Override
public IItemDefinition cardQuantumLink() {
return this.cardQuantumLink;
}
@Override
public IItemDefinition cardMagnet() {
return this.cardMagnet;
}
@Override @Override
public IItemDefinition cardFuzzy() { public IItemDefinition cardFuzzy() {
return this.cardFuzzy; return this.cardFuzzy;
@@ -64,12 +64,17 @@ public enum AEFeature {
ENTROPY_MANIPULATOR("EntropyManipulator", Constants.CATEGORY_TOOLS), ENTROPY_MANIPULATOR("EntropyManipulator", Constants.CATEGORY_TOOLS),
MATTER_CANNON("MatterCannon", Constants.CATEGORY_TOOLS), MATTER_CANNON("MatterCannon", Constants.CATEGORY_TOOLS),
WIRELESS_ACCESS_TERMINAL("WirelessAccessTerminal", Constants.CATEGORY_TOOLS), WIRELESS_ACCESS_TERMINAL("WirelessAccessTerminal", Constants.CATEGORY_TOOLS),
WIRELESS_CRAFTING_TERMINAL("WirelessCraftingTerminal", Constants.CATEGORY_TOOLS),
WIRELESS_PATTERN_TERMINAL("WirelessPatternTerminal", Constants.CATEGORY_TOOLS),
WIRELESS_FLUID_TERMINAL("WirelessFluidTerminal", Constants.CATEGORY_TOOLS),
COLOR_APPLICATOR("ColorApplicator", Constants.CATEGORY_TOOLS), COLOR_APPLICATOR("ColorApplicator", Constants.CATEGORY_TOOLS),
METEORITE_COMPASS("MeteoriteCompass", Constants.CATEGORY_TOOLS), METEORITE_COMPASS("MeteoriteCompass", Constants.CATEGORY_TOOLS),
SECURITY("Security", Constants.CATEGORY_NETWORK_FEATURES), SECURITY("Security", Constants.CATEGORY_NETWORK_FEATURES),
SPATIAL_IO("SpatialIO", Constants.CATEGORY_NETWORK_FEATURES), SPATIAL_IO("SpatialIO", Constants.CATEGORY_NETWORK_FEATURES),
QUANTUM_NETWORK_BRIDGE("QuantumNetworkBridge", Constants.CATEGORY_NETWORK_FEATURES), QUANTUM_NETWORK_BRIDGE("QuantumNetworkBridge", Constants.CATEGORY_NETWORK_FEATURES),
QUANTUM_LINKING_CARD("QuantumLinkingCard", Constants.CATEGORY_NETWORK_FEATURES),
CHANNELS("Channels", Constants.CATEGORY_NETWORK_FEATURES), CHANNELS("Channels", Constants.CATEGORY_NETWORK_FEATURES),
INTERFACE("Interface", Constants.CATEGORY_NETWORK_BUSES), INTERFACE("Interface", Constants.CATEGORY_NETWORK_BUSES),
@@ -25,10 +25,13 @@ import appeng.api.features.IWirelessTermHandler;
import appeng.api.features.IWirelessTermRegistry; import appeng.api.features.IWirelessTermRegistry;
import appeng.core.localization.PlayerMessages; import appeng.core.localization.PlayerMessages;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -80,6 +83,7 @@ public final class WirelessRegistry implements IWirelessTermRegistry {
} }
final IWirelessTermHandler handler = this.getWirelessTerminalHandler(item); final IWirelessTermHandler handler = this.getWirelessTerminalHandler(item);
final String unparsedKey = handler.getEncryptionKey(item); final String unparsedKey = handler.getEncryptionKey(item);
if (unparsedKey.isEmpty()) { if (unparsedKey.isEmpty()) {
player.sendMessage(PlayerMessages.DeviceNotLinked.get()); player.sendMessage(PlayerMessages.DeviceNotLinked.get());
@@ -94,7 +98,7 @@ public final class WirelessRegistry implements IWirelessTermRegistry {
} }
if (handler.hasPower(player, 0.5, item)) { if (handler.hasPower(player, 0.5, item)) {
Platform.openGUI(player, null, null, GuiBridge.GUI_WIRELESS_TERM); Platform.openGUI(player, null, null, (GuiBridge) handler.getGuiHandler(item));
} else { } else {
player.sendMessage(PlayerMessages.DeviceNotPowered.get()); player.sendMessage(PlayerMessages.DeviceNotPowered.get());
} }
@@ -161,6 +161,7 @@ public enum ButtonToolTips {
// Used in the tooltips of the items in the terminal, when moused over // Used in the tooltips of the items in the terminal, when moused over
ItemsStored, ItemsStored,
ItemsRequestable, ItemsRequestable,
ItemsCraftable,
SchedulingMode, SchedulingMode,
SchedulingModeDefault, SchedulingModeDefault,
@@ -84,7 +84,9 @@ public class AppEngPacketHandlerBase {
PACKET_INFORM_PLAYER(PacketInformPlayer.class), PACKET_INFORM_PLAYER(PacketInformPlayer.class),
PACKET_CRAFTING_CPUS_UPDATE(PacketCraftingCPUsUpdate.class); PACKET_CRAFTING_CPUS_UPDATE(PacketCraftingCPUsUpdate.class),
PACKET_TERMINAL_KEYBIND(PacketTerminalUse.class);
private final Class<? extends AppEngPacket> packetClass; private final Class<? extends AppEngPacket> packetClass;
+24 -8
View File
@@ -43,6 +43,7 @@ import appeng.container.AEBaseContainer;
import appeng.container.ContainerNull; import appeng.container.ContainerNull;
import appeng.container.ContainerOpenContext; import appeng.container.ContainerOpenContext;
import appeng.container.implementations.*; import appeng.container.implementations.*;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.fluids.container.*; import appeng.fluids.container.*;
import appeng.fluids.helper.IFluidInterfaceHost; import appeng.fluids.helper.IFluidInterfaceHost;
import appeng.fluids.parts.PartFluidFormationPlane; import appeng.fluids.parts.PartFluidFormationPlane;
@@ -71,6 +72,7 @@ import appeng.tile.storage.TileDrive;
import appeng.tile.storage.TileIOPort; import appeng.tile.storage.TileIOPort;
import appeng.tile.storage.TileSkyChest; import appeng.tile.storage.TileSkyChest;
import appeng.util.Platform; import appeng.util.Platform;
import baubles.api.BaublesApi;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -101,6 +103,10 @@ public enum GuiBridge implements IGuiHandler {
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, GuiHostType.ITEM, null), GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, GuiHostType.ITEM, null),
GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null), GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
GUI_WIRELESS_CRAFTING_TERMINAL(ContainerWirelessCraftingTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
GUI_WIRELESS_PATTERN_TERMINAL(ContainerWirelessPatternTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
GUI_WIRELESS_FLUID_TERMINAL(ContainerWirelessFluidTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, GuiHostType.ITEM, null), GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, GuiHostType.ITEM, null),
@@ -226,13 +232,17 @@ public enum GuiBridge implements IGuiHandler {
public Object getServerGuiElement(final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z) { public Object getServerGuiElement(final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z) {
final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07); final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07);
final GuiBridge ID = values()[ordinal >> 4]; final GuiBridge ID = values()[ordinal >> 4];
final boolean stem = ((ordinal >> 3) & 1) == 1; final boolean usingItemOnTile = ((ordinal >> 3) & 1) == 1;
if (ID.type.isItem()) { if (ID.type.isItem()) {
ItemStack it = ItemStack.EMPTY; ItemStack it = ItemStack.EMPTY;
if (stem) { if (usingItemOnTile) {
it = player.inventory.getCurrentItem(); it = player.inventory.getCurrentItem();
} else if (x >= 0 && x < player.inventory.mainInventory.size()) { } else if (y == 0) {
it = player.inventory.getStackInSlot(x); if (x >= 0 && x < player.inventory.mainInventory.size()) {
it = player.inventory.getStackInSlot(x);
}
} else if (y == 1 && z == Integer.MIN_VALUE) {
it = BaublesApi.getBaublesHandler(player).getStackInSlot(x);
} }
final Object myItem = this.getGuiObject(it, player, w, x, y, z); final Object myItem = this.getGuiObject(it, player, w, x, y, z);
if (myItem != null && ID.CorrectTileOrPart(myItem)) { if (myItem != null && ID.CorrectTileOrPart(myItem)) {
@@ -337,13 +347,19 @@ public enum GuiBridge implements IGuiHandler {
public Object getClientGuiElement(final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z) { public Object getClientGuiElement(final int ordinal, final EntityPlayer player, final World w, final int x, final int y, final int z) {
final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07); final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07);
final GuiBridge ID = values()[ordinal >> 4]; final GuiBridge ID = values()[ordinal >> 4];
final boolean stem = ((ordinal >> 3) & 1) == 1; final boolean usingItemOnTile = ((ordinal >> 3) & 1) == 1;
if (ID.type.isItem()) { if (ID.type.isItem()) {
ItemStack it = ItemStack.EMPTY; ItemStack it = ItemStack.EMPTY;
if (stem) { if (usingItemOnTile) {
it = player.inventory.getCurrentItem(); it = player.inventory.getCurrentItem();
} else if (x >= 0 && x < player.inventory.mainInventory.size()) { } else if (y == 0) {
it = player.inventory.getStackInSlot(x); if (x >= 0 && x < player.inventory.mainInventory.size()) {
it = player.inventory.getStackInSlot(x);
}
}
if (y == 1 && z == Integer.MIN_VALUE) {
it = BaublesApi.getBaublesHandler(player).getStackInSlot(x);
} }
final Object myItem = this.getGuiObject(it, player, w, x, y, z); final Object myItem = this.getGuiObject(it, player, w, x, y, z);
if (myItem != null && ID.CorrectTileOrPart(myItem)) { if (myItem != null && ID.CorrectTileOrPart(myItem)) {
@@ -27,6 +27,7 @@ import appeng.api.networking.security.IActionHost;
import appeng.container.ContainerOpenContext; import appeng.container.ContainerOpenContext;
import appeng.container.implementations.ContainerCraftAmount; import appeng.container.implementations.ContainerCraftAmount;
import appeng.container.implementations.ContainerCraftConfirm; import appeng.container.implementations.ContainerCraftConfirm;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.sync.AppEngPacket; import appeng.core.sync.AppEngPacket;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
@@ -91,7 +92,14 @@ public class PacketCraftRequest extends AppEngPacket {
final ContainerOpenContext context = cca.getOpenContext(); final ContainerOpenContext context = cca.getOpenContext();
if (context != null) { if (context != null) {
final TileEntity te = context.getTile(); final TileEntity te = context.getTile();
Platform.openGUI(player, te, cca.getOpenContext().getSide(), GuiBridge.GUI_CRAFTING_CONFIRM); if (te != null) {
Platform.openGUI(player, te, cca.getOpenContext().getSide(), GuiBridge.GUI_CRAFTING_CONFIRM);
} else {
if (ah instanceof IInventorySlotAware) {
IInventorySlotAware i = ((IInventorySlotAware) ah);
Platform.openGUI(player, i.getInventorySlot(), GuiBridge.GUI_CRAFTING_CONFIRM, i.isBaubleSlot());
}
}
if (player.openContainer instanceof ContainerCraftConfirm) { if (player.openContainer instanceof ContainerCraftConfirm) {
final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer; final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
@@ -33,6 +33,7 @@ import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.ContainerExpandedProcessingPatternTerm; import appeng.container.implementations.ContainerExpandedProcessingPatternTerm;
import appeng.container.implementations.ContainerPatternEncoder;
import appeng.container.implementations.ContainerPatternTerm; import appeng.container.implementations.ContainerPatternTerm;
import appeng.core.sync.AppEngPacket; import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
@@ -252,7 +253,7 @@ public class PacketJEIRecipe extends AppEngPacket {
con.onCraftMatrixChanged(new WrapperInvItemHandler(craftMatrix)); con.onCraftMatrixChanged(new WrapperInvItemHandler(craftMatrix));
if (this.output != null && ((con instanceof ContainerPatternTerm && !((ContainerPatternTerm) con).isCraftingMode()) || con instanceof ContainerExpandedProcessingPatternTerm)) { if (this.output != null && ((con instanceof ContainerPatternEncoder && !((ContainerPatternEncoder) con).isCraftingMode()))) {
IItemHandler outputSlots = cct.getInventoryByName("output"); IItemHandler outputSlots = cct.getInventoryByName("output");
for (int i = 0; i < outputSlots.getSlots(); ++i) { for (int i = 0; i < outputSlots.getSlots(); ++i) {
ItemHandlerUtil.setStackInSlot(outputSlots, i, ItemStack.EMPTY); ItemHandlerUtil.setStackInSlot(outputSlots, i, ItemStack.EMPTY);
@@ -24,6 +24,7 @@ import appeng.core.AELog;
import appeng.core.sync.AppEngPacket; import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.fluids.client.gui.GuiFluidTerminal; import appeng.fluids.client.gui.GuiFluidTerminal;
import appeng.fluids.client.gui.GuiWirelessFluidTerminal;
import appeng.fluids.util.AEFluidStack; import appeng.fluids.util.AEFluidStack;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
@@ -138,6 +139,8 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket {
if (gs instanceof GuiFluidTerminal) { if (gs instanceof GuiFluidTerminal) {
((GuiFluidTerminal) gs).postUpdate(this.list); ((GuiFluidTerminal) gs).postUpdate(this.list);
} else if (gs instanceof GuiWirelessFluidTerminal) {
((GuiWirelessFluidTerminal)gs).postUpdate(this.list);
} }
} }
@@ -22,6 +22,7 @@ package appeng.core.sync.packets;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.ContainerPatternEncoder;
import appeng.container.implementations.ContainerPatternTerm; import appeng.container.implementations.ContainerPatternTerm;
import appeng.core.sync.AppEngPacket; import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
@@ -98,9 +99,9 @@ public class PacketPatternSlot extends AppEngPacket {
@Override @Override
public void serverPacketData(final INetworkInfo manager, final AppEngPacket packet, final EntityPlayer player) { public void serverPacketData(final INetworkInfo manager, final AppEngPacket packet, final EntityPlayer player) {
final EntityPlayerMP sender = (EntityPlayerMP) player; final EntityPlayerMP sender = (EntityPlayerMP) player;
if (sender.openContainer instanceof ContainerPatternTerm) { if (sender.openContainer instanceof ContainerPatternEncoder) {
final ContainerPatternTerm patternTerminal = (ContainerPatternTerm) sender.openContainer; final ContainerPatternEncoder patternEncoder = (ContainerPatternEncoder) sender.openContainer;
patternTerminal.craftOrGetItem(this); patternEncoder.craftOrGetItem(this);
} }
} }
} }
@@ -19,8 +19,10 @@
package appeng.core.sync.packets; package appeng.core.sync.packets;
import appeng.api.networking.security.IActionHost;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.ContainerOpenContext; import appeng.container.ContainerOpenContext;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.core.sync.AppEngPacket; import appeng.core.sync.AppEngPacket;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
@@ -60,8 +62,21 @@ public class PacketSwitchGuis extends AppEngPacket {
final AEBaseContainer bc = (AEBaseContainer) c; final AEBaseContainer bc = (AEBaseContainer) c;
final ContainerOpenContext context = bc.getOpenContext(); final ContainerOpenContext context = bc.getOpenContext();
if (context != null) { if (context != null) {
final TileEntity te = context.getTile(); final Object target = bc.getTarget();
Platform.openGUI(player, te, context.getSide(), this.newGui); if (target instanceof IActionHost) {
final IActionHost ah = (IActionHost) target;
final TileEntity te = context.getTile();
if (te != null) {
Platform.openGUI(player, te, bc.getOpenContext().getSide(), this.newGui);
} else {
if (ah instanceof IInventorySlotAware) {
IInventorySlotAware i = ((IInventorySlotAware) ah);
Platform.openGUI(player, i.getInventorySlot(), this.newGui, i.isBaubleSlot());
}
}
}
} }
} }
} }
@@ -25,6 +25,7 @@ import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.fluids.container.ContainerFluidInterface; import appeng.fluids.container.ContainerFluidInterface;
import appeng.fluids.container.ContainerFluidTerminal; import appeng.fluids.container.ContainerFluidTerminal;
import appeng.fluids.container.ContainerWirelessFluidTerminal;
import appeng.fluids.util.AEFluidStack; import appeng.fluids.util.AEFluidStack;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
@@ -74,6 +75,8 @@ public class PacketTargetFluidStack extends AppEngPacket {
public void serverPacketData(final INetworkInfo manager, final AppEngPacket packet, final EntityPlayer player) { public void serverPacketData(final INetworkInfo manager, final AppEngPacket packet, final EntityPlayer player) {
if (player.openContainer instanceof ContainerFluidTerminal) { if (player.openContainer instanceof ContainerFluidTerminal) {
((ContainerFluidTerminal) player.openContainer).setTargetStack(this.stack); ((ContainerFluidTerminal) player.openContainer).setTargetStack(this.stack);
} else if (player.openContainer instanceof ContainerWirelessFluidTerminal) {
((ContainerWirelessFluidTerminal) player.openContainer).setTargetStack(this.stack);
} else if (player.openContainer instanceof ContainerFluidInterface) { } else if (player.openContainer instanceof ContainerFluidInterface) {
((ContainerFluidInterface) player.openContainer).setTargetStack(this.stack); ((ContainerFluidInterface) player.openContainer).setTargetStack(this.stack);
} else if (player.openContainer instanceof ContainerFluidInterfaceConfigurationTerminal) { } else if (player.openContainer instanceof ContainerFluidInterfaceConfigurationTerminal) {
@@ -0,0 +1,89 @@
package appeng.core.sync.packets;
import appeng.api.AEApi;
import appeng.api.features.ILocatable;
import appeng.api.features.IWirelessTermHandler;
import appeng.core.localization.PlayerMessages;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.items.tools.powered.Terminal;
import appeng.util.Platform;
import baubles.api.BaublesApi;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Optional;
public class PacketTerminalUse extends AppEngPacket {
Terminal terminal;
public PacketTerminalUse(final ByteBuf stream) {
this.terminal = Terminal.values()[stream.readInt()];
}
public PacketTerminalUse(Enum<Terminal> terminal) {
final ByteBuf data = Unpooled.buffer();
data.writeInt(this.getPacketID());
data.writeInt(terminal.ordinal());
this.configureWrite(data);
}
@Override
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player) {
NonNullList<ItemStack> mainInventory = player.inventory.mainInventory;
for (int i = 0; i < mainInventory.size(); i++) {
ItemStack is = mainInventory.get(i);
if (terminal.getItemDefinition().isSameAs(is)) {
openGui(is, i, player, false);
return;
}
}
if (Loader.isModLoaded("baubles")) {
tryOpenBauble(player);
}
}
@Optional.Method(modid = "baubles")
void tryOpenBauble(EntityPlayer player) {
for (int i = 0; i < BaublesApi.getBaublesHandler(player).getSlots(); i++) {
ItemStack is = BaublesApi.getBaublesHandler(player).getStackInSlot(i);
if (terminal.getItemDefinition().isSameAs(is)) {
openGui(is, i, player, true);
break;
}
}
}
void openGui(ItemStack itemStack, int slotIdx, EntityPlayer player, boolean isBauble) {
final IWirelessTermHandler handler = AEApi.instance().registries().wireless().getWirelessTerminalHandler(itemStack);
if (handler == null) {
return;
}
final String unparsedKey = handler.getEncryptionKey(itemStack);
if (unparsedKey.isEmpty()) {
player.sendMessage(PlayerMessages.DeviceNotLinked.get());
return;
}
final long parsedKey = Long.parseLong(unparsedKey);
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
if (securityStation == null) {
player.sendMessage(PlayerMessages.StationCanNotBeLocated.get());
return;
}
if (handler.hasPower(player, 0.5, itemStack)) {
Platform.openGUI(player, slotIdx, terminal.getBridge(), isBauble);
} else {
player.sendMessage(PlayerMessages.DeviceNotPowered.get());
}
}
}
@@ -130,10 +130,10 @@ public class PacketValueConfig extends AppEngPacket {
final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c; final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c;
lvc.setLevel(Long.parseLong(this.Value), player); lvc.setLevel(Long.parseLong(this.Value), player);
} else if (this.Name.startsWith("PatternTerminal.")) { } else if (this.Name.startsWith("PatternTerminal.")) {
if (c instanceof ContainerPatternTerm) { if (c instanceof ContainerPatternEncoder) {
final ContainerPatternTerm cpt = (ContainerPatternTerm) c; final ContainerPatternEncoder cpt = (ContainerPatternEncoder) c;
if (this.Name.equals("PatternTerminal.CraftMode")) { if (this.Name.equals("PatternTerminal.CraftMode")) {
cpt.getPart().setCraftingRecipe(this.Value.equals("1")); cpt.setCraftingMode(this.Value.equals("1"));
} else if (this.Name.equals("PatternTerminal.Encode")) { } else if (this.Name.equals("PatternTerminal.Encode")) {
if (this.Value.equals("2")) { if (this.Value.equals("2")) {
cpt.encodeAndMoveToInventory(); cpt.encodeAndMoveToInventory();
@@ -159,31 +159,6 @@ public class PacketValueConfig extends AppEngPacket {
} else if (this.Name.equals("PatternTerminal.Substitute")) { } else if (this.Name.equals("PatternTerminal.Substitute")) {
cpt.getPart().setSubstitution(this.Value.equals("1")); cpt.getPart().setSubstitution(this.Value.equals("1"));
} }
} else if (c instanceof ContainerExpandedProcessingPatternTerm) {
final ContainerExpandedProcessingPatternTerm cept = (ContainerExpandedProcessingPatternTerm) c;
if (this.Name.equals("PatternTerminal.Encode")) {
if (this.Value.equals("2")) {
cept.encodeAndMoveToInventory();
} else {
cept.encode();
}
} else if (this.Name.equals("PatternTerminal.Clear")) {
cept.clear();
} else if (this.Name.equals("PatternTerminal.MultiplyByTwo")) {
cept.multiply(2);
} else if (this.Name.equals("PatternTerminal.MultiplyByThree")) {
cept.multiply(3);
} else if (this.Name.equals("PatternTerminal.DivideByTwo")) {
cept.divide(2);
} else if (this.Name.equals("PatternTerminal.DivideByThree")) {
cept.divide(3);
} else if (this.Name.equals("PatternTerminal.IncreaseByOne")) {
cept.increase(1);
} else if (this.Name.equals("PatternTerminal.DecreaseByOne")) {
cept.decrease(1);
} else if (this.Name.equals("PatternTerminal.MaximizeCount")) {
cept.maximizeCount();
}
} }
} else if (this.Name.startsWith("StorageBus.")) { } else if (this.Name.startsWith("StorageBus.")) {
if (this.Name.equals("StorageBus.Action")) { if (this.Name.equals("StorageBus.Action")) {
@@ -19,32 +19,53 @@
package appeng.core.transformer; package appeng.core.transformer;
import appeng.core.AE2ELCore;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.io.ByteStreams;
import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraftforge.fml.common.Loader;
import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.ClassRemapper;
import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.tree.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
public class AE2ELTransformer implements IClassTransformer { public class AE2ELTransformer implements IClassTransformer {
@Override @Override
public byte[] transform(String name, String transformedName, byte[] basicClass) { public byte[] transform(String name, String transformedName, byte[] basicClass) {
if (Loader.instance().getIndexedModList().get("stackup") != null) {
return basicClass;
}
transformedName = transformedName.replace('/', '.'); transformedName = transformedName.replace('/', '.');
byte[] data = basicClass;
Consumer<ClassNode> consumer = (n) -> { Consumer<ClassNode> consumer = (n) -> {
}; };
Consumer<ClassNode> emptyConsumer = consumer; Consumer<ClassNode> emptyConsumer = consumer;
if ("net.minecraft.item.ItemStack".equals(transformedName)) { if ("net.minecraft.item.ItemStack".equals(transformedName)) {
consumer = consumer.andThen(ItemStackPatch::patchCountGetSet); consumer = consumer.andThen(ItemStackPatch::patchCountGetSet);
} else if ("net.minecraft.network.PacketBuffer".equals(transformedName)) {
consumer = consumer.andThen((node) -> {
spliceClasses(node, "appeng.core.transformer.PacketBufferPatch",
"readItemStack", "func_150791_c",
"writeItemStack", "func_150788_a");
});
} }
if (consumer != emptyConsumer) { if (consumer != emptyConsumer) {
return processNode(basicClass, consumer); return processNode(basicClass, consumer);
} else { } else {
return data; return basicClass;
} }
} }
@@ -58,4 +79,106 @@ public class AE2ELTransformer implements IClassTransformer {
return writer.toByteArray(); return writer.toByteArray();
} }
public static void spliceClasses(final ClassNode data, final String className, final String... methods) {
try (InputStream stream = AE2ELCore.class.getClassLoader().getResourceAsStream(className.replace('.', '/') + ".class")) {
spliceClasses(data, ByteStreams.toByteArray(stream), className, methods);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void spliceClasses(final ClassNode nodeData, final byte[] dataSplice, final String className, final String... methods) {
// System.out.println("Splicing from " + className + " to " + targetClassName)
if (dataSplice == null) {
throw new RuntimeException("Class " + className + " not found! This is a AE2EL bug!");
}
final Set<String> methodSet = Sets.newHashSet(methods);
final List<String> methodList = Lists.newArrayList(methods);
final ClassReader readerSplice = new ClassReader(dataSplice);
final String className2 = className.replace('.', '/');
final String targetClassName2 = nodeData.name;
final String targetClassName = targetClassName2.replace('/', '.');
final Remapper remapper = new Remapper() {
public String map(final String name) {
return className2.equals(name) ? targetClassName2 : name;
}
};
ClassNode nodeSplice = new ClassNode();
readerSplice.accept(new ClassRemapper(nodeSplice, remapper), ClassReader.EXPAND_FRAMES);
for (String s : nodeSplice.interfaces) {
if (methodSet.contains(s)) {
nodeData.interfaces.add(s);
System.out.println("Added INTERFACE: " + s);
}
}
for (int i = 0; i < nodeSplice.methods.size(); i++) {
if (methodSet.contains(nodeSplice.methods.get(i).name)) {
MethodNode mn = nodeSplice.methods.get(i);
boolean added = false;
for (int j = 0; j < nodeData.methods.size(); j++) {
if (nodeData.methods.get(j).name.equals(mn.name)
&& nodeData.methods.get(j).desc.equals(mn.desc)) {
MethodNode oldMn = nodeData.methods.get(j);
System.out.println("Spliced in METHOD: " + targetClassName + "." + mn.name);
nodeData.methods.set(j, mn);
if (nodeData.name.equals(nodeSplice.superName)) {
ListIterator<AbstractInsnNode> nodeListIterator = mn.instructions.iterator();
while (nodeListIterator.hasNext()) {
AbstractInsnNode node = nodeListIterator.next();
if (node instanceof MethodInsnNode
&& node.getOpcode() == Opcodes.INVOKESPECIAL) {
MethodInsnNode methodNode = (MethodInsnNode) node;
if (targetClassName2.equals(methodNode.owner)) {
methodNode.owner = nodeData.superName;
}
}
}
}
oldMn.name = methodList.get((methodList.indexOf(oldMn.name)) & (~1)) + "_ae2el_old";
nodeData.methods.add(oldMn);
added = true;
break;
}
}
if (!added) {
System.out.println("Added METHOD: " + targetClassName + "." + mn.name);
nodeData.methods.add(mn);
added = true;
}
}
}
for (int i = 0; i < nodeSplice.fields.size(); i++) {
if (methodSet.contains(nodeSplice.fields.get(i).name)) {
FieldNode mn = nodeSplice.fields.get(i);
boolean added = false;
for (int j = 0; j < nodeData.fields.size(); j++) {
if (nodeData.fields.get(j).name.equals(mn.name)
&& nodeData.fields.get(j).desc.equals(mn.desc)) {
System.out.println("Spliced in FIELD: " + targetClassName + "." + mn.name);
nodeData.fields.set(j, mn);
added = true;
break;
}
}
if (!added) {
System.out.println("Added FIELD: " + targetClassName + "." + mn.name);
nodeData.fields.add(mn);
added = true;
}
}
}
}
} }
@@ -20,11 +20,7 @@
package appeng.core.transformer; package appeng.core.transformer;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.*;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.LdcInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import java.util.ListIterator; import java.util.ListIterator;
@@ -0,0 +1,78 @@
package appeng.core.transformer;
/*
* Copyright (c) 2018, 2020 Adrian Siekierka
*
* This file is part of StackUp.
*
* StackUp is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* StackUp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with StackUp. If not, see <http://www.gnu.org/licenses/>.
*/
import io.netty.buffer.ByteBuf;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import java.io.IOException;
public class PacketBufferPatch extends PacketBuffer {
public PacketBufferPatch(ByteBuf wrapped) {
super(wrapped);
}
@Override
public ItemStack readItemStack() throws IOException {
int id = this.readShort();
if (id < 0) {
return ItemStack.EMPTY;
} else {
int count = this.readByte();
if (count == -42) {
count = this.readInt();
}
int damage = this.readShort();
ItemStack itemstack = new ItemStack(Item.getItemById(id), count, damage);
itemstack.getItem().readNBTShareTag(itemstack, this.readCompoundTag());
return itemstack;
}
}
@Override
public PacketBuffer writeItemStack(ItemStack stack) {
if (stack.isEmpty()) {
this.writeShort(-1);
} else {
this.writeShort(Item.getIdFromItem(stack.getItem()));
if (stack.getCount() >= 0 && stack.getCount() <= 64) {
this.writeByte(stack.getCount());
} else {
this.writeByte(-42);
this.writeInt(stack.getCount());
}
this.writeShort(stack.getMetadata());
NBTTagCompound tag = null;
if (stack.getItem().isDamageable() || stack.getItem().getShareTag()) {
tag = stack.getItem().getNBTShareTag(stack);
}
this.writeCompoundTag(tag);
}
return this;
}
}
@@ -21,6 +21,8 @@ package appeng.crafting;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.me.cache.CraftingGridCache; import appeng.me.cache.CraftingGridCache;
@@ -42,11 +44,15 @@ public class CraftingLinkNexus {
return true; return true;
} }
if (this.getRequest() == null || this.cpu == null) { CraftingLink req = this.getRequest();
if (req == null || this.cpu == null) {
this.tickOfDeath++; this.tickOfDeath++;
} else { } else {
final boolean hasCpu = craftingGridCache.hasCpu(this.cpu.getCpu()); final boolean hasCpu = craftingGridCache.hasCpu(this.cpu.getCpu());
final boolean hasMachine = this.getRequest().getRequester().getActionableNode().getGrid() == g; final ICraftingRequester requester = req.getRequester();
final IGridNode actionableNode = requester != null ? requester.getActionableNode() : null;
final IGrid grid = actionableNode != null ? actionableNode.getGrid() : null;
final boolean hasMachine = grid != null && grid == g;
if (hasCpu && hasMachine) { if (hasCpu && hasMachine) {
this.tickOfDeath = 0; this.tickOfDeath = 0;
@@ -10,10 +10,13 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Random; import java.util.Random;
@@ -97,6 +100,8 @@ public abstract class BlockSlabCommon extends BlockSlab {
return Variant.DEFAULT; return Variant.DEFAULT;
} }
public static class Double extends BlockSlabCommon { public static class Double extends BlockSlabCommon {
private final Block halfSlabBlock; private final Block halfSlabBlock;
@@ -134,6 +139,11 @@ public abstract class BlockSlabCommon extends BlockSlab {
public boolean isDouble() { public boolean isDouble() {
return false; return false;
} }
@Override
public boolean doesSideBlockChestOpening(@Nonnull IBlockState blockState, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nonnull EnumFacing side) {
return false;
}
} }
public enum Variant implements IStringSerializable { public enum Variant implements IStringSerializable {
@@ -0,0 +1,311 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.fluids.client.gui;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.me.FluidRepo;
import appeng.client.me.InternalFluidSlotME;
import appeng.client.me.SlotFluidME;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.fluids.container.ContainerMEPortableFluidCell;
import appeng.fluids.container.ContainerWirelessFluidTerminal;
import appeng.fluids.container.slots.IMEFluidSlot;
import appeng.helpers.InventoryAction;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ClickType;
import net.minecraft.inventory.Slot;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.common.Loader;
import org.lwjgl.input.Mouse;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
public class GuiMEPortableFluidCell extends AEBaseMEGui implements ISortSource, IConfigManagerHost {
private final List<SlotFluidME> meFluidSlots = new LinkedList<>();
private final FluidRepo repo;
private final IConfigManager configSrc;
private final ContainerMEPortableFluidCell container;
private final int offsetX = 9;
private final int rows = 6;
private final int perRow = 9;
protected ITerminalHost terminal;
private MEGuiTextField searchField;
private GuiImgButton sortByBox;
private GuiImgButton sortDirBox;
public GuiMEPortableFluidCell(InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject te, final ContainerWirelessFluidTerminal c) {
super(c);
this.terminal = te;
this.xSize = 185;
this.ySize = 222;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.repo = new FluidRepo(scrollbar, this);
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
(this.container = (ContainerMEPortableFluidCell) this.inventorySlots).setGui(this);
}
@Override
public void initGui() {
this.mc.player.openContainer = this.inventorySlots;
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
this.searchField = new MEGuiTextField(this.fontRenderer, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90, 12);
this.searchField.setEnableBackgroundDrawing(false);
this.searchField.setMaxStringLength(25);
this.searchField.setTextColor(0xFFFFFF);
this.searchField.setSelectionColor(0xFF99FF99);
this.searchField.setVisible(true);
int offset = this.guiTop;
this.buttonList.add(this.sortByBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
offset += 20;
this.buttonList.add(this.sortDirBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc
.getSetting(Settings.SORT_DIRECTION)));
for (int y = 0; y < this.rows; y++) {
for (int x = 0; x < this.perRow; x++) {
SlotFluidME slot = new SlotFluidME(new InternalFluidSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
this.getMeFluidSlots().add(slot);
this.inventorySlots.inventorySlots.add(slot);
}
}
this.setScrollBar();
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.WirelessTerminal.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture(this.getBackground());
final int x_width = 197;
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18);
for (int x = 0; x < 6; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
}
this.drawTexturedModalRect(offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77);
if (this.searchField != null) {
this.searchField.drawTextBox();
}
}
@Override
public void updateScreen() {
this.repo.setPower(this.container.isPowered());
super.updateScreen();
}
@Override
protected void renderHoveredToolTip(int mouseX, int mouseY) {
final Slot slot = this.getSlot(mouseX, mouseY);
if (slot != null && slot instanceof IMEFluidSlot && slot.isEnabled()) {
final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot;
if (fluidSlot.getAEFluidStack() != null && fluidSlot.shouldRenderAsFluid()) {
final IAEFluidStack fluidStack = fluidSlot.getAEFluidStack();
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(fluidStack.getStackSize() / 1000.0) + " B";
final String modName = "" + TextFormatting.BLUE + TextFormatting.ITALIC + Loader.instance()
.getIndexedModList()
.get(Platform.getModId(fluidStack))
.getName();
final List<String> list = new ArrayList<>();
list.add(fluidStack.getFluidStack().getLocalizedName());
list.add(formattedAmount);
list.add(modName);
this.drawHoveringText(list, mouseX, mouseY);
return;
}
}
super.renderHoveredToolTip(mouseX, mouseY);
}
@Override
protected void actionPerformed(GuiButton btn) throws IOException {
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum cv = iBtn.getCurrentValue();
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
try {
NetworkHandler.instance().sendToServer(new PacketValueConfig(iBtn.getSetting().name(), next.name()));
} catch (final IOException e) {
AELog.debug(e);
}
iBtn.set(next);
}
}
}
@Override
protected void handleMouseClick(Slot slot, int slotIdx, int mouseButton, ClickType clickType) {
if (slot instanceof SlotFluidME) {
final SlotFluidME meSlot = (SlotFluidME) slot;
if (clickType == ClickType.PICKUP) {
// TODO: Allow more options
if (mouseButton == 0 && meSlot.getHasStack()) {
this.container.setTargetStack(meSlot.getAEFluidStack());
AELog.debug("mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize());
NetworkHandler.instance().sendToServer(new PacketInventoryAction(InventoryAction.FILL_ITEM, slot.slotNumber, 0));
} else {
this.container.setTargetStack(meSlot.getAEFluidStack());
if (meSlot.getAEFluidStack() != null) {
AELog.debug("mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize());
}
NetworkHandler.instance().sendToServer(new PacketInventoryAction(InventoryAction.EMPTY_ITEM, slot.slotNumber, 0));
}
}
return;
}
super.handleMouseClick(slot, slotIdx, mouseButton, clickType);
}
@Override
protected void keyTyped(final char character, final int key) throws IOException {
if (!this.checkHotbarKeys(key)) {
if (character == ' ' && this.searchField.getText().isEmpty()) {
return;
}
if (this.searchField.textboxKeyTyped(character, key)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
} else {
super.keyTyped(character, key);
}
}
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) throws IOException {
this.searchField.mouseClicked(xCoord, yCoord, btn);
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
this.searchField.setText("");
this.repo.setSearchString("");
this.repo.updateView();
this.setScrollBar();
}
super.mouseClicked(xCoord, yCoord, btn);
}
public void postUpdate(final List<IAEFluidStack> list) {
for (final IAEFluidStack is : list) {
this.repo.postUpdate(is);
}
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar() {
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6));
}
@Override
public Enum getSortBy() {
return this.configSrc.getSetting(Settings.SORT_BY);
}
@Override
public Enum getSortDir() {
return this.configSrc.getSetting(Settings.SORT_DIRECTION);
}
@Override
public Enum getSortDisplay() {
return this.configSrc.getSetting(Settings.VIEW_MODE);
}
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) {
if (this.sortByBox != null) {
this.sortByBox.set(this.configSrc.getSetting(Settings.SORT_BY));
}
if (this.sortDirBox != null) {
this.sortDirBox.set(this.configSrc.getSetting(Settings.SORT_DIRECTION));
}
this.repo.updateView();
}
protected List<SlotFluidME> getMeFluidSlots() {
return this.meFluidSlots;
}
@Override
protected boolean isPowered() {
return this.repo.hasPower();
}
protected String getBackground() {
return "guis/terminal.png";
}
}
@@ -0,0 +1,55 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.fluids.client.gui;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.fluids.container.ContainerWirelessFluidTerminal;
import appeng.helpers.WirelessTerminalGuiObject;
import net.minecraft.client.gui.Gui;
import net.minecraft.entity.player.InventoryPlayer;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class GuiWirelessFluidTerminal extends GuiMEPortableFluidCell {
public GuiWirelessFluidTerminal(final InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject te) {
super(inventoryPlayer, te, new ContainerWirelessFluidTerminal(inventoryPlayer, te));
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/wirelessupgrades.png");
Gui.drawModalRectWithCustomSizedTexture(offsetX + 175, offsetY + 131, 0, 0, 32, 32, 32, 32);
super.drawBG(offsetX, offsetY, mouseX, mouseY);
}
@Override
public List<Rectangle> getJEIExclusionArea() {
List<Rectangle> ea = new ArrayList<>();
ea.add(new Rectangle(this.guiLeft + 174,
this.guiTop + 131,
32,
32));
return ea;
}
}
@@ -0,0 +1,598 @@
package appeng.fluids.container;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.implementations.IUpgradeableCellContainer;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.PlayerMessages;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketMEFluidInventoryUpdate;
import appeng.core.sync.packets.PacketTargetFluidStack;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.fluids.util.AEFluidStack;
import appeng.helpers.InventoryAction;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.automation.StackUpgradeInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import baubles.api.BaublesApi;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.BufferOverflowException;
public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAEAppEngInventory, IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEFluidStack>, IUpgradeableCellContainer, IInventorySlotAware {
protected final WirelessTerminalGuiObject wirelessTerminalGUIObject;
private final IConfigManager clientCM;
private final IMEMonitor<IAEFluidStack> monitor;
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList();
@GuiSync(99)
public boolean hasPower = false;
private final ITerminalHost terminal;
private IConfigManager serverCM;
private IConfigManagerHost gui;
private IGridNode networkNode;
// Holds the fluid the client wishes to extract, or null for insert
private IAEFluidStack clientRequestedTargetFluid = null;
private double powerMultiplier = 0.5;
private int ticks = 0;
private final int slot;
protected AppEngInternalInventory upgrades;
public ContainerMEPortableFluidCell(final InventoryPlayer ip, final IPortableCell monitorable) {
this(ip, monitorable, null, true);
}
public ContainerMEPortableFluidCell(final InventoryPlayer ip, final IPortableCell monitorable, WirelessTerminalGuiObject iGuiItemObject) {
this(ip, monitorable, iGuiItemObject, true);
}
public ContainerMEPortableFluidCell(InventoryPlayer ip, IPortableCell monitorable, WirelessTerminalGuiObject iGuiItemObject, boolean bindInventory) {
super(ip, monitorable);
this.terminal = monitorable;
this.wirelessTerminalGUIObject = (WirelessTerminalGuiObject) monitorable;
this.clientCM = new ConfigManager(this);
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
if (Platform.isServer()) {
this.serverCM = terminal.getConfigManager();
this.monitor = terminal.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
if (this.monitor != null) {
this.monitor.addListener(this, null);
this.setPowerSource((IEnergySource) terminal);
final IGridNode node;
if (terminal instanceof IGridHost) {
node = ((IGridHost) terminal).getGridNode(AEPartLocation.INTERNAL);
} else {
node = ((IActionHost) terminal).getActionableNode();
}
if (node != null) {
this.networkNode = node;
}
}
} else {
this.monitor = null;
}
if (monitorable != null) {
final int slotIndex = ((IInventorySlotAware) monitorable).getInventorySlot();
if (!((IInventorySlotAware) monitorable).isBaubleSlot()) {
this.lockPlayerInventorySlot(slotIndex);
}
this.slot = slotIndex;
} else {
this.slot = -1;
this.lockPlayerInventorySlot(ip.currentItem);
}
if (bindInventory) {
this.bindPlayerInventory(ip, 0, 140);
}
hasPower = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier(), Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.001;
upgrades = new StackUpgradeInventory(wirelessTerminalGUIObject.getItemStack(), this, 2);
this.loadFromNBT();
this.setupUpgrades();
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
final ItemStack currentItem;
if (wirelessTerminalGUIObject.isBaubleSlot()) {
currentItem = BaublesApi.getBaublesHandler(this.getPlayerInv().player).getStackInSlot(this.slot);
} else {
currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
}
if (currentItem.isEmpty()) {
this.setValidContainer(false);
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
if (wirelessTerminalGUIObject.isBaubleSlot()) {
BaublesApi.getBaublesHandler(this.getPlayerInv().player).setStackInSlot(this.slot, this.wirelessTerminalGUIObject.getItemStack());
} else {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
}
} else {
this.setValidContainer(false);
}
}
// drain 1 ae t
this.ticks++;
if (this.ticks > 10) {
double ext = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
if (ext < this.getPowerMultiplier() * this.ticks) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.DeviceNotPowered.get());
}
this.setValidContainer(false);
}
this.ticks = 0;
this.hasPower = ext > 0.001;
}
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
if (Platform.isServer() && this.isValidContainer()) {
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
}
this.setValidContainer(false);
} else {
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
}
if (this.monitor != this.terminal.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class))) {
this.setValidContainer(false);
}
for (final Settings set : this.serverCM.getSettings()) {
final Enum<?> sideLocal = this.serverCM.getSetting(set);
final Enum<?> sideRemote = this.clientCM.getSetting(set);
if (sideLocal != sideRemote) {
this.clientCM.putSetting(set, sideLocal);
for (final IContainerListener crafter : this.listeners) {
if (crafter instanceof EntityPlayerMP) {
try {
NetworkHandler.instance().sendTo(new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter);
} catch (final IOException e) {
AELog.debug(e);
}
}
}
}
}
if (!this.fluids.isEmpty()) {
try {
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
final PacketMEFluidInventoryUpdate piu = new PacketMEFluidInventoryUpdate();
for (final IAEFluidStack is : this.fluids) {
final IAEFluidStack send = monitorCache.findPrecise(is);
if (send == null) {
is.setStackSize(0);
piu.appendFluid(is);
} else {
piu.appendFluid(send);
}
}
if (!piu.isEmpty()) {
this.fluids.resetStatus();
for (final Object c : this.listeners) {
if (c instanceof EntityPlayer) {
NetworkHandler.instance().sendTo(piu, (EntityPlayerMP) c);
}
}
}
} catch (final IOException e) {
AELog.debug(e);
}
}
super.detectAndSendChanges();
}
}
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
if (Platform.isClient()) {
return ItemStack.EMPTY;
}
EntityPlayerMP player = (EntityPlayerMP) p;
if (this.inventorySlots.get(idx) instanceof SlotPlayerInv || this.inventorySlots.get(idx) instanceof SlotPlayerHotBar) {
final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx); // require AE SLots!
ItemStack itemStack = clickSlot.getStack();
ItemStack copy = itemStack.copy();
copy.setCount(1);
IFluidHandlerItem fh = FluidUtil.getFluidHandler(copy);
if (fh == null) {
// only fluid handlers items
return ItemStack.EMPTY;
}
int heldAmount = itemStack.getCount();
for (int i = 0; i < heldAmount; i++) {
copy = itemStack.copy();
copy.setCount(1);
fh = FluidUtil.getFluidHandler(copy);
final FluidStack extract = fh.drain(Integer.MAX_VALUE, false);
if (extract == null || extract.amount < 1) {
return ItemStack.EMPTY;
}
// Check if we can push into the system
final IAEFluidStack notStorable = Platform.poweredInsert(this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack(extract), this.getActionSource(), Actionable.SIMULATE);
if (notStorable != null && notStorable.getStackSize() > 0) {
final int toStore = (int) (extract.amount - notStorable.getStackSize());
final FluidStack storable = fh.drain(toStore, false);
if (storable == null || storable.amount == 0) {
return ItemStack.EMPTY;
} else {
extract.amount = storable.amount;
}
}
// Actually drain
final FluidStack drained = fh.drain(extract, true);
extract.amount = drained.amount;
final IAEFluidStack notInserted = Platform.poweredInsert(this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack(extract), this.getActionSource());
if (notInserted != null && notInserted.getStackSize() > 0) {
IAEFluidStack spill = this.monitor.injectItems(notInserted, Actionable.MODULATE, this.getActionSource());
if (spill != null && spill.getStackSize() > 0) {
fh.fill(spill.getFluidStack(), true);
}
}
if (notInserted == null || notInserted.getStackSize() == 0) {
if (!player.inventory.addItemStackToInventory(fh.getContainer())) {
player.dropItem(fh.getContainer(), false);
}
clickSlot.decrStackSize(1);
}
}
this.detectAndSendChanges();
return ItemStack.EMPTY;
}
return super.transferStackInSlot(p, idx);
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slot, long id) {
if (action != InventoryAction.FILL_ITEM && action != InventoryAction.EMPTY_ITEM) {
super.doAction(player, action, slot, id);
return;
}
final ItemStack held = player.inventory.getItemStack();
ItemStack heldCopy = held.copy();
heldCopy.setCount(1);
IFluidHandlerItem fh = FluidUtil.getFluidHandler(heldCopy);
if (fh == null) {
// only fluid handlers items
return;
}
if (action == InventoryAction.FILL_ITEM && this.clientRequestedTargetFluid != null) {
final IAEFluidStack stack = this.clientRequestedTargetFluid.copy();
// Check how much we can store in the item
stack.setStackSize(Integer.MAX_VALUE);
int amountAllowed = fh.fill(stack.getFluidStack(), false);
int heldAmount = held.getCount();
for (int i = 0; i < heldAmount; i++) {
ItemStack copiedFluidContainer = held.copy();
copiedFluidContainer.setCount(1);
fh = FluidUtil.getFluidHandler(copiedFluidContainer);
// Check if we can pull out of the system
final IAEFluidStack canPull = Platform.poweredExtraction(this.getPowerSource(), this.monitor, stack.setStackSize(amountAllowed), this.getActionSource(), Actionable.SIMULATE);
if (canPull == null || canPull.getStackSize() < 1) {
return;
}
// How much could fit into the container
final int canFill = fh.fill(canPull.getFluidStack(), false);
if (canFill == 0) {
return;
}
// Now actually pull out of the system
final IAEFluidStack pulled = Platform.poweredExtraction(this.getPowerSource(), this.monitor, stack.setStackSize(canFill), this.getActionSource());
if (pulled == null || pulled.getStackSize() < 1) {
// Something went wrong
AELog.error("Unable to pull fluid out of the ME system even though the simulation said yes ");
return;
}
// Actually fill
final int used = fh.fill(pulled.getFluidStack(), true);
if (used != canFill) {
AELog.error("Fluid item [%s] reported a different possible amount than it actually accepted.", held.getDisplayName());
}
if (held.getCount() == 1) {
player.inventory.setItemStack(fh.getContainer());
} else {
player.inventory.getItemStack().shrink(1);
if (!player.inventory.addItemStackToInventory(fh.getContainer())) {
player.dropItem(fh.getContainer(), false);
}
}
}
this.updateHeld(player);
} else if (action == InventoryAction.EMPTY_ITEM) {
int heldAmount = held.getCount();
for (int i = 0; i < heldAmount; i++) {
ItemStack copiedFluidContainer = held.copy();
copiedFluidContainer.setCount(1);
fh = FluidUtil.getFluidHandler(copiedFluidContainer);
// See how much we can drain from the item
final FluidStack extract = fh.drain(Integer.MAX_VALUE, false);
if (extract == null || extract.amount < 1) {
return;
}
// Check if we can push into the system
final IAEFluidStack notStorable = Platform.poweredInsert(this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack(extract), this.getActionSource(), Actionable.SIMULATE);
if (notStorable != null && notStorable.getStackSize() > 0) {
final int toStore = (int) (extract.amount - notStorable.getStackSize());
final FluidStack storable = fh.drain(toStore, false);
if (storable == null || storable.amount == 0) {
return;
} else {
extract.amount = storable.amount;
}
}
// Actually drain
final FluidStack drained = fh.drain(extract, true);
extract.amount = drained.amount;
final IAEFluidStack notInserted = Platform.poweredInsert(this.getPowerSource(), this.monitor, AEFluidStack.fromFluidStack(extract), this.getActionSource());
if (notInserted != null && notInserted.getStackSize() > 0) {
IAEFluidStack spill = this.monitor.injectItems(notInserted, Actionable.MODULATE, this.getActionSource());
if (spill != null && spill.getStackSize() > 0) {
fh.fill(spill.getFluidStack(), true);
}
}
if (held.getCount() == 1) {
player.inventory.setItemStack(fh.getContainer());
} else {
player.inventory.getItemStack().shrink(1);
if (!player.inventory.addItemStackToInventory(fh.getContainer())) {
player.dropItem(fh.getContainer(), false);
}
}
}
this.updateHeld(player);
}
}
private double getPowerMultiplier() {
return this.powerMultiplier;
}
void setPowerMultiplier(final double powerMultiplier) {
this.powerMultiplier = powerMultiplier;
}
public boolean isValid(Object verificationToken) {
return true;
}
@Override
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, IActionSource actionSource) {
for (final IAEFluidStack is : change) {
this.fluids.add(is);
}
}
@Override
public void onListUpdate() {
for (final IContainerListener c : this.listeners) {
this.queueInventory(c);
}
}
@Override
public void addListener(IContainerListener listener) {
super.addListener(listener);
this.queueInventory(listener);
}
@Override
public void onContainerClosed(final EntityPlayer player) {
super.onContainerClosed(player);
if (this.monitor != null) {
this.monitor.removeListener(this);
}
}
private void queueInventory(final IContainerListener c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
try {
PacketMEFluidInventoryUpdate piu = new PacketMEFluidInventoryUpdate();
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
for (final IAEFluidStack send : monitorCache) {
try {
piu.appendFluid(send);
} catch (final BufferOverflowException boe) {
NetworkHandler.instance().sendTo(piu, (EntityPlayerMP) c);
piu = new PacketMEFluidInventoryUpdate();
piu.appendFluid(send);
}
}
NetworkHandler.instance().sendTo(piu, (EntityPlayerMP) c);
} catch (final IOException e) {
AELog.debug(e);
}
}
}
@Override
public IConfigManager getConfigManager() {
if (Platform.isServer()) {
return this.serverCM;
}
return this.clientCM;
}
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) {
if (this.getGui() != null) {
this.getGui().updateSetting(manager, settingName, newValue);
}
}
public void setTargetStack(final IAEFluidStack stack) {
if (Platform.isClient()) {
if (stack == null && this.clientRequestedTargetFluid == null) {
return;
}
if (stack != null && this.clientRequestedTargetFluid != null && stack.getFluidStack()
.isFluidEqual(this.clientRequestedTargetFluid.getFluidStack())) {
return;
}
NetworkHandler.instance().sendToServer(new PacketTargetFluidStack((AEFluidStack) stack));
}
this.clientRequestedTargetFluid = stack == null ? null : stack.copy();
}
private IConfigManagerHost getGui() {
return this.gui;
}
public boolean isPowered() {
return this.hasPower;
}
public void setGui(@Nonnull final IConfigManagerHost gui) {
this.gui = gui;
}
@Override
public int availableUpgrades() {
return 1;
}
@Override
public void setupUpgrades() {
if (wirelessTerminalGUIObject != null) {
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.addSlotToContainer(
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 183, 139 + upgradeSlot * 18, this.getInventoryPlayer()))
.setNotDraggable());
}
}
}
@Override
public void saveChanges() {
if (Platform.isServer()) {
NBTTagCompound tag = new NBTTagCompound();
this.upgrades.writeToNBT(tag, "upgrades");
this.wirelessTerminalGUIObject.saveChanges(tag);
}
}
private void loadFromNBT() {
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
if (data != null) {
upgrades.readFromNBT(wirelessTerminalGUIObject.getItemStack().getTagCompound().getCompoundTag("upgrades"));
}
}
@Override
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
}
@Override
public int getInventorySlot() {
return wirelessTerminalGUIObject.getInventorySlot();
}
@Override
public boolean isBaubleSlot() {
return wirelessTerminalGUIObject.isBaubleSlot();
}
}
@@ -0,0 +1,32 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.fluids.container;
import appeng.helpers.WirelessTerminalGuiObject;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerWirelessFluidTerminal extends ContainerMEPortableFluidCell {
public ContainerWirelessFluidTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
super(ip, gui);
}
}
@@ -25,7 +25,9 @@ import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier; import appeng.api.config.PowerMultiplier;
import appeng.api.features.ILocatable; import appeng.api.features.ILocatable;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
import appeng.api.implementations.IUpgradeableCellHost;
import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.implementations.tiles.IWirelessAccessPoint; import appeng.api.implementations.tiles.IWirelessAccessPoint;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
@@ -43,18 +45,29 @@ import appeng.api.storage.data.IItemList;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.container.interfaces.IInventorySlotAware; import appeng.container.interfaces.IInventorySlotAware;
import appeng.me.cluster.IAECluster;
import appeng.me.cluster.implementations.QuantumCluster;
import appeng.parts.automation.StackUpgradeInventory;
import appeng.parts.automation.UpgradeInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.networking.TileWireless; import appeng.tile.networking.TileWireless;
import appeng.tile.qnb.TileQuantumBridge;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware { public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware, IViewCellStorage, IAEAppEngInventory, IUpgradeableCellHost {
private final ItemStack effectiveItem; private final ItemStack effectiveItem;
private final IWirelessTermHandler wth; private final IWirelessTermHandler wth;
private final String encryptionKey; private final String encryptionKey;
private final EntityPlayer myPlayer; private final EntityPlayer myPlayer;
private final boolean isBaubleSlot;
private IGrid targetGrid; private IGrid targetGrid;
private IStorageGrid sg; private IStorageGrid sg;
private IMEMonitor<IAEItemStack> itemStorage; private IMEMonitor<IAEItemStack> itemStorage;
@@ -63,12 +76,18 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
private double myRange = Double.MAX_VALUE; private double myRange = Double.MAX_VALUE;
private final int inventorySlot; private final int inventorySlot;
private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5);
private final UpgradeInventory upgrades;
private QuantumCluster myQC;
public WirelessTerminalGuiObject(final IWirelessTermHandler wh, final ItemStack is, final EntityPlayer ep, final World w, final int x, final int y, final int z) { public WirelessTerminalGuiObject(final IWirelessTermHandler wh, final ItemStack is, final EntityPlayer ep, final World w, final int x, final int y, final int z) {
this.encryptionKey = wh.getEncryptionKey(is); this.encryptionKey = wh.getEncryptionKey(is);
this.effectiveItem = is; this.effectiveItem = is;
this.myPlayer = ep; this.myPlayer = ep;
this.wth = wh; this.wth = wh;
this.inventorySlot = x; this.inventorySlot = x;
this.isBaubleSlot = y == 1;
ILocatable obj = null; ILocatable obj = null;
@@ -91,6 +110,10 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
} }
} }
} }
upgrades = new StackUpgradeInventory(effectiveItem, this, 2);
this.loadFromNBT();
} }
public double getRange() { public double getRange() {
@@ -227,6 +250,8 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
this.rangeCheck(); this.rangeCheck();
if (this.myWap != null) { if (this.myWap != null) {
return this.myWap.getActionableNode(); return this.myWap.getActionableNode();
} else if (this.myQC != null && this.myQC.getCenter().isPowered()) {
return this.myQC.getCenter().getActionableNode();
} }
return null; return null;
} }
@@ -242,9 +267,10 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
return false; return false;
} }
final IMachineSet tw = this.targetGrid.getMachines(TileWireless.class); IMachineSet tw = this.targetGrid.getMachines(TileWireless.class);
this.myWap = null; this.myWap = null;
this.myQC = null;
for (final IGridNode n : tw) { for (final IGridNode n : tw) {
final IWirelessAccessPoint wap = (IWirelessAccessPoint) n.getMachine(); final IWirelessAccessPoint wap = (IWirelessAccessPoint) n.getMachine();
@@ -253,7 +279,24 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
} }
} }
return this.myWap != null; if (myWap != null) return true;
tw = this.targetGrid.getMachines(TileQuantumBridge.class);
for (final IGridNode n : tw) {
TileQuantumBridge tqb = (TileQuantumBridge) n.getMachine();
if (tqb.getCluster() != null) {
TileQuantumBridge center = ((QuantumCluster) tqb.getCluster()).getCenter();
if (center != null) {
if (center.getInternalInventory().getStackInSlot(1).isItemEqual(AEApi.instance().definitions().materials().cardQuantumLink().maybeStack(1).get())) {
myQC = (QuantumCluster) tqb.getCluster();
myRange = 1;
return true;
}
}
}
}
return this.myWap != null || this.myQC != null;
} }
return false; return false;
} }
@@ -286,4 +329,58 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
return this.inventorySlot; return this.inventorySlot;
} }
@Override
public boolean isBaubleSlot() {
return isBaubleSlot;
}
@Override
public IItemHandler getViewCellStorage() {
NBTTagCompound data = effectiveItem.getTagCompound();
if (data != null) {
viewCell.readFromNBT(data, "viewCell");
}
return this.viewCell;
}
@Override
public void saveChanges() {
NBTTagCompound data = effectiveItem.getTagCompound();
if (data == null) {
data = new NBTTagCompound();
}
viewCell.writeToNBT(data, "viewCell");
upgrades.writeToNBT(data, "upgrades");
}
public void saveChanges(NBTTagCompound data) {
if (effectiveItem.getTagCompound() != null) {
effectiveItem.getTagCompound().merge(data);
} else {
effectiveItem.setTagCompound(data);
}
}
public void loadFromNBT() {
NBTTagCompound data = effectiveItem.getTagCompound();
if (data != null) {
viewCell.readFromNBT(data);
upgrades.readFromNBT(data);
}
}
@Override
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
}
@Override
public IItemHandler getInventoryByName(String name) {
if (name.equals("upgrades")) {
return upgrades;
} else if (name.equals("viewCell")) {
return viewCell;
}
return null;
}
} }
@@ -9,7 +9,7 @@ import java.util.Comparator;
public class InventoryBogoSortModule { public class InventoryBogoSortModule {
private static final boolean loaded = Loader.isModLoaded("bogosorter"); private static final boolean loaded = Loader.isModLoaded("bogosorter");
public static final Comparator<IAEItemStack> COMPARATOR = (o1, o2) -> SortHandler.ITEM_COMPARATOR.compare(o1.getDefinition(), o2.getDefinition()); public static final Comparator<IAEItemStack> COMPARATOR = (o1, o2) -> SortHandler.getClientItemComparator().compare(o1.getDefinition(), o2.getDefinition());
public static boolean isLoaded() { public static boolean isLoaded() {
@@ -7,8 +7,10 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerCraftingTerm; import appeng.container.implementations.ContainerCraftingTerm;
import appeng.container.implementations.ContainerMEMonitorable;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction; import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.InventoryAction; import appeng.helpers.InventoryAction;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
@@ -41,7 +43,7 @@ public class CraftableCallBack implements ITooltipCallback<ItemStack> {
if (!input) return; if (!input) return;
if (list != null) { if (list != null) {
IItemList<IAEItemStack> available = mergeInventories(list, (ContainerCraftingTerm) container); IItemList<IAEItemStack> available = mergeInventories(list, (ContainerMEMonitorable) container);
IAEItemStack search = AEItemStack.fromItemStack(ingredient); IAEItemStack search = AEItemStack.fromItemStack(ingredient);
if (ingredient.getItem().isDamageable() || Platform.isGTDamageableItem(ingredient.getItem())) { if (ingredient.getItem().isDamageable() || Platform.isGTDamageableItem(ingredient.getItem())) {
@@ -100,7 +102,7 @@ public class CraftableCallBack implements ITooltipCallback<ItemStack> {
} }
} }
IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerCraftingTerm containerCraftingTerm) { IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerMEMonitorable containerCraftingTerm) {
IItemList<IAEItemStack> itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); IItemList<IAEItemStack> itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
for (IAEItemStack i : repo) { for (IAEItemStack i : repo) {
itemList.addStorage(i); itemList.addStorage(i);
@@ -111,9 +113,11 @@ public class CraftableCallBack implements ITooltipCallback<ItemStack> {
itemList.addStorage(AEItemStack.fromItemStack(invWrapper.getStackInSlot(i))); itemList.addStorage(AEItemStack.fromItemStack(invWrapper.getStackInSlot(i)));
} }
IItemHandler itemHandler = containerCraftingTerm.getInventoryByName("crafting"); if (containerCraftingTerm instanceof IContainerCraftingPacket) {
for (int i = 0; i < itemHandler.getSlots(); i++) { IItemHandler itemHandler = ((IContainerCraftingPacket) containerCraftingTerm).getInventoryByName("crafting");
itemList.addStorage(AEItemStack.fromItemStack(itemHandler.getStackInSlot(i))); for (int i = 0; i < itemHandler.getSlots(); i++) {
itemList.addStorage(AEItemStack.fromItemStack(itemHandler.getStackInSlot(i)));
}
} }
return itemList; return itemList;
} }
@@ -2,11 +2,17 @@ package appeng.integration.modules.jei;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.client.gui.implementations.GuiCraftingTerm; import appeng.client.gui.implementations.GuiCraftingTerm;
import appeng.client.gui.implementations.GuiWirelessCraftingTerminal;
import appeng.container.implementations.ContainerCraftingTerm; import appeng.container.implementations.ContainerCraftingTerm;
import appeng.container.implementations.ContainerMEMonitorable;
import appeng.container.implementations.ContainerWirelessCraftingTerminal;
import appeng.helpers.IContainerCraftingPacket;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import mezz.jei.api.gui.IGuiIngredient; import mezz.jei.api.gui.IGuiIngredient;
@@ -39,13 +45,10 @@ public class JEIMissingItem implements IRecipeTransferError {
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
JEIMissingItem(Container container, @Nonnull IRecipeLayout recipeLayout) { JEIMissingItem(Container container, @Nonnull IRecipeLayout recipeLayout) {
if (container instanceof ContainerCraftingTerm) { if (container instanceof ContainerMEMonitorable) {
ContainerCraftingTerm craftingTerm = (ContainerCraftingTerm) container; IItemList<IAEItemStack> ir = ((ContainerMEMonitorable) container).items;
GuiCraftingTerm g = (GuiCraftingTerm) craftingTerm.getGui();
IItemList<IAEItemStack> ir = g.getRepo().getList(); IItemList<IAEItemStack> available = mergeInventories(ir, (ContainerMEMonitorable) container);
IItemList<IAEItemStack> available = mergeInventories(ir, (ContainerCraftingTerm) container);
boolean found; boolean found;
this.errored = false; this.errored = false;
@@ -54,7 +57,7 @@ public class JEIMissingItem implements IRecipeTransferError {
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) { for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
found = false; found = false;
if (i.isInput() && i.getAllIngredients().size() > 0) { if (i.isInput() && !i.getAllIngredients().isEmpty()) {
List<?> allIngredients = i.getAllIngredients(); List<?> allIngredients = i.getAllIngredients();
for (Object allIngredient : allIngredients) { for (Object allIngredient : allIngredients) {
if (allIngredient instanceof ItemStack) { if (allIngredient instanceof ItemStack) {
@@ -63,7 +66,7 @@ public class JEIMissingItem implements IRecipeTransferError {
IAEItemStack search = AEItemStack.fromItemStack(stack); IAEItemStack search = AEItemStack.fromItemStack(stack);
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) { if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL); Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
if (fuzzy.size() > 0) { if (!fuzzy.isEmpty()) {
for (IAEItemStack itemStack : fuzzy) { for (IAEItemStack itemStack : fuzzy) {
if (itemStack.getStackSize() > 0) { if (itemStack.getStackSize() > 0) {
if (Platform.isGTDamageableItem(stack.getItem())) { if (Platform.isGTDamageableItem(stack.getItem())) {
@@ -109,11 +112,9 @@ public class JEIMissingItem implements IRecipeTransferError {
@Override @Override
public void showError(Minecraft minecraft, int mouseX, int mouseY, @Nonnull IRecipeLayout recipeLayout, int recipeX, int recipeY) { public void showError(Minecraft minecraft, int mouseX, int mouseY, @Nonnull IRecipeLayout recipeLayout, int recipeX, int recipeY) {
Container c = minecraft.player.openContainer; Container c = minecraft.player.openContainer;
if (c instanceof ContainerCraftingTerm) { if (c instanceof ContainerMEMonitorable) {
ContainerCraftingTerm craftingTerm = (ContainerCraftingTerm) c; ContainerMEMonitorable container = (ContainerMEMonitorable) c;
IItemList<IAEItemStack> ir = ((ContainerMEMonitorable) c).items;
GuiCraftingTerm g = (GuiCraftingTerm) craftingTerm.getGui();
IItemList<IAEItemStack> ir = g.getRepo().getList();
boolean found; boolean found;
boolean craftable; boolean craftable;
int currentSlot = 0; int currentSlot = 0;
@@ -121,7 +122,7 @@ public class JEIMissingItem implements IRecipeTransferError {
if (System.currentTimeMillis() - lastUpdate > 1000) { if (System.currentTimeMillis() - lastUpdate > 1000) {
lastUpdate = System.currentTimeMillis(); lastUpdate = System.currentTimeMillis();
available = mergeInventories(ir, (ContainerCraftingTerm) minecraft.player.openContainer); available = mergeInventories(ir, container);
this.foundSlots.clear(); this.foundSlots.clear();
this.craftableSlots.clear(); this.craftableSlots.clear();
} else { } else {
@@ -144,7 +145,7 @@ public class JEIMissingItem implements IRecipeTransferError {
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) { for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
found = false; found = false;
craftable = false; craftable = false;
ArrayList<ItemStack> valid = new ArrayList<>(); IItemList<IAEItemStack> valid = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
if (i.isInput()) { if (i.isInput()) {
List<?> allIngredients = i.getAllIngredients(); List<?> allIngredients = i.getAllIngredients();
for (Object allIngredient : allIngredients) { for (Object allIngredient : allIngredients) {
@@ -154,7 +155,7 @@ public class JEIMissingItem implements IRecipeTransferError {
IAEItemStack search = AEItemStack.fromItemStack(stack); IAEItemStack search = AEItemStack.fromItemStack(stack);
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) { if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL); Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
if (fuzzy.size() > 0) { if (!fuzzy.isEmpty()) {
for (IAEItemStack itemStack : fuzzy) { for (IAEItemStack itemStack : fuzzy) {
if (itemStack.getStackSize() > 0) { if (itemStack.getStackSize() > 0) {
if (Platform.isGTDamageableItem(stack.getItem())) { if (Platform.isGTDamageableItem(stack.getItem())) {
@@ -164,7 +165,7 @@ public class JEIMissingItem implements IRecipeTransferError {
} }
found = true; found = true;
used.add(itemStack.copy().setStackSize(1)); used.add(itemStack.copy().setStackSize(1));
valid.add(itemStack.copy().setStackSize(1).createItemStack()); valid.add(itemStack.copy().setStackSize(1));
} else { } else {
if (itemStack.isCraftable()) { if (itemStack.isCraftable()) {
craftable = true; craftable = true;
@@ -179,12 +180,12 @@ public class JEIMissingItem implements IRecipeTransferError {
if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) { if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) {
used.add(ext.copy().setStackSize(1)); used.add(ext.copy().setStackSize(1));
if (craftable) { if (craftable) {
valid.clear(); valid = null;
} }
valid.add(ext.copy().setStackSize(1).createItemStack()); valid.add(ext.copy().setStackSize(1));
found = true; found = true;
} else if (ext.isCraftable()) { } else if (ext.isCraftable()) {
valid.add(ext.copy().setStackSize(1).createItemStack()); valid.add(ext.copy().setStackSize(1));
craftable = true; craftable = true;
} }
} }
@@ -194,21 +195,29 @@ public class JEIMissingItem implements IRecipeTransferError {
} }
} }
} }
if (i.getAllIngredients().size() == 0) { if (i.getAllIngredients().isEmpty()) {
found = true; found = true;
} }
ArrayList<ItemStack> validStacks = new ArrayList<>();
if (valid != null) {
valid.forEach(v -> {
ItemStack validStack = v.createItemStack();
validStack.setCount(1);
validStacks.add(validStack);
});
}
if (!found) { if (!found) {
if (craftable) { if (craftable) {
i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY); i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY);
this.craftableSlots.add(currentSlot); this.craftableSlots.add(currentSlot);
recipeLayout.getItemStacks().set(currentSlot, valid); recipeLayout.getItemStacks().set(currentSlot, validStacks);
} else { } else {
i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY); i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY);
} }
this.errored = true; this.errored = true;
} else { } else {
this.foundSlots.add(currentSlot); this.foundSlots.add(currentSlot);
recipeLayout.getItemStacks().set(currentSlot, valid); recipeLayout.getItemStacks().set(currentSlot, validStacks);
} }
} }
currentSlot++; currentSlot++;
@@ -219,7 +228,7 @@ public class JEIMissingItem implements IRecipeTransferError {
} }
} }
IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerCraftingTerm containerCraftingTerm) { IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerMEMonitorable containerCraftingTerm) {
IItemList<IAEItemStack> itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); IItemList<IAEItemStack> itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
for (IAEItemStack i : repo) { for (IAEItemStack i : repo) {
itemList.addStorage(i); itemList.addStorage(i);
@@ -230,9 +239,11 @@ public class JEIMissingItem implements IRecipeTransferError {
itemList.addStorage(AEItemStack.fromItemStack(invWrapper.getStackInSlot(i))); itemList.addStorage(AEItemStack.fromItemStack(invWrapper.getStackInSlot(i)));
} }
IItemHandler itemHandler = containerCraftingTerm.getInventoryByName("crafting"); if (containerCraftingTerm instanceof IContainerCraftingPacket) {
for (int i = 0; i < itemHandler.getSlots(); i++) { IItemHandler itemHandler = ((IContainerCraftingPacket) containerCraftingTerm).getInventoryByName("crafting");
itemList.addStorage(AEItemStack.fromItemStack(itemHandler.getStackInSlot(i))); for (int i = 0; i < itemHandler.getSlots(); i++) {
itemList.addStorage(AEItemStack.fromItemStack(itemHandler.getStackInSlot(i)));
}
} }
return itemList; return itemList;
} }
@@ -27,9 +27,7 @@ import appeng.api.definitions.IMaterials;
import appeng.api.features.IGrinderRecipe; import appeng.api.features.IGrinderRecipe;
import appeng.api.features.IInscriberRecipe; import appeng.api.features.IInscriberRecipe;
import appeng.client.gui.AEGuiHandler; import appeng.client.gui.AEGuiHandler;
import appeng.container.implementations.ContainerCraftingTerm; import appeng.container.implementations.*;
import appeng.container.implementations.ContainerExpandedProcessingPatternTerm;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
@@ -86,8 +84,10 @@ public class JEIPlugin implements IModPlugin {
// Allow recipe transfer from JEI to crafting and pattern terminal // Allow recipe transfer from JEI to crafting and pattern terminal
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerCraftingTerm.class), VanillaRecipeCategoryUid.CRAFTING); registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerCraftingTerm.class), VanillaRecipeCategoryUid.CRAFTING);
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerWirelessCraftingTerminal.class), VanillaRecipeCategoryUid.CRAFTING);
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerPatternTerm.class), Constants.UNIVERSAL_RECIPE_TRANSFER_UID); registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerPatternTerm.class), Constants.UNIVERSAL_RECIPE_TRANSFER_UID);
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerExpandedProcessingPatternTerm.class), Constants.UNIVERSAL_RECIPE_TRANSFER_UID); registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerExpandedProcessingPatternTerm.class), Constants.UNIVERSAL_RECIPE_TRANSFER_UID);
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerWirelessPatternTerminal.class), Constants.UNIVERSAL_RECIPE_TRANSFER_UID);
aeGuiHandler = new AEGuiHandler(); aeGuiHandler = new AEGuiHandler();
registry.addAdvancedGuiHandlers(aeGuiHandler); registry.addAdvancedGuiHandlers(aeGuiHandler);
@@ -20,7 +20,9 @@ package appeng.integration.modules.jei;
import appeng.container.implementations.ContainerCraftingTerm; import appeng.container.implementations.ContainerCraftingTerm;
import appeng.container.implementations.ContainerPatternEncoder;
import appeng.container.implementations.ContainerPatternTerm; import appeng.container.implementations.ContainerPatternTerm;
import appeng.container.implementations.ContainerWirelessCraftingTerminal;
import appeng.container.slot.SlotCraftingMatrix; import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotFakeCraftingMatrix; import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.core.AELog; import appeng.core.AELog;
@@ -74,7 +76,7 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
} }
if (!doTransfer) { if (!doTransfer) {
if (container instanceof ContainerCraftingTerm && recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) { if (recipeType.equals(VanillaRecipeCategoryUid.CRAFTING) && (container instanceof ContainerCraftingTerm || container instanceof ContainerWirelessCraftingTerminal)) {
JEIMissingItem error = new JEIMissingItem(container, recipeLayout); JEIMissingItem error = new JEIMissingItem(container, recipeLayout);
if (error.errored()) if (error.errored())
return error; return error;
@@ -82,9 +84,9 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
return null; return null;
} }
if (container instanceof ContainerPatternTerm) { if (container instanceof ContainerPatternEncoder) {
try { try {
if (!((ContainerPatternTerm) container).isCraftingMode()) { if (!((ContainerPatternEncoder) container).isCraftingMode()) {
if (recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) { if (recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", "1")); NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", "1"));
} }
@@ -19,6 +19,8 @@
package appeng.items.materials; package appeng.items.materials;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost; import appeng.api.implementations.IUpgradeableHost;
import appeng.api.implementations.items.IItemGroup; import appeng.api.implementations.items.IItemGroup;
@@ -27,11 +29,14 @@ import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.implementations.tiles.ISegmentedInventory; import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.parts.IPartHost; import appeng.api.parts.IPartHost;
import appeng.api.parts.SelectedPart; import appeng.api.parts.SelectedPart;
import appeng.api.storage.ICellWorkbenchItem;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.features.AEFeature; import appeng.core.features.AEFeature;
import appeng.core.features.IStackSrc; import appeng.core.features.IStackSrc;
import appeng.core.features.MaterialStackSrc; import appeng.core.features.MaterialStackSrc;
import appeng.items.AEBaseItem; import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.AdaptorItemHandler;
@@ -51,6 +56,7 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@@ -63,7 +69,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public final class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule { public final class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule, ICellWorkbenchItem {
public static ItemMaterial instance; public static ItemMaterial instance;
private static final int KILO_SCALAR = 1024; private static final int KILO_SCALAR = 1024;
@@ -90,6 +96,17 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
lines.add(c.getString("InscribeName")); lines.add(c.getString("InscribeName"));
} }
if (mt == MaterialType.CARD_MAGNET) {
final NBTTagCompound c = Platform.openNbtData(stack);
if (!c.hasKey("enabled") || c.getBoolean("enabled")) {
lines.add(I18n.translateToLocal("gui.tooltips.appliedenergistics2.Enable"));
} else {
lines.add(I18n.translateToLocal("gui.tooltips.appliedenergistics2.Disabled"));
}
lines.add(I18n.translateToLocal("item.appliedenergistics2.material.card_magnet.usage"));
lines.add(I18n.translateToLocal("item.appliedenergistics2.material.card_magnet.partition"));
}
final Upgrades u = this.getType(stack); final Upgrades u = this.getType(stack);
if (u != null) { if (u != null) {
final List<String> textList = new ArrayList<>(); final List<String> textList = new ArrayList<>();
@@ -144,6 +161,10 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
return Upgrades.CRAFTING; return Upgrades.CRAFTING;
case CARD_PATTERN_EXPANSION: case CARD_PATTERN_EXPANSION:
return Upgrades.PATTERN_EXPANSION; return Upgrades.PATTERN_EXPANSION;
case CARD_MAGNET:
return Upgrades.MAGNET;
case CARD_QUANTUM_LINK:
return Upgrades.QUANTUM_LINK;
default: default:
return null; return null;
} }
@@ -309,6 +330,36 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
return false; return false;
} }
@Override
public boolean isEditable(ItemStack is) {
return is.isItemEqual(AEApi.instance().definitions().materials().cardMagnet().maybeStack(1).get());
}
@Override
public IItemHandler getUpgradesInventory(final ItemStack is) {
return new CellUpgrades(is, 2);
}
@Override
public IItemHandler 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());
}
private static class SlightlyBetterSort implements Comparator<String> { private static class SlightlyBetterSort implements Comparator<String> {
private final Pattern pattern; private final Pattern pattern;
@@ -118,7 +118,9 @@ public enum MaterialType {
FLUID_CELL16K_PART(56, "material_fluid_cell16k_part", EnumSet.of(AEFeature.STORAGE_CELLS)), FLUID_CELL16K_PART(56, "material_fluid_cell16k_part", EnumSet.of(AEFeature.STORAGE_CELLS)),
FLUID_CELL64K_PART(57, "material_fluid_cell64k_part", EnumSet.of(AEFeature.STORAGE_CELLS)), FLUID_CELL64K_PART(57, "material_fluid_cell64k_part", EnumSet.of(AEFeature.STORAGE_CELLS)),
CARD_PATTERN_EXPANSION(58, "material_card_pattern_expansion", EnumSet.of(AEFeature.ADVANCED_CARDS)); CARD_PATTERN_EXPANSION(58, "material_card_pattern_expansion", EnumSet.of(AEFeature.ADVANCED_CARDS)),
CARD_QUANTUM_LINK(59, "material_card_quantum_link", EnumSet.of(AEFeature.ADVANCED_CARDS, AEFeature.QUANTUM_LINKING_CARD)),
CARD_MAGNET(60, "material_card_magnet", EnumSet.of(AEFeature.BASIC_CARDS));
private final Set<AEFeature> features; private final Set<AEFeature> features;
@@ -29,6 +29,8 @@ import appeng.helpers.InvalidPatternHelper;
import appeng.helpers.PatternHelper; import appeng.helpers.PatternHelper;
import appeng.items.AEBaseItem; import appeng.items.AEBaseItem;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.item.ItemStackHashStrategy;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
@@ -45,12 +47,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap;
public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternItem { public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternItem {
private static final ItemStackHashStrategy hashStrategy = ItemStackHashStrategy.comparingAllButCount();
// rather simple client side caching. // rather simple client side caching.
private static final Map<ItemStack, ItemStack> SIMPLE_CACHE = new WeakHashMap<>(); private static final Map<ItemStack, ItemStack> SIMPLE_CACHE = new Object2ObjectOpenCustomHashMap<>(hashStrategy);
public ItemEncodedPattern() { public ItemEncodedPattern() {
this.setMaxStackSize(64); this.setMaxStackSize(64);
@@ -70,6 +72,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
private boolean clearPattern(final ItemStack stack, final EntityPlayer player) { private boolean clearPattern(final ItemStack stack, final EntityPlayer player) {
if (player.isSneaking()) { if (player.isSneaking()) {
SIMPLE_CACHE.remove(stack);
if (Platform.isClient()) { if (Platform.isClient()) {
return false; return false;
} }
@@ -0,0 +1,28 @@
package appeng.items.tools.powered;
import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition;
import appeng.core.sync.GuiBridge;
public enum Terminal {
WIRELESS_TERMINAL(AEApi.instance().definitions().items().wirelessTerminal(), GuiBridge.GUI_WIRELESS_TERM),
WIRELESS_CRAFTING_TERMINAL(AEApi.instance().definitions().items().wirelessCraftingTerminal(), GuiBridge.GUI_WIRELESS_CRAFTING_TERMINAL),
WIRELESS_PATTERN_TERMINAL(AEApi.instance().definitions().items().wirelessPatternTerminal(), GuiBridge.GUI_WIRELESS_PATTERN_TERMINAL),
WIRELESS_FLUID_TERMINAL(AEApi.instance().definitions().items().wirelessFluidTerminal(), GuiBridge.GUI_WIRELESS_FLUID_TERMINAL);
final GuiBridge bridge;
final IItemDefinition itemDefinition;
Terminal(IItemDefinition itemDefinition, GuiBridge guiBridge) {
this.itemDefinition = itemDefinition;
this.bridge = guiBridge;
}
public GuiBridge getBridge() {
return bridge;
}
public IItemDefinition getItemDefinition() {
return itemDefinition;
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.items.tools.powered;
import appeng.api.AEApi;
import appeng.api.features.IWirelessTermHandler;
import appeng.core.sync.GuiBridge;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.network.IGuiHandler;
public class ToolWirelessCraftingTerminal extends ToolWirelessTerminal implements IWirelessTermHandler {
public ToolWirelessCraftingTerminal() {
super();
}
@Override
public boolean canHandle(final ItemStack is) {
return AEApi.instance().definitions().items().wirelessCraftingTerminal().isSameAs(is);
}
@Override
public IGuiHandler getGuiHandler(ItemStack is) {
return GuiBridge.GUI_WIRELESS_CRAFTING_TERMINAL;
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.items.tools.powered;
import appeng.api.AEApi;
import appeng.api.features.IWirelessTermHandler;
import appeng.core.sync.GuiBridge;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.network.IGuiHandler;
public class ToolWirelessFluidTerminal extends ToolWirelessTerminal implements IWirelessTermHandler {
public ToolWirelessFluidTerminal() {
super();
}
@Override
public boolean canHandle(final ItemStack is) {
return AEApi.instance().definitions().items().wirelessFluidTerminal().isSameAs(is);
}
@Override
public IGuiHandler getGuiHandler(ItemStack is) {
return GuiBridge.GUI_WIRELESS_FLUID_TERMINAL;
}
}
@@ -0,0 +1,44 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.items.tools.powered;
import appeng.api.AEApi;
import appeng.api.features.IWirelessTermHandler;
import appeng.core.sync.GuiBridge;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.network.IGuiHandler;
public class ToolWirelessPatternTerminal extends ToolWirelessTerminal implements IWirelessTermHandler {
public ToolWirelessPatternTerminal() {
super();
}
@Override
public boolean canHandle(final ItemStack is) {
return AEApi.instance().definitions().items().wirelessPatternTerminal().isSameAs(is);
}
@Override
public IGuiHandler getGuiHandler(ItemStack is) {
return GuiBridge.GUI_WIRELESS_PATTERN_TERMINAL;
}
}
@@ -20,30 +20,53 @@ package appeng.items.tools.powered;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.*; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.Upgrades;
import appeng.api.config.ViewItems;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.items.materials.ItemMaterial;
import appeng.items.tools.powered.powersink.AEBasePoweredItem; import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.util.ConfigManager; import appeng.util.ConfigManager;
import appeng.util.Platform; import appeng.util.Platform;
import baubles.api.BaubleType;
import baubles.api.IBauble;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.common.network.IGuiHandler;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.ItemStackHandler;
import java.util.List; import java.util.List;
@Optional.Interface(iface = "baubles.api.IBauble", modid = "baubles")
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler { public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler, IBauble {
int magnetTick;
public ToolWirelessTerminal() { public ToolWirelessTerminal() {
super(AEConfig.instance().getWirelessTerminalBattery()); super(AEConfig.instance().getWirelessTerminalBattery());
@@ -130,4 +153,115 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
return slotChanged; return slotChanged;
} }
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
if (Platform.isServer()) {
magnetLogic(stack, worldIn, entityIn);
}
}
@Override
public IGuiHandler getGuiHandler(ItemStack is) {
return GuiBridge.GUI_WIRELESS_TERM;
}
@Optional.Method(modid = "baubles")
@Override
public BaubleType getBaubleType(ItemStack itemStack) {
return BaubleType.TRINKET;
}
@Optional.Method(modid = "baubles")
@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
if (Platform.isServer()) {
magnetLogic(itemstack, player.world, player);
}
}
public void magnetLogic(ItemStack stack, World worldIn, Entity entityIn) {
if (entityIn instanceof EntityPlayer) {
this.magnetTick++;
if (magnetTick % 5 != 0) {
return;
}
magnetTick = 0;
if (!entityIn.isSneaking()) {
NBTTagCompound upgradeNBT = Platform.openNbtData(stack).getCompoundTag("upgrades");
ItemStackHandler siu = new ItemStackHandler(0);
siu.deserializeNBT(upgradeNBT);
for (int s = 0; s < siu.getSlots(); s++) {
ItemStack is = siu.getStackInSlot(s);
if (AEApi.instance().definitions().materials().cardMagnet().isSameAs(is)) {
NBTTagCompound tag = is.getTagCompound();
if (tag != null && !tag.getBoolean("enabled")) {
return;
}
ItemMaterial im = (ItemMaterial) is.getItem();
CellConfig c = (CellConfig) im.getConfigInventory(is);
CellUpgrades u = (CellUpgrades) im.getUpgradesInventory(is);
FuzzyMode fz = null;
boolean isFuzzy = u.getInstalledUpgrades(Upgrades.FUZZY) == 1;
if (isFuzzy) {
fz = im.getFuzzyMode(is);
}
boolean inverted = u.getInstalledUpgrades(Upgrades.INVERTER) == 1;
List<EntityItem> ei = worldIn.getEntitiesWithinAABB(EntityItem.class,
new AxisAlignedBB(
entityIn.posX - 5, entityIn.posY - 5, entityIn.posZ - 5,
entityIn.posX + 5, entityIn.posY + 5, entityIn.posZ + 5
));
boolean emptyFilter = true;
for (EntityItem i : ei) {
if (i.isDead) {
continue;
}
NBTTagCompound itemTag = i.getEntityData();
if (itemTag.hasKey("PreventRemoteMovement")) {
continue;
}
if (i.getThrower() != null && i.getThrower().equals(entityIn.getName()) && i.cannotPickup()) {
continue;
}
boolean matched = false;
for (int ss = 0; ss < c.getSlots(); ss++) {
ItemStack filter = c.getStackInSlot(ss);
if (filter.isEmpty()) continue;
emptyFilter = false;
if (isFuzzy) {
if (Platform.itemComparisons().isFuzzyEqualItem(filter, i.getItem(), fz)) {
matched = true;
break;
}
} else {
if (Platform.itemComparisons().isSameItem(filter, i.getItem())) {
matched = true;
break;
}
}
}
if (emptyFilter) {
teleportItem(i, entityIn);
} else if (matched && !inverted) {
teleportItem(i, entityIn);
} else if (!matched && inverted) {
teleportItem(i, entityIn);
}
}
}
}
}
}
}
private void teleportItem(EntityItem i, Entity entityIn) {
i.motionX = i.motionY = i.motionZ = 0;
i.setPosition(entityIn.posX, entityIn.posY, entityIn.posZ);
}
} }
+10 -7
View File
@@ -63,6 +63,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.stream.StreamSupport;
public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler<IAEItemStack> { public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper, ICellProvider, IMEInventoryHandler<IAEItemStack> {
@@ -285,14 +286,16 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
private void updateCPUClusters() { private void updateCPUClusters() {
this.craftingCPUClusters.clear(); this.craftingCPUClusters.clear();
for (final IGridNode cst : this.grid.getMachines(TileCraftingStorageTile.class)) { for (Object cls: StreamSupport.stream(grid.getMachinesClasses().spliterator(), false).filter(TileCraftingStorageTile.class::isAssignableFrom).toArray()) {
final TileCraftingStorageTile tile = (TileCraftingStorageTile) cst.getMachine(); for (final IGridNode cst : this.grid.getMachines((Class<? extends IGridHost>) cls)) {
final CraftingCPUCluster cluster = (CraftingCPUCluster) tile.getCluster(); final TileCraftingStorageTile tile = (TileCraftingStorageTile) cst.getMachine();
if (cluster != null) { final CraftingCPUCluster cluster = (CraftingCPUCluster) tile.getCluster();
this.craftingCPUClusters.add(cluster); if (cluster != null) {
this.craftingCPUClusters.add(cluster);
if (cluster.getLastCraftingLink() != null) { if (cluster.getLastCraftingLink() != null) {
this.addLink((CraftingLink) cluster.getLastCraftingLink()); this.addLink((CraftingLink) cluster.getLastCraftingLink());
}
} }
} }
} }
+6
View File
@@ -81,8 +81,11 @@ public class SecurityCache implements ISecurityGrid {
private void updateSecurityKey() { private void updateSecurityKey() {
final long lastCode = this.securityKey; final long lastCode = this.securityKey;
int newOwner = -1;
if (this.securityProvider.size() == 1) { if (this.securityProvider.size() == 1) {
this.securityKey = this.securityProvider.get(0).getSecurityKey(); this.securityKey = this.securityProvider.get(0).getSecurityKey();
ISecurityProvider securityProvider = this.securityProvider.get(0);
newOwner = securityProvider.getOwner();
} else { } else {
this.securityKey = -1; this.securityKey = -1;
} }
@@ -91,6 +94,9 @@ public class SecurityCache implements ISecurityGrid {
this.getGrid().postEvent(new MENetworkSecurityChange()); this.getGrid().postEvent(new MENetworkSecurityChange());
for (final IGridNode n : this.getGrid().getNodes()) { for (final IGridNode n : this.getGrid().getNodes()) {
((GridNode) n).setLastSecurityKey(this.securityKey); ((GridNode) n).setLastSecurityKey(this.securityKey);
if (n.getPlayerID() != newOwner) {
n.setPlayerID(newOwner);
}
} }
} }
} }
@@ -46,6 +46,8 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
private int inverterUpgrades = 0; private int inverterUpgrades = 0;
private int craftingUpgrades = 0; private int craftingUpgrades = 0;
private int patternExpansionUpgrades = 0; private int patternExpansionUpgrades = 0;
private int magnetUpgrades = 0;
private int quantumUpgrades = 0;
public UpgradeInventory(final IAEAppEngInventory parent, final int s) { public UpgradeInventory(final IAEAppEngInventory parent, final int s) {
super(null, s, 1); super(null, s, 1);
@@ -79,6 +81,10 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
return this.craftingUpgrades; return this.craftingUpgrades;
case PATTERN_EXPANSION: case PATTERN_EXPANSION:
return this.patternExpansionUpgrades; return this.patternExpansionUpgrades;
case MAGNET:
return this.magnetUpgrades;
case QUANTUM_LINK:
return this.quantumUpgrades;
default: default:
return 0; return 0;
} }
@@ -88,7 +94,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
private void updateUpgradeInfo() { private void updateUpgradeInfo() {
this.cached = true; this.cached = true;
this.patternExpansionUpgrades = this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = 0; this.patternExpansionUpgrades = this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = magnetUpgrades = quantumUpgrades = 0;
for (final ItemStack is : this) { for (final ItemStack is : this) {
if (is == null || is.getItem() == Items.AIR || !(is.getItem() instanceof IUpgradeModule)) { if (is == null || is.getItem() == Items.AIR || !(is.getItem() instanceof IUpgradeModule)) {
@@ -118,6 +124,11 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
case PATTERN_EXPANSION: case PATTERN_EXPANSION:
this.patternExpansionUpgrades++; this.patternExpansionUpgrades++;
break; break;
case MAGNET:
this.magnetUpgrades++;
break;
case QUANTUM_LINK:
this.quantumUpgrades++;
default: default:
break; break;
} }
@@ -130,6 +141,8 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
this.inverterUpgrades = Math.min(this.inverterUpgrades, this.getMaxInstalled(Upgrades.INVERTER)); this.inverterUpgrades = Math.min(this.inverterUpgrades, this.getMaxInstalled(Upgrades.INVERTER));
this.craftingUpgrades = Math.min(this.craftingUpgrades, this.getMaxInstalled(Upgrades.CRAFTING)); this.craftingUpgrades = Math.min(this.craftingUpgrades, this.getMaxInstalled(Upgrades.CRAFTING));
this.patternExpansionUpgrades = Math.min(this.patternExpansionUpgrades, this.getMaxInstalled(Upgrades.PATTERN_EXPANSION)); this.patternExpansionUpgrades = Math.min(this.patternExpansionUpgrades, this.getMaxInstalled(Upgrades.PATTERN_EXPANSION));
this.magnetUpgrades = Math.min(this.magnetUpgrades, this.getMaxInstalled(Upgrades.MAGNET));
this.quantumUpgrades = Math.min(this.quantumUpgrades, this.getMaxInstalled(Upgrades.QUANTUM_LINK));
} }
@Override @Override
@@ -48,6 +48,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IItemHa
private static final float POWER_DRAIN = 2.0f; private static final float POWER_DRAIN = 2.0f;
private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_items"); private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_items");
private boolean partVisited = false; private boolean partVisited = false;
private int depth;
@PartModels @PartModels
public static List<IPartModel> getModels() { public static List<IPartModel> getModels() {
@@ -195,7 +196,13 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IItemHa
@Override @Override
public ItemStack insertItem(final int slot, final ItemStack stack, boolean simulate) { public ItemStack insertItem(final int slot, final ItemStack stack, boolean simulate) {
return this.getDestination().insertItem(slot, stack, simulate); if (depth == 1) {
return stack;
}
this.depth += 1;
ItemStack ret = this.getDestination().insertItem(slot, stack, simulate);
this.depth -= 1;
return ret;
} }
@Override @Override
@@ -69,8 +69,13 @@ public abstract class AbstractPartEncoder extends AbstractPartTerminal {
this.crafting.setStackInSlot(x, item == null ? ItemStack.EMPTY : item.createItemStack()); this.crafting.setStackInSlot(x, item == null ? ItemStack.EMPTY : item.createItemStack());
} }
for (int x = 0; x < this.output.getSlots() && x < details.getOutputs().length; x++) { for (int x = 0; x < this.output.getSlots(); x++) {
final IAEItemStack item = details.getOutputs()[x]; final IAEItemStack item;
if (x < details.getOutputs().length) {
item = details.getOutputs()[x];
} else {
item = null;
}
this.output.setStackInSlot(x, item == null ? ItemStack.EMPTY : item.createItemStack()); this.output.setStackInSlot(x, item == null ? ItemStack.EMPTY : item.createItemStack());
} }
} }
@@ -36,6 +36,8 @@ import appeng.tile.grid.AENetworkInvTile;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
import appeng.util.inv.filter.AEItemDefinitionFilter;
import appeng.util.inv.filter.IAEItemFilter;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -53,7 +55,7 @@ import java.util.Optional;
public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock, ITickable { public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock, ITickable {
private final byte corner = 16; private final byte corner = 16;
private final AppEngInternalInventory internalInventory = new AppEngInternalInventory(this, 1, 1); private final AppEngInternalInventory internalInventory = new AppEngInternalInventory(this, 2, 1);
private final byte hasSingularity = 32; private final byte hasSingularity = 32;
private final byte powered = 64; private final byte powered = 64;
@@ -66,6 +68,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
this.getProxy().setValidSides(EnumSet.noneOf(EnumFacing.class)); this.getProxy().setValidSides(EnumSet.noneOf(EnumFacing.class));
this.getProxy().setFlags(GridFlags.DENSE_CAPACITY); this.getProxy().setFlags(GridFlags.DENSE_CAPACITY);
this.getProxy().setIdlePowerUsage(22); this.getProxy().setIdlePowerUsage(22);
this.internalInventory.setFilter(new QuantumBridgeInventoryFilter());
} }
@Override @Override
@@ -292,4 +295,24 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
public byte getCorner() { public byte getCorner() {
return this.corner; return this.corner;
} }
private class QuantumBridgeInventoryFilter implements IAEItemFilter {
@Override
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
return true;
}
@Override
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
if (inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(1).isEmpty() ) {
if (slot == 0 && AEApi.instance().definitions().materials().qESingularity().isSameAs(stack)) {
return true;
} else return slot == 1 && AEApi.instance().definitions().materials().cardQuantumLink().isSameAs(stack);
} else if (slot == 0 && inv.getStackInSlot(1).isEmpty()) {
return true;
}else return slot == 1 && inv.getStackInSlot(0).isEmpty();
}
}
} }

Some files were not shown because too many files have changed in this diff Show More