Skip to content

Commit

Permalink
Restructured registry packages (AppliedEnergistics#2703)
Browse files Browse the repository at this point in the history
Moved larger registries together with their related classes instead of putting unrelated classes into the same package.
  • Loading branch information
yueh authored and phit committed Dec 19, 2016
1 parent e3fecbc commit e860f52
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/main/java/appeng/core/Registration.java
Expand Up @@ -57,8 +57,8 @@
import appeng.capabilities.Capabilities;
import appeng.core.features.AEFeature;
import appeng.core.features.registries.P2PTunnelRegistry;
import appeng.core.features.registries.entries.BasicCellHandler;
import appeng.core.features.registries.entries.CreativeCellHandler;
import appeng.core.features.registries.cell.BasicCellHandler;
import appeng.core.features.registries.cell.CreativeCellHandler;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.core.stats.PlayerStatsRegistration;
Expand Down
Expand Up @@ -34,6 +34,9 @@
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.parts.IPartModels;
import appeng.api.storage.ICellRegistry;
import appeng.core.features.registries.cell.CellRegistry;
import appeng.core.features.registries.grinder.GrinderRecipeManager;
import appeng.core.features.registries.inscriber.InscriberRegistry;


/**
Expand Down
Expand Up @@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.core.features.registries.entries;
package appeng.core.features.registries.cell;


import net.minecraft.entity.player.EntityPlayer;
Expand Down
Expand Up @@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.core.features.registries;
package appeng.core.features.registries.cell;


import java.util.ArrayList;
Expand Down
Expand Up @@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.core.features.registries.entries;
package appeng.core.features.registries.cell;


import net.minecraft.entity.player.EntityPlayer;
Expand Down
Expand Up @@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.core.features.registries.entries;
package appeng.core.features.registries.grinder;


import java.util.Optional;
Expand All @@ -40,17 +40,17 @@ public class AppEngGrinderRecipe implements IGrinderRecipe

private final int turns;

public AppEngGrinderRecipe( final ItemStack input, final ItemStack output, final int cost )
AppEngGrinderRecipe( final ItemStack input, final ItemStack output, final int cost )
{
this( input, output, null, null, 0, 0, cost );
}

public AppEngGrinderRecipe( final ItemStack input, final ItemStack output, final ItemStack optional, final float chance, final int cost )
AppEngGrinderRecipe( final ItemStack input, final ItemStack output, final ItemStack optional, final float chance, final int cost )
{
this( input, output, optional, null, chance, 0, cost );
}

public AppEngGrinderRecipe( final ItemStack input, final ItemStack output, final ItemStack optional1, final ItemStack optional2, final float chance1, final float chance2, final int cost )
AppEngGrinderRecipe( final ItemStack input, final ItemStack output, final ItemStack optional1, final ItemStack optional2, final float chance1, final float chance2, final int cost )
{
this.in = input;
this.out = output;
Expand Down
Expand Up @@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.core.features.registries;
package appeng.core.features.registries.grinder;


import java.util.Collection;
Expand All @@ -36,7 +36,6 @@
import appeng.api.features.IGrinderRegistry;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.features.registries.entries.AppEngGrinderRecipe;
import appeng.recipes.ores.IOreListener;
import appeng.recipes.ores.OreDictionaryHandler;
import appeng.util.Platform;
Expand Down
Expand Up @@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.core.features.registries.entries;
package appeng.core.features.registries.inscriber;


import java.util.Collection;
Expand All @@ -38,7 +38,7 @@
*/
public class InscriberInscribeRecipe extends InscriberRecipe
{
public InscriberInscribeRecipe( @Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot )
InscriberInscribeRecipe( @Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot )
{
super( inputs, output, top, bot, InscriberProcessType.INSCRIBE );
}
Expand Down
Expand Up @@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.core.features.registries.entries;
package appeng.core.features.registries.inscriber;


import java.util.ArrayList;
Expand Down Expand Up @@ -57,7 +57,7 @@ public class InscriberRecipe implements IInscriberRecipe
@Nonnull
private final InscriberProcessType type;

public InscriberRecipe( @Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot, @Nonnull final InscriberProcessType type )
InscriberRecipe( @Nonnull final Collection<ItemStack> inputs, @Nonnull final ItemStack output, @Nullable final ItemStack top, @Nullable final ItemStack bot, @Nonnull final InscriberProcessType type )
{
this.inputs = new ArrayList<ItemStack>( inputs.size() );
this.inputs.addAll( inputs );
Expand Down
Expand Up @@ -16,7 +16,7 @@
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/

package appeng.core.features.registries;
package appeng.core.features.registries.inscriber;


import java.util.ArrayList;
Expand All @@ -35,7 +35,6 @@
import appeng.api.features.IInscriberRecipeBuilder;
import appeng.api.features.IInscriberRegistry;
import appeng.api.features.InscriberProcessType;
import appeng.core.features.registries.entries.InscriberRecipe;


/**
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/appeng/recipes/handlers/Inscribe.java
Expand Up @@ -29,8 +29,8 @@
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.features.IInscriberRecipe;
import appeng.api.features.IInscriberRecipeBuilder;
import appeng.api.features.InscriberProcessType;
import appeng.core.features.registries.entries.InscriberRecipe;


/**
Expand All @@ -55,6 +55,7 @@ public void register() throws RegistrationError, MissingIngredientError
return;
}

final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
final ItemStack[] realInput = this.getImprintable().getItemStackSet();
final List<ItemStack> inputs = new ArrayList<ItemStack>( realInput.length );
Collections.addAll( inputs, realInput );
Expand All @@ -63,7 +64,12 @@ public void register() throws RegistrationError, MissingIngredientError
final ItemStack output = this.getOutput().getItemStack();
final InscriberProcessType type = InscriberProcessType.INSCRIBE;

final IInscriberRecipe recipe = new InscriberRecipe( inputs, output, top, bot, type );
final IInscriberRecipe recipe = builder.withInputs( inputs )
.withOutput( output )
.withTopOptional( top )
.withBottomOptional( bot )
.withProcessType( type )
.build();

AEApi.instance().registries().inscriber().addRecipe( recipe );
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/appeng/recipes/handlers/Press.java
Expand Up @@ -29,8 +29,8 @@
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;
import appeng.api.features.IInscriberRecipe;
import appeng.api.features.IInscriberRecipeBuilder;
import appeng.api.features.InscriberProcessType;
import appeng.core.features.registries.entries.InscriberRecipe;


/**
Expand All @@ -55,6 +55,7 @@ public void register() throws RegistrationError, MissingIngredientError
return;
}

final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
final ItemStack[] realInput = this.getImprintable().getItemStackSet();
final List<ItemStack> inputs = new ArrayList<ItemStack>( realInput.length );
Collections.addAll( inputs, realInput );
Expand All @@ -63,7 +64,12 @@ public void register() throws RegistrationError, MissingIngredientError
final ItemStack output = this.getOutput().getItemStack();
final InscriberProcessType type = InscriberProcessType.PRESS;

final IInscriberRecipe recipe = new InscriberRecipe( inputs, output, top, bot, type );
final IInscriberRecipe recipe = builder.withInputs( inputs )
.withOutput( output )
.withTopOptional( top )
.withBottomOptional( bot )
.withProcessType( type )
.build();

AEApi.instance().registries().inscriber().addRecipe( recipe );
}
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/appeng/tile/misc/TileInscriber.java
Expand Up @@ -22,6 +22,7 @@
import java.io.IOException;
import java.util.EnumSet;
import java.util.List;

import javax.annotation.Nullable;

import com.google.common.collect.Lists;
Expand All @@ -45,6 +46,7 @@
import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.ITileDefinition;
import appeng.api.features.IInscriberRecipe;
import appeng.api.features.IInscriberRecipeBuilder;
import appeng.api.features.InscriberProcessType;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.networking.IGridNode;
Expand All @@ -56,7 +58,6 @@
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IConfigManager;
import appeng.core.features.registries.entries.InscriberRecipe;
import appeng.core.settings.TickRates;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
Expand Down Expand Up @@ -403,18 +404,28 @@ public IInscriberRecipe getTask()
final List<ItemStack> inputs = Lists.newArrayList( startingItem );
final InscriberProcessType type = InscriberProcessType.INSCRIBE;

return new InscriberRecipe( inputs, renamedItem, plateA, plateB, type );
final IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder();
return builder.withInputs( inputs )
.withOutput( renamedItem )
.withTopOptional( plateA )
.withBottomOptional( plateB )
.withProcessType( type )
.build();
}
}

for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
{

final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA, recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateB, recipe.getBottomOptional().orElse( null ) ) );
final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA,
recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateB,
recipe.getBottomOptional().orElse( null ) ) );

final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB, recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateA, recipe.getBottomOptional().orElse( null ) ) );
final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB,
recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateA,
recipe.getBottomOptional().orElse( null ) ) );

if( matchA || matchB )
{
Expand Down

0 comments on commit e860f52

Please sign in to comment.