reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
@@ -19,19 +19,20 @@
package appeng.integration.modules.jei;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketJEIRecipe;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.util.Platform;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import mezz.jei.transfer.RecipeTransferErrorInternal;
import mezz.jei.transfer.RecipeTransferErrorTooltip;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
@@ -39,157 +40,121 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketJEIRecipe;
import appeng.util.Platform;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T>
{
class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandler<T> {
private final Class<T> containerClass;
private final Class<T> containerClass;
RecipeTransferHandler( Class<T> containerClass )
{
this.containerClass = containerClass;
}
RecipeTransferHandler(Class<T> containerClass) {
this.containerClass = containerClass;
}
@Override
public Class<T> getContainerClass()
{
return this.containerClass;
}
@Override
public Class<T> getContainerClass() {
return this.containerClass;
}
@Nullable
@Override
public IRecipeTransferError transferRecipe( T container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer )
{
final String recipeType = recipeLayout.getRecipeCategory().getUid();
@Nullable
@Override
public IRecipeTransferError transferRecipe(T container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
final String recipeType = recipeLayout.getRecipeCategory().getUid();
if (recipeType.equals( VanillaRecipeCategoryUid.INFORMATION) || recipeType.equals(VanillaRecipeCategoryUid.FUEL))
{
return RecipeTransferErrorInternal.INSTANCE;
}
if (recipeType.equals(VanillaRecipeCategoryUid.INFORMATION) || recipeType.equals(VanillaRecipeCategoryUid.FUEL)) {
return RecipeTransferErrorInternal.INSTANCE;
}
if( !doTransfer )
{
return null;
}
if (!doTransfer) {
return null;
}
if( container instanceof ContainerPatternTerm )
{
try
{
if( !( (ContainerPatternTerm) container ).isCraftingMode() )
{
if( recipeType.equals( VanillaRecipeCategoryUid.CRAFTING ) )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", "1" ) );
}
}
else if( !recipeType.equals( VanillaRecipeCategoryUid.CRAFTING ) )
{
if (container instanceof ContainerPatternTerm) {
try {
if (!((ContainerPatternTerm) container).isCraftingMode()) {
if (recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) {
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", "1"));
}
} else if (!recipeType.equals(VanillaRecipeCategoryUid.CRAFTING)) {
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", "0" ) );
}
NetworkHandler.instance().sendToServer(new PacketValueConfig("PatternTerminal.CraftMode", "0"));
}
}
catch( IOException e )
{
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks().getGuiIngredients();
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks().getGuiIngredients();
final NBTTagCompound recipe = new NBTTagCompound();
final NBTTagList outputs = new NBTTagList();
final NBTTagCompound recipe = new NBTTagCompound();
final NBTTagList outputs = new NBTTagList();
int slotIndex = 0;
for( Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> ingredientEntry : ingredients.entrySet() )
{
IGuiIngredient<ItemStack> ingredient = ingredientEntry.getValue();
if( !ingredient.isInput() )
{
ItemStack output = ingredient.getDisplayedIngredient();
if( output != null )
{
final NBTTagCompound tag = new NBTTagCompound();
output.writeToNBT( tag );
outputs.appendTag( tag );
}
continue;
}
int slotIndex = 0;
for (Map.Entry<Integer, ? extends IGuiIngredient<ItemStack>> ingredientEntry : ingredients.entrySet()) {
IGuiIngredient<ItemStack> ingredient = ingredientEntry.getValue();
if (!ingredient.isInput()) {
ItemStack output = ingredient.getDisplayedIngredient();
if (output != null) {
final NBTTagCompound tag = new NBTTagCompound();
output.writeToNBT(tag);
outputs.appendTag(tag);
}
continue;
}
for( final Slot slot : container.inventorySlots )
{
if( slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix )
{
if( slot.getSlotIndex() == slotIndex )
{
final NBTTagList tags = new NBTTagList();
final List<ItemStack> list = new ArrayList<>();
final ItemStack displayed = ingredient.getDisplayedIngredient();
for (final Slot slot : container.inventorySlots) {
if (slot instanceof SlotCraftingMatrix || slot instanceof SlotFakeCraftingMatrix) {
if (slot.getSlotIndex() == slotIndex) {
final NBTTagList tags = new NBTTagList();
final List<ItemStack> list = new ArrayList<>();
final ItemStack displayed = ingredient.getDisplayedIngredient();
// prefer currently displayed item
if( displayed != null && !displayed.isEmpty() )
{
list.add( displayed );
}
// prefer currently displayed item
if (displayed != null && !displayed.isEmpty()) {
list.add(displayed);
}
// prefer pure crystals.
for ( ItemStack stack : ingredient.getAllIngredients() )
{
if( stack == null )
{
continue;
}
if( Platform.isRecipePrioritized( stack ) )
{
list.add( 0, stack );
}
else
{
list.add( stack );
}
}
// prefer pure crystals.
for (ItemStack stack : ingredient.getAllIngredients()) {
if (stack == null) {
continue;
}
if (Platform.isRecipePrioritized(stack)) {
list.add(0, stack);
} else {
list.add(stack);
}
}
for ( final ItemStack is : list )
{
final NBTTagCompound tag = new NBTTagCompound();
is.writeToNBT( tag );
tags.appendTag( tag );
}
for (final ItemStack is : list) {
final NBTTagCompound tag = new NBTTagCompound();
is.writeToNBT(tag);
tags.appendTag(tag);
}
recipe.setTag( "#" + slot.getSlotIndex(), tags );
break;
}
}
}
recipe.setTag("#" + slot.getSlotIndex(), tags);
break;
}
}
}
slotIndex++;
}
slotIndex++;
}
recipe.setTag( "outputs", outputs );
recipe.setTag("outputs", outputs);
try
{
NetworkHandler.instance().sendToServer( new PacketJEIRecipe( recipe ) );
}
catch( IOException e )
{
AELog.debug( e );
}
try {
NetworkHandler.instance().sendToServer(new PacketJEIRecipe(recipe));
} catch (IOException e) {
AELog.debug(e);
}
return null;
}
return null;
}
}