Added config for auto crafting of substitutions
Change missing items information to a packet (missing localization stuff yet)
This commit is contained in:
@@ -19,26 +19,7 @@
|
|||||||
package appeng.core;
|
package appeng.core;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import appeng.api.config.*;
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import net.minecraftforge.common.config.Property;
|
|
||||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
|
||||||
import net.minecraftforge.fml.common.ModContainer;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
|
|
||||||
import appeng.api.config.CondenserOutput;
|
|
||||||
import appeng.api.config.PowerMultiplier;
|
|
||||||
import appeng.api.config.PowerUnits;
|
|
||||||
import appeng.api.config.SearchBoxMode;
|
|
||||||
import appeng.api.config.Settings;
|
|
||||||
import appeng.api.config.TerminalStyle;
|
|
||||||
import appeng.api.config.YesNo;
|
|
||||||
import appeng.api.util.IConfigManager;
|
import appeng.api.util.IConfigManager;
|
||||||
import appeng.api.util.IConfigurableObject;
|
import appeng.api.util.IConfigurableObject;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
@@ -47,6 +28,17 @@ import appeng.items.materials.MaterialType;
|
|||||||
import appeng.util.ConfigManager;
|
import appeng.util.ConfigManager;
|
||||||
import appeng.util.IConfigManagerHost;
|
import appeng.util.IConfigManagerHost;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
import net.minecraftforge.common.config.Property;
|
||||||
|
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||||
|
import net.minecraftforge.fml.common.ModContainer;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
||||||
public final class AEConfig extends Configuration implements IConfigurableObject, IConfigManagerHost
|
public final class AEConfig extends Configuration implements IConfigurableObject, IConfigManagerHost
|
||||||
@@ -55,80 +47,33 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||||||
public static final String VERSION = "@version@";
|
public static final String VERSION = "@version@";
|
||||||
public static final String CHANNEL = "@aechannel@";
|
public static final String CHANNEL = "@aechannel@";
|
||||||
public static final String PACKET_CHANNEL = "AE";
|
public static final String PACKET_CHANNEL = "AE";
|
||||||
|
// Tunnels
|
||||||
// Config instance
|
public static final double TUNNEL_POWER_LOSS = 0.05;
|
||||||
private static AEConfig instance;
|
|
||||||
|
|
||||||
// Default Grindstone ores
|
// Default Grindstone ores
|
||||||
private static final String[] ORES_VANILLA = {
|
private static final String[] ORES_VANILLA = {"Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz"};
|
||||||
"Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold",
|
|
||||||
"Charcoal", "NetherQuartz"
|
|
||||||
};
|
|
||||||
private static final String[] ORES_AE = {"CertusQuartz", "Wheat", "Fluix"};
|
private static final String[] ORES_AE = {"CertusQuartz", "Wheat", "Fluix"};
|
||||||
private static final String[] ORES_COMMON = {
|
private static final String[] ORES_COMMON = {"Copper", "Tin", "Silver", "Lead", "Bronze"};
|
||||||
"Copper", "Tin", "Silver", "Lead", "Bronze"
|
private static final String[] ORES_MISC = {"Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum", "Osmium", "Zinc"};
|
||||||
};
|
|
||||||
private static final String[] ORES_MISC = {
|
|
||||||
"Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum",
|
|
||||||
"Osmium", "Zinc"
|
|
||||||
};
|
|
||||||
|
|
||||||
private String[] nonBlockingItems = {
|
|
||||||
"[gregtech|actuallyadditions]", "gregtech:circuit.integrated",
|
|
||||||
"gregtech:shape.mold.plate", "gregtech:shape.mold.gear",
|
|
||||||
"gregtech:shape.mold.credit", "gregtech:shape.mold.bottle",
|
|
||||||
"gregtech:shape.mold.ingot", "gregtech:shape.mold.ball",
|
|
||||||
"gregtech:shape.mold.block", "gregtech:shape.mold.nugget",
|
|
||||||
"gregtech:shape.mold.cylinder", "gregtech:shape.mold.anvil",
|
|
||||||
"gregtech:shape.mold.name", "gregtech:shape.mold.gear.small",
|
|
||||||
"gregtech:shape.mold.rotor", "gregtech:shape.extruder.plate",
|
|
||||||
"gregtech:shape.extruder.rod", "gregtech:shape.extruder.bolt",
|
|
||||||
"gregtech:shape.extruder.ring", "gregtech:shape.extruder.cell",
|
|
||||||
"gregtech:shape.extruder.ingot", "gregtech:shape.extruder.wire",
|
|
||||||
"gregtech:shape.extruder.pipe.tiny",
|
|
||||||
"gregtech:shape.extruder.pipe.small",
|
|
||||||
"gregtech:shape.extruder.pipe.medium",
|
|
||||||
"gregtech:shape.extruder.pipe.normal",
|
|
||||||
"gregtech:shape.extruder.pipe.large",
|
|
||||||
"gregtech:shape.extruder.pipe.huge",
|
|
||||||
"gregtech:shape.extruder.block", "gregtech:shape.extruder.sword",
|
|
||||||
"gregtech:shape.extruder.pickaxe", "gregtech:shape.extruder.shovel",
|
|
||||||
"gregtech:shape.extruder.axe", "gregtech:shape.extruder.hoe",
|
|
||||||
"gregtech:shape.extruder.hammer", "gregtech:shape.extruder.file",
|
|
||||||
"gregtech:shape.extruder.saw", "gregtech:shape.extruder.gear",
|
|
||||||
"gregtech:shape.extruder.bottle", "gregtech:shape.extruder.foil",
|
|
||||||
"gregtech:shape.extruder.gear_small",
|
|
||||||
"gregtech:shape.extruder.rod_long", "gregtech:shape.extruder.rotor",
|
|
||||||
"gregtech:glass_lens.white", "gregtech:glass_lens.orange",
|
|
||||||
"gregtech:glass_lens.magenta", "gregtech:glass_lens.light_blue",
|
|
||||||
"gregtech:glass_lens.yellow", "gregtech:glass_lens.lime",
|
|
||||||
"gregtech:glass_lens.pink", "gregtech:glass_lens.gray",
|
|
||||||
"gregtech:glass_lens.light_gray", "gregtech:glass_lens.cyan",
|
|
||||||
"gregtech:glass_lens.purple", "gregtech:glass_lens.blue",
|
|
||||||
"gregtech:glass_lens.brown", "gregtech:glass_lens.green",
|
|
||||||
"gregtech:glass_lens.red", "gregtech:glass_lens.black",
|
|
||||||
"contenttweaker:smallgearextrudershape",
|
|
||||||
"contenttweaker:creativeportabletankmold", "ore:lensAlmandine",
|
|
||||||
"ore:lensBlueTopaz", "ore:lensDiamond", "ore:lensEmerald",
|
|
||||||
"ore:lensGreenSapphire", "ore:lensRutile", "ore:lensRuby",
|
|
||||||
"ore:lensSapphire", "ore:lensTopaz", "ore:lensJasper",
|
|
||||||
"ore:lensGlass", "ore:lensOlivine", "ore:lensOpal",
|
|
||||||
"ore:lensAmethyst", "ore:lensLapis", "ore:lensEnderPearl",
|
|
||||||
"ore:lensEnderEye", "ore:lensGarnetRed", "ore:lensGarnetYellow",
|
|
||||||
"ore:lensVinteum", "ore:lensNetherStar",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Default Energy Conversion Rates
|
// Default Energy Conversion Rates
|
||||||
private static final double DEFAULT_IC2_EXCHANGE = 2.0;
|
private static final double DEFAULT_IC2_EXCHANGE = 2.0;
|
||||||
private static final double DEFAULT_GTEU_EXCHANGE = 2.0;
|
private static final double DEFAULT_GTEU_EXCHANGE = 2.0;
|
||||||
private static final double DEFAULT_RF_EXCHANGE = 0.5;
|
private static final double DEFAULT_RF_EXCHANGE = 0.5;
|
||||||
|
// Config instance
|
||||||
|
private static AEConfig instance;
|
||||||
private final IConfigManager settings = new ConfigManager( this );
|
private final IConfigManager settings = new ConfigManager( this );
|
||||||
|
|
||||||
private final EnumSet<AEFeature> featureFlags = EnumSet.noneOf( AEFeature.class );
|
private final EnumSet<AEFeature> featureFlags = EnumSet.noneOf( AEFeature.class );
|
||||||
private final File configFile;
|
private final File configFile;
|
||||||
|
// GUI Buttons
|
||||||
|
private final int[] craftByStacks = {1, 10, 100, 1000};
|
||||||
|
private final int[] priorityByStacks = {1, 10, 100, 1000};
|
||||||
|
private final int[] levelByStacks = {1, 10, 100, 1000};
|
||||||
|
private final int[] levelByMillibuckets = {10, 100, 1000, 10000};
|
||||||
|
private final Set<String> grinderBlackList;
|
||||||
|
private final int chargedChange = 4;
|
||||||
|
private final double wirelessHighWirelessCount = 64;
|
||||||
|
private String[] nonBlockingItems = {"[gregtech|actuallyadditions]", "gregtech:circuit.integrated", "gregtech:shape.mold.plate", "gregtech:shape.mold.gear", "gregtech:shape.mold.credit", "gregtech:shape.mold.bottle", "gregtech:shape.mold.ingot", "gregtech:shape.mold.ball", "gregtech:shape.mold.block", "gregtech:shape.mold.nugget", "gregtech:shape.mold.cylinder", "gregtech:shape.mold.anvil", "gregtech:shape.mold.name", "gregtech:shape.mold.gear.small", "gregtech:shape.mold.rotor", "gregtech:shape.extruder.plate", "gregtech:shape.extruder.rod", "gregtech:shape.extruder.bolt", "gregtech:shape.extruder.ring", "gregtech:shape.extruder.cell", "gregtech:shape.extruder.ingot", "gregtech:shape.extruder.wire", "gregtech:shape.extruder.pipe.tiny", "gregtech:shape.extruder.pipe.small", "gregtech:shape.extruder.pipe.medium", "gregtech:shape.extruder.pipe.normal", "gregtech:shape.extruder.pipe.large", "gregtech:shape.extruder.pipe.huge", "gregtech:shape.extruder.block", "gregtech:shape.extruder.sword", "gregtech:shape.extruder.pickaxe", "gregtech:shape.extruder.shovel", "gregtech:shape.extruder.axe", "gregtech:shape.extruder.hoe", "gregtech:shape.extruder.hammer", "gregtech:shape.extruder.file", "gregtech:shape.extruder.saw", "gregtech:shape.extruder.gear", "gregtech:shape.extruder.bottle", "gregtech:shape.extruder.foil", "gregtech:shape.extruder.gear_small", "gregtech:shape.extruder.rod_long", "gregtech:shape.extruder.rotor", "gregtech:glass_lens.white", "gregtech:glass_lens.orange", "gregtech:glass_lens.magenta", "gregtech:glass_lens.light_blue", "gregtech:glass_lens.yellow", "gregtech:glass_lens.lime", "gregtech:glass_lens.pink", "gregtech:glass_lens.gray", "gregtech:glass_lens.light_gray", "gregtech:glass_lens.cyan", "gregtech:glass_lens.purple", "gregtech:glass_lens.blue", "gregtech:glass_lens.brown", "gregtech:glass_lens.green", "gregtech:glass_lens.red", "gregtech:glass_lens.black", "contenttweaker:smallgearextrudershape", "contenttweaker:creativeportabletankmold", "ore:lensAlmandine", "ore:lensBlueTopaz", "ore:lensDiamond", "ore:lensEmerald", "ore:lensGreenSapphire", "ore:lensRutile", "ore:lensRuby", "ore:lensSapphire", "ore:lensTopaz", "ore:lensJasper", "ore:lensGlass", "ore:lensOlivine", "ore:lensOpal", "ore:lensAmethyst", "ore:lensLapis", "ore:lensEnderPearl", "ore:lensEnderEye", "ore:lensGarnetRed", "ore:lensGarnetYellow", "ore:lensVinteum", "ore:lensNetherStar",};
|
||||||
private boolean updatable = false;
|
private boolean updatable = false;
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
private boolean removeCrashingItemsOnLoad = false;
|
private boolean removeCrashingItemsOnLoad = false;
|
||||||
private int formationPlaneEntityLimit = 128;
|
private int formationPlaneEntityLimit = 128;
|
||||||
@@ -138,24 +83,14 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||||||
private boolean disableColoredCableRecipesInJEI = true;
|
private boolean disableColoredCableRecipesInJEI = true;
|
||||||
private int craftingCalculationTimePerTick = 5;
|
private int craftingCalculationTimePerTick = 5;
|
||||||
private PowerUnits selectedPowerUnit = PowerUnits.AE;
|
private PowerUnits selectedPowerUnit = PowerUnits.AE;
|
||||||
|
|
||||||
// GUI Buttons
|
|
||||||
private final int[] craftByStacks = {1, 10, 100, 1000};
|
|
||||||
private final int[] priorityByStacks = {1, 10, 100, 1000};
|
|
||||||
private final int[] levelByStacks = {1, 10, 100, 1000};
|
|
||||||
private final int[] levelByMillibuckets = {10, 100, 1000, 10000};
|
|
||||||
|
|
||||||
// Spatial IO/Dimension
|
// Spatial IO/Dimension
|
||||||
private int storageProviderID = -1;
|
private int storageProviderID = -1;
|
||||||
private int storageDimensionID = -1;
|
private int storageDimensionID = -1;
|
||||||
private double spatialPowerExponent = 1.35;
|
private double spatialPowerExponent = 1.35;
|
||||||
private double spatialPowerMultiplier = 1250.0;
|
private double spatialPowerMultiplier = 1250.0;
|
||||||
|
|
||||||
// Grindstone
|
// Grindstone
|
||||||
private String[] grinderOres = Stream.of( ORES_VANILLA, ORES_AE, ORES_COMMON, ORES_MISC ).flatMap( Stream::of ).toArray( String[]::new );
|
private String[] grinderOres = Stream.of( ORES_VANILLA, ORES_AE, ORES_COMMON, ORES_MISC ).flatMap( Stream::of ).toArray( String[]::new );
|
||||||
private Set<String> grinderBlackList;
|
|
||||||
private double oreDoublePercentage = 90.0;
|
private double oreDoublePercentage = 90.0;
|
||||||
|
|
||||||
// Batteries
|
// Batteries
|
||||||
private int wirelessTerminalBattery = 1600000;
|
private int wirelessTerminalBattery = 1600000;
|
||||||
private int entropyManipulatorBattery = 200000;
|
private int entropyManipulatorBattery = 200000;
|
||||||
@@ -163,20 +98,16 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||||||
private int portableCellBattery = 20000;
|
private int portableCellBattery = 20000;
|
||||||
private int colorApplicatorBattery = 20000;
|
private int colorApplicatorBattery = 20000;
|
||||||
private int chargedStaffBattery = 8000;
|
private int chargedStaffBattery = 8000;
|
||||||
|
|
||||||
// Certus quartz
|
// Certus quartz
|
||||||
private float spawnChargedChance = 0.92f;
|
private float spawnChargedChance = 0.92f;
|
||||||
private int quartzOresPerCluster = 4;
|
private int quartzOresPerCluster = 4;
|
||||||
private int quartzOresClusterAmount = 15;
|
private int quartzOresClusterAmount = 15;
|
||||||
private int chargedChange = 4;
|
|
||||||
|
|
||||||
// Meteors
|
// Meteors
|
||||||
private int minMeteoriteDistance = 707;
|
private int minMeteoriteDistance = 707;
|
||||||
private int minMeteoriteDistanceSq = this.minMeteoriteDistance * this.minMeteoriteDistance;
|
private int minMeteoriteDistanceSq = this.minMeteoriteDistance * this.minMeteoriteDistance;
|
||||||
private double meteoriteClusterChance = 0.1;
|
private double meteoriteClusterChance = 0.1;
|
||||||
private int meteoriteMaximumSpawnHeight = 180;
|
private int meteoriteMaximumSpawnHeight = 180;
|
||||||
private int[] meteoriteDimensionWhitelist = {0};
|
private int[] meteoriteDimensionWhitelist = {0};
|
||||||
|
|
||||||
// Wireless
|
// Wireless
|
||||||
private double wirelessBaseCost = 8;
|
private double wirelessBaseCost = 8;
|
||||||
private double wirelessCostMultiplier = 1;
|
private double wirelessCostMultiplier = 1;
|
||||||
@@ -184,10 +115,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||||||
private double wirelessBaseRange = 16;
|
private double wirelessBaseRange = 16;
|
||||||
private double wirelessBoosterRangeMultiplier = 1;
|
private double wirelessBoosterRangeMultiplier = 1;
|
||||||
private double wirelessBoosterExp = 1.5;
|
private double wirelessBoosterExp = 1.5;
|
||||||
private double wirelessHighWirelessCount = 64;
|
// Autocrafting
|
||||||
|
private boolean enableCraftingSubstitutes = false;
|
||||||
// Tunnels
|
|
||||||
public static final double TUNNEL_POWER_LOSS = 0.05;
|
|
||||||
|
|
||||||
private AEConfig( final File configFile )
|
private AEConfig( final File configFile )
|
||||||
{
|
{
|
||||||
@@ -249,6 +178,9 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||||||
this.colorApplicatorBattery = this.get( "battery", "colorApplicator", this.colorApplicatorBattery ).getInt( this.colorApplicatorBattery );
|
this.colorApplicatorBattery = this.get( "battery", "colorApplicator", this.colorApplicatorBattery ).getInt( this.colorApplicatorBattery );
|
||||||
this.matterCannonBattery = this.get( "battery", "matterCannon", this.matterCannonBattery ).getInt( this.matterCannonBattery );
|
this.matterCannonBattery = this.get( "battery", "matterCannon", this.matterCannonBattery ).getInt( this.matterCannonBattery );
|
||||||
|
|
||||||
|
this.addCustomCategoryComment( "autocrafting", "Enable patterns with substitutions on to have their substitutes to be auto craftable.\nThis changes the crafting tree, and can show missing ingredients for the substitute, instead of the patterned item" );
|
||||||
|
this.enableCraftingSubstitutes = this.get( "autocrafting", "EnableAutocraftinSubstitutes", this.enableCraftingSubstitutes ).getBoolean( this.enableCraftingSubstitutes );
|
||||||
|
|
||||||
this.clientSync();
|
this.clientSync();
|
||||||
|
|
||||||
this.addCustomCategoryComment( "features", "Warning: Disabling a feature may disable other features depending on it." );
|
this.addCustomCategoryComment( "features", "Warning: Disabling a feature may disable other features depending on it." );
|
||||||
@@ -670,11 +602,21 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||||||
return this.storageProviderID;
|
return this.storageProviderID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setStorageProviderID( int id )
|
||||||
|
{
|
||||||
|
this.storageProviderID = id;
|
||||||
|
}
|
||||||
|
|
||||||
public int getStorageDimensionID()
|
public int getStorageDimensionID()
|
||||||
{
|
{
|
||||||
return this.storageDimensionID;
|
return this.storageDimensionID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setStorageDimensionID( int id )
|
||||||
|
{
|
||||||
|
this.storageDimensionID = id;
|
||||||
|
}
|
||||||
|
|
||||||
public double getSpatialPowerExponent()
|
public double getSpatialPowerExponent()
|
||||||
{
|
{
|
||||||
return this.spatialPowerExponent;
|
return this.spatialPowerExponent;
|
||||||
@@ -810,20 +752,15 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
|||||||
return this.wirelessBoosterExp;
|
return this.wirelessBoosterExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setters keep visibility as low as possible.
|
||||||
|
|
||||||
public double getWirelessHighWirelessCount()
|
public double getWirelessHighWirelessCount()
|
||||||
{
|
{
|
||||||
return this.wirelessHighWirelessCount;
|
return this.wirelessHighWirelessCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setters keep visibility as low as possible.
|
public boolean getEnableCraftingSubstitutes()
|
||||||
|
|
||||||
void setStorageProviderID( int id )
|
|
||||||
{
|
{
|
||||||
this.storageProviderID = id;
|
return this.enableCraftingSubstitutes;
|
||||||
}
|
|
||||||
|
|
||||||
void setStorageDimensionID( int id )
|
|
||||||
{
|
|
||||||
this.storageDimensionID = id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,34 +21,23 @@ public class PacketInformPlayer extends AppEngPacket
|
|||||||
public PacketInformPlayer( ByteBuf stream ) throws IOException
|
public PacketInformPlayer( ByteBuf stream ) throws IOException
|
||||||
{
|
{
|
||||||
this.type = InfoType.values()[stream.readInt()];
|
this.type = InfoType.values()[stream.readInt()];
|
||||||
if( type == InfoType.PARTIAL_ITEM_EXTRACTION )
|
switch ( type )
|
||||||
{
|
{
|
||||||
this.reportedItem = AEItemStack.fromPacket( stream );
|
case PARTIAL_ITEM_EXTRACTION:
|
||||||
this.actualItem = AEItemStack.fromPacket( stream );
|
this.reportedItem = AEItemStack.fromPacket( stream );
|
||||||
}
|
this.actualItem = AEItemStack.fromPacket( stream );
|
||||||
else if( type == InfoType.NO_ITEMS_EXTRACTED )
|
break;
|
||||||
{
|
case NO_ITEMS_EXTRACTED:
|
||||||
this.reportedItem = AEItemStack.fromPacket( stream );
|
this.reportedItem = AEItemStack.fromPacket( stream );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketInformPlayer( final IAEItemStack iaeItemStack ) throws IOException
|
public PacketInformPlayer( IAEItemStack extra, IAEItemStack result, InfoType type ) throws IOException
|
||||||
{
|
|
||||||
this( iaeItemStack, null );
|
|
||||||
}
|
|
||||||
|
|
||||||
public PacketInformPlayer( IAEItemStack extra, IAEItemStack result ) throws IOException
|
|
||||||
{
|
{
|
||||||
this.reportedItem = extra;
|
this.reportedItem = extra;
|
||||||
this.actualItem = result;
|
this.actualItem = result;
|
||||||
if( actualItem == null )
|
this.type = type;
|
||||||
{
|
|
||||||
this.type = InfoType.NO_ITEMS_EXTRACTED;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.type = InfoType.PARTIAL_ITEM_EXTRACTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ByteBuf data = Unpooled.buffer();
|
final ByteBuf data = Unpooled.buffer();
|
||||||
|
|
||||||
@@ -78,12 +67,10 @@ public class PacketInformPlayer extends AppEngPacket
|
|||||||
{
|
{
|
||||||
AppEng.proxy.getPlayers().get( 0 ).sendStatusMessage( new TextComponentString( "System reported " + reportedItem.getStackSize() + " " + reportedItem.getItem().getItemStackDisplayName( reportedItem.getDefinition() ) + " available but could not extract anything" ), false );
|
AppEng.proxy.getPlayers().get( 0 ).sendStatusMessage( new TextComponentString( "System reported " + reportedItem.getStackSize() + " " + reportedItem.getItem().getItemStackDisplayName( reportedItem.getDefinition() ) + " available but could not extract anything" ), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum InfoType
|
public enum InfoType
|
||||||
{
|
{
|
||||||
PARTIAL_ITEM_EXTRACTION,
|
PARTIAL_ITEM_EXTRACTION, NO_ITEMS_EXTRACTED
|
||||||
NO_ITEMS_EXTRACTED
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,16 +19,6 @@
|
|||||||
package appeng.crafting;
|
package appeng.crafting;
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import appeng.me.cache.GridStorageCache;
|
|
||||||
import com.google.common.base.Stopwatch;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.networking.IGrid;
|
import appeng.api.networking.IGrid;
|
||||||
@@ -47,6 +37,13 @@ import appeng.api.storage.data.IItemList;
|
|||||||
import appeng.api.util.DimensionalCoord;
|
import appeng.api.util.DimensionalCoord;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.hooks.TickHandler;
|
import appeng.hooks.TickHandler;
|
||||||
|
import appeng.me.cache.GridStorageCache;
|
||||||
|
import com.google.common.base.Stopwatch;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
public class CraftingJob implements Runnable, ICraftingJob
|
public class CraftingJob implements Runnable, ICraftingJob
|
||||||
|
|||||||
@@ -19,17 +19,9 @@
|
|||||||
package appeng.crafting;
|
package appeng.crafting;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import appeng.api.config.FuzzyMode;
|
|
||||||
import appeng.util.Platform;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
|
import appeng.api.config.FuzzyMode;
|
||||||
import appeng.api.networking.crafting.ICraftingGrid;
|
import appeng.api.networking.crafting.ICraftingGrid;
|
||||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
import appeng.api.networking.security.IActionSource;
|
import appeng.api.networking.security.IActionSource;
|
||||||
@@ -41,7 +33,6 @@ import appeng.core.sync.packets.PacketInformPlayer;
|
|||||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.common.Optional;
|
import net.minecraftforge.fml.common.Optional;
|
||||||
|
|
||||||
@@ -132,32 +123,37 @@ public class CraftingTreeNode
|
|||||||
{
|
{
|
||||||
Collection<IAEItemStack> itemList = new ArrayList<>();
|
Collection<IAEItemStack> itemList = new ArrayList<>();
|
||||||
|
|
||||||
if( this.what.getItem().isDamageable() || Platform.isGTDamageableItem( this.what.getItem() ) )
|
boolean damageableItem = this.what.getItem().isDamageable() || Platform.isGTDamageableItem( this.what.getItem() );
|
||||||
{
|
|
||||||
itemList.addAll( inventoryList.findFuzzy( this.what, FuzzyMode.IGNORE_ALL ) );
|
|
||||||
|
|
||||||
if( this.parent.details.canSubstitute() )
|
if( this.parent.details.canSubstitute() )
|
||||||
|
{
|
||||||
|
for( IAEItemStack subs : this.parent.details.getSubstituteInputs( this.slot ) )
|
||||||
{
|
{
|
||||||
for( IAEItemStack is : inventoryList )
|
if( damageableItem )
|
||||||
{
|
{
|
||||||
if( is.fuzzyComparison( this.what, FuzzyMode.IGNORE_ALL ) )
|
itemList.addAll( inventoryList.findFuzzy( subs, FuzzyMode.IGNORE_ALL ) );
|
||||||
{
|
}
|
||||||
itemList.add( is );
|
subs = inventoryList.findPrecise( subs );
|
||||||
}
|
if( subs != null )
|
||||||
|
{
|
||||||
|
itemList.add( subs );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final IAEItemStack item = inventoryList.findPrecise( this.what );
|
if( damageableItem )
|
||||||
if( item != null )
|
|
||||||
{
|
|
||||||
itemList.add( item );
|
|
||||||
}
|
|
||||||
if( this.parent.details.canSubstitute() )
|
|
||||||
{
|
{
|
||||||
itemList.addAll( inventoryList.findFuzzy( this.what, FuzzyMode.IGNORE_ALL ) );
|
itemList.addAll( inventoryList.findFuzzy( this.what, FuzzyMode.IGNORE_ALL ) );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final IAEItemStack item = inventoryList.findPrecise( this.what );
|
||||||
|
if( item != null )
|
||||||
|
{
|
||||||
|
itemList.add( item );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( IAEItemStack fuzz : itemList )
|
for( IAEItemStack fuzz : itemList )
|
||||||
@@ -374,11 +370,11 @@ public class CraftingTreeNode
|
|||||||
{
|
{
|
||||||
if( ex == null )
|
if( ex == null )
|
||||||
{
|
{
|
||||||
NetworkHandler.instance().sendTo( new PacketInformPlayer( i ), (EntityPlayerMP) src.player().get() );
|
NetworkHandler.instance().sendTo( new PacketInformPlayer( i, null, PacketInformPlayer.InfoType.NO_ITEMS_EXTRACTED ), (EntityPlayerMP) src.player().get() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NetworkHandler.instance().sendTo( new PacketInformPlayer( ex, i ), (EntityPlayerMP) src.player().get() );
|
NetworkHandler.instance().sendTo( new PacketInformPlayer( ex, i, PacketInformPlayer.InfoType.PARTIAL_ITEM_EXTRACTION ), (EntityPlayerMP) src.player().get() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IOException e )
|
catch( IOException e )
|
||||||
|
|||||||
@@ -19,25 +19,24 @@
|
|||||||
package appeng.crafting;
|
package appeng.crafting;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import appeng.api.config.FuzzyMode;
|
|
||||||
import appeng.util.item.AEItemStack;
|
|
||||||
import com.google.common.collect.ImmutableCollection;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2LongArrayMap;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.networking.crafting.ICraftingGrid;
|
import appeng.api.networking.crafting.ICraftingGrid;
|
||||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||||
import appeng.api.networking.security.IActionSource;
|
import appeng.api.networking.security.IActionSource;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
|
import appeng.core.AEConfig;
|
||||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
import appeng.util.item.AEItemStack;
|
||||||
|
import com.google.common.collect.ImmutableCollection;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2LongArrayMap;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
|
||||||
public class CraftingTreeProcess
|
public class CraftingTreeProcess
|
||||||
@@ -92,12 +91,13 @@ public class CraftingTreeProcess
|
|||||||
}
|
}
|
||||||
|
|
||||||
long wantedSize = part.getStackSize();
|
long wantedSize = part.getStackSize();
|
||||||
IAEItemStack found;
|
|
||||||
long remaining = 0;
|
|
||||||
long requestAmount = 0;
|
|
||||||
|
|
||||||
if( wantedSize > 0 )
|
if( AEConfig.instance().getEnableCraftingSubstitutes() )
|
||||||
{
|
{
|
||||||
|
IAEItemStack found;
|
||||||
|
long remaining;
|
||||||
|
long requestAmount;
|
||||||
|
|
||||||
if( details.canSubstitute() )
|
if( details.canSubstitute() )
|
||||||
{
|
{
|
||||||
for( IAEItemStack subs : details.getSubstituteInputs( x ) )
|
for( IAEItemStack subs : details.getSubstituteInputs( x ) )
|
||||||
@@ -110,7 +110,7 @@ public class CraftingTreeProcess
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
remaining = 0;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( remaining > 0 )
|
if( remaining > 0 )
|
||||||
@@ -127,7 +127,8 @@ public class CraftingTreeProcess
|
|||||||
wantedSize -= remaining;
|
wantedSize -= remaining;
|
||||||
}
|
}
|
||||||
subs = subs.copy().setStackSize( requestAmount );
|
subs = subs.copy().setStackSize( requestAmount );
|
||||||
this.nodes.put( new CraftingTreeNode( cc, job, subs, this, x, depth + 1 ), requestAmount );
|
CraftingTreeNode node = new CraftingTreeNode( cc, job, subs, this, x, depth + 1 );
|
||||||
|
this.nodes.put( node, requestAmount );
|
||||||
if( wantedSize == 0 )
|
if( wantedSize == 0 )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -143,6 +144,10 @@ public class CraftingTreeProcess
|
|||||||
{
|
{
|
||||||
remaining = found.getStackSize();
|
remaining = found.getStackSize();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if( remaining > 0 )
|
if( remaining > 0 )
|
||||||
{
|
{
|
||||||
@@ -161,61 +166,47 @@ public class CraftingTreeProcess
|
|||||||
this.nodes.put( new CraftingTreeNode( cc, job, part, this, x, depth + 1 ), requestAmount );
|
this.nodes.put( new CraftingTreeNode( cc, job, part, this, x, depth + 1 ), requestAmount );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if( wantedSize > 0 )
|
||||||
if( wantedSize > 0 )
|
|
||||||
{
|
|
||||||
if( details.canSubstitute() && cc.getCraftingFor( part, details, x, world ).isEmpty() )
|
|
||||||
{
|
{
|
||||||
for( IAEItemStack subs : details.getSubstituteInputs( x ) )
|
if( details.canSubstitute() && cc.getCraftingFor( part, details, x, world ).isEmpty() )
|
||||||
{
|
{
|
||||||
if( subs.fuzzyComparison( part, FuzzyMode.IGNORE_ALL ) )
|
//try to order the crafting of a substitute
|
||||||
|
ICraftingPatternDetails prioritizedPattern = null;
|
||||||
|
IAEItemStack prioritizedIAE = null;
|
||||||
|
for( IAEItemStack subs : details.getSubstituteInputs( x ) )
|
||||||
{
|
{
|
||||||
wantedSize -= 1;
|
ImmutableCollection<ICraftingPatternDetails> detailCollection = cc.getCraftingFor( subs, details, x, world );
|
||||||
this.nodes.put( new CraftingTreeNode( cc, job, subs.copy().setStackSize( 1 ), this, x, depth + 1 ), 1 );
|
|
||||||
if( wantedSize == 0 )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//try to order the crafting of a substitute
|
|
||||||
ICraftingPatternDetails prioritizedPattern = null;
|
|
||||||
IAEItemStack prioritizedIAE = null;
|
|
||||||
for( IAEItemStack subs : details.getSubstituteInputs( x ) )
|
|
||||||
{
|
|
||||||
if( subs.equals( part ) )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ImmutableCollection<ICraftingPatternDetails> detailCollection = cc.getCraftingFor( subs, details, x, world );
|
|
||||||
|
|
||||||
for( ICraftingPatternDetails sp : detailCollection )
|
for( ICraftingPatternDetails sp : detailCollection )
|
||||||
{
|
|
||||||
if( prioritizedPattern == null )
|
|
||||||
{
|
{
|
||||||
prioritizedPattern = sp;
|
if( prioritizedPattern == null )
|
||||||
prioritizedIAE = subs;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( sp.getPriority() > prioritizedPattern.getPriority() )
|
|
||||||
{
|
{
|
||||||
prioritizedPattern = sp;
|
prioritizedPattern = sp;
|
||||||
|
prioritizedIAE = subs;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( sp.getPriority() > prioritizedPattern.getPriority() )
|
||||||
|
{
|
||||||
|
prioritizedPattern = sp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if( prioritizedIAE != null )
|
||||||
if( prioritizedIAE != null )
|
{
|
||||||
{
|
subs = subs.copy().setStackSize( wantedSize );
|
||||||
this.nodes.put( new CraftingTreeNode( cc, job, prioritizedIAE.copy(), this, x, depth + 1 ), wantedSize );
|
CraftingTreeNode node = new CraftingTreeNode( cc, job, subs, this, x, depth + 1 );
|
||||||
wantedSize = 0;
|
this.nodes.put( node, wantedSize );
|
||||||
break;
|
wantedSize = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( wantedSize > 0 )
|
if( wantedSize > 0 )
|
||||||
{
|
{
|
||||||
part = part.copy();
|
part = part.copy().setStackSize( wantedSize );
|
||||||
// use the first slot...
|
// use the first slot...
|
||||||
this.nodes.put( new CraftingTreeNode( cc, job, part, this, x, depth + 1 ), wantedSize );
|
this.nodes.put( new CraftingTreeNode( cc, job, part, this, x, depth + 1 ), wantedSize );
|
||||||
wantedSize = 0;
|
wantedSize = 0;
|
||||||
|
|||||||
@@ -318,11 +318,11 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||||||
{
|
{
|
||||||
if( result == null )
|
if( result == null )
|
||||||
{
|
{
|
||||||
NetworkHandler.instance().sendTo( new PacketInformPlayer( extra ), (EntityPlayerMP) src.player().get() );
|
NetworkHandler.instance().sendTo( new PacketInformPlayer( extra, null, PacketInformPlayer.InfoType.NO_ITEMS_EXTRACTED ), (EntityPlayerMP) src.player().get() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NetworkHandler.instance().sendTo( new PacketInformPlayer( extra, result ), (EntityPlayerMP) src.player().get() );
|
NetworkHandler.instance().sendTo( new PacketInformPlayer( extra, result, PacketInformPlayer.InfoType.PARTIAL_ITEM_EXTRACTION ), (EntityPlayerMP) src.player().get() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IOException e )
|
catch( IOException e )
|
||||||
|
|||||||
Reference in New Issue
Block a user