diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle index 693942a092d..6f43161faa5 100644 --- a/gradle/scripts/dependencies.gradle +++ b/gradle/scripts/dependencies.gradle @@ -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,7 @@ configurations { } dependencies { - compileOnly "gregtechce:gregtech:1.12.2:1.15.1.735" + deobfCompile "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 +94,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" diff --git a/src/main/java/appeng/core/AEConfig.java b/src/main/java/appeng/core/AEConfig.java index 0f17c5018b3..f6a3a5be878 100644 --- a/src/main/java/appeng/core/AEConfig.java +++ b/src/main/java/appeng/core/AEConfig.java @@ -20,11 +20,7 @@ import java.io.File; -import java.util.Arrays; -import java.util.Collection; -import java.util.EnumSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Stream; import com.google.common.collect.Sets; @@ -64,10 +60,46 @@ 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 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" + }; // Default Energy Conversion Rates private static final double DEFAULT_IC2_EXCHANGE = 2.0; @@ -91,10 +123,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; @@ -126,7 +158,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; @@ -157,32 +189,24 @@ private AEConfig( final File configFile ) 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( "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( "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.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 ); @@ -190,23 +214,16 @@ private AEConfig( final File configFile ) 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 ); @@ -247,8 +264,7 @@ private AEConfig( final File configFile ) 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 ) { @@ -264,17 +280,13 @@ private AEConfig( final File configFile ) { 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; @@ -448,8 +460,7 @@ public boolean useAEVersion( final MaterialType mt ) 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() ); @@ -717,6 +728,11 @@ public int getQuartzOresClusterAmount() return this.quartzOresClusterAmount; } + public String[] getNonBlockingItems() + { + return nonBlockingItems; + } + public int getChargedChange() { return this.chargedChange; diff --git a/src/main/java/appeng/core/AppEng.java b/src/main/java/appeng/core/AppEng.java index 40c10a7ea81..8328f24daa9 100644 --- a/src/main/java/appeng/core/AppEng.java +++ b/src/main/java/appeng/core/AppEng.java @@ -25,6 +25,7 @@ import javax.annotation.Nonnull; +import appeng.helpers.NonBlockingItems; import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; @@ -183,8 +184,7 @@ private void preInit( final FMLPreInitializationEvent event ) AELog.info( "Pre Initialization ( ended after " + watch.elapsed( TimeUnit.MILLISECONDS ) + "ms )" ); // Instantiate all Plugins - List injectables = Lists.newArrayList( - AEApi.instance() ); + List injectables = Lists.newArrayList( AEApi.instance() ); new PluginLoader().loadPlugins( injectables, event.getAsmData() ); } diff --git a/src/main/java/appeng/core/features/AEFeature.java b/src/main/java/appeng/core/features/AEFeature.java index 6ad05692cd7..7cd4478c576 100644 --- a/src/main/java/appeng/core/features/AEFeature.java +++ b/src/main/java/appeng/core/features/AEFeature.java @@ -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 ), @@ -164,7 +164,6 @@ public boolean isVisible() 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 ), diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index ea575049cc3..42d87789021 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -23,7 +23,7 @@ import javax.annotation.Nullable; -import appeng.integration.modules.gregtech.GTCEInventoryAdaptor; +import appeng.util.inv.BlockingInventoryAdaptor; import appeng.util.*; import appeng.util.inv.*; import com.google.common.collect.ImmutableSet; @@ -32,7 +32,6 @@ 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; @@ -140,7 +139,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn private final Accessor accessor = new Accessor(); private EnumSet visitedFaces = EnumSet.noneOf( EnumFacing.class ); private EnumMap> waitingToSendFacing = new EnumMap<>( EnumFacing.class ); - private GTCEInventoryAdaptor GTad; + private BlockingInventoryAdaptor blockingInventoryAdaptor; private boolean resetConfigCache = true; private IMEMonitor configCachedHandler; @@ -887,7 +886,7 @@ else if( removed.getCount() != diff ) } } } - + if( this.craftingTracker.isBusy( x ) ) { changed = this.handleCrafting( x, adaptor, itemStack ) || changed; @@ -1108,9 +1107,9 @@ private boolean invIsBlocked( InventoryAdaptor inv ) return ( inv.containsItems() ); } - private static boolean invIsBlockedGTCE( GTCEInventoryAdaptor inv ) + private static boolean invIsCustomBlocking( BlockingInventoryAdaptor inv ) { - return ( !inv.canRemoveAllExceptCircuits() ); + return ( inv.containsBlockingItems() ); } @Override @@ -1167,24 +1166,26 @@ public boolean pushPattern( final ICraftingPatternDetails patternDetails, final { if( this.isBlocking() ) { - IPhantomTile phantomTE = null; - if( Loader.isModLoaded( "actuallyadditions" ) && Loader.isModLoaded( "gregtech" ) && te instanceof IPhantomTile ) + IPhantomTile phantomTE; + if( Loader.isModLoaded( "actuallyadditions" ) && te instanceof IPhantomTile ) { phantomTE = ( (IPhantomTile) te ); if( phantomTE.hasBoundPosition() ) { TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() ); - if( phantom instanceof MetaTileEntityHolder && isGTCEblocked( phantom, s ) ) + if( NonBlockingItems.INSTANCE.getMap().containsKey( phantom.getBlockType().getRegistryName().getResourceDomain() ) ) { - visitedFaces.remove( s ); - continue; + if( isCustomInvBlocking( phantom, s ) ) + { + visitedFaces.remove( s ); + continue; + } } } } - - else if( Loader.isModLoaded( "gregtech" ) && te instanceof MetaTileEntityHolder ) + else if( NonBlockingItems.INSTANCE.getMap().containsKey( te.getBlockType().getRegistryName().getResourceDomain() ) ) { - if( isGTCEblocked( te, s ) ) + if( isCustomInvBlocking( te, s ) ) { visitedFaces.remove( s ); continue; @@ -1239,7 +1240,7 @@ public boolean isBusy() for( final EnumFacing s : possibleDirections ) { final TileEntity te = w.getTileEntity( tile.getPos().offset( s ) ); - IPhantomTile phantomTE = null; + IPhantomTile phantomTE; final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() ); if( ad != null ) @@ -1250,17 +1251,20 @@ public boolean isBusy() if( phantomTE.hasBoundPosition() ) { TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() ); - if( phantom instanceof MetaTileEntityHolder && !isGTCEblocked( phantom, s ) ) + if( NonBlockingItems.INSTANCE.getMap().containsKey( phantom.getBlockType().getRegistryName().getResourceDomain() ) ) { - allAreBusy = false; - break; + if( !isCustomInvBlocking( phantom, s ) ) + { + allAreBusy = false; + break; + } } } } - else if( Loader.isModLoaded( "gregtech" ) && te instanceof MetaTileEntityHolder ) + else if( NonBlockingItems.INSTANCE.getMap().containsKey( te.getBlockType().getRegistryName().getResourceDomain() ) ) { - if( !isGTCEblocked( te, s ) ) + if( !isCustomInvBlocking( te, s ) ) { allAreBusy = false; break; @@ -1279,10 +1283,10 @@ else if( !invIsBlocked( ad ) ) return busy; } - boolean isGTCEblocked( TileEntity te, EnumFacing s ) + boolean isCustomInvBlocking( TileEntity te, EnumFacing s ) { - GTad = GTCEInventoryAdaptor.getAdaptor( te, s.getOpposite() ); - return invIsBlockedGTCE( GTad ); + blockingInventoryAdaptor = BlockingInventoryAdaptor.getAdaptor( te, s.getOpposite() ); + return invIsCustomBlocking( blockingInventoryAdaptor ); } private boolean sameGrid( final IGrid grid ) throws GridAccessException diff --git a/src/main/java/appeng/helpers/NonBlockingItems.java b/src/main/java/appeng/helpers/NonBlockingItems.java new file mode 100644 index 00000000000..20a9eede9e4 --- /dev/null +++ b/src/main/java/appeng/helpers/NonBlockingItems.java @@ -0,0 +1,86 @@ +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.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.Loader; + +import java.util.*; + + +public class NonBlockingItems +{ + public static final NonBlockingItems INSTANCE = new NonBlockingItems(); + public static Map> NON_BLOCKING_MAP; + + NonBlockingItems() + { + NON_BLOCKING_MAP = new HashMap<>(); + 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 + { + Item item = Item.getByNameOrId( ModItemMeta[0] + ":" + ModItemMeta[1] ); + if( item != null ) + { + ItemStack itemStack; + itemStack = new ItemStack( item, 1, ModItemMeta.length == 3 ? Integer.parseInt( ModItemMeta[2] ) : 0 ); + NON_BLOCKING_MAP.get( modid ).add( AEItemStack.fromItemStack( itemStack ) ); + } + else + { + AELog.error( "Item not found on nonBlocking config: " + s ); + } + } + } + } + } + } + + public Map> getMap() + { + return NON_BLOCKING_MAP; + } +} diff --git a/src/main/java/appeng/integration/modules/gregtech/GTCEInventoryAdaptor.java b/src/main/java/appeng/integration/modules/gregtech/GTCEInventoryAdaptor.java deleted file mode 100644 index bbc15bebf97..00000000000 --- a/src/main/java/appeng/integration/modules/gregtech/GTCEInventoryAdaptor.java +++ /dev/null @@ -1,26 +0,0 @@ -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 -{ - 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(); -} \ No newline at end of file diff --git a/src/main/java/appeng/integration/modules/gregtech/GTCEItemHandler.java b/src/main/java/appeng/integration/modules/gregtech/GTCEItemHandler.java deleted file mode 100644 index e553f12e369..00000000000 --- a/src/main/java/appeng/integration/modules/gregtech/GTCEItemHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -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 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 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 iterator() - { - return new ItemHandlerIterator( this.itemHandler ); - } -} \ No newline at end of file diff --git a/src/main/java/appeng/util/inv/BlockingInventoryAdaptor.java b/src/main/java/appeng/util/inv/BlockingInventoryAdaptor.java new file mode 100644 index 00000000000..7400e0c6873 --- /dev/null +++ b/src/main/java/appeng/util/inv/BlockingInventoryAdaptor.java @@ -0,0 +1,26 @@ +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 +{ + 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(); +} \ No newline at end of file diff --git a/src/main/java/appeng/util/inv/BlockingItemHandler.java b/src/main/java/appeng/util/inv/BlockingItemHandler.java new file mode 100644 index 00000000000..7278c0ded69 --- /dev/null +++ b/src/main/java/appeng/util/inv/BlockingItemHandler.java @@ -0,0 +1,66 @@ +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 itemList = NonBlockingItems.INSTANCE.getMap().get( domain ); + if( stack.getItem().isDamageable() ) + { + Collection item = itemList.findFuzzy( AEItemStack.fromItemStack( stack ), FuzzyMode.IGNORE_ALL ); + return item.isEmpty(); + } + else + { + IAEItemStack item = itemList.findPrecise( AEItemStack.fromItemStack( stack ) ); + return item == null; + } + } + + @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 iterator() + { + return new ItemHandlerIterator( this.itemHandler ); + } +} \ No newline at end of file diff --git a/src/main/resources/assets/base/models/item/wrench.json b/src/main/resources/assets/base/models/item/wrench.json new file mode 100644 index 00000000000..81e4314c8cf --- /dev/null +++ b/src/main/resources/assets/base/models/item/wrench.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "base:items/wrench" + } +}