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,13 +19,12 @@
package appeng.recipes.game;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
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 net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
@@ -34,154 +33,130 @@ import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import appeng.api.AEApi;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems;
import appeng.api.definitions.IMaterials;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public final class DisassembleRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
{
private static final ItemStack MISMATCHED_STACK = ItemStack.EMPTY;
public final class DisassembleRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
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()
{
final IDefinitions definitions = AEApi.instance().definitions();
final IBlocks blocks = definitions.blocks();
final IItems items = definitions.items();
final IMaterials mats = definitions.materials();
public DisassembleRecipe() {
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( final InventoryCrafting inv, final World w )
{
return !this.getOutput( inv ).isEmpty();
}
@Override
public boolean matches(final InventoryCrafting inv, final World w) {
return !this.getOutput(inv).isEmpty();
}
@Nullable
private ItemStack getOutput( final IInventory inventory )
{
int itemCount = 0;
ItemStack output = MISMATCHED_STACK;
@Nullable
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();
}
@Nullable
@Override
public ItemStack getCraftingResult( final InventoryCrafting inv )
{
return this.getOutput( inv );
}
@Nullable
@Override
public ItemStack getCraftingResult(final InventoryCrafting 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;
}
@Nullable
@Override
public ItemStack getRecipeOutput() // no default output..
{
return ItemStack.EMPTY;
}
@Nullable
@Override
public ItemStack getRecipeOutput() // no default output..
{
return ItemStack.EMPTY;
}
@Override
public NonNullList<ItemStack> getRemainingItems( final InventoryCrafting inv )
{
return ForgeHooks.defaultRecipeGetRemainingItems( inv );
}
@Override
public NonNullList<ItemStack> getRemainingItems(final InventoryCrafting inv) {
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
}
}
@@ -19,8 +19,10 @@
package appeng.recipes.game;
import javax.annotation.Nullable;
import appeng.api.AEApi;
import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IDefinitions;
import appeng.items.parts.ItemFacade;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
@@ -29,72 +31,59 @@ import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import appeng.api.AEApi;
import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IDefinitions;
import appeng.items.parts.ItemFacade;
import javax.annotation.Nullable;
public final class FacadeRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
{
private final IComparableDefinition anchor;
private final ItemFacade facade;
public final class FacadeRecipe extends net.minecraftforge.registries.IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
private final IComparableDefinition anchor;
private final ItemFacade facade;
public FacadeRecipe( ItemFacade facade )
{
this.facade = facade;
final IDefinitions definitions = AEApi.instance().definitions();
public FacadeRecipe(ItemFacade facade) {
this.facade = facade;
final IDefinitions definitions = AEApi.instance().definitions();
this.anchor = definitions.parts().cableAnchor();
}
this.anchor = definitions.parts().cableAnchor();
}
@Override
public boolean matches( final InventoryCrafting inv, final World w )
{
return !this.getOutput( inv, false ).isEmpty();
}
@Override
public boolean matches(final InventoryCrafting inv, final World w) {
return !this.getOutput(inv, false).isEmpty();
}
@Nullable
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;
}
}
@Nullable
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( final InventoryCrafting inv )
{
return this.getOutput( inv, true );
}
@Override
public ItemStack getCraftingResult(final InventoryCrafting 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;
}
@Override
public ItemStack getRecipeOutput() // no default output..
{
return ItemStack.EMPTY;
}
@Override
public ItemStack getRecipeOutput() // no default output..
{
return ItemStack.EMPTY;
}
@Override
public NonNullList<ItemStack> getRemainingItems( final InventoryCrafting inv )
{
return ForgeHooks.defaultRecipeGetRemainingItems( inv );
}
@Override
public NonNullList<ItemStack> getRemainingItems(final InventoryCrafting inv) {
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
}
}