Compare commits

..

1 Commits

Author SHA1 Message Date
PrototypeTrousers 9fc96295a8 0 2022-01-14 15:02:30 -03:00
53 changed files with 859 additions and 2005 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
version = aeversion + "-" + aechannel + "-" + aebuild + "-" + extended + "-" + extendedversion
version = trousers + "-" + aeversion + "-" + aechannel + "-" + aebuild + "-" + trousersversion
group = aegroup
archivesBaseName = aebasename
+5 -2
View File
@@ -3,18 +3,20 @@ aechannel=stable
aebuild=7
aegroup=appeng
aebasename=appliedenergistics2
extended=extended_life
extendedversion=v49ac
trousers=trousers_edition
trousersversion=v49t
#########################################################
# Versions #
#########################################################
minecraft_version=1.12.2
mcp_mappings=snapshot_20171003
forge_version=14.23.5.2847
#########################################################
# Installable #
#########################################################
hwyla_version=1.8.26-B41_1.12.2
#########################################################
# Provided APIs #
#########################################################
@@ -26,6 +28,7 @@ cofhcore_version=1.12.2-4.5.2.19
crafttweaker_version=4.1.8.9
inventorytweaks_version=1.63
ctm_version=MC1.12.2-0.3.1.16
#########################################################
# Deployment #
#########################################################
+7 -6
View File
@@ -59,7 +59,7 @@ repositories {
url "http://maven.k-4u.nl/"
}
maven { // CraftTweaker
maven { // CraftTweaker
name 'jared maven'
url "http://maven.blamejared.com/"
}
@@ -70,9 +70,9 @@ repositories {
//}
maven {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
}
configurations {
@@ -80,7 +80,8 @@ configurations {
}
dependencies {
deobfCompile "gregtechce:gregtech:1.12.2:1.15.1.735"
compileOnly "gregtechce:gregtech:1.12.2:1.15.1.735"
// installable runtime dependencies
mods "mcp.mobius.waila:Hwyla:${hwyla_version}"
mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev"
@@ -94,7 +95,7 @@ dependencies {
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf"
compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}"
compileOnly "inventory-tweaks:InventoryTweaks:${inventorytweaks_version}:api"
compileOnly "inventory-tweaks:InventoryTweaks:${inventorytweaks_version}:api"
compileOnly "team.chisel.ctm:CTM:${ctm_version}"
compileOnly "de.ellpeck.actuallyadditions:ActuallyAdditions:1.12.2-r152.16:api"
@@ -28,8 +28,7 @@ public enum PowerUnits
{
AE( "gui.appliedenergistics2.units.appliedenergstics" ), // Native Units - AE Energy
EU( "gui.appliedenergistics2.units.ic2" ), // IndustrialCraft 2 - Energy Units
RF( "gui.appliedenergistics2.units.rf" ), // RF - Redstone Flux
GTCEU( "gui.appliedenergistics2.units.gtceu" ); // RF - Redstone Flux
RF( "gui.appliedenergistics2.units.rf" ); // RF - Redstone Flux
/**
* unlocalized name for the power unit.
@@ -29,7 +29,6 @@ public enum TunnelType
ME, // Network Tunnel
IC2_POWER, // EU Tunnel
FE_POWER, // Forge Energy tunnel
GTCEU_POWER, // Forge Energy tunnel
REDSTONE, // Redstone Tunnel
FLUID, // Fluid Tunnel
ITEM, // Item Tunnel
@@ -88,8 +88,6 @@ public interface IParts
IItemDefinition p2PTunnelFE();
IItemDefinition p2PTunnelGTCEU();
IItemDefinition p2PTunnelLight();
// IItemDefinition p2PTunnelOpenComputers();
@@ -119,10 +119,10 @@ public interface IAEItemStack extends IAEStack<IAEItemStack>
*
* @param is An item stack
*/
boolean equals( ItemStack is );
boolean equals(ItemStack is);
ItemStack getCachedItemStack( long stackSize );
ItemStack getCachedItemStack();
void setCachedItemStack( ItemStack is );
void setCachedItemStack(ItemStack is);
}
@@ -20,7 +20,6 @@ package appeng.capabilities;
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
import gregtech.api.capability.IEnergyContainer;
import net.darkhax.tesla.api.ITeslaConsumer;
import net.darkhax.tesla.api.ITeslaHolder;
import net.minecraft.nbt.NBTBase;
@@ -58,8 +57,6 @@ public final class Capabilities
public static Capability<IItemRepository> ITEM_REPOSITORY_CAPABILITY;
public static Capability<IEnergyContainer> GTCE_ENERGY;
/**
* Register AE2 provided capabilities.
*/
@@ -106,19 +103,7 @@ public final class Capabilities
}
@CapabilityInject( IItemRepository.class )
private static void capIItemRepositoryRegistered( Capability<IItemRepository> cap )
{
ITEM_REPOSITORY_CAPABILITY = cap;
}
@CapabilityInject( IEnergyContainer.class )
private static void capIEnergyContainerRegistered( Capability<IEnergyContainer> cap )
{
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.GTCE ) )
{
GTCE_ENERGY = cap;
}
}
private static void capIItemRepositoryRegistered( Capability<IItemRepository> cap ) { ITEM_REPOSITORY_CAPABILITY = cap; }
// Create a storage implementation that does not do anything
private static <T> Capability.IStorage<T> createNullStorage()
@@ -13,7 +13,6 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.misc.PartOreDicStorageBus;
import appeng.util.item.OreDictFilterMatcher;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
@@ -27,7 +26,7 @@ public class GuiPartOreDictStorageBus extends AEBaseGui
private GuiTabButton priority;
private GuiImgButton partition;
private static final Pattern ORE_DICTIONARY_FILTER = Pattern.compile( "[(!]* *[0-9a-zA-Z*]* *\\)*( *[&|^]? *[(!]* *[0-9a-zA-Z*]* *\\)*)*" );
private static final Pattern ORE_DICTIONARY_FILTER = Pattern.compile( "\\*?[a-zA-Z0-9_|\\\\+(){,}?!=\\-\\[:\\]&^$]*\\*?" );
private MEGuiTextField searchFieldInputs;
public GuiPartOreDictStorageBus( final InventoryPlayer inventoryPlayer, final PartOreDicStorageBus te )
@@ -104,7 +103,6 @@ public class GuiPartOreDictStorageBus extends AEBaseGui
if( !searchFieldInputs.isFocused() && wasFocused )
{
searchFieldInputs.setText( OreDictFilterMatcher.validateExp( searchFieldInputs.getText() ) );
NetworkHandler.instance().sendToServer( new PacketValueConfig( "OreDictStorageBus.save", searchFieldInputs.getText() ) );
}
@@ -127,11 +125,8 @@ public class GuiPartOreDictStorageBus extends AEBaseGui
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.OreDictStorageBus.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( this.searchFieldInputs.getText().length() + " / " + this.searchFieldInputs.getMaxStringLength(), 120, 36, 4210752 );
this.fontRenderer.drawString( "& = AND " + "| = OR", 8, 36, 4210752 );
this.fontRenderer.drawString( "^ = XOR " + "! = NOT", 8, 48, 4210752 );
this.fontRenderer.drawString( "() for priority " + "* for wildcard", 8, 60, 4210752 );
this.fontRenderer.drawString( "Ex.: *Redstone*&!dustRedstone", 8, 72, 4210752 );
this.fontRenderer.drawString( this.searchFieldInputs.getText().length() + " / " + this.searchFieldInputs.getMaxStringLength(), 8, 36, 4210752 );
this.fontRenderer.drawSplitString( "Supports regex. Or use * as a wildcard", 6, 48, 174, 4210752 );
}
@Override
@@ -87,7 +87,6 @@ public class GuiImgButton extends GuiButton implements ITooltip
this.registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName );
this.registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName );
this.registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName );
this.registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.GTCEU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName );
this.registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
this.registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );
@@ -1,18 +1,27 @@
package appeng.container.implementations;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.AEBaseContainer;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.parts.misc.PartOreDicStorageBus;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.item.AEItemStack;
import appeng.util.item.OreReference;
import appeng.util.iterators.NullIterator;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;
import java.io.IOException;
@@ -48,11 +57,6 @@ public class ContainerPartOreDictStorageBus extends AEBaseContainer
{
final IMEInventory<IAEItemStack> cellInv = this.part.getInternalHandler();
if( cellInv == null )
{
return;
}
Set<Integer> oreIDs = new HashSet<>();
for( IAEItemStack itemStack : cellInv.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ) )
@@ -99,7 +103,7 @@ public class ContainerPartOreDictStorageBus extends AEBaseContainer
{
try
{
NetworkHandler.instance().sendTo( new PacketValueConfig( "OreDictStorageBus.sendRegex", part.getOreExp() ), (EntityPlayerMP) getInventoryPlayer().player );
NetworkHandler.instance().sendTo( new PacketValueConfig( "OreDictStorageBus.sendRegex", part.getOreMatch() ), (EntityPlayerMP) getInventoryPlayer().player );
}
catch( IOException e )
{
+53 -71
View File
@@ -20,7 +20,11 @@ package appeng.core;
import java.io.File;
import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import com.google.common.collect.Sets;
@@ -60,50 +64,13 @@ public final class AEConfig extends Configuration implements IConfigurableObject
private static AEConfig instance;
// Default Grindstone ores
private static final String[] ORES_VANILLA = {
"Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold",
"Charcoal", "NetherQuartz"
};
private static final String[] ORES_AE = {"CertusQuartz", "Wheat", "Fluix"};
private static final String[] ORES_COMMON = {
"Copper", "Tin", "Silver", "Lead", "Bronze"
};
private static final String[] ORES_MISC = {
"Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum",
"Osmium", "Zinc"
};
private String[] nonBlockingItems = {
"[gregtech]", "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.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",
"contenttweaker:smallgearextrudershape",
"contenttweaker:creativeportabletankmold"
};
private static final String[] ORES_VANILLA = { "Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz" };
private static final String[] ORES_AE = { "CertusQuartz", "Wheat", "Fluix" };
private static final String[] ORES_COMMON = { "Copper", "Tin", "Silver", "Lead", "Bronze" };
private static final String[] ORES_MISC = { "Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum", "Osmium", "Zinc" };
// Default Energy Conversion Rates
private static final double DEFAULT_IC2_EXCHANGE = 2.0;
private static final double DEFAULT_GTCEU_EXCHANGE = 2.0;
private static final double DEFAULT_RF_EXCHANGE = 0.5;
private final IConfigManager settings = new ConfigManager( this );
@@ -123,10 +90,10 @@ public final class AEConfig extends Configuration implements IConfigurableObject
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};
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
private int storageProviderID = -1;
@@ -158,7 +125,7 @@ public final class AEConfig extends Configuration implements IConfigurableObject
private int minMeteoriteDistanceSq = this.minMeteoriteDistance * this.minMeteoriteDistance;
private double meteoriteClusterChance = 0.1;
private int meteoriteMaximumSpawnHeight = 180;
private int[] meteoriteDimensionWhitelist = {0};
private int[] meteoriteDimensionWhitelist = { 0 };
// Wireless
private double wirelessBaseCost = 8;
@@ -181,7 +148,6 @@ public final class AEConfig extends Configuration implements IConfigurableObject
PowerUnits.EU.conversionRatio = this.get( "PowerRatios", "IC2", DEFAULT_IC2_EXCHANGE ).getDouble( DEFAULT_IC2_EXCHANGE );
PowerUnits.RF.conversionRatio = this.get( "PowerRatios", "ForgeEnergy", DEFAULT_RF_EXCHANGE ).getDouble( DEFAULT_RF_EXCHANGE );
PowerUnits.GTCEU.conversionRatio = this.get( "PowerRatios", "GTCEU", DEFAULT_GTCEU_EXCHANGE ).getDouble( DEFAULT_GTCEU_EXCHANGE );
final double usageEffective = this.get( "PowerRatios", "UsageMultiplier", 1.0 ).getDouble( 1.0 );
PowerMultiplier.CONFIG.multiplier = Math.max( 0.01, usageEffective );
@@ -189,24 +155,32 @@ public final class AEConfig extends Configuration implements IConfigurableObject
CondenserOutput.MATTER_BALLS.requiredPower = this.get( "Condenser", "MatterBalls", 256 ).getInt( 256 );
CondenserOutput.SINGULARITY.requiredPower = this.get( "Condenser", "Singularity", 256000 ).getInt( 256000 );
this.removeCrashingItemsOnLoad = this.get( "general", "removeCrashingItemsOnLoad", false, "Will auto-remove items that crash when being loaded from storage. This will destroy those items instead of crashing the game!" ).getBoolean();
this.removeCrashingItemsOnLoad = this.get( "general", "removeCrashingItemsOnLoad", false,
"Will auto-remove items that crash when being loaded from storage. This will destroy those items instead of crashing the game!" ).getBoolean();
this.setCategoryComment( "BlockingMode", "Map of items to not block when blockingmode is enabled.\n[modid]\nmodid:item:metadata(optional,default:0)\nSupports more than one modid, so you can block different things between, for example, gregtech or enderio" );
this.nonBlockingItems = this.get( "BlockingMode", "nonBlockingItems", nonBlockingItems, "NonBlockingItems" ).getStringList();
this.setCategoryComment( "GrindStone", "Creates recipe of the following pattern automatically: '1 oreTYPE => 2 dustTYPE' and '(1 ingotTYPE or 1 crystalTYPE or 1 gemTYPE) => 1 dustTYPE'" );
this.grinderOres = this.get( "GrindStone", "grinderOres", this.grinderOres, "The list of types to handle. Specify without a prefix like ore or dust." ).getStringList();
this.grinderBlackList = Sets.newHashSet( this.get( "GrindStone", "blacklist", new String[]{}, "Blacklists the exact oredict name from being handled by any recipe." ).getStringList() );
this.oreDoublePercentage = this.get( "GrindStone", "oreDoublePercentage", this.oreDoublePercentage, "Chance to actually get an output with stacksize > 1." ).getDouble( this.oreDoublePercentage );
this.setCategoryComment( "GrindStone",
"Creates recipe of the following pattern automatically: '1 oreTYPE => 2 dustTYPE' and '(1 ingotTYPE or 1 crystalTYPE or 1 gemTYPE) => 1 dustTYPE'" );
this.grinderOres = this.get( "GrindStone", "grinderOres", this.grinderOres, "The list of types to handle. Specify without a prefix like ore or dust." )
.getStringList();
this.grinderBlackList = Sets.newHashSet(
this.get( "GrindStone", "blacklist", new String[] {}, "Blacklists the exact oredict name from being handled by any recipe." )
.getStringList() );
this.oreDoublePercentage = this
.get( "GrindStone", "oreDoublePercentage", this.oreDoublePercentage, "Chance to actually get an output with stacksize > 1." )
.getDouble( this.oreDoublePercentage );
this.settings.registerSetting( Settings.SEARCH_TOOLTIPS, YesNo.YES );
this.settings.registerSetting( Settings.TERMINAL_STYLE, TerminalStyle.TALL );
this.settings.registerSetting( Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH );
this.spawnChargedChance = (float) ( 1.0 - this.get( "worldGen", "spawnChargedChance", 1.0 - this.spawnChargedChance ).getDouble( 1.0 - this.spawnChargedChance ) );
this.spawnChargedChance = (float) ( 1.0 - this.get( "worldGen", "spawnChargedChance", 1.0 - this.spawnChargedChance )
.getDouble(
1.0 - this.spawnChargedChance ) );
this.minMeteoriteDistance = this.get( "worldGen", "minMeteoriteDistance", this.minMeteoriteDistance ).getInt( this.minMeteoriteDistance );
this.meteoriteClusterChance = this.get( "worldGen", "meteoriteClusterChance", this.meteoriteClusterChance ).getDouble( this.meteoriteClusterChance );
this.meteoriteMaximumSpawnHeight = this.get( "worldGen", "meteoriteMaximumSpawnHeight", this.meteoriteMaximumSpawnHeight ).getInt( this.meteoriteMaximumSpawnHeight );
this.meteoriteMaximumSpawnHeight = this.get( "worldGen", "meteoriteMaximumSpawnHeight", this.meteoriteMaximumSpawnHeight )
.getInt(
this.meteoriteMaximumSpawnHeight );
this.meteoriteDimensionWhitelist = this.get( "worldGen", "meteoriteDimensionWhitelist", this.meteoriteDimensionWhitelist ).getIntList();
this.quartzOresPerCluster = this.get( "worldGen", "quartzOresPerCluster", this.quartzOresPerCluster ).getInt( this.quartzOresPerCluster );
@@ -214,16 +188,23 @@ public final class AEConfig extends Configuration implements IConfigurableObject
this.minMeteoriteDistanceSq = this.minMeteoriteDistance * this.minMeteoriteDistance;
this.addCustomCategoryComment( "wireless", "Range= wirelessBaseRange + wirelessBoosterRangeMultiplier * Math.pow( boosters, wirelessBoosterExp )\nPowerDrain= wirelessBaseCost + wirelessCostMultiplier * Math.pow( boosters, 1 + boosters / wirelessHighWirelessCount )" );
this.addCustomCategoryComment( "wireless",
"Range= wirelessBaseRange + wirelessBoosterRangeMultiplier * Math.pow( boosters, wirelessBoosterExp )\nPowerDrain= wirelessBaseCost + wirelessCostMultiplier * Math.pow( boosters, 1 + boosters / wirelessHighWirelessCount )" );
this.wirelessBaseCost = this.get( "wireless", "wirelessBaseCost", this.wirelessBaseCost ).getDouble( this.wirelessBaseCost );
this.wirelessCostMultiplier = this.get( "wireless", "wirelessCostMultiplier", this.wirelessCostMultiplier ).getDouble( this.wirelessCostMultiplier );
this.wirelessBaseRange = this.get( "wireless", "wirelessBaseRange", this.wirelessBaseRange ).getDouble( this.wirelessBaseRange );
this.wirelessBoosterRangeMultiplier = this.get( "wireless", "wirelessBoosterRangeMultiplier", this.wirelessBoosterRangeMultiplier ).getDouble( this.wirelessBoosterRangeMultiplier );
this.wirelessBoosterRangeMultiplier = this.get( "wireless", "wirelessBoosterRangeMultiplier", this.wirelessBoosterRangeMultiplier )
.getDouble(
this.wirelessBoosterRangeMultiplier );
this.wirelessBoosterExp = this.get( "wireless", "wirelessBoosterExp", this.wirelessBoosterExp ).getDouble( this.wirelessBoosterExp );
this.wirelessTerminalDrainMultiplier = this.get( "wireless", "wirelessTerminalDrainMultiplier", this.wirelessTerminalDrainMultiplier ).getDouble( this.wirelessTerminalDrainMultiplier );
this.wirelessTerminalDrainMultiplier = this.get( "wireless", "wirelessTerminalDrainMultiplier", this.wirelessTerminalDrainMultiplier )
.getDouble(
this.wirelessTerminalDrainMultiplier );
this.formationPlaneEntityLimit = this.get( "automation", "formationPlaneEntityLimit", this.formationPlaneEntityLimit ).getInt( this.formationPlaneEntityLimit );
this.formationPlaneEntityLimit = this.get( "automation", "formationPlaneEntityLimit", this.formationPlaneEntityLimit )
.getInt(
this.formationPlaneEntityLimit );
this.wirelessTerminalBattery = this.get( "battery", "wirelessTerminal", this.wirelessTerminalBattery ).getInt( this.wirelessTerminalBattery );
this.chargedStaffBattery = this.get( "battery", "chargedStaff", this.chargedStaffBattery ).getInt( this.chargedStaffBattery );
@@ -264,7 +245,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
try
{
this.selectedPowerUnit = PowerUnits.valueOf( this.get( "Client", "PowerUnit", this.selectedPowerUnit.name(), this.getListComment( this.selectedPowerUnit ) ).getString() );
this.selectedPowerUnit = PowerUnits.valueOf(
this.get( "Client", "PowerUnit", this.selectedPowerUnit.name(), this.getListComment( this.selectedPowerUnit ) ).getString() );
}
catch( final Throwable t )
{
@@ -280,13 +262,17 @@ public final class AEConfig extends Configuration implements IConfigurableObject
{
this.storageProviderID = this.get( "spatialio", "storageProviderID", this.storageProviderID ).getInt( this.storageProviderID );
this.storageDimensionID = this.get( "spatialio", "storageDimensionID", this.storageDimensionID ).getInt( this.storageDimensionID );
this.spatialPowerMultiplier = this.get( "spatialio", "spatialPowerMultiplier", this.spatialPowerMultiplier ).getDouble( this.spatialPowerMultiplier );
this.spatialPowerMultiplier = this.get( "spatialio", "spatialPowerMultiplier", this.spatialPowerMultiplier )
.getDouble(
this.spatialPowerMultiplier );
this.spatialPowerExponent = this.get( "spatialio", "spatialPowerExponent", this.spatialPowerExponent ).getDouble( this.spatialPowerExponent );
}
if( this.isFeatureEnabled( AEFeature.CRAFTING_CPU ) )
{
this.craftingCalculationTimePerTick = this.get( "craftingCPU", "craftingCalculationTimePerTick", this.craftingCalculationTimePerTick ).getInt( this.craftingCalculationTimePerTick );
this.craftingCalculationTimePerTick = this.get( "craftingCPU", "craftingCalculationTimePerTick", this.craftingCalculationTimePerTick )
.getInt(
this.craftingCalculationTimePerTick );
}
this.updatable = true;
@@ -460,7 +446,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
return true;
}
this.setCategoryComment( "OreCamouflage", "AE2 Automatically uses alternative ores present in your instance of MC to blend better with its surroundings, if you prefer you can disable this selectively using these flags; Its important to note, that some if these items even if enabled may not be craftable in game because other items are overriding their recipes." );
this.setCategoryComment( "OreCamouflage",
"AE2 Automatically uses alternative ores present in your instance of MC to blend better with its surroundings, if you prefer you can disable this selectively using these flags; Its important to note, that some if these items even if enabled may not be craftable in game because other items are overriding their recipes." );
final Property p = this.get( "OreCamouflage", mt.name(), true );
p.setComment( "OreDictionary Names: " + mt.getOreName() );
@@ -728,11 +715,6 @@ public final class AEConfig extends Configuration implements IConfigurableObject
return this.quartzOresClusterAmount;
}
public String[] getNonBlockingItems()
{
return nonBlockingItems;
}
public int getChargedChange()
{
return this.chargedChange;
+2 -1
View File
@@ -183,7 +183,8 @@ public final class AppEng
AELog.info( "Pre Initialization ( ended after " + watch.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
// Instantiate all Plugins
List<Object> injectables = Lists.newArrayList( AEApi.instance() );
List<Object> injectables = Lists.newArrayList(
AEApi.instance() );
new PluginLoader().loadPlugins( injectables, event.getAsmData() );
}
@@ -70,7 +70,6 @@ public final class ApiParts implements IParts
private final IItemDefinition p2PTunnelFluids;
private final IItemDefinition p2PTunnelEU;
private final IItemDefinition p2PTunnelFE;
private final IItemDefinition p2PTunnelGTCEU;
private final IItemDefinition p2PTunnelLight;
// private final IItemDefinition p2PTunnelOpenComputers;
private final IItemDefinition cableAnchor;
@@ -134,7 +133,6 @@ public final class ApiParts implements IParts
this.p2PTunnelFluids = new DamagedItemDefinition( "part.tunnel.fluid", itemPart.createPart( PartType.P2P_TUNNEL_FLUIDS ) );
this.p2PTunnelEU = new DamagedItemDefinition( "part.tunnel.eu", itemPart.createPart( PartType.P2P_TUNNEL_IC2 ) );
this.p2PTunnelFE = new DamagedItemDefinition( "part.tunnel.fe", itemPart.createPart( PartType.P2P_TUNNEL_FE ) );
this.p2PTunnelGTCEU = new DamagedItemDefinition( "part.tunnel.gtceu", itemPart.createPart( PartType.P2P_TUNNEL_GTCEU ) );
this.p2PTunnelLight = new DamagedItemDefinition( "part.tunnel.light", itemPart.createPart( PartType.P2P_TUNNEL_LIGHT ) );
// this.p2PTunnelOpenComputers = new DamagedItemDefinition( itemMultiPart.createPart(
// PartType.P2PTunnelOpenComputers ) );
@@ -340,11 +338,6 @@ public final class ApiParts implements IParts
{
return this.p2PTunnelFE;
}
public IItemDefinition p2PTunnelGTCEU()
{
return this.p2PTunnelGTCEU;
}
@Override
public IItemDefinition p2PTunnelLight()
@@ -25,13 +25,13 @@ public enum AEFeature
// is just flat out required by tons of
// important stuff.
CORE( "Core", null )
{
@Override
public boolean isVisible()
{
return false;
}
},
{
@Override
public boolean isVisible()
{
return false;
}
},
CERTUS_QUARTZ_WORLD_GEN( "CertusQuartzWorldGen", Constants.CATEGORY_WORLD ),
METEORITE_WORLD_GEN( "MeteoriteWorldGen", Constants.CATEGORY_WORLD ),
@@ -126,7 +126,6 @@ public enum AEFeature
P2P_TUNNEL_REDSTONE( "P2PTunnelRedstone", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_EU( "P2PTunnelEU", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_FE( "P2PTunnelFE", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_GTCEU( "P2PTunnelGTCEU", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_FLUIDS( "P2PTunnelFluids", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_LIGHT( "P2PTunnelLight", Constants.CATEGORY_P2P_TUNNELS ),
P2P_TUNNEL_OPEN_COMPUTERS( "P2PTunnelOpenComputers", Constants.CATEGORY_P2P_TUNNELS ),
@@ -164,6 +163,7 @@ public enum AEFeature
MOLECULAR_ASSEMBLER( "MolecularAssembler", Constants.CATEGORY_CRAFTING_FEATURES ),
PATTERNS( "Patterns", Constants.CATEGORY_CRAFTING_FEATURES ),
CRAFTING_CPU( "CraftingCPU", Constants.CATEGORY_CRAFTING_FEATURES ),
CRAFTING_MANAGER_FALLBACK( "CraftingManagerFallback", Constants.CATEGORY_CRAFTING_FEATURES, "Use CraftingManager to find an alternative recipe, after a pattern rejected an ingredient. Should be enabled to avoid issues, but can have a minor performance impact." ),
BASIC_CARDS( "BasicCards", Constants.CATEGORY_UPGRADES ),
ADVANCED_CARDS( "AdvancedCards", Constants.CATEGORY_UPGRADES ),
@@ -19,14 +19,13 @@
package appeng.core.features.registries;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.core.AELog;
import appeng.util.item.OreHelper;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@@ -55,7 +54,8 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
private final Map<String, TunnelType> modIdTunnels = new HashMap<>( INITIAL_CAPACITY );
private final Map<Capability<?>, TunnelType> capTunnels = new HashMap<>( INITIAL_CAPACITY );
public void configure() {
public void configure()
{
final IDefinitions definitions = AEApi.instance().definitions();
final IBlocks blocks = definitions.blocks();
@@ -64,31 +64,13 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
/**
* light!
*/
this.addNewAttunement(new ItemStack(Blocks.TORCH), TunnelType.LIGHT);
this.addNewAttunement(new ItemStack(Blocks.GLOWSTONE), TunnelType.LIGHT);
List<String> gtceOreDict = new ArrayList<>();
gtceOreDict.add("wireGtHex");
gtceOreDict.add("wireGtOctal");
gtceOreDict.add("wireGtQuadruple");
gtceOreDict.add("wireGtDouble");
gtceOreDict.add("wireGtSingle");
gtceOreDict.add("cableGtHex");
gtceOreDict.add("cableGtOctal");
gtceOreDict.add("cableGtQuadruple");
gtceOreDict.add("cableGtDouble");
gtceOreDict.add("cableGtSingle");
for(String oreDict : gtceOreDict) {
Arrays.stream( OreDictionary.getOreNames() ).filter( oreName -> oreName.startsWith( oreDict ) ).forEach( oreName -> {
OreHelper.INSTANCE.getCachedOres( oreName ).forEach( stack -> this.addNewAttunement( stack, TunnelType.GTCEU_POWER ) );
} );
}
this.addNewAttunement( new ItemStack( Blocks.TORCH ), TunnelType.LIGHT );
this.addNewAttunement( new ItemStack( Blocks.GLOWSTONE ), TunnelType.LIGHT );
/**
* Forge energy tunnel items
*/
this.addNewAttunement( blocks.energyCellDense(), TunnelType.FE_POWER );
this.addNewAttunement( blocks.energyAcceptor(), TunnelType.FE_POWER );
this.addNewAttunement( blocks.energyCell(), TunnelType.FE_POWER );
@@ -99,7 +99,6 @@ public enum GuiText
OCTunnel,
LightTunnel,
FETunnel,
GTCEUTunnel,
PressureTunnel,
// spatial
@@ -252,7 +252,7 @@ public class CraftingTreeProcess
pro.dive( job );
}
job.addBytes( this.crafts * 8 + this.bytes );
job.addBytes( this.crafts + 8 + this.bytes );
}
IAEItemStack getAmountCrafted( IAEItemStack what2 )
+102 -117
View File
@@ -23,15 +23,15 @@ import java.util.*;
import javax.annotation.Nullable;
import appeng.util.inv.BlockingInventoryAdaptor;
import appeng.integration.modules.gregtech.GTCEInventoryAdaptor;
import appeng.util.*;
import appeng.util.inv.*;
import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.Ints;
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
import gregtech.api.block.machines.BlockMachine;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.MetaTileEntityHolder;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
@@ -108,16 +108,14 @@ import static gregtech.api.block.machines.BlockMachine.getMetaTileEntity;
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
{
private int[] failedCraftTriesSlot = {0, 0, 0, 0, 0, 0, 0, 0, 0};
private int[] failedCraftTriesSlot = {0,0,0,0,0,0,0,0,0};
public static final int NUMBER_OF_STORAGE_SLOTS = 9;
public static final int NUMBER_OF_CONFIG_SLOTS = 9;
public static final int NUMBER_OF_PATTERN_SLOTS = 36;
private static final Collection<Block> BAD_BLOCKS = new HashSet<>( 100 );
private final IAEItemStack[] requireWork = {
null, null, null, null, null, null, null, null, null
};
private final IAEItemStack[] requireWork = { null, null, null, null, null, null, null, null, null };
private final MultiCraftingTracker craftingTracker;
private final AENetworkProxy gridProxy;
private final IInterfaceHost iHost;
@@ -127,8 +125,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, NUMBER_OF_CONFIG_SLOTS );
private final AppEngInternalInventory storage = new AppEngInternalInventory( this, NUMBER_OF_STORAGE_SLOTS );
private final AppEngInternalInventory patterns = new AppEngInternalInventory( this, NUMBER_OF_PATTERN_SLOTS );
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>( new NullInventory<IAEItemStack>(), AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>( new NullInventory<IAEFluidStack>(), AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>( new NullInventory<IAEItemStack>(), AEApi.instance()
.storage()
.getStorageChannel( IItemStorageChannel.class ) );
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>( new NullInventory<IAEFluidStack>(), AEApi.instance()
.storage()
.getStorageChannel( IFluidStorageChannel.class ) );
private final UpgradeInventory upgrades;
private boolean hasConfig = false;
private int priority;
@@ -139,7 +141,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private final Accessor accessor = new Accessor();
private EnumSet<EnumFacing> visitedFaces = EnumSet.noneOf( EnumFacing.class );
private EnumMap<EnumFacing, List<ItemStack>> waitingToSendFacing = new EnumMap<>( EnumFacing.class );
private BlockingInventoryAdaptor blockingInventoryAdaptor;
private GTCEInventoryAdaptor GTad;
private boolean resetConfigCache = true;
private IMEMonitor<IAEItemStack> configCachedHandler;
@@ -243,12 +245,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
NBTTagCompound sidedWaitList = new NBTTagCompound();
if( this.waitingToSendFacing != null )
if (this.waitingToSendFacing != null)
{
for( EnumFacing s : this.iHost.getTargets() )
{
NBTTagList waitingListSided = new NBTTagList();
if( this.waitingToSendFacing.containsKey( s ) )
if (this.waitingToSendFacing.containsKey( s ))
{
for( final ItemStack is : this.waitingToSendFacing.get( s ) )
{
@@ -356,9 +358,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
return;
}
if( this.waitingToSendFacing == null )
{
this.waitingToSendFacing = new EnumMap<>( EnumFacing.class );
if (this.waitingToSendFacing == null){
this.waitingToSendFacing = new EnumMap<>(EnumFacing.class);
}
this.waitingToSendFacing.computeIfAbsent( f, k -> new ArrayList<>() );
@@ -415,6 +416,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
// :P
}
}
this.notifyNeighbors();
}
private void updateCraftingList()
@@ -430,12 +433,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
if( this.craftingList != null )
{
final Iterator<ICraftingPatternDetails> i = this.craftingList.iterator();
while ( i.hasNext() )
while( i.hasNext() )
{
final ICraftingPatternDetails details = i.next();
boolean found = false;
for( int x = 0; x < accountedFor.length; x++ )
for( int x = 0; x < accountedFor.length ; x++ )
{
final ItemStack is = this.patterns.getStackInSlot( x );
if( details.getPattern() == is )
@@ -451,7 +454,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
}
for( int x = 0; x < accountedFor.length; x++ )
for( int x = 0; x < accountedFor.length ; x++ )
{
if( !accountedFor[x] )
{
@@ -469,23 +472,18 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
}
private boolean hasWorkToDo()
{
private boolean hasWorkToDo() {
if( hasItemsToSend() )
{
if (hasItemsToSend()){
return true;
}
if( hasItemsToSendFacing() )
{
if(hasItemsToSendFacing()){
return true;
}
for( final IAEItemStack requiredWork : this.requireWork )
{
if( requiredWork != null )
{
for (final IAEItemStack requiredWork : this.requireWork) {
if (requiredWork != null) {
return true;
}
}
@@ -596,7 +594,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private boolean hasItemsToSendFacing()
{
if( waitingToSendFacing != null )
if (waitingToSendFacing != null)
{
for( EnumFacing enumFacing : waitingToSendFacing.keySet() )
{
@@ -616,13 +614,10 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
List<ItemStack> dropList = new ArrayList<>();
for( int invSlot = 0; invSlot < patterns.getSlots(); invSlot++ )
{
if( invSlot > 8 + this.getInstalledUpgrades( Upgrades.PATTERN_EXPANSION ) * 9 )
if( invSlot > 8 + this.getInstalledUpgrades( Upgrades.PATTERN_EXPANSION ) * 9 )
{
ItemStack is = patterns.getStackInSlot( invSlot );
if( is.isEmpty() )
{
continue;
}
if( is.isEmpty() ) continue;
dropList.add( patterns.extractItem( invSlot, Integer.MAX_VALUE, false ) );
}
}
@@ -639,7 +634,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
@Override
public boolean canInsert( final ItemStack stack )
{
final IAEItemStack out = this.destination.injectItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ), Actionable.SIMULATE, null );
final IAEItemStack out = this.destination.injectItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( stack ),
Actionable.SIMULATE, null );
if( out == null )
{
return true;
@@ -713,7 +709,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
this.pushItemsOut( this.iHost.getTargets() );
}
if( hasItemsToSendFacing() )
if (hasItemsToSendFacing())
{
for( EnumFacing enumFacing : waitingToSendFacing.keySet() )
{
@@ -736,7 +732,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
final World w = tile.getWorld();
final Iterator<ItemStack> i = this.waitingToSend.iterator();
while ( i.hasNext() )
while( i.hasNext() )
{
ItemStack whatToSend = i.next();
@@ -783,8 +779,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private void pushItemsOut( final EnumFacing s )
{
if( !this.waitingToSendFacing.containsKey( s ) || ( this.waitingToSendFacing.containsKey( s ) && this.waitingToSendFacing.get( s ).isEmpty() ) )
{
if (!this.waitingToSendFacing.containsKey(s) ||
(this.waitingToSendFacing.containsKey(s) && this.waitingToSendFacing.get( s ).isEmpty())) {
return;
}
@@ -848,7 +844,42 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
this.destination = this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IEnergySource src = this.gridProxy.getEnergy();
if( itemStack.getStackSize() < 0 )
if( this.craftingTracker.isBusy( x ) )
{
changed = this.handleCrafting( x, adaptor, itemStack ) || changed;
}
else if( itemStack.getStackSize() > 0 )
{
// make sure strange things didn't happen...
if( !adaptor.simulateAdd( itemStack.createItemStack() ).isEmpty() )
{
changed = true;
throw new GridAccessException();
}
IAEItemStack storedStack = this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).getStorageList().findPrecise( itemStack );
if( storedStack != null )
{
if( storedStack.getStackSize() > 0 )
{
final IAEItemStack acquired = Platform.poweredExtraction( src, this.destination, itemStack, this.interfaceRequestSource );
if( acquired != null )
{
changed = true;
final ItemStack issue = adaptor.addItems( acquired.createItemStack() );
if( !issue.isEmpty() )
{
throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" );
}
}
}
else if( storedStack.isCraftable() )
{
changed = this.handleCrafting( x, adaptor, itemStack ) || changed;
}
}
}
else if( itemStack.getStackSize() < 0 )
{
IAEItemStack toStore = itemStack.copy();
toStore.setStackSize( -toStore.getStackSize() );
@@ -886,44 +917,6 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
}
}
if( this.craftingTracker.isBusy( x ) )
{
changed = this.handleCrafting( x, adaptor, itemStack ) || changed;
}
else if( itemStack.getStackSize() > 0 )
{
// make sure strange things didn't happen...
ItemStack inputStack = itemStack.createItemStack();
if( !adaptor.simulateAdd( inputStack ).isEmpty() )
{
changed = true;
throw new GridAccessException();
}
IAEItemStack storedStack = this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).getStorageList().findPrecise( itemStack );
if( storedStack != null )
{
if( storedStack.getStackSize() > 0 )
{
final IAEItemStack acquired = Platform.poweredExtraction( src, this.destination, itemStack, this.interfaceRequestSource );
if( acquired != null )
{
changed = true;
inputStack.setCount( Ints.saturatedCast( acquired.getStackSize() ) );
final ItemStack issue = adaptor.addItems( inputStack );
if( !issue.isEmpty() )
{
throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" );
}
}
}
else if( storedStack.isCraftable() )
{
changed = this.handleCrafting( x, adaptor, itemStack ) || changed;
}
}
}
// else wtf?
}
catch( final GridAccessException e )
@@ -951,16 +944,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 && itemStack != null )
{
if( this.failedCraftTriesSlot[x] <= 0 )
if (this.failedCraftTriesSlot[x] <= 0)
{
boolean crafted = this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(), this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource );
boolean crafted = this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(),
this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource );
if( crafted )
{
this.failedCraftTriesSlot[x] = 0;
}
else
{
if (crafted) this.failedCraftTriesSlot[x] = 0;
else{
this.failedCraftTriesSlot[x] += 2;
}
}
@@ -1104,12 +1094,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private boolean invIsBlocked( InventoryAdaptor inv )
{
return ( inv.containsItems() );
return (inv.containsItems());
}
private static boolean invIsCustomBlocking( BlockingInventoryAdaptor inv )
private static boolean invIsBlockedGTCE( GTCEInventoryAdaptor inv )
{
return ( inv.containsBlockingItems() );
return ( !inv.canRemoveAllExceptCircuits() );
}
@Override
@@ -1166,26 +1156,24 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
if( this.isBlocking() )
{
IPhantomTile phantomTE;
if( Loader.isModLoaded( "actuallyadditions" ) && te instanceof IPhantomTile )
IPhantomTile phantomTE = null;
if( Loader.isModLoaded( "actuallyadditions" ) && Loader.isModLoaded( "gregtech" ) && te instanceof IPhantomTile )
{
phantomTE = ( (IPhantomTile) te );
if( phantomTE.hasBoundPosition() )
{
TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() );
if( NonBlockingItems.INSTANCE.getMap().containsKey( phantom.getBlockType().getRegistryName().getResourceDomain() ) )
if( phantom instanceof MetaTileEntityHolder && isGTCEblocked( phantom, s ) )
{
if( isCustomInvBlocking( phantom, s ) )
{
visitedFaces.remove( s );
continue;
}
visitedFaces.remove( s );
continue;
}
}
}
else if( NonBlockingItems.INSTANCE.getMap().containsKey( te.getBlockType().getRegistryName().getResourceDomain() ) )
else if( Loader.isModLoaded( "gregtech" ) && te instanceof MetaTileEntityHolder )
{
if( isCustomInvBlocking( te, s ) )
if( isGTCEblocked( te, s ) )
{
visitedFaces.remove( s );
continue;
@@ -1240,31 +1228,28 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
for( final EnumFacing s : possibleDirections )
{
final TileEntity te = w.getTileEntity( tile.getPos().offset( s ) );
IPhantomTile phantomTE;
IPhantomTile phantomTE = null;
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
if( ad != null )
{
if( Loader.isModLoaded( "actuallyadditions" ) && Loader.isModLoaded( "gregtech" ) && te instanceof IPhantomTile )
if( Loader.isModLoaded( "actuallyadditions") && Loader.isModLoaded( "gregtech" ) && te instanceof IPhantomTile )
{
phantomTE = ( (IPhantomTile) te );
if( phantomTE.hasBoundPosition() )
{
TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() );
if( NonBlockingItems.INSTANCE.getMap().containsKey( phantom.getBlockType().getRegistryName().getResourceDomain() ) )
if( phantom instanceof MetaTileEntityHolder && !isGTCEblocked( phantom, s ) )
{
if( !isCustomInvBlocking( phantom, s ) )
{
allAreBusy = false;
break;
}
allAreBusy = false;
break;
}
}
}
else if( NonBlockingItems.INSTANCE.getMap().containsKey( te.getBlockType().getRegistryName().getResourceDomain() ) )
else if( Loader.isModLoaded( "gregtech" ) && te instanceof MetaTileEntityHolder )
{
if( !isCustomInvBlocking( te, s ) )
if( !isGTCEblocked( te, s ) )
{
allAreBusy = false;
break;
@@ -1283,10 +1268,10 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
return busy;
}
boolean isCustomInvBlocking( TileEntity te, EnumFacing s )
boolean isGTCEblocked(TileEntity te, EnumFacing s)
{
blockingInventoryAdaptor = BlockingInventoryAdaptor.getAdaptor( te, s.getOpposite() );
return invIsCustomBlocking( blockingInventoryAdaptor );
GTad = GTCEInventoryAdaptor.getAdaptor( te, s.getOpposite() );
return invIsBlockedGTCE( GTad );
}
private boolean sameGrid( final IGrid grid ) throws GridAccessException
@@ -1346,13 +1331,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
if( this.waitingToSendFacing != null )
{
for( List<ItemStack> itemList : waitingToSendFacing.values() )
for (List<ItemStack> itemList : waitingToSendFacing.values())
{
for( final ItemStack is : itemList )
for (final ItemStack is : itemList)
{
if( !is.isEmpty() )
if (!is.isEmpty())
{
drops.add( is );
drops.add(is);
}
}
}
@@ -1482,9 +1467,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
final Block directedBlock = directedBlockState.getBlock();
ItemStack what = new ItemStack( directedBlock, 1, directedBlock.getMetaFromState( directedBlockState ) );
if( Loader.isModLoaded( "gregtech" ) && directedBlock instanceof BlockMachine )
if ( Loader.isModLoaded("gregtech") && directedBlock instanceof BlockMachine )
{
MetaTileEntity metaTileEntity = getMetaTileEntity( hostWorld, targ );
MetaTileEntity metaTileEntity = getMetaTileEntity(hostWorld, targ);
return metaTileEntity.getMetaFullName();
}
@@ -1,83 +0,0 @@
package appeng.helpers;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.util.item.AEItemStack;
import gregtech.api.items.metaitem.MetaItem;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import java.util.*;
public class NonBlockingItems
{
public static Map<String, IItemList<IAEItemStack>> NON_BLOCKING_MAP = new HashMap<>();
public static NonBlockingItems INSTANCE = new NonBlockingItems();
private NonBlockingItems()
{
String[] strings = AEConfig.instance().getNonBlockingItems();
String modid = "";
if( strings.length > 0 )
{
for( String s : strings )
{
if( s.startsWith( "[" ) && s.endsWith( "]" ) )
{
modid = s.substring( 1, s.length() - 1 );
}
else
{
if( !Loader.isModLoaded( modid ) )
{
continue;
}
NON_BLOCKING_MAP.putIfAbsent( modid, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
String[] ModItemMeta = s.split( ":" );
if( ModItemMeta.length < 2 || ModItemMeta.length > 3 )
{
AELog.error( "Invalid non blocking item entry: " + s );
continue;
}
if( ModItemMeta[0].equals( "gregtech" ) )
{
for( MetaItem<?> metaItem : MetaItem.getMetaItems() )
{
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem( ModItemMeta[1] );
if( metaItem.getItem( ModItemMeta[1] ) != null )
{
NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( metaItem2.getStackForm() ) );
break;
}
}
}
else
{
ItemStack itemStack = GameRegistry.makeItemStack( ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0, 1, null );
if( !itemStack.isEmpty() )
{
NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( itemStack ) );
}
else
{
AELog.error( "Item not found on nonBlocking config: " + s );
}
}
}
}
}
}
public Map<String, IItemList<IAEItemStack>> getMap()
{
return NON_BLOCKING_MAP;
}
}
@@ -30,37 +30,35 @@ import appeng.integration.modules.waila.WailaModule;
public enum IntegrationType
{
IC2( IntegrationSide.BOTH, "Industrial Craft 2", "ic2" )
{
@Override
public IIntegrationModule createInstance()
{
return Integrations.setIc2( new IC2Module() );
}
},
GTCE( IntegrationSide.BOTH, "GregTech", "gregtech" ),
{
@Override
public IIntegrationModule createInstance()
{
return Integrations.setIc2( new IC2Module() );
}
},
RC( IntegrationSide.BOTH, "Railcraft", "railcraft" ),
MFR( IntegrationSide.BOTH, "Mine Factory Reloaded", "minefactoryreloaded" ),
Waila( IntegrationSide.BOTH, "Waila", "waila" )
{
@Override
public IIntegrationModule createInstance()
{
return new WailaModule();
}
},
{
@Override
public IIntegrationModule createInstance()
{
return new WailaModule();
}
},
InvTweaks( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks" )
{
@Override
public IIntegrationModule createInstance()
{
return Integrations.setInvTweaks( new InventoryTweaksModule() );
}
},
{
@Override
public IIntegrationModule createInstance()
{
return Integrations.setInvTweaks( new InventoryTweaksModule() );
}
},
JEI( IntegrationSide.CLIENT, "Just Enough Items", "jei" )
{
@@ -0,0 +1,26 @@
package appeng.integration.modules.gregtech;
import appeng.util.inv.ItemSlot;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
public abstract class GTCEInventoryAdaptor implements Iterable<ItemSlot>
{
public static GTCEInventoryAdaptor getAdaptor(final TileEntity te, final EnumFacing d)
{
if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d))
{
// Attempt getting an IItemHandler for the given side via caps
IItemHandler itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d);
if (itemHandler != null)
{
return new GTCEItemHandler(itemHandler);
}
}
return null;
}
public abstract boolean canRemoveAllExceptCircuits();
}
@@ -0,0 +1,58 @@
package appeng.integration.modules.gregtech;
import appeng.util.inv.ItemHandlerIterator;
import appeng.util.inv.ItemSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
public class GTCEItemHandler extends GTCEInventoryAdaptor
{
ArrayList<Integer> GTCElenses = new ArrayList<>(Arrays.asList(15085,15214,15092,15111,15113,15219,15218,15243,15244,15209,15117,15206,15216,15331,15212,15213,15154,15122,15157,15190,15247));
ArrayList<Integer> GTCEmolds = new ArrayList<>(Arrays.asList(32301,32303,32304,32305,32306,32307,32308,32309,32313,32314,32315,32317,32350,32351,32352,32353,32354,32355,32356,32358,32359,32360,32361,32363,32364,32365,32366,32367,32368,32369,32370,32371,32372,32373));
Item smallGearExtruderShape = Item.getByNameOrId("contenttweaker:smallgearextrudershape");
Item creativePortableTankMold = Item.getByNameOrId("contenttweaker:creativeportabletankmold");
protected final IItemHandler itemHandler;
public GTCEItemHandler(IItemHandler itemHandler)
{
this.itemHandler = itemHandler;
}
boolean isBlockableItem(ItemStack stack)
{
if ( stack.getItem() == Item.getByNameOrId("gregtech:meta_item_1") ) {
int metadata = stack.getItemDamage();
if ( metadata == 32766 || GTCElenses.contains(metadata) || GTCEmolds.contains(metadata)) {
return false;
}
}
if ( stack.getItem() == smallGearExtruderShape ) return false;
if ( stack.getItem() == creativePortableTankMold) return false;
return true;
}
@Override
public boolean canRemoveAllExceptCircuits()
{
int slots = this.itemHandler.getSlots();
for ( int slot = 0; slot < slots; slot++ ) {
ItemStack is = this.itemHandler.getStackInSlot(slot);
if ( is.isEmpty() || !isBlockableItem(is) ) continue;
return false;
}
return true;
}
@Override
public Iterator<ItemSlot> iterator()
{
return new ItemHandlerIterator( this.itemHandler );
}
}
+21 -22
View File
@@ -29,7 +29,6 @@ import java.util.Set;
import java.util.stream.Collectors;
import appeng.parts.misc.*;
import appeng.parts.p2p.*;
import appeng.parts.reporting.*;
import com.google.common.collect.ImmutableList;
@@ -66,6 +65,13 @@ import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCableCovered;
import appeng.parts.networking.PartDenseCableSmart;
import appeng.parts.networking.PartQuartzFiber;
import appeng.parts.p2p.PartP2PFEPower;
import appeng.parts.p2p.PartP2PFluids;
import appeng.parts.p2p.PartP2PIC2Power;
import appeng.parts.p2p.PartP2PItems;
import appeng.parts.p2p.PartP2PLight;
import appeng.parts.p2p.PartP2PRedstone;
import appeng.parts.p2p.PartP2PTunnelME;
import appeng.util.Platform;
@@ -269,32 +275,25 @@ public enum PartType
@Override
String getUnlocalizedName()
{
return "p2p_tunnel";
}
},
return "p2p_tunnel";
}
},
P2P_TUNNEL_FE( 469, "p2p_tunnel_fe", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FE ), EnumSet.noneOf( IntegrationType.class ), PartP2PFEPower.class, GuiText.FETunnel )
{
@Override
String getUnlocalizedName()
{
return "p2p_tunnel";
}
},
P2P_TUNNEL_GTCEU( 470, "p2p_tunnel_gtceu", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_GTCEU ), EnumSet.of( IntegrationType.GTCE ), PartP2PGTCEPower.class, GuiText.GTCEUTunnel )
{
@Override
String getUnlocalizedName()
{
return "p2p_tunnel";
}
},
P2P_TUNNEL_FE( 469, "p2p_tunnel_fe", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FE ), EnumSet
.noneOf( IntegrationType.class ), PartP2PFEPower.class, GuiText.FETunnel )
{
@Override
String getUnlocalizedName()
{
return "p2p_tunnel";
}
},
// P2PTunnelOpenComputers( 468, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelOpenComputers ), EnumSet.of(
// IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel ),
INTERFACE_TERMINAL( 480, "interface_terminal", EnumSet.of( AEFeature.INTERFACE_TERMINAL ), EnumSet.noneOf( IntegrationType.class ), PartInterfaceTerminal.class ),
INTERFACE_TERMINAL( 480, "interface_terminal", EnumSet.of( AEFeature.INTERFACE_TERMINAL ), EnumSet
.noneOf( IntegrationType.class ), PartInterfaceTerminal.class ),
FLUID_TERMINAL( 520, "fluid_terminal", EnumSet.of( AEFeature.FLUID_TERMINAL ), EnumSet.noneOf( IntegrationType.class ), PartFluidTerminal.class );
+3 -9
View File
@@ -66,9 +66,8 @@ public class GridStorageCache implements IStorageGrid
private final SetMultimap<IAEStack, ItemWatcher> interests = HashMultimap.create();
private final GenericInterestManager<ItemWatcher> interestManager = new GenericInterestManager<>( this.interests );
private final HashMap<IGridNode, IStackWatcher> watchers = new HashMap<>();
private final Map<IStorageChannel<? extends IAEStack>, NetworkInventoryHandler<?>> storageNetworks;
private final Map<IStorageChannel<? extends IAEStack>, NetworkMonitor<?>> storageMonitors;
private int localDepth;
private Map<IStorageChannel<? extends IAEStack>, NetworkInventoryHandler<?>> storageNetworks;
private Map<IStorageChannel<? extends IAEStack>, NetworkMonitor<?>> storageMonitors;
public GridStorageCache( final IGrid g )
{
@@ -213,11 +212,6 @@ public class GridStorageCache implements IStorageGrid
@MENetworkEventSubscribe
public void cellUpdate( final MENetworkCellArrayUpdate ev )
{
if( localDepth > 0 )
{
return;
}
localDepth++;
this.storageNetworks.clear();
final List<ICellProvider> ll = new ArrayList<ICellProvider>();
@@ -253,7 +247,7 @@ public class GridStorageCache implements IStorageGrid
}
}
tracker.applyChanges();
localDepth--;
this.storageMonitors.forEach( ( channel, monitor ) -> monitor.setForceUpdate( true ) );
}
@@ -19,11 +19,9 @@
package appeng.parts.automation;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.Ints;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -72,7 +70,7 @@ import appeng.util.item.AEItemStack;
public class PartExportBus extends PartSharedItemBus implements ICraftingRequester
{
private final int[] failedCraftTriesSlot = {0, 0, 0, 0, 0, 0, 0, 0, 0};
private final int[] failedCraftTriesSlot = {0,0,0,0,0,0,0,0,0};
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/export_bus_base" );
@@ -133,7 +131,10 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
try
{
final InventoryAdaptor destination = this.getHandler();
final IMEMonitor<IAEItemStack> inv = this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEMonitor<IAEItemStack> inv = this.getProxy()
.getStorage()
.getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IEnergyGrid energy = this.getProxy().getEnergy();
final ICraftingGrid cg = this.getProxy().getCrafting();
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
@@ -149,26 +150,16 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
final IAEItemStack ais = this.getConfig().getAEStackInSlot( slotToExport );
if( ais == null || this.itemToSend <= 0 )
{
continue;
}
if( ais == null || this.itemToSend <= 0 ) continue;
if( this.craftOnly() )
{
if( this.failedCraftTriesSlot[x] <= 0 )
{
if ( this.craftOnly() ) {
if (this.failedCraftTriesSlot[x] <= 0) {
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething;
this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething;
if( this.didSomething )
{
this.failedCraftTriesSlot[x] = 0;
}
else
{
this.failedCraftTriesSlot[x] += 2;
}
if (this.didSomething) this.failedCraftTriesSlot[x] = 0;
else this.failedCraftTriesSlot[x] += 2;
}
this.failedCraftTriesSlot[x] -= 1;
continue;
@@ -197,19 +188,13 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
if( this.itemToSend == before && this.isCraftingEnabled() )
{
if( this.failedCraftTriesSlot[x] <= 0 )
{
if (this.failedCraftTriesSlot[x] <= 0) {
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething;
this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething;
if( this.didSomething )
{
this.failedCraftTriesSlot[x] = 0;
}
else
{
this.failedCraftTriesSlot[x] += 2;
}
if (this.didSomething) this.failedCraftTriesSlot[x] = 0;
else this.failedCraftTriesSlot[x] += 2;
}
this.failedCraftTriesSlot[x] -= 1;
}
@@ -293,27 +278,11 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
if( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 )
{
ItemStack inputStack = items.getCachedItemStack( items.getStackSize() );
ItemStack remaining;
remaining = mode == Actionable.SIMULATE ? d.simulateAdd( inputStack ) : d.addItems( inputStack );
if( !remaining.isEmpty() )
if( mode == Actionable.MODULATE )
{
items.setCachedItemStack( remaining );
return AEItemStack.fromItemStack( d.addItems( items.createItemStack() ) );
}
else
{
items.setCachedItemStack( inputStack );
}
if( remaining == inputStack )
{
return items;
}
return AEItemStack.fromItemStack( remaining );
return AEItemStack.fromItemStack( d.simulateAdd( items.createItemStack() ) );
}
}
}
@@ -349,21 +318,11 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
private void pushItemIntoTarget( final InventoryAdaptor d, final IEnergyGrid energy, final IMEInventory<IAEItemStack> inv, IAEItemStack ais )
{
ItemStack inputStack = ais.getCachedItemStack( ais.getStackSize() );
final ItemStack is = ais.createItemStack();
is.setCount( (int) this.itemToSend );
ItemStack remaining = d.simulateAdd( inputStack );
// Store the stack in the cache for next time.
if( !remaining.isEmpty() )
{
ais.setCachedItemStack( remaining );
}
else
{
ais.setCachedItemStack( inputStack );
}
final long canFit = remaining.isEmpty() ? this.itemToSend : this.itemToSend - remaining.getCount();
final ItemStack o = d.simulateAdd( is );
final long canFit = o.isEmpty() ? this.itemToSend : this.itemToSend - o.getCount();
if( canFit > 0 )
{
@@ -375,9 +334,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
{
this.itemToSend -= itemsToAdd.getStackSize();
inputStack.setCount( Ints.saturatedCast( itemsToAdd.getStackSize() ) );
final ItemStack failed = d.addItems( inputStack );
final ItemStack failed = d.addItems( itemsToAdd.createItemStack() );
if( !failed.isEmpty() )
{
ais.setStackSize( failed.getCount() );
@@ -80,11 +80,26 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
public IAEItemStack injectItems( IAEItemStack iox, Actionable type, IActionSource src )
{
// Try to reuse the cached stack
ItemStack inputStack = iox.getCachedItemStack( iox.getStackSize() );
ItemStack remaining = inputStack;
@Nullable ItemStack currentCached = iox.getCachedItemStack();
iox.setCachedItemStack(null);
ItemStack orgInput;
int slotCount = this.itemHandler.getSlots();
if( currentCached != null && iox.isSameType( currentCached ) )
{
// Cache is suitable, just update the count
orgInput = currentCached;
currentCached.setCount( Ints.saturatedCast( iox.getStackSize() ) );
}
else
{
// We need a new stack :-(
orgInput = iox.createItemStack();
}
ItemStack remaining = orgInput;
for( int i = 0; i < slotCount && !remaining.isEmpty(); i++ )
{
remaining = this.itemHandler.insertItem( i, remaining, type == Actionable.SIMULATE );
@@ -95,13 +110,9 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{
iox.setCachedItemStack( remaining );
}
else
{
iox.setCachedItemStack( inputStack );
}
// At this point, we still have some items left...
if( remaining == inputStack )
if( remaining == orgInput )
{
// The stack remained unmodified, target inventory is full
return iox;
@@ -42,6 +42,8 @@ class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<
private final InventoryCache cache;
private AccessRestriction access;
private ItemStack stackCache;
ItemRepositoryAdapter( IItemRepository itemRepository, IGridProxyable proxy )
{
this.itemRepository = itemRepository;
@@ -59,24 +61,31 @@ class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<
public IAEItemStack injectItems( IAEItemStack iox, Actionable type, IActionSource src )
{
// Try to reuse the cached stack
ItemStack inputStack = iox.getCachedItemStack( iox.getStackSize() );
@Nullable ItemStack currentCached = stackCache;
stackCache = null;
ItemStack remaining;
remaining = this.itemRepository.insertItem( inputStack, type == Actionable.SIMULATE );
// Store the stack in the cache for next time.
if( !remaining.isEmpty() )
ItemStack orgInput;
if( currentCached != null && iox.isSameType( currentCached ) )
{
iox.setCachedItemStack( remaining );
// Cache is suitable, just update the count
orgInput = currentCached;
currentCached.setCount( Ints.saturatedCast( iox.getStackSize() ) );
}
else
{
iox.setCachedItemStack( inputStack );
// We need a new stack :-(
orgInput = iox.createItemStack();
}
ItemStack remaining = this.itemRepository.insertItem( orgInput, type == Actionable.SIMULATE );
// Store the stack in the cache for next time.
if( !remaining.isEmpty() && remaining != orgInput )
{
stackCache = remaining;
}
// At this point, we still have some items left...
if( remaining == inputStack )
if( remaining == orgInput )
{
// The stack remained unmodified, target inventory is full
return iox;
@@ -20,7 +20,6 @@ import appeng.parts.PartModel;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import appeng.util.item.OreHelper;
import appeng.util.prioritylist.IPartitionList;
import appeng.util.prioritylist.OreDictPriorityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -41,7 +40,8 @@ public class PartOreDicStorageBus extends PartStorageBus
@PartModels
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_has_channel" ) );
public String oreExp = "";
public String oreMatch;
OreDictPriorityList<IAEItemStack> priorityList;
public PartOreDicStorageBus( ItemStack is )
@@ -53,15 +53,15 @@ public class PartOreDicStorageBus extends PartStorageBus
public void readFromNBT( NBTTagCompound data )
{
super.readFromNBT( data );
this.oreExp = data.getString( "oreMatch" );
this.priorityList = new OreDictPriorityList<>( OreHelper.INSTANCE.getMatchingOre( oreExp ), oreExp );
this.oreMatch = data.getString( "oreMatch" );
this.priorityList = new OreDictPriorityList<>( OreHelper.INSTANCE.getMatchingOre( oreMatch ), oreMatch );
}
@Override
public void writeToNBT( NBTTagCompound data )
{
super.writeToNBT( data );
data.setString( "oreMatch", getOreExp() );
data.setString( "oreMatch", getOreMatch() );
}
@Override
@@ -126,7 +126,7 @@ public class PartOreDicStorageBus extends PartStorageBus
this.handler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
this.handler.setPriority( this.priority );
this.handler.setPartitionList( this.getPriorityList() );
this.handler.setPartitionList( priorityList );
if( inv instanceof IBaseMonitor )
{
@@ -172,31 +172,21 @@ public class PartOreDicStorageBus extends PartStorageBus
return this.handler;
}
private IPartitionList<IAEItemStack> getPriorityList()
public String getOreMatch()
{
if( priorityList == null )
{
this.priorityList = new OreDictPriorityList<>( OreHelper.INSTANCE.getMatchingOre( oreExp ), oreExp );
}
return priorityList;
}
public String getOreExp()
{
if( this.oreExp == null )
if( this.oreMatch == null )
{
return "";
}
return oreExp;
return oreMatch;
}
public void saveOreMatch( String oreMatch )
{
if( !this.oreExp.equals( oreMatch ) )
if( !this.oreMatch.equals( oreMatch ) )
{
this.oreExp = oreMatch;
this.priorityList = new OreDictPriorityList<>( OreHelper.INSTANCE.getMatchingOre( oreExp ), oreExp );
this.oreMatch = oreMatch;
this.priorityList = new OreDictPriorityList<>( OreHelper.INSTANCE.getMatchingOre( oreMatch ), oreMatch );
if( this.handler != null )
{
handler.setPartitionList( this.priorityList );
@@ -1,308 +0,0 @@
package appeng.parts.p2p;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.api.parts.IPartModel;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
import gregtech.api.capability.GregtechCapabilities;
import gregtech.api.capability.IEnergyContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.Optional;
import java.util.ArrayDeque;
import java.util.List;
import java.util.Queue;
public class PartP2PGTCEPower extends PartP2PTunnel<PartP2PGTCEPower>
{
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_gtceu" );
private static final IEnergyContainer NULL_ENERGY_STORAGE = new NullEnergyStorage();
private final IEnergyContainer inputHandler = new InputEnergyStorage();
private final IEnergyContainer outputHandler = new OutputEnergyStorage();
private final Queue<PartP2PGTCEPower> outputs = new ArrayDeque<>();
public PartP2PGTCEPower( ItemStack is )
{
super( is );
}
@PartModels
public static List<IPartModel> getModels()
{
return MODELS.getModels();
}
@Override
public IPartModel getStaticModels()
{
return MODELS.getModel( this.isPowered(), this.isActive() );
}
@Override
public void onTunnelNetworkChange()
{
this.getHost().notifyNeighbors();
}
private IEnergyContainer getAttachedEnergyStorage()
{
if( this.isActive() )
{
final TileEntity self = this.getTile();
final TileEntity te = self.getWorld().getTileEntity( self.getPos().offset( this.getSide().getFacing() ) );
if( te != null && te.hasCapability( GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, this.getSide().getOpposite().getFacing() ) )
{
return te.getCapability( GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, this.getSide().getOpposite().getFacing() );
}
}
return NULL_ENERGY_STORAGE;
}
@Override
public boolean hasCapability( @Nonnull Capability<?> capability )
{
if( capability == GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER )
{
return true;
}
return super.hasCapability( capability );
}
@Nullable
@Override
public <T> T getCapability( @Nonnull Capability<T> capability )
{
if( capability == GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER )
{
if( this.isOutput() )
{
return (T) this.outputHandler;
}
return (T) this.inputHandler;
}
return super.getCapability( capability );
}
class InputEnergyStorage implements IEnergyContainer
{
@Override
public long getEnergyCanBeInserted()
{
long canInsert = 0;
if( outputs.isEmpty() )
{
try
{
for( PartP2PGTCEPower o : PartP2PGTCEPower.this.getOutputs() )
outputs.add( o );
}
catch( GridAccessException e )
{
e.printStackTrace();
}
}
while ( !outputs.isEmpty() )
{
PartP2PGTCEPower target = outputs.poll();
final IEnergyContainer output = target.getAttachedEnergyStorage();
if( output == null || output.getEnergyCanBeInserted() <= 0 )
{
continue;
}
canInsert += output.getEnergyCanBeInserted();
}
return canInsert;
}
@Override
public long acceptEnergyFromNetwork( EnumFacing facing, long voltage, long amperage )
{
long amperesUsed = 0L;
if( outputs.isEmpty() )
{
try
{
for( PartP2PGTCEPower o : PartP2PGTCEPower.this.getOutputs() )
outputs.add( o );
}
catch( GridAccessException e )
{
e.printStackTrace();
}
}
while ( !outputs.isEmpty() )
{
PartP2PGTCEPower target = outputs.poll();
final IEnergyContainer output = target.getAttachedEnergyStorage();
if( output == null || !output.inputsEnergy( facing ) || output.getEnergyCanBeInserted() <= 0 )
{
continue;
}
if( voltage > 0 )
{
amperesUsed += output.acceptEnergyFromNetwork( facing, voltage, amperage - amperesUsed );
}
if( amperage == amperesUsed )
{
break;
}
}
return amperesUsed;
}
@Override
public boolean inputsEnergy( EnumFacing enumFacing )
{
return true;
}
@Override
public long changeEnergy( long l )
{
return 0;
}
@Override
public long getEnergyStored()
{
return 0;
}
@Override
public long getEnergyCapacity()
{
return 0;
}
@Override
public long getInputAmperage()
{
return 0;
}
@Override
public long getInputVoltage()
{
return 0;
}
}
class OutputEnergyStorage implements IEnergyContainer
{
@Override
public long acceptEnergyFromNetwork( EnumFacing facing, long voltage, long amperage )
{
if( facing == getSide().getFacing() )
{
return 0;
}
final IEnergyContainer output = getAttachedEnergyStorage();
voltage *= 0.95;
if( voltage > 0 )
{
return output.acceptEnergyFromNetwork( facing, voltage, amperage );
}
return 0;
}
@Override
public boolean inputsEnergy( EnumFacing enumFacing )
{
return false;
}
@Override
public boolean outputsEnergy( EnumFacing side )
{
return true;
}
@Override
public long changeEnergy( long l )
{
return 0;
}
@Override
public long getEnergyStored()
{
return 0;
}
@Override
public long getEnergyCapacity()
{
return 0;
}
@Override
public long getInputAmperage()
{
return 0;
}
@Override
public long getInputVoltage()
{
return 0;
}
}
static class NullEnergyStorage implements IEnergyContainer
{
@Override
public long acceptEnergyFromNetwork( EnumFacing enumFacing, long l, long l1 )
{
return 0;
}
@Override
public boolean inputsEnergy( EnumFacing enumFacing )
{
return false;
}
@Override
public long changeEnergy( long l )
{
return 0;
}
@Override
public long getEnergyStored()
{
return 0;
}
@Override
public long getEnergyCapacity()
{
return 0;
}
@Override
public long getInputAmperage()
{
return 0;
}
@Override
public long getInputVoltage()
{
return 0;
}
}
}
@@ -292,10 +292,6 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
newType = parts.p2PTunnelFE().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;
case GTCEU_POWER:
newType = parts.p2PTunnelGTCEU().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;
case FLUID:
newType = parts.p2PTunnelFluids().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;
@@ -17,8 +17,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.items.IItemHandler;
import java.util.List;
import static appeng.helpers.PatternHelper.PROCESSING_INPUT_LIMIT;
import static appeng.helpers.PatternHelper.PROCESSING_OUTPUT_LIMIT;
@@ -45,18 +43,6 @@ public class PartExpandedProcessingPatternTerminal extends AbstractPartTerminal
super( is );
}
@Override
public void getDrops( final List<ItemStack> drops, final boolean wrenched )
{
for( final ItemStack is : this.pattern )
{
if( !is.isEmpty() )
{
drops.add( is );
}
}
}
@Override
public void readFromNBT( NBTTagCompound data )
{
@@ -22,13 +22,6 @@ package appeng.tile.crafting;
import java.io.IOException;
import java.util.List;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.IStorageMonitorableAccessor;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.capabilities.Capabilities;
import appeng.me.helpers.MachineSource;
import io.netty.buffer.ByteBuf;
import net.minecraft.inventory.InventoryCrafting;
@@ -103,7 +96,6 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
private boolean isAwake = false;
private boolean forcePlan = false;
private boolean reboot = true;
private final IActionSource mySrc = new MachineSource( this );
public TileMolecularAssembler()
{
@@ -466,7 +458,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
final ItemStack output = this.myPlan.getOutput( this.craftingInv, this.getWorld() );
if( !output.isEmpty() )
{
this.pushOut( output );
this.pushOut( output.copy() );
for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ )
{
@@ -575,34 +567,6 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
return output;
}
// Prioritize a handler to directly link to another ME network
IStorageMonitorableAccessor accessor = te.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, d.getOpposite() );
if( accessor != null )
{
IStorageMonitorable inventory = accessor.getInventory( this.mySrc );
if( inventory != null )
{
IAEItemStack toInsert = AEItemStack.fromItemStack( output );
IMEMonitor<IAEItemStack> inv = inventory.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
IAEItemStack remainder = inv.injectItems( toInsert, Actionable.SIMULATE, this.mySrc );
if( remainder == null )
{
inv.injectItems( toInsert, Actionable.MODULATE, this.mySrc );
return ItemStack.EMPTY;
}
else
{
if( remainder.getStackSize() == toInsert.getStackSize() )
{
return output.copy();
}
inv.injectItems( toInsert.setStackSize( toInsert.getStackSize() - remainder.getStackSize() ), Actionable.MODULATE, this.mySrc );
return remainder.createItemStack();
}
}
}
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( te, d.getOpposite() );
if( adaptor == null )
@@ -611,7 +575,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
}
final int size = output.getCount();
output = adaptor.addItems( output.copy() );
output = adaptor.addItems( output );
final int newSize = output.isEmpty() ? 0 : output.getCount();
if( size != newSize )
@@ -119,15 +119,14 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
if( this.getTileEntity() != null && this.eventsEnabled() && !this.dirtyFlag )
{
this.dirtyFlag = true;
ItemStack newStack = this.getStackInSlot( slot );
ItemStack newStack = this.getStackInSlot( slot ).copy();
ItemStack oldStack = this.previousStack;
InvOperation op = InvOperation.SET;
if( newStack.isEmpty() || oldStack.isEmpty() || oldStack.getCount() != newStack.getCount() && ItemStack.areItemsEqual( newStack, oldStack ) )
if( newStack.isEmpty() || oldStack.isEmpty() || ( oldStack.getCount() < oldStack.getMaxStackSize() && oldStack.getCount() < this.getSlotLimit( slot ) && ItemStack.areItemsEqual( newStack, oldStack ) ) )
{
if( newStack.getCount() > oldStack.getCount() )
{
newStack = newStack.copy();
newStack.shrink( oldStack.getCount() );
oldStack = ItemStack.EMPTY;
op = InvOperation.INSERT;
@@ -57,16 +57,10 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
}
catch( final GridAccessException e )
{
return 0;
return this.getInternalMaxPower();
}
}
@Override
public double getInternalMaxPower()
{
return getFunnelPowerDemand( Long.MAX_VALUE );
}
@Override
protected double funnelPowerIntoStorage( final double power, final Actionable mode )
{
@@ -53,7 +53,7 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
private EnumSet<EnumFacing> internalPowerSides = EnumSet.allOf( EnumFacing.class );
private final IEnergyStorage forgeEnergyAdapter;
private Object teslaEnergyAdapter;
private GTCEEnergyAdapter gtceEnergyAdapter = null;
private IC2PowerSink ic2Sink;
public AEBasePoweredTile()
@@ -63,11 +63,6 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
{
this.teslaEnergyAdapter = new TeslaEnergyAdapter( this );
}
if( Capabilities.GTCE_ENERGY != null )
{
this.gtceEnergyAdapter = new GTCEEnergyAdapter( this );
}
this.ic2Sink = Integrations.ic2().createPowerSink( this, this );
this.ic2Sink.setValidFaces( this.internalPowerSides );
}
@@ -289,13 +284,6 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
return true;
}
}
else if( capability == Capabilities.GTCE_ENERGY )
{
if( this.getPowerSides().contains( facing ) )
{
return true;
}
}
return super.hasCapability( capability, facing );
}
@@ -318,14 +306,7 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
return (T) this.teslaEnergyAdapter;
}
}
else if( capability == Capabilities.GTCE_ENERGY )
{
if( this.getPowerSides().contains( facing ) )
{
return (T) this.gtceEnergyAdapter;
}
}
return super.getCapability( capability, facing );
}
@@ -1,89 +0,0 @@
package appeng.tile.powersink;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
import gregtech.api.capability.IEnergyContainer;
import net.minecraft.util.EnumFacing;
public class GTCEEnergyAdapter implements IEnergyContainer
{
private final IExternalPowerSink sink;
double EUBuffer;
GTCEEnergyAdapter( IExternalPowerSink sink )
{
this.sink = sink;
}
@Override
public long acceptEnergyFromNetwork( EnumFacing enumFacing, long voltage, long amperage )
{
final double power = voltage * amperage;
final double oldBuffer = EUBuffer;
EUBuffer = this.sink.injectExternalPower( PowerUnits.GTCEU, power + EUBuffer, Actionable.MODULATE );
// if the overflow went down, all inputs were consumed
if ( EUBuffer <= oldBuffer )
{
return amperage;
}
// if overflow is greater than the inputs, nothing was consumed
if ( EUBuffer >= power )
{
EUBuffer -= power;
return 0;
}
// determine how many amps are being used
final double usedEU = power + oldBuffer - EUBuffer;
final long ampsUsed = (long) Math.ceil( usedEU / ( (double) voltage ) );
// adjust the overflow
EUBuffer += usedEU % voltage;
return ampsUsed;
}
@Override
public boolean inputsEnergy( EnumFacing enumFacing )
{
return true;
}
@Override
public long changeEnergy( long l )
{
return 0;
}
@Override
public long getEnergyStored()
{
return (long) Math.floor( PowerUnits.AE.convertTo( PowerUnits.GTCEU, this.sink.getAECurrentPower() ) );
}
@Override
public long getEnergyCapacity()
{
return (long) Math.floor( PowerUnits.AE.convertTo( PowerUnits.GTCEU, this.sink.getAEMaxPower() ) );
}
@Override
public long getInputAmperage()
{
return 0;
}
@Override
public long getInputVoltage()
{
return 0;
}
@Override
public long getEnergyCanBeInserted()
{
return this.getEnergyCapacity() - this.getEnergyStored();
}
}
+1 -1
View File
@@ -1226,7 +1226,7 @@ public class Platform
Preconditions.checkNotNull( src );
Preconditions.checkNotNull( mode );
final T possible = cell.injectItems( input, Actionable.SIMULATE, src );
final T possible = cell.injectItems( input.copy(), Actionable.SIMULATE, src );
long stored = input.getStackSize();
if( possible != null )
@@ -12,198 +12,198 @@ import java.util.Iterator;
public class AdaptorItemRepository extends InventoryAdaptor
{
protected final IItemRepository itemRepository;
protected final IItemRepository itemRepository;
public AdaptorItemRepository( IItemRepository itemRepository )
{
this.itemRepository = itemRepository;
}
public AdaptorItemRepository( IItemRepository itemRepository )
{
this.itemRepository = itemRepository;
}
@Override
public ItemStack removeItems( int amount, ItemStack filter, IInventoryDestination destination )
{
ItemStack rv = ItemStack.EMPTY;
ItemStack extracted = ItemStack.EMPTY;
@Override
public ItemStack removeItems( int amount, ItemStack filter, IInventoryDestination destination )
{
ItemStack rv = ItemStack.EMPTY;
ItemStack extracted = ItemStack.EMPTY;
if( !filter.isEmpty() )
{
extracted = this.itemRepository.extractItem( filter, amount, true );
}
else
{
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
{
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
if( !extracted.isEmpty() )
{
break;
}
}
}
if( !filter.isEmpty() )
{
extracted = this.itemRepository.extractItem( filter, amount, true );
}
else
{
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
{
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
if( !extracted.isEmpty() )
{
break;
}
}
}
if( destination != null )
{
if( destination != null )
{
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
{
return rv;
}
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
{
return rv;
}
}
}
extracted = this.itemRepository.extractItem( filter.isEmpty() ? extracted : filter, amount, false );
extracted = this.itemRepository.extractItem( filter, amount, false );
return extracted;
}
return extracted;
}
@Override
public ItemStack simulateRemove( int amount, ItemStack filter, IInventoryDestination destination )
{
ItemStack rv = ItemStack.EMPTY;
ItemStack extracted = ItemStack.EMPTY;
@Override
public ItemStack simulateRemove( int amount, ItemStack filter, IInventoryDestination destination )
{
ItemStack rv = ItemStack.EMPTY;
ItemStack extracted = ItemStack.EMPTY;
if( !filter.isEmpty() )
{
extracted = this.itemRepository.extractItem( filter, amount, true );
}
else
{
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
{
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
if( !extracted.isEmpty() )
{
break;
}
}
}
if( !filter.isEmpty() )
{
extracted = this.itemRepository.extractItem( filter, amount, true );
}
else
{
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
{
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
if( !extracted.isEmpty() )
{
break;
}
}
}
if( destination != null )
{
if( destination != null )
{
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
{
return rv;
}
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
{
return rv;
}
}
}
return extracted;
}
return extracted;
}
@Override
public ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
{
ItemStack rv = ItemStack.EMPTY;
ItemStack extracted = ItemStack.EMPTY;
@Override
public ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
{
ItemStack rv = ItemStack.EMPTY;
ItemStack extracted = ItemStack.EMPTY;
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
{
if( Platform.itemComparisons().isFuzzyEqualItem( record.itemPrototype, filter, fuzzyMode ) )
{
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
}
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
{
if( Platform.itemComparisons().isFuzzyEqualItem( record.itemPrototype, filter, fuzzyMode ) )
{
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
}
if( !extracted.isEmpty() )
{
break;
}
}
if( !extracted.isEmpty() )
{
break;
}
}
if( destination != null )
{
if( destination != null )
{
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
{
return rv;
}
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
{
return rv;
}
}
}
extracted = this.itemRepository.extractItem( extracted, amount, false );
extracted = this.itemRepository.extractItem( extracted, amount, false );
return extracted;
}
return extracted;
}
@Override
public ItemStack simulateSimilarRemove( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
{
ItemStack rv = ItemStack.EMPTY;
ItemStack extracted = ItemStack.EMPTY;
@Override
public ItemStack simulateSimilarRemove( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
{
ItemStack rv = ItemStack.EMPTY;
ItemStack extracted = ItemStack.EMPTY;
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
{
if( Platform.itemComparisons().isFuzzyEqualItem( record.itemPrototype, filter, fuzzyMode ) )
{
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
}
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
{
if( Platform.itemComparisons().isFuzzyEqualItem( record.itemPrototype, filter, fuzzyMode ) )
{
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
}
if( !extracted.isEmpty() )
{
break;
}
}
if( !extracted.isEmpty() )
{
break;
}
}
if( destination != null )
{
if( destination != null )
{
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
{
return rv;
}
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
{
return rv;
}
}
}
return extracted;
}
return extracted;
}
@Override
public ItemStack addItems( ItemStack toBeAdded )
{
return this.addItems( toBeAdded, false );
}
@Override
public ItemStack addItems( ItemStack toBeAdded )
{
return this.addItems( toBeAdded, false );
}
protected ItemStack addItems( final ItemStack itemsToAdd, final boolean simulate )
{
if( itemsToAdd.isEmpty() )
{
return ItemStack.EMPTY;
}
protected ItemStack addItems( final ItemStack itemsToAdd, final boolean simulate )
{
if( itemsToAdd.isEmpty() )
{
return ItemStack.EMPTY;
}
ItemStack left = itemsToAdd.copy();
ItemStack left = itemsToAdd.copy();
left = this.itemRepository.insertItem( left, simulate );
left = this.itemRepository.insertItem( left, simulate );
if( left.isEmpty() )
{
return ItemStack.EMPTY;
}
if( left.isEmpty() )
{
return ItemStack.EMPTY;
}
return left;
}
return left;
}
@Override
public ItemStack simulateAdd( ItemStack toBeSimulated )
{
return this.addItems( toBeSimulated, true );
}
@Override
public ItemStack simulateAdd( ItemStack toBeSimulated )
{
return this.addItems( toBeSimulated, true );
}
@Override
public boolean containsItems()
{
return !this.itemRepository.getAllItems().isEmpty();
}
@Override
public boolean containsItems()
{
return !this.itemRepository.getAllItems().isEmpty();
}
@Override
public boolean hasSlots()
{
return true;
}
@Override
public boolean hasSlots()
{
return true;
}
@Override
public Iterator<ItemSlot> iterator()
{
return null;
}
@Override
public Iterator<ItemSlot> iterator()
{
return null;
}
}
@@ -1,26 +0,0 @@
package appeng.util.inv;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
public abstract class BlockingInventoryAdaptor implements Iterable<ItemSlot>
{
public static BlockingInventoryAdaptor getAdaptor( final TileEntity te, final EnumFacing d )
{
if( te != null && te.hasCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d ) )
{
// Attempt getting an IItemHandler for the given side via caps
IItemHandler itemHandler = te.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d );
if( itemHandler != null )
{
return new BlockingItemHandler( itemHandler, te.getBlockType().getRegistryName().getResourceDomain() );
}
}
return null;
}
public abstract boolean containsBlockingItems();
}
@@ -1,58 +0,0 @@
package appeng.util.inv;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.helpers.NonBlockingItems;
import appeng.util.item.AEItemStack;
import appeng.util.item.ItemList;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
public class BlockingItemHandler extends BlockingInventoryAdaptor
{
protected final IItemHandler itemHandler;
private final String domain;
public BlockingItemHandler( IItemHandler itemHandler, String domain )
{
this.itemHandler = itemHandler;
this.domain = domain;
}
boolean isBlockableItem( ItemStack stack )
{
IItemList<IAEItemStack> itemList = NonBlockingItems.INSTANCE.getMap().get( domain );
Collection<IAEItemStack> item = itemList.findFuzzy( AEItemStack.fromItemStack( stack ), FuzzyMode.IGNORE_ALL );
return item.isEmpty();
}
@Override
public boolean containsBlockingItems()
{
int slots = this.itemHandler.getSlots();
for( int slot = 0; slot < slots; slot++ )
{
ItemStack is = this.itemHandler.getStackInSlot( slot );
if( is.isEmpty() || !isBlockableItem( is ) )
{
continue;
}
return true;
}
return false;
}
@Override
public Iterator<ItemSlot> iterator()
{
return new ItemHandlerIterator( this.itemHandler );
}
}
+24 -53
View File
@@ -25,7 +25,6 @@ import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.common.primitives.Ints;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -52,7 +51,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
@SideOnly(Side.CLIENT)
private String displayName;
@SideOnly( Side.CLIENT )
@SideOnly(Side.CLIENT)
private List<String> tooltip;
private ItemStack cachedItemStack;
@@ -237,83 +236,56 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
}
@Override
public boolean equals( final Object ia )
{
if( ia instanceof AEItemStack )
{
return this.isSameType( (AEItemStack) ia );
}
else if( ia instanceof ItemStack )
{
public boolean equals(final Object ia) {
if (ia instanceof AEItemStack) {
return this.isSameType((AEItemStack) ia);
} else if (ia instanceof ItemStack) {
// this actually breaks the equals contract (being equals to unrelated classes)
return equals( (ItemStack) ia );
return equals((ItemStack) ia);
}
return false;
}
@Override
public boolean equals( final ItemStack is )
{
return this.isSameType( is );
public boolean equals(final ItemStack is) {
return this.isSameType(is);
}
@Override
public ItemStack getCachedItemStack( long stackSize )
public ItemStack getCachedItemStack()
{
@Nullable ItemStack currentCached = this.cachedItemStack;
cachedItemStack = ItemStack.EMPTY;
ItemStack itemStack;
if( currentCached != null )
{
// Cache is suitable, just update the count
itemStack = currentCached;
currentCached.setCount( Ints.saturatedCast( stackSize ) );
}
else
{
// We need a new stack :-(
itemStack = this.createItemStack();
}
return itemStack;
return this.cachedItemStack;
}
@Override
public void setCachedItemStack( ItemStack itemStack )
public void setCachedItemStack( ItemStack is )
{
this.cachedItemStack = itemStack;
this.cachedItemStack = is;
}
@Override
public String toString()
{
public String toString() {
return this.getStackSize() + "x" + this.getDefinition().getItem().getRegistryName();
}
@SideOnly( Side.CLIENT )
public List<String> getToolTip()
{
if( this.tooltip == null )
{
this.tooltip = Platform.getTooltip( this.asItemStackRepresentation() );
@SideOnly(Side.CLIENT)
public List<String> getToolTip() {
if (this.tooltip == null) {
this.tooltip = Platform.getTooltip(this.asItemStackRepresentation());
}
return this.tooltip;
}
@SideOnly( Side.CLIENT )
public String getDisplayName()
{
if( this.displayName == null )
{
this.displayName = Platform.getItemDisplayName( this.asItemStackRepresentation() );
@SideOnly(Side.CLIENT)
public String getDisplayName() {
if (this.displayName == null) {
this.displayName = Platform.getItemDisplayName(this.asItemStackRepresentation());
}
return this.displayName;
}
@SideOnly( Side.CLIENT )
public String getModID()
{
@SideOnly(Side.CLIENT)
public String getModID() {
return this.getDefinition().getItem().getRegistryName().getResourceDomain();
}
@@ -323,8 +295,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
}
@Override
public boolean hasTagCompound()
{
public boolean hasTagCompound() {
return this.getDefinition().hasTagCompound();
}
@@ -22,78 +22,72 @@ import java.util.Objects;
import com.google.common.base.Preconditions;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
final class AESharedItemStack {
final class AESharedItemStack
{
private final ItemStack itemStack;
private final int itemId;
private final int itemDamage;
private final int hashCode;
private final ItemStack itemStack;
private final int itemDamage;
private final int hashCode;
public AESharedItemStack(final ItemStack itemStack) {
this(itemStack, itemStack.getItemDamage());
}
public AESharedItemStack( final ItemStack itemStack )
{
this( itemStack, itemStack.getItemDamage() );
}
/**
* A constructor to explicitly set the damage value and not fetch it from the {@link ItemStack}
*
* @param itemStack The {@link ItemStack} to filter
* @param damage The damage of the item
*/
private AESharedItemStack(ItemStack itemStack, int damage) {
this.itemStack = itemStack;
this.itemId = Item.getIdFromItem(itemStack.getItem());
this.itemDamage = damage;
/**
* A constructor to explicitly set the damage value and not fetch it from the {@link ItemStack}
*
* @param itemStack The {@link ItemStack} to filter
* @param damage The damage of the item
*/
private AESharedItemStack( ItemStack itemStack, int damage )
{
this.itemStack = itemStack;
this.itemDamage = damage;
// Ensure this is always called last.
this.hashCode = this.makeHashCode();
}
// Ensure this is always called last.
this.hashCode = this.makeHashCode();
}
ItemStack getDefinition() {
return this.itemStack;
}
ItemStack getDefinition()
{
return this.itemStack;
}
int getItemDamage() {
return this.itemDamage;
}
int getItemDamage()
{
return this.itemDamage;
}
@Override
public int hashCode() {
return this.hashCode;
}
@Override
public int hashCode()
{
return this.hashCode;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof AESharedItemStack)) {
return false;
}
@Override
public boolean equals( final Object obj )
{
if( this == obj )
{
return true;
}
if( !( obj instanceof AESharedItemStack ) )
{
return false;
}
final AESharedItemStack other = (AESharedItemStack) obj;
Preconditions.checkState(this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1");
Preconditions.checkArgument(other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1");
final AESharedItemStack other = (AESharedItemStack) obj;
Preconditions.checkState( this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1" );
Preconditions.checkArgument( other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1" );
if (this.itemStack == other.itemStack) {
return true;
}
return ItemStack.areItemStacksEqual(this.itemStack, other.itemStack);
}
if( this.itemStack == other.itemStack )
{
return true;
}
return ItemStack.areItemStacksEqual( this.itemStack, other.itemStack );
}
private int makeHashCode()
{
return Objects.hash( this.itemStack.getItem(), this.itemDamage, this.itemStack.hasTagCompound() ? this.itemStack.getTagCompound() : 0 );
}
private int makeHashCode() {
return Objects.hash(
this.itemId,
this.itemDamage,
this.itemStack.hasTagCompound() ? this.itemStack.getTagCompound() : 0);
}
}
@@ -1,383 +0,0 @@
package appeng.util.item;
import java.util.ArrayList;
import java.util.List;
/**
* @author brachy84
* @butcherer PrototypeTrousers
*/
public class OreDictFilterMatcher
{
/**
* Parses the given expression and creates a List.
*
* @param expression expr to parse
* @return match rule list
*/
public static List<MatchRule> parseExpression( String expression )
{
List<MatchRule> rules = new ArrayList<>();
parseExpression( rules, expression );
return rules;
}
/**
* Parses the given expression and puts them into the given list.
*
* @param rules list to fill
* @param expression expr to parse
* @return the position of the expr. Is only relevant for sub rules
*/
public static int parseExpression( List<MatchRule> rules, String expression )
{
rules.clear();
StringBuilder builder = new StringBuilder();
for( int i = 0; i < expression.length(); i++ )
{
char c = expression.charAt( i );
if( c == ' ' )
{
continue;
}
if( c == '(' )
{
List<MatchRule> subRules = new ArrayList<>();
i = parseExpression( subRules, expression.substring( i + 1 ) ) + i + 1;
rules.add( MatchRule.group( subRules, builder.toString() ) );
builder = new StringBuilder();
}
else
{
switch ( c )
{
case '&':
rules.add( new MatchRule( builder.toString() ) );
rules.add( new MatchRule( MatchLogic.AND ) );
builder = new StringBuilder();
break;
case '|':
rules.add( new MatchRule( builder.toString() ) );
rules.add( new MatchRule( MatchLogic.OR ) );
builder = new StringBuilder();
break;
case '^':
rules.add( new MatchRule( builder.toString() ) );
rules.add( new MatchRule( MatchLogic.XOR ) );
builder = new StringBuilder();
break;
case ')':
rules.add( new MatchRule( builder.toString() ) );
return i + 1;
default:
builder.append( c );
}
}
}
if( builder.length() > 0 )
{
rules.add( new MatchRule( builder.toString() ) );
}
return expression.length();
}
/**
* Matches the given string against a list of rules.
* The string does not have to be an oreDict.
*
* @param rules to check against
* @param oreDict string to check
* @return if the string matches the rules
*/
public static boolean matches( List<MatchRule> rules, String oreDict )
{
boolean first = true;
boolean lastResult = false;
MatchLogic lastLogic = null;
for( MatchRule rule : rules )
{
if( lastLogic == null )
{
if( rule.logic == MatchLogic.AND || rule.logic == MatchLogic.OR || rule.logic == MatchLogic.XOR )
{
lastLogic = rule.logic;
continue;
}
}
if( lastLogic != null || first )
{
if( lastLogic != null )
{
switch ( lastLogic )
{
case AND:
{
if( !lastResult )
{
return false;
}
break;
}
case OR:
{
if( lastResult )
{
return true;
}
break;
}
}
}
boolean newResult;
if( rule.isGroup() )
{
newResult = rule.logic == MatchLogic.NOT ^ matches( rule.subRules, oreDict );
}
else
{
newResult = matches( rule, oreDict );
}
if( lastLogic == MatchLogic.XOR )
{
if( lastResult == newResult )
{
return false;
}
}
lastLogic = null;
lastResult = newResult;
first = false;
}
}
return lastResult;
}
private static boolean matches( MatchRule rule, String oreDict )
{
String filter = rule.expression;
if( filter.equals( "*" ) )
{
return true;
}
boolean startWild = filter.startsWith( "*" ), endWild = filter.endsWith( "*" );
if( startWild )
{
filter = filter.substring( 1 );
}
String[] parts = filter.split( "\\*+" );
return ( rule.logic == MatchLogic.NOT ) ^ matches( parts, oreDict, startWild, endWild );
}
private static boolean matches( String[] filter, String oreDict, boolean startWild, boolean endWild )
{
String lastlastPart = filter[0];
String lastPart = filter[0];
int index = oreDict.indexOf( lastPart );
if( ( !startWild && index != 0 ) || index < 0 )
{
return false;
}
boolean didGoBack = false;
for( int i = 1; i < filter.length; i++ )
{
String part = filter[i];
int newIndex = oreDict.indexOf( part, index + lastPart.length() );
if( newIndex < 0 )
{
if( i > 1 && !didGoBack )
{
i -= 2;
lastPart = lastlastPart;
didGoBack = true;
continue;
}
return false;
}
lastlastPart = lastPart;
lastPart = part;
index = newIndex;
if( didGoBack )
{
didGoBack = false;
}
}
if( endWild || lastPart.length() + index == oreDict.length() )
{
return true;
}
for( int i = filter.length - 1; i < filter.length; i++ )
{
String part = filter[i];
int newIndex = oreDict.indexOf( part, index + lastPart.length() );
if( newIndex < 0 )
{
if( i > 1 && !didGoBack )
{
i -= 2;
lastPart = lastlastPart;
didGoBack = true;
continue;
}
return false;
}
lastlastPart = lastPart;
lastPart = part;
index = newIndex;
if( didGoBack )
{
didGoBack = false;
}
}
return lastPart.length() + index == oreDict.length();
}
public static String validateExp( String input )
{
// remove all operators that are double
input = input.replaceAll( "\\*{2,}", "*" );
input = input.replaceAll( "&{2,}", "&" );
input = input.replaceAll( "\\|{2,}", "|" );
input = input.replaceAll( "!{2,}", "!" );
input = input.replaceAll( "\\^{2,}", "^" );
input = input.replaceAll( " {2,}", " " );
// move ( and ) so it doesn't create invalid expressions f.e. xxx (& yyy) => xxx & (yyy)
// append or prepend ( and ) if the amount is not equal
StringBuilder builder = new StringBuilder();
int unclosed = 0;
char last = ' ';
for( int i = 0; i < input.length(); i++ )
{
char c = input.charAt( i );
if( c == ' ' )
{
if( last != '(' )
{
builder.append( " " );
}
continue;
}
if( c == '(' )
{
unclosed++;
}
else if( c == ')' )
{
unclosed--;
if( last == '&' || last == '|' || last == '^' )
{
int l = builder.lastIndexOf( " " + last );
int l2 = builder.lastIndexOf( "" + last );
builder.insert( l == l2 - 1 ? l : l2, ")" );
continue;
}
if( i > 0 && builder.charAt( builder.length() - 1 ) == ' ' )
{
builder.deleteCharAt( builder.length() - 1 );
}
}
else if( ( c == '&' || c == '|' || c == '^' ) && last == '(' )
{
builder.deleteCharAt( builder.lastIndexOf( "(" ) );
builder.append( c ).append( " (" );
continue;
}
builder.append( c );
last = c;
}
if( unclosed > 0 )
{
for( int i = 0; i < unclosed; i++ )
{
builder.append( ")" );
}
}
else if( unclosed < 0 )
{
unclosed = -unclosed;
for( int i = 0; i < unclosed; i++ )
{
builder.insert( 0, "(" );
}
}
input = builder.toString();
input = input.replaceAll( " {2,}", " " );
return input;
}
public static class MatchRule
{
public final MatchLogic logic;
public final String expression;
private final List<MatchRule> subRules;
private MatchRule( MatchLogic logic, String expression, List<MatchRule> subRules )
{
if( expression.startsWith( "!" ) )
{
logic = MatchLogic.NOT;
expression = expression.substring( 1 );
}
this.logic = logic;
this.expression = expression;
this.subRules = subRules;
}
public MatchRule( MatchLogic logic, String expression )
{
this( logic, expression, null );
}
public MatchRule( MatchLogic logic )
{
this( logic, "" );
}
public MatchRule( String expression )
{
this( MatchLogic.ANY, expression );
}
public static MatchRule not( String expression, boolean not )
{
return new MatchRule( not ? MatchLogic.NOT : MatchLogic.ANY, expression );
}
public static MatchRule group( List<MatchRule> subRules, String expression )
{
MatchLogic logic = expression.startsWith( "!" ) ? MatchLogic.NOT : MatchLogic.ANY;
return new MatchRule( logic, "", subRules );
}
public boolean isGroup()
{
return subRules != null;
}
}
public enum MatchLogic
{
OR,
AND,
XOR,
NOT,
ANY
}
}
+200 -164
View File
@@ -19,208 +19,244 @@
package appeng.util.item;
import appeng.api.storage.data.IAEItemStack;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.*;
import appeng.api.storage.data.IAEItemStack;
public class OreHelper
{
public static final OreHelper INSTANCE = new OreHelper();
public static final OreHelper INSTANCE = new OreHelper();
/**
* A local cache to speed up OreDictionary lookups.
*/
private final LoadingCache<String, List<ItemStack>> oreDictCache = CacheBuilder.newBuilder().build( new CacheLoader<String, List<ItemStack>>()
{
@Override
public List<ItemStack> load( final String oreName )
{
return OreDictionary.getOres( oreName );
}
} );
/**
* A local cache to speed up OreDictionary lookups.
*/
private final LoadingCache<String, List<ItemStack>> oreDictCache = CacheBuilder.newBuilder().build( new CacheLoader<String, List<ItemStack>>()
{
@Override
public List<ItemStack> load( final String oreName )
{
return OreDictionary.getOres( oreName );
}
} );
private final Map<ItemRef, OreReference> references = new HashMap<>();
private final Map<ItemRef, OreReference> references = new HashMap<>();
/**
* Test if the passed {@link ItemStack} is an ore.
*
* @param itemStack the itemstack to test
* @return true if an ore entry exists, false otherwise
*/
public Optional<OreReference> getOre( final ItemStack itemStack )
{
final ItemRef ir = new ItemRef( itemStack );
/**
* Test if the passed {@link ItemStack} is an ore.
*
* @param itemStack the itemstack to test
*
* @return true if an ore entry exists, false otherwise
*/
public Optional<OreReference> getOre( final ItemStack itemStack )
{
final ItemRef ir = new ItemRef( itemStack );
if( !this.references.containsKey( ir ) )
{
final OreReference ref = new OreReference();
final Collection<Integer> ores = ref.getOres();
final Collection<String> set = ref.getEquivalents();
if( !this.references.containsKey( ir ) )
{
final OreReference ref = new OreReference();
final Collection<Integer> ores = ref.getOres();
final Collection<String> set = ref.getEquivalents();
final Set<String> toAdd = new HashSet<>();
final Set<String> toAdd = new HashSet<>();
for( final String ore : OreDictionary.getOreNames() )
{
// skip ore if it is a match already or null.
if( ore == null || toAdd.contains( ore ) )
{
continue;
}
for( final String ore : OreDictionary.getOreNames() )
{
// skip ore if it is a match already or null.
if( ore == null || toAdd.contains( ore ) )
{
continue;
}
for( final ItemStack oreItem : this.oreDictCache.getUnchecked( ore ) )
{
if( OreDictionary.itemMatches( oreItem, itemStack, false ) )
{
toAdd.add( ore );
break;
}
}
}
for( final ItemStack oreItem : this.oreDictCache.getUnchecked( ore ) )
{
if( OreDictionary.itemMatches( oreItem, itemStack, false ) )
{
toAdd.add( ore );
break;
}
}
}
for( final String ore : toAdd )
{
set.add( ore );
ores.add( OreDictionary.getOreID( ore ) );
}
for( final String ore : toAdd )
{
set.add( ore );
ores.add( OreDictionary.getOreID( ore ) );
}
if( !set.isEmpty() )
{
this.references.put( ir, ref );
}
else
{
this.references.put( ir, null );
}
}
if( !set.isEmpty() )
{
this.references.put( ir, ref );
}
else
{
this.references.put( ir, null );
}
}
return Optional.ofNullable( this.references.get( ir ) );
}
return Optional.ofNullable( this.references.get( ir ) );
}
boolean sameOre( final AEItemStack aeItemStack, final IAEItemStack is )
{
final OreReference a = aeItemStack.getOre().orElse( null );
final OreReference b = ( (AEItemStack) is ).getOre().orElse( null );
boolean sameOre( final AEItemStack aeItemStack, final IAEItemStack is )
{
final OreReference a = aeItemStack.getOre().orElse( null );
final OreReference b = ( (AEItemStack) is ).getOre().orElse( null );
return this.sameOre( a, b );
}
return this.sameOre( a, b );
}
public boolean sameOre( final OreReference a, final OreReference b )
{
if( a == null || b == null )
{
return false;
}
public boolean sameOre( final OreReference a, final OreReference b )
{
if( a == null || b == null )
{
return false;
}
if( a == b )
{
return true;
}
if( a == b )
{
return true;
}
final Collection<Integer> bOres = b.getOres();
for( final Integer ore : a.getOres() )
{
if( bOres.contains( ore ) )
{
return true;
}
}
final Collection<Integer> bOres = b.getOres();
for( final Integer ore : a.getOres() )
{
if( bOres.contains( ore ) )
{
return true;
}
}
return false;
}
return false;
}
boolean sameOre( final AEItemStack aeItemStack, final ItemStack o )
{
return aeItemStack.getOre().map( a -> {
for( final String oreName : a.getEquivalents() )
{
for( final ItemStack oreItem : this.oreDictCache.getUnchecked( oreName ) )
{
if( OreDictionary.itemMatches( oreItem, o, false ) )
{
return true;
}
}
}
return false;
} ).orElse( false );
}
boolean sameOre( final AEItemStack aeItemStack, final ItemStack o )
{
return aeItemStack.getOre().map( a ->
{
for( final String oreName : a.getEquivalents() )
{
for( final ItemStack oreItem : this.oreDictCache.getUnchecked( oreName ) )
{
if( OreDictionary.itemMatches( oreItem, o, false ) )
{
return true;
}
}
}
return false;
} ).orElse( false );
}
public Set<Integer> getMatchingOre( String oreExp )
{
Set<Integer> matchingIds = new HashSet<>();
public Set<Integer> getMatchingOre( String allow )
{
List<String> matchingOres = new ArrayList<>();
ConcurrentMap<String, List<ItemStack>> oreKeys = oreDictCache.asMap();
List<OreDictFilterMatcher.MatchRule> rulesList = OreDictFilterMatcher.parseExpression( oreExp );
for( String ore : OreDictionary.getOreNames() )
{
if( OreDictFilterMatcher.matches( rulesList, ore ) )
{
matchingIds.add( OreDictionary.getOreID( ore ) );
}
}
return matchingIds;
}
oreKeys.forEach( ( s, l ) -> {
public List<ItemStack> getCachedOres( final String oreName )
{
return this.oreDictCache.getUnchecked( oreName );
}
if( allow.startsWith( "*" ) && allow.endsWith( "*" ) )
{
if( s.contains( allow.substring( 1, allow.length() - 1 ) ) )
{
matchingOres.add( s );
}
}
else if( allow.startsWith( "*" ) )
{
if( s.endsWith( allow.substring( 1 ) ) )
{
matchingOres.add( s );
}
}
else if( allow.endsWith( "*" ) )
{
if( s.startsWith( allow.substring( 0, allow.length() - 1 ) ) )
{
matchingOres.add( s );
}
}
else
{
if( s.matches( allow ) )
{
matchingOres.add( s );
}
}
} );
private static class ItemRef
{
Set<Integer> oreIDs = new HashSet<>();
for( String matchingOre : matchingOres )
{
oreIDs.add( OreDictionary.getOreID( matchingOre ) );
}
private final Item ref;
private final int damage;
private final int hash;
return oreIDs;
}
ItemRef( final ItemStack stack )
{
this.ref = stack.getItem();
List<ItemStack> getCachedOres( final String oreName )
{
return this.oreDictCache.getUnchecked( oreName );
}
if( stack.getItem().isDamageable() )
{
this.damage = 0; // IGNORED
}
else
{
this.damage = stack.getItemDamage(); // might be important...
}
private static class ItemRef
{
this.hash = this.ref.hashCode() ^ this.damage;
}
private final Item ref;
private final int damage;
private final int hash;
@Override
public int hashCode()
{
return this.hash;
}
ItemRef( final ItemStack stack )
{
this.ref = stack.getItem();
@Override
public boolean equals( final Object obj )
{
if( obj == null )
{
return false;
}
if( this.getClass() != obj.getClass() )
{
return false;
}
final ItemRef other = (ItemRef) obj;
return this.damage == other.damage && this.ref == other.ref;
}
if( stack.getItem().isDamageable() )
{
this.damage = 0; // IGNORED
}
else
{
this.damage = stack.getItemDamage(); // might be important...
}
@Override
public String toString()
{
return "ItemRef [ref=" + this.ref.getUnlocalizedName() + ", damage=" + this.damage + ", hash=" + this.hash + ']';
}
}
this.hash = this.ref.hashCode() ^ this.damage;
}
@Override
public int hashCode()
{
return this.hash;
}
@Override
public boolean equals( final Object obj )
{
if( obj == null )
{
return false;
}
if( this.getClass() != obj.getClass() )
{
return false;
}
final ItemRef other = (ItemRef) obj;
return this.damage == other.damage && this.ref == other.ref;
}
@Override
public String toString()
{
return "ItemRef [ref=" + this.ref.getUnlocalizedName() + ", damage=" + this.damage + ", hash=" + this.hash + ']';
}
}
}
@@ -102,7 +102,6 @@ gui.appliedenergistics2.FluidTunnel=Fluid
gui.appliedenergistics2.RedstoneTunnel=Redstone
gui.appliedenergistics2.EUTunnel=EU
gui.appliedenergistics2.FETunnel=FE
gui.appliedenergistics2.GTCEUTunnel=GTCEU
gui.appliedenergistics2.LightTunnel=Light
gui.appliedenergistics2.OCTunnel=OpenComputers
gui.appliedenergistics2.PressureTunnel=Pressure
@@ -376,7 +375,6 @@ gui.tooltips.appliedenergistics2.HighlightInterface=Highlight interface
gui.appliedenergistics2.units.appliedenergstics=AE
gui.appliedenergistics2.units.ic2=Energy Units
gui.appliedenergistics2.units.rf=Redstone Flux
gui.appliedenergistics2.units.gtceu=GTCEU
// Colors
gui.appliedenergistics2.White=White
@@ -1,6 +0,0 @@
{
"parent": "appliedenergistics2:item/part/p2p_tunnel",
"textures": {
"type": "appliedenergistics2:parts/p2p/power_gtceu"
}
}
@@ -1,6 +0,0 @@
{
"parent": "appliedenergistics2:part/p2p/p2p_tunnel_base",
"textures": {
"type": "appliedenergistics2:parts/p2p/power_gtceu"
}
}
@@ -1,36 +0,0 @@
{
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:part_exists",
"part": "part.storage_bus"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:interface"
}
]
}
],
"result": {
"type": "appliedenergistics2:part",
"part": "part.oredict_storage_bus"
},
"type": "appliedenergistics2:part_shapeless",
"ingredients": [
{
"item": "minecraft:sticky_piston"
},
{
"item": "#appliedenergistics2:interface"
},
{
"item": "minecraft:piston"
},
{
"item": "minecraft:book"
}
]
}
@@ -1,31 +0,0 @@
{
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:part_exists",
"part": "part.storage_bus"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:interface"
}
]
}
],
"result": {
"type": "appliedenergistics2:part",
"part": "part.oredict_storage_bus"
},
"type": "appliedenergistics2:part_shapeless",
"ingredients": [
{
"type": "appliedenergistics2:part",
"part": "part.storage_bus"
},
{
"item": "minecraft:book"
}
]
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 B

@@ -1,6 +0,0 @@
{
"parent": "item/generated",
"textures": {
"layer0": "base:items/wrench"
}
}
+11 -11
View File
@@ -1,17 +1,17 @@
[
{
"modid": "appliedenergistics2",
"name": "AE2 Unofficial Extended Life",
"description": "A Mod about Matter, Energy and using them to conquer the world..",
"version": "${version}",
"mcversion": "${mcversion}",
"url": "https://github.com/PrototypeTrousers/Applied-Energistics-2",
"updateUrl": "",
"authorList": [
"AlgorithmX2"
"modid":"appliedenergistics2",
"name":"Applied Energistics 2 Trousers Edition",
"description":"A Mod about Matter, Energy and using them to conquer the world..",
"version":"${version}",
"mcversion":"${mcversion}",
"url":"https://github.com/PrototypeTrousers/Applied-Energistics-2",
"updateUrl":"",
"authorList":[
"AlgorithmX2"
],
"credits": "AlgorithmX2",
"logoFile": "assets/appliedenergistics2/meta/logo.png",
"credits":"AlgorithmX2",
"logoFile":"assets/appliedenergistics2/meta/logo.png",
"screenshots":[]
}
]