Removed Inscriber Recipe Registry
Fixed Inscriber TESR rendering and added a small easing function
This commit is contained in:
@@ -20,7 +20,6 @@ package appeng.core.features.registries;
|
||||
|
||||
|
||||
import appeng.api.features.IChargerRegistry;
|
||||
import appeng.api.features.IInscriberRegistry;
|
||||
import appeng.api.features.ILocatableRegistry;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
@@ -35,7 +34,6 @@ import appeng.api.parts.IPartModels;
|
||||
import appeng.api.storage.ICellRegistry;
|
||||
import appeng.core.features.registries.cell.CellRegistry;
|
||||
import appeng.core.features.registries.charger.ChargerRegistry;
|
||||
import appeng.core.features.registries.inscriber.InscriberRegistry;
|
||||
|
||||
|
||||
/**
|
||||
@@ -49,7 +47,6 @@ import appeng.core.features.registries.inscriber.InscriberRegistry;
|
||||
*/
|
||||
public class RegistryContainer implements IRegistryContainer
|
||||
{
|
||||
private final IInscriberRegistry inscriber = new InscriberRegistry();
|
||||
private final IChargerRegistry charger = new ChargerRegistry();
|
||||
private final ICellRegistry cell = new CellRegistry();
|
||||
private final ILocatableRegistry locatable = new LocatableRegistry();
|
||||
@@ -92,12 +89,6 @@ public class RegistryContainer implements IRegistryContainer
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInscriberRegistry inscriber()
|
||||
{
|
||||
return this.inscriber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChargerRegistry charger()
|
||||
{
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.core.features.registries.inscriber;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
|
||||
|
||||
/**
|
||||
* inscribe recipes do not use up the provided optional upon craft
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public class InscriberInscribeRecipe extends InscriberRecipe
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, 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.core.features.registries.inscriber;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
|
||||
|
||||
/**
|
||||
* Basic inscriber recipe
|
||||
*
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv2
|
||||
*/
|
||||
public class InscriberRecipe implements IInscriberRecipe
|
||||
{
|
||||
@Nonnull
|
||||
private final List<ItemStack> inputs;
|
||||
|
||||
@Nonnull
|
||||
private final ItemStack output;
|
||||
|
||||
@Nonnull
|
||||
private final Optional<ItemStack> maybeTop;
|
||||
|
||||
@Nonnull
|
||||
private final Optional<ItemStack> maybeBot;
|
||||
|
||||
@Nonnull
|
||||
private 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<>( inputs.size() );
|
||||
this.inputs.addAll( inputs );
|
||||
|
||||
this.output = output;
|
||||
this.maybeTop = Optional.ofNullable( top );
|
||||
this.maybeBot = Optional.ofNullable( bot );
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final List<ItemStack> getInputs()
|
||||
{
|
||||
return this.inputs;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final ItemStack getOutput()
|
||||
{
|
||||
return this.output;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final Optional<ItemStack> getTopOptional()
|
||||
{
|
||||
return this.maybeTop;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final Optional<ItemStack> getBottomOptional()
|
||||
{
|
||||
return this.maybeBot;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final InscriberProcessType getProcessType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( final Object o )
|
||||
{
|
||||
if( this == o )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( !( o instanceof IInscriberRecipe ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final IInscriberRecipe that = (IInscriberRecipe) o;
|
||||
|
||||
if( !this.inputs.equals( that.getInputs() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( !this.output.equals( that.getOutput() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( !this.maybeTop.equals( that.getTopOptional() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( !this.maybeBot.equals( that.getBottomOptional() ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.type == that.getProcessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int result = this.inputs.hashCode();
|
||||
result = 31 * result + this.output.hashCode();
|
||||
result = 31 * result + this.maybeTop.hashCode();
|
||||
result = 31 * result + this.maybeBot.hashCode();
|
||||
result = 31 * result + this.type.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,211 +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.core.features.registries.inscriber;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.features.IInscriberRecipe;
|
||||
import appeng.api.features.IInscriberRecipeBuilder;
|
||||
import appeng.api.features.IInscriberRegistry;
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3
|
||||
* @since rv2
|
||||
*/
|
||||
public final class InscriberRegistry implements IInscriberRegistry
|
||||
{
|
||||
private final Set<IInscriberRecipe> recipes;
|
||||
private final Set<ItemStack> optionals;
|
||||
private final Set<ItemStack> inputs;
|
||||
|
||||
public InscriberRegistry()
|
||||
{
|
||||
this.inputs = new HashSet<>();
|
||||
this.optionals = new HashSet<>();
|
||||
this.recipes = new HashSet<>();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Collection<IInscriberRecipe> getRecipes()
|
||||
{
|
||||
return Collections.unmodifiableCollection( this.recipes );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<ItemStack> getOptionals()
|
||||
{
|
||||
return this.optionals;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Set<ItemStack> getInputs()
|
||||
{
|
||||
return this.inputs;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IInscriberRecipeBuilder builder()
|
||||
{
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addRecipe( final IInscriberRecipe recipe )
|
||||
{
|
||||
Preconditions.checkNotNull( recipe, "Tried to add (null) as inscriber recipe to the registry." );
|
||||
|
||||
if( this.recipes.add( recipe ) )
|
||||
{
|
||||
recipe.getTopOptional().ifPresent( this.optionals::add );
|
||||
recipe.getBottomOptional().ifPresent( this.optionals::add );
|
||||
|
||||
this.inputs.addAll( recipe.getInputs() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeRecipe( final IInscriberRecipe toBeRemovedRecipe )
|
||||
{
|
||||
Preconditions.checkNotNull( toBeRemovedRecipe, "Tried to remove (null) from the registry." );
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
for( final Iterator<IInscriberRecipe> iterator = this.recipes.iterator(); iterator.hasNext(); )
|
||||
{
|
||||
final IInscriberRecipe recipe = iterator.next();
|
||||
if( recipe.equals( toBeRemovedRecipe ) )
|
||||
{
|
||||
changed = true;
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal {@link IInscriberRecipeBuilder} implementation.
|
||||
* Needs to be adapted to represent a correct {@link IInscriberRecipe}
|
||||
*/
|
||||
private static final class Builder implements IInscriberRecipeBuilder
|
||||
{
|
||||
private List<ItemStack> inputs;
|
||||
private ItemStack output;
|
||||
private ItemStack topOptional;
|
||||
private ItemStack bottomOptional;
|
||||
private InscriberProcessType type;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder withInputs( @Nonnull final Collection<ItemStack> inputs )
|
||||
{
|
||||
Preconditions.checkNotNull( inputs );
|
||||
Preconditions.checkArgument( !inputs.isEmpty() );
|
||||
|
||||
this.inputs = new ArrayList<>( inputs.size() );
|
||||
this.inputs.addAll( inputs );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder withOutput( @Nonnull final ItemStack output )
|
||||
{
|
||||
Preconditions.checkNotNull( output );
|
||||
Preconditions.checkArgument( !output.isEmpty() );
|
||||
|
||||
this.output = output;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder withTopOptional( @Nonnull final ItemStack topOptional )
|
||||
{
|
||||
Preconditions.checkNotNull( topOptional );
|
||||
Preconditions.checkArgument( !topOptional.isEmpty() );
|
||||
|
||||
this.topOptional = topOptional;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder withBottomOptional( @Nonnull final ItemStack bottomOptional )
|
||||
{
|
||||
Preconditions.checkNotNull( bottomOptional );
|
||||
Preconditions.checkArgument( !bottomOptional.isEmpty() );
|
||||
|
||||
this.bottomOptional = bottomOptional;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Builder withProcessType( @Nonnull final InscriberProcessType type )
|
||||
{
|
||||
Preconditions.checkNotNull( type );
|
||||
|
||||
this.type = type;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IInscriberRecipe build()
|
||||
{
|
||||
Preconditions.checkState( this.inputs != null, "Input must be defined." );
|
||||
Preconditions.checkState( !this.inputs.isEmpty(), "Input must have a size." );
|
||||
Preconditions.checkState( !this.output.isEmpty(), "Output cannot be empty." );
|
||||
Preconditions.checkState( !this.topOptional.isEmpty() || !this.bottomOptional.isEmpty(), "One optional must be defined." );
|
||||
Preconditions.checkState( this.type != null, "Process type must be defined." );
|
||||
|
||||
return new InscriberRecipe( this.inputs, this.output, this.topOptional, this.bottomOptional, this.type );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user