pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
@@ -18,20 +18,14 @@
package appeng.core.features;
public enum ActivityState {
Enabled, Disabled;
public enum ActivityState
{
Enabled, Disabled;
public static ActivityState from( final boolean enabled )
{
if( enabled )
{
return ActivityState.Enabled;
}
else
{
return ActivityState.Disabled;
}
}
public static ActivityState from(final boolean enabled) {
if (enabled) {
return ActivityState.Enabled;
} else {
return ActivityState.Disabled;
}
}
}
@@ -18,10 +18,8 @@
package appeng.core.features;
import java.util.Set;
import appeng.api.features.AEFeature;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
@@ -31,44 +29,38 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.features.AEFeature;
public class BlockDefinition extends ItemDefinition implements IBlockDefinition {
private final Block block;
public class BlockDefinition extends ItemDefinition implements IBlockDefinition
{
private final Block block;
private final BlockItem blockItem;
private final BlockItem blockItem;
public BlockDefinition(String registryName, Block block, BlockItem item, Set<AEFeature> features) {
super(registryName, item, features);
this.block = block;
this.blockItem = item;
}
public BlockDefinition( String registryName, Block block, BlockItem item, Set<AEFeature> features )
{
super( registryName, item, features );
this.block = block;
this.blockItem = item;
}
@Override
public final Block block() {
return this.block;
}
@Override
public final Block block()
{
return this.block;
}
@Override
public BlockItem blockItem() {
return blockItem;
}
@Override
public BlockItem blockItem()
{
return blockItem;
}
@Override
public final ItemStack stack(int stackSize) {
Preconditions.checkArgument(stackSize > 0);
@Override
public final ItemStack stack( int stackSize )
{
Preconditions.checkArgument( stackSize > 0 );
return new ItemStack(block, stackSize);
}
return new ItemStack(block, stackSize);
}
@Override
public final boolean isSameAs( final IBlockReader world, final BlockPos pos )
{
return world.getBlockState( pos ).getBlock() == this.block;
}
@Override
public final boolean isSameAs(final IBlockReader world, final BlockPos pos) {
return world.getBlockState(pos).getBlock() == this.block;
}
}
@@ -18,7 +18,6 @@
package appeng.core.features;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
@@ -27,39 +26,33 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class BlockStackSrc implements IStackSrc {
public class BlockStackSrc implements IStackSrc
{
private final Block block;
private final boolean enabled;
private final Block block;
private final boolean enabled;
public BlockStackSrc(final Block block, final ActivityState state) {
Preconditions.checkNotNull(block);
Preconditions.checkNotNull(state);
Preconditions.checkArgument(state == ActivityState.Enabled || state == ActivityState.Disabled);
public BlockStackSrc( final Block block, final ActivityState state )
{
Preconditions.checkNotNull( block );
Preconditions.checkNotNull( state );
Preconditions.checkArgument( state == ActivityState.Enabled || state == ActivityState.Disabled );
this.block = block;
this.enabled = state == ActivityState.Enabled;
}
this.block = block;
this.enabled = state == ActivityState.Enabled;
}
@Nullable
@Override
public ItemStack stack(final int i) {
return new ItemStack(this.block, i);
}
@Nullable
@Override
public ItemStack stack( final int i )
{
return new ItemStack( this.block, i );
}
@Override
public Item getItem() {
return null;
}
@Override
public Item getItem()
{
return null;
}
@Override
public boolean isEnabled()
{
return this.enabled;
}
@Override
public boolean isEnabled() {
return this.enabled;
}
}
@@ -18,7 +18,6 @@
package appeng.core.features;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -27,76 +26,63 @@ import net.minecraft.tileentity.TileEntity;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
public final class ColoredItemDefinition implements AEColoredItemDefinition {
public final class ColoredItemDefinition implements AEColoredItemDefinition
{
private final ItemStackSrc[] colors = new ItemStackSrc[17];
private final ItemStackSrc[] colors = new ItemStackSrc[17];
public void add(final AEColor v, final ItemStackSrc is) {
this.colors[v.ordinal()] = is;
}
public void add( final AEColor v, final ItemStackSrc is )
{
this.colors[v.ordinal()] = is;
}
@Override
public Block block(final AEColor color) {
return null;
}
@Override
public Block block( final AEColor color )
{
return null;
}
@Override
public Item item(final AEColor color) {
final ItemStackSrc is = this.colors[color.ordinal()];
@Override
public Item item( final AEColor color )
{
final ItemStackSrc is = this.colors[color.ordinal()];
if (is == null) {
return null;
}
if( is == null )
{
return null;
}
return is.getItem();
}
return is.getItem();
}
@Override
public Class<? extends TileEntity> entity(final AEColor color) {
return null;
}
@Override
public Class<? extends TileEntity> entity( final AEColor color )
{
return null;
}
@Override
public ItemStack stack(final AEColor color, final int stackSize) {
final ItemStackSrc is = this.colors[color.ordinal()];
@Override
public ItemStack stack( final AEColor color, final int stackSize )
{
final ItemStackSrc is = this.colors[color.ordinal()];
if (is == null) {
return ItemStack.EMPTY;
}
if( is == null )
{
return ItemStack.EMPTY;
}
return is.stack(stackSize);
}
return is.stack( stackSize );
}
@Override
public ItemStack[] allStacks(final int stackSize) {
final ItemStack[] is = new ItemStack[this.colors.length];
for (int x = 0; x < is.length; x++) {
is[x] = this.colors[x].stack(1);
}
return is;
}
@Override
public ItemStack[] allStacks( final int stackSize )
{
final ItemStack[] is = new ItemStack[this.colors.length];
for( int x = 0; x < is.length; x++ )
{
is[x] = this.colors[x].stack( 1 );
}
return is;
}
@Override
public boolean sameAs(final AEColor color, final ItemStack comparableItem) {
final ItemStackSrc is = this.colors[color.ordinal()];
@Override
public boolean sameAs( final AEColor color, final ItemStack comparableItem )
{
final ItemStackSrc is = this.colors[color.ordinal()];
if (comparableItem.isEmpty() || is == null) {
return false;
}
if( comparableItem.isEmpty() || is == null )
{
return false;
}
return comparableItem.getItem() == is.getItem();
}
return comparableItem.getItem() == is.getItem();
}
}
@@ -18,77 +18,67 @@
package appeng.core.features;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nonnull;
import appeng.api.features.AEFeature;
import com.google.common.base.Preconditions;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import appeng.api.definitions.IItemDefinition;
import appeng.api.features.AEFeature;
public final class DamagedItemDefinition implements IItemDefinition {
private final String identifier;
private final IStackSrc source;
public final class DamagedItemDefinition implements IItemDefinition
{
private final String identifier;
private final IStackSrc source;
public DamagedItemDefinition(@Nonnull final String identifier, @Nonnull final IStackSrc source) {
this.identifier = Preconditions.checkNotNull(identifier);
this.source = Preconditions.checkNotNull(source);
}
public DamagedItemDefinition( @Nonnull final String identifier, @Nonnull final IStackSrc source )
{
this.identifier = Preconditions.checkNotNull( identifier );
this.source = Preconditions.checkNotNull( source );
}
@Override
public Item item() {
return source.getItem();
}
@Override
public Item item() {
return source.getItem();
}
@Override
public ItemStack stack(int stackSize) {
return source.stack(stackSize);
}
@Override
public ItemStack stack(int stackSize) {
return source.stack(stackSize);
}
@Nonnull
@Override
public String identifier() {
return this.identifier;
}
@Nonnull
@Override
public String identifier()
{
return this.identifier;
}
@Override
public Optional<Item> maybeItem() {
return Optional.of(this.source.getItem());
}
@Override
public Optional<Item> maybeItem()
{
return Optional.of(this.source.getItem());
}
@Override
public Optional<ItemStack> maybeStack(final int stackSize) {
return Optional.of(this.source.stack(stackSize));
}
@Override
public Optional<ItemStack> maybeStack( final int stackSize )
{
return Optional.of(this.source.stack(stackSize));
}
@Override
public Set<AEFeature> features() {
return Collections.emptySet();
}
@Override
public Set<AEFeature> features()
{
return Collections.emptySet();
}
@Override
public boolean isSameAs(final ItemStack comparableStack) {
if (comparableStack.isEmpty()) {
return false;
}
@Override
public boolean isSameAs( final ItemStack comparableStack )
{
if( comparableStack.isEmpty() )
{
return false;
}
return comparableStack.getItem() == this.source.getItem();
}
return comparableStack.getItem() == this.source.getItem();
}
}
@@ -18,17 +18,14 @@
package appeng.core.features;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public interface IStackSrc {
public interface IStackSrc
{
ItemStack stack(int i);
ItemStack stack( int i );
Item getItem();
Item getItem();
boolean isEnabled();
boolean isEnabled();
}
@@ -18,66 +18,57 @@
package appeng.core.features;
import java.util.Set;
import javax.annotation.Nonnull;
import appeng.api.features.AEFeature;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import appeng.api.definitions.IItemDefinition;
import appeng.api.features.AEFeature;
import appeng.util.Platform;
public class ItemDefinition implements IItemDefinition {
private final String identifier;
private final Item item;
private final Set<AEFeature> features;
public class ItemDefinition implements IItemDefinition
{
private final String identifier;
private final Item item;
private final Set<AEFeature> features;
public ItemDefinition(String registryName, Item item, Set<AEFeature> features) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(registryName), "registryName");
this.identifier = registryName;
this.item = item;
this.features = ImmutableSet.copyOf(features);
}
public ItemDefinition( String registryName, Item item, Set<AEFeature> features )
{
Preconditions.checkArgument( !Strings.isNullOrEmpty( registryName ), "registryName" );
this.identifier = registryName;
this.item = item;
this.features = ImmutableSet.copyOf(features);
}
@Nonnull
@Override
public String identifier() {
return this.identifier;
}
@Nonnull
@Override
public String identifier()
{
return this.identifier;
}
@Override
public final Item item() {
return this.item;
}
@Override
public final Item item()
{
return this.item;
}
@Override
public ItemStack stack(final int stackSize) {
return new ItemStack(item, stackSize);
}
@Override
public ItemStack stack( final int stackSize )
{
return new ItemStack( item, stackSize );
}
@Override
public Set<AEFeature> features() {
return features;
}
@Override
public Set<AEFeature> features()
{
return features;
}
@Override
public final boolean isSameAs( final ItemStack comparableStack )
{
return Platform.itemComparisons().isEqualItemType( comparableStack, this.stack( 1 ) );
}
@Override
public final boolean isSameAs(final ItemStack comparableStack) {
return Platform.itemComparisons().isEqualItemType(comparableStack, this.stack(1));
}
}
@@ -18,7 +18,6 @@
package appeng.core.features;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
@@ -26,39 +25,33 @@ import com.google.common.base.Preconditions;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemStackSrc implements IStackSrc {
public class ItemStackSrc implements IStackSrc
{
private final Item item;
private final boolean enabled;
private final Item item;
private final boolean enabled;
public ItemStackSrc(final Item item, final ActivityState state) {
Preconditions.checkNotNull(item);
Preconditions.checkNotNull(state);
Preconditions.checkArgument(state == ActivityState.Enabled || state == ActivityState.Disabled);
public ItemStackSrc( final Item item, final ActivityState state )
{
Preconditions.checkNotNull( item );
Preconditions.checkNotNull( state );
Preconditions.checkArgument( state == ActivityState.Enabled || state == ActivityState.Disabled );
this.item = item;
this.enabled = state == ActivityState.Enabled;
}
this.item = item;
this.enabled = state == ActivityState.Enabled;
}
@Nullable
@Override
public ItemStack stack(final int i) {
return new ItemStack(this.item, i);
}
@Nullable
@Override
public ItemStack stack( final int i )
{
return new ItemStack( this.item, i );
}
@Override
public Item getItem() {
return this.item;
}
@Override
public Item getItem()
{
return this.item;
}
@Override
public boolean isEnabled()
{
return this.enabled;
}
@Override
public boolean isEnabled() {
return this.enabled;
}
}
@@ -18,7 +18,6 @@
package appeng.core.features;
import com.google.common.base.Preconditions;
import net.minecraft.item.Item;
@@ -26,35 +25,29 @@ import net.minecraft.item.ItemStack;
import appeng.items.materials.MaterialType;
public class MaterialStackSrc implements IStackSrc {
private final MaterialType src;
private final boolean enabled;
public class MaterialStackSrc implements IStackSrc
{
private final MaterialType src;
private final boolean enabled;
public MaterialStackSrc(final MaterialType src, boolean enabled) {
Preconditions.checkNotNull(src);
public MaterialStackSrc( final MaterialType src, boolean enabled )
{
Preconditions.checkNotNull( src );
this.src = src;
this.enabled = enabled;
}
this.src = src;
this.enabled = enabled;
}
@Override
public ItemStack stack(final int stackSize) {
return this.src.stack(stackSize);
}
@Override
public ItemStack stack( final int stackSize )
{
return this.src.stack( stackSize );
}
@Override
public Item getItem() {
return this.src.getItemInstance();
}
@Override
public Item getItem()
{
return this.src.getItemInstance();
}
@Override
public boolean isEnabled()
{
return this.enabled;
}
@Override
public boolean isEnabled() {
return this.enabled;
}
}
@@ -18,33 +18,29 @@
package appeng.core.features;
import java.util.Optional;
import java.util.Set;
import javax.annotation.Nonnull;
import appeng.api.features.AEFeature;
import net.minecraft.item.BlockItem;
import net.minecraft.tileentity.TileEntity;
import appeng.api.definitions.ITileDefinition;
import appeng.api.features.AEFeature;
import appeng.block.AEBaseTileBlock;
public final class TileDefinition extends BlockDefinition implements ITileDefinition {
private final AEBaseTileBlock<?> block;
public final class TileDefinition extends BlockDefinition implements ITileDefinition
{
private final AEBaseTileBlock<?> block;
public TileDefinition(@Nonnull String registryName, AEBaseTileBlock<?> block, BlockItem item,
Set<AEFeature> features) {
super(registryName, block, item, features);
this.block = block;
}
public TileDefinition( @Nonnull String registryName, AEBaseTileBlock<?> block, BlockItem item, Set<AEFeature> features )
{
super( registryName, block, item, features );
this.block = block;
}
@Override
public Optional<? extends Class<? extends TileEntity>> maybeEntity()
{
return Optional.of(this.block.getTileEntityClass());
}
@Override
public Optional<? extends Class<? extends TileEntity>> maybeEntity() {
return Optional.of(this.block.getTileEntityClass());
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
@@ -29,58 +28,44 @@ import appeng.api.networking.IGridCache;
import appeng.api.networking.IGridCacheRegistry;
import appeng.core.AELog;
public final class GridCacheRegistry implements IGridCacheRegistry {
private final Map<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<>();
public final class GridCacheRegistry implements IGridCacheRegistry
{
private final Map<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<>();
@Override
public void registerGridCache(final Class<? extends IGridCache> iface,
final Class<? extends IGridCache> implementation) {
if (iface.isAssignableFrom(implementation)) {
this.caches.put(iface, implementation);
} else {
throw new IllegalArgumentException(
"Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: "
+ iface + " and " + implementation);
}
}
@Override
public void registerGridCache( final Class<? extends IGridCache> iface, final Class<? extends IGridCache> implementation )
{
if( iface.isAssignableFrom( implementation ) )
{
this.caches.put( iface, implementation );
}
else
{
throw new IllegalArgumentException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: " + iface + " and " + implementation );
}
}
@Override
public HashMap<Class<? extends IGridCache>, IGridCache> createCacheInstance(final IGrid g) {
final HashMap<Class<? extends IGridCache>, IGridCache> map = new HashMap<>();
@Override
public HashMap<Class<? extends IGridCache>, IGridCache> createCacheInstance( final IGrid g )
{
final HashMap<Class<? extends IGridCache>, IGridCache> map = new HashMap<>();
for (final Class<? extends IGridCache> iface : this.caches.keySet()) {
try {
final Constructor<? extends IGridCache> c = this.caches.get(iface).getConstructor(IGrid.class);
map.put(iface, c.newInstance(g));
} catch (final NoSuchMethodException e) {
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
throw new IllegalArgumentException(e);
} catch (final InvocationTargetException e) {
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
throw new IllegalStateException(e);
} catch (final InstantiationException e) {
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
throw new IllegalStateException(e);
} catch (final IllegalAccessException e) {
AELog.error("Grid Caches must have a constructor with IGrid as the single param.");
throw new IllegalStateException(e);
}
}
for( final Class<? extends IGridCache> iface : this.caches.keySet() )
{
try
{
final Constructor<? extends IGridCache> c = this.caches.get( iface ).getConstructor( IGrid.class );
map.put( iface, c.newInstance( g ) );
}
catch( final NoSuchMethodException e )
{
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
throw new IllegalArgumentException( e );
}
catch( final InvocationTargetException e )
{
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
throw new IllegalStateException( e );
}
catch( final InstantiationException e )
{
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
throw new IllegalStateException( e );
}
catch( final IllegalAccessException e )
{
AELog.error( "Grid Caches must have a constructor with IGrid as the single param." );
throw new IllegalStateException( e );
}
}
return map;
}
return map;
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries;
import java.util.HashMap;
import java.util.Map;
@@ -31,38 +30,29 @@ import appeng.api.features.ILocatable;
import appeng.api.features.ILocatableRegistry;
import appeng.util.Platform;
public final class LocatableRegistry implements ILocatableRegistry {
private final Map<Long, ILocatable> set;
public final class LocatableRegistry implements ILocatableRegistry
{
private final Map<Long, ILocatable> set;
public LocatableRegistry() {
this.set = new HashMap<>();
MinecraftForge.EVENT_BUS.register(this);
}
public LocatableRegistry()
{
this.set = new HashMap<>();
MinecraftForge.EVENT_BUS.register( this );
}
@SubscribeEvent
public void updateLocatable(final LocatableEventAnnounce e) {
if (Platform.isClient()) {
return; // IGNORE!
}
@SubscribeEvent
public void updateLocatable( final LocatableEventAnnounce e )
{
if( Platform.isClient() )
{
return; // IGNORE!
}
if (e.change == LocatableEvent.REGISTER) {
this.set.put(e.target.getLocatableSerial(), e.target);
} else if (e.change == LocatableEvent.UNREGISTER) {
this.set.remove(e.target.getLocatableSerial());
}
}
if( e.change == LocatableEvent.REGISTER )
{
this.set.put( e.target.getLocatableSerial(), e.target );
}
else if( e.change == LocatableEvent.UNREGISTER )
{
this.set.remove( e.target.getLocatableSerial() );
}
}
@Override
public ILocatable getLocatableBy( final long serial )
{
return this.set.get( serial );
}
@Override
public ILocatable getLocatableBy(final long serial) {
return this.set.get(serial);
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries;
import java.util.HashMap;
import net.minecraft.item.ItemStack;
@@ -26,36 +25,29 @@ import net.minecraft.item.Items;
import appeng.api.features.IMatterCannonAmmoRegistry;
public class MatterCannonAmmoRegistry implements /* FIXME IOreListener, */ IMatterCannonAmmoRegistry {
public class MatterCannonAmmoRegistry implements /* FIXME IOreListener, */ IMatterCannonAmmoRegistry
{
private final HashMap<ItemStack, Double> DamageModifiers = new HashMap<>();
private final HashMap<ItemStack, Double> DamageModifiers = new HashMap<>();
public MatterCannonAmmoRegistry() {
// FIXME OreDictionaryHandler.INSTANCE.observe( this );
this.registerAmmo(new ItemStack(Items.GOLD_NUGGET), 196.96655);
}
public MatterCannonAmmoRegistry()
{
// FIXME OreDictionaryHandler.INSTANCE.observe( this );
this.registerAmmo( new ItemStack( Items.GOLD_NUGGET ), 196.96655 );
}
@Override
public void registerAmmo(final ItemStack ammo, final double weight) {
this.DamageModifiers.put(ammo, weight);
}
@Override
public void registerAmmo( final ItemStack ammo, final double weight )
{
this.DamageModifiers.put( ammo, weight );
}
@Override
public float getPenetration( final ItemStack is )
{
for( final ItemStack o : this.DamageModifiers.keySet() )
{
if( ItemStack.areItemsEqual( o, is ) )
{
return this.DamageModifiers.get( o ).floatValue();
}
}
return 0;
}
@Override
public float getPenetration(final ItemStack is) {
for (final ItemStack o : this.DamageModifiers.keySet()) {
if (ItemStack.areItemsEqual(o, is)) {
return this.DamageModifiers.get(o).floatValue();
}
}
return 0;
}
// FIXME @Override
// FIXME public void oreRegistered( final String name, final ItemStack item )
@@ -138,11 +130,9 @@ public class MatterCannonAmmoRegistry implements /* FIXME IOreListener, */ IMatt
// FIXME this.considerItem( name, item, "Electrum", ( 107.8682 + 196.96655 ) / 2.0 );
// FIXME }
private void considerItem( final String ore, final ItemStack item, final String name, final double weight )
{
if( ore.equals( "berry" + name ) || ore.equals( "nugget" + name ) )
{
this.registerAmmo( item, weight );
}
}
private void considerItem(final String ore, final ItemStack item, final String name, final double weight) {
if (ore.equals("berry" + name) || ore.equals("nugget" + name)) {
this.registerAmmo(item, weight);
}
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -33,136 +32,115 @@ import appeng.api.movable.IMovableRegistry;
import appeng.api.movable.IMovableTile;
import appeng.spatial.DefaultSpatialHandler;
public class MovableTileRegistry implements IMovableRegistry {
public class MovableTileRegistry implements IMovableRegistry
{
private final HashSet<Block> blacklisted = new HashSet<>();
private final HashSet<Block> blacklisted = new HashSet<>();
private final HashMap<Class<? extends TileEntity>, IMovableHandler> Valid = new HashMap<>();
private final List<Class<? extends TileEntity>> test = new ArrayList<>();
private final List<IMovableHandler> handlers = new ArrayList<>();
private final DefaultSpatialHandler dsh = new DefaultSpatialHandler();
private final HashMap<Class<? extends TileEntity>, IMovableHandler> Valid = new HashMap<>();
private final List<Class<? extends TileEntity>> test = new ArrayList<>();
private final List<IMovableHandler> handlers = new ArrayList<>();
private final DefaultSpatialHandler dsh = new DefaultSpatialHandler();
private final IMovableHandler nullHandler = new DefaultSpatialHandler();
private final IMovableHandler nullHandler = new DefaultSpatialHandler();
@Override
public void blacklistBlock(final Block blk) {
this.blacklisted.add(blk);
}
@Override
public void blacklistBlock( final Block blk )
{
this.blacklisted.add( blk );
}
@Override
public void whiteListTileEntity(final Class<? extends TileEntity> c) {
if (c.getName().equals(TileEntity.class.getName())) {
throw new IllegalArgumentException(new AppEngException("Someone tried to make all tiles movable with " + c
+ ", this is a clear violation of the purpose of the white list."));
}
@Override
public void whiteListTileEntity( final Class<? extends TileEntity> c )
{
if( c.getName().equals( TileEntity.class.getName() ) )
{
throw new IllegalArgumentException( new AppEngException( "Someone tried to make all tiles movable with " + c + ", this is a clear violation of the purpose of the white list." ) );
}
this.test.add(c);
}
this.test.add( c );
}
@Override
public boolean askToMove(final TileEntity te) {
final Class myClass = te.getClass();
IMovableHandler canMove = this.Valid.get(myClass);
@Override
public boolean askToMove( final TileEntity te )
{
final Class myClass = te.getClass();
IMovableHandler canMove = this.Valid.get( myClass );
if (canMove == null) {
canMove = this.testClass(myClass, te);
}
if( canMove == null )
{
canMove = this.testClass( myClass, te );
}
if (canMove != this.nullHandler) {
if (te instanceof IMovableTile) {
((IMovableTile) te).prepareToMove();
}
if( canMove != this.nullHandler )
{
if( te instanceof IMovableTile )
{
( (IMovableTile) te ).prepareToMove();
}
te.remove();
return true;
}
te.remove();
return true;
}
return false;
}
return false;
}
private IMovableHandler testClass(final Class myClass, final TileEntity te) {
IMovableHandler handler = null;
private IMovableHandler testClass( final Class myClass, final TileEntity te )
{
IMovableHandler handler = null;
// ask handlers...
for (final IMovableHandler han : this.handlers) {
if (han.canHandle(myClass, te)) {
handler = han;
break;
}
}
// ask handlers...
for( final IMovableHandler han : this.handlers )
{
if( han.canHandle( myClass, te ) )
{
handler = han;
break;
}
}
// if you have a handler your opted in
if (handler != null) {
this.Valid.put(myClass, handler);
return handler;
}
// if you have a handler your opted in
if( handler != null )
{
this.Valid.put( myClass, handler );
return handler;
}
// if your movable our opted in
if (te instanceof IMovableTile) {
this.Valid.put(myClass, this.dsh);
return this.dsh;
}
// if your movable our opted in
if( te instanceof IMovableTile )
{
this.Valid.put( myClass, this.dsh );
return this.dsh;
}
// if you are on the white list your opted in.
for (final Class<? extends TileEntity> testClass : this.test) {
if (testClass.isAssignableFrom(myClass)) {
this.Valid.put(myClass, this.dsh);
return this.dsh;
}
}
// if you are on the white list your opted in.
for( final Class<? extends TileEntity> testClass : this.test )
{
if( testClass.isAssignableFrom( myClass ) )
{
this.Valid.put( myClass, this.dsh );
return this.dsh;
}
}
this.Valid.put(myClass, this.nullHandler);
return this.nullHandler;
}
this.Valid.put( myClass, this.nullHandler );
return this.nullHandler;
}
@Override
public void doneMoving(final TileEntity te) {
if (te instanceof IMovableTile) {
final IMovableTile mt = (IMovableTile) te;
mt.doneMoving();
}
}
@Override
public void doneMoving( final TileEntity te )
{
if( te instanceof IMovableTile )
{
final IMovableTile mt = (IMovableTile) te;
mt.doneMoving();
}
}
@Override
public void addHandler(final IMovableHandler han) {
this.handlers.add(han);
}
@Override
public void addHandler( final IMovableHandler han )
{
this.handlers.add( han );
}
@Override
public IMovableHandler getHandler(final TileEntity te) {
final Class myClass = te.getClass();
final IMovableHandler h = this.Valid.get(myClass);
return h == null ? this.dsh : h;
}
@Override
public IMovableHandler getHandler( final TileEntity te )
{
final Class myClass = te.getClass();
final IMovableHandler h = this.Valid.get( myClass );
return h == null ? this.dsh : h;
}
@Override
public IMovableHandler getDefaultHandler() {
return this.dsh;
}
@Override
public IMovableHandler getDefaultHandler()
{
return this.dsh;
}
@Override
public boolean isBlacklisted( final Block blk )
{
return this.blacklisted.contains( blk );
}
@Override
public boolean isBlacklisted(final Block blk) {
return this.blacklisted.contains(blk);
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -46,36 +45,33 @@ import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.util.AEColor;
import appeng.capabilities.Capabilities;
public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
private static final int INITIAL_CAPACITY = 40;
public final class P2PTunnelRegistry implements IP2PTunnelRegistry
{
private static final int INITIAL_CAPACITY = 40;
private final Map<ItemStack, TunnelType> tunnels = new HashMap<>(INITIAL_CAPACITY);
private final Map<String, TunnelType> modIdTunnels = new HashMap<>(INITIAL_CAPACITY);
private final Map<Capability<?>, TunnelType> capTunnels = new HashMap<>(INITIAL_CAPACITY);
private final Map<ItemStack, TunnelType> tunnels = new HashMap<>( INITIAL_CAPACITY );
private final Map<String, TunnelType> modIdTunnels = new HashMap<>( INITIAL_CAPACITY );
private final Map<Capability<?>, TunnelType> capTunnels = new HashMap<>( INITIAL_CAPACITY );
public void configure() {
public void configure()
{
final IDefinitions definitions = AEApi.instance().definitions();
final IBlocks blocks = definitions.blocks();
final IParts parts = definitions.parts();
final IDefinitions definitions = AEApi.instance().definitions();
final IBlocks blocks = definitions.blocks();
final IParts parts = definitions.parts();
/**
* light!
*/
this.addNewAttunement(new ItemStack(Blocks.TORCH), TunnelType.LIGHT);
this.addNewAttunement(new ItemStack(Blocks.GLOWSTONE), TunnelType.LIGHT);
/**
* light!
*/
this.addNewAttunement( new ItemStack( Blocks.TORCH ), TunnelType.LIGHT );
this.addNewAttunement( new ItemStack( Blocks.GLOWSTONE ), TunnelType.LIGHT );
/**
* Forge energy tunnel items
*/
/**
* Forge energy tunnel items
*/
this.addNewAttunement( blocks.energyCellDense(), TunnelType.FE_POWER );
this.addNewAttunement( blocks.energyAcceptor(), TunnelType.FE_POWER );
this.addNewAttunement( blocks.energyCell(), TunnelType.FE_POWER );
this.addNewAttunement( blocks.energyCellCreative(), TunnelType.FE_POWER );
this.addNewAttunement(blocks.energyCellDense(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyAcceptor(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyCell(), TunnelType.FE_POWER);
this.addNewAttunement(blocks.energyCellCreative(), TunnelType.FE_POWER);
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 0 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 1 ), TunnelType.FE_POWER );
@@ -84,9 +80,9 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 4 ), TunnelType.FE_POWER );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_0", 5 ), TunnelType.FE_POWER );
/**
* EU tunnel items
*/
/**
* EU tunnel items
*/
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 0 ), TunnelType.IC2_POWER ); // Copper cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 1 ), TunnelType.IC2_POWER ); // Glass fibre cable
@@ -94,31 +90,31 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 3 ), TunnelType.IC2_POWER ); // HV cable
// FIXME this.addNewAttunement( this.getModItem( "ic2", "cable", 4 ), TunnelType.IC2_POWER ); // Tin cable
/**
* attune based on most redstone base items.
*/
this.addNewAttunement( new ItemStack( Items.REDSTONE ), TunnelType.REDSTONE );
this.addNewAttunement( new ItemStack( Items.REPEATER ), TunnelType.REDSTONE );
this.addNewAttunement( new ItemStack( Blocks.REDSTONE_LAMP ), TunnelType.REDSTONE );
this.addNewAttunement( new ItemStack( Blocks.COMPARATOR ), TunnelType.REDSTONE );
this.addNewAttunement( new ItemStack( Blocks.DAYLIGHT_DETECTOR ), TunnelType.REDSTONE );
this.addNewAttunement( new ItemStack( Blocks.REDSTONE_WIRE ), TunnelType.REDSTONE );
this.addNewAttunement( new ItemStack( Blocks.REDSTONE_BLOCK ), TunnelType.REDSTONE );
this.addNewAttunement( new ItemStack( Blocks.LEVER ), TunnelType.REDSTONE );
/**
* attune based on most redstone base items.
*/
this.addNewAttunement(new ItemStack(Items.REDSTONE), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Items.REPEATER), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.REDSTONE_LAMP), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.COMPARATOR), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.DAYLIGHT_DETECTOR), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.REDSTONE_WIRE), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.REDSTONE_BLOCK), TunnelType.REDSTONE);
this.addNewAttunement(new ItemStack(Blocks.LEVER), TunnelType.REDSTONE);
/**
* attune based on lots of random item related stuff
*/
/**
* attune based on lots of random item related stuff
*/
this.addNewAttunement( blocks.iface(), TunnelType.ITEM );
this.addNewAttunement( parts.iface(), TunnelType.ITEM );
this.addNewAttunement( parts.storageBus(), TunnelType.ITEM );
this.addNewAttunement( parts.importBus(), TunnelType.ITEM );
this.addNewAttunement( parts.exportBus(), TunnelType.ITEM );
this.addNewAttunement(blocks.iface(), TunnelType.ITEM);
this.addNewAttunement(parts.iface(), TunnelType.ITEM);
this.addNewAttunement(parts.storageBus(), TunnelType.ITEM);
this.addNewAttunement(parts.importBus(), TunnelType.ITEM);
this.addNewAttunement(parts.exportBus(), TunnelType.ITEM);
this.addNewAttunement( new ItemStack( Blocks.HOPPER ), TunnelType.ITEM );
this.addNewAttunement( new ItemStack( Blocks.CHEST ), TunnelType.ITEM );
this.addNewAttunement( new ItemStack( Blocks.TRAPPED_CHEST ), TunnelType.ITEM );
this.addNewAttunement(new ItemStack(Blocks.HOPPER), TunnelType.ITEM);
this.addNewAttunement(new ItemStack(Blocks.CHEST), TunnelType.ITEM);
this.addNewAttunement(new ItemStack(Blocks.TRAPPED_CHEST), TunnelType.ITEM);
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 0 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 9 ), TunnelType.ITEM );
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 0 ), TunnelType.ITEM ); // itemduct
@@ -128,15 +124,15 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
// FIXME // itemduct
// FIXME this.addNewAttunement( this.getModItem( "thermaldynamics", "duct_32", 3 ), TunnelType.ITEM ); // impulse
// FIXME // itemduct
// (opaque)
// (opaque)
/**
* attune based on lots of random item related stuff
*/
this.addNewAttunement( new ItemStack( Items.BUCKET ), TunnelType.FLUID );
this.addNewAttunement( new ItemStack( Items.LAVA_BUCKET ), TunnelType.FLUID );
this.addNewAttunement( new ItemStack( Items.MILK_BUCKET ), TunnelType.FLUID );
this.addNewAttunement( new ItemStack( Items.WATER_BUCKET ), TunnelType.FLUID );
/**
* attune based on lots of random item related stuff
*/
this.addNewAttunement(new ItemStack(Items.BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.LAVA_BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.MILK_BUCKET), TunnelType.FLUID);
this.addNewAttunement(new ItemStack(Items.WATER_BUCKET), TunnelType.FLUID);
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "machineblock2", 11 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "mekanism", "parttransmitter", 4 ), TunnelType.FLUID );
// FIXME this.addNewAttunement( this.getModItem( "extrautilities", "extractor_base", 6 ), TunnelType.FLUID );
@@ -149,132 +145,115 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
// FIXME // hardened
// FIXME // (opaque)
// FIXME
for( final AEColor c : AEColor.values() )
{
this.addNewAttunement( parts.cableGlass().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableCovered().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableSmart().stack( c, 1 ), TunnelType.ME );
this.addNewAttunement( parts.cableDenseSmart().stack( c, 1 ), TunnelType.ME );
}
for (final AEColor c : AEColor.values()) {
this.addNewAttunement(parts.cableGlass().stack(c, 1), TunnelType.ME);
this.addNewAttunement(parts.cableCovered().stack(c, 1), TunnelType.ME);
this.addNewAttunement(parts.cableSmart().stack(c, 1), TunnelType.ME);
this.addNewAttunement(parts.cableDenseSmart().stack(c, 1), TunnelType.ME);
}
/**
* attune based caps
*/
this.addNewAttunement( Capabilities.FORGE_ENERGY, TunnelType.FE_POWER );
this.addNewAttunement( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, TunnelType.FLUID );
/**
* attune based caps
*/
this.addNewAttunement(Capabilities.FORGE_ENERGY, TunnelType.FE_POWER);
this.addNewAttunement(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, TunnelType.FLUID);
/**
* attune based on the ItemStack's modId
*/
/**
* attune based on the ItemStack's modId
*/
this.addNewAttunement( "thermaldynamics", TunnelType.FE_POWER );
this.addNewAttunement( "thermalexpansion", TunnelType.FE_POWER );
this.addNewAttunement( "thermalfoundation", TunnelType.FE_POWER );
// TODO: Remove when confirmed that the official 1.12 version of EnderIO will support FE.
this.addNewAttunement( "enderio", TunnelType.FE_POWER );
// TODO: Remove when confirmed that the official 1.12 version of Mekanism will support FE.
this.addNewAttunement( "mekanism", TunnelType.FE_POWER );
// TODO: Remove when support for RFTools' Powercells support is added
this.addNewAttunement( "rftools", TunnelType.FE_POWER );
this.addNewAttunement( "ic2", TunnelType.IC2_POWER );
this.addNewAttunement("thermaldynamics", TunnelType.FE_POWER);
this.addNewAttunement("thermalexpansion", TunnelType.FE_POWER);
this.addNewAttunement("thermalfoundation", TunnelType.FE_POWER);
// TODO: Remove when confirmed that the official 1.12 version of EnderIO will
// support FE.
this.addNewAttunement("enderio", TunnelType.FE_POWER);
// TODO: Remove when confirmed that the official 1.12 version of Mekanism will
// support FE.
this.addNewAttunement("mekanism", TunnelType.FE_POWER);
// TODO: Remove when support for RFTools' Powercells support is added
this.addNewAttunement("rftools", TunnelType.FE_POWER);
this.addNewAttunement("ic2", TunnelType.IC2_POWER);
}
}
@Override
public void addNewAttunement( @Nonnull final String modId, @Nullable final TunnelType type )
{
if( type == null || modId == null )
{
return;
}
this.modIdTunnels.put( modId, type );
}
@Override
public void addNewAttunement(@Nonnull final String modId, @Nullable final TunnelType type) {
if (type == null || modId == null) {
return;
}
this.modIdTunnels.put(modId, type);
}
@Override
public void addNewAttunement( @Nonnull final Capability<?> cap, @Nullable final TunnelType type )
{
if( type == null || cap == null )
{
return;
}
this.capTunnels.put( cap, type );
}
@Override
public void addNewAttunement(@Nonnull final Capability<?> cap, @Nullable final TunnelType type) {
if (type == null || cap == null) {
return;
}
this.capTunnels.put(cap, type);
}
@Override
public void addNewAttunement( @Nonnull final ItemStack trigger, @Nullable final TunnelType type )
{
if( type == null || trigger.isEmpty() )
{
return;
}
@Override
public void addNewAttunement(@Nonnull final ItemStack trigger, @Nullable final TunnelType type) {
if (type == null || trigger.isEmpty()) {
return;
}
this.tunnels.put( trigger, type );
}
this.tunnels.put(trigger, type);
}
@Nullable
@Override
public TunnelType getTunnelTypeByItem( final ItemStack trigger )
{
if( !trigger.isEmpty() )
{
// First match exact items
for( final Entry<ItemStack, TunnelType> entry : this.tunnels.entrySet() )
{
final ItemStack is = entry.getKey();
@Nullable
@Override
public TunnelType getTunnelTypeByItem(final ItemStack trigger) {
if (!trigger.isEmpty()) {
// First match exact items
for (final Entry<ItemStack, TunnelType> entry : this.tunnels.entrySet()) {
final ItemStack is = entry.getKey();
if( is.getItem() == trigger.getItem() )
{
return entry.getValue();
}
if (is.getItem() == trigger.getItem()) {
return entry.getValue();
}
if( ItemStack.areItemsEqual( is, trigger ) )
{
return entry.getValue();
}
}
if (ItemStack.areItemsEqual(is, trigger)) {
return entry.getValue();
}
}
// Next, check if the Item you're holding supports any registered capability
for( Direction face : Direction.values() )
{
for( Entry<Capability<?>, TunnelType> entry : this.capTunnels.entrySet() )
{
if( trigger.getCapability( entry.getKey(), face ).isPresent() )
{
return entry.getValue();
}
}
}
// Next, check if the Item you're holding supports any registered capability
for (Direction face : Direction.values()) {
for (Entry<Capability<?>, TunnelType> entry : this.capTunnels.entrySet()) {
if (trigger.getCapability(entry.getKey(), face).isPresent()) {
return entry.getValue();
}
}
}
// Use the mod id as last option.
for( final Entry<String, TunnelType> entry : this.modIdTunnels.entrySet() )
{
if( trigger.getItem().getRegistryName() != null && trigger.getItem().getRegistryName().getNamespace().equals( entry.getKey() ) )
{
return entry.getValue();
}
}
}
// Use the mod id as last option.
for (final Entry<String, TunnelType> entry : this.modIdTunnels.entrySet()) {
if (trigger.getItem().getRegistryName() != null
&& trigger.getItem().getRegistryName().getNamespace().equals(entry.getKey())) {
return entry.getValue();
}
}
}
return null;
}
return null;
}
@Nonnull
private ItemStack getModItem( final String modID, final String name )
{
@Nonnull
private ItemStack getModItem(final String modID, final String name) {
final Item item = ForgeRegistries.ITEMS.getValue( new ResourceLocation( modID + ":" + name ) );
final Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(modID + ":" + name));
if( item == null )
{
return ItemStack.EMPTY;
}
if (item == null) {
return ItemStack.EMPTY;
}
final ItemStack myItemStack = new ItemStack( item, 1 );
return myItemStack;
}
final ItemStack myItemStack = new ItemStack(item, 1);
return myItemStack;
}
private void addNewAttunement( final IItemDefinition definition, final TunnelType type )
{
definition.maybeStack( 1 ).ifPresent( definitionStack -> this.addNewAttunement( definitionStack, type ) );
}
private void addNewAttunement(final IItemDefinition definition, final TunnelType type) {
definition.maybeStack(1).ifPresent(definitionStack -> this.addNewAttunement(definitionStack, type));
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -27,32 +26,26 @@ import net.minecraft.util.ResourceLocation;
import appeng.api.parts.IPartModels;
public class PartModels implements IPartModels {
public class PartModels implements IPartModels
{
private final Set<ResourceLocation> models = new HashSet<>();
private final Set<ResourceLocation> models = new HashSet<>();
private boolean initialized = false;
private boolean initialized = false;
@Override
public void registerModels(Collection<ResourceLocation> partModels) {
if (this.initialized) {
throw new IllegalStateException("Cannot register models after the pre-initialization phase!");
}
@Override
public void registerModels( Collection<ResourceLocation> partModels )
{
if( this.initialized )
{
throw new IllegalStateException( "Cannot register models after the pre-initialization phase!" );
}
this.models.addAll(partModels);
}
this.models.addAll( partModels );
}
public Set<ResourceLocation> getModels() {
return this.models;
}
public Set<ResourceLocation> getModels()
{
return this.models;
}
public void setInitialized( boolean initialized )
{
this.initialized = initialized;
}
public void setInitialized(boolean initialized) {
this.initialized = initialized;
}
}
@@ -18,57 +18,48 @@
package appeng.core.features.registries;
import java.util.UUID;
import javax.annotation.Nullable;
import appeng.core.AppEng;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.PlayerEntity;
import appeng.api.features.IPlayerRegistry;
import appeng.core.AppEng;
import appeng.core.worlddata.WorldData;
import java.util.UUID;
public class PlayerRegistry implements IPlayerRegistry {
@Override
public int getID(final GameProfile username) {
if (username == null || !username.isComplete()) {
return -1;
}
public class PlayerRegistry implements IPlayerRegistry
{
return WorldData.instance().playerData().getMePlayerId(username);
}
@Override
public int getID( final GameProfile username )
{
if( username == null || !username.isComplete() )
{
return -1;
}
@Override
public int getID(final PlayerEntity player) {
return this.getID(player.getGameProfile());
}
return WorldData.instance().playerData().getMePlayerId( username );
}
@Nullable
@Override
public PlayerEntity findPlayer(final int playerID) {
UUID profileId = WorldData.instance().playerData().getProfileId(playerID);
if (profileId == null) {
return null;
}
@Override
public int getID( final PlayerEntity player )
{
return this.getID( player.getGameProfile() );
}
for (final PlayerEntity player : AppEng.proxy.getPlayers()) {
if (player.getUniqueID().equals(profileId)) {
return player;
}
}
@Nullable
@Override
public PlayerEntity findPlayer( final int playerID )
{
UUID profileId = WorldData.instance().playerData().getProfileId(playerID);
if (profileId == null) {
return null;
}
for( final PlayerEntity player : AppEng.proxy.getPlayers() )
{
if( player.getUniqueID().equals( profileId ) )
{
return player;
}
}
return null;
}
return null;
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries;
import appeng.api.features.IChargerRegistry;
import appeng.api.features.ILocatableRegistry;
import appeng.api.features.IMatterCannonAmmoRegistry;
@@ -35,7 +34,6 @@ import appeng.api.storage.ICellRegistry;
import appeng.core.features.registries.cell.CellRegistry;
import appeng.core.features.registries.charger.ChargerRegistry;
/**
* represents all registries
*
@@ -45,90 +43,77 @@ import appeng.core.features.registries.charger.ChargerRegistry;
* @version rv5
* @since rv0
*/
public class RegistryContainer implements IRegistryContainer
{
private final IChargerRegistry charger = new ChargerRegistry();
private final ICellRegistry cell = new CellRegistry();
private final ILocatableRegistry locatable = new LocatableRegistry();
private final ISpecialComparisonRegistry comparison = new SpecialComparisonRegistry();
private final IWirelessTermRegistry wireless = new WirelessRegistry();
private final IGridCacheRegistry gridCache = new GridCacheRegistry();
private final IP2PTunnelRegistry p2pTunnel = new P2PTunnelRegistry();
private final IMovableRegistry movable = new MovableTileRegistry();
private final IMatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
private final IPlayerRegistry playerRegistry = new PlayerRegistry();
private final IPartModels partModels = new PartModels();
public class RegistryContainer implements IRegistryContainer {
private final IChargerRegistry charger = new ChargerRegistry();
private final ICellRegistry cell = new CellRegistry();
private final ILocatableRegistry locatable = new LocatableRegistry();
private final ISpecialComparisonRegistry comparison = new SpecialComparisonRegistry();
private final IWirelessTermRegistry wireless = new WirelessRegistry();
private final IGridCacheRegistry gridCache = new GridCacheRegistry();
private final IP2PTunnelRegistry p2pTunnel = new P2PTunnelRegistry();
private final IMovableRegistry movable = new MovableTileRegistry();
private final IMatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
private final IPlayerRegistry playerRegistry = new PlayerRegistry();
private final IPartModels partModels = new PartModels();
@Override
public IMovableRegistry movable()
{
return this.movable;
}
@Override
public IMovableRegistry movable() {
return this.movable;
}
@Override
public IGridCacheRegistry gridCache()
{
return this.gridCache;
}
@Override
public IGridCacheRegistry gridCache() {
return this.gridCache;
}
@Override
public ISpecialComparisonRegistry specialComparison()
{
return this.comparison;
}
@Override
public ISpecialComparisonRegistry specialComparison() {
return this.comparison;
}
@Override
public IWirelessTermRegistry wireless()
{
return this.wireless;
}
@Override
public IWirelessTermRegistry wireless() {
return this.wireless;
}
@Override
public ICellRegistry cell()
{
return this.cell;
}
@Override
public ICellRegistry cell() {
return this.cell;
}
@Override
public IChargerRegistry charger()
{
return this.charger;
}
@Override
public IChargerRegistry charger() {
return this.charger;
}
@Override
public ILocatableRegistry locatable()
{
return this.locatable;
}
@Override
public ILocatableRegistry locatable() {
return this.locatable;
}
@Override
public IP2PTunnelRegistry p2pTunnel()
{
return this.p2pTunnel;
}
@Override
public IP2PTunnelRegistry p2pTunnel() {
return this.p2pTunnel;
}
@Override
public IMatterCannonAmmoRegistry matterCannon()
{
return this.matterCannonReg;
}
@Override
public IMatterCannonAmmoRegistry matterCannon() {
return this.matterCannonReg;
}
@Override
public IPlayerRegistry players()
{
return this.playerRegistry;
}
@Override
public IPlayerRegistry players() {
return this.playerRegistry;
}
@Override
public IWorldGen worldgen()
{
return WorldGenRegistry.INSTANCE;
}
@Override
public IWorldGen worldgen() {
return WorldGenRegistry.INSTANCE;
}
@Override
public IPartModels partModels()
{
return this.partModels;
}
@Override
public IPartModels partModels() {
return this.partModels;
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries;
import java.util.ArrayList;
import java.util.List;
@@ -28,35 +27,28 @@ import appeng.api.features.IItemComparison;
import appeng.api.features.IItemComparisonProvider;
import appeng.api.features.ISpecialComparisonRegistry;
public class SpecialComparisonRegistry implements ISpecialComparisonRegistry {
public class SpecialComparisonRegistry implements ISpecialComparisonRegistry
{
private final List<IItemComparisonProvider> CompRegistry;
private final List<IItemComparisonProvider> CompRegistry;
public SpecialComparisonRegistry() {
this.CompRegistry = new ArrayList<>();
}
public SpecialComparisonRegistry()
{
this.CompRegistry = new ArrayList<>();
}
@Override
public IItemComparison getSpecialComparison(final ItemStack stack) {
for (final IItemComparisonProvider i : this.CompRegistry) {
final IItemComparison comp = i.getComparison(stack);
if (comp != null) {
return comp;
}
}
@Override
public IItemComparison getSpecialComparison( final ItemStack stack )
{
for( final IItemComparisonProvider i : this.CompRegistry )
{
final IItemComparison comp = i.getComparison( stack );
if( comp != null )
{
return comp;
}
}
return null;
}
return null;
}
@Override
public void addComparisonProvider( final IItemComparisonProvider prov )
{
this.CompRegistry.add( prov );
}
@Override
public void addComparisonProvider(final IItemComparisonProvider prov) {
this.CompRegistry.add(prov);
}
}
@@ -18,14 +18,9 @@
package appeng.core.features.registries;
import java.util.ArrayList;
import java.util.List;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.ContainerMEPortableCell;
import appeng.container.implementations.ContainerWirelessTerm;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
@@ -35,92 +30,76 @@ import appeng.api.AEApi;
import appeng.api.features.ILocatable;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.features.IWirelessTermRegistry;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.ContainerMEPortableCell;
import appeng.container.implementations.ContainerWirelessTerm;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
public final class WirelessRegistry implements IWirelessTermRegistry {
private final List<IWirelessTermHandler> handlers;
public final class WirelessRegistry implements IWirelessTermRegistry
{
private final List<IWirelessTermHandler> handlers;
public WirelessRegistry() {
this.handlers = new ArrayList<>();
}
public WirelessRegistry()
{
this.handlers = new ArrayList<>();
}
@Override
public void registerWirelessHandler(final IWirelessTermHandler handler) {
if (handler != null) {
this.handlers.add(handler);
}
}
@Override
public void registerWirelessHandler( final IWirelessTermHandler handler )
{
if( handler != null )
{
this.handlers.add( handler );
}
}
@Override
public boolean isWirelessTerminal(final ItemStack is) {
for (final IWirelessTermHandler h : this.handlers) {
if (h.canHandle(is)) {
return true;
}
}
return false;
}
@Override
public boolean isWirelessTerminal( final ItemStack is )
{
for( final IWirelessTermHandler h : this.handlers )
{
if( h.canHandle( is ) )
{
return true;
}
}
return false;
}
@Override
public IWirelessTermHandler getWirelessTerminalHandler(final ItemStack is) {
for (final IWirelessTermHandler h : this.handlers) {
if (h.canHandle(is)) {
return h;
}
}
return null;
}
@Override
public IWirelessTermHandler getWirelessTerminalHandler( final ItemStack is )
{
for( final IWirelessTermHandler h : this.handlers )
{
if( h.canHandle( is ) )
{
return h;
}
}
return null;
}
@Override
public void openWirelessTerminalGui(ItemStack item, IBlockReader world, PlayerEntity player, Hand hand) {
if (Platform.isClient()) {
return;
}
@Override
public void openWirelessTerminalGui( ItemStack item, IBlockReader world, PlayerEntity player, Hand hand )
{
if( Platform.isClient() )
{
return;
}
if (!this.isWirelessTerminal(item)) {
player.sendMessage(PlayerMessages.DeviceNotWirelessTerminal.get());
return;
}
if( !this.isWirelessTerminal( item ) )
{
player.sendMessage( PlayerMessages.DeviceNotWirelessTerminal.get() );
return;
}
final IWirelessTermHandler handler = this.getWirelessTerminalHandler(item);
final String unparsedKey = handler.getEncryptionKey(item);
if (unparsedKey.isEmpty()) {
player.sendMessage(PlayerMessages.DeviceNotLinked.get());
return;
}
final IWirelessTermHandler handler = this.getWirelessTerminalHandler( item );
final String unparsedKey = handler.getEncryptionKey( item );
if( unparsedKey.isEmpty() )
{
player.sendMessage( PlayerMessages.DeviceNotLinked.get() );
return;
}
final long parsedKey = Long.parseLong(unparsedKey);
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
if (securityStation == null) {
player.sendMessage(PlayerMessages.StationCanNotBeLocated.get());
return;
}
final long parsedKey = Long.parseLong( unparsedKey );
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy( parsedKey );
if( securityStation == null )
{
player.sendMessage( PlayerMessages.StationCanNotBeLocated.get() );
return;
}
if( handler.hasPower( player, 0.5, item ) )
{
ContainerOpener.openContainer(ContainerWirelessTerm.TYPE, player, ContainerLocator.forHand(player, hand));
}
else
{
player.sendMessage( PlayerMessages.DeviceNotPowered.get() );
}
}
if (handler.hasPower(player, 0.5, item)) {
ContainerOpener.openContainer(ContainerWirelessTerm.TYPE, player, ContainerLocator.forHand(player, hand));
} else {
player.sendMessage(PlayerMessages.DeviceNotPowered.get());
}
}
}
@@ -18,109 +18,91 @@
package appeng.core.features.registries;
import java.util.HashSet;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraft.world.dimension.Dimension;
import appeng.api.features.IWorldGen;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.extensions.IForgeDimension;
import appeng.api.features.IWorldGen;
public final class WorldGenRegistry implements IWorldGen
{
public final class WorldGenRegistry implements IWorldGen {
public static final WorldGenRegistry INSTANCE = new WorldGenRegistry();
private final TypeSet[] types;
public static final WorldGenRegistry INSTANCE = new WorldGenRegistry();
private final TypeSet[] types;
private WorldGenRegistry()
{
private WorldGenRegistry() {
this.types = new TypeSet[WorldGenType.values().length];
this.types = new TypeSet[WorldGenType.values().length];
for( final WorldGenType type : WorldGenType.values() )
{
this.types[type.ordinal()] = new TypeSet();
}
}
for (final WorldGenType type : WorldGenType.values()) {
this.types[type.ordinal()] = new TypeSet();
}
}
@Override
public void disableWorldGenForProviderID( WorldGenType type, Class<? extends Dimension> provider )
{
if( type == null )
{
throw new IllegalArgumentException( "Bad Type Passed" );
}
@Override
public void disableWorldGenForProviderID(WorldGenType type, Class<? extends Dimension> provider) {
if (type == null) {
throw new IllegalArgumentException("Bad Type Passed");
}
if( provider == null )
{
throw new IllegalArgumentException( "Bad Provider Passed" );
}
if (provider == null) {
throw new IllegalArgumentException("Bad Provider Passed");
}
this.types[type.ordinal()].badProviders.add( provider );
}
this.types[type.ordinal()].badProviders.add(provider);
}
@Override
public void enableWorldGenForDimension( final WorldGenType type, final ResourceLocation dimensionID )
{
if( type == null )
{
throw new IllegalArgumentException( "Bad Type Passed" );
}
@Override
public void enableWorldGenForDimension(final WorldGenType type, final ResourceLocation dimensionID) {
if (type == null) {
throw new IllegalArgumentException("Bad Type Passed");
}
this.types[type.ordinal()].enabledDimensions.add( dimensionID );
}
this.types[type.ordinal()].enabledDimensions.add(dimensionID);
}
@Override
public void disableWorldGenForDimension( final WorldGenType type, final ResourceLocation dimensionID )
{
if( type == null )
{
throw new IllegalArgumentException( "Bad Type Passed" );
}
@Override
public void disableWorldGenForDimension(final WorldGenType type, final ResourceLocation dimensionID) {
if (type == null) {
throw new IllegalArgumentException("Bad Type Passed");
}
this.types[type.ordinal()].badDimensions.add( dimensionID );
}
this.types[type.ordinal()].badDimensions.add(dimensionID);
}
@Override
public boolean isWorldGenEnabled( final WorldGenType type, final World w )
{
if( type == null )
{
throw new IllegalArgumentException( "Bad Type Passed" );
}
@Override
public boolean isWorldGenEnabled(final WorldGenType type, final World w) {
if (type == null) {
throw new IllegalArgumentException("Bad Type Passed");
}
if( w == null )
{
throw new IllegalArgumentException( "Bad Provider Passed" );
}
if (w == null) {
throw new IllegalArgumentException("Bad Provider Passed");
}
ResourceLocation id = w.dimension.getDimension().getType().getRegistryName();
final boolean isBadProvider = this.types[type.ordinal()].badProviders.contains( w.dimension.getClass() );
final boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains( id );
final boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains( id );
ResourceLocation id = w.dimension.getDimension().getType().getRegistryName();
final boolean isBadProvider = this.types[type.ordinal()].badProviders.contains(w.dimension.getClass());
final boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains(id);
final boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains(id);
if( isBadProvider || isBadDimension )
{
return false;
}
if (isBadProvider || isBadDimension) {
return false;
}
if( !isGoodDimension && type == WorldGenType.METEORITES )
{
return false;
}
if (!isGoodDimension && type == WorldGenType.METEORITES) {
return false;
}
return true;
}
return true;
}
private static class TypeSet
{
private static class TypeSet {
final HashSet<Class<? extends Dimension>> badProviders = new HashSet<>();
final HashSet<ResourceLocation> badDimensions = new HashSet<>();
final HashSet<ResourceLocation> enabledDimensions = new HashSet<>();
}
final HashSet<Class<? extends Dimension>> badProviders = new HashSet<>();
final HashSet<ResourceLocation> badDimensions = new HashSet<>();
final HashSet<ResourceLocation> enabledDimensions = new HashSet<>();
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries.cell;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellHandler;
@@ -30,25 +29,21 @@ import appeng.api.storage.data.IAEStack;
import appeng.me.storage.BasicCellInventory;
import appeng.me.storage.BasicCellInventoryHandler;
public class BasicCellHandler implements ICellHandler {
public class BasicCellHandler implements ICellHandler
{
@Override
public boolean isCell(final ItemStack is) {
return BasicCellInventory.isCell(is);
}
@Override
public boolean isCell( final ItemStack is )
{
return BasicCellInventory.isCell( is );
}
@Override
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
{
final ICellInventory<T> inv = BasicCellInventory.createInventory( is, container );
if( inv == null || inv.getChannel() != channel )
{
return null;
}
return new BasicCellInventoryHandler<>( inv, channel );
}
@Override
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory(final ItemStack is,
final ISaveProvider container, final IStorageChannel<T> channel) {
final ICellInventory<T> inv = BasicCellInventory.createInventory(is, container);
if (inv == null || inv.getChannel() != channel) {
return null;
}
return new BasicCellInventoryHandler<>(inv, channel);
}
}
@@ -1,11 +1,6 @@
package appeng.core.features.registries.cell;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.ContainerMEMonitorable;
import appeng.container.implementations.ContainerWireless;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -19,21 +14,22 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.AEPartLocation;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.ContainerMEMonitorable;
import appeng.container.implementations.ContainerWireless;
import appeng.util.Platform;
public class BasicItemCellGuiHandler implements ICellGuiHandler {
@Override
public <T extends IAEStack<T>> boolean isHandlerFor(final IStorageChannel<T> channel) {
return channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
}
public class BasicItemCellGuiHandler implements ICellGuiHandler
{
@Override
public <T extends IAEStack<T>> boolean isHandlerFor( final IStorageChannel<T> channel )
{
return channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
public void openChestGui( final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan )
{
ContainerOpener.openContainer(ContainerMEMonitorable.TYPE, player, ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp()));
}
@Override
public void openChestGui(final PlayerEntity player, final IChestOrDrive chest, final ICellHandler cellHandler,
final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan) {
ContainerOpener.openContainer(ContainerMEMonitorable.TYPE, player,
ContainerLocator.forTileEntitySide((TileEntity) chest, chest.getUp()));
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries.cell;
import java.util.ArrayList;
import java.util.List;
@@ -35,108 +34,88 @@ import appeng.api.storage.ISaveProvider;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEStack;
public class CellRegistry implements ICellRegistry {
public class CellRegistry implements ICellRegistry
{
private final List<ICellHandler> handlers;
private final List<ICellGuiHandler> guiHandlers;
private final List<ICellHandler> handlers;
private final List<ICellGuiHandler> guiHandlers;
public CellRegistry() {
this.handlers = new ArrayList<>();
this.guiHandlers = new ArrayList<>();
}
public CellRegistry()
{
this.handlers = new ArrayList<>();
this.guiHandlers = new ArrayList<>();
}
@Override
public void addCellHandler(final ICellHandler handler) {
Preconditions.checkNotNull(handler, "Called before FMLCommonSetupEvent.");
Preconditions.checkArgument(!this.handlers.contains(handler),
"Tried to register the same handler instance twice.");
@Override
public void addCellHandler( final ICellHandler handler )
{
Preconditions.checkNotNull( handler, "Called before FMLCommonSetupEvent." );
Preconditions.checkArgument( !this.handlers.contains( handler ), "Tried to register the same handler instance twice." );
this.handlers.add(handler);
this.handlers.add( handler );
// Verify that the first entry is always our own handler.
Verify.verify(this.handlers.get(0) instanceof BasicCellHandler);
}
// Verify that the first entry is always our own handler.
Verify.verify( this.handlers.get( 0 ) instanceof BasicCellHandler );
}
@Override
public boolean isCellHandled(final ItemStack is) {
if (is.isEmpty()) {
return false;
}
for (final ICellHandler ch : this.handlers) {
if (ch.isCell(is)) {
return true;
}
}
return false;
}
@Override
public boolean isCellHandled( final ItemStack is )
{
if( is.isEmpty() )
{
return false;
}
for( final ICellHandler ch : this.handlers )
{
if( ch.isCell( is ) )
{
return true;
}
}
return false;
}
@Override
public ICellHandler getHandler(final ItemStack is) {
if (is.isEmpty()) {
return null;
}
for (final ICellHandler ch : this.handlers) {
if (ch.isCell(is)) {
return ch;
}
}
return null;
}
@Override
public ICellHandler getHandler( final ItemStack is )
{
if( is.isEmpty() )
{
return null;
}
for( final ICellHandler ch : this.handlers )
{
if( ch.isCell( is ) )
{
return ch;
}
}
return null;
}
@Override
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory(final ItemStack is,
final ISaveProvider container, final IStorageChannel<T> chan) {
if (is.isEmpty()) {
return null;
}
for (final ICellHandler ch : this.handlers) {
if (ch.isCell(is)) {
return ch.getCellInventory(is, container, chan);
}
}
return null;
}
@Override
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> chan )
{
if( is.isEmpty() )
{
return null;
}
for( final ICellHandler ch : this.handlers )
{
if( ch.isCell( is ) )
{
return ch.getCellInventory( is, container, chan );
}
}
return null;
}
@Override
public void addCellGuiHandler(ICellGuiHandler handler) {
this.guiHandlers.add(handler);
}
@Override
public void addCellGuiHandler( ICellGuiHandler handler )
{
this.guiHandlers.add( handler );
}
@Override
public <T extends IAEStack<T>> ICellGuiHandler getGuiHandler(final IStorageChannel<T> channel, final ItemStack is) {
ICellGuiHandler fallBack = null;
@Override
public <T extends IAEStack<T>> ICellGuiHandler getGuiHandler( final IStorageChannel<T> channel, final ItemStack is )
{
ICellGuiHandler fallBack = null;
for (final ICellGuiHandler ch : this.guiHandlers) {
if (ch.isHandlerFor(channel)) {
if (ch.isSpecializedFor(is)) {
return ch;
}
for( final ICellGuiHandler ch : this.guiHandlers )
{
if( ch.isHandlerFor( channel ) )
{
if( ch.isSpecializedFor( is ) )
{
return ch;
}
if( fallBack == null )
{
fallBack = ch;
}
}
}
return fallBack;
}
if (fallBack == null) {
fallBack = ch;
}
}
}
return fallBack;
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries.cell;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
@@ -30,36 +29,30 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.items.storage.ItemCreativeStorageCell;
import appeng.me.storage.CreativeCellInventory;
public final class CreativeCellHandler implements ICellHandler {
public final class CreativeCellHandler implements ICellHandler
{
@Override
public boolean isCell(final ItemStack is) {
return !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell;
}
@Override
public boolean isCell( final ItemStack is )
{
return !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell;
}
@Override
public ICellInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container,
final IStorageChannel channel) {
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) && !is.isEmpty()
&& is.getItem() instanceof ItemCreativeStorageCell) {
return CreativeCellInventory.getCell(is);
}
return null;
}
@Override
public ICellInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel )
{
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && !is.isEmpty() && is
.getItem() instanceof ItemCreativeStorageCell )
{
return CreativeCellInventory.getCell( is );
}
return null;
}
@Override
public int getStatusForCell(final ItemStack is, final ICellInventoryHandler handler) {
return 2;
}
@Override
public int getStatusForCell( final ItemStack is, final ICellInventoryHandler handler )
{
return 2;
}
@Override
public double cellIdleDrain( final ItemStack is, final ICellInventoryHandler handler )
{
return 0;
}
@Override
public double cellIdleDrain(final ItemStack is, final ICellInventoryHandler handler) {
return 0;
}
}
@@ -18,7 +18,6 @@
package appeng.core.features.registries.charger;
import java.util.IdentityHashMap;
import java.util.Map;
@@ -31,45 +30,39 @@ 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;
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;
private final Map<Item, Double> chargeRates;
public ChargerRegistry() {
this.chargeRates = new IdentityHashMap<>();
}
public ChargerRegistry()
{
this.chargeRates = new IdentityHashMap<>();
}
@Override
@Nonnegative
public double getChargeRate(@Nonnull Item item) {
Preconditions.checkNotNull(item);
@Override
@Nonnegative
public double getChargeRate( @Nonnull Item item )
{
Preconditions.checkNotNull( item );
return this.chargeRates.getOrDefault(item, DEFAULT_CHARGE_RATE);
}
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);
@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);
final double cappedValue = Math.min( value, CAPPED_CHARGE_RATE );
this.chargeRates.put(item, cappedValue);
}
this.chargeRates.put( item, cappedValue );
}
@Override
public void removeChargeRate(@Nonnull Item item) {
Preconditions.checkNotNull(item);
@Override
public void removeChargeRate( @Nonnull Item item )
{
Preconditions.checkNotNull( item );
this.chargeRates.remove( item );
}
this.chargeRates.remove(item);
}
}