Moving files over to datapack directory.

This commit is contained in:
Sebastian Hartte
2020-06-10 00:57:28 +02:00
parent 5f416bcca2
commit 8c45807ecd
359 changed files with 316 additions and 447 deletions
@@ -629,8 +629,6 @@ final class Registration
);
CraftingHelper.register( FeaturesEnabled.Serializer.INSTANCE );
CraftingHelper.register( new ResourceLocation( AppEng.MOD_ID, "part" ), PartIngredientSerializer.INSTANCE );
}
@@ -1,35 +0,0 @@
package appeng.recipes.ingredients;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import java.util.Arrays;
import java.util.stream.Stream;
public class PartIngredient extends Ingredient
{
private final String partName;
protected PartIngredient( String partName, Stream<? extends IItemList> itemLists )
{
super( itemLists );
this.partName = partName;
}
public static PartIngredient fromStacks(String partName, ItemStack... stacks) {
return new PartIngredient( partName, Arrays.stream( stacks ).map( SingleItemList::new ) );
}
public static PartIngredient empty( String partName )
{
return new PartIngredient( partName, Stream.empty() );
}
public String getPartName()
{
return partName;
}
}
@@ -1,94 +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.recipes.ingredients;
import appeng.api.AEApi;
import appeng.api.recipes.ResolverResult;
import appeng.api.recipes.ResolverResultSet;
import appeng.core.AELog;
import appeng.core.AppEng;
import com.google.gson.JsonObject;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.IIngredientSerializer;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nonnull;
public class PartIngredientSerializer implements IIngredientSerializer<PartIngredient>
{
public static PartIngredientSerializer INSTANCE = new PartIngredientSerializer();
private PartIngredientSerializer()
{
}
@Nonnull
@Override
public PartIngredient parse( JsonObject json )
{
final String partName = json.get( "part" ).getAsString();
return getPart( partName );
}
@Nonnull
@Override
public PartIngredient parse( PacketBuffer buffer )
{
return getPart( buffer.readString() );
}
@Override
public void write( @Nonnull PacketBuffer buffer, @Nonnull PartIngredient ingredient )
{
buffer.writeString( ingredient.getPartName() );
}
private PartIngredient getPart( String partName )
{
final Object result = AEApi.instance().registries().recipes().resolveItem( AppEng.MOD_ID, partName );
if( result instanceof ResolverResultSet )
{
final ResolverResultSet resolverResultSet = (ResolverResultSet) result;
return PartIngredient
.fromStacks( partName, resolverResultSet.results.toArray( new ItemStack[0] ) );
}
else if( result instanceof ResolverResult )
{
final ResolverResult resolverResult = (ResolverResult) result;
final Item item = ForgeRegistries.ITEMS.getValue( new ResourceLocation( AppEng.MOD_ID, resolverResult.itemName ) );
final ItemStack itemStack = new ItemStack( item, 1, resolverResult.compound );
itemStack.setDamage( resolverResult.damageValue );
return PartIngredient.fromStacks( partName, itemStack );
}
AELog.warn( "Looking for ingredient with name '" + partName + "' ended up with a null item!" );
return PartIngredient.empty( partName );
}
}

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