pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
@@ -18,114 +18,95 @@
package appeng.recipes.conditions;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.api.features.AEFeature;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.conditions.ICondition;
import net.minecraftforge.common.crafting.conditions.IConditionSerializer;
import java.util.Arrays;
import java.util.Locale;
import java.util.Set;
import java.util.stream.StreamSupport;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
public class FeaturesEnabled implements ICondition
{
private static final ResourceLocation NAME = new ResourceLocation( AppEng.MOD_ID, "feature" );
private final AEFeature[] features;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.conditions.ICondition;
import net.minecraftforge.common.crafting.conditions.IConditionSerializer;
public FeaturesEnabled( AEFeature... features )
{
this.features = features;
}
import appeng.api.features.AEFeature;
import appeng.core.AEConfig;
import appeng.core.AppEng;
public FeaturesEnabled( Set<AEFeature> features ) {
this(features.toArray(new AEFeature[0]));
}
public class FeaturesEnabled implements ICondition {
private static final ResourceLocation NAME = new ResourceLocation(AppEng.MOD_ID, "feature");
private final AEFeature[] features;
@Override
public ResourceLocation getID()
{
return NAME;
}
public FeaturesEnabled(AEFeature... features) {
this.features = features;
}
@Override
public boolean test()
{
for( AEFeature feature : features )
{
if( !AEConfig.instance().isFeatureEnabled( feature ) )
{
return false;
}
}
public FeaturesEnabled(Set<AEFeature> features) {
this(features.toArray(new AEFeature[0]));
}
return true;
}
@Override
public ResourceLocation getID() {
return NAME;
}
public static class Serializer implements IConditionSerializer<FeaturesEnabled>
{
private static final String JSON_FEATURES_KEY = "features";
@Override
public boolean test() {
for (AEFeature feature : features) {
if (!AEConfig.instance().isFeatureEnabled(feature)) {
return false;
}
}
public static final Serializer INSTANCE = new Serializer();
return true;
}
private Serializer()
{
}
public static class Serializer implements IConditionSerializer<FeaturesEnabled> {
private static final String JSON_FEATURES_KEY = "features";
@Override
public void write( JsonObject json, FeaturesEnabled value )
{
json.add( JSON_FEATURES_KEY, Arrays.stream( value.features )
.map( AEFeature::toString )
.reduce( new JsonArray(), ( JsonArray array, String string ) -> {
array.add( string );
return array;
}, ( a, b ) -> b ) );
}
public static final Serializer INSTANCE = new Serializer();
@Override
public FeaturesEnabled read( JsonObject jsonObject )
{
AEFeature[] features;
private Serializer() {
}
if( JSONUtils.isJsonArray( jsonObject, JSON_FEATURES_KEY ) )
{
final JsonArray featuresArray = JSONUtils.getJsonArray( jsonObject, JSON_FEATURES_KEY );
@Override
public void write(JsonObject json, FeaturesEnabled value) {
json.add(JSON_FEATURES_KEY, Arrays.stream(value.features).map(AEFeature::toString).reduce(new JsonArray(),
(JsonArray array, String string) -> {
array.add(string);
return array;
}, (a, b) -> b));
}
features = StreamSupport.stream( featuresArray.spliterator(), false )
.filter( JsonElement::isJsonPrimitive )
.map( JsonElement::getAsString )
.map( s -> s.toUpperCase( Locale.ENGLISH ) )
.map( AEFeature::valueOf )
.toArray( AEFeature[]::new );
}
else if( JSONUtils.isString( jsonObject, JSON_FEATURES_KEY ) )
{
final String featureName = JSONUtils.getString( jsonObject, JSON_FEATURES_KEY ).toUpperCase( Locale.ENGLISH );
features = new AEFeature[] { AEFeature.valueOf( featureName ) };
}
else
{
features = new AEFeature[] {};
}
@Override
public FeaturesEnabled read(JsonObject jsonObject) {
AEFeature[] features;
return new FeaturesEnabled( features );
}
if (JSONUtils.isJsonArray(jsonObject, JSON_FEATURES_KEY)) {
final JsonArray featuresArray = JSONUtils.getJsonArray(jsonObject, JSON_FEATURES_KEY);
@Override
public ResourceLocation getID()
{
return NAME;
}
features = StreamSupport.stream(featuresArray.spliterator(), false).filter(JsonElement::isJsonPrimitive)
.map(JsonElement::getAsString).map(s -> s.toUpperCase(Locale.ENGLISH)).map(AEFeature::valueOf)
.toArray(AEFeature[]::new);
} else if (JSONUtils.isString(jsonObject, JSON_FEATURES_KEY)) {
final String featureName = JSONUtils.getString(jsonObject, JSON_FEATURES_KEY)
.toUpperCase(Locale.ENGLISH);
features = new AEFeature[] { AEFeature.valueOf(featureName) };
} else {
features = new AEFeature[] {};
}
}
return new FeaturesEnabled(features);
}
@Override
public ResourceLocation getID() {
return NAME;
}
}
}
@@ -18,14 +18,12 @@
package appeng.recipes.game;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nonnull;
import appeng.api.AEApi;
import appeng.api.definitions.*;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AppEng;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -35,152 +33,132 @@ import net.minecraft.item.crafting.SpecialRecipeSerializer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import appeng.api.AEApi;
import appeng.api.definitions.*;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AppEng;
public final class DisassembleRecipe extends SpecialRecipe {
public static final IRecipeSerializer<DisassembleRecipe> SERIALIZER = new SpecialRecipeSerializer<>(
DisassembleRecipe::new);
public final class DisassembleRecipe extends SpecialRecipe
{
public static final IRecipeSerializer<DisassembleRecipe> SERIALIZER = new SpecialRecipeSerializer<>( DisassembleRecipe::new );
static {
SERIALIZER.setRegistryName(new ResourceLocation(AppEng.MOD_ID, "disassemble_recipe"));
}
static
{
SERIALIZER.setRegistryName( new ResourceLocation( AppEng.MOD_ID, "disassemble_recipe" ) );
}
private static final ItemStack MISMATCHED_STACK = ItemStack.EMPTY;
private static final ItemStack MISMATCHED_STACK = ItemStack.EMPTY;
private final Map<IItemDefinition, IItemDefinition> cellMappings;
private final Map<IItemDefinition, IItemDefinition> nonCellMappings;
private final Map<IItemDefinition, IItemDefinition> cellMappings;
private final Map<IItemDefinition, IItemDefinition> nonCellMappings;
public DisassembleRecipe(ResourceLocation id) {
super(id);
public DisassembleRecipe( ResourceLocation id )
{
super( id );
final IDefinitions definitions = AEApi.instance().definitions();
final IBlocks blocks = definitions.blocks();
final IItems items = definitions.items();
final IMaterials mats = definitions.materials();
final IDefinitions definitions = AEApi.instance().definitions();
final IBlocks blocks = definitions.blocks();
final IItems items = definitions.items();
final IMaterials mats = definitions.materials();
this.cellMappings = new HashMap<>(4);
this.nonCellMappings = new HashMap<>(5);
this.cellMappings = new HashMap<>( 4 );
this.nonCellMappings = new HashMap<>( 5 );
this.cellMappings.put(items.cell1k(), mats.cell1kPart());
this.cellMappings.put(items.cell4k(), mats.cell4kPart());
this.cellMappings.put(items.cell16k(), mats.cell16kPart());
this.cellMappings.put(items.cell64k(), mats.cell64kPart());
this.cellMappings.put( items.cell1k(), mats.cell1kPart() );
this.cellMappings.put( items.cell4k(), mats.cell4kPart() );
this.cellMappings.put( items.cell16k(), mats.cell16kPart() );
this.cellMappings.put( items.cell64k(), mats.cell64kPart() );
this.nonCellMappings.put(items.encodedPattern(), mats.blankPattern());
this.nonCellMappings.put(blocks.craftingStorage1k(), mats.cell1kPart());
this.nonCellMappings.put(blocks.craftingStorage4k(), mats.cell4kPart());
this.nonCellMappings.put(blocks.craftingStorage16k(), mats.cell16kPart());
this.nonCellMappings.put(blocks.craftingStorage64k(), mats.cell64kPart());
}
this.nonCellMappings.put( items.encodedPattern(), mats.blankPattern() );
this.nonCellMappings.put( blocks.craftingStorage1k(), mats.cell1kPart() );
this.nonCellMappings.put( blocks.craftingStorage4k(), mats.cell4kPart() );
this.nonCellMappings.put( blocks.craftingStorage16k(), mats.cell16kPart() );
this.nonCellMappings.put( blocks.craftingStorage64k(), mats.cell64kPart() );
}
@Override
public boolean matches(@Nonnull final CraftingInventory inv, @Nonnull final World w) {
return !this.getOutput(inv).isEmpty();
}
@Override
public boolean matches( @Nonnull final CraftingInventory inv, @Nonnull final World w )
{
return !this.getOutput( inv ).isEmpty();
}
@Nonnull
private ItemStack getOutput(final IInventory inventory) {
int itemCount = 0;
ItemStack output = MISMATCHED_STACK;
@Nonnull
private ItemStack getOutput( final IInventory inventory )
{
int itemCount = 0;
ItemStack output = MISMATCHED_STACK;
for (int slotIndex = 0; slotIndex < inventory.getSizeInventory(); slotIndex++) {
final ItemStack stackInSlot = inventory.getStackInSlot(slotIndex);
if (!stackInSlot.isEmpty()) {
// needs a single input in the recipe
itemCount++;
if (itemCount > 1) {
return MISMATCHED_STACK;
}
for( int slotIndex = 0; slotIndex < inventory.getSizeInventory(); slotIndex++ )
{
final ItemStack stackInSlot = inventory.getStackInSlot( slotIndex );
if( !stackInSlot.isEmpty() )
{
// needs a single input in the recipe
itemCount++;
if( itemCount > 1 )
{
return MISMATCHED_STACK;
}
// handle storage cells
Optional<ItemStack> maybeCellOutput = this.getCellOutput(stackInSlot);
if (maybeCellOutput.isPresent()) {
ItemStack storageCellStack = maybeCellOutput.get();
// make sure the storage cell stackInSlot empty...
final IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell().getCellInventory(
stackInSlot, null, AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
if (cellInv != null) {
final IItemList<IAEItemStack> list = cellInv.getAvailableItems(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
if (!list.isEmpty()) {
return ItemStack.EMPTY;
}
}
// handle storage cells
Optional<ItemStack> maybeCellOutput = this.getCellOutput( stackInSlot );
if( maybeCellOutput.isPresent() )
{
ItemStack storageCellStack = maybeCellOutput.get();
// make sure the storage cell stackInSlot empty...
final IMEInventory<IAEItemStack> cellInv = AEApi.instance()
.registries()
.cell()
.getCellInventory( stackInSlot, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( cellInv != null )
{
final IItemList<IAEItemStack> list = cellInv
.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
if( !list.isEmpty() )
{
return ItemStack.EMPTY;
}
}
output = storageCellStack;
}
output = storageCellStack;
}
// handle crafting storage blocks
output = this.getNonCellOutput(stackInSlot).orElse(output);
}
}
// handle crafting storage blocks
output = this.getNonCellOutput( stackInSlot ).orElse( output );
}
}
return output;
}
return output;
}
@Nonnull
private Optional<ItemStack> getCellOutput(final ItemStack compared) {
for (final Map.Entry<IItemDefinition, IItemDefinition> entry : this.cellMappings.entrySet()) {
if (entry.getKey().isSameAs(compared)) {
return entry.getValue().maybeStack(1);
}
}
@Nonnull
private Optional<ItemStack> getCellOutput( final ItemStack compared )
{
for( final Map.Entry<IItemDefinition, IItemDefinition> entry : this.cellMappings.entrySet() )
{
if( entry.getKey().isSameAs( compared ) )
{
return entry.getValue().maybeStack( 1 );
}
}
return Optional.empty();
}
return Optional.empty();
}
@Nonnull
private Optional<ItemStack> getNonCellOutput(final ItemStack compared) {
for (final Map.Entry<IItemDefinition, IItemDefinition> entry : this.nonCellMappings.entrySet()) {
if (entry.getKey().isSameAs(compared)) {
return entry.getValue().maybeStack(1);
}
}
@Nonnull
private Optional<ItemStack> getNonCellOutput( final ItemStack compared )
{
for( final Map.Entry<IItemDefinition, IItemDefinition> entry : this.nonCellMappings.entrySet() )
{
if( entry.getKey().isSameAs( compared ) )
{
return entry.getValue().maybeStack( 1 );
}
}
return Optional.empty();
}
return Optional.empty();
}
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull final CraftingInventory inv) {
return this.getOutput(inv);
}
@Nonnull
@Override
public ItemStack getCraftingResult( @Nonnull final CraftingInventory inv )
{
return this.getOutput( inv );
}
@Override
public boolean canFit(int i, int i1) {
return false;
}
@Override
public boolean canFit( int i, int i1 )
{
return false;
}
@Nonnull
@Override
public IRecipeSerializer<DisassembleRecipe> getSerializer()
{
return SERIALIZER;
}
@Nonnull
@Override
public IRecipeSerializer<DisassembleRecipe> getSerializer() {
return SERIALIZER;
}
}
@@ -18,12 +18,8 @@
package appeng.recipes.game;
import javax.annotation.Nonnull;
import appeng.api.AEApi;
import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IDefinitions;
import appeng.core.AppEng;
import appeng.items.parts.ItemFacade;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -33,78 +29,70 @@ import net.minecraft.item.crafting.SpecialRecipeSerializer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import appeng.api.AEApi;
import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IDefinitions;
import appeng.core.AppEng;
import appeng.items.parts.ItemFacade;
public final class FacadeRecipe extends SpecialRecipe {
public static SpecialRecipeSerializer<FacadeRecipe> SERIALIZER = null;
public final class FacadeRecipe extends SpecialRecipe
{
public static SpecialRecipeSerializer<FacadeRecipe> SERIALIZER = null;
private final IComparableDefinition anchor;
private final ItemFacade facade;
private final IComparableDefinition anchor;
private final ItemFacade facade;
public FacadeRecipe(ResourceLocation id, ItemFacade facade) {
super(id);
this.facade = facade;
final IDefinitions definitions = AEApi.instance().definitions();
public FacadeRecipe( ResourceLocation id, ItemFacade facade )
{
super( id );
this.facade = facade;
final IDefinitions definitions = AEApi.instance().definitions();
this.anchor = definitions.parts().cableAnchor();
}
this.anchor = definitions.parts().cableAnchor();
}
@Override
public boolean matches(@Nonnull final CraftingInventory inv, @Nonnull final World w) {
return !this.getOutput(inv, false).isEmpty();
}
@Override
public boolean matches( @Nonnull final CraftingInventory inv, @Nonnull final World w )
{
return !this.getOutput( inv, false ).isEmpty();
}
@Nonnull
private ItemStack getOutput(final IInventory inv, final boolean createFacade) {
if (inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(2).isEmpty() && inv.getStackInSlot(6).isEmpty()
&& inv.getStackInSlot(8).isEmpty()) {
if (this.anchor.isSameAs(inv.getStackInSlot(1)) && this.anchor.isSameAs(inv.getStackInSlot(3))
&& this.anchor.isSameAs(inv.getStackInSlot(5)) && this.anchor.isSameAs(inv.getStackInSlot(7))) {
final ItemStack facades = this.facade.createFacadeForItem(inv.getStackInSlot(4), !createFacade);
if (!facades.isEmpty() && createFacade) {
facades.setCount(4);
}
return facades;
}
}
@Nonnull
private ItemStack getOutput( final IInventory inv, final boolean createFacade )
{
if( inv.getStackInSlot( 0 ).isEmpty() && inv.getStackInSlot( 2 ).isEmpty() && inv.getStackInSlot( 6 ).isEmpty() && inv.getStackInSlot( 8 ).isEmpty() )
{
if( this.anchor.isSameAs( inv.getStackInSlot( 1 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 3 ) ) && this.anchor
.isSameAs( inv.getStackInSlot( 5 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 7 ) ) )
{
final ItemStack facades = this.facade.createFacadeForItem( inv.getStackInSlot( 4 ), !createFacade );
if( !facades.isEmpty() && createFacade )
{
facades.setCount( 4 );
}
return facades;
}
}
return ItemStack.EMPTY;
}
return ItemStack.EMPTY;
}
@Override
public ItemStack getCraftingResult(@Nonnull final CraftingInventory inv) {
return this.getOutput(inv, true);
}
@Override
public ItemStack getCraftingResult( @Nonnull final CraftingInventory inv )
{
return this.getOutput( inv, true );
}
@Override
public boolean canFit(int i, int i1) {
return false;
}
@Override
public boolean canFit( int i, int i1 )
{
return false;
}
@Nonnull
@Override
public IRecipeSerializer<FacadeRecipe> getSerializer() {
return getSerializer(facade);
}
@Nonnull
@Override
public IRecipeSerializer<FacadeRecipe> getSerializer()
{
return getSerializer( facade );
}
public static IRecipeSerializer<FacadeRecipe> getSerializer( ItemFacade facade )
{
if( SERIALIZER == null )
{
SERIALIZER = new SpecialRecipeSerializer<>( id -> new FacadeRecipe( id, facade ) );
SERIALIZER.setRegistryName( new ResourceLocation( AppEng.MOD_ID, "facade_recipe" ) );
}
return SERIALIZER;
}
public static IRecipeSerializer<FacadeRecipe> getSerializer(ItemFacade facade) {
if (SERIALIZER == null) {
SERIALIZER = new SpecialRecipeSerializer<>(id -> new FacadeRecipe(id, facade));
SERIALIZER.setRegistryName(new ResourceLocation(AppEng.MOD_ID, "facade_recipe"));
}
return SERIALIZER;
}
}
@@ -1,6 +1,9 @@
package appeng.recipes.handlers;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
@@ -11,8 +14,6 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import java.util.List;
public class GrinderRecipe implements IRecipe<IInventory> {
public static IRecipeType<GrinderRecipe> TYPE;
@@ -25,7 +26,8 @@ public class GrinderRecipe implements IRecipe<IInventory> {
private final List<GrinderOptionalResult> optionalResults;
private final int turns;
public GrinderRecipe(ResourceLocation id, String group, Ingredient ingredient, int ingredientCount, ItemStack result, int turns, List<GrinderOptionalResult> optionalResults) {
public GrinderRecipe(ResourceLocation id, String group, Ingredient ingredient, int ingredientCount,
ItemStack result, int turns, List<GrinderOptionalResult> optionalResults) {
this.id = id;
this.group = group;
this.ingredient = ingredient;
@@ -1,10 +1,15 @@
package appeng.recipes.handlers;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
@@ -14,12 +19,11 @@ import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistryEntry;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import appeng.core.AEConfig;
import appeng.core.AppEng;
public class GrinderRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<GrinderRecipe> {
public class GrinderRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>>
implements IRecipeSerializer<GrinderRecipe> {
public static final GrinderRecipeSerializer INSTANCE = new GrinderRecipeSerializer();
@@ -1,19 +1,20 @@
package appeng.recipes.handlers;
import javax.annotation.Nullable;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World;
import javax.annotation.Nullable;
public final class GrinderRecipes {
private GrinderRecipes() {
}
/**
* Search all available Grinder recipes for a recipe matching the given input or null;
* Search all available Grinder recipes for a recipe matching the given input or
* null;
*/
@Nullable
public static GrinderRecipe findForInput(World world, ItemStack input) {
@@ -27,7 +28,8 @@ public final class GrinderRecipes {
}
/**
* Checks if the given item stack is an ingredient in any grinder recipe, disregarding its current size.
* Checks if the given item stack is an ingredient in any grinder recipe,
* disregarding its current size.
*/
public static boolean isValidIngredient(World world, ItemStack stack) {
for (IRecipe<IInventory> recipe : world.getRecipeManager().getRecipes(GrinderRecipe.TYPE).values()) {
@@ -1,6 +1,7 @@
package appeng.recipes.handlers;
import appeng.api.features.InscriberProcessType;
import javax.annotation.Nullable;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
@@ -11,7 +12,7 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import appeng.api.features.InscriberProcessType;
public class InscriberRecipe implements IRecipe<IInventory> {
@@ -26,7 +27,8 @@ public class InscriberRecipe implements IRecipe<IInventory> {
private ItemStack output;
private InscriberProcessType processType;
public InscriberRecipe(ResourceLocation id, String group, Ingredient middleInput, ItemStack output, Ingredient topOptional, Ingredient bottomOptional, InscriberProcessType processType) {
public InscriberRecipe(ResourceLocation id, String group, Ingredient middleInput, ItemStack output,
Ingredient topOptional, Ingredient bottomOptional, InscriberProcessType processType) {
this.id = id;
this.group = group;
this.middleInput = middleInput;
@@ -1,8 +1,9 @@
package appeng.recipes.handlers;
import appeng.api.features.InscriberProcessType;
import appeng.core.AppEng;
import javax.annotation.Nullable;
import com.google.gson.JsonObject;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
@@ -12,9 +13,11 @@ import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistryEntry;
import javax.annotation.Nullable;
import appeng.api.features.InscriberProcessType;
import appeng.core.AppEng;
public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<InscriberRecipe> {
public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>>
implements IRecipeSerializer<InscriberRecipe> {
public static final InscriberRecipeSerializer INSTANCE = new InscriberRecipeSerializer();
@@ -26,7 +29,7 @@ public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSeriali
}
private static InscriberProcessType getMode(JsonObject json) {
String mode = JSONUtils.getString( json, "mode", "inscribe" );
String mode = JSONUtils.getString(json, "mode", "inscribe");
switch (mode) {
case "inscribe":
return InscriberProcessType.INSCRIBE;
@@ -47,18 +50,16 @@ public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSeriali
ItemStack result = ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, "result"));
// Deserialize the three parts of the input
JsonObject ingredients = JSONUtils.getJsonObject( json, "ingredients" );
Ingredient middle = Ingredient.deserialize( ingredients.get( "middle" ) );
Ingredient top = Ingredient.EMPTY;
if( ingredients.has( "top" ) )
{
top = Ingredient.deserialize( ingredients.get( "top" ) );
}
Ingredient bottom = Ingredient.EMPTY;
if( ingredients.has( "bottom" ) )
{
bottom = Ingredient.deserialize( ingredients.get( "bottom" ) );
}
JsonObject ingredients = JSONUtils.getJsonObject(json, "ingredients");
Ingredient middle = Ingredient.deserialize(ingredients.get("middle"));
Ingredient top = Ingredient.EMPTY;
if (ingredients.has("top")) {
top = Ingredient.deserialize(ingredients.get("top"));
}
Ingredient bottom = Ingredient.EMPTY;
if (ingredients.has("bottom")) {
bottom = Ingredient.deserialize(ingredients.get("bottom"));
}
return new InscriberRecipe(recipeId, group, middle, result, top, bottom, mode);
}