Replaced all instances of Guava's Optional type with Java 8's Optional type, as discussed in #81. (#90)
This commit is contained in:
parent
c2a239a12f
commit
e276aa682f
|
@ -27,8 +27,6 @@ package appeng.api.config;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
|
@ -70,11 +68,7 @@ public enum Upgrades
|
|||
*/
|
||||
public void registerItem( final IItemDefinition item, final int maxSupported )
|
||||
{
|
||||
final Optional<ItemStack> maybeStack = item.maybeStack( 1 );
|
||||
for( final ItemStack stack : maybeStack.asSet() )
|
||||
{
|
||||
this.registerItem( stack, maxSupported );
|
||||
}
|
||||
item.maybeStack( 1 ).ifPresent( is -> this.registerItem( is, maxSupported ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
package appeng.api.definitions;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
|
|
@ -26,7 +26,7 @@ package appeng.api.definitions;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
package appeng.api.definitions;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
|
|
@ -68,19 +68,17 @@ public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEIte
|
|||
{
|
||||
final Block blockID = Block.getBlockFromItem( this );
|
||||
final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
|
||||
for( final Block block : energyCell.maybeBlock().asSet() )
|
||||
{
|
||||
if( blockID == block )
|
||||
{
|
||||
return 200000;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 8 * 200000;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return energyCell.maybeBlock().map( block -> {
|
||||
if( blockID == block )
|
||||
{
|
||||
return 200000;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 8 * 200000;
|
||||
}
|
||||
}
|
||||
).orElse( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,12 +39,7 @@ public class ItemCraftingStorage extends AEBaseItemBlock
|
|||
@Override
|
||||
public ItemStack getContainerItem( final ItemStack itemStack )
|
||||
{
|
||||
for( final ItemStack stack : AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
return null;
|
||||
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).orElse( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -68,9 +68,9 @@ public class FeatureFactory
|
|||
|
||||
public AEColoredItemDefinition colored( IItemDefinition target, int offset )
|
||||
{
|
||||
final ColoredItemDefinition definition = new ColoredItemDefinition();
|
||||
ColoredItemDefinition definition = new ColoredItemDefinition();
|
||||
|
||||
for( final Item targetItem : target.maybeItem().asSet() )
|
||||
target.maybeItem().ifPresent( targetItem ->
|
||||
{
|
||||
for( final AEColor color : AEColor.VALID_COLORS )
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ public class FeatureFactory
|
|||
|
||||
definition.add( color, new ItemStackSrc( targetItem, offset + color.ordinal(), state ) );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
|
|
@ -100,38 +100,26 @@ public class GuiCraftAmount extends AEBaseGui
|
|||
|
||||
if( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
for( final ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = wirelessTerminalStack;
|
||||
}
|
||||
myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( myIcon );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if( target instanceof PartTerminal )
|
||||
{
|
||||
for( final ItemStack stack : parts.terminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = stack;
|
||||
}
|
||||
myIcon = parts.terminal().maybeStack( 1 ).orElse( null );
|
||||
this.originalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if( target instanceof PartCraftingTerminal )
|
||||
{
|
||||
for( final ItemStack stack : parts.craftingTerminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = stack;
|
||||
}
|
||||
myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( null );
|
||||
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if( target instanceof PartPatternTerminal )
|
||||
{
|
||||
for( final ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = stack;
|
||||
}
|
||||
myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( null );
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,38 +70,29 @@ public class GuiCraftingStatus extends GuiCraftingCPU
|
|||
|
||||
if( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
for( final ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.myIcon = wirelessTerminalStack;
|
||||
}
|
||||
myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( null );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if( target instanceof PartTerminal )
|
||||
{
|
||||
for( final ItemStack stack : parts.terminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.myIcon = stack;
|
||||
}
|
||||
myIcon = parts.terminal().maybeStack( 1 ).orElse( null );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if( target instanceof PartCraftingTerminal )
|
||||
{
|
||||
for( final ItemStack stack : parts.craftingTerminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.myIcon = stack;
|
||||
}
|
||||
myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( null );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if( target instanceof PartPatternTerminal )
|
||||
{
|
||||
for( final ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.myIcon = stack;
|
||||
}
|
||||
myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( null );
|
||||
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.lwjgl.input.Mouse;
|
|||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FullnessMode;
|
||||
|
@ -94,15 +93,9 @@ public class GuiIOPort extends GuiUpgradeable
|
|||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
for( final ItemStack cell1kStack : definitions.items().cell1k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.drawItem( offsetX + 66 - 8, offsetY + 17, cell1kStack );
|
||||
}
|
||||
definitions.items().cell1k().maybeStack( 1 ).ifPresent( cell1kStack -> this.drawItem( offsetX + 66 - 8, offsetY + 17, cell1kStack ) );
|
||||
|
||||
for( final ItemStack driveStack : definitions.blocks().drive().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.drawItem( offsetX + 94 + 8, offsetY + 17, driveStack );
|
||||
}
|
||||
definitions.blocks().drive().maybeStack( 1 ).ifPresent( driveStack -> this.drawItem( offsetX + 94 + 8, offsetY + 17, driveStack ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,58 +100,37 @@ public class GuiPriority extends AEBaseGui
|
|||
|
||||
if( target instanceof PartStorageBus )
|
||||
{
|
||||
for( final ItemStack storageBusStack : parts.storageBus().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = storageBusStack;
|
||||
}
|
||||
myIcon = parts.storageBus().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_STORAGEBUS;
|
||||
}
|
||||
|
||||
if( target instanceof PartFormationPlane )
|
||||
{
|
||||
for( final ItemStack formationPlaneStack : parts.formationPlane().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = formationPlaneStack;
|
||||
}
|
||||
myIcon = parts.formationPlane().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_FORMATION_PLANE;
|
||||
}
|
||||
|
||||
if( target instanceof TileDrive )
|
||||
{
|
||||
for( final ItemStack driveStack : blocks.drive().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = driveStack;
|
||||
}
|
||||
|
||||
myIcon = blocks.drive().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_DRIVE;
|
||||
}
|
||||
|
||||
if( target instanceof TileChest )
|
||||
{
|
||||
for( final ItemStack chestStack : blocks.chest().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = chestStack;
|
||||
}
|
||||
|
||||
myIcon = blocks.chest().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_CHEST;
|
||||
}
|
||||
|
||||
if( target instanceof TileInterface )
|
||||
{
|
||||
for( final ItemStack interfaceStack : blocks.iface().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = interfaceStack;
|
||||
}
|
||||
|
||||
myIcon = blocks.iface().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
if( target instanceof PartInterface )
|
||||
{
|
||||
for( final ItemStack interfaceStack : parts.iface().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = interfaceStack;
|
||||
}
|
||||
myIcon = parts.iface().maybeStack( 1 ).orElse( myIcon );
|
||||
this.OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,11 +126,11 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
|||
|
||||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||
{
|
||||
final boolean matchA = ( top == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( top, recipe.getTopOptional().orNull() ) ) && // and...
|
||||
( bot == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( bot, recipe.getBottomOptional().orNull() ) );
|
||||
final boolean matchA = ( top == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( top, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( bot == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( bot, recipe.getBottomOptional().orElse( null ) ) );
|
||||
|
||||
final boolean matchB = ( bot == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( bot, recipe.getTopOptional().orNull() ) ) && // and...
|
||||
( top == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( top, recipe.getBottomOptional().orNull() ) );
|
||||
final boolean matchB = ( bot == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( bot, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( top == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( top, recipe.getBottomOptional().orElse( null ) ) );
|
||||
|
||||
if( matchA || matchB )
|
||||
{
|
||||
|
@ -174,13 +174,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
|||
boolean isValid = false;
|
||||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( recipe.getTopOptional().orNull(), otherSlot ) )
|
||||
if( Platform.isSameItemPrecise( recipe.getTopOptional().orElse( null ), otherSlot ) )
|
||||
{
|
||||
isValid = Platform.isSameItemPrecise( is, recipe.getBottomOptional().orNull() );
|
||||
isValid = Platform.isSameItemPrecise( is, recipe.getBottomOptional().orElse( null ) );
|
||||
}
|
||||
else if( Platform.isSameItemPrecise( recipe.getBottomOptional().orNull(), otherSlot ) )
|
||||
else if( Platform.isSameItemPrecise( recipe.getBottomOptional().orElse( null ), otherSlot ) )
|
||||
{
|
||||
isValid = Platform.isSameItemPrecise( is, recipe.getTopOptional().orNull() );
|
||||
isValid = Platform.isSameItemPrecise( is, recipe.getTopOptional().orElse( null ) );
|
||||
}
|
||||
|
||||
if( isValid )
|
||||
|
|
|
@ -21,6 +21,7 @@ package appeng.container.implementations;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
@ -216,9 +217,10 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
|||
}
|
||||
|
||||
// add a new encoded pattern.
|
||||
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
|
||||
Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 );
|
||||
if( maybePattern.isPresent() )
|
||||
{
|
||||
output = encodedPatternStack;
|
||||
output = maybePattern.get();
|
||||
this.patternSlotOUT.putStack( output );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import net.minecraft.entity.player.InventoryPlayer;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
|
@ -138,13 +137,13 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
|
|||
{
|
||||
if( this.myName.length() > 0 )
|
||||
{
|
||||
for( final ItemStack namePressStack : AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).asSet() )
|
||||
return AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).map( namePressStack ->
|
||||
{
|
||||
final NBTTagCompound compound = Platform.openNbtData( namePressStack );
|
||||
compound.setString( "InscribeName", this.myName );
|
||||
|
||||
return namePressStack;
|
||||
}
|
||||
} ).orElse( null );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
package appeng.core;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -67,9 +69,10 @@ public final class CreativeTab extends CreativeTabs
|
|||
{
|
||||
for( final IItemDefinition definition : choices )
|
||||
{
|
||||
for( final ItemStack definitionStack : definition.maybeStack( 1 ).asSet() )
|
||||
Optional<ItemStack> maybeIs = definition.maybeStack( 1 );
|
||||
if( maybeIs.isPresent() )
|
||||
{
|
||||
return definitionStack;
|
||||
return maybeIs.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package appeng.core;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
|
|
@ -26,9 +26,6 @@ import javax.annotation.Nonnull;
|
|||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -297,12 +294,12 @@ public final class Registration
|
|||
registries.cell().addCellHandler( new BasicCellHandler() );
|
||||
registries.cell().addCellHandler( new CreativeCellHandler() );
|
||||
|
||||
for( final ItemStack ammoStack : api.definitions().materials().matterBall().maybeStack( 1 ).asSet() )
|
||||
api.definitions().materials().matterBall().maybeStack( 1 ).ifPresent( ammoStack ->
|
||||
{
|
||||
final double weight = 32;
|
||||
|
||||
registries.matterCannon().registerAmmo( ammoStack, weight );
|
||||
}
|
||||
} );
|
||||
|
||||
this.recipeHandler.injectRecipes();
|
||||
|
||||
|
@ -342,10 +339,7 @@ public final class Registration
|
|||
GuiText.values();
|
||||
|
||||
Api.INSTANCE.partHelper().initFMPSupport();
|
||||
for( final Block block : blocks.multiPart().maybeBlock().asSet() )
|
||||
{
|
||||
( (BlockCableBus) block ).setupTile();
|
||||
}
|
||||
blocks.multiPart().maybeBlock().ifPresent( block -> ( (BlockCableBus) block ).setupTile() );
|
||||
|
||||
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.postInitialize( event.getSide() ) );
|
||||
|
||||
|
@ -414,10 +408,10 @@ public final class Registration
|
|||
// Inscriber
|
||||
Upgrades.SPEED.registerItem( blocks.inscriber(), 3 );
|
||||
|
||||
for( final Item wirelessTerminalItem : items.wirelessTerminal().maybeItem().asSet() )
|
||||
items.wirelessTerminal().maybeItem().ifPresent( terminal ->
|
||||
{
|
||||
registries.wireless().registerWirelessHandler( (IWirelessTermHandler) wirelessTerminalItem );
|
||||
}
|
||||
registries.wireless().registerWirelessHandler( (IWirelessTermHandler) terminal );
|
||||
} );
|
||||
|
||||
// add villager trading to black smiths for a few basic materials
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.VillagerTrading ) )
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package appeng.core.features;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -38,7 +38,7 @@ public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
|||
public BlockDefinition( String registryName, Block block, ItemBlock item )
|
||||
{
|
||||
super( registryName, item );
|
||||
this.block = Optional.fromNullable( block );
|
||||
this.block = Optional.ofNullable( block );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +50,7 @@ public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
|||
@Override
|
||||
public final Optional<ItemBlock> maybeItemBlock()
|
||||
{
|
||||
return this.block.transform( ItemBlock::new );
|
||||
return this.block.map( ItemBlock::new );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,12 +58,12 @@ public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
|||
{
|
||||
Preconditions.checkArgument( stackSize > 0 );
|
||||
|
||||
return this.block.transform( b -> new ItemStack( b, stackSize ) );
|
||||
return this.block.map( b -> new ItemStack( b, stackSize ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isSameAs( final IBlockAccess world, final BlockPos pos )
|
||||
{
|
||||
return this.isEnabled() && world.getBlockState( pos ).getBlock() == this.block.get();
|
||||
return block.isPresent() && world.getBlockState( pos ).getBlock() == this.block.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -34,7 +33,6 @@ import appeng.api.definitions.IItemDefinition;
|
|||
public final class DamagedItemDefinition implements IItemDefinition
|
||||
{
|
||||
private final String identifier;
|
||||
private static final ItemTransformer ITEM_TRANSFORMER = new ItemTransformer();
|
||||
private final Optional<IStackSrc> source;
|
||||
|
||||
public DamagedItemDefinition( @Nonnull final String identifier, @Nonnull final IStackSrc source )
|
||||
|
@ -48,7 +46,7 @@ public final class DamagedItemDefinition implements IItemDefinition
|
|||
}
|
||||
else
|
||||
{
|
||||
this.source = Optional.absent();
|
||||
this.source = Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,13 +60,13 @@ public final class DamagedItemDefinition implements IItemDefinition
|
|||
@Override
|
||||
public Optional<Item> maybeItem()
|
||||
{
|
||||
return this.source.transform( ITEM_TRANSFORMER );
|
||||
return this.source.map( IStackSrc::getItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ItemStack> maybeStack( final int stackSize )
|
||||
{
|
||||
return this.source.transform( new ItemStackTransformer( stackSize ) );
|
||||
return this.source.map( input -> input.stack( stackSize ));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,30 +86,4 @@ public final class DamagedItemDefinition implements IItemDefinition
|
|||
return this.isEnabled() && comparableStack.getItem() == this.source.get().getItem() && comparableStack.getItemDamage() == this.source.get().getDamage();
|
||||
}
|
||||
|
||||
private static class ItemTransformer implements Function<IStackSrc, Item>
|
||||
{
|
||||
@Override
|
||||
public Item apply( final IStackSrc input )
|
||||
{
|
||||
return input.getItem();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ItemStackTransformer implements Function<IStackSrc, ItemStack>
|
||||
{
|
||||
private final int stackSize;
|
||||
|
||||
public ItemStackTransformer( final int stackSize )
|
||||
{
|
||||
Preconditions.checkArgument( stackSize > 0 );
|
||||
|
||||
this.stackSize = stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack apply( final IStackSrc input )
|
||||
{
|
||||
return input.stack( this.stackSize );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
|
@ -42,7 +41,7 @@ public class ItemDefinition implements IItemDefinition
|
|||
{
|
||||
Preconditions.checkArgument( !Strings.isNullOrEmpty( registryName ), "registryName" );
|
||||
this.identifier = registryName;
|
||||
this.item = Optional.fromNullable( item );
|
||||
this.item = Optional.ofNullable( item );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -61,7 +60,7 @@ public class ItemDefinition implements IItemDefinition
|
|||
@Override
|
||||
public Optional<ItemStack> maybeStack( final int stackSize )
|
||||
{
|
||||
return this.item.transform( new ItemStackTransformer( stackSize ) );
|
||||
return this.item.map( item -> new ItemStack( item, stackSize ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,24 +72,7 @@ public class ItemDefinition implements IItemDefinition
|
|||
@Override
|
||||
public final boolean isSameAs( final ItemStack comparableStack )
|
||||
{
|
||||
return this.isEnabled() && Platform.isSameItemType( comparableStack, this.maybeStack( 1 ).get() );
|
||||
return isEnabled() && Platform.isSameItemType( comparableStack, this.maybeStack( 1 ).get() );
|
||||
}
|
||||
|
||||
private static class ItemStackTransformer implements Function<Item, ItemStack>
|
||||
{
|
||||
private final int stackSize;
|
||||
|
||||
public ItemStackTransformer( final int stackSize )
|
||||
{
|
||||
Preconditions.checkArgument( stackSize > 0 );
|
||||
|
||||
this.stackSize = stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack apply( final Item input )
|
||||
{
|
||||
return new ItemStack( input, this.stackSize );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
@ -38,12 +37,12 @@ public final class TileDefinition extends BlockDefinition implements ITileDefini
|
|||
public TileDefinition( @Nonnull String registryName, AEBaseTileBlock block, ItemBlock item )
|
||||
{
|
||||
super( registryName, block, item );
|
||||
this.block = Optional.fromNullable( block );
|
||||
this.block = Optional.ofNullable( block );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<? extends Class<? extends TileEntity>> maybeEntity()
|
||||
{
|
||||
return this.block.transform( AEBaseTileBlock::getTileEntityClass );
|
||||
return this.block.map( AEBaseTileBlock::getTileEntityClass );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,8 +94,8 @@ public final class InscriberRegistry implements IInscriberRegistry
|
|||
|
||||
this.recipes.add( recipe );
|
||||
|
||||
this.optionals.addAll( recipe.getTopOptional().asSet() );
|
||||
this.optionals.addAll( recipe.getBottomOptional().asSet() );
|
||||
recipe.getTopOptional().ifPresent( optionals::add );
|
||||
recipe.getBottomOptional().ifPresent( optionals::add );
|
||||
|
||||
this.inputs.addAll( recipe.getInputs() );
|
||||
}
|
||||
|
|
|
@ -172,9 +172,6 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
|
|||
|
||||
private void addNewAttunement( final IItemDefinition definition, final TunnelType type )
|
||||
{
|
||||
for( final ItemStack definitionStack : definition.maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.addNewAttunement( definitionStack, type );
|
||||
}
|
||||
definition.maybeStack( 1 ).ifPresent( definitionStack -> addNewAttunement( definitionStack, type ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
@ -47,8 +47,8 @@ public class InscriberRecipe implements IInscriberRecipe
|
|||
this.inputs.addAll( inputs );
|
||||
|
||||
this.output = output;
|
||||
this.maybeTop = Optional.fromNullable( top );
|
||||
this.maybeBot = Optional.fromNullable( bot );
|
||||
this.maybeTop = Optional.ofNullable( top );
|
||||
this.maybeBot = Optional.ofNullable( bot );
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public enum Achievements
|
|||
|
||||
Achievements( final int x, final int y, final IItemDefinition which, final AchievementType type )
|
||||
{
|
||||
this.stack = which.maybeStack( 1 ).orNull();
|
||||
this.stack = which.maybeStack( 1 ).orElse( null );
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.UUID;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.UUID;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.UUID;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
|
@ -57,7 +57,7 @@ final class PlayerMapping implements IWorldPlayerMapping
|
|||
{
|
||||
final UUID maybe = this.mappings.get( id );
|
||||
|
||||
return Optional.fromNullable( maybe );
|
||||
return Optional.ofNullable( maybe );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Random;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -49,27 +48,20 @@ public final class BlockChargedQuartzOre extends BlockQuartzOre
|
|||
@Override
|
||||
public Item getItemDropped( final IBlockState state, final Random rand, final int fortune )
|
||||
{
|
||||
for( final Item charged : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeItem().asSet() )
|
||||
{
|
||||
return charged;
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" );
|
||||
return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeItem()
|
||||
.orElseThrow( () -> new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped( final IBlockState state )
|
||||
{
|
||||
for( final ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return crystalStack.getItemDamage();
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" );
|
||||
return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().maybeStack( 1 )
|
||||
.orElseThrow( () -> new MissingDefinition( "Tried to access charged certus quartz crystal, even though they are disabled" ) )
|
||||
.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r )
|
||||
{
|
||||
if( !AEConfig.instance.enableEffects )
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.Random;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -94,12 +93,8 @@ public class BlockQuartzOre extends AEBaseBlock
|
|||
public Item getItemDropped( final IBlockState state, /* is null */
|
||||
final Random rand, final int fortune )
|
||||
{
|
||||
for( final Item crystalItem : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeItem().asSet() )
|
||||
{
|
||||
return crystalItem;
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
|
||||
return AEApi.instance().definitions().materials().certusQuartzCrystal().maybeItem()
|
||||
.orElseThrow( () -> new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,12 +113,9 @@ public class BlockQuartzOre extends AEBaseBlock
|
|||
@Override
|
||||
public int damageDropped( final IBlockState state )
|
||||
{
|
||||
for( final ItemStack crystalStack : AEApi.instance().definitions().materials().certusQuartzCrystal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return crystalStack.getItemDamage();
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" );
|
||||
return AEApi.instance().definitions().materials().certusQuartzCrystal().maybeStack( 1 )
|
||||
.orElseThrow( () -> new MissingDefinition( "Tried to access certus quartz crystal, even though they are disabled" ) )
|
||||
.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -153,12 +153,12 @@ public final class EntityChargedQuartz extends AEBaseEntityItem
|
|||
netherQuartz.setDead();
|
||||
}
|
||||
|
||||
for( final ItemStack fluixCrystalStack : materials.fluixCrystal().maybeStack( 2 ).asSet() )
|
||||
materials.fluixCrystal().maybeStack( 2 ).ifPresent( is ->
|
||||
{
|
||||
final EntityItem entity = new EntityItem( this.worldObj, this.posX, this.posY, this.posZ, fluixCrystalStack );
|
||||
final EntityItem entity = new EntityItem( this.worldObj, this.posX, this.posY, this.posZ, is );
|
||||
|
||||
this.worldObj.spawnEntityInWorld( entity );
|
||||
}
|
||||
} );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public final class EntitySingularity extends AEBaseEntityItem
|
|||
e.setDead();
|
||||
}
|
||||
|
||||
for( final ItemStack singularityStack : materials.qESingularity().maybeStack( 2 ).asSet() )
|
||||
materials.qESingularity().maybeStack( 2 ).ifPresent( singularityStack ->
|
||||
{
|
||||
final NBTTagCompound cmp = Platform.openNbtData( singularityStack );
|
||||
cmp.setLong( "freq", ( new Date() ).getTime() * 100 + ( randTickSeed ) % 100 );
|
||||
|
@ -137,7 +137,7 @@ public final class EntitySingularity extends AEBaseEntityItem
|
|||
|
||||
final EntitySingularity entity = new EntitySingularity( this.worldObj, this.posX, this.posY, this.posZ, singularityStack );
|
||||
this.worldObj.spawnEntityInWorld( entity );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
if( item.stackSize <= 0 )
|
||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
|
@ -90,7 +89,7 @@ public final class EntityTinyTNTPrimed extends EntityTNTPrimed implements IEntit
|
|||
|
||||
if( this.isInWater() && Platform.isServer() ) // put out the fuse.
|
||||
{
|
||||
for( final ItemStack tntStack : AEApi.instance().definitions().blocks().tinyTNT().maybeStack( 1 ).asSet() )
|
||||
AEApi.instance().definitions().blocks().tinyTNT().maybeStack( 1 ).ifPresent( tntStack ->
|
||||
{
|
||||
final EntityItem item = new EntityItem( this.worldObj, this.posX, this.posY, this.posZ, tntStack );
|
||||
|
||||
|
@ -103,7 +102,7 @@ public final class EntityTinyTNTPrimed extends EntityTNTPrimed implements IEntit
|
|||
|
||||
this.worldObj.spawnEntityInWorld( item );
|
||||
this.setDead();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
if( this.getFuse() <= 0 )
|
||||
|
|
|
@ -20,6 +20,7 @@ package appeng.facade;
|
|||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
|
@ -149,9 +150,9 @@ public class FacadeContainer implements IFacadeContainer
|
|||
}
|
||||
else if( !isBC )
|
||||
{
|
||||
for( final Item facadeItem : AEApi.instance().definitions().items().facade().maybeItem().asSet() )
|
||||
{
|
||||
final ItemFacade ifa = (ItemFacade) facadeItem;
|
||||
Optional<Item> maybeFacadeItem = AEApi.instance().definitions().items().facade().maybeItem();
|
||||
if (maybeFacadeItem.isPresent()) {
|
||||
final ItemFacade ifa = (ItemFacade) maybeFacadeItem.get();
|
||||
final ItemStack facade = ifa.createFromIDs( ids );
|
||||
if( facade != null )
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ package appeng.items.misc;
|
|||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -66,16 +67,16 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
|||
@Nullable
|
||||
public static ResolverResult getResolver( final int certus2 )
|
||||
{
|
||||
ResolverResult resolver = null;
|
||||
|
||||
for( ItemStack crystalSeedStack : AEApi.instance().definitions().items().crystalSeed().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
crystalSeedStack.setItemDamage( certus2 );
|
||||
crystalSeedStack = newStyle( crystalSeedStack );
|
||||
resolver = new ResolverResult( "ItemCrystalSeed", crystalSeedStack.getItemDamage(), crystalSeedStack.getTagCompound() );
|
||||
}
|
||||
return AEApi.instance().definitions().items().crystalSeed().maybeStack( 1 )
|
||||
.map( crystalSeedStack ->
|
||||
{
|
||||
crystalSeedStack.setItemDamage( certus2 );
|
||||
crystalSeedStack = newStyle( crystalSeedStack );
|
||||
return new ResolverResult( "ItemCrystalSeed", crystalSeedStack.getItemDamage(), crystalSeedStack.getTagCompound() );
|
||||
} )
|
||||
.orElse( null );
|
||||
|
||||
return resolver;
|
||||
}
|
||||
|
||||
private static ItemStack newStyle( final ItemStack itemStack )
|
||||
|
@ -110,23 +111,26 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
|||
|
||||
if( newDamage == CERTUS + SINGLE_OFFSET )
|
||||
{
|
||||
for( final ItemStack quartzStack : materials.purifiedCertusQuartzCrystal().maybeStack( size ).asSet() )
|
||||
Optional<ItemStack> quartzStack = materials.purifiedCertusQuartzCrystal().maybeStack( size );
|
||||
if( quartzStack.isPresent() )
|
||||
{
|
||||
return quartzStack;
|
||||
return quartzStack.get();
|
||||
}
|
||||
}
|
||||
if( newDamage == NETHER + SINGLE_OFFSET )
|
||||
{
|
||||
for( final ItemStack quartzStack : materials.purifiedNetherQuartzCrystal().maybeStack( size ).asSet() )
|
||||
Optional<ItemStack> quartzStack = materials.purifiedNetherQuartzCrystal().maybeStack( size );
|
||||
if( quartzStack.isPresent() )
|
||||
{
|
||||
return quartzStack;
|
||||
return quartzStack.get();
|
||||
}
|
||||
}
|
||||
if( newDamage == FLUIX + SINGLE_OFFSET )
|
||||
{
|
||||
for( final ItemStack quartzStack : materials.purifiedFluixCrystal().maybeStack( size ).asSet() )
|
||||
Optional<ItemStack> quartzStack = materials.purifiedFluixCrystal().maybeStack( size );
|
||||
if( quartzStack.isPresent() )
|
||||
{
|
||||
return quartzStack;
|
||||
return quartzStack.get();
|
||||
}
|
||||
}
|
||||
if( newDamage > FINAL_STAGE )
|
||||
|
|
|
@ -80,16 +80,16 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
|||
|
||||
final InventoryPlayer inv = player.inventory;
|
||||
|
||||
for( int s = 0; s < player.inventory.getSizeInventory(); s++ )
|
||||
ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.stackSize ).orElse( null );
|
||||
if( is != null )
|
||||
{
|
||||
if( inv.getStackInSlot( s ) == stack )
|
||||
for( int s = 0; s < player.inventory.getSizeInventory(); s++ )
|
||||
{
|
||||
for( final ItemStack blankPattern : AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.stackSize ).asSet() )
|
||||
if( inv.getStackInSlot( s ) == stack )
|
||||
{
|
||||
inv.setInventorySlotContents( s, blankPattern );
|
||||
inv.setInventorySlotContents( s, is );
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,16 +250,14 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
|||
|
||||
public ItemStack createFromIDs( final int[] ids )
|
||||
{
|
||||
for( final ItemStack facadeStack : AEApi.instance().definitions().items().facade().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
final NBTTagCompound facadeTag = new NBTTagCompound();
|
||||
facadeTag.setIntArray( "x", ids.clone() );
|
||||
facadeStack.setTagCompound( facadeTag );
|
||||
ItemStack facadeStack = AEApi.instance().definitions().items().facade().maybeStack( 1 )
|
||||
.orElseThrow( () -> new MissingDefinition( "Tried to create a facade, while facades are being deactivated." ) );
|
||||
|
||||
return facadeStack;
|
||||
}
|
||||
final NBTTagCompound facadeTag = new NBTTagCompound();
|
||||
facadeTag.setIntArray( "x", ids.clone() );
|
||||
facadeStack.setTagCompound( facadeTag );
|
||||
|
||||
throw new MissingDefinition( "Tried to create a facade, while facades are being deactivated." );
|
||||
return facadeStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -259,14 +259,14 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
|
|||
}
|
||||
|
||||
// drop empty storage cell case
|
||||
for( final ItemStack storageCellStack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() )
|
||||
AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is ->
|
||||
{
|
||||
final ItemStack extraA = ia.addItems( storageCellStack );
|
||||
final ItemStack extraA = ia.addItems( is );
|
||||
if( extraA != null )
|
||||
{
|
||||
player.dropItem( extraA, false );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
if( player.inventoryContainer != null )
|
||||
{
|
||||
|
@ -289,12 +289,8 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
|
|||
@Override
|
||||
public ItemStack getContainerItem( final ItemStack itemStack )
|
||||
{
|
||||
for( final ItemStack stack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to use empty storage cells while basic storage cells are defined." );
|
||||
return AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 )
|
||||
.orElseThrow( () -> new MissingDefinition( "Tried to use empty storage cells while basic storage cells are defined." ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -293,10 +293,10 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
|||
final Block whatsThere = w.getBlockState( hitPos ).getBlock();
|
||||
if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) )
|
||||
{
|
||||
for( final Block paintBlock : AEApi.instance().definitions().blocks().paint().maybeBlock().asSet() )
|
||||
AEApi.instance().definitions().blocks().paint().maybeBlock().ifPresent( paintBlock ->
|
||||
{
|
||||
w.setBlockState( hitPos, paintBlock.getDefaultState(), 3 );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
final TileEntity te = w.getTileEntity( hitPos );
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
//import com.google.common.base.Optional;
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//import net.minecraft.entity.EntityLivingBase;
|
||||
//import net.minecraft.item.Item;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
//import com.google.common.base.Optional;
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package appeng.loot;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.storage.loot.LootEntry;
|
||||
import net.minecraft.world.storage.loot.LootEntryItem;
|
||||
import net.minecraft.world.storage.loot.LootPool;
|
||||
|
@ -28,8 +25,47 @@ public class ChestLoot
|
|||
{
|
||||
//TODO 1.9.4 aftermath - All these loot quality, pools and stuff. Figure it out and balance it.
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
event.getTable().addPool( new LootPool( ( ( FluentIterable<LootEntryItem> ) Iterables.transform( materials.certusQuartzCrystal().maybeStack( 1 ).asSet(), ( ItemStack itemstack ) -> new LootEntryItem( itemstack.getItem(), 2, 3, new LootFunction[]{ new SetMetadata(null, new RandomValueRange( itemstack.getItemDamage() ))}, new LootCondition[]{ new RandomChance( 1 ) }, "AE2 Crystal_" + itemstack.getItemDamage() ) ) ).toArray( LootEntryItem.class ), new LootCondition[0], new RandomValueRange( 1, 4 ), new RandomValueRange( 0, 2 ), "AE2 Crystals" ) );
|
||||
event.getTable().addPool( new LootPool( ( ( FluentIterable<LootEntryItem> ) Iterables.transform( materials.certusQuartzDust().maybeStack( 1 ).asSet(), ( ItemStack itemstack ) -> new LootEntryItem( itemstack.getItem(), 2, 3, new LootFunction[]{ new SetMetadata(null, new RandomValueRange( itemstack.getItemDamage() ))}, new LootCondition[]{ new RandomChance( 1 ) }, "AE2 Dust_" + itemstack.getItemDamage() ) ) ).toArray( LootEntryItem.class ), new LootCondition[0], new RandomValueRange( 1, 4 ), new RandomValueRange( 0, 2 ), "AE2 Dusts" ) );
|
||||
materials.certusQuartzCrystal().maybeStack( 1 ).ifPresent( is ->
|
||||
{
|
||||
event.getTable().addPool( new LootPool(
|
||||
new LootEntry[] {
|
||||
new LootEntryItem(
|
||||
is.getItem(),
|
||||
2,
|
||||
3,
|
||||
new LootFunction[] { new SetMetadata( null, new RandomValueRange( is.getItemDamage() ) ) },
|
||||
new LootCondition[] { new RandomChance( 1 ) },
|
||||
"AE2 Crystal_" + is.getItemDamage()
|
||||
)
|
||||
},
|
||||
new LootCondition[0],
|
||||
new RandomValueRange( 1, 4 ),
|
||||
new RandomValueRange( 0, 2 ), "AE2 Crystals"
|
||||
)
|
||||
);
|
||||
} );
|
||||
|
||||
materials.certusQuartzDust().maybeStack( 1 ).ifPresent( is ->
|
||||
{
|
||||
event.getTable().addPool( new LootPool(
|
||||
new LootEntryItem[] {
|
||||
new LootEntryItem(
|
||||
is.getItem(),
|
||||
2,
|
||||
3,
|
||||
new LootFunction[] { new SetMetadata( null, new RandomValueRange( is.getItemDamage() ) ) },
|
||||
new LootCondition[] { new RandomChance( 1 ) },
|
||||
"AE2 Dust_" + is.getItemDamage()
|
||||
)
|
||||
},
|
||||
new LootCondition[0],
|
||||
new RandomValueRange( 1, 4 ),
|
||||
new RandomValueRange( 0, 2 ),
|
||||
"AE2 Dusts"
|
||||
)
|
||||
);
|
||||
} );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package appeng.me.cluster.implementations;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
@ -165,11 +164,6 @@ public class QuantumCalculator extends MBCalculator
|
|||
|
||||
private boolean isBlockAtLocation( final IBlockAccess w, final BlockPos pos, final IBlockDefinition def )
|
||||
{
|
||||
for( final Block block : def.maybeBlock().asSet() )
|
||||
{
|
||||
return block == w.getBlockState( pos ).getBlock();
|
||||
}
|
||||
|
||||
return false;
|
||||
return def.maybeBlock().map( block -> block == w.getBlockState( pos ).getBlock() ).orElse( false );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -479,9 +480,10 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
|||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
if( definitions.parts().iface().isSameAs( is ) )
|
||||
{
|
||||
for( final ItemStack iface : definitions.blocks().iface().maybeStack( 1 ).asSet() )
|
||||
Optional<ItemStack> iface = definitions.blocks().iface().maybeStack( 1 );
|
||||
if( iface.isPresent() )
|
||||
{
|
||||
is = iface;
|
||||
is = iface.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ package appeng.parts;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
|
@ -379,12 +379,11 @@ public class PartPlacement
|
|||
final AEPartLocation mySide = host.addPart( held, AEPartLocation.fromFacing( side ), player, hand );
|
||||
if( mySide != null )
|
||||
{
|
||||
for( final Block multiPartBlock : multiPart.maybeBlock().asSet() )
|
||||
{
|
||||
multiPart.maybeBlock().ifPresent( multiPartBlock -> {
|
||||
final SoundType ss = multiPartBlock.getSoundType();
|
||||
|
||||
world.playSound( player, 0.5 + pos.getX(), 0.5 + pos.getY(), 0.5 + pos.getZ(), ss.getPlaceSound(), SoundCategory.BLOCKS, ( ss.getVolume() + 1.0F ) / 2.0F, ss.getPitch() * 0.8F );
|
||||
}
|
||||
});
|
||||
|
||||
if( !player.capabilities.isCreativeMode )
|
||||
{
|
||||
|
|
|
@ -21,17 +21,13 @@ package appeng.parts.p2p;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
|
@ -216,17 +212,14 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||
}
|
||||
else if( tt != null ) // attunement
|
||||
{
|
||||
ItemStack newType = null;
|
||||
final ItemStack newType;
|
||||
|
||||
final IParts parts = AEApi.instance().definitions().parts();
|
||||
|
||||
switch( tt )
|
||||
{
|
||||
case LIGHT:
|
||||
for( final ItemStack stack : parts.p2PTunnelLight().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
newType = parts.p2PTunnelLight().maybeStack( 1 ).orElse( null );
|
||||
break;
|
||||
|
||||
/*
|
||||
|
@ -239,10 +232,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||
*/
|
||||
|
||||
case FLUID:
|
||||
for( final ItemStack stack : parts.p2PTunnelLiquids().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
newType = parts.p2PTunnelLiquids().maybeStack( 1 ).orElse( null );
|
||||
break;
|
||||
|
||||
/*
|
||||
|
@ -255,24 +245,15 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||
*/
|
||||
|
||||
case ITEM:
|
||||
for( final ItemStack stack : parts.p2PTunnelItems().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
newType = parts.p2PTunnelItems().maybeStack( 1 ).orElse( null );
|
||||
break;
|
||||
|
||||
case ME:
|
||||
for( final ItemStack stack : parts.p2PTunnelME().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
newType = parts.p2PTunnelME().maybeStack( 1 ).orElse( null );
|
||||
break;
|
||||
|
||||
case REDSTONE:
|
||||
for( final ItemStack stack : parts.p2PTunnelRedstone().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
newType = stack;
|
||||
}
|
||||
newType = parts.p2PTunnelRedstone().maybeStack( 1 ).orElse( null );
|
||||
break;
|
||||
|
||||
/*
|
||||
|
@ -291,6 +272,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||
*/
|
||||
|
||||
default:
|
||||
newType = null;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.zip.ZipOutputStream;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
|
|
|
@ -21,12 +21,10 @@ 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 com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -100,8 +98,10 @@ public final class DisassembleRecipe implements IRecipe
|
|||
}
|
||||
|
||||
// handle storage cells
|
||||
for( final ItemStack storageCellStack : this.getCellOutput( stackInSlot ).asSet() )
|
||||
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, StorageChannel.ITEMS );
|
||||
if( cellInv != null )
|
||||
|
@ -117,10 +117,7 @@ public final class DisassembleRecipe implements IRecipe
|
|||
}
|
||||
|
||||
// handle crafting storage blocks
|
||||
for( final ItemStack craftingStorageStack : this.getNonCellOutput( stackInSlot ).asSet() )
|
||||
{
|
||||
output = craftingStorageStack;
|
||||
}
|
||||
output = getNonCellOutput( stackInSlot ).orElse( output );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +135,7 @@ public final class DisassembleRecipe implements IRecipe
|
|||
}
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -152,7 +149,7 @@ public final class DisassembleRecipe implements IRecipe
|
|||
}
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
package appeng.recipes.game;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -63,7 +62,7 @@ public final class FacadeRecipe implements IRecipe
|
|||
{
|
||||
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 ) ) )
|
||||
{
|
||||
for( final Item facadeItemDefinition : this.maybeFacade.asSet() )
|
||||
return this.maybeFacade.map( facadeItemDefinition ->
|
||||
{
|
||||
final ItemFacade facade = (ItemFacade) facadeItemDefinition;
|
||||
|
||||
|
@ -73,7 +72,7 @@ public final class FacadeRecipe implements IRecipe
|
|||
facades.stackSize = 4;
|
||||
}
|
||||
return facades;
|
||||
}
|
||||
} ).orElse( null );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@ package appeng.services;
|
|||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
@ -133,8 +133,10 @@ public final class CompassService
|
|||
// lower level...
|
||||
final Chunk c = w.getChunkFromChunkCoords( cx, cz );
|
||||
|
||||
for( final Block skyStoneBlock : AEApi.instance().definitions().blocks().skyStoneBlock().maybeBlock().asSet() )
|
||||
Optional<Block> maybeBlock = AEApi.instance().definitions().blocks().skyStoneBlock().maybeBlock();
|
||||
if( maybeBlock.isPresent() )
|
||||
{
|
||||
Block skyStoneBlock = maybeBlock.get();
|
||||
for( int i = 0; i < CHUNK_SIZE; i++ )
|
||||
{
|
||||
for( int j = 0; j < CHUNK_SIZE; j++ )
|
||||
|
|
|
@ -403,13 +403,13 @@ public class CachedPlane
|
|||
|
||||
private void setBlockIDWithMetadata( final int y, final Object[] blk )
|
||||
{
|
||||
for( final Block matrixFrameBlock : CachedPlane.this.matrixFrame.maybeBlock().asSet() )
|
||||
CachedPlane.this.matrixFrame.maybeBlock().ifPresent( matrixFrameBlock ->
|
||||
{
|
||||
if( blk[0] == matrixFrameBlock )
|
||||
{
|
||||
blk[0] = Platform.AIR_BLOCK;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
final ExtendedBlockStorage extendedBlockStorage = this.storage[y >> 4];
|
||||
extendedBlockStorage.set( this.x, y & 15, this.z, (IBlockState) blk[0] );
|
||||
|
|
|
@ -42,13 +42,12 @@ public class StorageChunkProvider extends ChunkProviderOverworld
|
|||
{
|
||||
BLOCKS = new Block[255 * SQUARE_CHUNK_SIZE];
|
||||
|
||||
for( final Block matrixFrameBlock : AEApi.instance().definitions().blocks().matrixFrame().maybeBlock().asSet() )
|
||||
{
|
||||
AEApi.instance().definitions().blocks().matrixFrame().maybeBlock().ifPresent( matrixFrameBlock -> {
|
||||
for( int x = 0; x < BLOCKS.length; x++ )
|
||||
{
|
||||
BLOCKS[x] = matrixFrameBlock;
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private final World world;
|
||||
|
|
|
@ -25,8 +25,6 @@ import java.util.List;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityHanging;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -178,10 +176,9 @@ public class StorageHelper
|
|||
, final World dst /** storage cell **/
|
||||
, final int x, final int y, final int z, final int i, final int j, final int k, final int scaleX, final int scaleY, final int scaleZ )
|
||||
{
|
||||
for( final Block matrixFrameBlock : AEApi.instance().definitions().blocks().matrixFrame().maybeBlock().asSet() )
|
||||
{
|
||||
this.transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new WrapInMatrixFrame( matrixFrameBlock.getDefaultState(), dst ) );
|
||||
}
|
||||
AEApi.instance().definitions().blocks().matrixFrame().maybeBlock().ifPresent( matrixFrameBlock ->
|
||||
this.transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new WrapInMatrixFrame( matrixFrameBlock.getDefaultState(), dst ) )
|
||||
);
|
||||
|
||||
final AxisAlignedBB srcBox = new AxisAlignedBB( x, y, z, x + scaleX + 1, y + scaleY + 1, z + scaleZ + 1 );
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class AEBaseTile extends TileEntity implements ITickable, IOrientable, IC
|
|||
|
||||
private static final ThreadLocal<WeakReference<AEBaseTile>> DROP_NO_ITEMS = new ThreadLocal<WeakReference<AEBaseTile>>();
|
||||
private static final Map<Class<? extends AEBaseTile>, Map<TileEventType, List<AETileEventHandler>>> HANDLERS = new HashMap<Class<? extends AEBaseTile>, Map<TileEventType, List<AETileEventHandler>>>();
|
||||
private static final Map<Class<? extends TileEntity>, IStackSrc> ITEM_STACKS = new HashMap<Class<? extends TileEntity>, IStackSrc>();
|
||||
private static final Map<Class<? extends TileEntity>, IStackSrc> ITEM_STACKS = new HashMap<>();
|
||||
private int renderFragment = 0;
|
||||
@Nullable
|
||||
private String customName;
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
package appeng.tile.crafting;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
|
@ -36,29 +38,25 @@ public class TileCraftingStorageTile extends TileCraftingTile
|
|||
final IBlocks blocks = AEApi.instance().definitions().blocks();
|
||||
final int storage = ( (TileCraftingTile) obj ).getStorageBytes() / KILO_SCALAR;
|
||||
|
||||
Optional<ItemStack> is;
|
||||
|
||||
switch( storage )
|
||||
{
|
||||
case 4:
|
||||
for( final ItemStack stack : blocks.craftingStorage4k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
is = blocks.craftingStorage4k().maybeStack( 1 );
|
||||
break;
|
||||
case 16:
|
||||
for( final ItemStack stack : blocks.craftingStorage16k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
is = blocks.craftingStorage16k().maybeStack( 1 );
|
||||
break;
|
||||
case 64:
|
||||
for( final ItemStack stack : blocks.craftingStorage64k().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
is = blocks.craftingStorage64k().maybeStack( 1 );
|
||||
break;
|
||||
default:
|
||||
is = Optional.empty();
|
||||
break;
|
||||
}
|
||||
|
||||
return super.getItemFromTile( obj );
|
||||
return is.orElseGet( () -> super.getItemFromTile( obj ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Collections;
|
|||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -79,15 +80,14 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
|||
@Override
|
||||
protected ItemStack getItemFromTile( final Object obj )
|
||||
{
|
||||
Optional<ItemStack> is = Optional.empty();
|
||||
|
||||
if( ( (TileCraftingTile) obj ).isAccelerator() )
|
||||
{
|
||||
for( final ItemStack accelerator : AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return accelerator;
|
||||
}
|
||||
is = AEApi.instance().definitions().blocks().craftingAccelerator().maybeStack( 1 );
|
||||
}
|
||||
|
||||
return super.getItemFromTile( obj );
|
||||
return is.orElseGet( () -> super.getItemFromTile( obj ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -167,10 +167,8 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, ITick
|
|||
{
|
||||
this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
|
||||
for( final ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
{
|
||||
this.setInventorySlotContents( 0, charged );
|
||||
}
|
||||
materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).ifPresent( charged ->
|
||||
this.setInventorySlotContents( 0, charged ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,10 +207,8 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, ITick
|
|||
{
|
||||
this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
|
||||
for( final ItemStack charged : materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).asSet() )
|
||||
{
|
||||
this.setInventorySlotContents( 0, charged );
|
||||
}
|
||||
materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).ifPresent( charged ->
|
||||
this.setInventorySlotContents( 0, charged ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,21 +144,15 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf
|
|||
switch( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) )
|
||||
{
|
||||
case MATTER_BALLS:
|
||||
for( final ItemStack matterBallStack : materials.matterBall().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return matterBallStack;
|
||||
}
|
||||
return materials.matterBall().maybeStack( 1 ).orElse( null );
|
||||
|
||||
case SINGULARITY:
|
||||
for( final ItemStack singularityStack : materials.singularity().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return singularityStack;
|
||||
}
|
||||
return materials.singularity().maybeStack( 1 ).orElse( null );
|
||||
|
||||
case TRASH:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public double getRequiredPower()
|
||||
|
|
|
@ -399,11 +399,11 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
|||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||
{
|
||||
|
||||
final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateA, recipe.getTopOptional().orNull() ) ) && // and...
|
||||
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateB, recipe.getBottomOptional().orNull() ) );
|
||||
final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateA, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateB, recipe.getBottomOptional().orElse( null ) ) );
|
||||
|
||||
final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateB, recipe.getTopOptional().orNull() ) ) && // and...
|
||||
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateA, recipe.getBottomOptional().orNull() ) );
|
||||
final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.isSameItemPrecise( plateB, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.isSameItemPrecise( plateA, recipe.getBottomOptional().orElse( null ) ) );
|
||||
|
||||
if( matchA || matchB )
|
||||
{
|
||||
|
|
|
@ -20,8 +20,7 @@ package appeng.tile.qnb;
|
|||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
|
@ -143,12 +142,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
|||
|
||||
private boolean isCenter()
|
||||
{
|
||||
for( final Block link : AEApi.instance().definitions().blocks().quantumLink().maybeBlock().asSet() )
|
||||
{
|
||||
return this.getBlockType() == link;
|
||||
}
|
||||
|
||||
return false;
|
||||
return AEApi.instance().definitions().blocks().quantumLink().maybeBlock()
|
||||
.map( link -> getBlockType() == link )
|
||||
.orElse( false );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
|
|
|
@ -22,7 +22,7 @@ package appeng.util;
|
|||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class ClassInstantiation<T>
|
|||
}
|
||||
}
|
||||
|
||||
return Optional.absent();
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private boolean isClassMatch( Class<?> expected, Class<?> got, final Object value )
|
||||
|
|
|
@ -94,10 +94,7 @@ public final class MeteoritePlacer
|
|||
this.validSpawn.add( Blocks.SNOW );
|
||||
this.validSpawn.add( Blocks.STAINED_HARDENED_CLAY );
|
||||
|
||||
for( final Block skyStoneBlock : this.skyStoneDefinition.maybeBlock().asSet() )
|
||||
{
|
||||
this.invalidSpawn.add( skyStoneBlock );
|
||||
}
|
||||
this.skyStoneDefinition.maybeBlock().ifPresent( this.invalidSpawn::add );
|
||||
this.invalidSpawn.add( Blocks.PLANKS );
|
||||
this.invalidSpawn.add( Blocks.IRON_DOOR );
|
||||
this.invalidSpawn.add( Blocks.IRON_BARS );
|
||||
|
@ -216,39 +213,14 @@ public final class MeteoritePlacer
|
|||
|
||||
private void placeMeteorite( final IMeteoriteWorld w, final int x, final int y, final int z )
|
||||
{
|
||||
final int meteorXLength = w.minX( x - 8 );
|
||||
final int meteorXHeight = w.maxX( x + 8 );
|
||||
final int meteorZLength = w.minZ( z - 8 );
|
||||
final int meteorZHeight = w.maxZ( z + 8 );
|
||||
|
||||
|
||||
// spawn meteor
|
||||
for( int i = meteorXLength; i < meteorXHeight; i++ )
|
||||
{
|
||||
for( int j = y - 8; j < y + 8; j++ )
|
||||
{
|
||||
for( int k = meteorZLength; k < meteorZHeight; k++ )
|
||||
{
|
||||
final double dx = i - x;
|
||||
final double dy = j - y;
|
||||
final double dz = k - z;
|
||||
|
||||
if( dx * dx * 0.7 + dy * dy * ( j > y ? 1.4 : 0.8 ) + dz * dz * 0.7 < this.squaredMeteoriteSize )
|
||||
{
|
||||
for( final Block skyStoneBlock : this.skyStoneDefinition.maybeBlock().asSet() )
|
||||
{
|
||||
this.putter.put( w, i, j, k, skyStoneBlock );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.skyStoneDefinition.maybeBlock().ifPresent( block -> placeMeteoriteSkyStone( w, x, y, z, block ) );
|
||||
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.SpawnPressesInMeteorites ) )
|
||||
{
|
||||
for( final Block skyChestBlock : this.skyChestDefinition.maybeBlock().asSet() )
|
||||
{
|
||||
this.putter.put( w, x, y, z, skyChestBlock );
|
||||
}
|
||||
this.skyChestDefinition.maybeBlock().ifPresent( block -> this.putter.put( w, x, y, z, block ) );
|
||||
|
||||
final TileEntity te = w.getTileEntity( x, y, z );
|
||||
if( te instanceof IInventory )
|
||||
|
@ -264,8 +236,8 @@ public final class MeteoritePlacer
|
|||
|
||||
for( int zz = 0; zz < primary; zz++ )
|
||||
{
|
||||
int r = 0;
|
||||
boolean duplicate = false;
|
||||
int r;
|
||||
boolean duplicate;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -286,28 +258,16 @@ public final class MeteoritePlacer
|
|||
switch( r % 4 )
|
||||
{
|
||||
case 0:
|
||||
for( final ItemStack calc : materials.calcProcessorPress().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
toAdd = calc;
|
||||
}
|
||||
toAdd = materials.calcProcessorPress().maybeStack( 1 ).orElse( null );
|
||||
break;
|
||||
case 1:
|
||||
for( final ItemStack calc : materials.engProcessorPress().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
toAdd = calc;
|
||||
}
|
||||
toAdd = materials.engProcessorPress().maybeStack( 1 ).orElse( null );
|
||||
break;
|
||||
case 2:
|
||||
for( final ItemStack calc : materials.logicProcessorPress().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
toAdd = calc;
|
||||
}
|
||||
toAdd = materials.logicProcessorPress().maybeStack( 1 ).orElse( null );
|
||||
break;
|
||||
case 3:
|
||||
for( final ItemStack calc : materials.siliconPress().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
toAdd = calc;
|
||||
}
|
||||
toAdd = materials.siliconPress().maybeStack( 1 ).orElse( null );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
@ -334,10 +294,7 @@ public final class MeteoritePlacer
|
|||
{
|
||||
case 0:
|
||||
final int amount = (int) ( ( Math.random() * SKYSTONE_SPAWN_LIMIT ) + 1 );
|
||||
for( final ItemStack skyStoneStack : this.skyStoneDefinition.maybeStack( amount ).asSet() )
|
||||
{
|
||||
ap.addItems( skyStoneStack );
|
||||
}
|
||||
this.skyStoneDefinition.maybeStack( amount ).ifPresent( ap::addItems );
|
||||
break;
|
||||
case 1:
|
||||
final List<ItemStack> possibles = new LinkedList<ItemStack>();
|
||||
|
@ -366,6 +323,32 @@ public final class MeteoritePlacer
|
|||
}
|
||||
}
|
||||
|
||||
private void placeMeteoriteSkyStone( IMeteoriteWorld w, int x, int y, int z, Block block )
|
||||
{
|
||||
final int meteorXLength = w.minX( x - 8 );
|
||||
final int meteorXHeight = w.maxX( x + 8 );
|
||||
final int meteorZLength = w.minZ( z - 8 );
|
||||
final int meteorZHeight = w.maxZ( z + 8 );
|
||||
|
||||
for( int i = meteorXLength; i < meteorXHeight; i++ )
|
||||
{
|
||||
for( int j = y - 8; j < y + 8; j++ )
|
||||
{
|
||||
for( int k = meteorZLength; k < meteorZHeight; k++ )
|
||||
{
|
||||
final double dx = i - x;
|
||||
final double dy = j - y;
|
||||
final double dz = k - z;
|
||||
|
||||
if( dx * dx * 0.7 + dy * dy * ( j > y ? 1.4 : 0.8 ) + dz * dz * 0.7 < this.squaredMeteoriteSize )
|
||||
{
|
||||
this.putter.put( w, i, j, k, block );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void decay( final IMeteoriteWorld w, final int x, final int y, final int z )
|
||||
{
|
||||
double randomShit = 0;
|
||||
|
|
|
@ -48,8 +48,8 @@ public final class QuartzWorldGen implements IWorldGenerator
|
|||
final IBlockDefinition oreDefinition = blocks.quartzOre();
|
||||
final IBlockDefinition chargedDefinition = blocks.quartzOreCharged();
|
||||
|
||||
final Block ore = oreDefinition.maybeBlock().orNull();
|
||||
final Block charged = chargedDefinition.maybeBlock().orNull();
|
||||
final Block ore = oreDefinition.maybeBlock().orElse( null );
|
||||
final Block charged = chargedDefinition.maybeBlock().orElse( null );
|
||||
|
||||
this.oreNormal = new WorldGenMinable( ore.getDefaultState(), AEConfig.instance.quartzOresPerCluster );
|
||||
this.oreCharged = new WorldGenMinable( charged.getDefaultState(), AEConfig.instance.quartzOresPerCluster );
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
package appeng.worldgen.meteorite;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
|
@ -63,10 +62,7 @@ public class Fallout
|
|||
}
|
||||
else if( a > 0.6 )
|
||||
{
|
||||
for( final Block skyStoneBlock : this.skyStoneDefinition.maybeBlock().asSet() )
|
||||
{
|
||||
this.putter.put( w, x, y, z, skyStoneBlock );
|
||||
}
|
||||
skyStoneDefinition.maybeBlock().ifPresent( block -> this.putter.put( w, x, y, z, block ) );
|
||||
}
|
||||
else if( a > 0.5 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue