Compare commits

...

73 Commits

Author SHA1 Message Date
fscan 1e15b23506 Rework AEItemStack (#3091)
* Use itemstack as itemdef
* HIGH_TAG/LOW_TAG should be compared both directions
* Remove getTagCompound
* Make Itemlist implementation independent
* Cache item id for performance reasons
* Add preconditions to saveguard against external meddling
* Chache itemDamage
* Remove IAEStackSearchKey for now, rename getDisplayStack
2017-09-30 17:18:30 +02:00
yueh 2ed7a5598a Improved IGrinderRegistry (#3110)
* Improved IGrinderRegistry

Added a builder for grinder recipes similar to IInscriberRegistry.
Replaced different add methods with this builder.
IIinscriberRegistry#addRecipe and removeRecipe now return true on success.
2017-09-29 20:32:59 +02:00
yueh 1c05dd5834 Further improvments for the energygrid. (#3107)
* Further improvments for the enerygrid.

Simplified quartz fiber.
Removed different Actionable code paths and replaced with a unified
approach.
Dropped lastProvider/Requester, it simply iterates over all, but still
drops them when necessary.
2017-09-29 20:32:20 +02:00
Florian Scandella 632d124359 Fix ArithmeticException in PartP2PFEPower 2017-09-26 22:14:04 +02:00
yueh 829c18e2bb Make UVLLoader a bit more robust (#3102)
Catch all parsing exceptions instead of propagating them upwards as
these are meaningless for the actual test.
Renamed uvlMarker to ae2_uvl_marker just in case some other mod uses the
same key.
2017-09-21 20:42:23 +02:00
yueh d3a5be7ed6 Fixes #3105: Dupe bug due to forge default itemhandler implementation. (#3106) 2017-09-21 20:41:30 +02:00
Florian Scandella 217cbf0982 we dont use scala ... 2017-09-17 13:38:44 +02:00
fscan 4dd0a4cd96 Improve terminal search box (#3064)
Uses exsting JEI filter in JEI mode.
Preselects text for easy delete/change without using rightclick.
QoL improvements for focus handling.
2017-09-16 17:44:16 +02:00
Florian Scandella 54c0ce43ea fix fluid p2p voiding excess liquids 2017-09-14 18:38:29 +02:00
yueh bd8f43acbf Updated to forge 1.12.1 RB. (#3087)
Updated related deps.
2017-09-12 13:23:17 +02:00
yueh 970630a90d Refactored the BaseActionSource (#3063)
* Refactored the BaseActionSource

It now uses an interface `IActionSource` instead of a concrete class and further
subclasses. 

Instead of relying on a specific class for a certain action type, it now
uses methods with Optional as return values to determine a player or
machine issuing an action. Refer to the JavaDocs for the exact behaviour.

* `IActionHost` no longer extends `IGridHost`

It never used the additional functionality and if needed the `IGridNode`
will also provide a reference to the corresponding `IGridHost`.

Due to most crafting related GUIs being hardcoded to `IGridHost`, 
they no longer work when `IActionHost` is not extending it. Actually
`IActionHost` is the better solution for it, as it prevents us from looking
the grid up via the `IGridHost` and potentially finding a wrong grid.

* Interfaces now only lock the currently worked slot.

This allows `DualityInterface#onChangeInventory` to update slots of the same interface, should they be the source for a requested item and therefore updating their working set accordingly to queue further crafting requests for unfulfilled stack requirements.
2017-09-12 11:39:00 +02:00
yueh 771a944058 Fixes #3081: Fixes blocking mode blocking on empty inventory. (#3082) 2017-09-11 12:03:32 +02:00
Florian Scandella db1cd8c312 Cache the STORAGE_MONITORABLE_ACCESSOR Capability to reduce the amount of MENetworkCellArrayUpdates 2017-09-09 13:04:21 +02:00
fscan 375e1efb15 We don't need the showCraftingLabel flag, as IAEStack is perfectly fine with 0 size stacks. (#3071)
Adjust rendering code to use ItemStack with size 1 where required.
2017-09-09 12:58:22 +02:00
yueh 955fcac92a Correctly handle the grid power storage during onJoin/onSplit. 2017-09-03 13:40:30 +02:00
Florian Scandella 216e2cb1e3 Fix matter condenser input slot 2017-09-03 04:45:17 +02:00
Florian Scandella 53f5724657 Set stack size to 1 for rendering 2017-09-02 01:06:25 +02:00
Florian Scandella a3269826f9 cleanup inventory change handling 2017-08-31 14:01:46 +02:00
Florian Scandella 1a918be658 only calculate difference when it's the same item 2017-08-29 22:52:59 +02:00
Florian Scandella 90130e72aa call saveChanges when inventory changes. 2017-08-29 22:52:06 +02:00
Florian Scandella c8f10d92bb use index not slotNumber 2017-08-29 21:20:18 +02:00
fscan 548af3c6cc Use standard inheritance to propagage NBT events (#3058)
* Remove the old annotation system
* Use TileEntity#onLoad instead of onChunkLoad event
* Do not call invalidate in onChunkUnload and validate in onLoad
2017-08-28 09:34:09 +02:00
yueh 98b9380494 Fixes machines not extracting power from the local grid.
There is currently no difference between an external grid and the local
machines trying to extract power from the grid. Thus preventing any
external grid from stealing power also does prevent machines from
extracting, if there is no other provider available.

Also a small change to use a priorityqueue with the lowest percentage
stored first. This can better utilize the upper limit by reaching it
faster and exiting earlier.
2017-08-27 15:01:07 +02:00
fscan bbf4d4a9ce Spatial rework (#3048)
* Moved all spatial cells into a single dimension instead of one dimension per cell

Each cell will now be backed by a single region file each. So  backups and restores can still be done on a per cell level.

Old cells will not be migrated.

* Moved custom cell tracking to a capability based one on the world

The size and owner of a cell is now stored inside the capabilities of the world/dimension not a custom system and we can rely on forge handling the persistence of it.

* Added the cell id to the actual item tooltip, as this is now a real identifier and not an arbitrary dimension id.

* Added vanilla banners to the whitelist

* Added unittests to the dimension manager to ensure the algorithm mapping to the correct region file

* Updated the API to conform with the new dimenion/types/biomes registration and mappings

* Fixed a couple of bugs related to world/dimension/biome registration 

* Fixed a bug when transfering certain blocks due to passing missing/incorrect blockstate
2017-08-24 11:24:33 +02:00
yueh 1513ba3f6a Performance improvements for the energygrid (#3051)
* Performance improvements for the energygrid

Reworked the old recursive approach to a queue based loop.
Extract will try to prefer the next grid with the hightest amount of
stored energy.
Inject will try to prefer the grid with the lowest percentage stored.
Other operations are first come, first serve.

* Added a local buffer storage to EnergyGrid

This replaces the old not really working buffer with a special
IAEPowerStorage acting as buffer/proxy for the local energy demand as
well as temporary overflow should something provide more energy than
requested.

Currently it set to hold a maximum of 200 AE (+ optional overflow until
consumed). It will only be used locally, no other grid can use it to
avoid starving the neighbor grids before finding a energy cell.

* Fixes IExternalPowerSink

All implementations currently depend on the network demand being a valid
source, which might not be true.

Further it can cause the sink to iterate the network twice (demand and
inject) and both again for simulate and modulate.

Also it did not return the actual leftover amount instead of relying on
the demand matching it.

* Minor fixes related to removing nodes from a grid.

The grid did remove IStackWatcherHost not IEnergyWatcherHost, this was
fine for AE2 as only level emitters use it and they implement both.
But not for potential addons.

Also they would potentually not being removed as the are indexed by the
gridnodes not the machine.

Fixes #1004
2017-08-24 11:06:31 +02:00
yueh f03f8ec432 Remove RF dependency 2017-08-22 11:07:00 +02:00
Florian Scandella e1dcd588b7 add particle texture to charged quartz 2017-08-21 20:11:20 +02:00
fscan 8338a7d13e Fixes #3049: JEI recipe transfer can voiding items (#3053) 2017-08-21 14:39:29 +02:00
yueh b8e685b1b6 Fixes #3040: Cache recipe and revalidate it (#3042)
* Fixes #3040: Cache recipe and revalidate it

This caches the last used recipe instead of only the result. Which
allows to revalidate the crafting grid against the recipe itself before
hitting the CraftingManager again. Therefore avoiding a high performance
hit for recipe lookups, just find the potential same recipe again.

* Remove old recipe lookup as forge provides it now.

* Further optimizations.

These are a bit quick'n'dirty and need a better solution with a full
container/gui refactoring. But for now they provide some great benefits
in terms of performance.
2017-08-20 21:31:30 +02:00
yueh d84500c5b7 Fixes FE P2P tunnel drain issues
Only queue drain on modulate, also queue it for extracting from the
input side.
2017-08-20 14:35:31 +02:00
yueh a1679c944b Added SCS size to the Spatial IO Port. (#3045)
Uses the same format as the cells display in their tooltip for easy comparison.
2017-08-20 13:14:27 +02:00
fscan a3a39201d1 Missed vibration chamber when fixing the others. (#3050) 2017-08-19 21:31:16 +02:00
Emanuele Torre d788da687e Update it_it.lang (#3041) 2017-08-18 10:31:15 +02:00
yueh 030e0c6a14 Updated gradle.properties for deploying to multiple minecraft versions 2017-08-18 00:47:31 +02:00
fscan 8e4265aa33 P2P Tunnel improvements (#3039)
* Fix P2P Tunnels randomly resetting to ME
* Allow one way push and pull. Outputs can pull from the input side, input can push into outputs.
2017-08-18 00:44:19 +02:00
Gunther De Wachter 80eaa032b9 Fixes #3011: placing the last part in off-hand clearing main hand as well 2017-08-17 22:19:50 +02:00
yueh bee9c70497 Added 1.12.1 as accepted version. 2017-08-17 21:17:55 +02:00
yueh c4fa21c193 Removes coremod (#3038)
From now on every integration must not rely on method stripping through
a coremod or @Optional. Notable example for a very good solution is IC2.

As consequence this drops all support for RF and mods must support on of
our supported energy types. At the time of writing, ForgeEnergy and
IC2/EU.
2017-08-17 21:16:57 +02:00
Gunther De Wachter 8a7450168b Updated JEI plugin to newer API methods. 2017-08-17 20:41:20 +02:00
Gunther De Wachter 7cb641cdc8 Fix shift clicking memory card still triggering off-hand item/block usage. 2017-08-17 20:41:20 +02:00
Gunther De Wachter b5b8050c4c Added workaround for sorting items on amount with fake amount when showing crafting label 2017-08-17 20:41:20 +02:00
Gunther De Wachter e65083b045 Fixed dropping items on the ground when clicking on a crafting label with items in hand 2017-08-17 20:41:20 +02:00
yueh b61219ef88 Covered dense cables (#3030)
* Renamed all dense smart cable related things to include smart
* Added dense covered cables
* Added abstract PartDenseCable to reduce redundant code
* Added dense covered recipes

* Ensures ItemPart ordering to be consitent.

Now takes the metadata into account to preserve the ordering for colored
items instead of just the part type name and depend on the insertion
order of a hashmap.
2017-08-17 18:41:39 +02:00
yueh 4f9fd1b369 IC2 rework to avoid a coremod or @Optional (#3034)
* IC2 rework to avoid a coremod or @Optional

Updated IC2 dependency

Refactored IC2 itemcharging to use an IBackupElectricManager.
Allows charging any ae powered item by using an IBackupElectricManager
instead of having to implement IElectricItem and stripping it by some
sort.

Updated IAEItemPowerStorage to use Actionable for an easier handling
with power APIs supporting a simulation.

Refactored EU P2P to avoid method stripping
Use a modified internal BasicSinkSource instead of implementing
IEnergySource and IEnergySink directly on the tunnel.

Removed the superfluous EU P2P layers.

* Removed internalBattery due to being too complex

* Creative Energy Cell is not a chargeable item
2017-08-17 17:35:34 +02:00
yueh 630fae3f73 Fixes #3024: Crash on recipe lookup for disabled features (#3026)
* Fixes #3024: Crash on recipe lookup for disabled features

Adds a new recipe condition for a single AEFeature or a list of them.
Moved the factories to their own package, in preparation of phasing out
the old recipe handling.
2017-08-17 17:17:26 +02:00
yueh 488ef1b544 Fixes recipes to use correct ingredients
Fluix Pearls instead of Fluix Crystals for spatial related items.
Fluix cables for most items, not any cable to avoid loops or unwanted
crafting steps.
2017-08-17 15:12:34 +02:00
fscan 098ee2f000 Making charged certus ore glow again (#3035) 2017-08-17 11:01:31 +02:00
fscan 04d2b06c0d Ignore MOVE_REGION when clicking on crafting slots (#3032)
Exclude crafting slots from list of slots to move on space click.

Fixes #3031
2017-08-15 15:07:42 +02:00
fscan ac48ab02fc Fix crash in clearStack (#3033) 2017-08-15 15:05:12 +02:00
fscan 9022150e38 Fill existing stacks first when adding to player inventory. (#3025) 2017-08-14 11:03:53 +02:00
yueh 65c6d2249a Fixes encoding issues with spatial cell names 2017-08-13 19:02:03 +02:00
yueh 8e7f79a9ea Ensure gradle uses UTF-8 2017-08-12 16:35:38 +02:00
fscan 95b48b9438 Registration rework (#3018)
Refactored component registration.

Fixes #3008: crank rendering
2017-08-12 15:02:50 +02:00
yueh cdd76b7b22 Added helpers for hex and color output. (#3027) 2017-08-12 14:52:31 +02:00
fscan 3e2bc0e038 Inscriber improvements and fixes (#3028) 2017-08-12 14:52:01 +02:00
yueh eec3e59eea Add missing annotations 2017-08-11 21:44:30 +02:00
yueh e39855b48f Use qualified method and field access 2017-08-11 21:43:47 +02:00
yueh cdcab7d91c Organise Imports 2017-08-11 21:42:26 +02:00
yueh 27ad2c2b96 Code format 2017-08-11 21:41:51 +02:00
yueh 542a2e5d5a Fixes NPE due to using wrong field. 2017-08-11 21:33:57 +02:00
fscan 3b58f5e8da fix me io port (#3019) 2017-08-09 10:39:07 +02:00
fscan 092afad4a5 Correctly detect redstone updates on all sides. (#3017) 2017-08-09 10:30:44 +02:00
Gunther De Wachter 6aa810d62a Re-add a missing piece of IC2 integration code.
This should fix a bunch of IC2 spam in the console and allow items to be charged in IC2 blocks.
2017-08-07 10:15:26 +02:00
Gunther De Wachter 41d98f9944 Fixed ME Chest visually not updating its cell state 2017-08-05 11:43:57 +02:00
Gunther De Wachter 1b198979fd Fixed export bus never speeding up. 2017-08-05 10:45:13 +02:00
tyra 8d5cc916e0 Adds improved tooltip to invalid encodedPattern (#2992)
* Adds improved tooltip to invalid encodedPattern

This also fixes that encodedPattern might be shown as valid,
even though one or more input or output item is missing.
2017-08-04 21:17:35 +02:00
Gunther De Wachter 5abb8bf886 Removed call to super in Crafting Terminal initialisation code. Fixes #2988 2017-08-04 20:28:11 +02:00
Gunther De Wachter 0bed78a144 Re-enabled JEI search integration in terminals. 2017-08-03 22:00:42 +02:00
fscan 30940e91ea InterfaceTerminal: Put into to cursor, not player hand (#2996) 2017-07-31 17:16:56 +02:00
fscan 0f9ac5fdda Fix Inscriber and Molecular Assembler (#2995)
* Fix inscriber
* Allow GUI extraction for Molecular Assembler
2017-07-31 16:06:39 +02:00
fscan 5e001d86cb Move model loading to the correct event. Fixes #2991 (#2994)
* Use the correct event for loading models.
* Introduce IModelRegistry to wrap the ModelLoader
2017-07-31 15:51:53 +02:00
fscan b13a338948 Fix/Remove storage/import/export bus IItemHandler caching (#2987)
* Fix storage/import/export bus IItemHandler caching
2017-07-31 15:51:01 +02:00
yueh 454404b0c1 Changed ItemGen to use IItemHandler 2017-07-30 20:17:23 +02:00
539 changed files with 6595 additions and 7705 deletions
+6 -3
View File
@@ -45,6 +45,12 @@ apply from: 'gradle/scripts/optional.gradle'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// ensure everything uses UTF-8 and not some random codepage chosen by gradle
compileJava.options.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
version = aeversion + "-" + aechannel + "-" + aebuild
group = aegroup
archivesBaseName = aebasename
@@ -52,7 +58,6 @@ archivesBaseName = aebasename
// Add Coremod Manifest
jar {
manifest {
attributes 'FMLCorePluginContainsFMLMod': 'true'
attributes 'FMLAT': 'appeng_at.cfg'
}
@@ -68,8 +73,6 @@ jar {
}
minecraft {
coreMod = "appeng.coremod.AppEngCore"
version = minecraft_version + "-" + forge_version
replaceIn "AEConfig.java"
+13 -8
View File
@@ -7,20 +7,25 @@ aebasename=appliedenergistics2
#########################################################
# Versions #
#########################################################
minecraft_version=1.12
mcp_mappings=snapshot_20170704
forge_version=14.21.1.2412
minecraft_version=1.12.1
mcp_mappings=snapshot_20170811
forge_version=14.22.1.2478
#########################################################
# Installable #
#########################################################
hwyla_version=1.8.19-B33_1.12
hwyla_version=1.8.20-B35_1.12
#########################################################
# Provided APIs #
#########################################################
jei_version=4.7.1.69
jei_version=4.7.8.95
tesla_version=1.0.61
ic2_version=2.8.7-ex112
rf_version=2.0.0.1
top_version=1.12-1.4.8-2
ic2_version=2.8.19-ex112
top_version=1.12-1.4.18-10
#########################################################
# Deployment #
#########################################################
website_version=1.12.x
curse_versions=1.12,1.12.1
+1 -5
View File
@@ -69,18 +69,14 @@ dependencies {
mods "mcp.mobius.waila:Hwyla:${hwyla_version}"
mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev"
mods "mcjty.theoneprobe:TheOneProbe-${minecraft_version}:${top_version}"
// mods "com.github.mcjty:compatlayer:${compatlayer_version}"
// compile against provided APIs
compileOnly "mezz.jei:jei_${minecraft_version}:${jei_version}:api"
compileOnly "mcp.mobius.waila:Hwyla:${hwyla_version}"
compileOnly "net.darkhax.tesla:Tesla-${minecraft_version}:${tesla_version}"
compileOnly "net.darkhax.tesla:Tesla-1.12:${tesla_version}"
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
// deobfCompile "mcp.mobius.waila:Hwyla:${hwyla_version}"
deobfCompile "cofh:RedstoneFlux:${minecraft_version}-${rf_version}:universal"
// at runtime, use the full JEI jar
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
@@ -28,7 +28,6 @@ public enum TunnelType
{
ME, // Network Tunnel
IC2_POWER, // EU Tunnel
RF_POWER, // RF Tunnel
FE_POWER, // Forge Energy tunnel
REDSTONE, // Redstone Tunnel
FLUID, // Fluid Tunnel
@@ -38,7 +38,9 @@ public interface IParts
AEColoredItemDefinition cableGlass();
AEColoredItemDefinition cableDense();
AEColoredItemDefinition cableDenseCovered();
AEColoredItemDefinition cableDenseSmart();
AEColoredItemDefinition lumenCableSmart();
@@ -46,7 +48,7 @@ public interface IParts
AEColoredItemDefinition lumenCableGlass();
AEColoredItemDefinition lumenCableDense();
AEColoredItemDefinition lumenDenseCableSmart();
IItemDefinition quartzFiber();
@@ -80,8 +82,6 @@ public interface IParts
IItemDefinition p2PTunnelEU();
IItemDefinition p2PTunnelRF();
IItemDefinition p2PTunnelFE();
IItemDefinition p2PTunnelLight();
@@ -0,0 +1,115 @@
/*
* 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.features;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
/**
* Builder for a grinder recipe.
*
* The only default value provided are turns at a value of 8.
*
* @author yueh
* @version rv5
* @since rv5
*/
public interface IGrinderRecipeBuilder
{
/**
* Creates an grinder recipe with inputs.
* Needs to be invoked.
*
* @param input new input for the recipe
*
* @return currently used builder
*/
@Nonnull
IGrinderRecipeBuilder withInput( @Nonnull ItemStack input );
/**
* Creates an grinder recipe with output.
* Needs to be invoked.
*
* @param output new output for the recipe
*
* @return currently used builder
*/
@Nonnull
IGrinderRecipeBuilder withOutput( @Nonnull ItemStack output );
/**
* Creates an grinder recipe with the first optional output and its chance.
*
* @param optional new first optional for the recipe
* @param chance chance for the first optional output, must be within 0.0 - 1.0
*
* @return currently used builder
*/
@Nonnull
IGrinderRecipeBuilder withFirstOptional( @Nonnull ItemStack optional, float chance );
/**
* Creates an grinder recipe with the second optional output and its chance.
*
* @param optional new second optional for the recipe
* @param chance chance for the second optional output, must be within 0.0 - 1.0
*
* @return currently used builder
*/
@Nonnull
IGrinderRecipeBuilder withSecondOptional( @Nonnull ItemStack optional, float chance );
/**
* Creates an grinder recipe with the amount of turns as cost.
*
* Defaults to 8 when not called.
*
* @param turns new turns for the recipe, must be > 0
*
* @return currently used builder
*/
@Nonnull
IGrinderRecipeBuilder withTurns( @Nonnegative int turns );
/**
* Finalizes the process of making the recipe.
* Needs to be invoked to fetch grinder recipe.
*
* @return valid grinder recipe
*
* @throws IllegalStateException when input is not defined
* @throws IllegalStateException when input has no size
* @throws IllegalStateException when output is not defined
* @throws IllegalStateException when both optionals are not defined
* @throws IllegalStateException when process type is not defined
*/
@Nonnull
IGrinderRecipe build();
}
@@ -38,6 +38,14 @@ import net.minecraft.item.ItemStack;
public interface IGrinderRegistry
{
/**
* Extensible way to create a grinder recipe.
*
* @return builder for grinder recipes
*/
@Nonnull
IGrinderRecipeBuilder builder();
/**
* An immutable list of the currently registered recipes.
*
@@ -47,48 +55,13 @@ public interface IGrinderRegistry
Collection<IGrinderRecipe> getRecipes();
/**
* Add a new recipe with a single input and output and how many turns it requires.
*
* Will ignore duplicate recipes with the same input item.
*
* @param in The {@link ItemStack} to grind.
* @param out The {@link ItemStack} to output.
* @param turns Amount of turns to turn the input into the output, with turns > 0.
* Add a new recipe to the registry.
*/
void addRecipe( @Nonnull ItemStack in, @Nonnull ItemStack out, int turns );
/**
* Add a new recipe with an input, output and a single optional output.
*
* Will ignore duplicate recipes with the same input item.
*
* @param in The {@link ItemStack} to grind.
* @param out The {@link ItemStack} to output.
* @param optional The optional {@link ItemStack} to output of a certain chance.
* @param chance Chance to get the optional output within 0.0 - 1.0
* @param turns Amount of turns to turn the input into the output, with turns > 0.
*/
void addRecipe( @Nonnull ItemStack in, @Nonnull ItemStack out, @Nonnull ItemStack optional, float chance, int turns );
/**
* add a new recipe with optional outputs, duplicates will not be added.
*
* Will ignore duplicate recipes with the same input item.
*
* @param in The {@link ItemStack} to grind.
* @param out The {@link ItemStack} to output.
* @param optional The first optional {@link ItemStack} to output of a certain chance.
* @param chance Chance to get the first optional output within 0.0 - 1.0
* @param optional2 The second optional {@link ItemStack} to output of a certain chance.
* @param chance2 chance to get the second optional output within 0.0 - 1.0
* @param turns Amount of turns to turn the input into the output, with turns > 0.
*
*/
void addRecipe( @Nonnull ItemStack in, @Nonnull ItemStack out, @Nonnull ItemStack optional, float chance, @Nonnull ItemStack optional2, float chance2, int turns );
boolean addRecipe( IGrinderRecipe recipe );
/**
* Remove the specific from the recipe list.
*
*
* @param recipe The recipe to be removed.
* @return true, if it was removed
*/
@@ -106,11 +79,11 @@ public interface IGrinderRegistry
/**
* Allows do add a custom ratio from an ore to dust when being grinded.
*
*
* The default ratio is 1 ore to 2 dusts.
*
*
* These have to be added before any recipe is registered. Otherwise it will use the default value.
*
*
* @param oredictName The name of the ore;
* @param ratio The amount, must be > 0;
*/
@@ -118,9 +91,9 @@ public interface IGrinderRegistry
/**
* Remove a custom ratio for a specific ore name.
*
*
* Will use the default of 2 value afterwards.
*
*
* @param oredictName The name of the ore;
*/
boolean removeDustRatio( @Nonnull String oredictName );
@@ -31,11 +31,19 @@ import net.minecraft.item.ItemStack;
* Lets you manipulate Inscriber Recipes, by adding or editing existing ones.
*
* @author thatsIch
* @version rv3
* @version rv5
* @since rv2
*/
public interface IInscriberRegistry
{
/**
* Extensible way to create an inscriber recipe.
*
* @return builder for inscriber recipes
*/
@Nonnull
IInscriberRecipeBuilder builder();
/**
* An immutable copy of currently registered recipes.
*
@@ -65,29 +73,25 @@ public interface IInscriberRegistry
@Nonnull
Set<ItemStack> getInputs();
/**
* Extensible way to create an inscriber recipe.
*
* @return builder for inscriber recipes
*/
@Nonnull
IInscriberRecipeBuilder builder();
/**
* add a new recipe the easy way, duplicates will not be added.
* Added recipes will be automatically added to the optionals and inputs.
*
* @param recipe new recipe
*
* @return true, when successfully added
*
* @throws IllegalArgumentException if null is added
*/
void addRecipe( IInscriberRecipe recipe );
boolean addRecipe( IInscriberRecipe recipe );
/**
* Removes all equal recipes from the registry.
*
*
* @param toBeRemovedRecipe to be removed recipe, can be null, makes just no sense.
*
* @return true, when successfully removed
*/
void removeRecipe( IInscriberRecipe toBeRemovedRecipe );
boolean removeRecipe( IInscriberRecipe toBeRemovedRecipe );
}
@@ -27,6 +27,7 @@ package appeng.api.implementations.items;
import net.minecraft.item.ItemStack;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.energy.IAEPowerStorage;
@@ -42,27 +43,27 @@ public interface IAEItemPowerStorage
*
* @return amount unable to be stored
*/
double injectAEPower( ItemStack is, double amt );
double injectAEPower( ItemStack stack, double amount, Actionable mode );
/**
* Attempt to extract power from the device, it will extract what it can and
* return it.
*
* @param amt to be extracted power from device
* @param amount to be extracted power from device
*
* @return what it could extract
*/
double extractAEPower( ItemStack is, double amt );
double extractAEPower( ItemStack stack, double amount, Actionable mode );
/**
* @return the current maximum power ( this can change :P )
*/
double getAEMaxPower( ItemStack is );
double getAEMaxPower( ItemStack stack );
/**
* @return the current AE Power Level, this may exceed getMEMaxPower()
*/
double getAECurrentPower( ItemStack is );
double getAECurrentPower( ItemStack stack );
/**
* Control the power flow by telling what the network can do, either add? or
@@ -70,5 +71,5 @@ public interface IAEItemPowerStorage
*
* @return access restriction of network
*/
AccessRestriction getPowerFlow( ItemStack is );
AccessRestriction getPowerFlow( ItemStack stack );
}
@@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.implementations.TransitionResult;
import appeng.api.storage.ISpatialDimension;
import appeng.api.util.WorldCoord;
@@ -57,7 +58,7 @@ public interface ISpatialStorageCell
*
* @return the world for this cell
*/
World getWorld( ItemStack is );
ISpatialDimension getSpatialDimension();
/**
* get the currently stored size.
@@ -69,22 +70,13 @@ public interface ISpatialStorageCell
WorldCoord getStoredSize( ItemStack is );
/**
* Minimum coordinates in its world for the storage cell.
* get the currently stored Dimension id.
*
* @param is spatial storage cell
*
* @return minimum coordinate of dimension
* @return dimension id or -1
*/
WorldCoord getMin( ItemStack is );
/**
* Maximum coordinates in its world for the storage cell.
*
* @param is spatial storage cell
*
* @return maximum coordinate of dimension
*/
WorldCoord getMax( ItemStack is );
int getStoredDimensionID( ItemStack is );
/**
* Perform a spatial swap with the contents of the cell, and the world.
@@ -93,9 +85,9 @@ public interface ISpatialStorageCell
* @param w world of spatial
* @param min min coord
* @param max max coord
* @param doTransition transition
* @param playerId owner of current grid or -1
*
* @return result of transition
*/
TransitionResult doSpatialTransition( ItemStack is, World w, WorldCoord min, WorldCoord max, boolean doTransition );
TransitionResult doSpatialTransition( ItemStack is, World w, WorldCoord min, WorldCoord max, int playerId );
}
@@ -24,7 +24,7 @@
package appeng.api.networking.crafting;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.data.IAEItemStack;
@@ -40,7 +40,7 @@ public interface ICraftingCPU extends IBaseMonitor<IAEItemStack>
/**
* @return the action source for the CPU.
*/
BaseActionSource getActionSource();
IActionSource getActionSource();
/**
* @return the available storage in bytes
@@ -33,7 +33,7 @@ import net.minecraft.world.World;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridCache;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEItemStack;
@@ -63,7 +63,7 @@ public interface ICraftingGrid extends IGridCache
* @return a future which will at an undetermined point in the future get you the {@link ICraftingJob} do not wait
* on this, your be waiting forever.
*/
Future<ICraftingJob> beginCraftingJob( World world, IGrid grid, BaseActionSource actionSrc, IAEItemStack craftWhat, ICraftingCallback callback );
Future<ICraftingJob> beginCraftingJob( World world, IGrid grid, IActionSource actionSrc, IAEItemStack craftWhat, ICraftingCallback callback );
/**
* Submit the job to the Crafting system for processing.
@@ -82,7 +82,7 @@ public interface ICraftingGrid extends IGridCache
* {@link ICraftingRequester} methods. if you send null, this object should be discarded after verifying the
* return state.
*/
ICraftingLink submitJob( ICraftingJob job, ICraftingRequester requestingMachine, ICraftingCPU target, boolean prioritizePower, BaseActionSource src );
ICraftingLink submitJob( ICraftingJob job, ICraftingRequester requestingMachine, ICraftingCPU target, boolean prioritizePower, IActionSource src );
/**
* @return list of all the crafting cpus on the grid
@@ -24,7 +24,10 @@
package appeng.api.networking.energy;
import java.util.Set;
import java.util.Collection;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import appeng.api.config.Actionable;
@@ -35,17 +38,91 @@ import appeng.api.config.Actionable;
public interface IEnergyGridProvider
{
/**
* internal use only
*
* Can return a list of providers behind the current.
*
* An example would be something acting as proxy between different {@link IEnergyGrid}s.
*
* This can contain duplicate entries, AE will ensure that each provider is only visited once.
*
* internal use only
*/
double extractAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen );
@Nonnull
Collection<IEnergyGridProvider> providers();
/**
* internal use only
*
* Extracts the requested amount from the provider.
*
* This should never forward a call to another {@link IEnergyGridProvider}, instead return them via
* {@link IEnergyGridProvider#providers()}
*
* @return the used amount
*/
double injectAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen );
@Nonnegative
double extractProviderPower( @Nonnegative double amt, @Nonnull Actionable mode );
/**
* Injects the offered amount into the provider.
*
* This should never forward a call to another {@link IEnergyGridProvider}, instead return them via
* {@link IEnergyGridProvider#providers()}
*
* internal use only
*
* @return the leftover amount
*/
@Nonnegative
double injectProviderPower( @Nonnegative double amt, @Nonnull Actionable mode );
/**
* internal use only
*
* Returns the current demand of an provider.
*
* This should never forward a call to another {@link IEnergyGridProvider}, instead return them via
* {@link IEnergyGridProvider#providers()}
*
*
* @param d the max amount offered, the demand should never exceed it.
* @return the total amount demanded
*/
double getEnergyDemand( double d, Set<IEnergyGrid> seen );
@Nonnegative
double getProviderEnergyDemand( @Nonnegative double d );
/**
* internal use only
*
* AE currently uses this to enqueue the next visited provider.
*
* There is no guarantee that this works on in a perfect way.
* It can be limited to the returns of the past {@link IEnergyGridProvider#providers()}, but not any future one
* discovered by visiting further providers.
*
* E.g. inject into the the lowest one first or extract from the highest one.
*
* @return the current stored amount.
*
*
*/
@Nonnegative
double getProviderStoredEnergy();
/**
* internal use only
*
* AE currently uses this to enqueue the next visited provider.
*
* There is no guarantee that this works on in a perfect way.
* It can be limited to the returns of the past {@link IEnergyGridProvider#providers()}, but not any future one
* discovered by visiting further providers.
*
* E.g. inject into the the lowest one first or extract from the highest one.
*
* @return the maximum amount stored.
*/
@Nonnegative
double getProviderMaxEnergy();
}
@@ -1,41 +0,0 @@
/*
* 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.networking.security;
/**
* TODO: Consider refactoring.
*/
public class BaseActionSource
{
public boolean isPlayer()
{
return false;
}
public boolean isMachine()
{
return false;
}
}
@@ -24,11 +24,10 @@
package appeng.api.networking.security;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
public interface IActionHost extends IGridHost
public interface IActionHost
{
/**
@@ -0,0 +1,77 @@
/*
* 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.networking.security;
import java.util.Optional;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
/**
* The source of any action.
*
* This can either be a {@link EntityPlayer} or an {@link IActionHost}.
*
* In most cases this is used for security checks, but can be used to validate the source itself.
*
*/
public interface IActionSource
{
/**
* If present, AE will consider the player being the source for the action.
*
* This will take precedence over {@link IActionSource#machine()} in any case.
*
* @return An optional player issuing the action.
*/
@Nonnull
Optional<EntityPlayer> player();
/**
* If present, it indicates the {@link IActionHost} of the source.
*
* Should {@link IActionSource#player()} be absent, it will consider a machine as source.
*
* It is recommended to include the machine even when a player is present.
*
* @return An optional machine issuing the action or acting as proxy for a player.
*/
@Nonnull
Optional<IActionHost> machine();
/**
* An {@link IActionSource} can have multiple optional contexts.
*
* It is strongly recommended to limit the uses for absolutely necessary cases.
*
* Currently there are no public contexts made available by AE.
* An example would be the context interfaces use internally to avoid looping items between each other.
*/
@Nonnull
<T> Optional<T> context( @Nonnull Class<T> key );
}
@@ -1,44 +0,0 @@
/*
* 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.networking.security;
/**
* TODO: Consider refactoring.
*/
public class MachineSource extends BaseActionSource
{
public final IActionHost via;
public MachineSource( final IActionHost v )
{
this.via = v;
}
@Override
public boolean isMachine()
{
return true;
}
}
@@ -24,7 +24,7 @@
package appeng.api.networking.storage;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
@@ -50,5 +50,5 @@ public interface IStackWatcherHost
* @param src action source
* @param chan storage channel
*/
void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan );
void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, StorageChannel chan );
}
@@ -26,7 +26,7 @@ package appeng.api.networking.storage;
import appeng.api.networking.IGridCache;
import appeng.api.networking.IGridHost;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ICellContainer;
import appeng.api.storage.ICellProvider;
import appeng.api.storage.IStorageMonitorable;
@@ -50,7 +50,7 @@ public interface IStorageGrid extends IGridCache, IStorageMonitorable
*
* @param input injected items
*/
void postAlterationOfStoredItems( StorageChannel chan, Iterable<? extends IAEStack> input, BaseActionSource src );
void postAlterationOfStoredItems( StorageChannel chan, Iterable<? extends IAEStack> input, IActionSource src );
/**
* Used to add a cell provider to the storage system
@@ -25,7 +25,7 @@ package appeng.api.storage;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
@@ -52,7 +52,7 @@ public interface IMEInventory<StackType extends IAEStack>
*
* @return returns the number of items not added.
*/
StackType injectItems( StackType input, Actionable type, BaseActionSource src );
StackType injectItems( StackType input, Actionable type, IActionSource src );
/**
* Extract the specified item from the ME Inventory
@@ -62,7 +62,7 @@ public interface IMEInventory<StackType extends IAEStack>
*
* @return returns the number of items extracted, null
*/
StackType extractItems( StackType request, Actionable mode, BaseActionSource src );
StackType extractItems( StackType request, Actionable mode, IActionSource src );
/**
* request a full report of all available items, storage.
@@ -24,7 +24,7 @@
package appeng.api.storage;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.data.IAEStack;
@@ -46,7 +46,7 @@ public interface IMEMonitorHandlerReceiver<StackType extends IAEStack>
*
* @param change done change
*/
void postChange( IBaseMonitor<StackType> monitor, Iterable<StackType> change, BaseActionSource actionSource );
void postChange( IBaseMonitor<StackType> monitor, Iterable<StackType> change, IActionSource actionSource );
/**
* called when the list updates its contents, this is mostly for handling power events.
@@ -16,19 +16,26 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.abstraction;
package appeng.api.storage;
import appeng.integration.IIntegrationModule;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
* @author GuntherDW
*/
public interface IRF
public interface ISpatialDimension
{
class Stub extends IIntegrationModule.Stub implements IRF
{
World getWorld();
}
int createNewCellDimension( BlockPos contentSize, int playerId );
void deleteCellDimension( int cellDimId );
boolean isCellDimension( int cellDimID );
int getCellDimensionOwner( int cellDimId );
BlockPos getCellDimensionOrigin( int cellDimId );
BlockPos getCellContentSize( int cellDimId );
}
@@ -35,7 +35,7 @@ import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
@@ -109,7 +109,7 @@ public interface IStorageHelper
*
* @return items that successfully extracted.
*/
IAEItemStack poweredExtraction( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, BaseActionSource src );
IAEItemStack poweredExtraction( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, IActionSource src );
/**
* use energy from energy, to inject input items into cell, at the request of src
@@ -121,5 +121,5 @@ public interface IStorageHelper
*
* @return items that failed to insert.
*/
IAEItemStack poweredInsert( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, BaseActionSource src );
IAEItemStack poweredInsert( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, IActionSource src );
}
@@ -4,7 +4,7 @@ package appeng.api.storage;
import javax.annotation.Nullable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
/**
@@ -22,5 +22,5 @@ public interface IStorageMonitorableAccessor
* @return Null if the network cannot be accessed by the given action source (i.e. security doesn't permit it).
*/
@Nullable
IStorageMonitorable getInventory( BaseActionSource src );
IStorageMonitorable getInventory( IActionSource src );
}
@@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableList;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
@@ -81,7 +81,7 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
}
@Override
public StackType injectItems( final StackType input, final Actionable mode, final BaseActionSource src )
public StackType injectItems( final StackType input, final Actionable mode, final IActionSource src )
{
if( mode == Actionable.SIMULATE )
{
@@ -95,7 +95,7 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
return this.internalHandler;
}
private StackType monitorDifference( final IAEStack original, final StackType leftOvers, final boolean extraction, final BaseActionSource src )
private StackType monitorDifference( final IAEStack original, final StackType leftOvers, final boolean extraction, final IActionSource src )
{
final StackType diff = (StackType) original.copy();
@@ -116,12 +116,12 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
return leftOvers;
}
protected void postChangesToListeners( final Iterable<StackType> changes, final BaseActionSource src )
protected void postChangesToListeners( final Iterable<StackType> changes, final IActionSource src )
{
this.notifyListenersOfChange( changes, src );
}
protected void notifyListenersOfChange( final Iterable<StackType> diff, final BaseActionSource src )
protected void notifyListenersOfChange( final Iterable<StackType> diff, final IActionSource src )
{
this.hasChanged = true;// need to update the cache.
final Iterator<Entry<IMEMonitorHandlerReceiver<StackType>, Object>> i = this.getListeners();
@@ -146,7 +146,7 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
}
@Override
public StackType extractItems( final StackType request, final Actionable mode, final BaseActionSource src )
public StackType extractItems( final StackType request, final Actionable mode, final IActionSource src )
{
if( mode == Actionable.SIMULATE )
{
@@ -46,7 +46,7 @@ public interface IAEItemStack extends IAEStack<IAEItemStack>
*
* @return new ItemStack
*/
ItemStack getItemStack();
ItemStack createItemStack();
/**
* is there NBT Data for this item?
@@ -105,4 +105,11 @@ public interface IAEItemStack extends IAEStack<IAEItemStack>
* @return true if it is the same type (same item, damage, nbt)
*/
boolean isSameType( ItemStack stored );
/**
* DO NOT MODIFY THIS STACK! NEVER. If you think about it .. DON'T
*
* @return definition stack
*/
ItemStack getDefinition();
}
@@ -28,13 +28,14 @@ import java.io.IOException;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.StorageChannel;
public interface IAEStack<StackType extends IAEStack>
public interface IAEStack<StackType extends IAEStack<StackType>>
{
/**
@@ -182,13 +183,6 @@ public interface IAEStack<StackType extends IAEStack>
*/
StackType empty();
/**
* obtain the NBT Data for the item.
*
* @return nbt data
*/
IAETagCompound getTagCompound();
/**
* @return true if the stack is a {@link IAEItemStack}
*/
@@ -205,13 +199,9 @@ public interface IAEStack<StackType extends IAEStack>
StorageChannel getChannel();
/**
* @return true if it should show the crafting label.
* Returns itemstack for display and similar purposes. Always has a count of 1.
*
* @return itemstack
*/
boolean getShowCraftingLabel();
/**
* Used internally to show that it should show a Crafting label instead of a "1"
*/
void setShowCraftingLabel( boolean showCraftingLabel );
ItemStack asItemStackRepresentation();
}
@@ -1,59 +0,0 @@
/*
* 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.storage.data;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.features.IItemComparison;
/**
* Don't cast this... either compare with it, or copy it.
*
* Don't Implement.
*/
public interface IAETagCompound
{
/**
* @return a copy ( the copy will not be a IAETagCompound, it will be a NBTTagCompound )
*/
NBTTagCompound getNBTTagCompoundCopy();
/**
* compare to other NBTTagCompounds or IAETagCompounds
*
* @param a compared object
*
* @return true, if they are the same.
*/
@Override
boolean equals( Object a );
/**
* @return the special comparison for this tag
*/
IItemComparison getSpecialComparison();
}
@@ -46,6 +46,11 @@ public enum AECableType
*/
SMART,
/**
* Smart Dense Cable, represents a tier 2 block that can carry 32 channels.
*/
DENSE_COVERED,
/**
* Smart Dense Cable, represents a tier 2 block that can carry 32 channels.
*/
@@ -55,6 +60,7 @@ public enum AECableType
GLASS,
COVERED,
SMART,
DENSE_COVERED,
DENSE_SMART
};
@@ -31,6 +31,7 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.implementations.items.IAEItemPowerStorage;
@@ -66,67 +67,39 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
.gui_localize( PowerUnits.AE.unlocalizedName ) + " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) );
}
private double getMaxEnergyCapacity()
@Override
public double injectAEPower( final ItemStack is, double amount, Actionable mode )
{
final Block blockID = Block.getBlockFromItem( this );
final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
return energyCell.maybeBlock().map( block ->
final double internalCurrentPower = this.getInternal( is );
final double internalMaxPower = this.getAEMaxPower( is );
final double required = internalMaxPower - internalCurrentPower;
final double overflow = Math.max( 0, amount - required );
if( mode == Actionable.MODULATE )
{
if( blockID == block )
{
return 200000;
}
else
{
return 8 * 200000;
}
} ).orElse( 0 );
final double toAdd = Math.min( required, amount );
final double newPowerStored = internalCurrentPower + toAdd;
this.setInternal( is, newPowerStored );
}
return overflow;
}
@Override
public double injectAEPower( final ItemStack is, double amt )
public double extractAEPower( final ItemStack is, double amount, Actionable mode )
{
double internalCurrentPower = this.getInternal( is );
final double internalMaxPower = this.getMaxEnergyCapacity();
internalCurrentPower += amt;
if( internalCurrentPower > internalMaxPower )
final double internalCurrentPower = this.getInternal( is );
final double fulfillable = Math.min( amount, internalCurrentPower );
if( mode == Actionable.MODULATE )
{
amt = internalCurrentPower - internalMaxPower;
internalCurrentPower = internalMaxPower;
this.setInternal( is, internalCurrentPower );
return amt;
final double newPowerStored = internalCurrentPower - fulfillable;
this.setInternal( is, newPowerStored );
}
this.setInternal( is, internalCurrentPower );
return 0;
}
private double getInternal( final ItemStack is )
{
final NBTTagCompound nbt = Platform.openNbtData( is );
return nbt.getDouble( "internalCurrentPower" );
}
private void setInternal( final ItemStack is, final double amt )
{
final NBTTagCompound nbt = Platform.openNbtData( is );
nbt.setDouble( "internalCurrentPower", amt );
}
@Override
public double extractAEPower( final ItemStack is, double amt )
{
double internalCurrentPower = this.getInternal( is );
if( internalCurrentPower > amt )
{
internalCurrentPower -= amt;
this.setInternal( is, internalCurrentPower );
return amt;
}
amt = internalCurrentPower;
this.setInternal( is, 0 );
return amt;
return fulfillable;
}
@Override
@@ -146,4 +119,34 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
{
return AccessRestriction.WRITE;
}
private double getMaxEnergyCapacity()
{
final Block blockID = Block.getBlockFromItem( this );
final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
return energyCell.maybeBlock().map( block ->
{
if( blockID == block )
{
return 200000;
}
else
{
return 8 * 200000;
}
} ).orElse( 0 );
}
private double getInternal( final ItemStack is )
{
final NBTTagCompound nbt = Platform.openNbtData( is );
return nbt.getDouble( "internalCurrentPower" );
}
private void setInternal( final ItemStack is, final double amt )
{
final NBTTagCompound nbt = Platform.openNbtData( is );
nbt.setDouble( "internalCurrentPower", amt );
}
}
@@ -101,6 +101,7 @@ public class BlockCableBus extends AEBaseTileBlock
// this will actually be overwritten later through setupTile and the
// combined layers
this.setTileEntity( TileCableBus.class );
this.useNeighborBrightness = true;
}
@Override
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -42,11 +42,13 @@ import appeng.api.definitions.IBlockDefinition;
import appeng.block.AEBaseBlock;
import appeng.block.AEBaseItemBlock;
import appeng.block.AEBaseTileBlock;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IPreInitComponent;
import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.CreativeTab;
import appeng.core.Registration;
import appeng.core.features.AEFeature;
import appeng.core.features.ActivityState;
import appeng.core.features.BlockDefinition;
@@ -65,13 +67,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
private final Supplier<? extends Block> blockSupplier;
private final List<BiConsumer<Block, Item>> preInitCallbacks = new ArrayList<>();
private final List<BiConsumer<Block, Item>> initCallbacks = new ArrayList<>();
private final List<BiConsumer<Block, Item>> modelRegCallbacks = new ArrayList<>();
private final List<BiConsumer<Block, Item>> postInitCallbacks = new ArrayList<>();
private final List<BiFunction<Block, Item, IBootstrapComponent>> bootstrapComponents = new ArrayList<>();
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class );
@@ -103,30 +99,9 @@ class BlockDefinitionBuilder implements IBlockBuilder
}
@Override
public BlockDefinitionBuilder preInit( BiConsumer<Block, Item> callback )
public BlockDefinitionBuilder bootstrap( BiFunction<Block, Item, IBootstrapComponent> callback )
{
this.preInitCallbacks.add( callback );
return this;
}
@Override
public BlockDefinitionBuilder init( BiConsumer<Block, Item> callback )
{
this.initCallbacks.add( callback );
return this;
}
@Override
public BlockDefinitionBuilder modelRegInit( BiConsumer<Block, Item> callback )
{
this.modelRegCallbacks.add( callback );
return this;
}
@Override
public BlockDefinitionBuilder postInit( BiConsumer<Block, Item> callback )
{
this.postInitCallbacks.add( callback );
this.bootstrapComponents.add( callback );
return this;
}
@@ -221,22 +196,16 @@ class BlockDefinitionBuilder implements IBlockBuilder
}
// Register the item and block with the game
this.factory.addPreInit( side ->
this.factory.addBootstrapComponent( (IBlockRegistrationComponent) ( side, registry ) -> registry.register( block ) );
if( item != null )
{
Registration.addBlockToRegister( block );
if( item != null )
{
Registration.addItemToRegister( item );
}
} );
this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, registry ) -> registry.register( item ) );
}
block.setCreativeTab( this.creativeTab );
// Register all extra handlers
this.preInitCallbacks.forEach( consumer -> this.factory.addPreInit( side -> consumer.accept( block, item ) ) );
this.initCallbacks.forEach( consumer -> this.factory.addInit( side -> consumer.accept( block, item ) ) );
this.modelRegCallbacks.forEach( consumer -> this.factory.addModelReg( side -> consumer.accept( block, item ) ) );
this.postInitCallbacks.forEach( consumer -> this.factory.addPostInit( side -> consumer.accept( block, item ) ) );
this.bootstrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( block, item ) ) );
if( this.tileEntityDefinition != null && block instanceof AEBaseTileBlock )
{
@@ -268,7 +237,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
if( block instanceof AEBaseTileBlock )
{
this.factory.addPreInit( side ->
this.factory.addBootstrapComponent( (IPreInitComponent) side ->
{
AEBaseTile.registerTileItem(
this.tileEntityDefinition == null ? ( (AEBaseTileBlock) block ).getTileEntityClass() : this.tileEntityDefinition.getTileEntityClass(),
@@ -110,13 +110,13 @@ class BlockRendering implements IBlockRendering
if( this.modelCustomizer != null )
{
factory.modelOverrideComponent.addOverride( block.getRegistryName().getResourcePath(), this.modelCustomizer );
factory.addModelOverride( block.getRegistryName().getResourcePath(), this.modelCustomizer );
}
else if( block instanceof AEBaseTileBlock )
{
// This is a default rotating model if the base-block uses an AE tile entity which exposes UP/FRONT as
// extended props
factory.modelOverrideComponent.addOverride( block.getRegistryName().getResourcePath(), ( l, m ) -> new AutoRotatingModel( m ) );
factory.addModelOverride( block.getRegistryName().getResourcePath(), ( l, m ) -> new AutoRotatingModel( m ) );
}
// TODO : 1.12
@@ -20,10 +20,18 @@ package appeng.bootstrap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Supplier;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.fml.relauncher.Side;
@@ -33,11 +41,7 @@ import appeng.api.definitions.IItemDefinition;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.components.BuiltInModelComponent;
import appeng.bootstrap.components.InitComponent;
import appeng.bootstrap.components.ModelOverrideComponent;
import appeng.bootstrap.components.ModelRegComponent;
import appeng.bootstrap.components.PostInitComponent;
import appeng.bootstrap.components.PreInitComponent;
import appeng.bootstrap.components.TileEntityComponent;
import appeng.core.features.AEFeature;
import appeng.core.features.ActivityState;
@@ -51,10 +55,10 @@ public class FeatureFactory
private final AEFeature[] defaultFeatures;
private final List<IBootstrapComponent> bootstrapComponents;
private final Map<Class<? extends IBootstrapComponent>, List<IBootstrapComponent>> bootstrapComponents;
@SideOnly( Side.CLIENT )
ModelOverrideComponent modelOverrideComponent;
private ModelOverrideComponent modelOverrideComponent;
@SideOnly( Side.CLIENT )
private BuiltInModelComponent builtInModelComponent;
@@ -64,18 +68,18 @@ public class FeatureFactory
public FeatureFactory()
{
this.defaultFeatures = new AEFeature[] { AEFeature.CORE };
this.bootstrapComponents = new ArrayList<>();
this.bootstrapComponents = new HashMap<>();
this.tileEntityComponent = new TileEntityComponent();
this.bootstrapComponents.add( this.tileEntityComponent );
this.addBootstrapComponent( this.tileEntityComponent );
if( Platform.isClient() )
{
this.modelOverrideComponent = new ModelOverrideComponent();
this.bootstrapComponents.add( this.modelOverrideComponent );
this.addBootstrapComponent( this.modelOverrideComponent );
this.builtInModelComponent = new BuiltInModelComponent();
this.bootstrapComponents.add( this.builtInModelComponent );
this.addBootstrapComponent( this.builtInModelComponent );
}
}
@@ -123,29 +127,16 @@ public class FeatureFactory
return new FeatureFactory( this, features );
}
void addBootstrapComponent( IBootstrapComponent component )
public void addBootstrapComponent( IBootstrapComponent component )
{
this.bootstrapComponents.add( component );
Arrays.stream( component.getClass().getInterfaces() )
.filter( i -> IBootstrapComponent.class.isAssignableFrom( i ) )
.forEach( i -> this.addBootstrapComponent( (Class<? extends IBootstrapComponent>) i, component ) );
}
void addPreInit( PreInitComponent component )
private <T extends IBootstrapComponent> void addBootstrapComponent( Class<? extends IBootstrapComponent> eventType, T component )
{
this.bootstrapComponents.add( component );
}
void addInit( InitComponent component )
{
this.bootstrapComponents.add( component );
}
void addModelReg( ModelRegComponent component )
{
this.bootstrapComponents.add( component );
}
void addPostInit( PostInitComponent component )
{
this.bootstrapComponents.add( component );
bootstrapComponents.computeIfAbsent( eventType, c -> new ArrayList<IBootstrapComponent>() ).add( component );
}
@SideOnly( Side.CLIENT )
@@ -154,8 +145,14 @@ public class FeatureFactory
this.builtInModelComponent.addModel( path, model );
}
public List<IBootstrapComponent> getBootstrapComponents()
@SideOnly( Side.CLIENT )
void addModelOverride( String resourcePath, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer )
{
return this.bootstrapComponents;
this.modelOverrideComponent.addOverride( resourcePath, customizer );
}
public <T extends IBootstrapComponent> Iterator<T> getBootstrapComponents( Class<T> eventType )
{
return (Iterator<T>) this.bootstrapComponents.getOrDefault( eventType, Collections.emptyList() ).iterator();
}
}
@@ -19,7 +19,7 @@
package appeng.bootstrap;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import net.minecraft.block.Block;
@@ -33,14 +33,7 @@ import appeng.core.features.AEFeature;
public interface IBlockBuilder
{
IBlockBuilder preInit( BiConsumer<Block, Item> callback );
IBlockBuilder init( BiConsumer<Block, Item> callback );
IBlockBuilder modelRegInit( BiConsumer<Block, Item> callback );
IBlockBuilder postInit( BiConsumer<Block, Item> callback );
IBlockBuilder bootstrap( BiFunction<Block, Item, IBootstrapComponent> component );
IBlockBuilder features( AEFeature... features );
@@ -19,28 +19,10 @@
package appeng.bootstrap;
import net.minecraftforge.fml.relauncher.Side;
/**
* Bootstrap components can be registered to take part in the various initialization phases of Forge.
* See the individual subclasses for a specific forge initalization event.
*/
public interface IBootstrapComponent
{
default void preInitialize( Side side )
{
}
default void modelReg( Side side )
{
}
default void initialize( Side side )
{
}
default void postInitialize( Side side )
{
}
}
@@ -19,7 +19,7 @@
package appeng.bootstrap;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.creativetab.CreativeTabs;
@@ -36,12 +36,7 @@ import appeng.core.features.ItemDefinition;
*/
public interface IItemBuilder
{
IItemBuilder preInit( Consumer<Item> callback );
IItemBuilder init( Consumer<Item> callback );
IItemBuilder postInit( Consumer<Item> callback );
IItemBuilder bootstrap( Function<Item, IBootstrapComponent> component );
IItemBuilder features( AEFeature... features );
@@ -16,24 +16,24 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.integration.modules.rf;
package appeng.bootstrap;
import appeng.integration.IIntegrationModule;
import appeng.integration.IntegrationHelper;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
/**
* @author GuntherDW
*/
public class RFModule implements IIntegrationModule
public interface IModelRegistry
{
public RFModule()
{
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyContainerItem.class );
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyProvider.class );
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyConnection.class );
IntegrationHelper.testClassExistence( this, cofh.redstoneflux.api.IEnergyContainerItem.class );
}
void registerItemVariants( Item item, ResourceLocation... names );
void setCustomModelResourceLocation( Item item, int metadata, ModelResourceLocation model );
void setCustomMeshDefinition( Item item, ItemMeshDefinition meshDefinition );
void setCustomStateMapper( Block block, IStateMapper mapper );
}
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.block.BlockDispenser;
@@ -33,10 +33,11 @@ import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IPostInitComponent;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.CreativeTab;
import appeng.core.Registration;
import appeng.core.features.AEFeature;
import appeng.core.features.ItemDefinition;
import appeng.util.Platform;
@@ -53,13 +54,7 @@ class ItemDefinitionBuilder implements IItemBuilder
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class );
private final List<Consumer<Item>> preInitCallbacks = new ArrayList<>();
private final List<Consumer<Item>> initCallbacks = new ArrayList<>();
private final List<Consumer<Item>> modelRegCallbacks = new ArrayList<>();
private final List<Consumer<Item>> postInitCallbacks = new ArrayList<>();
private final List<Function<Item, IBootstrapComponent>> boostrapComponents = new ArrayList<>();
private Supplier<IBehaviorDispenseItem> dispenserBehaviorSupplier;
@@ -80,23 +75,9 @@ class ItemDefinitionBuilder implements IItemBuilder
}
@Override
public ItemDefinitionBuilder preInit( Consumer<Item> callback )
public IItemBuilder bootstrap( Function<Item, IBootstrapComponent> component )
{
this.preInitCallbacks.add( callback );
return this;
}
@Override
public ItemDefinitionBuilder init( Consumer<Item> callback )
{
this.initCallbacks.add( callback );
return this;
}
@Override
public ItemDefinitionBuilder postInit( Consumer<Item> callback )
{
this.postInitCallbacks.add( callback );
this.boostrapComponents.add( component );
return this;
}
@@ -163,22 +144,19 @@ class ItemDefinitionBuilder implements IItemBuilder
item.setCreativeTab( this.creativeTab );
// Register all extra handlers
this.preInitCallbacks.forEach( consumer -> this.factory.addPreInit( side -> consumer.accept( item ) ) );
this.initCallbacks.forEach( consumer -> this.factory.addInit( side -> consumer.accept( item ) ) );
this.modelRegCallbacks.forEach( consumer -> this.factory.addModelReg( side -> consumer.accept( item ) ) );
this.postInitCallbacks.forEach( consumer -> this.factory.addPostInit( side -> consumer.accept( item ) ) );
this.boostrapComponents.forEach( component -> component.apply( item ) );
// Register custom dispenser behavior if requested
if( this.dispenserBehaviorSupplier != null )
{
this.factory.addPostInit( side ->
this.factory.addBootstrapComponent( (IPostInitComponent) side ->
{
IBehaviorDispenseItem behavior = this.dispenserBehaviorSupplier.get();
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item, behavior );
} );
}
this.factory.addPreInit( side -> Registration.addItemToRegister( item ) );
this.factory.addBootstrapComponent( (IItemRegistrationComponent) ( side, reg ) -> reg.register( item ) );
if( Platform.isClient() )
{
@@ -187,4 +165,5 @@ class ItemDefinitionBuilder implements IItemBuilder
return definition;
}
}
@@ -128,15 +128,13 @@ class ItemRendering implements IItemRendering
Block block = ( (ItemBlock) item ).getBlock();
// We can only do this once the blocks are actually registered...
StateMapperHelper helper = new StateMapperHelper( block.getRegistryName() );
StateMapperHelper helper = new StateMapperHelper( item.getRegistryName() );
model = helper.getModelResourceLocation( block.getDefaultState() );
}
else
{
model = new ModelResourceLocation( item.getRegistryName(), "inventory" );
resources.add( model );
}
factory.addBootstrapComponent( new ItemModelComponent( item, ImmutableMap.of( 0, model ) ) );
}
@@ -147,17 +145,12 @@ class ItemRendering implements IItemRendering
{
factory.addBootstrapComponent( new ItemVariantsComponent( item, resources ) );
}
else if( !this.itemModels.isEmpty() || this.itemMeshDefinition != null )
else if( this.itemMeshDefinition != null )
{
// Adding an empty variant list here will prevent Vanilla from trying to load the default item model in this
// case
factory.addBootstrapComponent( new ItemVariantsComponent( item, Collections.emptyList() ) );
}
else if( item instanceof ItemBlock )
{
// The default for block items is to register the block model
factory.addBootstrapComponent( new ItemVariantsComponent( item, Collections.emptyList() ) );
}
if( this.itemColor != null )
{
@@ -25,7 +25,7 @@ import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraftforge.fml.relauncher.Side;
public class BlockColorComponent implements InitComponent
public class BlockColorComponent implements IInitComponent
{
private final Block block;
@@ -33,7 +33,7 @@ import appeng.client.render.model.BuiltInModelLoader;
@SideOnly( Side.CLIENT )
public class BuiltInModelComponent implements PreInitComponent
public class BuiltInModelComponent implements IPreInitComponent
{
private final Map<String, IModel> builtInModels = new HashMap<>();
@@ -0,0 +1,16 @@
package appeng.bootstrap.components;
import net.minecraft.block.Block;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IBlockRegistrationComponent extends IBootstrapComponent
{
void blockRegistration( Side side, IForgeRegistry<Block> blockRegistry );
}
@@ -25,10 +25,7 @@ import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface InitComponent extends IBootstrapComponent
public interface IInitComponent extends IBootstrapComponent
{
@Override
void initialize( Side side );
}
@@ -0,0 +1,16 @@
package appeng.bootstrap.components;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IItemRegistrationComponent extends IBootstrapComponent
{
void itemRegistration( Side side, IForgeRegistry<Item> itemRegistry );
}
@@ -0,0 +1,36 @@
/*
* 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.bootstrap.components;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IBootstrapComponent;
import appeng.bootstrap.IModelRegistry;
/**
* @author GuntherDW
*/
@FunctionalInterface
public interface IModelRegistrationComponent extends IBootstrapComponent
{
void modelRegistration( Side side, IModelRegistry registry );
}
@@ -16,18 +16,16 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.tile;
package appeng.bootstrap.components;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import net.minecraftforge.fml.relauncher.Side;
import appeng.tile.events.TileEventType;
import appeng.bootstrap.IBootstrapComponent;
@Retention( RetentionPolicy.RUNTIME )
public @interface TileEvent
@FunctionalInterface
public interface IOreDictComponent extends IBootstrapComponent
{
TileEventType value();
void oreRegistration( Side side );
}
@@ -25,9 +25,7 @@ import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface PostInitComponent extends IBootstrapComponent
public interface IPostInitComponent extends IBootstrapComponent
{
@Override
void postInitialize( Side side );
}
@@ -25,10 +25,7 @@ import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface PreInitComponent extends IBootstrapComponent
public interface IPreInitComponent extends IBootstrapComponent
{
@Override
void preInitialize( Side side );
}
@@ -0,0 +1,16 @@
package appeng.bootstrap.components;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.IBootstrapComponent;
@FunctionalInterface
public interface IRecipeRegistrationComponent extends IBootstrapComponent
{
void recipeRegistration( Side side, IForgeRegistry<IRecipe> recipeRegistry );
}
@@ -25,7 +25,7 @@ import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
public class ItemColorComponent implements InitComponent
public class ItemColorComponent implements IInitComponent
{
private final Item item;
@@ -21,17 +21,18 @@ package appeng.bootstrap.components;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IModelRegistry;
/**
* Registers a custom item mesh definition that can be used to dynamically determine the item model based on
* item stack properties.
*/
public class ItemMeshDefinitionComponent implements InitComponent
public class ItemMeshDefinitionComponent implements IModelRegistrationComponent
{
private final Item item;
@@ -45,8 +46,8 @@ public class ItemMeshDefinitionComponent implements InitComponent
}
@Override
public void initialize( Side side )
public void modelRegistration( Side side, IModelRegistry registry )
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( this.item, this.meshDefinition );
registry.setCustomMeshDefinition( this.item, this.meshDefinition );
}
}
@@ -23,18 +23,18 @@ import java.util.Map;
import javax.annotation.Nonnull;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IModelRegistry;
/**
* Registers the models that should by used for an item, including the ability to
* distinguish by meta.
*/
public class ItemModelComponent implements InitComponent
public class ItemModelComponent implements IModelRegistrationComponent
{
private final Item item;
@@ -48,13 +48,11 @@ public class ItemModelComponent implements InitComponent
}
@Override
public void initialize( Side side )
public void modelRegistration( Side side, IModelRegistry registry )
{
ItemModelMesher itemMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
this.modelsByMeta.forEach( ( meta, model ) ->
{
itemMesher.register( this.item, meta, model );
registry.setCustomModelResourceLocation( this.item, meta, model );
} );
}
@@ -21,15 +21,14 @@ package appeng.bootstrap.components;
import java.util.Collection;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IBootstrapComponent;
import appeng.bootstrap.IModelRegistry;
public class ItemVariantsComponent implements IBootstrapComponent
public class ItemVariantsComponent implements IModelRegistrationComponent
{
private final Item item;
@@ -43,9 +42,9 @@ public class ItemVariantsComponent implements IBootstrapComponent
}
@Override
public void preInitialize( Side side )
public void modelRegistration( Side side, IModelRegistry registry )
{
ResourceLocation[] resourceArr = this.resources.toArray( new ResourceLocation[0] );
ModelBakery.registerItemVariants( this.item, resourceArr );
registry.registerItemVariants( this.item, resourceArr );
}
}
@@ -39,7 +39,7 @@ import net.minecraftforge.fml.relauncher.Side;
import appeng.core.AppEng;
public class ModelOverrideComponent implements PreInitComponent
public class ModelOverrideComponent implements IPreInitComponent
{
private static final ModelResourceLocation MODEL_MISSING = new ModelResourceLocation( "builtin/missing", "missing" );
@@ -1,21 +0,0 @@
package appeng.bootstrap.components;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IBootstrapComponent;
/**
* @author GuntherDW
*/
@FunctionalInterface
public interface ModelRegComponent extends IBootstrapComponent
{
@Override
void modelReg( Side side );
}
@@ -24,14 +24,15 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import appeng.bootstrap.IModelRegistry;
/**
* Registers a custom state mapper for a given block.
*/
public class StateMapperComponent implements ModelRegComponent
public class StateMapperComponent implements IModelRegistrationComponent
{
private final Block block;
@@ -45,9 +46,9 @@ public class StateMapperComponent implements ModelRegComponent
}
@Override
public void modelReg( Side side )
public void modelRegistration( Side side, IModelRegistry registry )
{
ModelLoader.setCustomStateMapper( this.block, this.stateMapper );
registry.setCustomStateMapper( this.block, this.stateMapper );
if( this.stateMapper instanceof IResourceManagerReloadListener )
{
( (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager() )
@@ -32,7 +32,7 @@ import appeng.tile.AEBaseTile;
* @param <T>
*/
// public class TesrComponent<T extends AEBaseTile> implements ModelRegComponent
public class TesrComponent<T extends AEBaseTile> implements PreInitComponent
public class TesrComponent<T extends AEBaseTile> implements IPreInitComponent
{
private final Class<T> tileEntityClass;
@@ -15,7 +15,7 @@ import appeng.core.AppEng;
/**
* @author GuntherDW
*/
public class TileEntityComponent implements PreInitComponent
public class TileEntityComponent implements IPreInitComponent
{
private List<TileEntityDefinition> tileEntityDefinitions = new ArrayList<>();
@@ -28,6 +28,7 @@ import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.api.storage.ISpatialDimension;
import appeng.api.storage.IStorageMonitorableAccessor;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
@@ -45,6 +46,8 @@ public final class Capabilities
public static Capability<IStorageMonitorableAccessor> STORAGE_MONITORABLE_ACCESSOR;
public static Capability<ISpatialDimension> SPATIAL_DIMENSION;
public static Capability<ITeslaConsumer> TESLA_CONSUMER;
public static Capability<ITeslaHolder> TESLA_HOLDER;
@@ -57,6 +60,7 @@ public final class Capabilities
public static void register()
{
CapabilityManager.INSTANCE.register( IStorageMonitorableAccessor.class, createNullStorage(), NullMENetworkAccessor::new );
CapabilityManager.INSTANCE.register( ISpatialDimension.class, createNullStorage(), NullSpatialDimension::new );
}
@CapabilityInject( IStorageMonitorableAccessor.class )
@@ -65,6 +69,12 @@ public final class Capabilities
STORAGE_MONITORABLE_ACCESSOR = cap;
}
@CapabilityInject( ISpatialDimension.class )
private static void capISpatialDimensionRegistered( Capability<ISpatialDimension> cap )
{
SPATIAL_DIMENSION = cap;
}
@CapabilityInject( ITeslaConsumer.class )
private static void capITeslaConsumerRegistered( Capability<ITeslaConsumer> cap )
{
@@ -19,7 +19,7 @@
package appeng.capabilities;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.IStorageMonitorableAccessor;
@@ -28,7 +28,7 @@ class NullMENetworkAccessor implements IStorageMonitorableAccessor
{
@Override
public IStorageMonitorable getInventory( BaseActionSource src )
public IStorageMonitorable getInventory( IActionSource src )
{
return null;
}
@@ -0,0 +1,70 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, 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.capabilities;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.api.storage.ISpatialDimension;
class NullSpatialDimension implements ISpatialDimension
{
@Override
public int createNewCellDimension( BlockPos size, int owner )
{
return -1;
}
@Override
public void deleteCellDimension( int cellStorageId )
{
}
@Override
public int getCellDimensionOwner( int cellStorageId )
{
return -1;
}
@Override
public BlockPos getCellDimensionOrigin( int cellStorageId )
{
return null;
}
@Override
public World getWorld()
{
return null;
}
@Override
public boolean isCellDimension( int cellDimID )
{
return false;
}
@Override
public BlockPos getCellContentSize( int cellDimId )
{
return null;
}
}
@@ -62,7 +62,6 @@ import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketAssemblerAnimation;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.coremod.MissingCoreMod;
import appeng.entity.EntityFloatingItem;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.entity.RenderFloatingItem;
@@ -241,12 +240,6 @@ public class ClientHelper extends ServerHelper
mc.world.markBlockRangeForRenderUpdate( x - range, y - range, z - range, x + range, y + range, z + range );
}
@Override
public void missingCoreMod()
{
throw new MissingCoreMod();
}
@SubscribeEvent
public void postPlayerRender( final RenderLivingEvent.Pre p )
{
+3 -22
View File
@@ -84,7 +84,6 @@ import appeng.helpers.InventoryAction;
public abstract class AEBaseGui extends GuiContainer
{
private static boolean switchingGuis;
private final List<InternalSlotME> meSlots = new LinkedList<>();
// drag y
private final Set<Slot> drag_click = new HashSet<>();
@@ -94,13 +93,10 @@ public abstract class AEBaseGui extends GuiContainer
private Stopwatch dbl_clickTimer = Stopwatch.createStarted();
private ItemStack dbl_whichItem = ItemStack.EMPTY;
private Slot bl_clicked;
private boolean subGui;
public AEBaseGui( final Container container )
{
super( container );
this.subGui = switchingGuis;
switchingGuis = false;
}
protected static String join( final Collection<String> toolTip, final String delimiter )
@@ -123,11 +119,6 @@ public abstract class AEBaseGui extends GuiContainer
}
}
public boolean isSubGui()
{
return this.subGui;
}
@Override
public void initGui()
{
@@ -455,7 +446,8 @@ public abstract class AEBaseGui extends GuiContainer
action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ( (SlotME) slot ).getAEStack();
if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getShowCraftingLabel() )
if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack()
.isEmpty() )
{
action = InventoryAction.AUTO_CRAFT;
}
@@ -587,7 +579,6 @@ public abstract class AEBaseGui extends GuiContainer
public void onGuiClosed()
{
super.onGuiClosed();
this.subGui = true; // in case the gui is reopened later ( i'm looking at you NEI )
}
protected Slot getSlot( final int mouseX, final int mouseY )
@@ -715,7 +706,7 @@ public abstract class AEBaseGui extends GuiContainer
// Annoying but easier than trying to splice into render item
super.drawSlot( new Size1Slot( (SlotME) s ) );
this.stackSizeRenderer.renderStackSize( this.fontRenderer, ( (SlotME) s ).getAEStack(), s.getStack(), s.xPos, s.yPos );
this.stackSizeRenderer.renderStackSize( this.fontRenderer, ( (SlotME) s ).getAEStack(), s.xPos, s.yPos );
}
catch( final Exception err )
@@ -870,14 +861,4 @@ public abstract class AEBaseGui extends GuiContainer
{
return this.meSlots;
}
public static final synchronized boolean isSwitchingGuis()
{
return switchingGuis;
}
public static final synchronized void setSwitchingGuis( final boolean switchingGuis )
{
AEBaseGui.switchingGuis = switchingGuis;
}
}
@@ -352,11 +352,11 @@ public class GuiCraftConfirm extends AEBaseGui
final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
final int posY = y * offY + yo;
final ItemStack is = refStack.copy().getItemStack();
final ItemStack is = refStack.asItemStackRepresentation();
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
dspToolTip = Platform.getItemDisplayName( refStack );
if( lineList.size() > 0 )
{
@@ -309,11 +309,11 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
final int posX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
final int posY = y * offY + ITEMSTACK_TOP_OFFSET;
final ItemStack is = refStack.copy().getItemStack();
final ItemStack is = refStack.asItemStackRepresentation();
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
dspToolTip = Platform.getItemDisplayName( refStack );
if( lineList.size() > 0 )
{
@@ -60,6 +60,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.integration.Integrations;
import appeng.parts.reporting.AbstractPartTerminal;
import appeng.tile.misc.TileSecurityStation;
import appeng.util.IConfigManagerHost;
@@ -304,6 +305,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.searchField.setEnableBackgroundDrawing( false );
this.searchField.setMaxStringLength( 25 );
this.searchField.setTextColor( 0xFFFFFF );
this.searchField.setSelectionColor( 0xFF99FF99 );
this.searchField.setVisible( true );
if( this.viewCell || this instanceof GuiWirelessTerm )
@@ -313,13 +315,19 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
this.craftingStatusBtn.setHideEdge( 13 );
}
// Enum setting = AEConfig.instance().getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
final Enum setting = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE );
this.searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.JEI_AUTOSEARCH == setting );
this.searchField.setCanLoseFocus( SearchBoxMode.MANUAL_SEARCH == setting || SearchBoxMode.JEI_MANUAL_SEARCH == setting );
if( this.isSubGui() )
if( setting == SearchBoxMode.JEI_AUTOSEARCH || setting == SearchBoxMode.JEI_MANUAL_SEARCH )
{
memoryText = Integrations.jei().getSearchText();
}
if( memoryText != null && !memoryText.isEmpty() )
{
this.searchField.setText( memoryText );
this.searchField.selectAll();
this.repo.setSearchString( memoryText );
this.repo.updateView();
this.setScrollBar();
@@ -363,12 +371,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
{
final Enum searchMode = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE );
if( searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.JEI_AUTOSEARCH )
{
this.searchField.mouseClicked( xCoord, yCoord, btn );
}
this.searchField.mouseClicked( xCoord, yCoord, btn );
if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
{
@@ -180,7 +180,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
if( this.tooltip == z - viewStart )
{
toolTip = Platform.getItemDisplayName( this.repo.getItem( z ) );
toolTip = Platform.getItemDisplayName( refStack );
toolTip += ( '\n' + GuiText.Installed.getLocal() + ": " + ( refStack.getStackSize() ) );
if( refStack.getCountRequestable() > 0 )
@@ -192,7 +192,7 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource
toolPosY = y * 18 + yo;
}
this.drawItem( posX, posY, this.repo.getItem( z ) );
this.drawItem( posX, posY, refStack.asItemStackRepresentation() );
x++;
@@ -78,12 +78,23 @@ public class GuiSpatialIOPort extends AEBaseGui
this.fontRenderer.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getCurrentPower(), false ), 13, 21,
4210752 );
this.fontRenderer.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getMaxPower(), false ), 13, 31, 4210752 );
this.fontRenderer.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getRequiredPower(), false ), 13, 78,
this.fontRenderer.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getRequiredPower(), false ), 13, 73,
4210752 );
this.fontRenderer.drawString( GuiText.Efficiency.getLocal() + ": " + ( ( (float) this.container.getEfficency() ) / 100 ) + '%', 13, 88, 4210752 );
this.fontRenderer.drawString( GuiText.Efficiency.getLocal() + ": " + ( ( (float) this.container.getEfficency() ) / 100 ) + '%', 13, 83, 4210752 );
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96, 4210752 );
if( this.container.xSize != 0 && this.container.ySize != 0 && this.container.zSize != 0 )
{
final String text = GuiText.SCSSize.getLocal() + ": " + this.container.xSize + "x" + this.container.ySize + "x" + this.container.zSize;
this.fontRenderer.drawString( text, 13, 93, 4210752 );
}
else
{
this.fontRenderer.drawString( GuiText.SCSSize.getLocal() + ": " + GuiText.SCSSInvalid.getLocal(), 13, 93, 4210752 );
}
}
@Override
@@ -21,6 +21,10 @@ package appeng.client.gui.widgets;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
/**
@@ -39,6 +43,7 @@ public class MEGuiTextField extends GuiTextField
private final int _yPos;
private final int _width;
private final int _height;
private int selectionColor = 0xFF00FF00;
/**
* Uses the values to instantiate a padded version of a text field.
@@ -66,8 +71,11 @@ public class MEGuiTextField extends GuiTextField
super.mouseClicked( xPos, yPos, button );
final boolean requiresFocus = this.isMouseIn( xPos, yPos );
if( !this.isFocused() )
{
this.setFocused( requiresFocus );
}
this.setFocused( requiresFocus );
return true;
}
@@ -86,4 +94,69 @@ public class MEGuiTextField extends GuiTextField
return withinXRange && withinYRange;
}
public void selectAll()
{
this.setCursorPosition( 0 );
this.setSelectionPos( this.getMaxStringLength() );
}
public void setSelectionColor( int color )
{
this.selectionColor = color;
}
@Override
public void drawSelectionBox( int startX, int startY, int endX, int endY )
{
if( startX < endX )
{
int i = startX;
startX = endX;
endX = i;
}
startX += 1;
endX -= 1;
if( startY < endY )
{
int j = startY;
startY = endY;
endY = j;
}
startY -= PADDING;
if( endX > this.x + this.width )
{
endX = this.x + this.width;
}
if( startX > this.x + this.width )
{
startX = this.x + this.width;
}
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
float red = (float) ( this.selectionColor >> 16 & 255 ) / 255.0F;
float blue = (float) ( this.selectionColor >> 8 & 255 ) / 255.0F;
float green = (float) ( this.selectionColor & 255 ) / 255.0F;
float alpha = (float) ( this.selectionColor >> 24 & 255 ) / 255.0F;
GlStateManager.color( red, green, blue, alpha );
GlStateManager.disableTexture2D();
GlStateManager.enableColorLogic();
GlStateManager.colorLogicOp( GlStateManager.LogicOp.OR_REVERSE );
bufferbuilder.begin( 7, DefaultVertexFormats.POSITION );
bufferbuilder.pos( (double) startX, (double) endY, 0.0D ).endVertex();
bufferbuilder.pos( (double) endX, (double) endY, 0.0D ).endVertex();
bufferbuilder.pos( (double) endX, (double) startY, 0.0D ).endVertex();
bufferbuilder.pos( (double) startX, (double) startY, 0.0D ).endVertex();
tessellator.draw();
GlStateManager.disableColorLogic();
GlStateManager.enableTexture2D();
}
}
@@ -42,7 +42,7 @@ public class InternalSlotME
ItemStack getStack()
{
return this.repo.getItem( this.offset );
return this.getAEStack() == null ? ItemStack.EMPTY : this.getAEStack().asItemStackRepresentation();
}
IAEItemStack getAEStack()
+3 -24
View File
@@ -50,7 +50,6 @@ public class ItemRepo
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
private final ArrayList<IAEItemStack> view = new ArrayList<>();
private final ArrayList<ItemStack> dsp = new ArrayList<>();
private final IScrollSource src;
private final ISortSource sortSrc;
@@ -78,17 +77,6 @@ public class ItemRepo
return this.view.get( idx );
}
public ItemStack getItem( int idx )
{
idx += this.src.getCurrentScroll() * this.rowSize;
if( idx >= this.dsp.size() )
{
return ItemStack.EMPTY;
}
return this.dsp.get( idx );
}
void setSearch( final String search )
{
this.searchString = search == null ? "" : search;
@@ -118,10 +106,8 @@ public class ItemRepo
public void updateView()
{
this.view.clear();
this.dsp.clear();
this.view.ensureCapacity( this.list.size() );
this.dsp.ensureCapacity( this.list.size() );
final Enum viewMode = this.sortSrc.getSortDisplay();
final Enum searchMode = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE );
@@ -177,12 +163,10 @@ public class ItemRepo
if( viewMode == ViewItems.CRAFTABLE )
{
is = is.copy();
// is.setStackSize( 0 ) triggers isEmpty() and thus only shows empty stacks!
is.setStackSize( 1 );
is.setShowCraftingLabel( true );
is.setStackSize( 0 );
}
if( viewMode == ViewItems.STORED && is.getShowCraftingLabel() )
if( viewMode == ViewItems.STORED && is.getStackSize() == 0 )
{
continue;
}
@@ -196,7 +180,7 @@ public class ItemRepo
notDone = false;
}
if( terminalSearchToolTips && notDone )
if( terminalSearchToolTips && notDone && !searchMod )
{
for( final Object lp : Platform.getTooltip( is ) )
{
@@ -237,11 +221,6 @@ public class ItemRepo
{
Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME );
}
for( final IAEItemStack is : this.view )
{
this.dsp.add( is.getItemStack() );
}
}
private void updateJEI( String filter )
@@ -21,7 +21,6 @@ package appeng.client.render;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.AEConfig;
@@ -42,9 +41,9 @@ public class StackSizeRenderer
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
public void renderStackSize( FontRenderer fontRenderer, IAEItemStack aeStack, ItemStack is, int xPos, int yPos )
public void renderStackSize( FontRenderer fontRenderer, IAEItemStack aeStack, int xPos, int yPos )
{
if( !is.isEmpty() )
if( aeStack != null )
{
final float scaleFactor = AEConfig.instance().useTerminalUseLargeFont() ? 0.85f : 0.5f;
final float inverseScaleFactor = 1.0f / scaleFactor;
@@ -53,7 +52,7 @@ public class StackSizeRenderer
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
fontRenderer.setUnicodeFlag( false );
if( aeStack.getShowCraftingLabel() )
if( aeStack.getStackSize() == 0 && aeStack.isCraftable() )
{
final String craftLabelText = AEConfig.instance().useTerminalUseLargeFont() ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft
.getLocal();
@@ -71,10 +70,9 @@ public class StackSizeRenderer
GlStateManager.enableBlend();
}
final long amount = aeStack != null ? aeStack.getStackSize() : is.getCount();
if( amount != 0 && !aeStack.getShowCraftingLabel() )
if( aeStack.getStackSize() > 0 )
{
final String stackSize = this.getToBeRenderedStackSize( amount );
final String stackSize = this.getToBeRenderedStackSize( aeStack.getStackSize() );
GlStateManager.disableLighting();
GlStateManager.disableDepth();
@@ -126,8 +126,9 @@ public class TesrRenderHelper
*/
public static void renderItem2dWithAmount( IAEItemStack itemStack, float itemScale, float spacing )
{
final ItemStack renderStack = itemStack.asItemStackRepresentation();
TesrRenderHelper.renderItem2d( itemStack.getItemStack(), itemScale );
TesrRenderHelper.renderItem2d( renderStack, itemScale );
final long stackSize = itemStack.getStackSize();
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize );
@@ -101,6 +101,9 @@ class CableBuilder
case SMART:
textureFolder = "parts/cable/smart/";
break;
case DENSE_COVERED:
textureFolder = "parts/cable/dense_covered/";
break;
case DENSE_SMART:
textureFolder = "parts/cable/dense_smart/";
break;
@@ -127,6 +130,7 @@ class CableBuilder
case SMART:
this.addCableCore( CableCoreType.COVERED, color, quadsOut );
break;
case DENSE_COVERED:
case DENSE_SMART:
this.addCableCore( CableCoreType.DENSE_SMART, color, quadsOut );
break;
@@ -448,7 +452,31 @@ class CableBuilder
addCoveredCableSizedCube( facing, distanceFromEdge, cubeBuilder );
}
public void addDenseConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, int channels, List<BakedQuad> quadsOut )
public void addDenseCoveredConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, List<BakedQuad> quadsOut )
{
// Dense cables only render their connections as dense if the adjacent blocks actually wants that
if( connectionType == AECableType.COVERED || connectionType == AECableType.SMART || connectionType == AECableType.GLASS )
{
this.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
return;
}
CubeBuilder cubeBuilder = new CubeBuilder( this.format, quadsOut );
// We render all faces except the one on the connection side
cubeBuilder.setDrawFaces( EnumSet.complementOf( EnumSet.of( facing ) ) );
TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_COVERED ).get( cableColor );
cubeBuilder.setTexture( texture );
addDenseCableSizedCube( facing, cubeBuilder );
// Reset back to normal rendering for the rest
cubeBuilder.setRenderFullBright( false );
cubeBuilder.setTexture( texture );
}
public void addDenseSmartConnection( EnumFacing facing, AEColor cableColor, AECableType connectionType, boolean cableBusAdjacent, int channels, List<BakedQuad> quadsOut )
{
// Dense cables only render their connections as dense if the adjacent blocks actually wants that
if( connectionType == AECableType.SMART )
@@ -456,7 +484,7 @@ class CableBuilder
this.addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
return;
}
else if( connectionType != AECableType.DENSE_SMART )
else if( connectionType == AECableType.COVERED || connectionType == AECableType.GLASS )
{
this.addCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
return;
@@ -495,7 +523,19 @@ class CableBuilder
}
public void addStraightDenseConnection( EnumFacing facing, AEColor cableColor, int channels, List<BakedQuad> quadsOut )
public void addStraightDenseCoveredConnection( EnumFacing facing, AEColor cableColor, List<BakedQuad> quadsOut )
{
CubeBuilder cubeBuilder = new CubeBuilder( this.format, quadsOut );
TextureAtlasSprite texture = this.connectionTextures.get( AECableType.DENSE_COVERED ).get( cableColor );
cubeBuilder.setTexture( texture );
setStraightCableUVs( cubeBuilder, facing, 5, 11 );
addStraightDenseCableSizedCube( facing, cubeBuilder );
}
public void addStraightDenseSmartConnection( EnumFacing facing, AEColor cableColor, int channels, List<BakedQuad> quadsOut )
{
CubeBuilder cubeBuilder = new CubeBuilder( this.format, quadsOut );
@@ -164,6 +164,8 @@ public class CableBusBakedModel implements IBakedModel
{
case GLASS:
return firstType == AECableType.GLASS && secondType == AECableType.GLASS;
case DENSE_COVERED:
return firstType == AECableType.DENSE_COVERED && secondType == AECableType.DENSE_COVERED;
case DENSE_SMART:
return firstType == AECableType.DENSE_SMART && secondType == AECableType.DENSE_SMART;
}
@@ -200,8 +202,11 @@ public class CableBusBakedModel implements IBakedModel
case SMART:
this.cableBuilder.addStraightSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
break;
case DENSE_COVERED:
this.cableBuilder.addStraightDenseCoveredConnection( facing, cableColor, quadsOut );
break;
case DENSE_SMART:
this.cableBuilder.addStraightDenseConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
this.cableBuilder.addStraightDenseSmartConnection( facing, cableColor, renderState.getChannelsOnSide().get( facing ), quadsOut );
break;
}
@@ -228,6 +233,7 @@ public class CableBusBakedModel implements IBakedModel
case SMART:
this.cableBuilder.addConstrainedSmartConnection( facing, cableColor, distance, channels, quadsOut );
break;
case DENSE_COVERED:
case DENSE_SMART:
// Dense cables do not render connections to parts since none can be attached
break;
@@ -253,8 +259,11 @@ public class CableBusBakedModel implements IBakedModel
case SMART:
this.cableBuilder.addSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
break;
case DENSE_COVERED:
this.cableBuilder.addDenseCoveredConnection( facing, cableColor, connectionType, cableBusAdjacent, quadsOut );
break;
case DENSE_SMART:
this.cableBuilder.addDenseConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
this.cableBuilder.addDenseSmartConnection( facing, cableColor, connectionType, cableBusAdjacent, channels, quadsOut );
break;
}
}
@@ -55,6 +55,7 @@ public enum CableCoreType
result.put( AECableType.GLASS, CableCoreType.GLASS );
result.put( AECableType.COVERED, CableCoreType.COVERED );
result.put( AECableType.SMART, CableCoreType.COVERED );
result.put( AECableType.DENSE_COVERED, CableCoreType.DENSE_SMART );
result.put( AECableType.DENSE_SMART, CableCoreType.DENSE_SMART );
return ImmutableMap.copyOf( result );
@@ -227,7 +227,7 @@ class ItemEncodedPatternBakedModel implements IBakedModel
{
ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
ItemStack output = iep.getOutput( stack );
if( output != null )
if( !output.isEmpty() )
{
IBakedModel realModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel( output );
// Give the item model a chance to handle the overrides as well
@@ -22,6 +22,7 @@ package appeng.client.render.effects;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.storage.data.IAEItemStack;
@@ -45,7 +46,8 @@ public class AssemblerFX extends Particle implements ICanDie
this.motionY = 0;
this.motionZ = 0;
this.speed = speed;
this.fi = new EntityFloatingItem( this, w, x, y, z, is.getItemStack() );
final ItemStack displayItem = is.asItemStackRepresentation();
this.fi = new EntityFloatingItem( this, w, x, y, z, displayItem );
w.spawnEntity( this.fi );
this.particleMaxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;
}
@@ -191,17 +191,19 @@ public enum UVLModelLoader implements ICustomModelLoader
{
modelPath = modelPath.substring( "models/".length() );
}
try( InputStreamReader io = new InputStreamReader( Minecraft.getMinecraft()
.getResourceManager()
.getResource( new ResourceLocation( modelLocation.getResourceDomain(), "models/" + modelPath + ".json" ) )
.getInputStream() ) )
{
return gson.fromJson( io, UVLMarker.class ).uvlMarker;
return gson.fromJson( io, UVLMarker.class ).ae2_uvl_marker;
}
catch( IOException e )
catch( Exception e )
{
// Catch-all in case of any JSON parser issues.
}
return false;
}
@@ -387,7 +389,7 @@ public enum UVLModelLoader implements ICustomModelLoader
class UVLMarker
{
boolean uvlMarker = false;
boolean ae2_uvl_marker = false;
}
}
@@ -51,10 +51,9 @@ import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.security.PlayerSource;
import appeng.api.parts.IPart;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.data.IAEItemStack;
@@ -77,6 +76,7 @@ import appeng.core.sync.packets.PacketPartialItem;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.ICustomNameObject;
import appeng.helpers.InventoryAction;
import appeng.me.helpers.PlayerSource;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorItemHandler;
@@ -87,7 +87,7 @@ import appeng.util.item.AEItemStack;
public abstract class AEBaseContainer extends Container
{
private final InventoryPlayer invPlayer;
private final BaseActionSource mySrc;
private final IActionSource mySrc;
private final HashSet<Integer> locked = new HashSet<>();
private final TileEntity tileEntity;
private final IPart part;
@@ -225,10 +225,11 @@ public abstract class AEBaseContainer extends Container
// client doesn't need to re-send, makes for lower overhead rapid packets.
if( Platform.isClient() )
{
final ItemStack a = stack == null ? ItemStack.EMPTY : stack.getItemStack();
final ItemStack b = this.clientRequestedTargetItem == null ? ItemStack.EMPTY : this.clientRequestedTargetItem.getItemStack();
if( Platform.itemComparisons().isSameItem( a, b ) )
if( stack == null && this.clientRequestedTargetItem == null )
{
return;
}
if( stack != null && stack.isSameType( this.clientRequestedTargetItem ) )
{
return;
}
@@ -279,7 +280,7 @@ public abstract class AEBaseContainer extends Container
this.clientRequestedTargetItem = stack == null ? null : stack.copy();
}
public BaseActionSource getActionSource()
public IActionSource getActionSource()
{
return this.mySrc;
}
@@ -828,11 +829,11 @@ public abstract class AEBaseContainer extends Container
if( action == InventoryAction.MOVE_REGION )
{
final List<Slot> from = new LinkedList<>();
final List<Slot> from = new ArrayList<>();
for( final Object j : this.inventorySlots )
{
if( j instanceof Slot && j.getClass() == s.getClass() )
if( j instanceof Slot && j.getClass() == s.getClass() && !( j instanceof SlotCraftingTerm ) )
{
from.add( (Slot) j );
}
@@ -861,7 +862,7 @@ public abstract class AEBaseContainer extends Container
if( slotItem != null )
{
IAEItemStack ais = slotItem.copy();
ItemStack myItem = ais.getItemStack();
ItemStack myItem = ais.createItemStack();
ais.setStackSize( myItem.getMaxStackSize() );
@@ -877,7 +878,7 @@ public abstract class AEBaseContainer extends Container
ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
if( ais != null )
{
adp.addItems( ais.getItemStack() );
adp.addItems( ais.createItemStack() );
}
}
break;
@@ -901,7 +902,7 @@ public abstract class AEBaseContainer extends Container
{
final InventoryAdaptor ia = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) );
final ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null );
final ItemStack fail = ia.removeItems( 1, extracted.getDefinition(), null );
if( fail.isEmpty() )
{
this.getCellInventory().extractItems( extracted, Actionable.MODULATE, this.getActionSource() );
@@ -930,7 +931,7 @@ public abstract class AEBaseContainer extends Container
{
liftQty = 0;
}
if( !Platform.itemComparisons().isSameItem( slotItem.getItemStack(), item ) )
if( !Platform.itemComparisons().isSameItem( slotItem.getDefinition(), item ) )
{
liftQty = 0;
}
@@ -945,7 +946,7 @@ public abstract class AEBaseContainer extends Container
{
final InventoryAdaptor ia = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) );
final ItemStack fail = ia.addItems( ais.getItemStack() );
final ItemStack fail = ia.addItems( ais.createItemStack() );
if( !fail.isEmpty() )
{
this.getCellInventory().injectItems( ais, Actionable.MODULATE, this.getActionSource() );
@@ -967,11 +968,11 @@ public abstract class AEBaseContainer extends Container
if( slotItem != null )
{
IAEItemStack ais = slotItem.copy();
ais.setStackSize( ais.getItemStack().getMaxStackSize() );
ais.setStackSize( ais.getDefinition().getMaxStackSize() );
ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
if( ais != null )
{
player.inventory.setItemStack( ais.getItemStack() );
player.inventory.setItemStack( ais.createItemStack() );
}
else
{
@@ -986,7 +987,7 @@ public abstract class AEBaseContainer extends Container
ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
if( ais != null )
{
player.inventory.setItemStack( ais.getItemStack() );
player.inventory.setItemStack( ais.createItemStack() );
}
else
{
@@ -1007,7 +1008,7 @@ public abstract class AEBaseContainer extends Container
if( slotItem != null )
{
IAEItemStack ais = slotItem.copy();
final long maxSize = ais.getItemStack().getMaxStackSize();
final long maxSize = ais.getDefinition().getMaxStackSize();
ais.setStackSize( maxSize );
ais = this.getCellInventory().extractItems( ais, Actionable.SIMULATE, this.getActionSource() );
@@ -1020,7 +1021,7 @@ public abstract class AEBaseContainer extends Container
if( ais != null )
{
player.inventory.setItemStack( ais.getItemStack() );
player.inventory.setItemStack( ais.createItemStack() );
}
else
{
@@ -1050,7 +1051,7 @@ public abstract class AEBaseContainer extends Container
case CREATIVE_DUPLICATE:
if( player.capabilities.isCreativeMode && slotItem != null )
{
final ItemStack is = slotItem.getItemStack();
final ItemStack is = slotItem.createItemStack();
is.setCount( is.getMaxStackSize() );
player.inventory.setItemStack( is );
this.updateHeld( player );
@@ -1069,7 +1070,7 @@ public abstract class AEBaseContainer extends Container
for( int slotNum = 0; slotNum < playerInv; slotNum++ )
{
IAEItemStack ais = slotItem.copy();
ItemStack myItem = ais.getItemStack();
ItemStack myItem = ais.createItemStack();
ais.setStackSize( myItem.getMaxStackSize() );
@@ -1085,7 +1086,7 @@ public abstract class AEBaseContainer extends Container
ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
if( ais != null )
{
adp.addItems( ais.getItemStack() );
adp.addItems( ais.createItemStack() );
}
else
{
@@ -1128,7 +1129,7 @@ public abstract class AEBaseContainer extends Container
{
return ItemStack.EMPTY;
}
return ais.getItemStack();
return ais.createItemStack();
}
private void updateSlot( final Slot clickSlot )
@@ -240,8 +240,8 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
{
if( i.hasNext() )
{
final ItemStack g = i.next().getItemStack();
g.setCount( 1 );
// TODO: check if ok
final ItemStack g = i.next().asItemStackRepresentation();
ItemHandlerUtil.setStackInSlot( inv, x, g );
}
else
@@ -27,13 +27,13 @@ import net.minecraft.world.World;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotInaccessible;
import appeng.me.helpers.PlayerSource;
import appeng.tile.inventory.AppEngInternalInventory;
@@ -69,7 +69,7 @@ public class ContainerCraftAmount extends AEBaseContainer
return this.getPlayerInv().player.world;
}
public BaseActionSource getActionSrc()
public IActionSource getActionSrc()
{
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
}
@@ -44,9 +44,8 @@ import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.ITerminalHost;
@@ -58,8 +57,8 @@ import appeng.core.AELog;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.me.helpers.PlayerSource;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
@@ -353,15 +352,13 @@ public class ContainerCraftConfirm extends AEBaseContainer
this.setAutoStart( false );
if( g != null && originalGui != null && this.getOpenContext() != null )
{
NetworkHandler.instance().sendTo( new PacketSwitchGuis( originalGui ), (EntityPlayerMP) this.getInventoryPlayer().player );
final TileEntity te = this.getOpenContext().getTile();
Platform.openGUI( this.getInventoryPlayer().player, te, this.getOpenContext().getSide(), originalGui );
}
}
}
private BaseActionSource getActionSrc()
private IActionSource getActionSrc()
{
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
}
@@ -28,16 +28,14 @@ import net.minecraft.inventory.IContainerListener;
import appeng.api.AEApi;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.CraftingItemList;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AEPartLocation;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.core.AELog;
@@ -65,15 +63,11 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
public ContainerCraftingCPU( final InventoryPlayer ip, final Object te )
{
super( ip, te );
final IGridHost host = (IGridHost) ( te instanceof IGridHost ? te : null );
final IActionHost host = (IActionHost) ( te instanceof IActionHost ? te : null );
if( host != null )
if( host != null && host.getActionableNode() != null )
{
this.findNode( host, AEPartLocation.INTERNAL );
for( final AEPartLocation d : AEPartLocation.SIDE_LOCATIONS )
{
this.findNode( host, d );
}
this.setNetwork( host.getActionableNode().getGrid() );
}
if( te instanceof TileCraftingTile )
@@ -87,18 +81,6 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
}
}
private void findNode( final IGridHost host, final AEPartLocation d )
{
if( this.getNetwork() == null )
{
final IGridNode node = host.getGridNode( d );
if( node != null )
{
this.setNetwork( node.getGrid() );
}
}
}
protected void setCPU( final ICraftingCPU c )
{
if( c == this.getMonitor() )
@@ -238,7 +220,7 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
}
@Override
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource actionSource )
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource )
{
for( IAEItemStack is : change )
{
@@ -24,6 +24,7 @@ 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.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
@@ -46,6 +47,7 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 1 );
private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
private final SlotCraftingTerm outputSlot;
private IRecipe currentRecipe;
public ContainerCraftingTerm( final InventoryPlayer ip, final ITerminalHost monitorable )
{
@@ -85,8 +87,21 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
ic.setInventorySlotContents( x, this.craftingSlots[x].getStack() );
}
this.outputSlot.putStack( CraftingManager.findMatchingResult( ic, this.getPlayerInv().player.world ) );
super.onCraftMatrixChanged( inventory );
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
@@ -116,4 +131,9 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
{
return true;
}
public IRecipe getCurrentRecipe()
{
return this.currentRecipe;
}
}
@@ -135,13 +135,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
{
final boolean matchA = ( top.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
( bot.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
( ( bot.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
final boolean matchB = ( bot.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
( top.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
( ( top.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) ) );
if( matchA || matchB )
{
@@ -50,6 +50,7 @@ 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.inv.WrapperFilteredItemHandler;
import appeng.util.inv.WrapperRangeItemHandler;
import appeng.util.inv.filter.IAEItemFilter;
@@ -207,7 +208,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
final ItemStack is = inv.server.getStackInSlot( slot );
final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty();
final InventoryAdaptor playerHand = InventoryAdaptor.getAdaptor( player );
final InventoryAdaptor playerHand = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) );
final IItemHandler theSlot = new WrapperFilteredItemHandler( new WrapperRangeItemHandler( inv.server, slot, slot + 1 ), new PatternSlotFilter() );
final InventoryAdaptor interfaceSlot = new AdaptorItemHandler( theSlot );
@@ -47,7 +47,8 @@ import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.parts.IPart;
import appeng.api.storage.IMEMonitor;
@@ -122,9 +123,22 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
{
this.setPowerSource( (IEnergySource) monitorable );
}
else if( monitorable instanceof IGridHost )
else if( monitorable instanceof IGridHost || monitorable instanceof IActionHost )
{
final IGridNode node = ( (IGridHost) monitorable ).getGridNode( AEPartLocation.INTERNAL );
final IGridNode node;
if( monitorable instanceof IGridHost )
{
node = ( (IGridHost) monitorable ).getGridNode( AEPartLocation.INTERNAL );
}
else if( monitorable instanceof IActionHost )
{
node = ( (IActionHost) monitorable ).getActionableNode();
}
else
{
node = null;
}
if( node != null )
{
this.networkNode = node;
@@ -374,7 +388,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
}
@Override
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource source )
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source )
{
for( final IAEItemStack is : change )
{
@@ -26,7 +26,6 @@ import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.util.Platform;
public class ContainerMEPortableCell extends ContainerMEMonitorable
@@ -67,7 +66,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
{
if( !currentItem.isEmpty() )
{
if( Platform.itemComparisons().isEqualItem( this.civ.getItemStack(), currentItem ) )
if( ItemStack.areItemsEqual( this.civ.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.civ.getItemStack() );
}
@@ -73,7 +73,7 @@ public class ContainerNetworkTool extends AEBaseContainer
{
if( !currentItem.isEmpty() )
{
if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) )
if( ItemStack.areItemsEqual( this.toolInv.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
}
@@ -43,7 +43,6 @@ import net.minecraftforge.items.wrapper.PlayerInvWrapper;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.networking.security.MachineSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
@@ -59,6 +58,7 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.core.sync.packets.PacketPatternSlot;
import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.me.helpers.MachineSource;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.InventoryAdaptor;
@@ -364,7 +364,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
inv = playerInv;
}
if( !inv.simulateAdd( out.getItemStack() ).isEmpty() )
if( !inv.simulateAdd( out.createItemStack() ).isEmpty() )
{
return;
}
@@ -374,7 +374,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
if( extracted != null )
{
inv.addItems( extracted.getItemStack() );
inv.addItems( extracted.createItemStack() );
if( p instanceof EntityPlayerMP )
{
this.updateHeld( (EntityPlayerMP) p );
@@ -388,10 +388,10 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < 9; x++ )
{
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].getItemStack() );
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].createItemStack() );
}
final IRecipe r = Platform.findMatchingRecipe( ic, p.world );
final IRecipe r = CraftingManager.findMatchingRecipe( ic, p.world );
if( r == null )
{
@@ -413,7 +413,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
}
}
final IRecipe rr = Platform.findMatchingRecipe( real, p.world );
final IRecipe rr = CraftingManager.findMatchingRecipe( real, p.world );
if( rr == r && Platform.itemComparisons().isSameItem( rr.getCraftingResult( real ), is ) )
{
@@ -73,7 +73,7 @@ public class ContainerQuartzKnife extends AEBaseContainer
{
if( !currentItem.isEmpty() )
{
if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) )
if( ItemStack.areItemsEqual( this.toolInv.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
}
@@ -110,7 +110,7 @@ public class ContainerQuartzKnife extends AEBaseContainer
@Override
public ItemStack getStack()
{
final IItemHandler baseInv = getItemHandler();
final IItemHandler baseInv = this.getItemHandler();
final ItemStack input = baseInv.getStackInSlot( 0 );
if( input == ItemStack.EMPTY )
{
@@ -137,10 +137,10 @@ public class ContainerQuartzKnife extends AEBaseContainer
@Nonnull
public ItemStack decrStackSize( int amount )
{
ItemStack ret = getStack();
ItemStack ret = this.getStack();
if( !ret.isEmpty() )
{
makePlate();
this.makePlate();
}
return ret;
}
@@ -150,21 +150,21 @@ public class ContainerQuartzKnife extends AEBaseContainer
{
if( stack.isEmpty() )
{
makePlate();
this.makePlate();
}
}
private void makePlate()
{
if( !getItemHandler().extractItem( 0, 1, false ).isEmpty() )
if( !this.getItemHandler().extractItem( 0, 1, false ).isEmpty() )
{
final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack();
item.damageItem( 1, getPlayerInv().player );
item.damageItem( 1, ContainerQuartzKnife.this.getPlayerInv().player );
if( item.getCount() == 0 )
{
getPlayerInv().mainInventory.add( getPlayerInv().currentItem, ItemStack.EMPTY );
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( getPlayerInv().player, item, null ) );
ContainerQuartzKnife.this.getPlayerInv().mainInventory.add( ContainerQuartzKnife.this.getPlayerInv().currentItem, ItemStack.EMPTY );
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( ContainerQuartzKnife.this.getPlayerInv().player, item, null ) );
}
}
}
@@ -26,6 +26,7 @@ import appeng.api.networking.IGrid;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.spatial.ISpatialCache;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotOutput;
@@ -48,6 +49,13 @@ public class ContainerSpatialIOPort extends AEBaseContainer
private IGrid network;
private int delay = 40;
@GuiSync( 31 )
public int xSize;
@GuiSync( 32 )
public int ySize;
@GuiSync( 33 )
public int zSize;
public ContainerSpatialIOPort( final InventoryPlayer ip, final TileSpatialIOPort spatialIOPort )
{
super( ip, spatialIOPort, null );
@@ -85,6 +93,22 @@ public class ContainerSpatialIOPort extends AEBaseContainer
this.setMaxPower( (long) ( 100.0 * eg.getMaxStoredPower() ) );
this.setRequiredPower( (long) ( 100.0 * sc.requiredPower() ) );
this.setEfficency( (long) ( 100.0f * sc.currentEfficiency() ) );
final DimensionalCoord min = sc.getMin();
final DimensionalCoord max = sc.getMax();
if( min != null && max != null && sc.isValidRegion() )
{
this.xSize = sc.getMax().x - sc.getMin().x - 1;
this.ySize = sc.getMax().y - sc.getMin().y - 1;
this.zSize = sc.getMax().z - sc.getMin().z - 1;
}
else
{
this.xSize = 0;
this.ySize = 0;
this.zSize = 0;
}
}
}
}
@@ -165,8 +165,8 @@ public class ContainerStorageBus extends ContainerUpgradeable
{
if( i.hasNext() && this.isSlotEnabled( ( x / 9 ) - 2 ) )
{
final ItemStack g = i.next().getItemStack();
g.setCount( 1 );
// TODO: check if ok
final ItemStack g = i.next().asItemStackRepresentation();
ItemHandlerUtil.setStackInSlot( inv, x, g );
}
else
@@ -245,7 +245,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
{
if( !currentItem.isEmpty() )
{
if( Platform.itemComparisons().isEqualItem( this.tbInventory.getItemStack(), currentItem ) )
if( ItemStack.areItemsEqual( this.tbInventory.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.tbSlot, this.tbInventory.getItemStack() );
}
@@ -24,6 +24,7 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import appeng.util.helpers.ItemHandlerUtil;
@@ -149,7 +150,7 @@ public class AppEngCraftingSlot extends AppEngSlot
ic.setInventorySlotContents( x, this.craftMatrix.getStackInSlot( x ) );
}
final NonNullList<ItemStack> aitemstack = CraftingManager.getRemainingItems( ic, playerIn.world );
final NonNullList<ItemStack> aitemstack = this.getRemainingItems( ic, playerIn.world );
ItemHandlerUtil.copy( ic, this.craftMatrix, false );
@@ -195,4 +196,10 @@ public class AppEngCraftingSlot extends AppEngSlot
return super.decrStackSize( par1 );
}
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
protected NonNullList<ItemStack> getRemainingItems( InventoryCrafting ic, World world )
{
return CraftingManager.getRemainingItems( ic, world );
}
}
@@ -79,7 +79,7 @@ public class AppEngSlot extends Slot
public void clearStack()
{
super.putStack( ItemStack.EMPTY );
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, ItemStack.EMPTY );
}
@Override
@@ -112,7 +112,7 @@ public class AppEngSlot extends Slot
return this.getDisplayStack();
}
return this.itemHandler.getStackInSlot( index );
return this.itemHandler.getStackInSlot( this.index );
}
@Override
@@ -120,7 +120,7 @@ public class AppEngSlot extends Slot
{
if( this.isSlotEnabled() )
{
ItemHandlerUtil.setStackInSlot( this.itemHandler, index, stack );
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, stack );
this.onSlotChanged();
if( this.getContainer() != null )
@@ -151,7 +151,7 @@ public class AppEngSlot extends Slot
@Override
public int getItemStackLimit( @Nonnull ItemStack stack )
{
return Math.min( getSlotStackLimit(), stack.getMaxStackSize() );
return Math.min( this.getSlotStackLimit(), stack.getMaxStackSize() );
}
@Override
@@ -159,7 +159,7 @@ public class AppEngSlot extends Slot
{
if( this.isSlotEnabled() )
{
return !this.itemHandler.extractItem( index, 1, true ).isEmpty();
return !this.itemHandler.extractItem( this.index, 1, true ).isEmpty();
}
return false;
}
@@ -168,7 +168,7 @@ public class AppEngSlot extends Slot
@Nonnull
public ItemStack decrStackSize( int amount )
{
return this.itemHandler.extractItem( index, amount, false );
return this.itemHandler.extractItem( this.index, amount, false );
}
@Override
@@ -191,7 +191,7 @@ public class AppEngSlot extends Slot
public ItemStack getDisplayStack()
{
return this.itemHandler.getStackInSlot( index );
return this.itemHandler.getStackInSlot( this.index );
}
public float getOpacityOfIcon()
@@ -27,18 +27,22 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
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.items.IItemHandler;
import appeng.api.config.Actionable;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull;
import appeng.container.implementations.ContainerCraftingTerm;
import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.InventoryAction;
import appeng.items.storage.ItemViewCell;
@@ -57,12 +61,12 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
private final IItemHandler craftInv;
private final IItemHandler pattern;
private final BaseActionSource mySrc;
private final IActionSource mySrc;
private final IEnergySource energySrc;
private final IStorageMonitorable storage;
private final IContainerCraftingPacket container;
public SlotCraftingTerm( final EntityPlayer player, final BaseActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp )
public SlotCraftingTerm( final EntityPlayer player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp )
{
super( player, cMatrix, output, 0, x, y );
this.energySrc = energySrc;
@@ -130,7 +134,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
return;
}
final ItemStack rs = Platform.cloneItemStack( this.getStack() );
final ItemStack rs = this.getStack().copy();
if( rs.isEmpty() )
{
return;
@@ -153,6 +157,41 @@ 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 )
{
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 CraftingManager.findMatchingRecipe( ic, world );
}
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
@Override
protected NonNullList<ItemStack> getRemainingItems( InventoryCrafting ic, World world )
{
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().getRemainingItems( ic );
}
}
return CraftingManager.getRemainingItems( ic, world );
}
private int capCraftingAttempts( final int maxTimesToCraft )
{
return maxTimesToCraft;
@@ -163,7 +202,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
// update crafting matrix...
ItemStack is = this.getStack();
if( !is.isEmpty() && Platform.itemComparisons().isEqualItem( request, is ) )
if( !is.isEmpty() && ItemStack.areItemsEqual( request, is ) )
{
final ItemStack[] set = new ItemStack[this.getPattern().getSlots()];
// Safeguard for empty slots in the inventory for now
@@ -178,7 +217,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
ic.setInventorySlotContents( x, this.getPattern().getStackInSlot( x ) );
}
final IRecipe r = Platform.findMatchingRecipe( ic, p.world );
final IRecipe r = this.findRecipe( ic, p.world );
if( r == null )
{
@@ -270,7 +309,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
final IAEItemStack fail = inv.injectItems( AEItemStack.create( set[x] ), Actionable.MODULATE, this.mySrc );
if( fail != null )
{
drops.add( fail.getItemStack() );
drops.add( fail.createItemStack() );
}
}
}
@@ -27,7 +27,7 @@ import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IStorageMonitorable;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.packets.PacketPatternSlot;
@@ -40,7 +40,7 @@ public class SlotPatternTerm extends SlotCraftingTerm
private final int groupNum;
private final IOptionalSlotHost host;
public SlotPatternTerm( final EntityPlayer player, final BaseActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final IContainerCraftingPacket c )
public SlotPatternTerm( final EntityPlayer player, final IActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final IContainerCraftingPacket c )
{
super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c );

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