Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e15b23506 | |||
| 2ed7a5598a | |||
| 1c05dd5834 | |||
| 632d124359 | |||
| 829c18e2bb | |||
| d3a5be7ed6 | |||
| 217cbf0982 | |||
| 4dd0a4cd96 | |||
| 54c0ce43ea | |||
| bd8f43acbf | |||
| 970630a90d | |||
| 771a944058 | |||
| db1cd8c312 | |||
| 375e1efb15 | |||
| 955fcac92a | |||
| 216e2cb1e3 | |||
| 53f5724657 | |||
| a3269826f9 | |||
| 1a918be658 | |||
| 90130e72aa | |||
| c8f10d92bb | |||
| 548af3c6cc | |||
| 98b9380494 | |||
| bbf4d4a9ce | |||
| 1513ba3f6a | |||
| f03f8ec432 | |||
| e1dcd588b7 | |||
| 8338a7d13e | |||
| b8e685b1b6 | |||
| d84500c5b7 | |||
| a1679c944b | |||
| a3a39201d1 | |||
| d788da687e |
+7
-8
@@ -7,23 +7,22 @@ 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.9-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 #
|
||||
|
||||
@@ -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}"
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
+18
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
* 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
|
||||
@@ -16,18 +16,26 @@
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.tile.events;
|
||||
package appeng.api.storage;
|
||||
|
||||
|
||||
public enum TileEventType
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
public interface ISpatialDimension
|
||||
{
|
||||
WORLD_NBT_READ,
|
||||
WORLD_NBT_WRITE,
|
||||
World getWorld();
|
||||
|
||||
/**
|
||||
* Methods annotated with this need to return a boolean
|
||||
*/
|
||||
NETWORK_READ,
|
||||
int createNewCellDimension( BlockPos contentSize, int playerId );
|
||||
|
||||
NETWORK_WRITE
|
||||
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();
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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() && player.inventory.getItemStack().isEmpty() )
|
||||
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()
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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,7 +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 ) );
|
||||
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
|
||||
@@ -115,4 +131,9 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public IRecipe getCurrentRecipe()
|
||||
{
|
||||
return this.currentRecipe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.slotNumber, ItemStack.EMPTY );
|
||||
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -95,8 +95,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
private final int[] levelByStacks = { 1, 10, 100, 1000 };
|
||||
|
||||
// Spatial IO/Dimension
|
||||
private int storageBiomeID = -1;
|
||||
private int storageProviderID = -1;
|
||||
private int storageDimensionID = -1;
|
||||
private double spatialPowerExponent = 1.35;
|
||||
private double spatialPowerMultiplier = 1250.0;
|
||||
|
||||
@@ -251,8 +251,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
|
||||
if( this.isFeatureEnabled( AEFeature.SPATIAL_IO ) )
|
||||
{
|
||||
this.storageBiomeID = this.get( "spatialio", "storageBiomeID", this.storageBiomeID ).getInt( this.storageBiomeID );
|
||||
this.storageProviderID = this.get( "spatialio", "storageProviderID", this.storageProviderID ).getInt( this.storageProviderID );
|
||||
this.storageDimensionID = this.get( "spatialio", "storageDimensionID", this.storageDimensionID ).getInt( this.storageDimensionID );
|
||||
this.spatialPowerMultiplier = this.get( "spatialio", "spatialPowerMultiplier", this.spatialPowerMultiplier ).getDouble(
|
||||
this.spatialPowerMultiplier );
|
||||
this.spatialPowerExponent = this.get( "spatialio", "spatialPowerExponent", this.spatialPowerExponent ).getDouble( this.spatialPowerExponent );
|
||||
@@ -397,8 +397,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
{
|
||||
if( this.isFeatureEnabled( AEFeature.SPATIAL_IO ) )
|
||||
{
|
||||
this.get( "spatialio", "storageBiomeID", this.storageBiomeID ).set( this.storageBiomeID );
|
||||
this.get( "spatialio", "storageProviderID", this.storageProviderID ).set( this.storageProviderID );
|
||||
this.get( "spatialio", "storageDimensionID", this.storageDimensionID ).set( this.storageDimensionID );
|
||||
}
|
||||
|
||||
this.get( "Client", "PowerUnit", this.selectedPowerUnit.name(), this.getListComment( this.selectedPowerUnit ) ).set( this.selectedPowerUnit.name() );
|
||||
@@ -619,16 +619,16 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
return this.levelByStacks;
|
||||
}
|
||||
|
||||
public int getStorageBiomeID()
|
||||
{
|
||||
return this.storageBiomeID;
|
||||
}
|
||||
|
||||
public int getStorageProviderID()
|
||||
{
|
||||
return this.storageProviderID;
|
||||
}
|
||||
|
||||
public int getStorageDimensionID()
|
||||
{
|
||||
return this.storageDimensionID;
|
||||
}
|
||||
|
||||
public double getSpatialPowerExponent()
|
||||
{
|
||||
return this.spatialPowerExponent;
|
||||
@@ -766,13 +766,13 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
|
||||
// Setters keep visibility as low as possible.
|
||||
|
||||
void setStorageBiomeID( int id )
|
||||
{
|
||||
this.storageBiomeID = id;
|
||||
}
|
||||
|
||||
void setStorageProviderID( int id )
|
||||
{
|
||||
this.storageProviderID = id;
|
||||
}
|
||||
|
||||
void setStorageDimensionID( int id )
|
||||
{
|
||||
this.storageDimensionID = id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,11 @@ public final class AppEng
|
||||
return this.registration.storageDimensionType;
|
||||
}
|
||||
|
||||
public int getStorageDimensionID()
|
||||
{
|
||||
return this.registration.storageDimensionID;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void preInit( final FMLPreInitializationEvent event )
|
||||
{
|
||||
@@ -170,7 +175,7 @@ public final class AppEng
|
||||
{
|
||||
IntegrationRegistry.INSTANCE.add( type );
|
||||
}
|
||||
|
||||
|
||||
this.registration.preInitialize( event );
|
||||
|
||||
if( Platform.isClient() )
|
||||
|
||||
@@ -35,10 +35,13 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
@@ -86,10 +89,8 @@ import appeng.core.features.registries.cell.CreativeCellHandler;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.stats.PlayerStatsRegistration;
|
||||
import appeng.core.worlddata.SpatialDimensionManager;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.items.materials.ItemMaterial;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.loot.ChestLoot;
|
||||
@@ -128,6 +129,7 @@ import appeng.worldgen.QuartzWorldGen;
|
||||
final class Registration
|
||||
{
|
||||
DimensionType storageDimensionType;
|
||||
int storageDimensionID;
|
||||
Biome storageBiome;
|
||||
|
||||
private File recipeDirectory;
|
||||
@@ -159,28 +161,29 @@ final class Registration
|
||||
definitions.getRegistry().getBootstrapComponents( IPreInitComponent.class ).forEachRemaining( b -> b.preInitialize( event.getSide() ) );
|
||||
}
|
||||
|
||||
private void registerSpatial( final boolean force, IForgeRegistry<Biome> registry )
|
||||
private void registerSpatialBiome( IForgeRegistry<Biome> registry )
|
||||
{
|
||||
if( !AEConfig.instance().isFeatureEnabled( AEFeature.SPATIAL_IO ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final AEConfig config = AEConfig.instance();
|
||||
|
||||
if( this.storageBiome == null )
|
||||
{
|
||||
this.storageBiome = new BiomeGenStorage();
|
||||
}
|
||||
|
||||
registry.register( this.storageBiome.setRegistryName( "appliedenergistics2:storage_biome" ) );
|
||||
}
|
||||
|
||||
if( config.getStorageProviderID() != -1 )
|
||||
private void registerSpatialDimension()
|
||||
{
|
||||
final AEConfig config = AEConfig.instance();
|
||||
if( !config.isFeatureEnabled( AEFeature.SPATIAL_IO ) )
|
||||
{
|
||||
this.storageDimensionType = DimensionType.register( "Storage Cell", "_cell", config.getStorageProviderID(), StorageWorldProvider.class, false );
|
||||
return;
|
||||
}
|
||||
|
||||
if( config.getStorageProviderID() == -1 && force )
|
||||
if( config.getStorageProviderID() == -1 )
|
||||
{
|
||||
final Set<Integer> ids = new HashSet<>();
|
||||
for( DimensionType type : DimensionType.values() )
|
||||
@@ -188,17 +191,25 @@ final class Registration
|
||||
ids.add( type.getId() );
|
||||
}
|
||||
|
||||
config.setStorageProviderID( -11 );
|
||||
|
||||
while( ids.contains( config.getStorageProviderID() ) )
|
||||
int newId = -11;
|
||||
while( ids.contains( newId ) )
|
||||
{
|
||||
config.setStorageProviderID( config.getStorageProviderID() - 1 );
|
||||
--newId;
|
||||
}
|
||||
|
||||
this.storageDimensionType = DimensionType.register( "Storage Cell", "_cell", config.getStorageProviderID(), StorageWorldProvider.class, false );
|
||||
|
||||
config.setStorageProviderID( newId );
|
||||
config.save();
|
||||
}
|
||||
|
||||
this.storageDimensionType = DimensionType.register( "Storage Cell", "_cell", config.getStorageProviderID(), StorageWorldProvider.class, true );
|
||||
|
||||
if( config.getStorageDimensionID() == -1 )
|
||||
{
|
||||
config.setStorageDimensionID( DimensionManager.getNextFreeDimId() );
|
||||
config.save();
|
||||
}
|
||||
this.storageDimensionID = config.getStorageDimensionID();
|
||||
|
||||
DimensionManager.registerDimension( this.storageDimensionID, this.storageDimensionType );
|
||||
}
|
||||
|
||||
private void registerCraftHandlers( final IRecipeHandlerRegistry registry )
|
||||
@@ -284,7 +295,7 @@ final class Registration
|
||||
public void registerBiomes( RegistryEvent.Register<Biome> event )
|
||||
{
|
||||
final IForgeRegistry<Biome> registry = event.getRegistry();
|
||||
this.registerSpatial( false, registry );
|
||||
this.registerSpatialBiome( registry );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -355,6 +366,16 @@ final class Registration
|
||||
recipeHandler.injectRecipes();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void attachSpatialDimensionManager( AttachCapabilitiesEvent<World> event )
|
||||
{
|
||||
if( AEConfig.instance()
|
||||
.isFeatureEnabled( AEFeature.SPATIAL_IO ) && event.getObject() == DimensionManager.getWorld( AEConfig.instance().getStorageDimensionID() ) )
|
||||
{
|
||||
event.addCapability( new ResourceLocation( "appliedenergistics2:spatial_dimension_manager" ), new SpatialDimensionManager( event.getObject() ) );
|
||||
}
|
||||
}
|
||||
|
||||
void postInit( final FMLPostInitializationEvent event )
|
||||
{
|
||||
final IRegistryContainer registries = Api.INSTANCE.registries();
|
||||
@@ -363,6 +384,8 @@ final class Registration
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
final IItems items = definitions.items();
|
||||
|
||||
registerSpatialDimension();
|
||||
|
||||
// default settings..
|
||||
( (P2PTunnelRegistry) registries.p2pTunnel() ).configure();
|
||||
|
||||
@@ -469,6 +492,7 @@ final class Registration
|
||||
/*
|
||||
* White List Vanilla...
|
||||
*/
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityBanner.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityBeacon.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityBrewingStand.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityChest.class );
|
||||
@@ -480,15 +504,15 @@ final class Registration
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityEnchantmentTable.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityEnderChest.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityEndPortal.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySkull.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityFurnace.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityMobSpawner.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySign.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityPiston.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityFlowerPot.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityFurnace.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityHopper.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityMobSpawner.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityPiston.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityShulkerBox.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySign.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySkull.class );
|
||||
|
||||
/*
|
||||
* Whitelist AE2
|
||||
|
||||
@@ -30,7 +30,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.IMEInventory;
|
||||
import appeng.api.storage.IStorageHelper;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
@@ -90,13 +90,13 @@ public class ApiStorage implements IStorageHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredExtraction( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack request, final BaseActionSource src )
|
||||
public IAEItemStack poweredExtraction( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack request, final IActionSource src )
|
||||
{
|
||||
return Platform.poweredExtraction( energy, cell, request, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredInsert( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack input, final BaseActionSource src )
|
||||
public IAEItemStack poweredInsert( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack input, final IActionSource src )
|
||||
{
|
||||
return Platform.poweredInsert( energy, cell, input, src );
|
||||
}
|
||||
|
||||
@@ -58,6 +58,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import appeng.api.features.IGrinderRecipeBuilder;
|
||||
import appeng.api.features.IGrinderRegistry;
|
||||
import appeng.core.api.IIMCProcessor;
|
||||
|
||||
|
||||
@@ -96,12 +99,26 @@ public class IMCGrinder implements IIMCProcessor
|
||||
}
|
||||
|
||||
final float chance = msg.getFloat( "chance" );
|
||||
final IGrinderRegistry grinderRegistry = AEApi.instance().registries().grinder();
|
||||
final IGrinderRecipeBuilder builder = grinderRegistry.builder();
|
||||
final IGrinderRecipe grinderRecipe = builder.withInput( in )
|
||||
.withOutput( out )
|
||||
.withFirstOptional( optional, chance )
|
||||
.withTurns( turns )
|
||||
.build();
|
||||
|
||||
AEApi.instance().registries().grinder().addRecipe( in, out, optional, chance, turns );
|
||||
grinderRegistry.addRecipe( grinderRecipe );
|
||||
}
|
||||
else
|
||||
{
|
||||
AEApi.instance().registries().grinder().addRecipe( in, out, turns );
|
||||
final IGrinderRegistry grinderRegistry = AEApi.instance().registries().grinder();
|
||||
final IGrinderRecipeBuilder builder = grinderRegistry.builder();
|
||||
final IGrinderRecipe grinderRecipe = builder.withInput( in )
|
||||
.withOutput( out )
|
||||
.withTurns( turns )
|
||||
.build();
|
||||
|
||||
grinderRegistry.addRecipe( grinderRecipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
import appeng.recipes.ores.IOreListener;
|
||||
import appeng.recipes.ores.OreDictionaryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmoRegistry
|
||||
@@ -52,7 +51,7 @@ public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmo
|
||||
{
|
||||
for( final ItemStack o : this.DamageModifiers.keySet() )
|
||||
{
|
||||
if( Platform.itemComparisons().isEqualItem( o, is ) )
|
||||
if( ItemStack.areItemsEqual( o, is ) )
|
||||
{
|
||||
return this.DamageModifiers.get( o ).floatValue();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import appeng.api.definitions.IParts;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
@@ -216,7 +215,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
return this.tunnels.get( is );
|
||||
}
|
||||
|
||||
if( Platform.itemComparisons().isEqualItem( is, trigger ) )
|
||||
if( ItemStack.areItemsEqual( is, trigger ) )
|
||||
{
|
||||
return this.tunnels.get( is );
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
@@ -33,7 +35,10 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import appeng.api.features.IGrinderRecipeBuilder;
|
||||
import appeng.api.features.IGrinderRegistry;
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.api.features.IInscriberRecipeBuilder;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.recipes.ores.IOreListener;
|
||||
@@ -83,58 +88,26 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
OreDictionaryHandler.INSTANCE.observe( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrinderRecipeBuilder builder()
|
||||
{
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addRecipe( IGrinderRecipe recipe )
|
||||
{
|
||||
Preconditions.checkNotNull( recipe, "Cannot add null as recipe." );
|
||||
|
||||
return this.injectRecipe( recipe );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IGrinderRecipe> getRecipes()
|
||||
{
|
||||
return Collections.unmodifiableCollection( this.recipes.values() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe( final ItemStack in, final ItemStack out, final int cost )
|
||||
{
|
||||
Preconditions.checkNotNull( in, "Null is not accepted as input itemstack." );
|
||||
Preconditions.checkNotNull( out, "Null is not accepted as output itemstack." );
|
||||
Preconditions.checkArgument( cost > 0, "Turns must be > 0" );
|
||||
|
||||
this.log( "Allow Grinding of '%1$s' to '%2$s' for %3$d turn", Platform.getItemDisplayName( in ), Platform.getItemDisplayName( out ), cost );
|
||||
|
||||
this.injectRecipe( new AppEngGrinderRecipe( this.copy( in ), this.copy( out ), cost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe( final ItemStack in, final ItemStack out, final ItemStack optional, final float chance, final int cost )
|
||||
{
|
||||
Preconditions.checkNotNull( in, "Null is not accepted as input itemstack." );
|
||||
Preconditions.checkNotNull( out, "Null is not accepted as output itemstack." );
|
||||
Preconditions.checkNotNull( optional, "Null is not accepted as optional itemstack." );
|
||||
Preconditions.checkArgument( chance >= 0.0 && chance <= 1.0, "chance must be within 0.0 - 1.0." );
|
||||
Preconditions.checkArgument( cost > 0, "Turns must be > 0" );
|
||||
|
||||
this.log( "Allow Grinding of '%1$s' to '%2$s' with optional '%3$s' @ %4$.2f for %5$d", Platform.getItemDisplayName( in ),
|
||||
Platform.getItemDisplayName( out ), Platform.getItemDisplayName( optional ), chance, cost );
|
||||
|
||||
this.injectRecipe( new AppEngGrinderRecipe( this.copy( in ), this.copy( out ), this.copy( optional ), chance, cost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe( final ItemStack in, final ItemStack out, final ItemStack optional1, final float chance1, final ItemStack optional2, final float chance2, final int cost )
|
||||
{
|
||||
Preconditions.checkNotNull( in, "Null is not accepted as input itemstack." );
|
||||
Preconditions.checkNotNull( out, "Null is not accepted as output itemstack." );
|
||||
Preconditions.checkNotNull( optional1, "Null is not accepted as optional itemstack." );
|
||||
Preconditions.checkArgument( chance1 >= 0.0 && chance1 <= 1.0, "chance must be within 0.0 - 1.0." );
|
||||
Preconditions.checkNotNull( optional2, "Null is not accepted as optional2 itemstack." );
|
||||
Preconditions.checkArgument( chance2 >= 0.0 && chance2 <= 1.0, "chance2 must be within 0.0 - 1.0." );
|
||||
Preconditions.checkArgument( cost > 0, "Turns must be > 0" );
|
||||
|
||||
this.log( "Allow Grinding of '%1$s' to '%2$s' with optional '%3$s' @ %4$.2f and optional2 '%5$s' @ %6$.2f for %7$d", Platform.getItemDisplayName( in ),
|
||||
Platform.getItemDisplayName( out ), Platform.getItemDisplayName( optional1 ), chance1, Platform.getItemDisplayName( optional2 ), chance2,
|
||||
cost );
|
||||
|
||||
this.injectRecipe(
|
||||
new AppEngGrinderRecipe( this.copy( in ), this.copy( out ), this.copy( optional1 ), this.copy( optional2 ), chance1, chance2, cost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeRecipe( IGrinderRecipe recipe )
|
||||
{
|
||||
@@ -214,26 +187,19 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
}
|
||||
}
|
||||
|
||||
private void injectRecipe( final AppEngGrinderRecipe appEngGrinderRecipe )
|
||||
private boolean injectRecipe( final IGrinderRecipe grinderRecipe )
|
||||
{
|
||||
final CacheKey cacheKey = new CacheKey( appEngGrinderRecipe.getInput() );
|
||||
final CacheKey cacheKey = new CacheKey( grinderRecipe.getInput() );
|
||||
|
||||
if( this.recipes.containsKey( cacheKey ) )
|
||||
{
|
||||
this.log( "Tried to add duplicate recipe for '%1$s'", Platform.getItemDisplayName( appEngGrinderRecipe.getInput() ) );
|
||||
return;
|
||||
this.log( "Tried to add duplicate recipe for '%1$s'", Platform.getItemDisplayName( grinderRecipe.getInput() ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
this.recipes.put( cacheKey, appEngGrinderRecipe );
|
||||
}
|
||||
this.recipes.put( cacheKey, grinderRecipe );
|
||||
|
||||
private ItemStack copy( final ItemStack is )
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
return is.copy();
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getDustToOreRatio( final String name )
|
||||
@@ -259,11 +225,25 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
{
|
||||
final ItemStack extra = is.copy();
|
||||
extra.setCount( ratio - 1 );
|
||||
this.addRecipe( item, is, extra, (float) ( AEConfig.instance().getOreDoublePercentage() / 100.0 ), 8 );
|
||||
|
||||
final IGrinderRecipeBuilder builder = this.builder();
|
||||
IGrinderRecipe grinderRecipe = builder.withInput( item )
|
||||
.withOutput( is )
|
||||
.withFirstOptional( extra, (float) ( AEConfig.instance().getOreDoublePercentage() / 100.0 ) )
|
||||
.withTurns( 8 )
|
||||
.build();
|
||||
|
||||
this.addRecipe( grinderRecipe );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.addRecipe( item, is, 8 );
|
||||
final IGrinderRecipeBuilder builder = this.builder();
|
||||
IGrinderRecipe grinderRecipe = builder.withInput( item )
|
||||
.withOutput( is )
|
||||
.withTurns( 8 )
|
||||
.build();
|
||||
|
||||
this.addRecipe( grinderRecipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,7 +260,13 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
|
||||
if( this.dusts.containsKey( name ) )
|
||||
{
|
||||
this.addRecipe( item, this.dusts.get( name ), 4 );
|
||||
final IGrinderRecipeBuilder builder = this.builder();
|
||||
IGrinderRecipe grinderRecipe = builder.withInput( item )
|
||||
.withOutput( this.dusts.get( name ) )
|
||||
.withTurns( 4 )
|
||||
.build();
|
||||
|
||||
this.addRecipe( grinderRecipe );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,6 +276,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( this.dusts.containsKey( name ) )
|
||||
{
|
||||
this.log( "Rejecting Dust: '%1$s'", Platform.getItemDisplayName( item ) );
|
||||
@@ -311,11 +298,25 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
{
|
||||
final ItemStack extra = is.copy();
|
||||
extra.setCount( ratio - 1 );
|
||||
this.addRecipe( d.getKey(), is, extra, (float) ( AEConfig.instance().getOreDoublePercentage() / 100.0 ), 8 );
|
||||
|
||||
final IGrinderRecipeBuilder builder = this.builder();
|
||||
final IGrinderRecipe grinderRecipe = builder.withInput( d.getKey() )
|
||||
.withOutput( is )
|
||||
.withFirstOptional( extra, (float) ( AEConfig.instance().getOreDoublePercentage() / 100.0 ) )
|
||||
.withTurns( 8 )
|
||||
.build();
|
||||
|
||||
this.addRecipe( grinderRecipe );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.addRecipe( d.getKey(), is, 8 );
|
||||
final IGrinderRecipeBuilder builder = this.builder();
|
||||
final IGrinderRecipe grinderRecipe = builder.withInput( d.getKey() )
|
||||
.withOutput( is )
|
||||
.withTurns( 8 )
|
||||
.build();
|
||||
|
||||
this.addRecipe( grinderRecipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,7 +325,13 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
{
|
||||
if( name.equals( d.getValue() ) )
|
||||
{
|
||||
this.addRecipe( d.getKey(), item, 4 );
|
||||
final IGrinderRecipeBuilder builder = this.builder();
|
||||
final IGrinderRecipe grinderRecipe = builder.withInput( d.getKey() )
|
||||
.withOutput( item )
|
||||
.withTurns( 4 )
|
||||
.build();
|
||||
|
||||
this.addRecipe( grinderRecipe );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,7 +372,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( obj == null || this.getClass() != obj.getClass() )
|
||||
if( obj == null || getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -393,4 +400,100 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal {@link IInscriberRecipeBuilder} implementation.
|
||||
* Needs to be adapted to represent a correct {@link IInscriberRecipe}
|
||||
*/
|
||||
private static final class Builder implements IGrinderRecipeBuilder
|
||||
{
|
||||
|
||||
private ItemStack in;
|
||||
private ItemStack out;
|
||||
|
||||
private float optionalChance;
|
||||
private ItemStack optionalOutput;
|
||||
|
||||
private float optionalChance2;
|
||||
private ItemStack optionalOutput2;
|
||||
|
||||
private int turns = 8;
|
||||
|
||||
@Override
|
||||
public IGrinderRecipeBuilder withInput( ItemStack input )
|
||||
{
|
||||
Preconditions.checkNotNull( input );
|
||||
Preconditions.checkArgument( !input.isEmpty(), "Input cannot be empty." );
|
||||
|
||||
this.in = this.copy( input );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrinderRecipeBuilder withOutput( ItemStack output )
|
||||
{
|
||||
Preconditions.checkNotNull( output );
|
||||
Preconditions.checkArgument( !output.isEmpty(), "Output cannot be empty." );
|
||||
|
||||
this.out = this.copy( output );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrinderRecipeBuilder withFirstOptional( ItemStack optional, float chance )
|
||||
{
|
||||
Preconditions.checkNotNull( optional );
|
||||
Preconditions.checkArgument( !optional.isEmpty(), "Optional cannot be empty." );
|
||||
Preconditions.checkArgument( chance >= 0 && chance <= 1.0 );
|
||||
|
||||
this.optionalOutput = this.copy( optional );
|
||||
this.optionalChance = chance;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrinderRecipeBuilder withSecondOptional( ItemStack optional, float chance )
|
||||
{
|
||||
Preconditions.checkNotNull( optional );
|
||||
Preconditions.checkArgument( !optional.isEmpty(), "Optional cannot be empty." );
|
||||
Preconditions.checkArgument( chance >= 0 && chance <= 1.0 );
|
||||
|
||||
this.optionalOutput2 = this.copy( optional );
|
||||
this.optionalChance2 = chance;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrinderRecipeBuilder withTurns( int turns )
|
||||
{
|
||||
Preconditions.checkArgument( turns > 0 );
|
||||
|
||||
this.turns = turns;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IGrinderRecipe build()
|
||||
{
|
||||
Preconditions.checkState( this.in != null, "Input itemstack must be defined." );
|
||||
Preconditions.checkState( this.out != null, "Output itemstack must be defined." );
|
||||
|
||||
return new AppEngGrinderRecipe( this.in, this.out, this.optionalOutput, this.optionalOutput2, this.optionalChance, this.optionalChance2, this.turns );
|
||||
}
|
||||
|
||||
private ItemStack copy( final ItemStack is )
|
||||
{
|
||||
if( is != null )
|
||||
{
|
||||
return is.copy();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
@@ -84,32 +86,43 @@ public final class InscriberRegistry implements IInscriberRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe( final IInscriberRecipe recipe )
|
||||
public boolean addRecipe( final IInscriberRecipe recipe )
|
||||
{
|
||||
if( recipe == null )
|
||||
Preconditions.checkNotNull( recipe, "Tried to add (null) as inscriber recipe to the registry." );
|
||||
|
||||
if( this.recipes.add( recipe ) )
|
||||
{
|
||||
throw new IllegalArgumentException( "Tried to add an invalid (null) inscriber recipe to the registry." );
|
||||
this.recipes.add( recipe );
|
||||
|
||||
recipe.getTopOptional().ifPresent( this.optionals::add );
|
||||
recipe.getBottomOptional().ifPresent( this.optionals::add );
|
||||
|
||||
this.inputs.addAll( recipe.getInputs() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
this.recipes.add( recipe );
|
||||
|
||||
recipe.getTopOptional().ifPresent( this.optionals::add );
|
||||
recipe.getBottomOptional().ifPresent( this.optionals::add );
|
||||
|
||||
this.inputs.addAll( recipe.getInputs() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRecipe( final IInscriberRecipe toBeRemovedRecipe )
|
||||
public boolean removeRecipe( final IInscriberRecipe toBeRemovedRecipe )
|
||||
{
|
||||
Preconditions.checkNotNull( toBeRemovedRecipe, "Tried to remove (null) from the registry." );
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
for( final Iterator<IInscriberRecipe> iterator = this.recipes.iterator(); iterator.hasNext(); )
|
||||
{
|
||||
final IInscriberRecipe recipe = iterator.next();
|
||||
if( recipe.equals( toBeRemovedRecipe ) )
|
||||
{
|
||||
changed = true;
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,6 +141,9 @@ public final class InscriberRegistry implements IInscriberRegistry
|
||||
@Override
|
||||
public Builder withInputs( @Nonnull final Collection<ItemStack> inputs )
|
||||
{
|
||||
Preconditions.checkNotNull( inputs );
|
||||
Preconditions.checkArgument( !inputs.isEmpty() );
|
||||
|
||||
this.inputs = new ArrayList<>( inputs.size() );
|
||||
this.inputs.addAll( inputs );
|
||||
|
||||
@@ -138,6 +154,9 @@ public final class InscriberRegistry implements IInscriberRegistry
|
||||
@Override
|
||||
public Builder withOutput( @Nonnull final ItemStack output )
|
||||
{
|
||||
Preconditions.checkNotNull( output );
|
||||
Preconditions.checkArgument( !output.isEmpty() );
|
||||
|
||||
this.output = output;
|
||||
|
||||
return this;
|
||||
@@ -147,6 +166,9 @@ public final class InscriberRegistry implements IInscriberRegistry
|
||||
@Override
|
||||
public Builder withTopOptional( @Nonnull final ItemStack topOptional )
|
||||
{
|
||||
Preconditions.checkNotNull( topOptional );
|
||||
Preconditions.checkArgument( !topOptional.isEmpty() );
|
||||
|
||||
this.topOptional = topOptional;
|
||||
|
||||
return this;
|
||||
@@ -156,6 +178,9 @@ public final class InscriberRegistry implements IInscriberRegistry
|
||||
@Override
|
||||
public Builder withBottomOptional( @Nonnull final ItemStack bottomOptional )
|
||||
{
|
||||
Preconditions.checkNotNull( bottomOptional );
|
||||
Preconditions.checkArgument( !bottomOptional.isEmpty() );
|
||||
|
||||
this.bottomOptional = bottomOptional;
|
||||
|
||||
return this;
|
||||
@@ -165,6 +190,8 @@ public final class InscriberRegistry implements IInscriberRegistry
|
||||
@Override
|
||||
public Builder withProcessType( @Nonnull final InscriberProcessType type )
|
||||
{
|
||||
Preconditions.checkNotNull( type );
|
||||
|
||||
this.type = type;
|
||||
|
||||
return this;
|
||||
@@ -174,26 +201,11 @@ public final class InscriberRegistry implements IInscriberRegistry
|
||||
@Override
|
||||
public IInscriberRecipe build()
|
||||
{
|
||||
if( this.inputs == null )
|
||||
{
|
||||
throw new IllegalStateException( "Input must be defined." );
|
||||
}
|
||||
if( this.inputs.isEmpty() )
|
||||
{
|
||||
throw new IllegalStateException( "Input must have a size." );
|
||||
}
|
||||
if( this.output.isEmpty() )
|
||||
{
|
||||
throw new IllegalStateException( "Output must be defined." );
|
||||
}
|
||||
if( this.topOptional.isEmpty() && this.bottomOptional.isEmpty() )
|
||||
{
|
||||
throw new IllegalStateException( "One optional must be defined." );
|
||||
}
|
||||
if( this.type == null )
|
||||
{
|
||||
throw new IllegalStateException( "Process type must be defined." );
|
||||
}
|
||||
Preconditions.checkState( this.inputs != null, "Input must be defined." );
|
||||
Preconditions.checkState( !this.inputs.isEmpty(), "Input must have a size." );
|
||||
Preconditions.checkState( !this.output.isEmpty(), "Output cannot be empty." );
|
||||
Preconditions.checkState( !this.topOptional.isEmpty() || !this.bottomOptional.isEmpty(), "One optional must be defined." );
|
||||
Preconditions.checkState( this.type != null, "Process type must be defined." );
|
||||
|
||||
return new InscriberRecipe( this.inputs, this.output, this.topOptional, this.bottomOptional, this.type );
|
||||
}
|
||||
|
||||
@@ -92,7 +92,10 @@ public enum GuiText
|
||||
FETunnel,
|
||||
PressureTunnel,
|
||||
|
||||
// spatial
|
||||
StoredSize,
|
||||
CellId,
|
||||
|
||||
CopyMode,
|
||||
CopyModeDesc,
|
||||
PatternTerminal,
|
||||
@@ -114,6 +117,8 @@ public enum GuiText
|
||||
MaxPower,
|
||||
RequiredPower,
|
||||
Efficiency,
|
||||
SCSSize,
|
||||
SCSSInvalid,
|
||||
InWorldCrafting,
|
||||
|
||||
inWorldFluix,
|
||||
|
||||
@@ -39,7 +39,6 @@ import appeng.core.sync.packets.PacketLightning;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketMatterCannon;
|
||||
import appeng.core.sync.packets.PacketMockExplosion;
|
||||
import appeng.core.sync.packets.PacketNewStorageDimension;
|
||||
import appeng.core.sync.packets.PacketPaintedEntity;
|
||||
import appeng.core.sync.packets.PacketPartPlacement;
|
||||
import appeng.core.sync.packets.PacketPartialItem;
|
||||
@@ -83,8 +82,6 @@ public class AppEngPacketHandlerBase
|
||||
|
||||
PACKET_CLICK( PacketClick.class ),
|
||||
|
||||
PACKET_NEW_STORAGE_DIMENSION( PacketNewStorageDimension.class ),
|
||||
|
||||
PACKET_SWITCH_GUIS( PacketSwitchGuis.class ),
|
||||
|
||||
PACKET_SWAP_SLOTS( PacketSwapSlots.class ),
|
||||
|
||||
@@ -24,15 +24,12 @@ import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.ThreadQuickExitException;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLEventChannel;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
|
||||
|
||||
public class NetworkHandler
|
||||
@@ -89,21 +86,6 @@ public class NetworkHandler
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConnection( final ServerConnectionFromClientEvent ev )
|
||||
{
|
||||
WorldData.instance().dimensionData().sendToPlayer( ev.getManager() );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConnection( final PlayerLoggedInEvent loginEvent )
|
||||
{
|
||||
if( loginEvent.player instanceof EntityPlayerMP )
|
||||
{
|
||||
WorldData.instance().dimensionData().sendToPlayer( null );
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverPacket( final ServerCustomPacketEvent ev )
|
||||
{
|
||||
|
||||
@@ -28,11 +28,10 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
@@ -77,10 +76,10 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
{
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer;
|
||||
final Object target = cca.getTarget();
|
||||
if( target instanceof IGridHost )
|
||||
if( target instanceof IActionHost )
|
||||
{
|
||||
final IGridHost gh = (IGridHost) target;
|
||||
final IGridNode gn = gh.getGridNode( AEPartLocation.INTERNAL );
|
||||
final IActionHost ah = (IActionHost) target;
|
||||
final IGridNode gn = ah.getActionableNode();
|
||||
if( gn == null )
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -141,10 +141,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
|
||||
if( baseContainer.getTargetStack() != null )
|
||||
{
|
||||
// Force to stack size 1 to fix a client-side display problem...
|
||||
ItemStack displayIs = baseContainer.getTargetStack().getItemStack().copy();
|
||||
displayIs.setCount( 1 );
|
||||
cca.getCraftingItem().putStack( displayIs );
|
||||
cca.getCraftingItem().putStack( baseContainer.getTargetStack().asItemStackRepresentation() );
|
||||
// This is the *actual* item that matters, not the display item above
|
||||
cca.setItemToCraft( baseContainer.getTargetStack() );
|
||||
}
|
||||
@@ -171,7 +168,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( this.slotItem.getItemStack() );
|
||||
AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( this.slotItem.createItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,17 +30,13 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -49,15 +45,13 @@ import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.prioritylist.IPartitionList;
|
||||
@@ -114,165 +108,132 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
final EntityPlayerMP pmp = (EntityPlayerMP) player;
|
||||
final Container con = pmp.openContainer;
|
||||
|
||||
if( con instanceof IContainerCraftingPacket )
|
||||
if( !( con instanceof IContainerCraftingPacket ) )
|
||||
{
|
||||
final IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
if( node != null )
|
||||
return;
|
||||
}
|
||||
|
||||
final IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
|
||||
if( node == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final IGrid grid = node.getGrid();
|
||||
if( grid == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final IStorageGrid inv = grid.getCache( IStorageGrid.class );
|
||||
final IEnergyGrid energy = grid.getCache( IEnergyGrid.class );
|
||||
final ISecurityGrid security = grid.getCache( ISecurityGrid.class );
|
||||
final IItemHandler craftMatrix = cct.getInventoryByName( "crafting" );
|
||||
final IItemHandler playerInventory = cct.getInventoryByName( "player" );
|
||||
|
||||
if( inv != null && this.recipe != null && security != null )
|
||||
{
|
||||
final IMEMonitor<IAEItemStack> storage = inv.getItemInventory();
|
||||
final IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
|
||||
|
||||
for( int x = 0; x < craftMatrix.getSlots(); x++ )
|
||||
{
|
||||
final IGrid grid = node.getGrid();
|
||||
if( grid == null )
|
||||
ItemStack currentItem = craftMatrix.getStackInSlot( x );
|
||||
|
||||
// prepare slots
|
||||
if( !currentItem.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
// already the correct item?
|
||||
ItemStack newItem = canUseInSlot( x, currentItem );
|
||||
|
||||
final IStorageGrid inv = grid.getCache( IStorageGrid.class );
|
||||
final IEnergyGrid energy = grid.getCache( IEnergyGrid.class );
|
||||
final ISecurityGrid security = grid.getCache( ISecurityGrid.class );
|
||||
final IItemHandler craftMatrix = cct.getInventoryByName( "crafting" );
|
||||
final IItemHandler playerInventory = cct.getInventoryByName( "player" );
|
||||
|
||||
final Actionable realForFake = cct.useRealItems() ? Actionable.MODULATE : Actionable.SIMULATE;
|
||||
|
||||
if( inv != null && this.recipe != null && security != null )
|
||||
{
|
||||
final InventoryCrafting testInv = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
for( int x = 0; x < 9; x++ )
|
||||
// put away old item
|
||||
if( newItem != currentItem && security.hasPermission( player, SecurityPermissions.INJECT ) )
|
||||
{
|
||||
if( this.recipe[x] != null && this.recipe[x].length > 0 )
|
||||
final IAEItemStack in = AEItemStack.create( currentItem );
|
||||
final IAEItemStack out = cct.useRealItems() ? Platform.poweredInsert( energy, storage, in, cct.getActionSource() ) : null;
|
||||
if( out != null )
|
||||
{
|
||||
testInv.setInventorySlotContents( x, this.recipe[x][0] );
|
||||
currentItem = out.createItemStack();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentItem = ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final IRecipe r = Platform.findMatchingRecipe( testInv, pmp.world );
|
||||
|
||||
if( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
|
||||
if( currentItem.isEmpty() && this.recipe[x] != null )
|
||||
{
|
||||
// for each variant
|
||||
for( int y = 0; y < this.recipe[x].length && currentItem.isEmpty(); y++ )
|
||||
{
|
||||
final ItemStack is = r.getCraftingResult( testInv );
|
||||
|
||||
if( !is.isEmpty() )
|
||||
final IAEItemStack request = AEItemStack.create( this.recipe[x][y] );
|
||||
if( request != null )
|
||||
{
|
||||
final IMEMonitor<IAEItemStack> storage = inv.getItemInventory();
|
||||
final IItemList all = storage.getStorageList();
|
||||
final IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
|
||||
|
||||
for( int x = 0; x < craftMatrix.getSlots(); x++ )
|
||||
// try ae
|
||||
if( ( filter == null || filter.isListed( request ) ) && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
|
||||
{
|
||||
final ItemStack patternItem = testInv.getStackInSlot( x );
|
||||
|
||||
ItemStack currentItem = craftMatrix.getStackInSlot( x );
|
||||
if( !currentItem.isEmpty() )
|
||||
request.setStackSize( 1 );
|
||||
IAEItemStack out;
|
||||
if( cct.useRealItems() )
|
||||
{
|
||||
testInv.setInventorySlotContents( x, currentItem );
|
||||
final ItemStack newItemStack = r.matches( testInv, pmp.world ) ? r.getCraftingResult( testInv ) : ItemStack.EMPTY;
|
||||
testInv.setInventorySlotContents( x, patternItem );
|
||||
|
||||
if( newItemStack.isEmpty() || !Platform.itemComparisons().isSameItem( newItemStack, is ) )
|
||||
{
|
||||
final IAEItemStack in = AEItemStack.create( currentItem );
|
||||
if( in != null )
|
||||
{
|
||||
final IAEItemStack out = realForFake == Actionable.SIMULATE ? null : Platform.poweredInsert( energy, storage, in,
|
||||
cct.getActionSource() );
|
||||
if( out != null )
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( craftMatrix, x, out.getItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( craftMatrix, x, ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
currentItem = craftMatrix.getStackInSlot( x );
|
||||
}
|
||||
}
|
||||
out = Platform.poweredExtraction( energy, storage, request, cct.getActionSource() );
|
||||
}
|
||||
else
|
||||
{
|
||||
out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() );
|
||||
}
|
||||
|
||||
// True if we need to fetch an item for the recipe
|
||||
if( !patternItem.isEmpty() && currentItem.isEmpty() )
|
||||
if( out != null )
|
||||
{
|
||||
// Grab from network by recipe
|
||||
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getActionSource(), storage, player.world, r, is, testInv,
|
||||
patternItem, x, all, realForFake, filter );
|
||||
|
||||
// If that doesn't get it, grab exact items from network (?)
|
||||
// TODO see if this code is necessary
|
||||
if( whichItem.isEmpty() )
|
||||
{
|
||||
for( int y = 0; y < this.recipe[x].length; y++ )
|
||||
{
|
||||
final IAEItemStack request = AEItemStack.create( this.recipe[x][y] );
|
||||
if( request != null )
|
||||
{
|
||||
if( filter == null || filter.isListed( request ) )
|
||||
{
|
||||
request.setStackSize( 1 );
|
||||
final IAEItemStack out = Platform.poweredExtraction( energy, storage, request, cct.getActionSource() );
|
||||
if( out != null )
|
||||
{
|
||||
whichItem = out.getItemStack();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If that doesn't work, grab from the player's inventory
|
||||
if( whichItem.isEmpty() && playerInventory != null )
|
||||
{
|
||||
whichItem = this.extractItemFromPlayerInventory( player, realForFake, patternItem );
|
||||
}
|
||||
|
||||
ItemHandlerUtil.setStackInSlot( craftMatrix, x, whichItem );
|
||||
currentItem = out.createItemStack();
|
||||
}
|
||||
}
|
||||
|
||||
// try inventory
|
||||
if( currentItem.isEmpty() )
|
||||
{
|
||||
AdaptorItemHandler ad = new AdaptorItemHandler( playerInventory );
|
||||
|
||||
if( cct.useRealItems() )
|
||||
{
|
||||
currentItem = ad.removeItems( 1, this.recipe[x][y], null );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentItem = ad.simulateRemove( 1, this.recipe[x][y], null );
|
||||
}
|
||||
}
|
||||
con.onCraftMatrixChanged( new WrapperInvItemHandler( craftMatrix ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemHandlerUtil.setStackInSlot( craftMatrix, x, currentItem );
|
||||
}
|
||||
con.onCraftMatrixChanged( new WrapperInvItemHandler( craftMatrix ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to extract an item from the player inventory. Does account for fuzzy items.
|
||||
*
|
||||
* @param player the {@link EntityPlayer} to extract from
|
||||
* @param mode the {@link Actionable} to simulate or modulate the operation
|
||||
* @param patternItem which {@link ItemStack} to extract
|
||||
* @return null or a found {@link ItemStack}
|
||||
*
|
||||
* @param slot
|
||||
* @param is itemstack
|
||||
* @return is if it can be used, else EMPTY
|
||||
*/
|
||||
private ItemStack extractItemFromPlayerInventory( final EntityPlayer player, final Actionable mode, final ItemStack patternItem )
|
||||
private ItemStack canUseInSlot( int slot, ItemStack is )
|
||||
{
|
||||
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player );
|
||||
final AEItemStack request = AEItemStack.create( patternItem );
|
||||
final boolean isSimulated = mode == Actionable.SIMULATE;
|
||||
final boolean checkFuzzy = request.isOre() || patternItem.getItemDamage() == OreDictionary.WILDCARD_VALUE || patternItem.hasTagCompound() || patternItem
|
||||
.isItemStackDamageable();
|
||||
|
||||
if( !checkFuzzy )
|
||||
if( this.recipe[slot] != null )
|
||||
{
|
||||
if( isSimulated )
|
||||
for( ItemStack option : this.recipe[slot] )
|
||||
{
|
||||
return ia.simulateRemove( 1, patternItem, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ia.removeItems( 1, patternItem, null );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( isSimulated )
|
||||
{
|
||||
return ia.simulateSimilarRemove( 1, patternItem, FuzzyMode.IGNORE_ALL, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ia.removeSimilarItems( 1, patternItem, FuzzyMode.IGNORE_ALL, null );
|
||||
if( is.isItemEqual( option ) )
|
||||
{
|
||||
return is;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
public class PacketNewStorageDimension extends AppEngPacket
|
||||
{
|
||||
|
||||
private final int newDim;
|
||||
|
||||
// automatic.
|
||||
public PacketNewStorageDimension( final ByteBuf stream )
|
||||
{
|
||||
this.newDim = stream.readInt();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketNewStorageDimension( final int newDim )
|
||||
{
|
||||
this.newDim = newDim;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( newDim );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final EntityPlayer player )
|
||||
{
|
||||
try
|
||||
{
|
||||
DimensionManager.registerDimension( this.newDim, AppEng.instance().getStorageDimensionType() );
|
||||
}
|
||||
catch( final IllegalArgumentException iae )
|
||||
{
|
||||
// ok!
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -51,11 +50,6 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
{
|
||||
this.newGui = newGui;
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
AEBaseGui.setSwitchingGuis( true );
|
||||
}
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
@@ -79,10 +73,4 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final EntityPlayer player )
|
||||
{
|
||||
AEBaseGui.setSwitchingGuis( true );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketNewStorageDimension;
|
||||
import appeng.hooks.TickHandler;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3 - 30.05.2015
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
final class DimensionData implements IWorldDimensionData, IOnWorldStartable, IOnWorldStoppable
|
||||
{
|
||||
private static final String CONFIG_CATEGORY = "DimensionManager";
|
||||
private static final String CONFIG_KEY = "StorageCells";
|
||||
private static final int[] STORAGE_CELLS_DEFAULT = new int[0];
|
||||
|
||||
private static final String STORAGE_CELL_CATEGORY = "StorageCell";
|
||||
|
||||
private static final String STORAGE_CELL_SCALE_X_KEY = "scaleX";
|
||||
private static final String STORAGE_CELL_SCALE_Y_KEY = "scaleY";
|
||||
private static final String STORAGE_CELL_SCALE_Z_KEY = "scaleZ";
|
||||
|
||||
private static final String PACKAGE_DEST_CATEGORY = "DimensionManager";
|
||||
private static final String PACKAGE_KEY_CATEGORY = "StorageCells";
|
||||
private static final int[] PACKAGE_DEF_CATEGORY = new int[0];
|
||||
|
||||
private final Configuration config;
|
||||
private final List<Integer> storageCellDimensionIDs;
|
||||
|
||||
DimensionData( @Nonnull final Configuration parentFile )
|
||||
{
|
||||
Preconditions.checkNotNull( parentFile );
|
||||
|
||||
this.config = parentFile;
|
||||
|
||||
final int[] storageCellIDs = this.storageCellIDsProperty().getIntList();
|
||||
|
||||
this.storageCellDimensionIDs = Lists.newArrayList();
|
||||
for( final int storageCellID : storageCellIDs )
|
||||
{
|
||||
this.storageCellDimensionIDs.add( storageCellID );
|
||||
}
|
||||
}
|
||||
|
||||
private Property storageCellIDsProperty()
|
||||
{
|
||||
return this.config.get( CONFIG_CATEGORY, CONFIG_KEY, STORAGE_CELLS_DEFAULT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldStart()
|
||||
{
|
||||
for( final Integer storageCellDimID : this.storageCellDimensionIDs )
|
||||
{
|
||||
DimensionManager.registerDimension( storageCellDimID, AppEng.instance().getStorageDimensionType() );
|
||||
}
|
||||
|
||||
this.config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldStop()
|
||||
{
|
||||
this.config.save();
|
||||
|
||||
for( final Integer storageCellDimID : this.storageCellDimensionIDs )
|
||||
{
|
||||
DimensionManager.unregisterDimension( storageCellDimID );
|
||||
}
|
||||
|
||||
this.storageCellDimensionIDs.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorageCell( final int newStorageCellID )
|
||||
{
|
||||
this.storageCellDimensionIDs.add( newStorageCellID );
|
||||
DimensionManager.registerDimension( newStorageCellID, AppEng.instance().getStorageDimensionType() );
|
||||
|
||||
NetworkHandler.instance().sendToAll( new PacketNewStorageDimension( newStorageCellID ) );
|
||||
|
||||
final String[] values = new String[this.storageCellDimensionIDs.size()];
|
||||
|
||||
for( int x = 0; x < values.length; x++ )
|
||||
{
|
||||
values[x] = String.valueOf( this.storageCellDimensionIDs.get( x ) );
|
||||
}
|
||||
|
||||
this.storageCellIDsProperty().set( values );
|
||||
this.config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldCoord getStoredSize( final int dim )
|
||||
{
|
||||
final String category = STORAGE_CELL_CATEGORY + dim;
|
||||
|
||||
final int x = this.config.get( category, STORAGE_CELL_SCALE_X_KEY, 0 ).getInt();
|
||||
final int y = this.config.get( category, STORAGE_CELL_SCALE_Y_KEY, 0 ).getInt();
|
||||
final int z = this.config.get( category, STORAGE_CELL_SCALE_Z_KEY, 0 ).getInt();
|
||||
|
||||
return new WorldCoord( x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredSize( final int dim, final int targetX, final int targetY, final int targetZ )
|
||||
{
|
||||
final String category = STORAGE_CELL_CATEGORY + dim;
|
||||
|
||||
this.config.get( category, STORAGE_CELL_SCALE_X_KEY, 0 ).set( targetX );
|
||||
this.config.get( category, STORAGE_CELL_SCALE_Y_KEY, 0 ).set( targetY );
|
||||
this.config.get( category, STORAGE_CELL_SCALE_Z_KEY, 0 ).set( targetZ );
|
||||
|
||||
this.config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToPlayer( @Nullable final NetworkManager manager )
|
||||
{
|
||||
if( manager != null )
|
||||
{
|
||||
for( final int newDim : this.config.get( PACKAGE_DEST_CATEGORY, PACKAGE_KEY_CATEGORY, PACKAGE_DEF_CATEGORY ).getIntList() )
|
||||
{
|
||||
manager.sendPacket( ( new PacketNewStorageDimension( newDim ) ).getProxy() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( final TickHandler.PlayerColor pc : TickHandler.INSTANCE.getPlayerColors().values() )
|
||||
{
|
||||
NetworkHandler.instance().sendToAll( pc.getPacket() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,9 +39,6 @@ public interface IWorldData
|
||||
@Nonnull
|
||||
IWorldPlayerData playerData();
|
||||
|
||||
@Nonnull
|
||||
IWorldDimensionData dimensionData();
|
||||
|
||||
@Nonnull
|
||||
IWorldCompassData compassData();
|
||||
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* 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.core.worlddata;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.capabilities.Capabilities;
|
||||
|
||||
|
||||
public class SpatialDimensionManager implements ISpatialDimension, ICapabilitySerializable<NBTTagCompound>
|
||||
{
|
||||
private static final String NBT_SPATIAL_DATA_KEY = "spatial_data";
|
||||
private static final String NBT_SPATIAL_ID_KEY = "id";
|
||||
|
||||
private World world;
|
||||
private Map<Integer, StorageCellData> spatialData = new HashMap<>();
|
||||
|
||||
private static final int MAX_CELL_DIMENSION = 512;
|
||||
|
||||
public SpatialDimensionManager( World world )
|
||||
{
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int createNewCellDimension( BlockPos contentSize, int owner )
|
||||
{
|
||||
int newId = this.getNextId();
|
||||
|
||||
StorageCellData data = new StorageCellData();
|
||||
data.contentDimension = contentSize;
|
||||
data.owner = owner;
|
||||
|
||||
this.spatialData.put( newId, data );
|
||||
|
||||
return newId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCellDimension( int cellStorageId )
|
||||
{
|
||||
StorageCellData removed = spatialData.remove( cellStorageId );
|
||||
if( removed != null )
|
||||
{
|
||||
this.clearCellArea( cellStorageId, removed );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellDimension( int cellStorageId )
|
||||
{
|
||||
return this.spatialData.containsKey( cellStorageId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellDimensionOwner( int cellStorageId )
|
||||
{
|
||||
StorageCellData cell = this.spatialData.get( cellStorageId );
|
||||
if( cell != null )
|
||||
{
|
||||
return cell.owner;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellDimensionOrigin( int cellStorageId )
|
||||
{
|
||||
if( this.isCellDimension( cellStorageId ) )
|
||||
{
|
||||
return getBlockPosFromId( cellStorageId );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellContentSize( int cellStorageId )
|
||||
{
|
||||
StorageCellData cell = this.spatialData.get( cellStorageId );
|
||||
if( cell != null )
|
||||
{
|
||||
return cell.contentDimension;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capability, EnumFacing facing )
|
||||
{
|
||||
return capability == Capabilities.SPATIAL_DIMENSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capability, EnumFacing facing )
|
||||
{
|
||||
if( capability == Capabilities.SPATIAL_DIMENSION )
|
||||
{
|
||||
return (T) this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serializeNBT()
|
||||
{
|
||||
final NBTTagCompound ret = new NBTTagCompound();
|
||||
final NBTTagList list = new NBTTagList();
|
||||
|
||||
for( Map.Entry<Integer, StorageCellData> entry : this.spatialData.entrySet() )
|
||||
{
|
||||
final NBTTagCompound nbt = entry.getValue().serializeNBT();
|
||||
nbt.setInteger( NBT_SPATIAL_ID_KEY, entry.getKey() );
|
||||
list.appendTag( nbt );
|
||||
}
|
||||
ret.setTag( NBT_SPATIAL_DATA_KEY, list );
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT( NBTTagCompound nbt )
|
||||
{
|
||||
if( nbt.hasKey( NBT_SPATIAL_DATA_KEY ) )
|
||||
{
|
||||
final NBTTagList list = (NBTTagList) nbt.getTag( NBT_SPATIAL_DATA_KEY );
|
||||
|
||||
this.spatialData.clear();
|
||||
for( int i = 0; i < list.tagCount(); ++i )
|
||||
{
|
||||
final NBTTagCompound entry = list.getCompoundTagAt( i );
|
||||
final StorageCellData data = new StorageCellData();
|
||||
final int id = entry.getInteger( NBT_SPATIAL_ID_KEY );
|
||||
data.deserializeNBT( entry );
|
||||
this.spatialData.put( id, data );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getNextId()
|
||||
{
|
||||
return this.spatialData.keySet().stream().max( Integer::compare ).orElse( -1 ) + 1;
|
||||
}
|
||||
|
||||
private BlockPos getBlockPosFromId( int id )
|
||||
{
|
||||
int signBits = id & 0b11;
|
||||
int offsetBits = id >> 2;
|
||||
int offsetScale = 1;
|
||||
int posx = MAX_CELL_DIMENSION / 2;
|
||||
int posz = MAX_CELL_DIMENSION / 2;
|
||||
|
||||
// find quadrant
|
||||
while( offsetBits != 0 )
|
||||
{
|
||||
posx += MAX_CELL_DIMENSION * offsetScale * ( offsetBits & 0b01 );
|
||||
posz += MAX_CELL_DIMENSION * offsetScale * ( offsetBits >> 1 & 0b01 );
|
||||
|
||||
offsetBits >>= 2;
|
||||
offsetScale <<= 1;
|
||||
}
|
||||
|
||||
// mirror in one of 4 directions
|
||||
if( ( signBits & 0b01 ) == 0 )
|
||||
{
|
||||
posx *= -1;
|
||||
}
|
||||
if( ( signBits & 0b10 ) == 0 )
|
||||
{
|
||||
posz *= -1;
|
||||
}
|
||||
|
||||
// offset from cell center
|
||||
posx -= 64;
|
||||
posz -= 64;
|
||||
|
||||
return new BlockPos( posx, 64, posz );
|
||||
}
|
||||
|
||||
private void clearCellArea( int cellId, StorageCellData cell )
|
||||
{
|
||||
// TODO reset chunks?
|
||||
}
|
||||
|
||||
private static class StorageCellData implements INBTSerializable<NBTTagCompound>
|
||||
{
|
||||
private static final String NBT_OWNER_KEY = "owner";
|
||||
private static final String NBT_DIM_X_KEY = "dim_x";
|
||||
private static final String NBT_DIM_Y_KEY = "dim_y";
|
||||
private static final String NBT_DIM_Z_KEY = "dim_z";
|
||||
|
||||
public BlockPos contentDimension;
|
||||
public int owner;
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serializeNBT()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger( NBT_DIM_X_KEY, contentDimension.getX() );
|
||||
nbt.setInteger( NBT_DIM_Y_KEY, contentDimension.getY() );
|
||||
nbt.setInteger( NBT_DIM_Z_KEY, contentDimension.getZ() );
|
||||
nbt.setInteger( NBT_OWNER_KEY, owner );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT( NBTTagCompound nbt )
|
||||
{
|
||||
contentDimension = new BlockPos( nbt.getInteger( NBT_DIM_X_KEY ), nbt.getInteger( NBT_DIM_Y_KEY ), nbt.getInteger( NBT_DIM_Z_KEY ) );
|
||||
owner = nbt.getInteger( NBT_OWNER_KEY );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@ public final class WorldData implements IWorldData
|
||||
private static IWorldData instance;
|
||||
|
||||
private final IWorldPlayerData playerData;
|
||||
private final IWorldDimensionData dimensionData;
|
||||
private final IWorldGridStorageData storageData;
|
||||
private final IWorldCompassData compassData;
|
||||
private final IWorldSpawnData spawnData;
|
||||
@@ -87,7 +86,6 @@ public final class WorldData implements IWorldData
|
||||
this.sharedConfig = new Configuration( settingsFile, AEConfig.VERSION );
|
||||
|
||||
final PlayerData playerData = new PlayerData( this.sharedConfig );
|
||||
final DimensionData dimensionData = new DimensionData( this.sharedConfig );
|
||||
final StorageData storageData = new StorageData( this.sharedConfig );
|
||||
|
||||
final ThreadFactory compassThreadFactory = new CompassThreadFactory();
|
||||
@@ -97,13 +95,12 @@ public final class WorldData implements IWorldData
|
||||
final IWorldSpawnData spawnData = new SpawnData( this.spawnDirectory );
|
||||
|
||||
this.playerData = playerData;
|
||||
this.dimensionData = dimensionData;
|
||||
this.storageData = storageData;
|
||||
this.compassData = compassData;
|
||||
this.spawnData = spawnData;
|
||||
|
||||
this.startables = Lists.<IOnWorldStartable>newArrayList( playerData, dimensionData, storageData );
|
||||
this.stoppables = Lists.<IOnWorldStoppable>newArrayList( playerData, dimensionData, storageData, compassData );
|
||||
this.startables = Lists.<IOnWorldStartable>newArrayList( playerData, storageData );
|
||||
this.stoppables = Lists.<IOnWorldStoppable>newArrayList( playerData, storageData, compassData );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,13 +195,6 @@ public final class WorldData implements IWorldData
|
||||
return this.playerData;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IWorldDimensionData dimensionData()
|
||||
{
|
||||
return this.dimensionData;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IWorldCompassData compassData()
|
||||
|
||||
@@ -37,10 +37,8 @@ import appeng.api.networking.crafting.ICraftingCallback;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
@@ -66,7 +64,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
private boolean simulate = false;
|
||||
private MECraftingInventory availableCheck;
|
||||
private long bytes = 0;
|
||||
private final BaseActionSource actionSrc;
|
||||
private final IActionSource actionSrc;
|
||||
private final ICraftingCallback callback;
|
||||
private boolean running = false;
|
||||
private boolean done = false;
|
||||
@@ -78,7 +76,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
return w;
|
||||
}
|
||||
|
||||
public CraftingJob( final World w, final IGrid grid, final BaseActionSource actionSrc, final IAEItemStack what, final ICraftingCallback callback )
|
||||
public CraftingJob( final World w, final IGrid grid, final IActionSource actionSrc, final IAEItemStack what, final ICraftingCallback callback )
|
||||
{
|
||||
this.world = this.wrapWorld( w );
|
||||
this.output = what.copy();
|
||||
@@ -375,22 +373,21 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
final long elapsedTime = timer.elapsed( TimeUnit.MILLISECONDS );
|
||||
final String actionSource;
|
||||
|
||||
if( this.actionSrc instanceof MachineSource )
|
||||
if( this.actionSrc.player().isPresent() )
|
||||
{
|
||||
final IActionHost machineSource = ( (MachineSource) this.actionSrc ).via;
|
||||
final EntityPlayer player = this.actionSrc.player().get();
|
||||
|
||||
actionSource = player.toString();
|
||||
}
|
||||
else if( this.actionSrc.machine().isPresent() )
|
||||
{
|
||||
final IActionHost machineSource = this.actionSrc.machine().get();
|
||||
final IGridNode actionableNode = machineSource.getActionableNode();
|
||||
final IGridHost machine = actionableNode.getMachine();
|
||||
final DimensionalCoord location = actionableNode.getGridBlock().getLocation();
|
||||
|
||||
actionSource = String.format( LOG_MACHINE_SOURCE_DETAILS, machine, location );
|
||||
}
|
||||
else if( this.actionSrc instanceof PlayerSource )
|
||||
{
|
||||
final PlayerSource source = (PlayerSource) this.actionSrc;
|
||||
final EntityPlayer player = source.player;
|
||||
|
||||
actionSource = player.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
actionSource = "[unknown source]";
|
||||
|
||||
@@ -33,7 +33,7 @@ import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
@@ -117,7 +117,7 @@ public class CraftingTreeNode
|
||||
return this.parent.notRecursive( details );
|
||||
}
|
||||
|
||||
IAEItemStack request( final MECraftingInventory inv, long l, final BaseActionSource src ) throws CraftBranchFailure, InterruptedException
|
||||
IAEItemStack request( final MECraftingInventory inv, long l, final IActionSource src ) throws CraftBranchFailure, InterruptedException
|
||||
{
|
||||
this.job.handlePausing();
|
||||
|
||||
@@ -147,7 +147,7 @@ public class CraftingTreeNode
|
||||
|
||||
for( IAEItemStack fuzz : itemList )
|
||||
{
|
||||
if( this.parent.details.isValidItemForSlot( this.getSlot(), fuzz.getItemStack(), this.world ) )
|
||||
if( this.parent.details.isValidItemForSlot( this.getSlot(), fuzz.createItemStack(), this.world ) )
|
||||
{
|
||||
fuzz = fuzz.copy();
|
||||
fuzz.setStackSize( l );
|
||||
@@ -346,7 +346,7 @@ public class CraftingTreeNode
|
||||
}
|
||||
}
|
||||
|
||||
public void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final BaseActionSource src ) throws CraftBranchFailure
|
||||
public void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final IActionSource src ) throws CraftBranchFailure
|
||||
{
|
||||
for( final IAEItemStack i : this.used )
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
@@ -73,7 +73,7 @@ public class CraftingTreeProcess
|
||||
final IAEItemStack[] is = details.getInputs();
|
||||
for( int x = 0; x < ic.getSizeInventory(); x++ )
|
||||
{
|
||||
ic.setInventorySlotContents( x, is[x] == null ? ItemStack.EMPTY : is[x].getItemStack() );
|
||||
ic.setInventorySlotContents( x, is[x] == null ? ItemStack.EMPTY : is[x].createItemStack() );
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) world ), details.getOutput( ic, world ), ic );
|
||||
@@ -89,7 +89,7 @@ public class CraftingTreeProcess
|
||||
|
||||
for( final IAEItemStack part : details.getCondensedInputs() )
|
||||
{
|
||||
final ItemStack g = part.getItemStack();
|
||||
final ItemStack g = part.createItemStack();
|
||||
|
||||
boolean isAnInput = false;
|
||||
for( final IAEItemStack a : details.getCondensedOutputs() )
|
||||
@@ -146,7 +146,7 @@ public class CraftingTreeProcess
|
||||
{
|
||||
for( final IAEItemStack part : details.getCondensedInputs() )
|
||||
{
|
||||
final ItemStack g = part.getItemStack();
|
||||
final ItemStack g = part.createItemStack();
|
||||
|
||||
boolean isAnInput = false;
|
||||
for( final IAEItemStack a : details.getCondensedOutputs() )
|
||||
@@ -184,7 +184,7 @@ public class CraftingTreeProcess
|
||||
return ( remaining / stackSize ) + ( remaining % stackSize != 0 ? 1 : 0 );
|
||||
}
|
||||
|
||||
void request( final MECraftingInventory inv, final long i, final BaseActionSource src ) throws CraftBranchFailure, InterruptedException
|
||||
void request( final MECraftingInventory inv, final long i, final IActionSource src ) throws CraftBranchFailure, InterruptedException
|
||||
{
|
||||
this.job.handlePausing();
|
||||
|
||||
@@ -197,7 +197,7 @@ public class CraftingTreeProcess
|
||||
final IAEItemStack item = entry.getKey().getStack( entry.getValue() );
|
||||
final IAEItemStack stack = entry.getKey().request( inv, item.getStackSize(), src );
|
||||
|
||||
ic.setInventorySlotContents( entry.getKey().getSlot(), stack.getItemStack() );
|
||||
ic.setInventorySlotContents( entry.getKey().getSlot(), stack.createItemStack() );
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) this.world ), this.details.getOutput( ic, this.world ), ic );
|
||||
@@ -225,7 +225,7 @@ public class CraftingTreeProcess
|
||||
|
||||
if( this.containerItems )
|
||||
{
|
||||
final ItemStack is = Platform.getContainerItem( stack.getItemStack() );
|
||||
final ItemStack is = Platform.getContainerItem( stack.createItemStack() );
|
||||
final IAEItemStack o = AEApi.instance().storage().createItemStack( is );
|
||||
if( o != null )
|
||||
{
|
||||
@@ -297,7 +297,7 @@ public class CraftingTreeProcess
|
||||
}
|
||||
}
|
||||
|
||||
void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final BaseActionSource src ) throws CraftBranchFailure
|
||||
void setJob( final MECraftingInventory storage, final CraftingCPUCluster craftingCPUCluster, final IActionSource src ) throws CraftBranchFailure
|
||||
{
|
||||
craftingCPUCluster.addCrafting( this.details, this.crafts );
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.crafting;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
@@ -99,7 +99,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
this.par = parent;
|
||||
}
|
||||
|
||||
public MECraftingInventory( final IMEMonitor<IAEItemStack> target, final BaseActionSource src, final boolean logExtracted, final boolean logInjections, final boolean logMissing )
|
||||
public MECraftingInventory( final IMEMonitor<IAEItemStack> target, final IActionSource src, final boolean logExtracted, final boolean logInjections, final boolean logMissing )
|
||||
{
|
||||
this.target = target;
|
||||
this.logExtracted = logExtracted;
|
||||
@@ -181,7 +181,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final BaseActionSource src )
|
||||
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( input == null )
|
||||
{
|
||||
@@ -201,7 +201,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final BaseActionSource src )
|
||||
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( request == null )
|
||||
{
|
||||
@@ -265,7 +265,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
return this.localCache;
|
||||
}
|
||||
|
||||
public boolean commit( final BaseActionSource src )
|
||||
public boolean commit( final IActionSource src )
|
||||
{
|
||||
final IItemList<IAEItemStack> added = AEApi.instance().storage().createItemList();
|
||||
final IItemList<IAEItemStack> pulled = AEApi.instance().storage().createItemList();
|
||||
|
||||
@@ -121,12 +121,12 @@ public final class EntityChargedQuartz extends AEBaseEntityItem
|
||||
final ItemStack other = ( (EntityItem) e ).getItem();
|
||||
if( !other.isEmpty() )
|
||||
{
|
||||
if( Platform.itemComparisons().isEqualItem( other, new ItemStack( Items.REDSTONE ) ) )
|
||||
if( ItemStack.areItemsEqual( other, new ItemStack( Items.REDSTONE ) ) )
|
||||
{
|
||||
redstone = (EntityItem) e;
|
||||
}
|
||||
|
||||
if( Platform.itemComparisons().isEqualItem( other, new ItemStack( Items.QUARTZ ) ) )
|
||||
if( ItemStack.areItemsEqual( other, new ItemStack( Items.QUARTZ ) ) )
|
||||
{
|
||||
netherQuartz = (EntityItem) e;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -66,9 +67,8 @@ import appeng.api.networking.crafting.ICraftingProvider;
|
||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
@@ -88,6 +88,7 @@ import appeng.capabilities.Capabilities;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.me.storage.MEMonitorIInventory;
|
||||
import appeng.me.storage.MEMonitorPassThrough;
|
||||
import appeng.me.storage.NullInventory;
|
||||
@@ -118,8 +119,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
private final MultiCraftingTracker craftingTracker;
|
||||
private final AENetworkProxy gridProxy;
|
||||
private final IInterfaceHost iHost;
|
||||
private final BaseActionSource mySource;
|
||||
private final BaseActionSource interfaceRequestSource;
|
||||
private final IActionSource mySource;
|
||||
private final IActionSource interfaceRequestSource;
|
||||
private final ConfigManager cm = new ConfigManager( this );
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, NUMBER_OF_CONFIG_SLOTS );
|
||||
private final AppEngInternalInventory storage = new AppEngInternalInventory( this, NUMBER_OF_STORAGE_SLOTS );
|
||||
@@ -132,7 +133,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
private List<ICraftingPatternDetails> craftingList = null;
|
||||
private List<ItemStack> waitingToSend = null;
|
||||
private IMEInventory<IAEItemStack> destination;
|
||||
private boolean isWorking = false;
|
||||
private int isWorking = -1;
|
||||
private final Accessor accessor = new Accessor();
|
||||
|
||||
public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih )
|
||||
@@ -164,7 +165,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
@Override
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
if( this.isWorking )
|
||||
if( this.isWorking == slot )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -407,34 +408,34 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
req = null;
|
||||
}
|
||||
|
||||
final ItemStack Stored = this.storage.getStackInSlot( slot );
|
||||
final ItemStack stored = this.storage.getStackInSlot( slot );
|
||||
|
||||
if( req == null && !Stored.isEmpty() )
|
||||
if( req == null && !stored.isEmpty() )
|
||||
{
|
||||
final IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
|
||||
final IAEItemStack work = AEApi.instance().storage().createItemStack( stored );
|
||||
this.requireWork[slot] = work.setStackSize( -work.getStackSize() );
|
||||
return;
|
||||
}
|
||||
else if( req != null )
|
||||
{
|
||||
if( Stored.isEmpty() ) // need to add stuff!
|
||||
if( stored.isEmpty() ) // need to add stuff!
|
||||
{
|
||||
this.requireWork[slot] = req.copy();
|
||||
return;
|
||||
}
|
||||
else if( req.isSameType( Stored ) ) // same type ( qty different? )!
|
||||
else if( req.isSameType( stored ) ) // same type ( qty different? )!
|
||||
{
|
||||
if( req.getStackSize() != Stored.getCount() )
|
||||
if( req.getStackSize() != stored.getCount() )
|
||||
{
|
||||
this.requireWork[slot] = req.copy();
|
||||
this.requireWork[slot].setStackSize( req.getStackSize() - Stored.getCount() );
|
||||
this.requireWork[slot].setStackSize( req.getStackSize() - stored.getCount() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
// Stored != null; dispose!
|
||||
{
|
||||
final IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
|
||||
final IAEItemStack work = AEApi.instance().storage().createItemStack( stored );
|
||||
this.requireWork[slot] = work.setStackSize( -work.getStackSize() );
|
||||
return;
|
||||
}
|
||||
@@ -657,7 +658,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
private boolean usePlan( final int x, final IAEItemStack itemStack )
|
||||
{
|
||||
final InventoryAdaptor adaptor = this.getAdaptor( x );
|
||||
this.isWorking = true;
|
||||
this.isWorking = x;
|
||||
|
||||
boolean changed = false;
|
||||
try
|
||||
@@ -672,7 +673,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
else if( itemStack.getStackSize() > 0 )
|
||||
{
|
||||
// make sure strange things didn't happen...
|
||||
if( !adaptor.simulateAdd( itemStack.getItemStack() ).isEmpty() )
|
||||
if( !adaptor.simulateAdd( itemStack.createItemStack() ).isEmpty() )
|
||||
{
|
||||
changed = true;
|
||||
throw new GridAccessException();
|
||||
@@ -682,7 +683,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
if( acquired != null )
|
||||
{
|
||||
changed = true;
|
||||
final ItemStack issue = adaptor.addItems( acquired.getItemStack() );
|
||||
final ItemStack issue = adaptor.addItems( acquired.createItemStack() );
|
||||
if( !issue.isEmpty() )
|
||||
{
|
||||
throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" );
|
||||
@@ -701,7 +702,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
long diff = toStore.getStackSize();
|
||||
|
||||
// make sure strange things didn't happen...
|
||||
final ItemStack canExtract = adaptor.simulateRemove( (int) diff, toStore.getItemStack(), null );
|
||||
// TODO: check if OK
|
||||
final ItemStack canExtract = adaptor.simulateRemove( (int) diff, toStore.getDefinition(), null );
|
||||
if( canExtract.isEmpty() || canExtract.getCount() != diff )
|
||||
{
|
||||
changed = true;
|
||||
@@ -742,7 +744,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
this.updatePlan( x );
|
||||
}
|
||||
|
||||
this.isWorking = false;
|
||||
this.isWorking = -1;
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -865,7 +867,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
this.craftingTracker.cancel();
|
||||
}
|
||||
|
||||
public IStorageMonitorable getMonitorable( final BaseActionSource src, final IStorageMonitorable myInterface )
|
||||
public IStorageMonitorable getMonitorable( final IActionSource src, final IStorageMonitorable myInterface )
|
||||
{
|
||||
if( Platform.canAccess( this.gridProxy, src ) )
|
||||
{
|
||||
@@ -990,7 +992,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
||||
if( ad != null )
|
||||
{
|
||||
if( !ad.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty() )
|
||||
if( ad.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty() )
|
||||
{
|
||||
allAreBusy = false;
|
||||
break;
|
||||
@@ -1117,11 +1119,11 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return AEItemStack.create( adaptor.simulateAdd( acquired.getItemStack() ) );
|
||||
return AEItemStack.create( adaptor.simulateAdd( acquired.createItemStack() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
final IAEItemStack is = AEItemStack.create( adaptor.addItems( acquired.getItemStack() ) );
|
||||
final IAEItemStack is = AEItemStack.create( adaptor.addItems( acquired.createItemStack() ) );
|
||||
this.updatePlan( slot );
|
||||
return is;
|
||||
}
|
||||
@@ -1275,10 +1277,34 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
|
||||
private class InterfaceRequestSource extends MachineSource
|
||||
{
|
||||
private final InterfaceRequestContext context;
|
||||
|
||||
public InterfaceRequestSource( final IActionHost v )
|
||||
public InterfaceRequestSource( IActionHost v )
|
||||
{
|
||||
super( v );
|
||||
this.context = new InterfaceRequestContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> context( Class<T> key )
|
||||
{
|
||||
if( key == InterfaceRequestContext.class )
|
||||
{
|
||||
return (Optional<T>) Optional.of( this.context );
|
||||
}
|
||||
|
||||
return super.context( key );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class InterfaceRequestContext implements Comparable<Integer>
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compareTo( Integer o )
|
||||
{
|
||||
return Integer.compare( DualityInterface.this.priority, o );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1292,9 +1318,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
|
||||
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src )
|
||||
{
|
||||
if( src instanceof InterfaceRequestSource )
|
||||
final Optional<InterfaceRequestContext> context = src.context( InterfaceRequestContext.class );
|
||||
final boolean isInterface = context.isPresent();
|
||||
|
||||
if( isInterface )
|
||||
{
|
||||
return input;
|
||||
}
|
||||
@@ -1303,9 +1332,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final BaseActionSource src )
|
||||
public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final IActionSource src )
|
||||
{
|
||||
if( src instanceof InterfaceRequestSource )
|
||||
final Optional<InterfaceRequestContext> context = src.context( InterfaceRequestContext.class );
|
||||
final boolean hasLowerOrEqualPriority = context.map( c -> c.compareTo( DualityInterface.this.priority ) <= 0 ).orElse( false );
|
||||
|
||||
if( hasLowerOrEqualPriority )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -1319,7 +1351,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IStorageMonitorable getInventory( BaseActionSource src )
|
||||
public IStorageMonitorable getInventory( IActionSource src )
|
||||
{
|
||||
return DualityInterface.this.getMonitorable( src, DualityInterface.this );
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
|
||||
|
||||
public interface IContainerCraftingPacket
|
||||
@@ -44,7 +44,7 @@ public interface IContainerCraftingPacket
|
||||
/**
|
||||
* @return who are we?
|
||||
*/
|
||||
BaseActionSource getActionSource();
|
||||
IActionSource getActionSource();
|
||||
|
||||
/**
|
||||
* @return consume items?
|
||||
|
||||
@@ -33,7 +33,7 @@ import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingRequester;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
@@ -81,9 +81,9 @@ public class MultiCraftingTracker
|
||||
}
|
||||
}
|
||||
|
||||
public boolean handleCrafting( final int x, final long itemToCraft, final IAEItemStack ais, final InventoryAdaptor d, final World w, final IGrid g, final ICraftingGrid cg, final BaseActionSource mySrc )
|
||||
public boolean handleCrafting( final int x, final long itemToCraft, final IAEItemStack ais, final InventoryAdaptor d, final World w, final IGrid g, final ICraftingGrid cg, final IActionSource mySrc )
|
||||
{
|
||||
if( ais != null && d.simulateAdd( ais.getItemStack() ).isEmpty() )
|
||||
if( ais != null && d.simulateAdd( ais.createItemStack() ).isEmpty() )
|
||||
{
|
||||
final Future<ICraftingJob> craftingJob = this.getJob( x );
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ package appeng.helpers;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import scala.NotImplementedError;
|
||||
|
||||
|
||||
public class NonNullArrayIterator<E> implements Iterator<E>
|
||||
{
|
||||
@@ -58,6 +56,6 @@ public class NonNullArrayIterator<E> implements Iterator<E>
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
throw new NotImplementedError();
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
|
||||
if( this.isCrafting )
|
||||
{
|
||||
this.standardRecipe = Platform.findMatchingRecipe( this.crafting, w );
|
||||
this.standardRecipe = CraftingManager.findMatchingRecipe( this.crafting, w );
|
||||
|
||||
if( this.standardRecipe != null )
|
||||
{
|
||||
@@ -334,7 +334,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
|
||||
if( this.outputs != null && this.outputs.length > 0 )
|
||||
{
|
||||
return this.outputs[0].getItemStack();
|
||||
return this.outputs[0].createItemStack();
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
@@ -32,11 +32,10 @@ import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IWirelessAccessPoint;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IMachineSet;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
@@ -44,8 +43,6 @@ import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
@@ -87,9 +84,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
// :P
|
||||
}
|
||||
|
||||
if( obj instanceof IGridHost )
|
||||
if( obj instanceof IActionHost )
|
||||
{
|
||||
final IGridNode n = ( (IGridHost) obj ).getGridNode( AEPartLocation.INTERNAL );
|
||||
final IGridNode n = ( (IActionHost) obj ).getActionableNode();
|
||||
if( n != null )
|
||||
{
|
||||
this.targetGrid = n.getGrid();
|
||||
@@ -225,7 +222,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
|
||||
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src )
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
@@ -235,7 +232,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final BaseActionSource src )
|
||||
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( this.itemStorage != null )
|
||||
{
|
||||
@@ -280,24 +277,6 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
return this.wth.getConfigManager( this.effectiveItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode( final AEPartLocation dir )
|
||||
{
|
||||
return this.getActionableNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode()
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.google.common.collect.LinkedListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
@@ -166,18 +165,6 @@ public class TickHandler
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkLoad( final ChunkEvent.Load load )
|
||||
{
|
||||
for( final Object te : load.getChunk().getTileEntityMap().values() )
|
||||
{
|
||||
if( te instanceof AEBaseTile )
|
||||
{
|
||||
( (AEBaseTile) te ).onChunkLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick( final TickEvent ev )
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.util.EnumFacing;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.integration.abstraction.IC2PowerSink;
|
||||
import appeng.tile.powersink.IExternalPowerSink;
|
||||
@@ -76,7 +77,7 @@ public class IC2PowerSinkAdapter extends BasicSink implements IC2PowerSink
|
||||
@Override
|
||||
public double injectEnergy( EnumFacing directionFrom, double amount, double voltage )
|
||||
{
|
||||
return PowerUnits.EU.convertTo( PowerUnits.AE, this.powerSink.injectExternalPower( PowerUnits.EU, amount ) );
|
||||
return PowerUnits.EU.convertTo( PowerUnits.AE, this.powerSink.injectExternalPower( PowerUnits.EU, amount, Actionable.MODULATE ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.integration.modules.jei;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -35,6 +34,7 @@ import mezz.jei.api.gui.IDrawableStatic;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@@ -26,7 +26,6 @@ import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -34,6 +33,7 @@ import net.minecraftforge.fml.client.config.HoverChecker;
|
||||
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
import appeng.api.config.CondenserOutput;
|
||||
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@@ -88,12 +88,14 @@ class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipeWrapper>, IR
|
||||
itemStacks.set( ingredients );
|
||||
}
|
||||
|
||||
@Override public void addRecipeCategories( IRecipeCategory... recipeCategories )
|
||||
@Override
|
||||
public void addRecipeCategories( IRecipeCategory... recipeCategories )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override public IJeiHelpers getJeiHelpers()
|
||||
@Override
|
||||
public IJeiHelpers getJeiHelpers()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
|
||||
|
||||
class GrinderRecipeHandler implements IRecipeWrapperFactory<IGrinderRecipe>
|
||||
|
||||
@@ -23,13 +23,13 @@ import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
import appeng.api.features.IGrinderRecipe;
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -32,6 +30,7 @@ import mezz.jei.api.gui.IDrawableStatic;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ package appeng.integration.modules.jei;
|
||||
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeWrapperFactory;
|
||||
|
||||
|
||||
class InscriberRecipeHandler implements IRecipeWrapperFactory<IInscriberRecipe>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user