Added Registry for customized charger rates. (#3139)
* Added Registry for customized charger rates. * Added rates for all chargable items/block. * Charger and Inscriber now store 1.6k AE each instead of 1.5k * A crank applies 160 AE instead of 150 * Charged certus now requires 1.6k instead of 1.5k
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import appeng.api.features.IChargerRegistry;
|
||||
import appeng.api.features.IGrinderRegistry;
|
||||
import appeng.api.features.IInscriberRegistry;
|
||||
import appeng.api.features.ILocatableRegistry;
|
||||
@@ -35,6 +36,7 @@ import appeng.api.networking.IGridCacheRegistry;
|
||||
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.grinder.GrinderRecipeManager;
|
||||
import appeng.core.features.registries.inscriber.InscriberRegistry;
|
||||
|
||||
@@ -44,13 +46,15 @@ import appeng.core.features.registries.inscriber.InscriberRegistry;
|
||||
*
|
||||
* @author AlgorithmX2
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @author yueh
|
||||
* @version rv5
|
||||
* @since rv0
|
||||
*/
|
||||
public class RegistryContainer implements IRegistryContainer
|
||||
{
|
||||
private final IGrinderRegistry grinder = new GrinderRecipeManager();
|
||||
private final IInscriberRegistry inscriber = new InscriberRegistry();
|
||||
private final IChargerRegistry charger = new ChargerRegistry();
|
||||
private final ICellRegistry cell = new CellRegistry();
|
||||
private final ILocatableRegistry locatable = new LocatableRegistry();
|
||||
private final ISpecialComparisonRegistry comparison = new SpecialComparisonRegistry();
|
||||
@@ -105,6 +109,12 @@ public class RegistryContainer implements IRegistryContainer
|
||||
return this.inscriber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChargerRegistry charger()
|
||||
{
|
||||
return this.charger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILocatableRegistry locatable()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, 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.charger;
|
||||
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import appeng.api.features.IChargerRegistry;
|
||||
|
||||
|
||||
public class ChargerRegistry implements IChargerRegistry
|
||||
{
|
||||
private static final double DEFAULT_CHARGE_RATE = 160d;
|
||||
private static final double CAPPED_CHARGE_RATE = 16000d;
|
||||
|
||||
private final Map<Item, Double> chargeRates;
|
||||
|
||||
public ChargerRegistry()
|
||||
{
|
||||
this.chargeRates = new IdentityHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnegative
|
||||
public double getChargeRate( @Nonnull Item item )
|
||||
{
|
||||
Preconditions.checkNotNull( item );
|
||||
|
||||
return this.chargeRates.getOrDefault( item, DEFAULT_CHARGE_RATE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChargeRate( @Nonnull Item item, @Nonnegative double value )
|
||||
{
|
||||
Preconditions.checkNotNull( item );
|
||||
Preconditions.checkArgument( value > 0d );
|
||||
|
||||
final double cappedValue = Math.min( value, CAPPED_CHARGE_RATE );
|
||||
|
||||
this.chargeRates.put( item, cappedValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChargeRate( @Nonnull Item item )
|
||||
{
|
||||
Preconditions.checkNotNull( item );
|
||||
|
||||
this.chargeRates.remove( item );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user