Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 66ab022c95 | |||
| ab1f519401 | |||
| d06a70ee22 | |||
| 422f9faf76 | |||
| 96ab73001b | |||
| 854676a33c | |||
| 7f76723da5 | |||
| 3fc7cf0247 | |||
| b377dfdd69 | |||
| 51522019ca | |||
| ff1091d252 | |||
| 15dff5d53d | |||
| 7ab89a0657 | |||
| dcd36b3b2f | |||
| 7b985c72bd | |||
| 269d3766db | |||
| d7e7ef0cb4 | |||
| 472f1e65a2 | |||
| 56268aba79 | |||
| 9d7dacdc29 | |||
| fb2aa21337 | |||
| 8bad14f982 | |||
| 0e797b2120 | |||
| 17c38a6418 | |||
| 58a6dabb20 | |||
| 329e613c99 | |||
| 11a4783881 | |||
| e230440cba | |||
| 149e7d251a | |||
| 405f14bd13 | |||
| acd77ff3f2 | |||
| a0ec9ceb51 | |||
| d6f2ed30e5 | |||
| 9785e38e3f | |||
| 1759bd898e | |||
| ae0d02e7d5 | |||
| d76eec2145 | |||
| d7e1554e41 | |||
| 9dee7f6c0e | |||
| 13c3067068 | |||
| 7c4e5679a3 | |||
| 03ed421331 | |||
| 36197a5dc6 | |||
| f407a26a8f | |||
| cb1011295c | |||
| 55a56ad79d | |||
| dd2f1c6dc7 | |||
| f14407b87a | |||
| 04f006695e | |||
| 4f36ccf64d | |||
| d9b4410c94 | |||
| 9bbd0ad61b | |||
| 662a7805dd | |||
| c46eadec08 | |||
| 148207f5c3 | |||
| 3ae251f098 | |||
| 82a906886f | |||
| 5b2c6658c0 | |||
| 653557bc65 | |||
| dde87448a9 | |||
| 8c29eeecdc | |||
| d852d0c216 | |||
| f9bb00a7e7 | |||
| 9f7e42ca7d | |||
| b76c18fedf | |||
| 98ce8235bb | |||
| e1ea4ae22f | |||
| 20ba83c529 | |||
| 225a4d5ab6 | |||
| bd4f03652e | |||
| d6650f9617 | |||
| c5607bda4e | |||
| 11af1f2111 | |||
| 7748f7c92d | |||
| 801fec3eaa | |||
| de324aad91 | |||
| 16ccb2ee46 | |||
| bd0d2a1f28 | |||
| 9abd53a8e8 | |||
| 1f12fc5e91 | |||
| 87fcc6c267 | |||
| e301459dfa | |||
| bf802f1c6f | |||
| 7ba4ca6923 | |||
| 53ed861e23 | |||
| 833f8aca2a | |||
| 9bcf45b7e2 | |||
| b2847677ed | |||
| 95845d5a6c | |||
| 286a3631be | |||
| 6506301049 | |||
| 422543f205 |
@@ -1,17 +1,21 @@
|
||||
This is a fork of AE2 i made for trying to solve issues for the [Omnifactory](https://www.curseforge.com/minecraft/modpacks/omnifactory) modpack.
|
||||
|
||||
See https://github.com/PrototypeTrousers/Applied-Energistics-2/tree/AE2-Omnifactory branch for commits
|
||||
and
|
||||
https://github.com/PrototypeTrousers/Applied-Energistics-2/releases for the compiled jars.
|
||||
See [AE2-Omnifactory](https://github.com/PrototypeTrousers/Applied-Energistics-2/tree/AE2-Omnifactory) branch for commits and [Releases](https://github.com/PrototypeTrousers/Applied-Energistics-2/releases) for the compiled jars.
|
||||
|
||||
# Applied Energistics 2 (PrototypeTrousers fork for Omnifactory)
|
||||
|
||||
## About
|
||||
A Mod about Matter, Energy and using them to conquer the world.
|
||||
|
||||
A Mod about Matter, Energy and using them to conquer the world..
|
||||
## RecipeStages
|
||||
You need to add the following into a CraftTweaker script:
|
||||
```
|
||||
mods.recipestages.Recipes.setPackageStage("appeng", allStages);
|
||||
```
|
||||
|
||||
The second argument allows you to customize which stages exactly you want to be craftable with AE2. Idk why would you like to restrict any, but you can.
|
||||
|
||||
## License
|
||||
|
||||
* Applied Energistics 2 API
|
||||
- (c) 2013 - 2018 AlgorithmX2 et al
|
||||
- [](http://opensource.org/licenses/MIT)
|
||||
@@ -25,7 +29,6 @@ A Mod about Matter, Energy and using them to conquer the world..
|
||||
- [](https://creativecommons.org/publicdomain/zero/1.0/)
|
||||
|
||||
## Credits
|
||||
|
||||
Thanks to
|
||||
|
||||
* Notch et al for Minecraft
|
||||
|
||||
@@ -21,6 +21,7 @@ buildscript {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
@@ -65,6 +66,8 @@ archivesBaseName = aebasename
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'FMLAT': 'appeng_at.cfg'
|
||||
attributes "FMLCorePlugin": "appeng.core.AE2ELCore"
|
||||
attributes "FMLCorePluginContainsFMLMod": "true"
|
||||
}
|
||||
|
||||
from sourceSets.api.output
|
||||
|
||||
+1
-3
@@ -4,7 +4,7 @@ aebuild=7
|
||||
aegroup=appeng
|
||||
aebasename=appliedenergistics2
|
||||
extended=extended_life
|
||||
extendedversion=v0.54.2
|
||||
extendedversion=v0.55.2
|
||||
#########################################################
|
||||
# Versions #
|
||||
#########################################################
|
||||
@@ -24,8 +24,6 @@ ic2_version=2.8.73-ex112
|
||||
top_version=1.12-1.4.23-16
|
||||
cofhcore_version=1.12.2-4.5.2.19
|
||||
crafttweaker_version=4.1.8.9
|
||||
inventorytweaks_version=1.63
|
||||
bogosorter_version=1.1.0
|
||||
ctm_version=MC1.12.2-0.3.1.16
|
||||
forestry_version=5.8.2.387
|
||||
#########################################################
|
||||
|
||||
@@ -83,11 +83,14 @@ dependencies {
|
||||
// installable runtime dependencies
|
||||
deobfCompile "curse.maven:gregtechceu-557242:3949406"
|
||||
|
||||
compileOnly "curse.maven:chisel-235279:2915375"
|
||||
|
||||
deobfCompile "baubles:Baubles:1.12:1.5.2"
|
||||
//mods "mcp.mobius.waila:Hwyla:${hwyla_version}"
|
||||
mods "curse.maven:hwyla-253449:2568751"
|
||||
mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev"
|
||||
mods "mcjty.theoneprobe:TheOneProbe-${minecraft_version}:${top_version}"
|
||||
|
||||
|
||||
// compile against provided APIs
|
||||
compileOnly "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
|
||||
//compileOnly "mcp.mobius.waila:Hwyla:${hwyla_version}"
|
||||
@@ -95,18 +98,20 @@ dependencies {
|
||||
//Code chicken lib, GTCE dependency
|
||||
deobfCompile "curse.maven:CCL-242818:2779848"
|
||||
|
||||
compileOnly "curse.maven:recipe-stages-280554:3405072"
|
||||
compileOnly "curse.maven:item-stages-280316:2696769"
|
||||
compileOnly "curse.maven:game-stages-268655:2951844"
|
||||
compileOnly "net.darkhax.tesla:Tesla-1.12.2:${tesla_version}"
|
||||
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
|
||||
compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf"
|
||||
compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}"
|
||||
compileOnly "inventory-tweaks:InventoryTweaks:${inventorytweaks_version}:api"
|
||||
compileOnly "inventory-bogo-sorter:bogosorter:${bogosorter_version}"
|
||||
compileOnly "curse.maven:inventory-tweaks-223094:2482482"
|
||||
compileOnly "curse.maven:inventory-bogo-sorter-632327:4329854"
|
||||
compileOnly "team.chisel.ctm:CTM:${ctm_version}"
|
||||
compileOnly "de.ellpeck.actuallyadditions:ActuallyAdditions:1.12.2-r152.16:api"
|
||||
deobfCompile "net.sengir.forestry:forestry_${minecraft_version}:$forestry_version"
|
||||
|
||||
|
||||
// at runtime, use the full JEI jar
|
||||
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package appeng.api.config;
|
||||
|
||||
public enum Packaging {
|
||||
ENABLED, DISABLED;
|
||||
}
|
||||
@@ -32,66 +32,61 @@ import net.minecraft.item.ItemStack;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
|
||||
|
||||
public enum Upgrades
|
||||
{
|
||||
/**
|
||||
* Gold Tier Upgrades.
|
||||
*/
|
||||
CAPACITY( 0 ),
|
||||
REDSTONE( 0 ),
|
||||
CRAFTING( 0 ),
|
||||
public enum Upgrades {
|
||||
/**
|
||||
* Gold Tier Upgrades.
|
||||
*/
|
||||
CAPACITY(0),
|
||||
REDSTONE(0),
|
||||
CRAFTING(0),
|
||||
MAGNET(0),
|
||||
|
||||
/**
|
||||
* Diamond Tier Upgrades.
|
||||
*/
|
||||
FUZZY( 1 ),
|
||||
SPEED( 1 ),
|
||||
INVERTER( 1 ),
|
||||
PATTERN_EXPANSION(1);
|
||||
/**
|
||||
* Diamond Tier Upgrades.
|
||||
*/
|
||||
FUZZY(1),
|
||||
SPEED(1),
|
||||
INVERTER(1),
|
||||
PATTERN_EXPANSION(1),
|
||||
QUANTUM_LINK(1);
|
||||
|
||||
private final int tier;
|
||||
private final Map<ItemStack, Integer> supportedMax = new HashMap<>();
|
||||
private final int tier;
|
||||
private final Map<ItemStack, Integer> supportedMax = new HashMap<>();
|
||||
|
||||
Upgrades( final int tier )
|
||||
{
|
||||
this.tier = tier;
|
||||
}
|
||||
Upgrades(final int tier) {
|
||||
this.tier = tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of Items/Blocks that support this upgrade, and how many it supports.
|
||||
*/
|
||||
public Map<ItemStack, Integer> getSupported()
|
||||
{
|
||||
return this.supportedMax;
|
||||
}
|
||||
/**
|
||||
* @return list of Items/Blocks that support this upgrade, and how many it supports.
|
||||
*/
|
||||
public Map<ItemStack, Integer> getSupported() {
|
||||
return this.supportedMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a specific amount of this upgrade into a specific machine
|
||||
*
|
||||
* @param item machine in which this upgrade can be installed
|
||||
* @param maxSupported amount how many upgrades can be installed
|
||||
*/
|
||||
public void registerItem( final IItemDefinition item, final int maxSupported )
|
||||
{
|
||||
item.maybeStack( 1 ).ifPresent( is -> this.registerItem( is, maxSupported ) );
|
||||
}
|
||||
/**
|
||||
* Registers a specific amount of this upgrade into a specific machine
|
||||
*
|
||||
* @param item machine in which this upgrade can be installed
|
||||
* @param maxSupported amount how many upgrades can be installed
|
||||
*/
|
||||
public void registerItem(final IItemDefinition item, final int maxSupported) {
|
||||
item.maybeStack(1).ifPresent(is -> this.registerItem(is, maxSupported));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a specific amount of this upgrade into a specific machine
|
||||
*
|
||||
* @param stack machine in which this upgrade can be installed
|
||||
* @param maxSupported amount how many upgrades can be installed
|
||||
*/
|
||||
public void registerItem( final ItemStack stack, final int maxSupported )
|
||||
{
|
||||
if( stack != null )
|
||||
{
|
||||
this.supportedMax.put( stack, maxSupported );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Registers a specific amount of this upgrade into a specific machine
|
||||
*
|
||||
* @param stack machine in which this upgrade can be installed
|
||||
* @param maxSupported amount how many upgrades can be installed
|
||||
*/
|
||||
public void registerItem(final ItemStack stack, final int maxSupported) {
|
||||
if (stack != null) {
|
||||
this.supportedMax.put(stack, maxSupported);
|
||||
}
|
||||
}
|
||||
|
||||
public int getTier()
|
||||
{
|
||||
return this.tier;
|
||||
}
|
||||
public int getTier() {
|
||||
return this.tier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,7 @@ import appeng.api.util.AEColoredItemDefinition;
|
||||
/**
|
||||
* A list of all items in AE
|
||||
*/
|
||||
public interface IItems
|
||||
{
|
||||
public interface IItems {
|
||||
IItemDefinition certusQuartzAxe();
|
||||
|
||||
IItemDefinition certusQuartzHoe();
|
||||
@@ -64,6 +63,12 @@ public interface IItems
|
||||
|
||||
IItemDefinition wirelessTerminal();
|
||||
|
||||
IItemDefinition wirelessCraftingTerminal();
|
||||
|
||||
IItemDefinition wirelessPatternTerminal();
|
||||
|
||||
IItemDefinition wirelessFluidTerminal();
|
||||
|
||||
IItemDefinition biometricCard();
|
||||
|
||||
IItemDefinition chargedStaff();
|
||||
|
||||
@@ -27,121 +27,124 @@ package appeng.api.definitions;
|
||||
/**
|
||||
* A list of all materials in AE
|
||||
*/
|
||||
public interface IMaterials
|
||||
{
|
||||
IItemDefinition cell2SpatialPart();
|
||||
public interface IMaterials {
|
||||
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 appeng.api.util.IConfigManager;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
|
||||
|
||||
/**
|
||||
* A handler for a wireless terminal.
|
||||
*/
|
||||
public interface IWirelessTermHandler extends INetworkEncodable
|
||||
{
|
||||
public interface IWirelessTermHandler extends INetworkEncodable {
|
||||
|
||||
/**
|
||||
* @param is wireless terminal
|
||||
*
|
||||
* @return true, if usePower, hasPower, etc... can be called for the provided item
|
||||
*/
|
||||
boolean canHandle( ItemStack is );
|
||||
/**
|
||||
* @param is wireless terminal
|
||||
* @return true, if usePower, hasPower, etc... can be called for the provided item
|
||||
*/
|
||||
boolean canHandle(ItemStack is);
|
||||
|
||||
/**
|
||||
* 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
|
||||
* hasPower
|
||||
* @param is wireless terminal
|
||||
*
|
||||
* @return true if wireless terminal uses power
|
||||
*/
|
||||
boolean usePower( EntityPlayer player, double amount, ItemStack is );
|
||||
/**
|
||||
* 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
|
||||
* hasPower
|
||||
* @param is wireless terminal
|
||||
* @return true if wireless terminal uses power
|
||||
*/
|
||||
boolean usePower(EntityPlayer player, double amount, ItemStack is);
|
||||
|
||||
/**
|
||||
* gets the power status of the item.
|
||||
*
|
||||
* @param is wireless terminal
|
||||
*
|
||||
* @return returns true if there is any power left.
|
||||
*/
|
||||
boolean hasPower( EntityPlayer player, double amount, ItemStack is );
|
||||
/**
|
||||
* gets the power status of the item.
|
||||
*
|
||||
* @param is wireless terminal
|
||||
* @return returns true if there is any power left.
|
||||
*/
|
||||
boolean hasPower(EntityPlayer player, double amount, ItemStack is);
|
||||
|
||||
/**
|
||||
* Return the config manager for the wireless terminal.
|
||||
*
|
||||
* @param is wireless terminal
|
||||
*
|
||||
* @return config manager of wireless terminal
|
||||
*/
|
||||
IConfigManager getConfigManager( ItemStack is );
|
||||
/**
|
||||
* Return the config manager for the wireless terminal.
|
||||
*
|
||||
* @param is wireless terminal
|
||||
* @return config manager of wireless terminal
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,82 +37,86 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* do not implement provided by {@link ICraftingPatternItem}
|
||||
*
|
||||
* <p>
|
||||
* caching this INSTANCE will increase performance of validation and checks.
|
||||
*/
|
||||
public interface ICraftingPatternDetails
|
||||
{
|
||||
public interface ICraftingPatternDetails {
|
||||
|
||||
/**
|
||||
* @return source item.
|
||||
*/
|
||||
ItemStack getPattern();
|
||||
/**
|
||||
* @return source item.
|
||||
*/
|
||||
ItemStack getPattern();
|
||||
|
||||
/**
|
||||
* @param slotIndex specific slot index
|
||||
* @param itemStack item in slot
|
||||
* @param world crafting world
|
||||
*
|
||||
* @return if an item can be used in the specific slot for this pattern.
|
||||
*/
|
||||
boolean isValidItemForSlot( int slotIndex, ItemStack itemStack, World world );
|
||||
/**
|
||||
* @param slotIndex specific slot index
|
||||
* @param itemStack item in slot
|
||||
* @param world crafting world
|
||||
* @return if an item can be used in the specific slot for this pattern.
|
||||
*/
|
||||
boolean isValidItemForSlot(int slotIndex, ItemStack itemStack, World world);
|
||||
|
||||
/**
|
||||
* @return if this pattern is a crafting pattern ( work bench )
|
||||
*/
|
||||
boolean isCraftable();
|
||||
/**
|
||||
* @return if this pattern is a crafting pattern ( work bench )
|
||||
*/
|
||||
boolean isCraftable();
|
||||
|
||||
/**
|
||||
* @return a list of the inputs, will include nulls.
|
||||
*/
|
||||
IAEItemStack[] getInputs();
|
||||
/**
|
||||
* @return a list of the inputs, will include nulls.
|
||||
*/
|
||||
IAEItemStack[] getInputs();
|
||||
|
||||
/**
|
||||
* @return a list of the inputs, will be clean
|
||||
*/
|
||||
IAEItemStack[] getCondensedInputs();
|
||||
/**
|
||||
* @return a list of the inputs, will be clean
|
||||
*/
|
||||
IAEItemStack[] getCondensedInputs();
|
||||
|
||||
/**
|
||||
* @return a list of the outputs, will be clean
|
||||
*/
|
||||
IAEItemStack[] getCondensedOutputs();
|
||||
/**
|
||||
* @return a list of the outputs, will be clean
|
||||
*/
|
||||
IAEItemStack[] getCondensedOutputs();
|
||||
|
||||
/**
|
||||
* @return a list of the outputs, will include nulls.
|
||||
*/
|
||||
IAEItemStack[] getOutputs();
|
||||
/**
|
||||
* @return a list of the outputs, will include nulls.
|
||||
*/
|
||||
IAEItemStack[] getOutputs();
|
||||
|
||||
/**
|
||||
* @return if this pattern is enabled to support substitutions.
|
||||
*/
|
||||
boolean canSubstitute();
|
||||
/**
|
||||
* @return if this pattern is enabled to support substitutions.
|
||||
*/
|
||||
boolean canSubstitute();
|
||||
|
||||
default List<IAEItemStack> getSubstituteInputs( int slot )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
default List<IAEItemStack> getSubstituteInputs(int slot) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow using this INSTANCE of the pattern details to preform the crafting action with performance enhancements.
|
||||
*
|
||||
* @param craftingInv inventory
|
||||
* @param world crafting world
|
||||
*
|
||||
* @return the crafted ( work bench ) item.
|
||||
*/
|
||||
ItemStack getOutput( InventoryCrafting craftingInv, World world );
|
||||
/**
|
||||
* Allow using this INSTANCE of the pattern details to preform the crafting action with performance enhancements.
|
||||
*
|
||||
* @param craftingInv inventory
|
||||
* @param world crafting world
|
||||
* @return the crafted ( work bench ) item.
|
||||
*/
|
||||
ItemStack getOutput(InventoryCrafting craftingInv, World world);
|
||||
|
||||
/**
|
||||
* Get the priority of this pattern
|
||||
*
|
||||
* @return the priority of this pattern
|
||||
*/
|
||||
int getPriority();
|
||||
/**
|
||||
* Get the priority of this pattern
|
||||
*
|
||||
* @return the priority of this pattern
|
||||
*/
|
||||
int getPriority();
|
||||
|
||||
/**
|
||||
* Set the priority the of this pattern.
|
||||
*
|
||||
* @param priority priority of pattern
|
||||
*/
|
||||
void setPriority( int priority );
|
||||
/**
|
||||
* Set the priority the of this pattern.
|
||||
*
|
||||
* @param priority priority of pattern
|
||||
*/
|
||||
void setPriority(int priority);
|
||||
|
||||
/**
|
||||
* @return if this pattern is a packaging pattern.
|
||||
*/
|
||||
|
||||
default boolean isPackage() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import appeng.api.storage.IStorageChannel;
|
||||
* - For fluids: AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class).createList()
|
||||
* - Replace with the corresponding {@link IStorageChannel} type for non native channels
|
||||
*/
|
||||
public interface IItemList<T extends IAEStack<T>> extends IItemContainer<T>, Iterable<T>, Cloneable
|
||||
public interface IItemList<T extends IAEStack<T>> extends IItemContainer<T>, Iterable<T>
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -85,9 +85,4 @@ public interface IItemList<T extends IAEStack<T>> extends IItemContainer<T>, Ite
|
||||
* resets stack sizes to 0.
|
||||
*/
|
||||
void resetStatus();
|
||||
|
||||
/**
|
||||
* create a copy of this list.
|
||||
*/
|
||||
IItemList<T> clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.enderio.core.common.interfaces;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface IOverlayRenderAware {
|
||||
|
||||
public void renderItemOverlayIntoGUI(@Nonnull ItemStack stack, int xPosition, int yPosition);
|
||||
|
||||
}
|
||||
@@ -44,6 +44,7 @@ import appeng.tile.networking.TileCableBusTESR;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -413,6 +414,30 @@ public class BlockCableBus extends AEBaseTileBlock implements IAEFacade {
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) {
|
||||
IFacadeContainer container = this.fc(world, pos);
|
||||
if (container != null) {
|
||||
IFacadePart facade = container.getFacade(AEPartLocation.fromFacing(side));
|
||||
if (facade != null) {
|
||||
return BlockFaceShape.SOLID;
|
||||
}
|
||||
}
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityWalk(World world, BlockPos pos, Entity entityIn) {
|
||||
IFacadeContainer container = this.fc(world, pos);
|
||||
if (container != null) {
|
||||
IFacadePart facade = container.getFacade(AEPartLocation.fromFacing(EnumFacing.UP));
|
||||
if (facade != null) {
|
||||
facade.getBlockState().getBlock().onEntityWalk(world, pos, entityIn);
|
||||
}
|
||||
}
|
||||
super.onEntityWalk(world, pos, entityIn);
|
||||
}
|
||||
|
||||
public static Class<? extends AEBaseTile> getNoTesrTile() {
|
||||
return noTesrTile;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import appeng.api.parts.CableRenderMode;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.render.crafting.ItemEncodedPatternBakedModel;
|
||||
import appeng.client.render.effects.*;
|
||||
import appeng.client.render.model.UVLModelLoader;
|
||||
import appeng.client.render.tesr.InscriberTESR;
|
||||
@@ -30,9 +31,11 @@ import appeng.client.render.textures.ParticleTextures;
|
||||
import appeng.container.interfaces.IJEIGhostIngredients;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.core.sync.packets.PacketTerminalUse;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.entity.EntityFloatingItem;
|
||||
import appeng.entity.EntityTinyTNTPrimed;
|
||||
@@ -42,6 +45,8 @@ import appeng.helpers.HighlighterHandler;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
import appeng.items.tools.powered.Terminal;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.server.ServerHelper;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -57,12 +62,19 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.*;
|
||||
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.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
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.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 java.io.IOException;
|
||||
@@ -71,11 +83,17 @@ import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
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 {
|
||||
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 List<KeyBinding> keyBindings = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void preinit() {
|
||||
@@ -96,6 +114,14 @@ public class ClientHelper extends ServerHelper {
|
||||
ClientRegistry.registerKeyBinding(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 ->
|
||||
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(ItemEncodedPatternBakedModel.PATTERN_ITEM_COLOR_HANDLER, pattern));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -314,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
|
||||
public void onTextureStitch(final TextureStitchEvent.Pre 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;
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.fluids.client.render.FluidStackSizeRenderer;
|
||||
import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.base.Joiner;
|
||||
@@ -897,7 +898,37 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
|
||||
}
|
||||
}
|
||||
if (s instanceof SlotPlayerInv || s instanceof SlotPlayerHotBar) {
|
||||
super.drawSlot(s);
|
||||
if (!is.isEmpty() && is.getItem() instanceof ItemEncodedPattern) {
|
||||
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
|
||||
final ItemStack out = iep.getOutput(is);
|
||||
if (!out.isEmpty()) {
|
||||
AppEngSlot appEngSlot = ((AppEngSlot) s);
|
||||
appEngSlot.setDisplay(true);
|
||||
appEngSlot.setReturnAsSingleStack(true);
|
||||
|
||||
this.zLevel = 100.0F;
|
||||
this.itemRender.zLevel = 100.0F;
|
||||
|
||||
if (!this.isPowered()) {
|
||||
drawRect(s.xPos, s.yPos, 16 + s.xPos, 16 + s.yPos, 0x66111111);
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
|
||||
// Annoying but easier than trying to splice into render item
|
||||
super.drawSlot(s);
|
||||
|
||||
if (isShiftKeyDown()) {
|
||||
this.stackSizeRenderer.renderStackSize(this.fontRenderer, AEItemStack.fromItemStack(out), s.xPos, s.yPos);
|
||||
} else {
|
||||
super.drawSlot(s);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
super.drawSlot(s);
|
||||
}
|
||||
} else if (s instanceof AppEngSlot) {
|
||||
AppEngSlot appEngSlot = ((AppEngSlot) s);
|
||||
appEngSlot.setDisplay(true);
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.client.gui.implementations;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
@@ -97,9 +98,8 @@ public class GuiCraftAmount extends AEBaseGui {
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
myIcon = definitions.items().wirelessTerminal().maybeStack(1).orElse(myIcon);
|
||||
|
||||
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
myIcon = ((WirelessTerminalGuiObject) target).getItemStack();
|
||||
this.originalGui = (GuiBridge) AEApi.instance().registries().wireless().getWirelessTerminalHandler(myIcon).getGuiHandler(myIcon);
|
||||
}
|
||||
|
||||
if (target instanceof PartTerminal) {
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -84,7 +85,8 @@ public class GuiCraftConfirm extends AEBaseGui {
|
||||
this.ccc.setGui(this);
|
||||
|
||||
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) {
|
||||
|
||||
@@ -26,6 +26,7 @@ package appeng.client.gui.implementations;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
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.CraftingCPUStatus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.registries.WirelessRegistry;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
@@ -84,9 +86,8 @@ public class GuiCraftingStatus extends GuiCraftingCPU {
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
this.myIcon = definitions.items().wirelessTerminal().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
|
||||
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
myIcon = ((WirelessTerminalGuiObject) target).getItemStack();
|
||||
this.originalGui = (GuiBridge) AEApi.instance().registries().wireless().getWirelessTerminalHandler(myIcon).getGuiHandler(myIcon);
|
||||
}
|
||||
|
||||
if (target instanceof PartTerminal) {
|
||||
|
||||
@@ -82,8 +82,4 @@ public class GuiCraftingTerm extends GuiMEMonitorable {
|
||||
protected String getBackground() {
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
|
||||
public ItemRepo getRepo() {
|
||||
return this.repo;
|
||||
}
|
||||
}
|
||||
|
||||
+33
-17
@@ -1,7 +1,7 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.ItemSubstitution;
|
||||
import appeng.api.config.Packaging;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
@@ -36,6 +36,9 @@ public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implement
|
||||
private static final String SUBSITUTION_DISABLE = "0";
|
||||
private static final String SUBSITUTION_ENABLE = "1";
|
||||
|
||||
private static final String PACKAGING_DISABLE = "0";
|
||||
private static final String PACKAGING_ENABLE = "1";
|
||||
|
||||
private static final String CRAFTMODE_CRFTING = "1";
|
||||
private static final String CRAFTMODE_PROCESSING = "0";
|
||||
|
||||
@@ -52,10 +55,14 @@ public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implement
|
||||
private GuiImgButton divThreeBtn;
|
||||
private GuiImgButton minusOneBtn;
|
||||
private GuiImgButton maxCountBtn;
|
||||
private GuiImgButton packagingEnabledBtn;
|
||||
private GuiImgButton packagingDisabledBtn;
|
||||
public Map<IGhostIngredientHandler.Target<?>, Object> mapTargetSlot = new HashMap<>();
|
||||
private ContainerExpandedProcessingPatternTerm container;
|
||||
|
||||
public GuiExpandedProcessingPatternTerm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te, new ContainerExpandedProcessingPatternTerm(inventoryPlayer, te));
|
||||
this.container = (ContainerExpandedProcessingPatternTerm) this.inventorySlots;
|
||||
this.setReservedSpace(81);
|
||||
}
|
||||
|
||||
@@ -112,6 +119,13 @@ public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implement
|
||||
if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
|
||||
}
|
||||
|
||||
if (this.packagingEnabledBtn == btn || this.packagingDisabledBtn == btn) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(
|
||||
new PacketValueConfig("PatternTerminal.Package", this.packagingEnabledBtn == btn ? PACKAGING_DISABLE : PACKAGING_ENABLE));
|
||||
}
|
||||
|
||||
} catch (final IOException e) {
|
||||
AELog.error(e);
|
||||
}
|
||||
@@ -121,29 +135,26 @@ public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implement
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
this.tabCraftButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack(Blocks.CRAFTING_TABLE), GuiText.CraftingPattern.getLocal(), this.itemRender);
|
||||
this.buttonList.add(this.tabCraftButton);
|
||||
|
||||
this.tabProcessButton = new GuiTabButton(this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack(Blocks.FURNACE), GuiText.ProcessingPattern.getLocal(), this.itemRender);
|
||||
this.buttonList.add(this.tabProcessButton);
|
||||
|
||||
this.substitutionsEnabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED);
|
||||
this.substitutionsEnabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.substitutionsEnabledBtn);
|
||||
this.packagingEnabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, Packaging.ENABLED);
|
||||
this.packagingEnabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.packagingEnabledBtn);
|
||||
|
||||
this.substitutionsDisabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED);
|
||||
this.substitutionsDisabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.substitutionsDisabledBtn);
|
||||
this.packagingDisabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, Packaging.DISABLED);
|
||||
this.packagingDisabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.packagingDisabledBtn);
|
||||
|
||||
this.clearBtn = new GuiImgButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
|
||||
this.clearBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.clearBtn);
|
||||
|
||||
this.x3Btn = new GuiImgButton(this.guiLeft + 131, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE);
|
||||
this.x3Btn = new GuiImgButton(this.guiLeft + 131, this.guiTop + this.ySize - 154, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE);
|
||||
this.x3Btn.setHalfSize(true);
|
||||
this.buttonList.add(this.x3Btn);
|
||||
|
||||
this.x2Btn = new GuiImgButton(this.guiLeft + 131, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO);
|
||||
this.x2Btn = new GuiImgButton(this.guiLeft + 131, this.guiTop + this.ySize - 144, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO);
|
||||
this.x2Btn.setHalfSize(true);
|
||||
this.buttonList.add(this.x2Btn);
|
||||
|
||||
@@ -151,11 +162,11 @@ public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implement
|
||||
this.plusOneBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.plusOneBtn);
|
||||
|
||||
this.divThreeBtn = new GuiImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE);
|
||||
this.divThreeBtn = new GuiImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 154, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE);
|
||||
this.divThreeBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.divThreeBtn);
|
||||
|
||||
this.divTwoBtn = new GuiImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO);
|
||||
this.divTwoBtn = new GuiImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 144, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO);
|
||||
this.divTwoBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.divTwoBtn);
|
||||
|
||||
@@ -173,16 +184,21 @@ public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implement
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.tabCraftButton.visible = false;
|
||||
this.tabProcessButton.visible = true;
|
||||
this.substitutionsEnabledBtn.visible = false;
|
||||
this.substitutionsDisabledBtn.visible = false;
|
||||
this.x2Btn.visible = true;
|
||||
this.x3Btn.visible = true;
|
||||
this.divTwoBtn.visible = true;
|
||||
this.divThreeBtn.visible = true;
|
||||
this.plusOneBtn.visible = true;
|
||||
this.minusOneBtn.visible = true;
|
||||
|
||||
if (this.container.packaging) {
|
||||
this.packagingEnabledBtn.visible = true;
|
||||
this.packagingDisabledBtn.visible = false;
|
||||
} else {
|
||||
this.packagingEnabledBtn.visible = false;
|
||||
this.packagingDisabledBtn.visible = true;
|
||||
}
|
||||
//this.maxCountBtn.visible = true;
|
||||
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
|
||||
+4
-3
@@ -35,6 +35,7 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.fluids.client.gui.widgets.GuiFluidTank;
|
||||
import appeng.fluids.helper.DualityFluidInterface;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.parts.reporting.PartFluidInterfaceConfigurationTerminal;
|
||||
@@ -155,7 +156,7 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements
|
||||
int extraLines = numUpgradesMap.get(inv);
|
||||
|
||||
for (int row = 0; row < 1 + extraLines && linesDraw < LINES_ON_PAGE; ++row) {
|
||||
for (int z = 0; z < 5; z++) {
|
||||
for (int z = 0; z < DualityFluidInterface.NUMBER_OF_TANKS; z++) {
|
||||
GuiFluidTank tankSlot;
|
||||
if (!matchedInterfaces.contains(inv) && !this.matchedStacks.contains(inv.getInventory().getFluidInSlot(z + (row * 5)))) {
|
||||
tankSlot = new GuiFluidTank(inv.getInventory(), z + (row * 5), z + (row * 5), (z * 18 + 22), offset, 16, 16, true);
|
||||
@@ -243,7 +244,7 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof ClientDCInternalFluidInv) {
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
final int width = 5 * 18;
|
||||
final int width = DualityFluidInterface.NUMBER_OF_TANKS * 18;
|
||||
|
||||
int extraLines = numUpgradesMap.get(lineObj);
|
||||
|
||||
@@ -447,7 +448,7 @@ public class GuiFluidInterfaceConfigurationTerminal extends AEBaseGui implements
|
||||
ClientDCInternalFluidInv o = this.byId.get(id);
|
||||
|
||||
if (o == null) {
|
||||
this.byId.put(id, o = new ClientDCInternalFluidInv(5, id, sortBy, string, 1000));
|
||||
this.byId.put(id, o = new ClientDCInternalFluidInv(DualityFluidInterface.NUMBER_OF_TANKS, id, sortBy, string, 1000));
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -61,6 +61,7 @@ import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static appeng.client.render.BlockPosHighlighter.hilightBlock;
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEIGhostIngredients {
|
||||
@@ -299,11 +300,7 @@ public class GuiInterfaceConfigurationTerminal extends AEBaseGui implements IJEI
|
||||
for (int x = 0; x < current.getInventory().getSlots(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.hasKey(which)) {
|
||||
NBTTagCompound tag = invData.getCompoundTag(which);
|
||||
current.getInventory().setStackInSlot(x, new ItemStack(tag));
|
||||
if (tag.hasKey("stackSize")) {
|
||||
current.getInventory().getStackInSlot(x).setCount(tag.getInteger("stackSize"));
|
||||
}
|
||||
current.getInventory().setStackInSlot(x, stackFromNBT(invData.getCompoundTag(which)));
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.client.gui.implementations;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
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.SlotDisconnected;
|
||||
import appeng.container.implementations.ContainerInterfaceTerminal;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.DualityInterface;
|
||||
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.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -46,20 +50,35 @@ import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.awt.*;
|
||||
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.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
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?
|
||||
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 HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
||||
@@ -78,7 +97,10 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
private final PartInterfaceTerminal partInterfaceTerminal;
|
||||
private GuiButton guiButtonHide;
|
||||
private GuiButton guiButtonNextAssembler;
|
||||
private GuiImgButton terminalStyleBox;
|
||||
|
||||
private final HashMap<ClientDCInternalInv, Integer> dimHashMap = new HashMap<>();
|
||||
private int drawnRows = 0;
|
||||
|
||||
public GuiInterfaceTerminal(final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te) {
|
||||
super(new ContainerInterfaceTerminal(inventoryPlayer, te));
|
||||
@@ -88,10 +110,33 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
this.setScrollBar(scrollbar);
|
||||
this.xSize = 208;
|
||||
this.ySize = 255;
|
||||
this.setReservedSpace(82);
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
|
||||
this.getScrollBar().setLeft(189);
|
||||
@@ -114,6 +159,17 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
|
||||
this.searchFieldInputs.setText(partInterfaceTerminal.in);
|
||||
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
|
||||
@@ -122,13 +178,18 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
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
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
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();
|
||||
|
||||
this.guiButtonNextAssembler = new GuiImgButton(guiLeft + 123, guiTop + 25, Settings.ACTIONS, ActionItems.FREE_MOLECULAR_SLOT_SHORTCUT);
|
||||
@@ -137,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);
|
||||
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);
|
||||
|
||||
for (final Slot s : this.inventorySlots.inventorySlots) {
|
||||
if (s instanceof AppEngSlot) {
|
||||
if (s.xPos < 197) {
|
||||
this.repositionSlot((AppEngSlot) s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int offset = 52;
|
||||
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);
|
||||
if (lineObj instanceof ClientDCInternalInv) {
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
@@ -151,7 +224,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
this.buttonList.add(guiButton);
|
||||
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++) {
|
||||
this.inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z + (row * 9), (z * 18 + 22), offset));
|
||||
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z + (row * 9)))) {
|
||||
@@ -226,6 +299,25 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
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) {
|
||||
partInterfaceTerminal.onlyInterfacesWithFreeSlots = !partInterfaceTerminal.onlyInterfacesWithFreeSlots;
|
||||
this.refreshList();
|
||||
@@ -246,15 +338,21 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
}
|
||||
}
|
||||
|
||||
private void reinitalize() {
|
||||
this.buttonList.clear();
|
||||
this.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.bindTexture("guis/newinterfaceterminal.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
//split the texture for the top
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 166);
|
||||
|
||||
int offset = 51;
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
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);
|
||||
if (lineObj instanceof ClientDCInternalInv) {
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
@@ -262,16 +360,38 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
|
||||
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);
|
||||
|
||||
offset += 18;
|
||||
linesDraw++;
|
||||
}
|
||||
} 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;
|
||||
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) {
|
||||
this.searchFieldInputs.drawTextBox();
|
||||
@@ -321,7 +441,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
for (int x = 0; x < current.getInventory().getSlots(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.hasKey(which)) {
|
||||
current.getInventory().setStackInSlot(x, new ItemStack(invData.getCompoundTag(which)));
|
||||
current.getInventory().setStackInSlot(x, stackFromNBT(invData.getCompoundTag(which)));
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {
|
||||
@@ -444,7 +564,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
final NBTTagCompound encodedValue = itemStack.getTagCompound();
|
||||
|
||||
if (encodedValue == null) {
|
||||
return false;
|
||||
return searchTerm.matches(GuiText.InvalidPattern.getLocal());
|
||||
}
|
||||
|
||||
NBTTagList tag = new NBTTagList();
|
||||
@@ -522,4 +642,12 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
int getReservedSpace() {
|
||||
return this.reservedSpace;
|
||||
}
|
||||
|
||||
void setReservedSpace(final int reservedSpace) {
|
||||
this.reservedSpace = reservedSpace;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,6 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
private int currentMouseY = 0;
|
||||
private boolean delayedUpdate;
|
||||
|
||||
private boolean updateView = true;
|
||||
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
|
||||
|
||||
public GuiMEMonitorable(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
@@ -162,7 +161,8 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
}
|
||||
|
||||
if (!this.delayedUpdate) {
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +319,8 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.searchField.setText(memoryText);
|
||||
this.searchField.selectAll();
|
||||
this.repo.setSearchString(memoryText);
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
craftingGridOffsetX = Integer.MAX_VALUE;
|
||||
@@ -380,7 +381,8 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
@@ -440,7 +442,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
int getMaxRows() {
|
||||
protected int getMaxRows() {
|
||||
return AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@@ -474,7 +476,8 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
|
||||
if (this.searchField.textboxKeyTyped(character, key)) {
|
||||
this.repo.setSearchString(this.searchField.getText());
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
// tell forge the key event is handled and should not be sent out
|
||||
this.keyHandled = mouseInGui;
|
||||
} else {
|
||||
@@ -501,7 +504,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.delayedUpdate = false;
|
||||
}
|
||||
}
|
||||
if (!this.delayedUpdate && updateView) {
|
||||
if (!this.delayedUpdate) {
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
@@ -537,7 +540,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
|
||||
}
|
||||
|
||||
this.updateView = true;
|
||||
this.repo.updateView();
|
||||
}
|
||||
|
||||
int getReservedSpace() {
|
||||
|
||||
@@ -20,22 +20,17 @@ package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiMEPortableCell extends GuiMEMonitorable {
|
||||
|
||||
public GuiMEPortableCell(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
|
||||
super(inventoryPlayer, te, new ContainerMEPortableCell(inventoryPlayer, te));
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
int defaultGetMaxRows() {
|
||||
return super.getMaxRows();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
int getMaxRows() {
|
||||
protected int getMaxRows() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,6 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
private GuiImgButton units;
|
||||
private int tooltip = -1;
|
||||
|
||||
private boolean updateView = true;
|
||||
|
||||
public GuiNetworkStatus(final InventoryPlayer inventoryPlayer, final INetworkTool te) {
|
||||
super(new ContainerNetworkStatus(inventoryPlayer, te));
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
@@ -208,17 +206,9 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
for (final IAEItemStack is : list) {
|
||||
this.repo.postUpdate(is);
|
||||
}
|
||||
this.updateView = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
if (updateView) {
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
updateView = false;
|
||||
}
|
||||
super.updateScreen();
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
|
||||
@@ -21,11 +21,14 @@ package appeng.client.gui.implementations;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.ItemSubstitution;
|
||||
import appeng.api.config.Packaging;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerPatternEncoder;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerWirelessPatternTerminal;
|
||||
import appeng.container.interfaces.IJEIGhostIngredients;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotFake;
|
||||
@@ -35,6 +38,7 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import mezz.jei.api.gui.IGhostIngredientHandler.Target;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -57,10 +61,13 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
|
||||
private static final String SUBSITUTION_DISABLE = "0";
|
||||
private static final String SUBSITUTION_ENABLE = "1";
|
||||
|
||||
private static final String PACKAGING_DISABLE = "0";
|
||||
private static final String PACKAGING_ENABLE = "1";
|
||||
|
||||
private static final String CRAFTMODE_CRFTING = "1";
|
||||
private static final String CRAFTMODE_PROCESSING = "0";
|
||||
|
||||
private final ContainerPatternTerm container;
|
||||
private final ContainerPatternEncoder container;
|
||||
|
||||
private GuiTabButton tabCraftButton;
|
||||
private GuiTabButton tabProcessButton;
|
||||
@@ -75,6 +82,8 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
|
||||
private GuiImgButton divThreeBtn;
|
||||
private GuiImgButton minusOneBtn;
|
||||
private GuiImgButton maxCountBtn;
|
||||
private GuiImgButton packagingEnabledBtn;
|
||||
private GuiImgButton packagingDisabledBtn;
|
||||
public Map<Target<?>, Object> mapTargetSlot = new HashMap<>();
|
||||
|
||||
public GuiPatternTerm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
@@ -83,6 +92,12 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
|
||||
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
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
@@ -140,6 +155,12 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
|
||||
.sendToServer(
|
||||
new PacketValueConfig("PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
|
||||
}
|
||||
|
||||
if (this.packagingEnabledBtn == btn || this.packagingDisabledBtn == btn) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(
|
||||
new PacketValueConfig("PatternTerminal.Package", this.packagingEnabledBtn == btn ? PACKAGING_DISABLE : PACKAGING_ENABLE));
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
AELog.error(e);
|
||||
}
|
||||
@@ -165,6 +186,14 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
|
||||
this.substitutionsDisabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.substitutionsDisabledBtn);
|
||||
|
||||
this.packagingEnabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, Packaging.ENABLED);
|
||||
this.packagingEnabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.packagingEnabledBtn);
|
||||
|
||||
this.packagingDisabledBtn = new GuiImgButton(this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, Packaging.DISABLED);
|
||||
this.packagingDisabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.packagingDisabledBtn);
|
||||
|
||||
this.clearBtn = new GuiImgButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
|
||||
this.clearBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.clearBtn);
|
||||
@@ -212,6 +241,8 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
|
||||
this.divThreeBtn.visible = false;
|
||||
this.plusOneBtn.visible = false;
|
||||
this.minusOneBtn.visible = false;
|
||||
this.packagingEnabledBtn.visible = false;
|
||||
this.packagingDisabledBtn.visible = false;
|
||||
//this.maxCountBtn.visible = false;
|
||||
|
||||
if (this.container.substitute) {
|
||||
@@ -222,6 +253,13 @@ public class GuiPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredi
|
||||
this.substitutionsDisabledBtn.visible = true;
|
||||
}
|
||||
} else {
|
||||
if (this.container.packaging) {
|
||||
this.packagingEnabledBtn.visible = true;
|
||||
this.packagingDisabledBtn.visible = false;
|
||||
} else {
|
||||
this.packagingEnabledBtn.visible = false;
|
||||
this.packagingDisabledBtn.visible = true;
|
||||
}
|
||||
this.tabCraftButton.visible = false;
|
||||
this.tabProcessButton.visible = true;
|
||||
this.substitutionsEnabledBtn.visible = false;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class GuiQNB extends AEBaseGui {
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.container.implementations.ContainerWirelessTerm;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiWirelessTerm extends GuiMEPortableCell {
|
||||
public class GuiWirelessTerm extends GuiMEMonitorable {
|
||||
|
||||
public GuiWirelessTerm(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
|
||||
super(inventoryPlayer, te);
|
||||
public GuiWirelessTerm(final InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject te) {
|
||||
super(inventoryPlayer, te, new ContainerWirelessTerm(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows() {
|
||||
return this.defaultGetMaxRows();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,9 @@ public class GuiImgButton extends GuiButton implements ITooltip {
|
||||
this.registerApp(4 + 3 * 16, Settings.ACTIONS, ItemSubstitution.ENABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescEnabled);
|
||||
this.registerApp(7 + 3 * 16, Settings.ACTIONS, ItemSubstitution.DISABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescDisabled);
|
||||
|
||||
this.registerApp(8 + 3 * 16, Settings.ACTIONS, Packaging.ENABLED, ButtonToolTips.Packaging, ButtonToolTips.PackagingDescEnabled);
|
||||
this.registerApp(9 + 3 * 16, Settings.ACTIONS, Packaging.DISABLED, ButtonToolTips.Packaging, ButtonToolTips.PackagingDescDisabled);
|
||||
|
||||
this.registerApp(16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems);
|
||||
this.registerApp(18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable);
|
||||
this.registerApp(19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable);
|
||||
|
||||
@@ -39,20 +39,19 @@ import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class ItemRepo {
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final List<IAEItemStack> view;
|
||||
private final ArrayList<IAEItemStack> view = new ArrayList<>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
private int rowSize = 9;
|
||||
|
||||
private volatile String searchString = "";
|
||||
private String searchString = "";
|
||||
private IPartitionList<IAEItemStack> myPartitionList;
|
||||
private String innerSearch = "";
|
||||
private boolean hasPower;
|
||||
@@ -60,9 +59,6 @@ public class ItemRepo {
|
||||
public ItemRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||
this.src = src;
|
||||
this.sortSrc = sortSrc;
|
||||
|
||||
this.view = Collections.synchronizedList(new ArrayList<>());
|
||||
list.forEach(this.view::add);
|
||||
}
|
||||
|
||||
public IAEItemStack getReferenceItem(int idx) {
|
||||
@@ -99,123 +95,111 @@ public class ItemRepo {
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> searchTask = null;
|
||||
|
||||
public void updateView() {
|
||||
if (searchTask != null) {
|
||||
return;
|
||||
this.view.clear();
|
||||
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
|
||||
final Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum searchMode = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE);
|
||||
final boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE;
|
||||
|
||||
if (searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP) {
|
||||
this.updateJEI(this.searchString);
|
||||
}
|
||||
|
||||
// Since sortSrc is final, so we can safely call it inside lambda
|
||||
searchTask = CompletableFuture.supplyAsync(() -> {
|
||||
IItemList<IAEItemStack> list = this.list.clone();
|
||||
List<IAEItemStack> view = new ArrayList<>(list.size());
|
||||
Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
final boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
|
||||
|
||||
boolean needsZeroCopy = viewMode == ViewItems.CRAFTABLE;
|
||||
boolean searchMod = false;
|
||||
|
||||
boolean terminalSearchToolTips = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
|
||||
this.innerSearch = searchString.toLowerCase();
|
||||
if (this.innerSearch.startsWith("@")) {
|
||||
searchMod = true;
|
||||
this.innerSearch = this.innerSearch.substring(1);
|
||||
}
|
||||
|
||||
boolean searchMod = false;
|
||||
|
||||
String innerSearch = searchString.toLowerCase();
|
||||
if (innerSearch.startsWith("@")) {
|
||||
searchMod = true;
|
||||
innerSearch = innerSearch.substring(1);
|
||||
}
|
||||
|
||||
Pattern m = null;
|
||||
Pattern m = null;
|
||||
try {
|
||||
m = Pattern.compile(this.innerSearch, Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable ignore) {
|
||||
try {
|
||||
m = Pattern.compile(innerSearch, Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable ignore) {
|
||||
try {
|
||||
m = Pattern.compile(Pattern.quote(innerSearch), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable __) {
|
||||
return Collections.<IAEItemStack>emptyList();
|
||||
m = Pattern.compile(Pattern.quote(this.innerSearch), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable __) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean notDone = false;
|
||||
for (IAEItemStack is : this.list) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (IAEItemStack is : list) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
final String dspName = (searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is)).toLowerCase();
|
||||
boolean foundMatchingItemStack = true;
|
||||
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String dspName = (searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is)).toLowerCase();
|
||||
boolean foundMatchingItemStack = true;
|
||||
|
||||
for (String term : innerSearch.split(" ")) {
|
||||
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
|
||||
term = term.substring(1);
|
||||
if (dspName.contains(term)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
} else if (!dspName.contains(term)) {
|
||||
for (String term : innerSearch.split(" ")) {
|
||||
if (term.length() > 1 && (term.startsWith("-") || term.startsWith("!"))) {
|
||||
term = term.substring(1);
|
||||
if (dspName.contains(term)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (terminalSearchToolTips && !foundMatchingItemStack) {
|
||||
final List<String> tooltip = Platform.getTooltip(is);
|
||||
for (final String line : tooltip) {
|
||||
if (m.matcher(line).find()) {
|
||||
foundMatchingItemStack = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundMatchingItemStack) {
|
||||
if (needsZeroCopy) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
view.add(is);
|
||||
} else if (!dspName.contains(term)) {
|
||||
foundMatchingItemStack = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
ItemSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
ItemSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
view.sort(ItemSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
view.sort(ItemSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
if (InventoryBogoSortModule.isLoaded()) {
|
||||
Collections.sort(this.view, InventoryBogoSortModule.COMPARATOR);
|
||||
} else {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
if (terminalSearchToolTips && !foundMatchingItemStack) {
|
||||
final List<String> tooltip = Platform.getTooltip(is);
|
||||
for (final String line : tooltip) {
|
||||
if (m.matcher(line).find()) {
|
||||
foundMatchingItemStack = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundMatchingItemStack) {
|
||||
if (needsZeroCopy) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
this.view.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
ItemSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
ItemSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
if (InventoryBogoSortModule.isLoaded()) {
|
||||
Collections.sort(this.view, InventoryBogoSortModule.COMPARATOR);
|
||||
} else {
|
||||
view.sort(ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
}
|
||||
|
||||
return view;
|
||||
}).thenAcceptAsync(view -> {
|
||||
this.view.clear();
|
||||
this.view.addAll(view);
|
||||
}).thenRunAsync(() -> {
|
||||
this.searchTask = null; // Prevent redundant cancellation
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateJEI(String filter) {
|
||||
@@ -227,10 +211,6 @@ public class ItemRepo {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (searchTask != null) {
|
||||
searchTask.cancel(true);
|
||||
searchTask = null;
|
||||
}
|
||||
this.list.resetStatus();
|
||||
}
|
||||
|
||||
@@ -256,17 +236,6 @@ public class ItemRepo {
|
||||
|
||||
public void setSearchString(@Nonnull final String searchString) {
|
||||
this.searchString = searchString;
|
||||
|
||||
if (searchTask != null) {
|
||||
searchTask.cancel(true);
|
||||
searchTask = null;
|
||||
}
|
||||
|
||||
// Passive JEI auto search
|
||||
final Enum<?> searchMode = AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE);
|
||||
if (searchMode == SearchBoxMode.JEI_AUTOSEARCH || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH || searchMode == SearchBoxMode.JEI_AUTOSEARCH_KEEP || searchMode == SearchBoxMode.JEI_MANUAL_SEARCH_KEEP) {
|
||||
this.updateJEI(this.searchString);
|
||||
}
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getList() {
|
||||
|
||||
@@ -5,11 +5,11 @@ import appeng.items.misc.ItemEncodedPattern;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -32,13 +32,22 @@ import java.util.List;
|
||||
* the pattern is being
|
||||
* rendered in the GUI, and not anywhere else.
|
||||
*/
|
||||
class ItemEncodedPatternBakedModel implements IBakedModel {
|
||||
public class ItemEncodedPatternBakedModel implements IBakedModel {
|
||||
private final IBakedModel baseModel;
|
||||
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms;
|
||||
|
||||
private final CustomOverrideList overrides;
|
||||
|
||||
public static final IItemColor PATTERN_ITEM_COLOR_HANDLER = (stack, tintIndex) -> {
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
|
||||
ItemStack output = iep.getOutput(stack);
|
||||
if (!output.isEmpty() && isShiftKeyDown()) {
|
||||
return Minecraft.getMinecraft().getItemColors().colorMultiplier(output, tintIndex);
|
||||
}
|
||||
return 0xFFFFFF;
|
||||
};
|
||||
|
||||
ItemEncodedPatternBakedModel(IBakedModel baseModel, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms) {
|
||||
this.baseModel = baseModel;
|
||||
this.transforms = transforms;
|
||||
@@ -90,88 +99,8 @@ class ItemEncodedPatternBakedModel implements IBakedModel {
|
||||
return PerspectiveMapWrapper.handlePerspective(this, this.transforms, cameraTransformType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Since the ItemOverrideList handling comes before handling the perspective awareness (which is the first place
|
||||
* where we
|
||||
* know how we are being rendered) we need to remember the model of the crafting output, and make the decision on
|
||||
* which to render later on.
|
||||
* Sadly, Forge is pretty inconsistent when it will call the handlePerspective method, so some methods are called
|
||||
* even on this interim-model.
|
||||
* Usually those methods only matter for rendering on the ground and other cases, where we wouldn't render the
|
||||
* crafting output model anyway,
|
||||
* so in those cases we delegate to the model of the encoded pattern.
|
||||
*/
|
||||
private class ShiftHoldingModelWrapper implements IBakedModel {
|
||||
|
||||
private final IBakedModel outputModel;
|
||||
|
||||
private ShiftHoldingModelWrapper(IBakedModel outputModel) {
|
||||
this.outputModel = outputModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
|
||||
final IBakedModel selectedModel;
|
||||
|
||||
// No need to re-check for shift being held since this model is only handed out in that case
|
||||
if (cameraTransformType == ItemCameraTransforms.TransformType.GUI) {
|
||||
selectedModel = this.outputModel;
|
||||
} else {
|
||||
selectedModel = ItemEncodedPatternBakedModel.this.baseModel;
|
||||
}
|
||||
|
||||
// Now retroactively handle the isGui3d call, for which we always return false below
|
||||
if (selectedModel.isGui3d() != ItemEncodedPatternBakedModel.this.baseModel.isGui3d()) {
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
|
||||
if (selectedModel instanceof IBakedModel) {
|
||||
return selectedModel.handlePerspective(cameraTransformType);
|
||||
}
|
||||
|
||||
return PerspectiveMapWrapper.handlePerspective(this, ItemEncodedPatternBakedModel.this.transforms, cameraTransformType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.getQuads(state, side, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.isAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
// NOTE: Sadly, Forge will let Minecraft call this method before handling the perspective awareness
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.isGui3d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.isBuiltInRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.getParticleTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.getItemCameraTransforms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
// This may be called for items on the ground, in which case we will always fall back to the pattern
|
||||
return ItemEncodedPatternBakedModel.this.baseModel.getOverrides();
|
||||
}
|
||||
private static boolean isShiftKeyDown() {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,15 +117,11 @@ class ItemEncodedPatternBakedModel implements IBakedModel {
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||
boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
if (shiftHeld) {
|
||||
if (isShiftKeyDown()) {
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
|
||||
ItemStack output = iep.getOutput(stack);
|
||||
if (!output.isEmpty()) {
|
||||
IBakedModel realModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(output);
|
||||
// Give the item model a chance to handle the overrides as well
|
||||
realModel = realModel.getOverrides().handleItemState(realModel, output, world, entity);
|
||||
return new ShiftHoldingModelWrapper(realModel);
|
||||
return Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(output, world, entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,14 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.guisync.SyncData;
|
||||
import appeng.container.slot.*;
|
||||
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.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
@@ -48,7 +55,6 @@ import appeng.helpers.InventoryAction;
|
||||
import appeng.me.helpers.PlayerSource;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.WrapperCursorItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -388,47 +394,8 @@ public abstract class AEBaseContainer extends Container {
|
||||
|
||||
if (Platform.itemComparisons().isSameItem(tis, t)) // t.isItemEqual(tis))
|
||||
{
|
||||
int maxSize = d.getSlotStackLimit();
|
||||
|
||||
int placeAble = maxSize - t.getCount();
|
||||
|
||||
if (tis.getCount() < placeAble) {
|
||||
placeAble = tis.getCount();
|
||||
}
|
||||
|
||||
t.setCount(t.getCount() + placeAble);
|
||||
tis.setCount(tis.getCount() - placeAble);
|
||||
|
||||
d.putStack(t);
|
||||
|
||||
if (tis.getCount() <= 0) {
|
||||
clickSlot.putStack(ItemStack.EMPTY);
|
||||
d.onSlotChanged();
|
||||
|
||||
this.updateSlot(clickSlot);
|
||||
this.updateSlot(d);
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
this.updateSlot(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// any match..
|
||||
for (final Slot d : selectedSlots) {
|
||||
if (d instanceof SlotDisabled || d instanceof SlotME) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (d.isItemValid(tis)) {
|
||||
if (d.getHasStack()) {
|
||||
final ItemStack t = d.getStack().copy();
|
||||
|
||||
if (Platform.itemComparisons().isSameItem(t, tis)) {
|
||||
int maxSize = t.getMaxStackSize();
|
||||
if (d.getSlotStackLimit() < maxSize) {
|
||||
if (maxSize > d.getSlotStackLimit()) {
|
||||
maxSize = d.getSlotStackLimit();
|
||||
}
|
||||
|
||||
@@ -447,10 +414,6 @@ public abstract class AEBaseContainer extends Container {
|
||||
clickSlot.putStack(ItemStack.EMPTY);
|
||||
d.onSlotChanged();
|
||||
|
||||
// if ( worldEntity != null )
|
||||
// worldEntity.markDirty();
|
||||
// if ( hasMETiles ) updateClient();
|
||||
|
||||
this.updateSlot(clickSlot);
|
||||
this.updateSlot(d);
|
||||
return ItemStack.EMPTY;
|
||||
@@ -458,7 +421,18 @@ public abstract class AEBaseContainer extends Container {
|
||||
this.updateSlot(d);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// any match..
|
||||
for (final Slot d : selectedSlots) {
|
||||
if (d instanceof SlotDisabled || d instanceof SlotME) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (d.isItemValid(tis)) {
|
||||
if (!d.getHasStack()) {
|
||||
int maxSize = tis.getMaxStackSize();
|
||||
if (maxSize > d.getSlotStackLimit()) {
|
||||
maxSize = d.getSlotStackLimit();
|
||||
@@ -476,10 +450,6 @@ public abstract class AEBaseContainer extends Container {
|
||||
clickSlot.putStack(ItemStack.EMPTY);
|
||||
d.onSlotChanged();
|
||||
|
||||
// if ( worldEntity != null )
|
||||
// worldEntity.markDirty();
|
||||
// if ( hasMETiles ) updateClient();
|
||||
|
||||
this.updateSlot(clickSlot);
|
||||
this.updateSlot(d);
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
@@ -54,6 +54,7 @@ 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.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
@@ -279,7 +280,8 @@ public class ContainerCraftConfirm extends AEBaseContainer {
|
||||
|
||||
final IActionHost ah = this.getActionHost();
|
||||
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) {
|
||||
|
||||
@@ -28,8 +28,13 @@ import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.AppEngInternalOversizedInventory;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class ContainerInterface extends ContainerUpgradeable implements IOptionalSlotHost {
|
||||
@@ -62,10 +67,23 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
|
||||
}
|
||||
|
||||
for (int x = 0; x < DualityInterface.NUMBER_OF_STORAGE_SLOTS; x++) {
|
||||
this.addSlotToContainer(new SlotNormal(this.myDuality.getStorage(), x, 8 + 18 * x, 35 + 18));
|
||||
this.addSlotToContainer(new SlotOversized(this.myDuality.getStorage(), x, 8 + 18 * x, 35 + 18));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
|
||||
if (slotId >= 0 && slotId < this.inventorySlots.size()) {
|
||||
if (this.inventorySlots.get(slotId) instanceof SlotOversized) {
|
||||
((AppEngInternalOversizedInventory) ((SlotOversized) this.inventorySlots.get(slotId)).getItemHandler()).limitExtraction(true);
|
||||
ItemStack ret = super.slotClick(slotId, dragType, clickTypeIn, player);
|
||||
((AppEngInternalOversizedInventory) ((SlotOversized) this.inventorySlots.get(slotId)).getItemHandler()).limitExtraction(false);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return super.slotClick(slotId, dragType, clickTypeIn, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight() {
|
||||
return 256;
|
||||
|
||||
+3
-4
@@ -50,6 +50,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
|
||||
|
||||
|
||||
public final class ContainerInterfaceConfigurationTerminal extends AEBaseContainer {
|
||||
|
||||
@@ -310,10 +312,7 @@ public final class ContainerInterfaceConfigurationTerminal extends AEBaseContain
|
||||
ItemHandlerUtil.setStackInSlot(inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy());
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
is.writeToNBT(itemNBT);
|
||||
if (is.getCount() > is.getMaxStackSize()) {
|
||||
itemNBT.setInteger("stackSize", is.getCount());
|
||||
}
|
||||
stackWriteToNBT(is, itemNBT);
|
||||
}
|
||||
|
||||
tag.setTag(Integer.toString(x + offset), itemNBT);
|
||||
|
||||
@@ -57,6 +57,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
|
||||
|
||||
|
||||
public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
|
||||
@@ -77,7 +79,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
this.grid = anchor.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
this.bindPlayerInventory(ip, 14, 256 - /* height of player inventory */82);
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -345,7 +347,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
ItemHandlerUtil.setStackInSlot(inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy());
|
||||
|
||||
if (!is.isEmpty()) {
|
||||
is.writeToNBT(itemNBT);
|
||||
stackWriteToNBT(is, itemNBT);
|
||||
}
|
||||
|
||||
tag.setTag(Integer.toString(x + offset), itemNBT);
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.container.implementations;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
@@ -50,6 +51,7 @@ import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.me.helpers.ChannelPowerSrc;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
@@ -70,7 +72,7 @@ import java.util.List;
|
||||
|
||||
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;
|
||||
public final IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
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) {
|
||||
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.clientCM = new ConfigManager(this);
|
||||
@@ -110,6 +116,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
|
||||
if (monitorable instanceof IPortableCell) {
|
||||
this.setPowerSource((IEnergySource) monitorable);
|
||||
if (monitorable instanceof WirelessTerminalGuiObject) {
|
||||
this.networkNode = ((WirelessTerminalGuiObject) monitorable).getActionableNode();
|
||||
}
|
||||
} else if (monitorable instanceof IMEChest) {
|
||||
this.setPowerSource((IEnergySource) monitorable);
|
||||
} 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) {
|
||||
for (final IAEItemStack is : list) {
|
||||
this.items.add(is);
|
||||
}
|
||||
((GuiMEMonitorable) this.gui).postUpdate(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,55 +21,126 @@ package appeng.container.implementations;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.IUpgradeableCellContainer;
|
||||
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.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
public class ContainerMEPortableCell extends ContainerMEMonitorable {
|
||||
public class ContainerMEPortableCell extends ContainerMEMonitorable implements IUpgradeableCellContainer, IAEAppEngInventory, IInventorySlotAware {
|
||||
|
||||
private double powerMultiplier = 0.5;
|
||||
|
||||
private final IPortableCell civ;
|
||||
private int ticks = 0;
|
||||
protected final WirelessTerminalGuiObject wirelessTerminalGUIObject;
|
||||
private final int slot;
|
||||
private double powerMultiplier = 0.5;
|
||||
private int ticks = 0;
|
||||
|
||||
public ContainerMEPortableCell(final InventoryPlayer ip, final IPortableCell monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
if (monitorable instanceof IInventorySlotAware) {
|
||||
protected AppEngInternalInventory upgrades;
|
||||
protected SlotRestrictedInput magnetSlot;
|
||||
|
||||
public ContainerMEPortableCell(InventoryPlayer ip, WirelessTerminalGuiObject monitorable, boolean bindInventory) {
|
||||
super(ip, monitorable, bindInventory);
|
||||
if (monitorable != null) {
|
||||
final int slotIndex = ((IInventorySlotAware) monitorable).getInventorySlot();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
if (!((IInventorySlotAware) monitorable).isBaubleSlot()) {
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
}
|
||||
this.slot = slotIndex;
|
||||
} else {
|
||||
this.slot = -1;
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
}
|
||||
this.civ = monitorable;
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
this.wirelessTerminalGUIObject = monitorable;
|
||||
this.upgrades = new StackUpgradeInventory(wirelessTerminalGUIObject.getItemStack(), this, 2);
|
||||
this.loadFromNBT();
|
||||
this.setupUpgrades();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot);
|
||||
if (Platform.isServer()) {
|
||||
|
||||
if (this.civ == null || currentItem.isEmpty()) {
|
||||
this.setValidContainer(false);
|
||||
} else if (this.civ != null && !this.civ.getItemStack().isEmpty() && currentItem != this.civ.getItemStack()) {
|
||||
if (ItemStack.areItemsEqual(this.civ.getItemStack(), currentItem)) {
|
||||
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack());
|
||||
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)) {
|
||||
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
// drain 1 ae t
|
||||
this.ticks++;
|
||||
if (this.ticks > 10) {
|
||||
this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
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 (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);
|
||||
}
|
||||
|
||||
// drain 1 ae t
|
||||
this.ticks++;
|
||||
if (this.ticks > 10) {
|
||||
this.civ.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
this.ticks = 0;
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
@Override
|
||||
protected IActionHost getActionHost() {
|
||||
return this.wirelessTerminalGUIObject;
|
||||
}
|
||||
|
||||
private double getPowerMultiplier() {
|
||||
@@ -79,4 +150,57 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable {
|
||||
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 onSlotChange(Slot s) {
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@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,29 +1,35 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
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.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.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternTerm;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.parts.reporting.AbstractPartEncoder;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
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.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
@@ -38,9 +44,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackWriteToNBT;
|
||||
|
||||
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);
|
||||
|
||||
@@ -48,7 +58,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
protected SlotPatternTerm craftSlot;
|
||||
protected SlotRestrictedInput patternSlotIN;
|
||||
protected SlotRestrictedInput patternSlotOUT;
|
||||
private IRecipe currentRecipe;
|
||||
protected IRecipe currentRecipe;
|
||||
|
||||
protected SlotFakeCraftingMatrix[] craftingSlots;
|
||||
protected OptionalSlotFake[] outputSlots;
|
||||
@@ -57,17 +67,22 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
public boolean craftingMode = true;
|
||||
@GuiSync(96)
|
||||
public boolean substitute = false;
|
||||
|
||||
public ContainerPatternEncoder(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
patternTerminal = (AbstractPartEncoder) monitorable;
|
||||
}
|
||||
@GuiSync(95)
|
||||
public boolean packaging = false;
|
||||
|
||||
protected ContainerPatternEncoder(InventoryPlayer ip, ITerminalHost monitorable, boolean bindInventory) {
|
||||
super(ip, monitorable, bindInventory);
|
||||
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
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
|
||||
if (Platform.isClient()) {
|
||||
@@ -97,7 +112,10 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
if (name.equals("player")) {
|
||||
return new PlayerInvWrapper(this.getInventoryPlayer());
|
||||
}
|
||||
return this.getPart().getInventoryByName(name);
|
||||
if (this.getPart() != null) {
|
||||
return this.getPart().getInventoryByName(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,7 +130,20 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
|
||||
@Override
|
||||
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
|
||||
@@ -199,7 +230,6 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1);
|
||||
if (maybePattern.isPresent()) {
|
||||
output = maybePattern.get();
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,10 +249,16 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
|
||||
encodedValue.setTag("in", tagIn);
|
||||
encodedValue.setTag("out", tagOut);
|
||||
encodedValue.setBoolean("crafting", this.isCraftingMode());
|
||||
encodedValue.setBoolean("substitute", this.isSubstitute());
|
||||
if (this.isCraftingMode()) {
|
||||
encodedValue.setBoolean("crafting", this.isCraftingMode());
|
||||
encodedValue.setBoolean("substitute", this.isSubstitute());
|
||||
} else {
|
||||
encodedValue.setBoolean("packaging", this.isPackaging());
|
||||
}
|
||||
|
||||
output.setTagCompound(encodedValue);
|
||||
|
||||
patternSlotOUT.putStack(output);
|
||||
}
|
||||
|
||||
public void multiply(int multiple) {
|
||||
@@ -473,8 +509,20 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
void setCraftingMode(final boolean craftingMode) {
|
||||
public void setCraftingMode(final boolean 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -483,19 +531,88 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
}
|
||||
|
||||
public void setSubstitute(final boolean substitute) {
|
||||
if (getPart() != null) {
|
||||
getPart().setSubstitution(substitute);
|
||||
} else if (iGuiItemObject != null) {
|
||||
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
||||
if (nbtTagCompound != null) {
|
||||
nbtTagCompound.setBoolean("isSubstitute", 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPackaging() {
|
||||
return this.packaging;
|
||||
}
|
||||
|
||||
public void setPackaging(boolean packaging) {
|
||||
if (getPart() != null) {
|
||||
getPart().setPackaging(packaging);
|
||||
} else if (iGuiItemObject != null) {
|
||||
NBTTagCompound nbtTagCompound = iGuiItemObject.getItemStack().getTagCompound();
|
||||
if (nbtTagCompound != null) {
|
||||
nbtTagCompound.setBoolean("isPackaging", packaging);
|
||||
}
|
||||
}
|
||||
this.packaging = packaging;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (Platform.isServer()) {
|
||||
if (this.isCraftingMode() != this.getPart().isCraftingRecipe()) {
|
||||
this.setCraftingMode(this.getPart().isCraftingRecipe());
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
if (getPart() != null) {
|
||||
if (this.isCraftingMode() != this.getPart().isCraftingRecipe()) {
|
||||
this.setCraftingMode(this.getPart().isCraftingRecipe());
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
this.packaging = this.getPart().isPackaging();
|
||||
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);
|
||||
}
|
||||
|
||||
this.substitute = this.getPart().isSubstitution();
|
||||
if (nbtTagCompound.hasKey("isSubstitute")) {
|
||||
boolean substitute = nbtTagCompound.getBoolean("isSubstitute");
|
||||
if (this.isSubstitute() != substitute) {
|
||||
this.setSubstitute(substitute);
|
||||
}
|
||||
} else {
|
||||
nbtTagCompound.setBoolean("isSubstitute", false);
|
||||
}
|
||||
|
||||
if (nbtTagCompound.hasKey("isPackaging")) {
|
||||
boolean packaging = nbtTagCompound.getBoolean("isPackaging");
|
||||
if (this.isPackaging() != packaging) {
|
||||
this.setPackaging(packaging);
|
||||
}
|
||||
} else {
|
||||
nbtTagCompound.setBoolean("isPackaging", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,10 +643,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if (!i.isEmpty()) {
|
||||
i.writeToNBT(c);
|
||||
if (i.getCount() > i.getMaxStackSize()) {
|
||||
c.setInteger("stackSize", i.getCount());
|
||||
}
|
||||
stackWriteToNBT(i, c);
|
||||
}
|
||||
|
||||
return c;
|
||||
@@ -547,4 +661,98 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
|
||||
this.detectAndSendChanges();
|
||||
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,48 +19,19 @@
|
||||
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.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.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.container.slot.SlotPatternTerm;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
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.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.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;
|
||||
|
||||
|
||||
public class ContainerPatternTerm extends ContainerPatternEncoder {
|
||||
|
||||
|
||||
|
||||
public ContainerPatternTerm(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
@@ -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.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
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) {
|
||||
super(ip, quantumBridge, null);
|
||||
|
||||
this.addSlotToContainer((new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
|
||||
.getInternalInventory(), 0, 80, 37, this.getInventoryPlayer())).setStackLimit(1));
|
||||
SINGULARITY = new OptionalSlotRestrictedInput(SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
|
||||
.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);
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* 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 ContainerMEPortableCell 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);
|
||||
}
|
||||
}
|
||||
|
||||
@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,307 @@
|
||||
/*
|
||||
* 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)) {
|
||||
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
// drain 1 ae t
|
||||
this.ticks++;
|
||||
if (this.ticks > 10) {
|
||||
this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
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 (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");
|
||||
tag.setBoolean("isPackaging", this.packaging);
|
||||
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"));
|
||||
this.packaging = data.getBoolean("isPackaging");
|
||||
}
|
||||
}
|
||||
|
||||
@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 < details.getOutputs().length; x++) {
|
||||
final IAEItemStack item = details.getOutputs()[x];
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
|
||||
public class ContainerWirelessTerm extends ContainerMEPortableCell {
|
||||
|
||||
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
|
||||
|
||||
public ContainerWirelessTerm(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
|
||||
super(ip, gui);
|
||||
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()));
|
||||
}
|
||||
super(ip, gui, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,39 @@
|
||||
/*
|
||||
* 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.interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Any item providing a GUI and depending on an exact inventory slot.
|
||||
* <p>
|
||||
* This interface is likely a volatile one until a general GUI refactoring occurred.
|
||||
* Use it with care and expect changes.
|
||||
*/
|
||||
public interface IInventorySlotAware {
|
||||
/**
|
||||
* This is needed to select the correct slot index.
|
||||
*
|
||||
* @return the inventory index of this portable cell.
|
||||
*/
|
||||
int getInventorySlot();
|
||||
}
|
||||
/*
|
||||
* 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.interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Any item providing a GUI and depending on an exact inventory slot.
|
||||
* <p>
|
||||
* This interface is likely a volatile one until a general GUI refactoring occurred.
|
||||
* Use it with care and expect changes.
|
||||
*/
|
||||
public interface IInventorySlotAware {
|
||||
/**
|
||||
* This is needed to select the correct slot index.
|
||||
*
|
||||
* @return the inventory index of this portable cell.
|
||||
*/
|
||||
int getInventorySlot();
|
||||
|
||||
default boolean isBaubleSlot() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public class AppEngSlot extends Slot {
|
||||
@Override
|
||||
public void onSlotChanged() {
|
||||
this.setIsValid(hasCalculatedValidness.NotAvailable);
|
||||
if (this.isSlotEnabled()) {
|
||||
if (this.isSlotEnabled() && this.itemHandler != null) {
|
||||
ItemHandlerUtil.setStackInSlot(this.itemHandler, this.index, this.getStack().copy());
|
||||
|
||||
if (this.getContainer() != null) {
|
||||
|
||||
@@ -40,6 +40,10 @@ import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.WrapperCursorItemHandler;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.blamejared.recipestages.recipes.RecipeStage;
|
||||
import net.darkhax.gamestages.GameStageHelper;
|
||||
import net.darkhax.itemstages.ItemStages;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -49,6 +53,9 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -90,6 +97,28 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
return is;
|
||||
}
|
||||
|
||||
// Don't render the item client-side if the item stage for it is not unlocked yet
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (Platform.isClient() && Loader.isModLoaded("itemstages")) {
|
||||
return itemstageStack();
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
ItemStack itemstageStack() {
|
||||
final ItemStack item = super.getStack();
|
||||
final String itemsStage = ItemStages.getStage(item);
|
||||
final String enchantStage = ItemStages.getEnchantStage(item);
|
||||
final EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
|
||||
if ((itemsStage != null && !GameStageHelper.hasStage(player, itemsStage))
|
||||
|| (enchantStage != null && !GameStageHelper.hasStage(player, enchantStage)))
|
||||
return ItemStack.EMPTY;
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
public void doClick(final InventoryAction action, final EntityPlayer who) {
|
||||
if (this.getStack().isEmpty()) {
|
||||
return;
|
||||
@@ -144,17 +173,39 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
protected IRecipe findRecipe(InventoryCrafting ic, World world) {
|
||||
protected IRecipe findRecipe(InventoryCrafting ic, World world, EntityPlayer player) {
|
||||
if (this.container instanceof ContainerCraftingTerm) {
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
if (recipe != null && recipe.matches(ic, world)) {
|
||||
return containerTerminal.getCurrentRecipe();
|
||||
return handleRecipe(ic, containerTerminal.getCurrentRecipe(), player);
|
||||
}
|
||||
}
|
||||
|
||||
return CraftingManager.findMatchingRecipe(ic, world);
|
||||
return handleRecipe(ic, CraftingManager.findMatchingRecipe(ic, world), player);
|
||||
}
|
||||
|
||||
// Returns null in case this recipe is not yet unlocked
|
||||
private IRecipe handleRecipe(InventoryCrafting ic, IRecipe recipe, EntityPlayer player) {
|
||||
if (Loader.isModLoaded("recipestages")) {
|
||||
if (recipe instanceof RecipeStage) {
|
||||
final RecipeStage staged = (RecipeStage) recipe;
|
||||
if (!staged.isGoodForCrafting(ic))
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (Loader.isModLoaded("itemstages")) {
|
||||
final String itemsStage = ItemStages.getStage(recipe.getRecipeOutput());
|
||||
final String enchantStage = ItemStages.getEnchantStage(recipe.getRecipeOutput());
|
||||
|
||||
if ((itemsStage != null && !GameStageHelper.hasStage(player, itemsStage))
|
||||
|| (enchantStage != null && !GameStageHelper.hasStage(player, enchantStage)))
|
||||
return null;
|
||||
}
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
@@ -192,7 +243,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
ic.setInventorySlotContents(x, this.getPattern().getStackInSlot(x));
|
||||
}
|
||||
|
||||
final IRecipe r = this.findRecipe(ic, p.world);
|
||||
final IRecipe r = this.findRecipe(ic, p.world, p);
|
||||
|
||||
if (r == null) {
|
||||
final Item target = request.getItem();
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package appeng.container.slot;
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class SlotOversized extends SlotNormal {
|
||||
public SlotOversized(IItemHandler inv, int slot, int xPos, int yPos) {
|
||||
super(inv, slot, xPos, yPos);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ package appeng.container.slot;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
@@ -200,6 +201,11 @@ public class SlotRestrictedInput extends AppEngSlot {
|
||||
return i.getItem() instanceof IBiometricCard;
|
||||
case UPGRADES:
|
||||
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:
|
||||
break;
|
||||
}
|
||||
@@ -269,6 +275,8 @@ public class SlotRestrictedInput extends AppEngSlot {
|
||||
|
||||
RANGE_BOOSTER(6 * 16 + 15),
|
||||
QE_SINGULARITY(10 * 16 + 15),
|
||||
|
||||
CARD_QUANTUM(13 * 16 + 15),
|
||||
SPATIAL_STORAGE_CELLS(11 * 16 + 15),
|
||||
|
||||
FUEL(12 * 16 + 15),
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package appeng.core;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
@IFMLLoadingPlugin.Name("AE2ELCore")
|
||||
@IFMLLoadingPlugin.MCVersion("1.12.2")
|
||||
@IFMLLoadingPlugin.SortingIndex(1001)
|
||||
@IFMLLoadingPlugin.TransformerExclusions("appeng.core.transformer")
|
||||
public class AE2ELCore implements IFMLLoadingPlugin {
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[]{
|
||||
"appeng.core.transformer.AE2ELTransformer"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -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_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 + ",);";
|
||||
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
|
||||
private static final AppEng INSTANCE = new AppEng();
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.features.IRecipeHandlerRegistry;
|
||||
@@ -105,7 +107,9 @@ import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@@ -377,6 +381,9 @@ final class Registration {
|
||||
Upgrades.FUZZY.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
|
||||
Upgrades.FUZZY.registerItem(parts.storageBus(), 1);
|
||||
Upgrades.INVERTER.registerItem(parts.storageBus(), 1);
|
||||
@@ -403,7 +410,22 @@ final class Registration {
|
||||
Upgrades.SPEED.registerItem(blocks.inscriber(), 3);
|
||||
|
||||
// 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.QUANTUM_LINK.registerItem(id, 1);
|
||||
Upgrades.MAGNET.registerItem(id, 1);
|
||||
});
|
||||
}
|
||||
items.wirelessFluidTerminal().maybeItem().ifPresent(terminal -> {
|
||||
registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal);
|
||||
Upgrades.QUANTUM_LINK.registerItem(items.wirelessFluidTerminal(), 1);
|
||||
});
|
||||
|
||||
// Charge Rates
|
||||
items.chargedStaff().maybeItem().ifPresent(chargedStaff -> registries.charger().addChargeRate(chargedStaff, 320d));
|
||||
|
||||
@@ -4,14 +4,36 @@ package appeng.core.api;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IClientHelper;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.fluids.items.FluidDummyItem;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ApiClientHelper implements IClientHelper {
|
||||
|
||||
private static final String[] NUMBER_FORMATS = new String[]{"#.000", "#.00", "#.0", "#"};
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler, List<String> lines) {
|
||||
if (handler == null) {
|
||||
@@ -27,16 +49,95 @@ public class ApiClientHelper implements IClientHelper {
|
||||
.getLocal());
|
||||
}
|
||||
|
||||
IItemList<?> itemList = cellInventory.getChannel().createList();
|
||||
|
||||
if (handler.isPreformatted()) {
|
||||
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded).getLocal();
|
||||
|
||||
if (handler.isFuzzy()) {
|
||||
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Fuzzy.getLocal());
|
||||
lines.add("[" + GuiText.Partitioned.getLocal() + "]" + " - " + list + ' ' + GuiText.Fuzzy.getLocal());
|
||||
} else {
|
||||
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
|
||||
lines.add("[" + GuiText.Partitioned.getLocal() + "]" + " - " + list + ' ' + GuiText.Precise.getLocal());
|
||||
}
|
||||
|
||||
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
IItemHandler inv = cellInventory.getConfigInventory();
|
||||
cellInventory.getAvailableItems((IItemList) itemList);
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
final ItemStack is = inv.getStackInSlot(i);
|
||||
if (!is.isEmpty()) {
|
||||
if (cellInventory.getChannel() instanceof IItemStorageChannel) {
|
||||
if (!handler.isFuzzy()) {
|
||||
final IAEItemStack ais = AEItemStack.fromItemStack(is);
|
||||
IAEItemStack stocked = ((IItemList<IAEItemStack>) itemList).findPrecise(ais);
|
||||
lines.add("[" + is.getDisplayName() + "]" + ": " + (stocked == null ? "0" : ReadableNumberConverter.INSTANCE.toWideReadableForm(stocked.getStackSize())));
|
||||
} else {
|
||||
final IAEItemStack ais = AEItemStack.fromItemStack(is);
|
||||
Collection<IAEItemStack> stocked = ((IItemList<IAEItemStack>) itemList).findFuzzy(ais, handler.getCellInv().getFuzzyMode());
|
||||
|
||||
int[] ids = OreDictionary.getOreIDs(is);
|
||||
long size = 0;
|
||||
for (IAEItemStack ist : stocked) {
|
||||
size += ist.getStackSize();
|
||||
}
|
||||
|
||||
if (is.getItem().isDamageable()) {
|
||||
lines.add("[" + is.getDisplayName() + "]" + ": " + size);
|
||||
} else if (ids.length > 0) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int j : ids) {
|
||||
sb.append(OreDictionary.getOreName(j)).append(", ");
|
||||
}
|
||||
lines.add("[{" + sb.substring(0, sb.length() - 2) + "}]" + ": " + ReadableNumberConverter.INSTANCE.toWideReadableForm(size));
|
||||
}
|
||||
}
|
||||
} else if (cellInventory.getChannel() instanceof IFluidStorageChannel) {
|
||||
final AEFluidStack ais;
|
||||
if (is.getItem() instanceof FluidDummyItem) {
|
||||
ais = AEFluidStack.fromFluidStack(((FluidDummyItem) is.getItem()).getFluidStack(is));
|
||||
} else {
|
||||
ais = AEFluidStack.fromFluidStack(FluidUtil.getFluidContained(is));
|
||||
}
|
||||
IAEFluidStack stocked = ((IItemList<IAEFluidStack>) itemList).findPrecise(ais);
|
||||
lines.add("[" + is.getDisplayName() + "]" + ": " + (stocked == null ? "0" : fluidStackSize(stocked.getStackSize())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
cellInventory.getAvailableItems((IItemList) itemList);
|
||||
for (IAEStack<?> s : itemList) {
|
||||
if (s instanceof IAEItemStack) {
|
||||
lines.add(((IAEItemStack) s).getDefinition().getDisplayName() + ": " + ReadableNumberConverter.INSTANCE.toWideReadableForm(s.getStackSize()));
|
||||
} else if (s instanceof IAEFluidStack) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,9 @@ public final class ApiItems implements IItems {
|
||||
|
||||
private final IItemDefinition entropyManipulator;
|
||||
private final IItemDefinition wirelessTerminal;
|
||||
private final IItemDefinition wirelessCraftingTerminal;
|
||||
private final IItemDefinition wirelessPatternTerminal;
|
||||
private final IItemDefinition wirelessFluidTerminal;
|
||||
private final IItemDefinition biometricCard;
|
||||
private final IItemDefinition chargedStaff;
|
||||
private final IItemDefinition massCannon;
|
||||
@@ -178,6 +181,10 @@ public final class ApiItems implements IItems {
|
||||
.dispenserBehavior(DispenserBlockTool::new)
|
||||
.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.massCannon = powerTools.item("matter_cannon", ToolMatterCannon::new)
|
||||
.addFeatures(AEFeature.MATTER_CANNON)
|
||||
@@ -343,6 +350,21 @@ public final class ApiItems implements IItems {
|
||||
return this.wirelessTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessCraftingTerminal() {
|
||||
return wirelessCraftingTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessFluidTerminal() {
|
||||
return wirelessFluidTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessPatternTerminal() {
|
||||
return wirelessPatternTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition biometricCard() {
|
||||
return this.biometricCard;
|
||||
|
||||
@@ -85,6 +85,8 @@ public final class ApiMaterials implements IMaterials {
|
||||
private final IItemDefinition cardSpeed;
|
||||
private final IItemDefinition cardCapacity;
|
||||
private final IItemDefinition cardPatternExpansion;
|
||||
private final IItemDefinition cardQuantumLink;
|
||||
private final IItemDefinition cardMagnet;
|
||||
private final IItemDefinition cardFuzzy;
|
||||
private final IItemDefinition cardInverter;
|
||||
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.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.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.cardInverter = new DamagedItemDefinition("material.card.inverter", materials.createMaterial(MaterialType.CARD_INVERTER));
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardQuantumLink() {
|
||||
return this.cardQuantumLink;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardMagnet() {
|
||||
return this.cardMagnet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition cardFuzzy() {
|
||||
return this.cardFuzzy;
|
||||
|
||||
@@ -28,6 +28,7 @@ package appeng.core.api.imc;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.api.IIMCProcessor;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
|
||||
@@ -37,7 +38,7 @@ public class IMCSpatial implements IIMCProcessor {
|
||||
public void process(final IMCMessage m) {
|
||||
|
||||
try {
|
||||
final Class classInstance = Class.forName(m.getStringValue());
|
||||
final Class classInstance = Class.forName(m.getStringValue(), false, Launch.classLoader);
|
||||
AEApi.instance().registries().movable().whiteListTileEntity(classInstance);
|
||||
} catch (final ClassNotFoundException e) {
|
||||
AELog.info("Bad Class Registered: " + m.getStringValue() + " by " + m.getSender());
|
||||
|
||||
@@ -64,6 +64,10 @@ public enum AEFeature {
|
||||
ENTROPY_MANIPULATOR("EntropyManipulator", Constants.CATEGORY_TOOLS),
|
||||
MATTER_CANNON("MatterCannon", 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),
|
||||
METEORITE_COMPASS("MeteoriteCompass", Constants.CATEGORY_TOOLS),
|
||||
|
||||
|
||||
@@ -25,10 +25,13 @@ import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -80,6 +83,7 @@ public final class WirelessRegistry implements IWirelessTermRegistry {
|
||||
}
|
||||
|
||||
final IWirelessTermHandler handler = this.getWirelessTerminalHandler(item);
|
||||
|
||||
final String unparsedKey = handler.getEncryptionKey(item);
|
||||
if (unparsedKey.isEmpty()) {
|
||||
player.sendMessage(PlayerMessages.DeviceNotLinked.get());
|
||||
@@ -94,7 +98,7 @@ public final class WirelessRegistry implements IWirelessTermRegistry {
|
||||
}
|
||||
|
||||
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 {
|
||||
player.sendMessage(PlayerMessages.DeviceNotPowered.get());
|
||||
}
|
||||
|
||||
@@ -116,6 +116,11 @@ public enum ButtonToolTips {
|
||||
SubstitutionsOff,
|
||||
SubstitutionsDescEnabled,
|
||||
SubstitutionsDescDisabled,
|
||||
Packaging,
|
||||
PackagingOn,
|
||||
PackagingOff,
|
||||
PackagingDescEnabled,
|
||||
PackagingDescDisabled,
|
||||
CraftOnly,
|
||||
CraftEither,
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ public enum GuiText {
|
||||
And,
|
||||
With,
|
||||
Substitute,
|
||||
Package,
|
||||
Yes,
|
||||
No,
|
||||
|
||||
|
||||
@@ -84,7 +84,9 @@ public class AppEngPacketHandlerBase {
|
||||
|
||||
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;
|
||||
|
||||
@@ -43,6 +43,7 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.*;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.fluids.container.*;
|
||||
import appeng.fluids.helper.IFluidInterfaceHost;
|
||||
import appeng.fluids.parts.PartFluidFormationPlane;
|
||||
@@ -71,6 +72,7 @@ import appeng.tile.storage.TileDrive;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
import baubles.api.BaublesApi;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
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_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),
|
||||
|
||||
@@ -226,13 +232,14 @@ 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) {
|
||||
final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07);
|
||||
final GuiBridge ID = values()[ordinal >> 4];
|
||||
final boolean stem = ((ordinal >> 3) & 1) == 1;
|
||||
if (ID.type.isItem()) {
|
||||
ItemStack it = ItemStack.EMPTY;
|
||||
if (stem) {
|
||||
it = player.inventory.getCurrentItem();
|
||||
} else if (x >= 0 && x < player.inventory.mainInventory.size()) {
|
||||
it = player.inventory.getStackInSlot(x);
|
||||
if (y == 0) {
|
||||
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);
|
||||
if (myItem != null && ID.CorrectTileOrPart(myItem)) {
|
||||
@@ -337,13 +344,15 @@ 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) {
|
||||
final AEPartLocation side = AEPartLocation.fromOrdinal(ordinal & 0x07);
|
||||
final GuiBridge ID = values()[ordinal >> 4];
|
||||
final boolean stem = ((ordinal >> 3) & 1) == 1;
|
||||
if (ID.type.isItem()) {
|
||||
ItemStack it = ItemStack.EMPTY;
|
||||
if (stem) {
|
||||
it = player.inventory.getCurrentItem();
|
||||
} else if (x >= 0 && x < player.inventory.mainInventory.size()) {
|
||||
it = player.inventory.getStackInSlot(x);
|
||||
if (y == 0) {
|
||||
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);
|
||||
if (myItem != null && ID.CorrectTileOrPart(myItem)) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.implementations.ContainerExpandedProcessingPatternTerm;
|
||||
import appeng.container.implementations.ContainerPatternEncoder;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
@@ -63,6 +64,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class PacketJEIRecipe extends AppEngPacket {
|
||||
|
||||
@@ -85,7 +88,7 @@ public class PacketJEIRecipe extends AppEngPacket {
|
||||
if (list.tagCount() > 0) {
|
||||
this.recipe.add(new ItemStack[list.tagCount()]);
|
||||
for (int y = 0; y < list.tagCount(); y++) {
|
||||
this.recipe.get(x)[y] = new ItemStack(list.getCompoundTagAt(y));
|
||||
this.recipe.get(x)[y] = stackFromNBT(list.getCompoundTagAt(y));
|
||||
}
|
||||
} else {
|
||||
this.recipe.add(emptyArray);
|
||||
@@ -97,7 +100,7 @@ public class PacketJEIRecipe extends AppEngPacket {
|
||||
final NBTTagList outputList = comp.getTagList("outputs", 10);
|
||||
this.output = new ArrayList<>();
|
||||
for (int z = 0; z < outputList.tagCount(); z++) {
|
||||
this.output.add(new ItemStack(outputList.getCompoundTagAt(z)));
|
||||
this.output.add(stackFromNBT(outputList.getCompoundTagAt(z)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,9 +200,12 @@ public class PacketJEIRecipe extends AppEngPacket {
|
||||
if (request.getItem().isDamageable() || Platform.isGTDamageableItem(request.getItem())) {
|
||||
Collection<IAEItemStack> outList = inv.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)).getStorageList().findFuzzy(request, FuzzyMode.IGNORE_ALL);
|
||||
for (IAEItemStack is : outList) {
|
||||
if (is.getDefinition().getMetadata() == request.getDefinition().getMetadata()) {
|
||||
out = Platform.poweredExtraction(energy, storage, is.copy().setStackSize(1), cct.getActionSource());
|
||||
if (Platform.isGTDamageableItem(request.getItem())) {
|
||||
if (!(is.getDefinition().getMetadata() == request.getDefinition().getMetadata())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
out = Platform.poweredExtraction(energy, storage, is.copy().setStackSize(1), cct.getActionSource());
|
||||
if (out != null) {
|
||||
break;
|
||||
}
|
||||
@@ -247,16 +253,18 @@ public class PacketJEIRecipe extends AppEngPacket {
|
||||
|
||||
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");
|
||||
for (int i = 0; i < outputSlots.getSlots(); ++i) {
|
||||
ItemHandlerUtil.setStackInSlot(outputSlots, i, ItemStack.EMPTY);
|
||||
}
|
||||
for (int i = 0; i < this.output.size() && i < outputSlots.getSlots(); ++i) {
|
||||
if (this.output.get(i) == null || this.output.get(i) == ItemStack.EMPTY) {
|
||||
continue;
|
||||
if (outputSlots != null) {
|
||||
for (int i = 0; i < outputSlots.getSlots(); ++i) {
|
||||
ItemHandlerUtil.setStackInSlot(outputSlots, i, ItemStack.EMPTY);
|
||||
}
|
||||
for (int i = 0; i < this.output.size() && i < outputSlots.getSlots(); ++i) {
|
||||
if (this.output.get(i) == null || this.output.get(i) == ItemStack.EMPTY) {
|
||||
continue;
|
||||
}
|
||||
ItemHandlerUtil.setStackInSlot(outputSlots, i, this.output.get(i));
|
||||
}
|
||||
ItemHandlerUtil.setStackInSlot(outputSlots, i, this.output.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.client.gui.GuiFluidTerminal;
|
||||
import appeng.fluids.client.gui.GuiWirelessFluidTerminal;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -138,6 +139,8 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket {
|
||||
|
||||
if (gs instanceof GuiFluidTerminal) {
|
||||
((GuiFluidTerminal) gs).postUpdate(this.list);
|
||||
} else if (gs instanceof GuiWirelessFluidTerminal) {
|
||||
((GuiWirelessFluidTerminal)gs).postUpdate(this.list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ package appeng.core.sync.packets;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerPatternEncoder;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -98,9 +98,9 @@ public class PacketPatternSlot extends AppEngPacket {
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final AppEngPacket packet, final EntityPlayer player) {
|
||||
final EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
if (sender.openContainer instanceof ContainerPatternTerm) {
|
||||
final ContainerPatternTerm patternTerminal = (ContainerPatternTerm) sender.openContainer;
|
||||
patternTerminal.craftOrGetItem(this);
|
||||
if (sender.openContainer instanceof ContainerPatternEncoder) {
|
||||
final ContainerPatternEncoder patternEncoder = (ContainerPatternEncoder) sender.openContainer;
|
||||
patternEncoder.craftOrGetItem(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.fluids.container.ContainerFluidInterface;
|
||||
import appeng.fluids.container.ContainerFluidTerminal;
|
||||
import appeng.fluids.container.ContainerWirelessFluidTerminal;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
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) {
|
||||
if (player.openContainer instanceof ContainerFluidTerminal) {
|
||||
((ContainerFluidTerminal) player.openContainer).setTargetStack(this.stack);
|
||||
} else if (player.openContainer instanceof ContainerWirelessFluidTerminal) {
|
||||
((ContainerWirelessFluidTerminal) player.openContainer).setTargetStack(this.stack);
|
||||
} else if (player.openContainer instanceof ContainerFluidInterface) {
|
||||
((ContainerFluidInterface) player.openContainer).setTargetStack(this.stack);
|
||||
} else if (player.openContainer instanceof ContainerFluidInterfaceConfigurationTerminal) {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
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;
|
||||
|
||||
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)) {
|
||||
Platform.openGUI(player, i, terminal.getBridge(), false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < BaublesApi.getBaublesHandler(player).getSlots(); i++) {
|
||||
ItemStack is = BaublesApi.getBaublesHandler(player).getStackInSlot(i);
|
||||
if (terminal.getItemDefinition().isSameAs(is)) {
|
||||
Platform.openGUI(player, i, terminal.getBridge(), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,10 +130,10 @@ public class PacketValueConfig extends AppEngPacket {
|
||||
final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c;
|
||||
lvc.setLevel(Long.parseLong(this.Value), player);
|
||||
} else if (this.Name.startsWith("PatternTerminal.")) {
|
||||
if (c instanceof ContainerPatternTerm) {
|
||||
final ContainerPatternTerm cpt = (ContainerPatternTerm) c;
|
||||
if (c instanceof ContainerPatternEncoder) {
|
||||
final ContainerPatternEncoder cpt = (ContainerPatternEncoder) c;
|
||||
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")) {
|
||||
if (this.Value.equals("2")) {
|
||||
cpt.encodeAndMoveToInventory();
|
||||
@@ -157,32 +157,9 @@ public class PacketValueConfig extends AppEngPacket {
|
||||
} else if (this.Name.equals("PatternTerminal.MaximizeCount")) {
|
||||
cpt.maximizeCount();
|
||||
} else if (this.Name.equals("PatternTerminal.Substitute")) {
|
||||
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();
|
||||
cpt.setSubstitute(this.Value.equals("1"));
|
||||
} else if (this.Name.equals("PatternTerminal.Package")) {
|
||||
cpt.setPackaging(this.Value.equals("1"));
|
||||
}
|
||||
}
|
||||
} else if (this.Name.startsWith("StorageBus.")) {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package appeng.core.transformer;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class AE2ELTransformer implements IClassTransformer {
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
transformedName = transformedName.replace('/', '.');
|
||||
|
||||
byte[] data = basicClass;
|
||||
Consumer<ClassNode> consumer = (n) -> {
|
||||
};
|
||||
Consumer<ClassNode> emptyConsumer = consumer;
|
||||
|
||||
if ("net.minecraft.item.ItemStack".equals(transformedName)) {
|
||||
consumer = consumer.andThen(ItemStackPatch::patchCountGetSet);
|
||||
}
|
||||
|
||||
if (consumer != emptyConsumer) {
|
||||
return processNode(basicClass, consumer);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] processNode(byte[] data, Consumer<ClassNode> classNodeConsumer) {
|
||||
ClassReader reader = new ClassReader(data);
|
||||
ClassNode nodeOrig = new ClassNode();
|
||||
reader.accept(nodeOrig, 0);
|
||||
classNodeConsumer.accept(nodeOrig);
|
||||
ClassWriter writer = new ClassWriter(0);
|
||||
nodeOrig.accept(writer);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package appeng.core.transformer;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
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;
|
||||
|
||||
public final class ItemStackPatch {
|
||||
private ItemStackPatch() {
|
||||
}
|
||||
|
||||
public static void patchCountGetSet(ClassNode node) {
|
||||
for (MethodNode mn : node.methods) {
|
||||
if ("<init>".equals(mn.name)) {
|
||||
ListIterator<AbstractInsnNode> it = mn.instructions.iterator();
|
||||
while (it.hasNext()) {
|
||||
AbstractInsnNode in = it.next();
|
||||
if (in instanceof LdcInsnNode && "Count".equals(((LdcInsnNode) in).cst)) {
|
||||
AbstractInsnNode in2 = it.next();
|
||||
if (in2.getOpcode() == Opcodes.INVOKEVIRTUAL) {
|
||||
// :thinking:
|
||||
boolean patched = false;
|
||||
MethodInsnNode min2 = (MethodInsnNode) in2;
|
||||
if (min2.name.equals("getByte")) {
|
||||
min2.name = "getInteger";
|
||||
patched = true;
|
||||
} else if (min2.name.equals("func_74771_c")) {
|
||||
min2.name = "func_74762_e";
|
||||
patched = true;
|
||||
}
|
||||
|
||||
if (patched) {
|
||||
min2.desc = "(Ljava/lang/String;)I";
|
||||
System.out.println("Patched ItemStack Count getter!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ("func_77955_b".equals(mn.name) || "writeToNBT".equals(mn.name)) {
|
||||
ListIterator<AbstractInsnNode> it = mn.instructions.iterator();
|
||||
while (it.hasNext()) {
|
||||
AbstractInsnNode in = it.next();
|
||||
if (in instanceof LdcInsnNode && "Count".equals(((LdcInsnNode) in).cst)) {
|
||||
it.next();
|
||||
it.next();
|
||||
it.next();
|
||||
AbstractInsnNode in2 = it.next();
|
||||
if (in2.getOpcode() == Opcodes.INVOKEVIRTUAL) {
|
||||
// :thinking:
|
||||
boolean patched = false;
|
||||
MethodInsnNode min2 = (MethodInsnNode) in2;
|
||||
if (min2.name.equals("setByte")) {
|
||||
min2.name = "setInteger";
|
||||
patched = true;
|
||||
} else if (min2.name.equals("func_74774_a")) {
|
||||
min2.name = "func_74768_a";
|
||||
patched = true;
|
||||
}
|
||||
|
||||
if (patched) {
|
||||
min2.desc = "(Ljava/lang/String;I)V";
|
||||
System.out.println("Patched ItemStack Count setter!");
|
||||
|
||||
// Remove I2B cast
|
||||
it.previous();
|
||||
it.previous();
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Optional.Interface(iface = "gregtech.api.items.IToolItem", modid = "gregtech")
|
||||
public class CraftingTreeNode {
|
||||
|
||||
// what slot!
|
||||
|
||||
@@ -50,6 +50,7 @@ public class GuiFluidInterface extends GuiUpgradeable implements IConfigManagerH
|
||||
public GuiFluidInterface(final InventoryPlayer ip, final IFluidInterfaceHost te) {
|
||||
super(new ContainerFluidInterface(ip, te));
|
||||
this.ySize = 231;
|
||||
this.xSize = 245;
|
||||
this.host = te;
|
||||
(this.container = (ContainerFluidInterface) this.inventorySlots).setGui(this);
|
||||
|
||||
@@ -85,7 +86,7 @@ public class GuiFluidInterface extends GuiUpgradeable implements IConfigManagerH
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
this.bindTexture("guis/interfacefluid.png");
|
||||
this.bindTexture("guis/interfacefluidextendedlife.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,591 @@
|
||||
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)) {
|
||||
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
|
||||
// drain 1 ae t
|
||||
this.ticks++;
|
||||
if (this.ticks > 10) {
|
||||
double power = this.wirelessTerminalGUIObject.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
this.ticks = 0;
|
||||
this.hasPower = power > 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(Slot s) {
|
||||
detectAndSendChanges();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
final Block directedBlock = directedBlockState.getBlock();
|
||||
ItemStack what = new ItemStack(directedBlock, 1, directedBlock.getMetaFromState(directedBlockState));
|
||||
|
||||
if (Loader.isModLoaded("gregtech") && directedBlock instanceof BlockMachine) {
|
||||
if (Platform.GTLoaded && directedBlock instanceof BlockMachine) {
|
||||
MetaTileEntity metaTileEntity = Platform.getMetaTileEntity(directedTile.getWorld(), directedTile.getPos());
|
||||
if (metaTileEntity != null) {
|
||||
return metaTileEntity.getMetaFullName();
|
||||
|
||||
@@ -104,7 +104,7 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
|
||||
if (doFill) {
|
||||
if (fluid == null) {
|
||||
this.setFluidInSlot(slot, AEFluidStack.fromFluidStack(resource));
|
||||
this.setFluidInSlot(slot, AEFluidStack.fromFluidStack(resource).setStackSize(amountToStore));
|
||||
} else {
|
||||
fluid.setStackSize(fluid.getStackSize() + amountToStore);
|
||||
this.onContentChanged(slot);
|
||||
|
||||
@@ -161,13 +161,6 @@ public final class FluidList implements IItemList<IAEFluidStack> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidList clone() {
|
||||
FluidList list = new FluidList();
|
||||
list.records.putAll(records);
|
||||
return list;
|
||||
}
|
||||
|
||||
private IAEFluidStack getFluidRecord(final IAEFluidStack fluid) {
|
||||
return this.records.get(fluid);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.AppEngInternalOversizedInventory;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
@@ -100,6 +101,8 @@ import net.minecraftforge.items.wrapper.RangedWrapper;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.*;
|
||||
|
||||
|
||||
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost {
|
||||
public static final int NUMBER_OF_STORAGE_SLOTS = 9;
|
||||
@@ -115,7 +118,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
private final IActionSource interfaceRequestSource;
|
||||
private final ConfigManager cm = new ConfigManager(this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, NUMBER_OF_CONFIG_SLOTS, 512);
|
||||
private final AppEngInternalInventory storage = new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS, 512);
|
||||
private final AppEngInternalInventory storage = new AppEngInternalOversizedInventory(this, NUMBER_OF_STORAGE_SLOTS, 512);
|
||||
private final AppEngInternalInventory patterns = new AppEngInternalInventory(this, NUMBER_OF_PATTERN_SLOTS);
|
||||
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>(new NullInventory<IAEItemStack>(), AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>(new NullInventory<IAEFluidStack>(), AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
|
||||
@@ -207,9 +210,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
final NBTTagList waitingToSend = new NBTTagList();
|
||||
if (this.waitingToSend != null) {
|
||||
for (final ItemStack is : this.waitingToSend) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
is.writeToNBT(item);
|
||||
waitingToSend.appendTag(item);
|
||||
final NBTTagCompound itemNBT = stackToNBT(is);
|
||||
waitingToSend.appendTag(itemNBT);
|
||||
}
|
||||
}
|
||||
data.setTag("waitingToSend", waitingToSend);
|
||||
@@ -221,9 +223,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
NBTTagList waitingListSided = new NBTTagList();
|
||||
if (this.waitingToSendFacing.containsKey(s)) {
|
||||
for (final ItemStack is : this.waitingToSendFacing.get(s)) {
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
is.writeToNBT(item);
|
||||
waitingListSided.appendTag(item);
|
||||
final NBTTagCompound itemNBT = stackToNBT(is);
|
||||
waitingListSided.appendTag(itemNBT);
|
||||
}
|
||||
sidedWaitList.setTag(s.name(), waitingListSided);
|
||||
}
|
||||
@@ -239,7 +240,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
for (int x = 0; x < waitingList.tagCount(); x++) {
|
||||
final NBTTagCompound c = waitingList.getCompoundTagAt(x);
|
||||
if (c != null) {
|
||||
final ItemStack is = new ItemStack(c);
|
||||
final ItemStack is = stackFromNBT(c);
|
||||
this.addToSendList(is);
|
||||
}
|
||||
}
|
||||
@@ -254,7 +255,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
for (int x = 0; x < w.tagCount(); x++) {
|
||||
final NBTTagCompound c = w.getCompoundTagAt(x);
|
||||
if (c != null) {
|
||||
final ItemStack is = new ItemStack(c);
|
||||
final ItemStack is = stackFromNBT(c);
|
||||
this.addToSendListFacing(is, EnumFacing.getFront(s.getIndex()));
|
||||
}
|
||||
}
|
||||
@@ -626,7 +627,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
if (result.isEmpty()) {
|
||||
whatToSend = ItemStack.EMPTY;
|
||||
} else {
|
||||
whatToSend.setCount(whatToSend.getCount() - (whatToSend.getCount() - result.getCount()));
|
||||
whatToSend.setCount(result.getCount());
|
||||
whatToSend.setTagCompound(result.getTagCompound());
|
||||
}
|
||||
|
||||
if (whatToSend.isEmpty()) {
|
||||
@@ -680,6 +682,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
final IAEItemStack result = inv.injectItems(AEItemStack.fromItemStack(whatToSend), Actionable.MODULATE, this.mySource);
|
||||
if (result != null) {
|
||||
whatToSend.setCount((int) result.getStackSize());
|
||||
whatToSend.setTagCompound(result.getDefinition().getTagCompound());
|
||||
} else {
|
||||
i.remove();
|
||||
}
|
||||
@@ -708,6 +711,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
final ItemStack result = ad.addItems(whatToSend);
|
||||
if (!result.isEmpty()) {
|
||||
whatToSend.setCount(result.getCount());
|
||||
whatToSend.setTagCompound(result.getTagCompound());
|
||||
} else {
|
||||
i.remove();
|
||||
}
|
||||
@@ -1105,7 +1109,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
|
||||
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor(te, s.getOpposite());
|
||||
if (ad != null) {
|
||||
if (Loader.isModLoaded("actuallyadditions") && Loader.isModLoaded("gregtech") && te instanceof IPhantomTile) {
|
||||
if (Loader.isModLoaded("actuallyadditions") && Platform.GTLoaded && te instanceof IPhantomTile) {
|
||||
IPhantomTile phantomTE = ((IPhantomTile) te);
|
||||
if (phantomTE.hasBoundPosition()) {
|
||||
TileEntity phantom = w.getTileEntity(phantomTE.getBoundPosition());
|
||||
@@ -1287,7 +1291,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
final Block directedBlock = directedBlockState.getBlock();
|
||||
ItemStack what = new ItemStack(directedBlock, 1, directedBlock.getMetaFromState(directedBlockState));
|
||||
|
||||
if (Loader.isModLoaded("gregtech") && directedBlock instanceof BlockMachine) {
|
||||
if (Platform.GTLoaded && directedBlock instanceof BlockMachine) {
|
||||
MetaTileEntity metaTileEntity = Platform.getMetaTileEntity(directedTile.getWorld(), directedTile.getPos());
|
||||
if (metaTileEntity != null) {
|
||||
return metaTileEntity.getMetaFullName();
|
||||
|
||||
@@ -28,6 +28,8 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class InvalidPatternHelper {
|
||||
|
||||
@@ -89,11 +91,14 @@ public class InvalidPatternHelper {
|
||||
private final ItemStack stack;
|
||||
|
||||
public PatternIngredient(NBTTagCompound tag) {
|
||||
this.stack = new ItemStack(tag);
|
||||
this.stack = stackFromNBT(tag);
|
||||
|
||||
if (this.stack.isEmpty()) {
|
||||
this.id = tag.getString("id");
|
||||
this.count = tag.getByte("Count");
|
||||
if (tag.hasKey("stackSize")) {
|
||||
this.count = tag.getInteger("stackSize");
|
||||
}
|
||||
this.damage = Math.max(0, tag.getShort("Damage"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package appeng.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Methods to help with the added "stackSize" NBT tag to get around "Count" being written and read as a byte.
|
||||
*/
|
||||
public class ItemStackHelper {
|
||||
public static ItemStack stackFromNBT(NBTTagCompound itemNBT) {
|
||||
ItemStack is = new ItemStack(itemNBT);
|
||||
if (itemNBT.hasKey("stackSize")) {
|
||||
is.setCount(itemNBT.getInteger("stackSize"));
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
public static void stackWriteToNBT(ItemStack is, NBTTagCompound itemNBT) {
|
||||
is.writeToNBT(itemNBT);
|
||||
if (is.getCount() > Byte.MAX_VALUE) {
|
||||
itemNBT.setInteger("stackSize", is.getCount());
|
||||
}
|
||||
}
|
||||
|
||||
public static NBTTagCompound stackToNBT(ItemStack is) {
|
||||
NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
stackWriteToNBT(is, itemNBT);
|
||||
return itemNBT;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class NonBlockingItems {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ModItemMeta[0].equals("gregtech") && Platform.isModLoaded("gregtech")) {
|
||||
if (ModItemMeta[0].equals("gregtech") && Platform.GTLoaded) {
|
||||
boolean found = false;
|
||||
for (MetaItem<?> metaItem : MetaItem.getMetaItems()) {
|
||||
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem(ModItemMeta[1]);
|
||||
|
||||
@@ -40,6 +40,8 @@ import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
|
||||
|
||||
public class PatternHelper implements ICraftingPatternDetails, Comparable<PatternHelper> {
|
||||
|
||||
@@ -66,6 +68,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
private final Set<TestLookup> failCache = new HashSet<>();
|
||||
private final Set<TestLookup> passCache = new HashSet<>();
|
||||
private final IAEItemStack pattern;
|
||||
private final boolean isPackaging;
|
||||
private int priority = 0;
|
||||
|
||||
public PatternHelper(final ItemStack is, final World w) {
|
||||
@@ -78,6 +81,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
final NBTTagList inTag = encodedValue.getTagList("in", 10);
|
||||
final NBTTagList outTag = encodedValue.getTagList("out", 10);
|
||||
this.isCrafting = encodedValue.getBoolean("crafting");
|
||||
this.isPackaging = encodedValue.getBoolean("packaging");
|
||||
|
||||
crafting = new InventoryCrafting(new ContainerNull(), isCrafting ? 3 : 4, isCrafting ? 3 : 4);
|
||||
testFrame = new InventoryCrafting(new ContainerNull(), isCrafting ? 3 : 4, isCrafting ? 3 : 4);
|
||||
@@ -91,11 +95,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
|
||||
for (int x = 0; x < inTag.tagCount(); x++) {
|
||||
NBTTagCompound ingredient = inTag.getCompoundTagAt(x);
|
||||
final ItemStack gs = new ItemStack(ingredient);
|
||||
|
||||
if (ingredient.hasKey("stackSize")) {
|
||||
gs.setCount(ingredient.getInteger("stackSize"));
|
||||
}
|
||||
final ItemStack gs = stackFromNBT(ingredient);
|
||||
|
||||
if (!ingredient.hasNoTags() && gs.isEmpty()) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
@@ -126,11 +126,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
|
||||
for (int x = 0; x < outTag.tagCount(); x++) {
|
||||
NBTTagCompound resultItemTag = outTag.getCompoundTagAt(x);
|
||||
final ItemStack gs = new ItemStack(resultItemTag);
|
||||
|
||||
if (resultItemTag.hasKey("stackSize")) {
|
||||
gs.setCount(resultItemTag.getInteger("stackSize"));
|
||||
}
|
||||
final ItemStack gs = stackFromNBT(resultItemTag);
|
||||
|
||||
if (!resultItemTag.hasNoTags() && gs.isEmpty()) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
@@ -213,6 +209,11 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
return this.patternItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPackage() {
|
||||
return this.isPackaging;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isValidItemForSlot(final int slotIndex, final ItemStack i, final World w) {
|
||||
if (!this.isCrafting) {
|
||||
|
||||
@@ -25,7 +25,9 @@ import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.IUpgradeableCellHost;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.implementations.tiles.IWirelessAccessPoint;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -43,18 +45,29 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
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.qnb.TileQuantumBridge;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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 IWirelessTermHandler wth;
|
||||
private final String encryptionKey;
|
||||
private final EntityPlayer myPlayer;
|
||||
private final boolean isBaubleSlot;
|
||||
private IGrid targetGrid;
|
||||
private IStorageGrid sg;
|
||||
private IMEMonitor<IAEItemStack> itemStorage;
|
||||
@@ -63,12 +76,18 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
private double myRange = Double.MAX_VALUE;
|
||||
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) {
|
||||
this.encryptionKey = wh.getEncryptionKey(is);
|
||||
this.effectiveItem = is;
|
||||
this.myPlayer = ep;
|
||||
this.wth = wh;
|
||||
this.inventorySlot = x;
|
||||
this.isBaubleSlot = y == 1;
|
||||
|
||||
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() {
|
||||
@@ -227,6 +250,8 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
this.rangeCheck();
|
||||
if (this.myWap != null) {
|
||||
return this.myWap.getActionableNode();
|
||||
} else if (this.myQC != null && this.myQC.getCenter().isPowered()) {
|
||||
return this.myQC.getCenter().getActionableNode();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -242,9 +267,10 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
return false;
|
||||
}
|
||||
|
||||
final IMachineSet tw = this.targetGrid.getMachines(TileWireless.class);
|
||||
IMachineSet tw = this.targetGrid.getMachines(TileWireless.class);
|
||||
|
||||
this.myWap = null;
|
||||
this.myQC = null;
|
||||
|
||||
for (final IGridNode n : tw) {
|
||||
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;
|
||||
}
|
||||
@@ -286,4 +329,58 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
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 {
|
||||
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() {
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package appeng.integration.modules.chisel;
|
||||
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovementInput;
|
||||
import net.minecraft.util.MovementInputFromOptions;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import team.chisel.common.config.Configurations;
|
||||
|
||||
import static team.chisel.client.handler.BlockSpeedHandler.speedupBlocks;
|
||||
|
||||
@Mod.EventBusSubscriber(Side.CLIENT)
|
||||
public class ChiselBlockSpeedHandler {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static MovementInput manualInputCheck;
|
||||
|
||||
@Optional.Method(modid = "chisel")
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void speedupPlayer(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.START && event.side.isClient() && event.player.onGround && event.player instanceof EntityPlayerSP) {
|
||||
if (manualInputCheck == null) {
|
||||
manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
|
||||
}
|
||||
EntityPlayerSP player = (EntityPlayerSP) event.player;
|
||||
BlockPos blockPosBelow = new BlockPos(player.posX, player.posY - (1 / 16D), player.posZ);
|
||||
IBlockState below = player.getEntityWorld().getBlockState(blockPosBelow);
|
||||
if (below.getBlock() instanceof BlockCableBus) {
|
||||
IBlockState f = ((BlockCableBus) below.getBlock()).getFacadeState(Minecraft.getMinecraft().world, blockPosBelow, EnumFacing.UP);
|
||||
if (speedupBlocks.contains(f.getBlock())) {
|
||||
manualInputCheck.updatePlayerMoveState();
|
||||
if ((manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) && !player.isInWater()) {
|
||||
player.motionX *= Configurations.concreteVelocityMult;
|
||||
player.motionZ *= Configurations.concreteVelocityMult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package appeng.integration.modules.gregtech;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ToolClass {
|
||||
private static Class<?> GTToolClass;
|
||||
private static Method getMaxItemDamage = null;
|
||||
private static Method getItemDamage = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
GTToolClass = Class.forName("gregtech.api.items.IToolItem", false, Launch.classLoader);
|
||||
getItemDamage = ReflectionHelper.findMethod(GTToolClass, "getItemDamage", null, ItemStack.class);
|
||||
getMaxItemDamage = ReflectionHelper.findMethod(GTToolClass, "getMaxItemDamage", null, ItemStack.class);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
try {
|
||||
GTToolClass = Class.forName("gregtech.api.items.toolitem.IGTTool", false, Launch.classLoader);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final Enum<Interfaces> GTToolInterface = getGTToolInterface();
|
||||
|
||||
public static Class<?> getGTToolClass() {
|
||||
if (GTToolClass == null) {
|
||||
System.out.printf("TToolClass == null");
|
||||
}
|
||||
return GTToolClass;
|
||||
}
|
||||
|
||||
public static Enum<Interfaces> getGTToolInterface() {
|
||||
if (GTToolClass.getName().equals("IToolItem")) {
|
||||
return Interfaces.ITOOLITEM;
|
||||
} else {
|
||||
return Interfaces.IGTTOOL;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getGTMaxDamage(ItemStack itemStack) {
|
||||
if (GTToolInterface == Interfaces.ITOOLITEM) {
|
||||
try {
|
||||
return (int) getMaxItemDamage.invoke(itemStack.getItem(), itemStack);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
return itemStack.getMaxDamage();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getGTitemDamage(ItemStack itemStack) {
|
||||
if (GTToolInterface == Interfaces.ITOOLITEM) {
|
||||
try {
|
||||
return (int) getItemDamage.invoke(itemStack.getItem(), itemStack);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
return itemStack.getItemDamage();
|
||||
}
|
||||
}
|
||||
|
||||
enum Interfaces {
|
||||
ITOOLITEM,
|
||||
IGTTOOL
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,29 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import mezz.jei.api.gui.ITooltipCallback;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -34,26 +42,83 @@ public class CraftableCallBack implements ITooltipCallback<ItemStack> {
|
||||
public void onTooltip(int slotIndex, boolean input, ItemStack ingredient, List<String> tooltip) {
|
||||
if (!input) return;
|
||||
if (list != null) {
|
||||
IAEItemStack found = list.findPrecise(AEItemStack.fromItemStack(ingredient));
|
||||
if (found != null) {
|
||||
if (found.getStackSize() == 0) {
|
||||
|
||||
IItemList<IAEItemStack> available = mergeInventories(list, (ContainerMEMonitorable) container);
|
||||
|
||||
IAEItemStack search = AEItemStack.fromItemStack(ingredient);
|
||||
if (ingredient.getItem().isDamageable() || Platform.isGTDamageableItem(ingredient.getItem())) {
|
||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||
if (fuzzy.size() > 0) {
|
||||
for (IAEItemStack itemStack : fuzzy) {
|
||||
if (itemStack.getStackSize() > 0) {
|
||||
if (Platform.isGTDamageableItem(ingredient.getItem())) {
|
||||
if (!(ingredient.getMetadata() == itemStack.getDefinition().getMetadata())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
if (itemStack.isCraftable()) {
|
||||
line = "§1[" + I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.Craftable") + "]";
|
||||
tooltip.add(line);
|
||||
if (Mouse.isButtonDown(2) && this.lastClicked.elapsed(TimeUnit.MILLISECONDS) > 200) {
|
||||
this.lastClicked.reset().start();
|
||||
((AEBaseContainer) container).setTargetStack(itemStack);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.AUTO_CRAFT, container.getInventory().size(), 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
}
|
||||
if (found.isCraftable()) {
|
||||
String line = "§1[" + I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.Craftable") + "]";
|
||||
tooltip.add(line);
|
||||
if (Mouse.isButtonDown(2) && this.lastClicked.elapsed(TimeUnit.MILLISECONDS) > 200) {
|
||||
this.lastClicked.reset().start();
|
||||
((AEBaseContainer) container).setTargetStack(found);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.AUTO_CRAFT, container.getInventory().size(), 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
IAEItemStack found = available.findPrecise(search);
|
||||
if (found != null) {
|
||||
if (found.getStackSize() == 0) {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
}
|
||||
if (found.isCraftable()) {
|
||||
String line = "§1[" + I18n.translateToLocalFormatted("gui.tooltips.appliedenergistics2.Craftable") + "]";
|
||||
tooltip.add(line);
|
||||
if (Mouse.isButtonDown(2) && this.lastClicked.elapsed(TimeUnit.MILLISECONDS) > 200) {
|
||||
this.lastClicked.reset().start();
|
||||
((AEBaseContainer) container).setTargetStack(found);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.AUTO_CRAFT, container.getInventory().size(), 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String line = "§c[" + I18n.translateToLocalFormatted("gui.appliedenergistics2.Missing") + "]";
|
||||
tooltip.add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerMEMonitorable containerCraftingTerm) {
|
||||
IItemList<IAEItemStack> itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
for (IAEItemStack i : repo) {
|
||||
itemList.addStorage(i);
|
||||
}
|
||||
|
||||
PlayerMainInvWrapper invWrapper = new PlayerMainInvWrapper(containerCraftingTerm.getPlayerInv());
|
||||
for (int i = 0; i < invWrapper.getSlots(); i++) {
|
||||
itemList.addStorage(AEItemStack.fromItemStack(invWrapper.getStackInSlot(i)));
|
||||
}
|
||||
|
||||
if (containerCraftingTerm instanceof IContainerCraftingPacket) {
|
||||
IItemHandler itemHandler = ((IContainerCraftingPacket) containerCraftingTerm).getInventoryByName("crafting");
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||
itemList.addStorage(AEItemStack.fromItemStack(itemHandler.getStackInSlot(i)));
|
||||
}
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,17 @@ package appeng.integration.modules.jei;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.implementations.GuiCraftingTerm;
|
||||
import appeng.client.gui.implementations.GuiWirelessCraftingTerminal;
|
||||
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.item.AEItemStack;
|
||||
import mezz.jei.api.gui.IGuiIngredient;
|
||||
@@ -16,29 +22,37 @@ import mezz.jei.gui.recipes.RecipeLayout;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static mezz.jei.api.recipe.transfer.IRecipeTransferError.Type.USER_FACING;
|
||||
|
||||
public class JEIMissingItem implements IRecipeTransferError {
|
||||
|
||||
private boolean errored;
|
||||
public long lastUpdate;
|
||||
private final List<Integer> craftableSlots = new ArrayList<>();
|
||||
private final List<Integer> foundSlots = new ArrayList<>();
|
||||
|
||||
IItemList<IAEItemStack> available = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
JEIMissingItem(Container container, @Nonnull IRecipeLayout recipeLayout) {
|
||||
if (container instanceof ContainerCraftingTerm) {
|
||||
ContainerCraftingTerm craftingTerm = (ContainerCraftingTerm) container;
|
||||
GuiCraftingTerm g = (GuiCraftingTerm) craftingTerm.getGui();
|
||||
if (container instanceof ContainerMEMonitorable) {
|
||||
IItemList<IAEItemStack> ir = ((ContainerMEMonitorable) container).items;
|
||||
|
||||
IItemList<IAEItemStack> available = mergeInventories(ir, (ContainerMEMonitorable) container);
|
||||
|
||||
IItemList<IAEItemStack> ir = g.getRepo().getList();
|
||||
boolean found;
|
||||
this.errored = false;
|
||||
recipeLayout.getItemStacks().addTooltipCallback(new CraftableCallBack(container, ir));
|
||||
recipeLayout.getItemStacks().addTooltipCallback(new CraftableCallBack(container, available));
|
||||
|
||||
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||
@@ -49,30 +63,34 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
if (allIngredient instanceof ItemStack) {
|
||||
ItemStack stack = (ItemStack) allIngredient;
|
||||
if (!stack.isEmpty()) {
|
||||
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||
Collection<IAEItemStack> fuzzy = ir.findFuzzy(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL);
|
||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||
if (fuzzy.size() > 0) {
|
||||
for (IAEItemStack itemStack : fuzzy) {
|
||||
if (itemStack.getStackSize() > 0) {
|
||||
if (itemStack.fuzzyComparison(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL)) {
|
||||
found = true;
|
||||
break;
|
||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||
if (!(stack.getMetadata() == itemStack.getDefinition().getMetadata())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
used.add(itemStack.copy().setStackSize(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IAEItemStack ext = ir.findPrecise(AEItemStack.fromItemStack(stack));
|
||||
IAEItemStack ext = available.findPrecise(search);
|
||||
if (ext != null) {
|
||||
IAEItemStack usedStack = used.findPrecise(ext);
|
||||
if (ext.getStackSize() > 0 && (usedStack == null || ext.getStackSize() > usedStack.getStackSize())) {
|
||||
used.add(ext.copy().setStackSize(1));
|
||||
found = true;
|
||||
} else {
|
||||
found = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,38 +112,60 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
@Override
|
||||
public void showError(Minecraft minecraft, int mouseX, int mouseY, @Nonnull IRecipeLayout recipeLayout, int recipeX, int recipeY) {
|
||||
Container c = minecraft.player.openContainer;
|
||||
if (c instanceof ContainerCraftingTerm) {
|
||||
ContainerCraftingTerm craftingTerm = (ContainerCraftingTerm) c;
|
||||
|
||||
GuiCraftingTerm g = (GuiCraftingTerm) craftingTerm.getGui();
|
||||
IItemList<IAEItemStack> ir = g.getRepo().getList();
|
||||
if (c instanceof ContainerMEMonitorable) {
|
||||
ContainerMEMonitorable container = (ContainerMEMonitorable) c;
|
||||
IItemList<IAEItemStack> ir = ((ContainerMEMonitorable) c).items;
|
||||
boolean found;
|
||||
boolean craftable;
|
||||
int currentSlot = 0;
|
||||
this.errored = false;
|
||||
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
if (System.currentTimeMillis() - lastUpdate > 1000) {
|
||||
lastUpdate = System.currentTimeMillis();
|
||||
available = mergeInventories(ir, container);
|
||||
this.foundSlots.clear();
|
||||
this.craftableSlots.clear();
|
||||
} else {
|
||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||
if (i.isInput()) {
|
||||
if (!foundSlots.contains(currentSlot)) {
|
||||
if (craftableSlots.contains(currentSlot)) {
|
||||
i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY);
|
||||
} else {
|
||||
i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY);
|
||||
}
|
||||
}
|
||||
}
|
||||
currentSlot++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.used.resetStatus();
|
||||
|
||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||
found = false;
|
||||
craftable = false;
|
||||
List<ItemStack> valid = new ArrayList<>();
|
||||
if (i.isInput() && i.getAllIngredients().size() > 0) {
|
||||
ArrayList<ItemStack> valid = new ArrayList<>();
|
||||
if (i.isInput()) {
|
||||
List<?> allIngredients = i.getAllIngredients();
|
||||
for (Object allIngredient : allIngredients) {
|
||||
if (allIngredient instanceof ItemStack) {
|
||||
ItemStack stack = (ItemStack) allIngredient;
|
||||
if (!stack.isEmpty()) {
|
||||
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||
Collection<IAEItemStack> fuzzy = ir.findFuzzy(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL);
|
||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||
if (fuzzy.size() > 0) {
|
||||
for (IAEItemStack itemStack : fuzzy) {
|
||||
if (itemStack.getStackSize() > 0) {
|
||||
if (itemStack.fuzzyComparison(AEItemStack.fromItemStack(stack), FuzzyMode.IGNORE_ALL)) {
|
||||
found = true;
|
||||
used.add(itemStack.copy().setStackSize(1));
|
||||
valid.addAll(fuzzy.stream().map(IAEItemStack::createItemStack).collect(Collectors.toList()));
|
||||
break;
|
||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||
if (!(stack.getMetadata() == itemStack.getDefinition().getMetadata())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
used.add(itemStack.copy().setStackSize(1));
|
||||
valid.add(itemStack.copy().setStackSize(1).createItemStack());
|
||||
} else {
|
||||
if (itemStack.isCraftable()) {
|
||||
craftable = true;
|
||||
@@ -134,7 +174,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IAEItemStack ext = ir.findPrecise(AEItemStack.fromItemStack(stack));
|
||||
IAEItemStack ext = available.findPrecise(search);
|
||||
if (ext != null) {
|
||||
IAEItemStack usedStack = used.findPrecise(ext);
|
||||
if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) {
|
||||
@@ -144,27 +184,32 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
}
|
||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
||||
found = true;
|
||||
break;
|
||||
} else if (ext.isCraftable()) {
|
||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
||||
craftable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i.getAllIngredients().size() == 0) {
|
||||
found = true;
|
||||
}
|
||||
if (!found) {
|
||||
if (craftable) {
|
||||
i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY);
|
||||
this.craftableSlots.add(currentSlot);
|
||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
||||
} else {
|
||||
i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY);
|
||||
}
|
||||
this.errored = true;
|
||||
} else {
|
||||
this.foundSlots.add(currentSlot);
|
||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
||||
this.errored = false;
|
||||
}
|
||||
}
|
||||
currentSlot++;
|
||||
@@ -175,7 +220,27 @@ public class JEIMissingItem implements IRecipeTransferError {
|
||||
}
|
||||
}
|
||||
|
||||
IItemList<IAEItemStack> mergeInventories(IItemList<IAEItemStack> repo, ContainerMEMonitorable containerCraftingTerm) {
|
||||
IItemList<IAEItemStack> itemList = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
for (IAEItemStack i : repo) {
|
||||
itemList.addStorage(i);
|
||||
}
|
||||
|
||||
PlayerMainInvWrapper invWrapper = new PlayerMainInvWrapper(containerCraftingTerm.getPlayerInv());
|
||||
for (int i = 0; i < invWrapper.getSlots(); i++) {
|
||||
itemList.addStorage(AEItemStack.fromItemStack(invWrapper.getStackInSlot(i)));
|
||||
}
|
||||
|
||||
if (containerCraftingTerm instanceof IContainerCraftingPacket) {
|
||||
IItemHandler itemHandler = ((IContainerCraftingPacket) containerCraftingTerm).getInventoryByName("crafting");
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||
itemList.addStorage(AEItemStack.fromItemStack(itemHandler.getStackInSlot(i)));
|
||||
}
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
|
||||
public boolean errored() {
|
||||
return this.errored;
|
||||
return errored;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,7 @@ import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.client.gui.AEGuiHandler;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerExpandedProcessingPatternTerm;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.*;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
@@ -86,8 +84,10 @@ public class JEIPlugin implements IModPlugin {
|
||||
|
||||
// Allow recipe transfer from JEI to crafting and pattern terminal
|
||||
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<>(ContainerExpandedProcessingPatternTerm.class), Constants.UNIVERSAL_RECIPE_TRANSFER_UID);
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandler<>(ContainerWirelessPatternTerminal.class), Constants.UNIVERSAL_RECIPE_TRANSFER_UID);
|
||||
|
||||
aeGuiHandler = new AEGuiHandler();
|
||||
registry.addAdvancedGuiHandlers(aeGuiHandler);
|
||||
|
||||
@@ -20,7 +20,9 @@ package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerPatternEncoder;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerWirelessCraftingTerminal;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.AELog;
|
||||
@@ -48,6 +50,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static appeng.helpers.ItemStackHelper.stackToNBT;
|
||||
|
||||
|
||||
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T> {
|
||||
|
||||
@@ -72,7 +76,7 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
}
|
||||
|
||||
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);
|
||||
if (error.errored())
|
||||
return error;
|
||||
@@ -80,9 +84,9 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
return null;
|
||||
}
|
||||
|
||||
if (container instanceof ContainerPatternTerm) {
|
||||
if (container instanceof ContainerPatternEncoder) {
|
||||
try {
|
||||
if (!((ContainerPatternTerm) container).isCraftingMode()) {
|
||||
if (!((ContainerPatternEncoder) container).isCraftingMode()) {
|
||||
if (recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) {
|
||||
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", "1"));
|
||||
}
|
||||
@@ -108,8 +112,7 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
if (!ingredient.isInput()) {
|
||||
ItemStack output = ingredient.getDisplayedIngredient();
|
||||
if (output != null) {
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
output.writeToNBT(tag);
|
||||
final NBTTagCompound tag = stackToNBT(output);
|
||||
outputs.appendTag(tag);
|
||||
}
|
||||
continue;
|
||||
@@ -140,8 +143,7 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
}
|
||||
|
||||
for (final ItemStack is : list) {
|
||||
final NBTTagCompound tag = new NBTTagCompound();
|
||||
is.writeToNBT(tag);
|
||||
final NBTTagCompound tag = stackToNBT(is);
|
||||
tags.appendTag(tag);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package appeng.items.materials;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
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.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.IStackSrc;
|
||||
import appeng.core.features.MaterialStackSrc;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
@@ -51,6 +56,7 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -63,7 +69,7 @@ import java.util.regex.Matcher;
|
||||
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;
|
||||
|
||||
private static final int KILO_SCALAR = 1024;
|
||||
@@ -90,6 +96,17 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
|
||||
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);
|
||||
if (u != null) {
|
||||
final List<String> textList = new ArrayList<>();
|
||||
@@ -144,6 +161,10 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
|
||||
return Upgrades.CRAFTING;
|
||||
case CARD_PATTERN_EXPANSION:
|
||||
return Upgrades.PATTERN_EXPANSION;
|
||||
case CARD_MAGNET:
|
||||
return Upgrades.MAGNET;
|
||||
case CARD_QUANTUM_LINK:
|
||||
return Upgrades.QUANTUM_LINK;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -309,6 +330,36 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
|
||||
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 final Pattern pattern;
|
||||
|
||||
|
||||
@@ -118,7 +118,9 @@ public enum MaterialType {
|
||||
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)),
|
||||
|
||||
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)),
|
||||
CARD_MAGNET(60, "material_card_magnet", EnumSet.of(AEFeature.BASIC_CARDS));
|
||||
|
||||
|
||||
private final Set<AEFeature> features;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user