Basic reformat, hit once, hope never again
This commit is contained in:
@@ -48,75 +48,33 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AEConfig extends Configuration implements IConfigurableObject, IConfigManagerHost
|
||||
{
|
||||
|
||||
public static AEConfig instance;
|
||||
|
||||
public static final double TUNNEL_POWER_LOSS = 0.05;
|
||||
|
||||
public static final String VERSION = "@version@";
|
||||
public static final String CHANNEL = "@aechannel@";
|
||||
|
||||
public final static String PACKET_CHANNEL = "AE";
|
||||
|
||||
public static AEConfig instance;
|
||||
public final IConfigManager settings = new ConfigManager( this );
|
||||
public final EnumSet<AEFeature> featureFlags = EnumSet.noneOf( AEFeature.class );
|
||||
PowerUnits selectedPowerUnit = PowerUnits.AE;
|
||||
|
||||
public final int[] craftByStacks = new int[] { 1, 10, 100, 1000 };
|
||||
public final int[] priorityByStacks = new int[] { 1, 10, 100, 1000 };
|
||||
public final int[] levelByStacks = new int[] { 1, 10, 100, 1000 };
|
||||
private final double WirelessHighWirelessCount = 64;
|
||||
final private File configFile;
|
||||
public int storageBiomeID = -1;
|
||||
public int storageProviderID = -1;
|
||||
|
||||
public int formationPlaneEntityLimit = 128;
|
||||
|
||||
public float spawnChargedChance = 0.92f;
|
||||
public int quartzOresPerCluster = 4;
|
||||
public int quartzOresClusterAmount = 15;
|
||||
public int chargedChange = 4;
|
||||
public int minMeteoriteDistance = 707;
|
||||
public int minMeteoriteDistanceSq = this.minMeteoriteDistance * this.minMeteoriteDistance;
|
||||
|
||||
private double WirelessBaseCost = 8;
|
||||
private double WirelessCostMultiplier = 1;
|
||||
private final double WirelessHighWirelessCount = 64;
|
||||
private double WirelessTerminalDrainMultiplier = 1;
|
||||
|
||||
private double WirelessBaseRange = 16;
|
||||
private double WirelessBoosterRangeMultiplier = 1;
|
||||
private double WirelessBoosterExp = 1.5;
|
||||
|
||||
public double wireless_getDrainRate(double range)
|
||||
{
|
||||
return this.WirelessTerminalDrainMultiplier * range;
|
||||
}
|
||||
|
||||
public double wireless_getMaxRange(int boosters)
|
||||
{
|
||||
return this.WirelessBaseRange + this.WirelessBoosterRangeMultiplier * Math.pow( boosters, this.WirelessBoosterExp );
|
||||
}
|
||||
|
||||
public double wireless_getPowerDrain(int boosters)
|
||||
{
|
||||
return this.WirelessBaseCost + this.WirelessCostMultiplier * Math.pow( boosters, 1 + boosters / this.WirelessHighWirelessCount );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property get(String category, String key, String defaultValue, String comment, Property.Type type)
|
||||
{
|
||||
Property prop = super.get( category, key, defaultValue, comment, type );
|
||||
|
||||
if ( prop != null )
|
||||
{
|
||||
if ( !category.equals( "Client" ) )
|
||||
prop.setRequiresMcRestart( true );
|
||||
}
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
||||
public double spatialPowerExponent = 1.35;
|
||||
public double spatialPowerMultiplier = 1250.0;
|
||||
|
||||
public String[] grinderOres = {
|
||||
// Vanilla Items
|
||||
"Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz",
|
||||
@@ -126,105 +84,32 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
"CertusQuartz", "Wheat", "Fluix",
|
||||
// Other Mod Ores
|
||||
"Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum", "Osmium", "Zinc" };
|
||||
|
||||
public double oreDoublePercentage = 90.0;
|
||||
|
||||
public boolean enableEffects = true;
|
||||
public boolean useLargeFonts = false;
|
||||
public boolean useColoredCraftingStatus;
|
||||
public final int[] craftByStacks = new int[] { 1, 10, 100, 1000 };
|
||||
public final int[] priorityByStacks = new int[] { 1, 10, 100, 1000 };
|
||||
public final int[] levelByStacks = new int[] { 1, 10, 100, 1000 };
|
||||
|
||||
public int wirelessTerminalBattery = 1600000;
|
||||
public int entropyManipulatorBattery = 200000;
|
||||
public int matterCannonBattery = 200000;
|
||||
public int portableCellBattery = 20000;
|
||||
public int colorApplicatorBattery = 20000;
|
||||
public int chargedStaffBattery = 8000;
|
||||
|
||||
public boolean disableColoredCableRecipesInNEI = true;
|
||||
|
||||
public boolean updatable = false;
|
||||
final private File configFile;
|
||||
|
||||
public double meteoriteClusterChance = 0.1;
|
||||
public double meteoriteSpawnChance = 0.3;
|
||||
public int[] meteoriteDimensionWhitelist = new int[] { 0 };
|
||||
|
||||
public int craftingCalculationTimePerTick = 5;
|
||||
PowerUnits selectedPowerUnit = PowerUnits.AE;
|
||||
private double WirelessBaseCost = 8;
|
||||
private double WirelessCostMultiplier = 1;
|
||||
private double WirelessTerminalDrainMultiplier = 1;
|
||||
private double WirelessBaseRange = 16;
|
||||
private double WirelessBoosterRangeMultiplier = 1;
|
||||
private double WirelessBoosterExp = 1.5;
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs)
|
||||
public AEConfig( File configFile )
|
||||
{
|
||||
if ( eventArgs.modID.equals( AppEng.MOD_ID ) )
|
||||
{
|
||||
this.clientSync();
|
||||
}
|
||||
}
|
||||
|
||||
private void clientSync()
|
||||
{
|
||||
this.disableColoredCableRecipesInNEI = this.get( "Client", "disableColoredCableRecipesInNEI", true ).getBoolean( true );
|
||||
this.enableEffects = this.get( "Client", "enableEffects", true ).getBoolean( true );
|
||||
this.useLargeFonts = this.get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false );
|
||||
this.useColoredCraftingStatus = this.get( "Client", "useColoredCraftingStatus", true ).getBoolean( true );
|
||||
|
||||
// load buttons..
|
||||
for (int btnNum = 0; btnNum < 4; btnNum++)
|
||||
{
|
||||
Property cmb = this.get( "Client", "craftAmtButton" + (btnNum + 1), this.craftByStacks[btnNum] );
|
||||
Property pmb = this.get( "Client", "priorityAmtButton" + (btnNum + 1), this.priorityByStacks[btnNum] );
|
||||
Property lmb = this.get( "Client", "levelAmtButton" + (btnNum + 1), this.levelByStacks[btnNum] );
|
||||
|
||||
int buttonCap = (int) (Math.pow( 10, btnNum + 1 ) - 1);
|
||||
|
||||
this.craftByStacks[btnNum] = Math.abs( cmb.getInt( this.craftByStacks[btnNum] ) );
|
||||
this.priorityByStacks[btnNum] = Math.abs( pmb.getInt( this.priorityByStacks[btnNum] ) );
|
||||
this.levelByStacks[btnNum] = Math.abs( pmb.getInt( this.levelByStacks[btnNum] ) );
|
||||
|
||||
cmb.comment = "Controls buttons on Crafting Screen : Capped at " + buttonCap;
|
||||
pmb.comment = "Controls buttons on Priority Screen : Capped at " + buttonCap;
|
||||
lmb.comment = "Controls buttons on Level Emitter Screen : Capped at " + buttonCap;
|
||||
|
||||
this.craftByStacks[btnNum] = Math.min( this.craftByStacks[btnNum], buttonCap );
|
||||
this.priorityByStacks[btnNum] = Math.min( this.priorityByStacks[btnNum], buttonCap );
|
||||
this.levelByStacks[btnNum] = Math.min( this.levelByStacks[btnNum], buttonCap );
|
||||
}
|
||||
|
||||
for (Settings e : this.settings.getSettings())
|
||||
{
|
||||
String Category = "Client"; // e.getClass().getSimpleName();
|
||||
Enum<?> value = this.settings.getSetting( e );
|
||||
|
||||
Property p = this.get( Category, e.name(), value.name(), this.getListComment( value ) );
|
||||
|
||||
try
|
||||
{
|
||||
value = Enum.valueOf( value.getClass(), p.getString() );
|
||||
}
|
||||
catch (IllegalArgumentException er)
|
||||
{
|
||||
AELog.info( "Invalid value '" + p.getString() + "' for " + e.name() + " using '" + value.name() + "' instead" );
|
||||
}
|
||||
|
||||
this.settings.putSetting( e, value );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean disableColoredCableRecipesInNEI()
|
||||
{
|
||||
return this.disableColoredCableRecipesInNEI;
|
||||
}
|
||||
|
||||
public String getFilePath()
|
||||
{
|
||||
return this.configFile.toString();
|
||||
}
|
||||
|
||||
public AEConfig( File configFile ) {
|
||||
super( configFile );
|
||||
this.configFile = configFile;
|
||||
|
||||
@@ -253,29 +138,25 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
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.meteoriteSpawnChance = this.get( "worldGen", "meteoriteSpawnChance", this.meteoriteSpawnChance ).getDouble( this.meteoriteSpawnChance );
|
||||
this.meteoriteDimensionWhitelist = this.get ("worldGen", "meteoriteDimensionWhitelist", this.meteoriteDimensionWhitelist).getIntList();
|
||||
this.meteoriteDimensionWhitelist = this.get( "worldGen", "meteoriteDimensionWhitelist", this.meteoriteDimensionWhitelist ).getIntList();
|
||||
|
||||
this.quartzOresPerCluster = this.get( "worldGen", "quartzOresPerCluster", this.quartzOresPerCluster ).getInt( this.quartzOresPerCluster );
|
||||
this.quartzOresClusterAmount = this.get( "worldGen", "quartzOresClusterAmount", this.quartzOresClusterAmount ).getInt( this.quartzOresClusterAmount );
|
||||
|
||||
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 );
|
||||
|
||||
@@ -288,11 +169,11 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
|
||||
this.clientSync();
|
||||
|
||||
for (AEFeature feature : AEFeature.values())
|
||||
for( AEFeature feature : AEFeature.values() )
|
||||
{
|
||||
if ( feature.isVisible )
|
||||
if( feature.isVisible )
|
||||
{
|
||||
if ( this.get( "Features." + feature.category, feature.name(), feature.defaultValue ).getBoolean( feature.defaultValue ) )
|
||||
if( this.get( "Features." + feature.category, feature.name(), feature.defaultValue ).getBoolean( feature.defaultValue ) )
|
||||
this.featureFlags.add( feature );
|
||||
}
|
||||
else
|
||||
@@ -300,10 +181,10 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
}
|
||||
|
||||
ModContainer imb = cpw.mods.fml.common.Loader.instance().getIndexedModList().get( "ImmibisCore" );
|
||||
if ( imb != null )
|
||||
if( imb != null )
|
||||
{
|
||||
List<String> version = Arrays.asList( "59.0.0", "59.0.1", "59.0.2" );
|
||||
if ( version.contains( imb.getVersion() ) )
|
||||
if( version.contains( imb.getVersion() ) )
|
||||
this.featureFlags.remove( AEFeature.AlphaPass );
|
||||
}
|
||||
|
||||
@@ -311,17 +192,17 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
{
|
||||
this.selectedPowerUnit = PowerUnits.valueOf( this.get( "Client", "PowerUnit", this.selectedPowerUnit.name(), this.getListComment( this.selectedPowerUnit ) ).getString() );
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch( Throwable t )
|
||||
{
|
||||
this.selectedPowerUnit = PowerUnits.AE;
|
||||
}
|
||||
|
||||
for (TickRates tr : TickRates.values())
|
||||
for( TickRates tr : TickRates.values() )
|
||||
{
|
||||
tr.Load( this );
|
||||
}
|
||||
|
||||
if ( this.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
if( this.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
{
|
||||
this.storageBiomeID = this.get( "spatialio", "storageBiomeID", this.storageBiomeID ).getInt( this.storageBiomeID );
|
||||
this.storageProviderID = this.get( "spatialio", "storageProviderID", this.storageProviderID ).getInt( this.storageProviderID );
|
||||
@@ -329,41 +210,75 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
this.spatialPowerExponent = this.get( "spatialio", "spatialPowerExponent", this.spatialPowerExponent ).getDouble( this.spatialPowerExponent );
|
||||
}
|
||||
|
||||
if ( this.isFeatureEnabled( AEFeature.CraftingCPU ) )
|
||||
if( this.isFeatureEnabled( AEFeature.CraftingCPU ) )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public boolean useAEVersion(MaterialType mt)
|
||||
private void clientSync()
|
||||
{
|
||||
if ( this.isFeatureEnabled( AEFeature.WebsiteRecipes ) )
|
||||
return true;
|
||||
this.disableColoredCableRecipesInNEI = this.get( "Client", "disableColoredCableRecipesInNEI", true ).getBoolean( true );
|
||||
this.enableEffects = this.get( "Client", "enableEffects", true ).getBoolean( true );
|
||||
this.useLargeFonts = this.get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false );
|
||||
this.useColoredCraftingStatus = this.get( "Client", "useColoredCraftingStatus", true ).getBoolean( 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." );
|
||||
Property p = this.get( "OreCamouflage", mt.name(), true );
|
||||
p.comment = "OreDictionary Names: " + mt.getOreName();
|
||||
// load buttons..
|
||||
for( int btnNum = 0; btnNum < 4; btnNum++ )
|
||||
{
|
||||
Property cmb = this.get( "Client", "craftAmtButton" + ( btnNum + 1 ), this.craftByStacks[btnNum] );
|
||||
Property pmb = this.get( "Client", "priorityAmtButton" + ( btnNum + 1 ), this.priorityByStacks[btnNum] );
|
||||
Property lmb = this.get( "Client", "levelAmtButton" + ( btnNum + 1 ), this.levelByStacks[btnNum] );
|
||||
|
||||
return !p.getBoolean( true );
|
||||
int buttonCap = (int) ( Math.pow( 10, btnNum + 1 ) - 1 );
|
||||
|
||||
this.craftByStacks[btnNum] = Math.abs( cmb.getInt( this.craftByStacks[btnNum] ) );
|
||||
this.priorityByStacks[btnNum] = Math.abs( pmb.getInt( this.priorityByStacks[btnNum] ) );
|
||||
this.levelByStacks[btnNum] = Math.abs( pmb.getInt( this.levelByStacks[btnNum] ) );
|
||||
|
||||
cmb.comment = "Controls buttons on Crafting Screen : Capped at " + buttonCap;
|
||||
pmb.comment = "Controls buttons on Priority Screen : Capped at " + buttonCap;
|
||||
lmb.comment = "Controls buttons on Level Emitter Screen : Capped at " + buttonCap;
|
||||
|
||||
this.craftByStacks[btnNum] = Math.min( this.craftByStacks[btnNum], buttonCap );
|
||||
this.priorityByStacks[btnNum] = Math.min( this.priorityByStacks[btnNum], buttonCap );
|
||||
this.levelByStacks[btnNum] = Math.min( this.levelByStacks[btnNum], buttonCap );
|
||||
}
|
||||
|
||||
for( Settings e : this.settings.getSettings() )
|
||||
{
|
||||
String Category = "Client"; // e.getClass().getSimpleName();
|
||||
Enum<?> value = this.settings.getSetting( e );
|
||||
|
||||
Property p = this.get( Category, e.name(), value.name(), this.getListComment( value ) );
|
||||
|
||||
try
|
||||
{
|
||||
value = Enum.valueOf( value.getClass(), p.getString() );
|
||||
}
|
||||
catch( IllegalArgumentException er )
|
||||
{
|
||||
AELog.info( "Invalid value '" + p.getString() + "' for " + e.name() + " using '" + value.name() + "' instead" );
|
||||
}
|
||||
|
||||
this.settings.putSetting( e, value );
|
||||
}
|
||||
}
|
||||
|
||||
private String getListComment(Enum value)
|
||||
private String getListComment( Enum value )
|
||||
{
|
||||
String comment = null;
|
||||
|
||||
if ( value != null )
|
||||
if( value != null )
|
||||
{
|
||||
EnumSet set = EnumSet.allOf( value.getClass() );
|
||||
|
||||
for (Object Oeg : set)
|
||||
for( Object Oeg : set )
|
||||
{
|
||||
Enum eg = (Enum) Oeg;
|
||||
if ( comment == null )
|
||||
if( comment == null )
|
||||
comment = "Possible Values: " + eg.name();
|
||||
else
|
||||
comment += ", " + eg.name();
|
||||
@@ -373,27 +288,44 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
return comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum setting, Enum newValue)
|
||||
public boolean isFeatureEnabled( AEFeature f )
|
||||
{
|
||||
for (Settings e : this.settings.getSettings())
|
||||
return this.featureFlags.contains( f );
|
||||
}
|
||||
|
||||
public double wireless_getDrainRate( double range )
|
||||
{
|
||||
return this.WirelessTerminalDrainMultiplier * range;
|
||||
}
|
||||
|
||||
public double wireless_getMaxRange( int boosters )
|
||||
{
|
||||
return this.WirelessBaseRange + this.WirelessBoosterRangeMultiplier * Math.pow( boosters, this.WirelessBoosterExp );
|
||||
}
|
||||
|
||||
public double wireless_getPowerDrain( int boosters )
|
||||
{
|
||||
return this.WirelessBaseCost + this.WirelessCostMultiplier * Math.pow( boosters, 1 + boosters / this.WirelessHighWirelessCount );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property get( String category, String key, String defaultValue, String comment, Property.Type type )
|
||||
{
|
||||
Property prop = super.get( category, key, defaultValue, comment, type );
|
||||
|
||||
if( prop != null )
|
||||
{
|
||||
if ( e == setting )
|
||||
{
|
||||
String Category = "Client";
|
||||
Property p = this.get( Category, e.name(), this.settings.getSetting( e ).name(), this.getListComment( newValue ) );
|
||||
p.set( newValue.name() );
|
||||
}
|
||||
if( !category.equals( "Client" ) )
|
||||
prop.setRequiresMcRestart( true );
|
||||
}
|
||||
|
||||
if ( this.updatable )
|
||||
this.save();
|
||||
return prop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if ( this.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
if( this.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
{
|
||||
this.get( "spatialio", "storageBiomeID", this.storageBiomeID ).set( this.storageBiomeID );
|
||||
this.get( "spatialio", "storageProviderID", this.storageProviderID ).set( this.storageProviderID );
|
||||
@@ -401,28 +333,81 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
|
||||
this.get( "Client", "PowerUnit", this.selectedPowerUnit.name(), this.getListComment( this.selectedPowerUnit ) ).set( this.selectedPowerUnit.name() );
|
||||
|
||||
if ( this.hasChanged() )
|
||||
if( this.hasChanged() )
|
||||
super.save();
|
||||
}
|
||||
|
||||
public int getFreeIDSLot(int varID, String Category)
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged( ConfigChangedEvent.OnConfigChangedEvent eventArgs )
|
||||
{
|
||||
if( eventArgs.modID.equals( AppEng.MOD_ID ) )
|
||||
{
|
||||
this.clientSync();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean disableColoredCableRecipesInNEI()
|
||||
{
|
||||
return this.disableColoredCableRecipesInNEI;
|
||||
}
|
||||
|
||||
public String getFilePath()
|
||||
{
|
||||
return this.configFile.toString();
|
||||
}
|
||||
|
||||
public boolean useAEVersion( MaterialType mt )
|
||||
{
|
||||
if( this.isFeatureEnabled( AEFeature.WebsiteRecipes ) )
|
||||
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." );
|
||||
Property p = this.get( "OreCamouflage", mt.name(), true );
|
||||
p.comment = "OreDictionary Names: " + mt.getOreName();
|
||||
|
||||
return !p.getBoolean( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( IConfigManager manager, Enum setting, Enum newValue )
|
||||
{
|
||||
for( Settings e : this.settings.getSettings() )
|
||||
{
|
||||
if( e == setting )
|
||||
{
|
||||
String Category = "Client";
|
||||
Property p = this.get( Category, e.name(), this.settings.getSetting( e ).name(), this.getListComment( newValue ) );
|
||||
p.set( newValue.name() );
|
||||
}
|
||||
}
|
||||
|
||||
if( this.updatable )
|
||||
this.save();
|
||||
}
|
||||
|
||||
public int getFreeMaterial( int varID )
|
||||
{
|
||||
return this.getFreeIDSLot( varID, "materials" );
|
||||
}
|
||||
|
||||
public int getFreeIDSLot( int varID, String Category )
|
||||
{
|
||||
boolean alreadyUsed = false;
|
||||
int min = 0;
|
||||
|
||||
for (Property p : this.getCategory( Category ).getValues().values())
|
||||
for( Property p : this.getCategory( Category ).getValues().values() )
|
||||
{
|
||||
int thisInt = p.getInt();
|
||||
|
||||
if ( varID == thisInt )
|
||||
if( varID == thisInt )
|
||||
alreadyUsed = true;
|
||||
|
||||
min = Math.max( min, thisInt + 1 );
|
||||
}
|
||||
|
||||
if ( alreadyUsed )
|
||||
if( alreadyUsed )
|
||||
{
|
||||
if ( min < 16383 )
|
||||
if( min < 16383 )
|
||||
min = 16383;
|
||||
|
||||
return min;
|
||||
@@ -431,12 +416,7 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
return varID;
|
||||
}
|
||||
|
||||
public int getFreeMaterial(int varID)
|
||||
{
|
||||
return this.getFreeIDSLot( varID, "materials" );
|
||||
}
|
||||
|
||||
public int getFreePart(int varID)
|
||||
public int getFreePart( int varID )
|
||||
{
|
||||
return this.getFreeIDSLot( varID, "parts" );
|
||||
}
|
||||
@@ -447,32 +427,27 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
public boolean isFeatureEnabled(AEFeature f)
|
||||
{
|
||||
return this.featureFlags.contains( f );
|
||||
}
|
||||
|
||||
public boolean useTerminalUseLargeFont()
|
||||
{
|
||||
return this.useLargeFonts;
|
||||
}
|
||||
|
||||
public int craftItemsByStackAmounts(int i)
|
||||
public int craftItemsByStackAmounts( int i )
|
||||
{
|
||||
return this.craftByStacks[i];
|
||||
}
|
||||
|
||||
public int priorityByStacksAmounts(int i)
|
||||
public int priorityByStacksAmounts( int i )
|
||||
{
|
||||
return this.priorityByStacks[i];
|
||||
}
|
||||
|
||||
public int levelByStackAmounts(int i)
|
||||
public int levelByStackAmounts( int i )
|
||||
{
|
||||
return this.levelByStacks[i];
|
||||
}
|
||||
|
||||
public Enum getSetting(String Category, Class<? extends Enum> class1, Enum myDefault)
|
||||
public Enum getSetting( String Category, Class<? extends Enum> class1, Enum myDefault )
|
||||
{
|
||||
String name = class1.getSimpleName();
|
||||
Property p = this.get( Category, name, myDefault.name() );
|
||||
@@ -481,7 +456,7 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
{
|
||||
return (Enum) class1.getField( p.toString() ).get( class1 );
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch( Throwable t )
|
||||
{
|
||||
// :{
|
||||
}
|
||||
@@ -489,7 +464,7 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
return myDefault;
|
||||
}
|
||||
|
||||
public void setSetting(String Category, Enum s)
|
||||
public void setSetting( String Category, Enum s )
|
||||
{
|
||||
String name = s.getClass().getSimpleName();
|
||||
this.get( Category, name, s.name() ).set( s.name() );
|
||||
@@ -501,10 +476,9 @@ public class AEConfig extends Configuration implements IConfigurableObject, ICon
|
||||
return this.selectedPowerUnit;
|
||||
}
|
||||
|
||||
public void nextPowerUnit(boolean backwards)
|
||||
public void nextPowerUnit( boolean backwards )
|
||||
{
|
||||
this.selectedPowerUnit = Platform.rotateEnum( this.selectedPowerUnit, backwards, Settings.POWER_UNITS.getPossibleValues() );
|
||||
this.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
@@ -26,76 +27,77 @@ import appeng.core.features.AEFeature;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public final class AELog
|
||||
{
|
||||
|
||||
public static final FMLRelaunchLog INSTANCE = FMLRelaunchLog.log;
|
||||
|
||||
private AELog() {
|
||||
}
|
||||
|
||||
private static void log(Level level, String format, Object... data)
|
||||
private AELog()
|
||||
{
|
||||
if ( AEConfig.instance == null || AEConfig.instance.isFeatureEnabled( AEFeature.Logging ) )
|
||||
{
|
||||
FMLRelaunchLog.log( "AE2:" + (Platform.isServer() ? "S" : "C"), level, format, data );
|
||||
}
|
||||
}
|
||||
|
||||
public static void severe(String format, Object... data)
|
||||
{
|
||||
log( Level.ERROR, format, data );
|
||||
}
|
||||
|
||||
public static void warning(String format, Object... data)
|
||||
public static void warning( String format, Object... data )
|
||||
{
|
||||
log( Level.WARN, format, data );
|
||||
}
|
||||
|
||||
public static void info(String format, Object... data)
|
||||
private static void log( Level level, String format, Object... data )
|
||||
{
|
||||
log( Level.INFO, format, data );
|
||||
if( AEConfig.instance == null || AEConfig.instance.isFeatureEnabled( AEFeature.Logging ) )
|
||||
{
|
||||
FMLRelaunchLog.log( "AE2:" + ( Platform.isServer() ? "S" : "C" ), level, format, data );
|
||||
}
|
||||
}
|
||||
|
||||
public static void grinder(String o)
|
||||
public static void grinder( String o )
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.GrinderLogging ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.GrinderLogging ) )
|
||||
{
|
||||
log( Level.DEBUG, "grinder: " + o );
|
||||
}
|
||||
}
|
||||
|
||||
public static void error(Throwable e)
|
||||
public static void integration( Throwable exception )
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.Logging ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.IntegrationLogging ) )
|
||||
{
|
||||
error( exception );
|
||||
}
|
||||
}
|
||||
|
||||
public static void error( Throwable e )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.Logging ) )
|
||||
{
|
||||
severe( "Error: " + e.getClass().getName() + " : " + e.getMessage() );
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void integration(Throwable exception)
|
||||
public static void severe( String format, Object... data )
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.IntegrationLogging ) )
|
||||
{
|
||||
error( exception );
|
||||
}
|
||||
log( Level.ERROR, format, data );
|
||||
}
|
||||
|
||||
public static void blockUpdate(int xCoord, int yCoord, int zCoord, AEBaseTile aeBaseTile)
|
||||
public static void blockUpdate( int xCoord, int yCoord, int zCoord, AEBaseTile aeBaseTile )
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.UpdateLogging ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.UpdateLogging ) )
|
||||
{
|
||||
info( aeBaseTile.getClass().getName() + " @ " + xCoord + ", " + yCoord + ", " + zCoord );
|
||||
}
|
||||
}
|
||||
|
||||
public static void crafting(String format, Object... data)
|
||||
public static void info( String format, Object... data )
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CraftingLog ) )
|
||||
log( Level.INFO, format, data );
|
||||
}
|
||||
|
||||
public static void crafting( String format, Object... data )
|
||||
{
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.CraftingLog ) )
|
||||
{
|
||||
log( Level.INFO, format, data );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import appeng.me.GridConnection;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public final class Api implements IAppEngApi
|
||||
{
|
||||
public static final Api INSTANCE = new Api();
|
||||
@@ -118,7 +119,7 @@ public final class Api implements IAppEngApi
|
||||
@Override
|
||||
public IGridNode createGridNode( IGridBlock blk )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
throw new RuntimeException( "Grid Features are Server Side Only." );
|
||||
return new GridNode( blk );
|
||||
}
|
||||
|
||||
@@ -101,15 +101,15 @@ public class AppEng
|
||||
@EventHandler
|
||||
void preInit( FMLPreInitializationEvent event )
|
||||
{
|
||||
if ( !Loader.isModLoaded( "appliedenergistics2-core" ) )
|
||||
if( !Loader.isModLoaded( "appliedenergistics2-core" ) )
|
||||
{
|
||||
CommonHelper.proxy.missingCoreMod();
|
||||
}
|
||||
|
||||
Stopwatch watch = Stopwatch.createStarted();
|
||||
this.configDirectory = new File(event.getModConfigurationDirectory().getPath(), "AppliedEnergistics2");
|
||||
this.configDirectory = new File( event.getModConfigurationDirectory().getPath(), "AppliedEnergistics2" );
|
||||
|
||||
final File configFile = new File( this.configDirectory, "AppliedEnergistics2.cfg");
|
||||
final File configFile = new File( this.configDirectory, "AppliedEnergistics2.cfg" );
|
||||
final File facadeFile = new File( this.configDirectory, "Facades.cfg" );
|
||||
final File versionFile = new File( this.configDirectory, "VersionChecker.cfg" );
|
||||
|
||||
@@ -120,15 +120,15 @@ public class AppEng
|
||||
AELog.info( "Pre Initialization ( started )" );
|
||||
|
||||
CreativeTab.init();
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) )
|
||||
CreativeTabFacade.init();
|
||||
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
CommonHelper.proxy.init();
|
||||
|
||||
Registration.INSTANCE.preInitialize( event );
|
||||
|
||||
if ( versionCheckerConfig.isEnabled() )
|
||||
if( versionCheckerConfig.isEnabled() )
|
||||
{
|
||||
final VersionChecker versionChecker = new VersionChecker( versionCheckerConfig );
|
||||
final Thread versionCheckerThread = new Thread( versionChecker );
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -33,29 +34,30 @@ import appeng.block.AEBaseBlock;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
|
||||
|
||||
public abstract class CommonHelper
|
||||
{
|
||||
|
||||
@SidedProxy(clientSide = "appeng.client.ClientHelper", serverSide = "appeng.server.ServerHelper")
|
||||
@SidedProxy( clientSide = "appeng.client.ClientHelper", serverSide = "appeng.server.ServerHelper" )
|
||||
public static CommonHelper proxy;
|
||||
|
||||
public abstract void init();
|
||||
|
||||
public abstract World getWorld();
|
||||
|
||||
public abstract void bindTileEntitySpecialRenderer(Class tile, AEBaseBlock blk);
|
||||
public abstract void bindTileEntitySpecialRenderer( Class tile, AEBaseBlock blk );
|
||||
|
||||
public abstract List<EntityPlayer> getPlayers();
|
||||
|
||||
public abstract void sendToAllNearExcept(EntityPlayer p, double x, double y, double z, double dist, World w, AppEngPacket packet);
|
||||
public abstract void sendToAllNearExcept( EntityPlayer p, double x, double y, double z, double dist, World w, AppEngPacket packet );
|
||||
|
||||
public abstract void spawnEffect(EffectType effect, World worldObj, double posX, double posY, double posZ, Object extra);
|
||||
public abstract void spawnEffect( EffectType effect, World worldObj, double posX, double posY, double posZ, Object extra );
|
||||
|
||||
public abstract boolean shouldAddParticles(Random r);
|
||||
public abstract boolean shouldAddParticles( Random r );
|
||||
|
||||
public abstract MovingObjectPosition getMOP();
|
||||
|
||||
public abstract void doRenderItem(ItemStack itemstack, World w);
|
||||
public abstract void doRenderItem( ItemStack itemstack, World w );
|
||||
|
||||
public abstract void postInit();
|
||||
|
||||
@@ -63,8 +65,7 @@ public abstract class CommonHelper
|
||||
|
||||
public abstract void triggerUpdates();
|
||||
|
||||
public abstract void updateRenderMode(EntityPlayer player);
|
||||
public abstract void updateRenderMode( EntityPlayer player );
|
||||
|
||||
public abstract void missingCoreMod();
|
||||
|
||||
}
|
||||
|
||||
@@ -65,9 +65,9 @@ public final class CreativeTab extends CreativeTabs
|
||||
|
||||
private ItemStack findFirst( IItemDefinition... choices )
|
||||
{
|
||||
for ( IItemDefinition definition : choices )
|
||||
for( IItemDefinition definition : choices )
|
||||
{
|
||||
for ( ItemStack definitionStack : definition.maybeStack( 1 ).asSet() )
|
||||
for( ItemStack definitionStack : definition.maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return definitionStack;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -28,15 +29,22 @@ import com.google.common.base.Optional;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
|
||||
|
||||
public final class CreativeTabFacade extends CreativeTabs
|
||||
{
|
||||
|
||||
public static CreativeTabFacade instance = null;
|
||||
|
||||
public CreativeTabFacade() {
|
||||
public CreativeTabFacade()
|
||||
{
|
||||
super( "appliedenergistics2.facades" );
|
||||
}
|
||||
|
||||
public static void init()
|
||||
{
|
||||
instance = new CreativeTabFacade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getTabIconItem()
|
||||
{
|
||||
@@ -47,17 +55,11 @@ public final class CreativeTabFacade extends CreativeTabs
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
final Optional<Item> maybeFacade = AEApi.instance().definitions().items().facade().maybeItem();
|
||||
if ( maybeFacade.isPresent() )
|
||||
if( maybeFacade.isPresent() )
|
||||
{
|
||||
return ((ItemFacade) maybeFacade.get()).getCreativeTabIcon();
|
||||
return ( (ItemFacade) maybeFacade.get() ).getCreativeTabIcon();
|
||||
}
|
||||
|
||||
return new ItemStack( Blocks.planks );
|
||||
}
|
||||
|
||||
public static void init()
|
||||
{
|
||||
instance = new CreativeTabFacade();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -29,33 +30,35 @@ import net.minecraftforge.common.config.Configuration;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
|
||||
|
||||
public class FacadeConfig extends Configuration
|
||||
{
|
||||
|
||||
public static FacadeConfig instance;
|
||||
final Pattern replacementPattern;
|
||||
|
||||
public FacadeConfig( File facadeFile ) {
|
||||
public FacadeConfig( File facadeFile )
|
||||
{
|
||||
super( facadeFile );
|
||||
this.replacementPattern = Pattern.compile( "[^a-zA-Z0-9]" );
|
||||
}
|
||||
|
||||
public boolean checkEnabled(Block id, int metadata, boolean automatic)
|
||||
public boolean checkEnabled( Block id, int metadata, boolean automatic )
|
||||
{
|
||||
if ( id == null )
|
||||
if( id == null )
|
||||
return false;
|
||||
|
||||
UniqueIdentifier blk = GameRegistry.findUniqueIdentifierFor( id );
|
||||
if ( blk == null )
|
||||
if( blk == null )
|
||||
{
|
||||
for (Field f : Block.class.getFields())
|
||||
for( Field f : Block.class.getFields() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( f.get( Block.class ) == id )
|
||||
return this.get( "minecraft", f.getName() + (metadata == 0 ? "" : "." + metadata), automatic ).getBoolean( automatic );
|
||||
if( f.get( Block.class ) == id )
|
||||
return this.get( "minecraft", f.getName() + ( metadata == 0 ? "" : "." + metadata ), automatic ).getBoolean( automatic );
|
||||
}
|
||||
catch (Throwable e)
|
||||
catch( Throwable e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
@@ -65,7 +68,7 @@ public class FacadeConfig extends Configuration
|
||||
{
|
||||
Matcher mod = this.replacementPattern.matcher( blk.modId );
|
||||
Matcher name = this.replacementPattern.matcher( blk.name );
|
||||
return this.get( mod.replaceAll( "" ), name.replaceAll( "" ) + (metadata == 0 ? "" : "." + metadata), automatic ).getBoolean( automatic );
|
||||
return this.get( mod.replaceAll( "" ), name.replaceAll( "" ) + ( metadata == 0 ? "" : "." + metadata ), automatic ).getBoolean( automatic );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class IMCHandler
|
||||
this.processors.put( "add-grindable", new IMCGrinder() );
|
||||
this.processors.put( "add-mattercannon-ammo", new IMCMatterCannon() );
|
||||
|
||||
for ( TunnelType type : TunnelType.values() )
|
||||
for( TunnelType type : TunnelType.values() )
|
||||
{
|
||||
this.processors.put( "add-p2p-attunement-" + type.name().replace( '_', '-' ).toLowerCase(), new IMCP2PAttunement() );
|
||||
}
|
||||
@@ -72,14 +72,14 @@ public class IMCHandler
|
||||
*/
|
||||
public void handleIMCEvent( FMLInterModComms.IMCEvent event )
|
||||
{
|
||||
for ( FMLInterModComms.IMCMessage message : event.getMessages() )
|
||||
for( FMLInterModComms.IMCMessage message : event.getMessages() )
|
||||
{
|
||||
final String key = message.key;
|
||||
|
||||
try
|
||||
{
|
||||
IIMCProcessor handler = this.processors.get( key );
|
||||
if ( handler != null )
|
||||
if( handler != null )
|
||||
{
|
||||
handler.process( message );
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class IMCHandler
|
||||
throw new RuntimeException( "Invalid IMC Called: " + key );
|
||||
}
|
||||
}
|
||||
catch ( Throwable t )
|
||||
catch( Throwable t )
|
||||
{
|
||||
AELog.warning( "Problem detected when processing IMC " + key + " from " + message.getSender() );
|
||||
AELog.error( t );
|
||||
|
||||
@@ -22,12 +22,12 @@ package appeng.core;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper class for the player mappings.
|
||||
|
||||
@@ -64,12 +64,12 @@ public class PlayerMappingsInitializer
|
||||
this.playerMappings = new HashMap<Integer, UUID>( capacity );
|
||||
|
||||
// Iterates through every pair of UUID to ID
|
||||
for ( Map.Entry<String, Property> entry : playerList.getValues().entrySet() )
|
||||
for( Map.Entry<String, Property> entry : playerList.getValues().entrySet() )
|
||||
{
|
||||
final String maybeUUID = entry.getKey();
|
||||
final int id = entry.getValue().getInt();
|
||||
|
||||
if ( matcher.isUUID( maybeUUID ) )
|
||||
if( matcher.isUUID( maybeUUID ) )
|
||||
{
|
||||
final UUID UUIDString = UUID.fromString( maybeUUID );
|
||||
|
||||
|
||||
@@ -76,8 +76,6 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.stats.PlayerStatsRegistration;
|
||||
import appeng.hooks.AETrading;
|
||||
import appeng.worldgen.MeteoriteWorldGen;
|
||||
import appeng.worldgen.QuartzWorldGen;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.items.materials.ItemMultiMaterial;
|
||||
@@ -117,6 +115,8 @@ import appeng.spatial.BiomeGenStorage;
|
||||
import appeng.spatial.StorageWorldProvider;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import appeng.worldgen.MeteoriteWorldGen;
|
||||
import appeng.worldgen.QuartzWorldGen;
|
||||
|
||||
|
||||
public final class Registration
|
||||
@@ -165,12 +165,12 @@ public final class Registration
|
||||
this.assignItems( items, apiItems );
|
||||
|
||||
// Register all detected handlers and features (items, blocks) in pre-init
|
||||
for ( IFeatureHandler handler : definitions.getFeatureHandlerRegistry().getRegisteredFeatureHandlers() )
|
||||
for( IFeatureHandler handler : definitions.getFeatureHandlerRegistry().getRegisteredFeatureHandlers() )
|
||||
{
|
||||
handler.register();
|
||||
}
|
||||
|
||||
for ( IAEFeature feature : definitions.getFeatureRegistry().getRegisteredFeatures() )
|
||||
for( IAEFeature feature : definitions.getFeatureRegistry().getRegisteredFeatures() )
|
||||
{
|
||||
feature.postInit();
|
||||
}
|
||||
@@ -178,37 +178,37 @@ public final class Registration
|
||||
|
||||
private void registerSpatial( boolean force )
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
if( !AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
return;
|
||||
|
||||
AEConfig config = AEConfig.instance;
|
||||
|
||||
if ( this.storageBiome == null )
|
||||
if( this.storageBiome == null )
|
||||
{
|
||||
if ( force && config.storageBiomeID == -1 )
|
||||
if( force && config.storageBiomeID == -1 )
|
||||
{
|
||||
config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() );
|
||||
if ( config.storageBiomeID == -1 )
|
||||
if( config.storageBiomeID == -1 )
|
||||
throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
|
||||
this.storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
config.save();
|
||||
}
|
||||
|
||||
if ( !force && config.storageBiomeID != -1 )
|
||||
if( !force && config.storageBiomeID != -1 )
|
||||
this.storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID != -1 )
|
||||
if( config.storageProviderID != -1 )
|
||||
{
|
||||
DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID == -1 && force )
|
||||
if( config.storageProviderID == -1 && force )
|
||||
{
|
||||
config.storageProviderID = -11;
|
||||
|
||||
while ( !DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false ) )
|
||||
while( !DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false ) )
|
||||
config.storageProviderID--;
|
||||
|
||||
config.save();
|
||||
@@ -508,7 +508,7 @@ public final class Registration
|
||||
// Perform ore camouflage!
|
||||
ItemMultiMaterial.instance.makeUnique();
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CustomRecipes ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.CustomRecipes ) )
|
||||
this.recipeHandler.parseRecipes( new ConfigLoader( AppEng.instance.getConfigDirectory() ), "index.recipe" );
|
||||
else
|
||||
this.recipeHandler.parseRecipes( new JarLoader( "/assets/appliedenergistics2/recipes/" ), "index.recipe" );
|
||||
@@ -517,13 +517,13 @@ public final class Registration
|
||||
partHelper.registerNewLayer( "appeng.parts.layers.LayerIFluidHandler", "net.minecraftforge.fluids.IFluidHandler" );
|
||||
partHelper.registerNewLayer( "appeng.parts.layers.LayerITileStorageMonitorable", "appeng.api.implementations.tiles.ITileStorageMonitorable" );
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) )
|
||||
if( AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) )
|
||||
{
|
||||
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergySink", "ic2.api.energy.tile.IEnergySink" );
|
||||
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergySource", "ic2.api.energy.tile.IEnergySource" );
|
||||
}
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) )
|
||||
if( AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) )
|
||||
partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyReceiver" );
|
||||
|
||||
FMLCommonHandler.instance().bus().register( TickHandler.INSTANCE );
|
||||
@@ -548,7 +548,7 @@ public final class Registration
|
||||
registries.cell().addCellHandler( new BasicCellHandler() );
|
||||
registries.cell().addCellHandler( new CreativeCellHandler() );
|
||||
|
||||
for ( ItemStack ammoStack : api.definitions().materials().matterBall().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack ammoStack : api.definitions().materials().matterBall().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
final double weight = 32;
|
||||
|
||||
@@ -561,10 +561,10 @@ public final class Registration
|
||||
registration.registerAchievementHandlers();
|
||||
registration.registerAchievements();
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting ) )
|
||||
CraftingManager.getInstance().getRecipeList().add( new DisassembleRecipe() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.enableFacadeCrafting ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.enableFacadeCrafting ) )
|
||||
CraftingManager.getInstance().getRecipeList().add( new FacadeRecipe() );
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ public final class Registration
|
||||
GuiText.values();
|
||||
|
||||
Api.INSTANCE.getPartHelper().initFMPSupport();
|
||||
for ( Block block : blocks.multiPart().maybeBlock().asSet() )
|
||||
for( Block block : blocks.multiPart().maybeBlock().asSet() )
|
||||
{
|
||||
( (BlockCableBus) block ).setupTile();
|
||||
}
|
||||
@@ -657,35 +657,35 @@ public final class Registration
|
||||
// Inscriber
|
||||
Upgrades.SPEED.registerItem( blocks.inscriber(), 3 );
|
||||
|
||||
for ( Item wirelessTerminalItem : items.wirelessTerminal().maybeItem().asSet() )
|
||||
for( Item wirelessTerminalItem : items.wirelessTerminal().maybeItem().asSet() )
|
||||
{
|
||||
registries.wireless().registerWirelessHandler( (IWirelessTermHandler) wirelessTerminalItem );
|
||||
}
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) )
|
||||
{
|
||||
ChestGenHooks d = ChestGenHooks.getInfo( ChestGenHooks.MINESHAFT_CORRIDOR );
|
||||
|
||||
final IMaterials materials = definitions.materials();
|
||||
|
||||
for ( ItemStack crystal : materials.certusQuartzCrystal().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack crystal : materials.certusQuartzCrystal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
d.addItem( new WeightedRandomChestContent( crystal, 1, 4, 2 ) );
|
||||
}
|
||||
for ( ItemStack dust : materials.certusQuartzDust().maybeStack( 1 ).asSet() )
|
||||
for( ItemStack dust : materials.certusQuartzDust().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
d.addItem( new WeightedRandomChestContent( dust, 1, 4, 2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
// add villager trading to black smiths for a few basic materials
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.VillagerTrading ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.VillagerTrading ) )
|
||||
VillagerRegistry.instance().registerVillageTradeHandler( 3, new AETrading() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CertusQuartzWorldGen ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.CertusQuartzWorldGen ) )
|
||||
GameRegistry.registerWorldGenerator( new QuartzWorldGen(), 0 );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) )
|
||||
{
|
||||
GameRegistry.registerWorldGenerator( new MeteoriteWorldGen(), 0 );
|
||||
}
|
||||
@@ -728,7 +728,7 @@ public final class Registration
|
||||
/**
|
||||
* world gen
|
||||
*/
|
||||
for ( WorldGenType type : WorldGenType.values() )
|
||||
for( WorldGenType type : WorldGenType.values() )
|
||||
{
|
||||
registries.worldgen().disableWorldGenForProviderID( type, StorageWorldProvider.class );
|
||||
|
||||
@@ -740,7 +740,7 @@ public final class Registration
|
||||
}
|
||||
|
||||
// whitelist from config
|
||||
for ( int dimension : AEConfig.instance.meteoriteDimensionWhitelist )
|
||||
for( int dimension : AEConfig.instance.meteoriteDimensionWhitelist )
|
||||
{
|
||||
registries.worldgen().enableWorldGenForDimension( WorldGenType.Meteorites, dimension );
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class WorldSettings extends Configuration
|
||||
this.spawnDataFolder = new File( aeFolder, SPAWNDATA_FOLDER );
|
||||
this.compass = new CompassService( aeFolder );
|
||||
|
||||
for ( int dimID : this.get( "DimensionManager", "StorageCells", new int[0] ).getIntList() )
|
||||
for( int dimID : this.get( "DimensionManager", "StorageCells", new int[0] ).getIntList() )
|
||||
{
|
||||
this.storageCellDims.add( dimID );
|
||||
DimensionManager.registerDimension( dimID, AEConfig.instance.storageProviderID );
|
||||
@@ -85,7 +85,7 @@ public class WorldSettings extends Configuration
|
||||
this.lastGridStorage = Long.parseLong( this.get( "Counters", "lastGridStorage", 0 ).getString() );
|
||||
this.lastPlayer = this.get( "Counters", "lastPlayer", 0 ).getInt();
|
||||
}
|
||||
catch ( NumberFormatException err )
|
||||
catch( NumberFormatException err )
|
||||
{
|
||||
this.lastGridStorage = 0;
|
||||
this.lastPlayer = 0;
|
||||
@@ -97,25 +97,25 @@ public class WorldSettings extends Configuration
|
||||
|
||||
public static WorldSettings getInstance()
|
||||
{
|
||||
if ( instance == null )
|
||||
if( instance == null )
|
||||
{
|
||||
File world = DimensionManager.getCurrentSaveRootDirectory();
|
||||
|
||||
File aeBaseFolder = new File( world.getPath(), "AE2" );
|
||||
|
||||
if ( !aeBaseFolder.isDirectory() && !aeBaseFolder.mkdir() )
|
||||
if( !aeBaseFolder.isDirectory() && !aeBaseFolder.mkdir() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + aeBaseFolder.getAbsolutePath() );
|
||||
}
|
||||
|
||||
File compass = new File( aeBaseFolder, COMPASS_FOLDER );
|
||||
if ( !compass.isDirectory() && !compass.mkdir() )
|
||||
if( !compass.isDirectory() && !compass.mkdir() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + compass.getAbsolutePath() );
|
||||
}
|
||||
|
||||
File spawnData = new File( aeBaseFolder, SPAWNDATA_FOLDER );
|
||||
if ( !spawnData.isDirectory() && !spawnData.mkdir() )
|
||||
if( !spawnData.isDirectory() && !spawnData.mkdir() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + spawnData.getAbsolutePath() );
|
||||
}
|
||||
@@ -130,22 +130,22 @@ public class WorldSettings extends Configuration
|
||||
{
|
||||
Collection<NBTTagCompound> ll = new LinkedList<NBTTagCompound>();
|
||||
|
||||
synchronized ( WorldSettings.class )
|
||||
synchronized( WorldSettings.class )
|
||||
{
|
||||
for ( int x = -1; x <= 1; x++ )
|
||||
for( int x = -1; x <= 1; x++ )
|
||||
{
|
||||
for ( int z = -1; z <= 1; z++ )
|
||||
for( int z = -1; z <= 1; z++ )
|
||||
{
|
||||
int cx = x + ( chunkX >> 4 );
|
||||
int cz = z + ( chunkZ >> 4 );
|
||||
|
||||
NBTTagCompound data = this.loadSpawnData( dim, cx << 4, cz << 4 );
|
||||
|
||||
if ( data != null )
|
||||
if( data != null )
|
||||
{
|
||||
// edit.
|
||||
int size = data.getInteger( "num" );
|
||||
for ( int s = 0; s < size; s++ )
|
||||
for( int s = 0; s < size; s++ )
|
||||
ll.add( data.getCompoundTag( String.valueOf( s ) ) );
|
||||
}
|
||||
}
|
||||
@@ -157,13 +157,13 @@ public class WorldSettings extends Configuration
|
||||
|
||||
NBTTagCompound loadSpawnData( int dim, int chunkX, int chunkZ )
|
||||
{
|
||||
if ( !Thread.holdsLock( WorldSettings.class ) )
|
||||
if( !Thread.holdsLock( WorldSettings.class ) )
|
||||
throw new RuntimeException( "Invalid Request" );
|
||||
|
||||
NBTTagCompound data = null;
|
||||
File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" );
|
||||
|
||||
if ( file.isFile() )
|
||||
if( file.isFile() )
|
||||
{
|
||||
FileInputStream fileInputStream = null;
|
||||
|
||||
@@ -172,20 +172,20 @@ public class WorldSettings extends Configuration
|
||||
fileInputStream = new FileInputStream( file );
|
||||
data = CompressedStreamTools.readCompressed( fileInputStream );
|
||||
}
|
||||
catch ( Throwable e )
|
||||
catch( Throwable e )
|
||||
{
|
||||
data = new NBTTagCompound();
|
||||
AELog.error( e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( fileInputStream != null )
|
||||
if( fileInputStream != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
fileInputStream.close();
|
||||
}
|
||||
catch ( IOException e )
|
||||
catch( IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public class WorldSettings extends Configuration
|
||||
|
||||
public boolean hasGenerated( int dim, int chunkX, int chunkZ )
|
||||
{
|
||||
synchronized ( WorldSettings.class )
|
||||
synchronized( WorldSettings.class )
|
||||
{
|
||||
NBTTagCompound data = this.loadSpawnData( dim, chunkX, chunkZ );
|
||||
return data.getBoolean( chunkX + "," + chunkZ );
|
||||
@@ -211,7 +211,7 @@ public class WorldSettings extends Configuration
|
||||
|
||||
public void setGenerated( int dim, int chunkX, int chunkZ )
|
||||
{
|
||||
synchronized ( WorldSettings.class )
|
||||
synchronized( WorldSettings.class )
|
||||
{
|
||||
NBTTagCompound data = this.loadSpawnData( dim, chunkX, chunkZ );
|
||||
|
||||
@@ -224,7 +224,7 @@ public class WorldSettings extends Configuration
|
||||
|
||||
void writeSpawnData( int dim, int chunkX, int chunkZ, NBTTagCompound data )
|
||||
{
|
||||
if ( !Thread.holdsLock( WorldSettings.class ) )
|
||||
if( !Thread.holdsLock( WorldSettings.class ) )
|
||||
throw new RuntimeException( "Invalid Request" );
|
||||
|
||||
File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" );
|
||||
@@ -235,19 +235,19 @@ public class WorldSettings extends Configuration
|
||||
fileOutputStream = new FileOutputStream( file );
|
||||
CompressedStreamTools.writeCompressed( data, fileOutputStream );
|
||||
}
|
||||
catch ( Throwable e )
|
||||
catch( Throwable e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( fileOutputStream != null )
|
||||
if( fileOutputStream != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
fileOutputStream.close();
|
||||
}
|
||||
catch ( IOException e )
|
||||
catch( IOException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
@@ -257,7 +257,7 @@ public class WorldSettings extends Configuration
|
||||
|
||||
public boolean addNearByMeteorites( int dim, int chunkX, int chunkZ, NBTTagCompound newData )
|
||||
{
|
||||
synchronized ( WorldSettings.class )
|
||||
synchronized( WorldSettings.class )
|
||||
{
|
||||
NBTTagCompound data = this.loadSpawnData( dim, chunkX, chunkZ );
|
||||
|
||||
@@ -276,7 +276,7 @@ public class WorldSettings extends Configuration
|
||||
{
|
||||
this.save();
|
||||
|
||||
for ( Integer dimID : this.storageCellDims )
|
||||
for( Integer dimID : this.storageCellDims )
|
||||
DimensionManager.unregisterDimension( dimID );
|
||||
|
||||
this.storageCellDims.clear();
|
||||
@@ -289,10 +289,10 @@ public class WorldSettings extends Configuration
|
||||
public void save()
|
||||
{
|
||||
// populate new data
|
||||
for ( GridStorageSearch gs : this.loadedStorage.keySet() )
|
||||
for( GridStorageSearch gs : this.loadedStorage.keySet() )
|
||||
{
|
||||
GridStorage thisStorage = gs.gridStorage.get();
|
||||
if ( thisStorage != null && thisStorage.getGrid() != null && !thisStorage.getGrid().isEmpty() )
|
||||
if( thisStorage != null && thisStorage.getGrid() != null && !thisStorage.getGrid().isEmpty() )
|
||||
{
|
||||
String value = thisStorage.getValue();
|
||||
this.get( "gridstorage", String.valueOf( thisStorage.getID() ), value ).set( value );
|
||||
@@ -300,7 +300,7 @@ public class WorldSettings extends Configuration
|
||||
}
|
||||
|
||||
// save to files
|
||||
if ( this.hasChanged() )
|
||||
if( this.hasChanged() )
|
||||
super.save();
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ public class WorldSettings extends Configuration
|
||||
|
||||
String[] values = new String[this.storageCellDims.size()];
|
||||
|
||||
for ( int x = 0; x < values.length; x++ )
|
||||
for( int x = 0; x < values.length; x++ )
|
||||
values[x] = String.valueOf( this.storageCellDims.get( x ) );
|
||||
|
||||
this.get( "DimensionManager", "StorageCells", new int[0] ).set( values );
|
||||
@@ -327,16 +327,16 @@ public class WorldSettings extends Configuration
|
||||
|
||||
public void sendToPlayer( NetworkManager manager )
|
||||
{
|
||||
if ( manager != null )
|
||||
if( manager != null )
|
||||
{
|
||||
for ( int newDim : this.get( "DimensionManager", "StorageCells", new int[0] ).getIntList() )
|
||||
for( int newDim : this.get( "DimensionManager", "StorageCells", new int[0] ).getIntList() )
|
||||
{
|
||||
manager.scheduleOutboundPacket( ( new PacketNewStorageDimension( newDim ) ).getProxy() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( PlayerColor pc : TickHandler.INSTANCE.getPlayerColors().values() )
|
||||
for( PlayerColor pc : TickHandler.INSTANCE.getPlayerColors().values() )
|
||||
NetworkHandler.instance.sendToAll( pc.getPacket() );
|
||||
}
|
||||
}
|
||||
@@ -374,7 +374,7 @@ public class WorldSettings extends Configuration
|
||||
GridStorageSearch gss = new GridStorageSearch( storageID );
|
||||
WeakReference<GridStorageSearch> result = this.loadedStorage.get( gss );
|
||||
|
||||
if ( result == null || result.get() == null )
|
||||
if( result == null || result.get() == null )
|
||||
{
|
||||
String id = String.valueOf( storageID );
|
||||
String Data = this.get( "gridstorage", id, "" ).getString();
|
||||
@@ -426,13 +426,13 @@ public class WorldSettings extends Configuration
|
||||
{
|
||||
ConfigCategory playerList = this.getCategory( "players" );
|
||||
|
||||
if ( playerList == null || profile == null || !profile.isComplete() )
|
||||
if( playerList == null || profile == null || !profile.isComplete() )
|
||||
return -1;
|
||||
|
||||
String uuid = profile.getId().toString();
|
||||
|
||||
Property prop = playerList.get( uuid );
|
||||
if ( prop != null && prop.isIntValue() )
|
||||
if( prop != null && prop.isIntValue() )
|
||||
return prop.getInt();
|
||||
else
|
||||
{
|
||||
@@ -455,12 +455,12 @@ public class WorldSettings extends Configuration
|
||||
{
|
||||
Optional<UUID> maybe = this.mappings.get( playerID );
|
||||
|
||||
if ( maybe.isPresent() )
|
||||
if( maybe.isPresent() )
|
||||
{
|
||||
final UUID uuid = maybe.get();
|
||||
for ( EntityPlayer player : CommonHelper.proxy.getPlayers() )
|
||||
for( EntityPlayer player : CommonHelper.proxy.getPlayers() )
|
||||
{
|
||||
if ( player.getUniqueID().equals( uuid ) )
|
||||
if( player.getUniqueID().equals( uuid ) )
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
@@ -45,6 +43,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
@@ -59,6 +59,7 @@ import appeng.parts.PartPlacement;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ApiPart implements IPartHelper
|
||||
{
|
||||
|
||||
@@ -69,14 +70,212 @@ public class ApiPart implements IPartHelper
|
||||
|
||||
public void initFMPSupport()
|
||||
{
|
||||
for (Class layerInterface : this.interfaces2Layer.keySet())
|
||||
for( Class layerInterface : this.interfaces2Layer.keySet() )
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).registerPassThrough( layerInterface );
|
||||
if( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).registerPassThrough( layerInterface );
|
||||
}
|
||||
}
|
||||
|
||||
private Class loadClass(String Name, byte[] b)
|
||||
public Class getCombinedInstance( String base )
|
||||
{
|
||||
if( this.desc.size() == 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Class.forName( base );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
String description = base + ':' + Joiner.on( ";" ).skipNulls().join( this.desc.iterator() );
|
||||
|
||||
if( this.tileImplementations.get( description ) != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.tileImplementations.get( description );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
String f = base;// TileCableBus.class.getName();
|
||||
String Addendum = "";
|
||||
try
|
||||
{
|
||||
Addendum = Class.forName( base ).getSimpleName();
|
||||
}
|
||||
catch( ClassNotFoundException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
Class myCLass;
|
||||
|
||||
try
|
||||
{
|
||||
myCLass = Class.forName( f );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
|
||||
String path = f;
|
||||
|
||||
for( String name : this.desc )
|
||||
{
|
||||
try
|
||||
{
|
||||
String newPath = path + ';' + name;
|
||||
myCLass = this.getClassByDesc( Addendum, newPath, f, this.interfaces2Layer.get( Class.forName( name ) ) );
|
||||
path = newPath;
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
AELog.warning( "Error loading " + name );
|
||||
AELog.error( t );
|
||||
// throw new RuntimeException( t );
|
||||
}
|
||||
f = myCLass.getName();
|
||||
}
|
||||
|
||||
this.tileImplementations.put( description, myCLass );
|
||||
|
||||
try
|
||||
{
|
||||
return myCLass;
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
public Class getClassByDesc( String Addendum, String fullPath, String root, String next )
|
||||
{
|
||||
if( this.roots.get( fullPath ) != null )
|
||||
return this.roots.get( fullPath );
|
||||
|
||||
ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );
|
||||
ClassNode n = this.getReader( next );
|
||||
String originalName = n.name;
|
||||
|
||||
try
|
||||
{
|
||||
n.name = n.name + '_' + Addendum;
|
||||
n.superName = Class.forName( root ).getName().replace( ".", "/" );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
for( MethodNode mn : n.methods )
|
||||
{
|
||||
Iterator<AbstractInsnNode> i = mn.instructions.iterator();
|
||||
while( i.hasNext() )
|
||||
{
|
||||
this.processNode( i.next(), n.superName );
|
||||
}
|
||||
}
|
||||
|
||||
DefaultPackageClassNameRemapper remapper = new DefaultPackageClassNameRemapper();
|
||||
remapper.inputOutput.put( "appeng/api/parts/LayerBase", n.superName );
|
||||
remapper.inputOutput.put( originalName, n.name );
|
||||
n.accept( new RemappingClassAdapter( cw, remapper ) );
|
||||
// n.accept( cw );
|
||||
|
||||
// n.accept( new TraceClassVisitor( new PrintWriter( System.out ) ) );
|
||||
byte[] byteArray = cw.toByteArray();
|
||||
int size = byteArray.length;
|
||||
Class clazz = this.loadClass( n.name.replace( "/", "." ), byteArray );
|
||||
|
||||
try
|
||||
{
|
||||
Object fish = clazz.newInstance();
|
||||
Class rootC = Class.forName( root );
|
||||
|
||||
boolean hasError = false;
|
||||
|
||||
if( !rootC.isInstance( fish ) )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to implement " + root + " did not." );
|
||||
}
|
||||
|
||||
if( fish instanceof LayerBase )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to NOT implement LayerBase but it DID." );
|
||||
}
|
||||
|
||||
if( !fullPath.contains( ".fmp." ) )
|
||||
{
|
||||
if( !( fish instanceof TileCableBus ) )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileCableBus did not." );
|
||||
}
|
||||
|
||||
if( !( fish instanceof TileEntity ) )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileEntity did not." );
|
||||
}
|
||||
}
|
||||
|
||||
if( !hasError )
|
||||
{
|
||||
AELog.info( "Layer: " + n.name + " loaded successfully - " + size + " bytes" );
|
||||
}
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
AELog.severe( "Layer: " + n.name + " Failed." );
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
this.roots.put( fullPath, clazz );
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public ClassNode getReader( String name )
|
||||
{
|
||||
try
|
||||
{
|
||||
ClassReader cr;
|
||||
String path = '/' + name.replace( ".", "/" ) + ".class";
|
||||
InputStream is = this.getClass().getResourceAsStream( path );
|
||||
cr = new ClassReader( is );
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept( cn, ClassReader.EXPAND_FRAMES );
|
||||
return cn;
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( "Error loading " + name, t );
|
||||
}
|
||||
}
|
||||
|
||||
private void processNode( AbstractInsnNode next, String nePar )
|
||||
{
|
||||
if( next instanceof MethodInsnNode )
|
||||
{
|
||||
MethodInsnNode min = (MethodInsnNode) next;
|
||||
if( min.owner.equals( "appeng/api/parts/LayerBase" ) )
|
||||
{
|
||||
min.owner = nePar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Class loadClass( String Name, byte[] b )
|
||||
{
|
||||
// override classDefine (as it is protected) and define the class.
|
||||
Class clazz = null;
|
||||
@@ -104,7 +303,7 @@ public class ApiPart implements IPartHelper
|
||||
defineClassMethod.setAccessible( false );
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch( Exception e )
|
||||
{
|
||||
AELog.error( e );
|
||||
throw new RuntimeException( "Unable to manage part API.", e );
|
||||
@@ -112,241 +311,13 @@ public class ApiPart implements IPartHelper
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public ClassNode getReader(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
ClassReader cr;
|
||||
String path = '/' + name.replace( ".", "/" ) + ".class";
|
||||
InputStream is = this.getClass().getResourceAsStream( path );
|
||||
cr = new ClassReader( is );
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept( cn, ClassReader.EXPAND_FRAMES );
|
||||
return cn;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( "Error loading " + name, t );
|
||||
}
|
||||
}
|
||||
|
||||
public Class getCombinedInstance(String base)
|
||||
{
|
||||
if ( this.desc.size() == 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Class.forName( base );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
String description = base + ':' + Joiner.on( ";" ).skipNulls().join( this.desc.iterator() );
|
||||
|
||||
if ( this.tileImplementations.get( description ) != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.tileImplementations.get( description );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
String f = base;// TileCableBus.class.getName();
|
||||
String Addendum = "";
|
||||
try
|
||||
{
|
||||
Addendum = Class.forName( base ).getSimpleName();
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
Class myCLass;
|
||||
|
||||
try
|
||||
{
|
||||
myCLass = Class.forName( f );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
|
||||
String path = f;
|
||||
|
||||
for (String name : this.desc)
|
||||
{
|
||||
try
|
||||
{
|
||||
String newPath = path + ';' + name;
|
||||
myCLass = this.getClassByDesc( Addendum, newPath, f, this.interfaces2Layer.get( Class.forName( name ) ) );
|
||||
path = newPath;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.warning( "Error loading " + name );
|
||||
AELog.error( t );
|
||||
// throw new RuntimeException( t );
|
||||
}
|
||||
f = myCLass.getName();
|
||||
}
|
||||
|
||||
this.tileImplementations.put( description, myCLass );
|
||||
|
||||
try
|
||||
{
|
||||
return myCLass;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
static class DefaultPackageClassNameRemapper extends Remapper
|
||||
{
|
||||
|
||||
public final HashMap<String, String> inputOutput = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public String map(String typeName)
|
||||
{
|
||||
String o = this.inputOutput.get( typeName );
|
||||
if ( o == null )
|
||||
return typeName;
|
||||
return o;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Class getClassByDesc(String Addendum, String fullPath, String root, String next)
|
||||
{
|
||||
if ( this.roots.get( fullPath ) != null )
|
||||
return this.roots.get( fullPath );
|
||||
|
||||
ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );
|
||||
ClassNode n = this.getReader( next );
|
||||
String originalName = n.name;
|
||||
|
||||
try
|
||||
{
|
||||
n.name = n.name + '_' + Addendum;
|
||||
n.superName = Class.forName( root ).getName().replace( ".", "/" );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
for (MethodNode mn : n.methods)
|
||||
{
|
||||
Iterator<AbstractInsnNode> i = mn.instructions.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
this.processNode( i.next(), n.superName );
|
||||
}
|
||||
}
|
||||
|
||||
DefaultPackageClassNameRemapper remapper = new DefaultPackageClassNameRemapper();
|
||||
remapper.inputOutput.put( "appeng/api/parts/LayerBase", n.superName );
|
||||
remapper.inputOutput.put( originalName, n.name );
|
||||
n.accept( new RemappingClassAdapter( cw, remapper ) );
|
||||
// n.accept( cw );
|
||||
|
||||
// n.accept( new TraceClassVisitor( new PrintWriter( System.out ) ) );
|
||||
byte[] byteArray = cw.toByteArray();
|
||||
int size = byteArray.length;
|
||||
Class clazz = this.loadClass( n.name.replace( "/", "." ), byteArray );
|
||||
|
||||
try
|
||||
{
|
||||
Object fish = clazz.newInstance();
|
||||
Class rootC = Class.forName( root );
|
||||
|
||||
boolean hasError = false;
|
||||
|
||||
if ( !rootC.isInstance( fish ) )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to implement " + root + " did not." );
|
||||
}
|
||||
|
||||
if ( fish instanceof LayerBase )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to NOT implement LayerBase but it DID." );
|
||||
}
|
||||
|
||||
if ( !fullPath.contains( ".fmp." ) )
|
||||
{
|
||||
if ( !(fish instanceof TileCableBus) )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileCableBus did not." );
|
||||
}
|
||||
|
||||
if ( !(fish instanceof TileEntity) )
|
||||
{
|
||||
hasError = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileEntity did not." );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !hasError )
|
||||
{
|
||||
AELog.info( "Layer: " + n.name + " loaded successfully - " + size + " bytes" );
|
||||
}
|
||||
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.severe( "Layer: " + n.name + " Failed." );
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
this.roots.put( fullPath, clazz );
|
||||
return clazz;
|
||||
}
|
||||
|
||||
private void processNode(AbstractInsnNode next, String nePar)
|
||||
{
|
||||
if ( next instanceof MethodInsnNode )
|
||||
{
|
||||
MethodInsnNode min = (MethodInsnNode) next;
|
||||
if ( min.owner.equals( "appeng/api/parts/LayerBase" ) )
|
||||
{
|
||||
min.owner = nePar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemBusRenderer(IPartItem i)
|
||||
{
|
||||
if ( Platform.isClient() && i instanceof Item )
|
||||
MinecraftForgeClient.registerItemRenderer( (Item) i, BusRenderer.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBus(ItemStack is, int x, int y, int z, int side, EntityPlayer player, World w)
|
||||
{
|
||||
return PartPlacement.place( is, x, y, z, side, player, w, PartPlacement.PlaceType.PLACE_ITEM, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerNewLayer(String layer, String layerInterface)
|
||||
public boolean registerNewLayer( String layer, String layerInterface )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Class<?> layerInterfaceClass = Class.forName( layerInterface );
|
||||
if ( this.interfaces2Layer.get( layerInterfaceClass ) == null )
|
||||
if( this.interfaces2Layer.get( layerInterfaceClass ) == null )
|
||||
{
|
||||
this.interfaces2Layer.put( layerInterfaceClass, layer );
|
||||
this.desc.add( layerInterface );
|
||||
@@ -355,17 +326,44 @@ public class ApiPart implements IPartHelper
|
||||
else
|
||||
AELog.info( "Layer " + layer + " not registered, " + layerInterface + " already has a layer." );
|
||||
}
|
||||
catch (Throwable ignored)
|
||||
catch( Throwable ignored )
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemBusRenderer( IPartItem i )
|
||||
{
|
||||
if( Platform.isClient() && i instanceof Item )
|
||||
MinecraftForgeClient.registerItemRenderer( (Item) i, BusRenderer.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBus( ItemStack is, int x, int y, int z, int side, EntityPlayer player, World w )
|
||||
{
|
||||
return PartPlacement.place( is, x, y, z, side, player, w, PartPlacement.PlaceType.PLACE_ITEM, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableRenderMode getCableRenderMode()
|
||||
{
|
||||
return CommonHelper.proxy.getRenderMode();
|
||||
}
|
||||
|
||||
static class DefaultPackageClassNameRemapper extends Remapper
|
||||
{
|
||||
|
||||
public final HashMap<String, String> inputOutput = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public String map( String typeName )
|
||||
{
|
||||
String o = this.inputOutput.get( typeName );
|
||||
if( o == null )
|
||||
return typeName;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.api;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -41,17 +42,24 @@ import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.ItemList;
|
||||
|
||||
|
||||
public class ApiStorage implements IStorageHelper
|
||||
{
|
||||
|
||||
@Override
|
||||
public IAEItemStack createItemStack(ItemStack is)
|
||||
public ICraftingLink loadCraftingLink( NBTTagCompound data, ICraftingRequester req )
|
||||
{
|
||||
return new CraftingLink( data, req );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack createItemStack( ItemStack is )
|
||||
{
|
||||
return AEItemStack.create( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack createFluidStack(FluidStack is)
|
||||
public IAEFluidStack createFluidStack( FluidStack is )
|
||||
{
|
||||
return AEFluidStack.create( is );
|
||||
}
|
||||
@@ -69,32 +77,26 @@ public class ApiStorage implements IStorageHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredExtraction(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, BaseActionSource src)
|
||||
{
|
||||
return Platform.poweredExtraction( energy, cell, request, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredInsert(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, BaseActionSource src)
|
||||
{
|
||||
return Platform.poweredInsert( energy, cell, input, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack readItemFromPacket(ByteBuf input) throws IOException
|
||||
public IAEItemStack readItemFromPacket( ByteBuf input ) throws IOException
|
||||
{
|
||||
return AEItemStack.loadItemStackFromPacket( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack readFluidFromPacket(ByteBuf input) throws IOException
|
||||
public IAEFluidStack readFluidFromPacket( ByteBuf input ) throws IOException
|
||||
{
|
||||
return AEFluidStack.loadFluidStackFromPacket( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingLink loadCraftingLink(NBTTagCompound data, ICraftingRequester req)
|
||||
public IAEItemStack poweredExtraction( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, BaseActionSource src )
|
||||
{
|
||||
return new CraftingLink( data, req );
|
||||
return Platform.poweredExtraction( energy, cell, request, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredInsert( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, BaseActionSource src )
|
||||
{
|
||||
return Platform.poweredInsert( energy, cell, input, src );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
package appeng.core.api;
|
||||
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
|
||||
public interface IIMCProcessor
|
||||
{
|
||||
void process( IMCMessage m );
|
||||
|
||||
@@ -38,10 +38,10 @@ public final class ApiParts implements IParts
|
||||
private final AEColoredItemDefinition cableCovered;
|
||||
private final AEColoredItemDefinition cableGlass;
|
||||
private final AEColoredItemDefinition cableDense;
|
||||
// private final AEColoredItemDefinition lumenCableSmart;
|
||||
// private final AEColoredItemDefinition lumenCableCovered;
|
||||
// private final AEColoredItemDefinition lumenCableGlass;
|
||||
// private final AEColoredItemDefinition lumenCableDense;
|
||||
// private final AEColoredItemDefinition lumenCableSmart;
|
||||
// private final AEColoredItemDefinition lumenCableCovered;
|
||||
// private final AEColoredItemDefinition lumenCableGlass;
|
||||
// private final AEColoredItemDefinition lumenCableDense;
|
||||
private final IItemDefinition quartzFiber;
|
||||
private final IItemDefinition toggleBus;
|
||||
private final IItemDefinition invertedToggleBus;
|
||||
@@ -79,10 +79,10 @@ public final class ApiParts implements IParts
|
||||
this.cableCovered = constructor.constructColoredDefinition( itemMultiPart, PartType.CableCovered );
|
||||
this.cableGlass = constructor.constructColoredDefinition( itemMultiPart, PartType.CableGlass );
|
||||
this.cableDense = constructor.constructColoredDefinition( itemMultiPart, PartType.CableDense );
|
||||
// this.lumenCableSmart = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
|
||||
// this.lumenCableCovered = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
|
||||
// this.lumenCableGlass = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
|
||||
// this.lumenCableDense = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
|
||||
// this.lumenCableSmart = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
|
||||
// this.lumenCableCovered = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
|
||||
// this.lumenCableGlass = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
|
||||
// this.lumenCableDense = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
|
||||
this.quartzFiber = new DamagedItemDefinition( itemMultiPart.createPart( PartType.QuartzFiber ) );
|
||||
this.toggleBus = new DamagedItemDefinition( itemMultiPart.createPart( PartType.ToggleBus ) );
|
||||
this.invertedToggleBus = new DamagedItemDefinition( itemMultiPart.createPart( PartType.InvertedToggleBus ) );
|
||||
@@ -140,28 +140,28 @@ public final class ApiParts implements IParts
|
||||
public AEColoredItemDefinition lumenCableSmart()
|
||||
{
|
||||
throw new MissingDefinition( "Lumen Smart Cable has yet to be implemented." );
|
||||
// return this.lumenCableSmart;
|
||||
// return this.lumenCableSmart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColoredItemDefinition lumenCableCovered()
|
||||
{
|
||||
throw new MissingDefinition( "Lumen Covered Cable has yet to be implemented." );
|
||||
// return this.lumenCableCovered;
|
||||
// return this.lumenCableCovered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColoredItemDefinition lumenCableGlass()
|
||||
{
|
||||
throw new MissingDefinition( "Lumen Glass Cable has yet to be implemented." );
|
||||
// return this.lumenCableGlass;
|
||||
// return this.lumenCableGlass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEColoredItemDefinition lumenCableDense()
|
||||
{
|
||||
throw new MissingDefinition( "Lumen Dense Cable has yet to be implemented." );
|
||||
// return this.lumenCableDense;
|
||||
// return this.lumenCableDense;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,7 @@ public class DefinitionConstructor
|
||||
{
|
||||
final IBlockDefinition definition = this.registerBlockDefinition( feature );
|
||||
|
||||
if ( definition instanceof ITileDefinition )
|
||||
if( definition instanceof ITileDefinition )
|
||||
{
|
||||
return ( (ITileDefinition) definition );
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class DefinitionConstructor
|
||||
{
|
||||
final IItemDefinition definition = this.registerItemDefinition( feature );
|
||||
|
||||
if ( definition instanceof IBlockDefinition )
|
||||
if( definition instanceof IBlockDefinition )
|
||||
{
|
||||
return ( (IBlockDefinition) definition );
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class DefinitionConstructor
|
||||
{
|
||||
final IFeatureHandler handler = feature.handler();
|
||||
|
||||
if ( handler.isFeatureAvailable() )
|
||||
if( handler.isFeatureAvailable() )
|
||||
{
|
||||
this.handlers.addFeatureHandler( handler );
|
||||
this.features.addFeature( feature );
|
||||
@@ -74,9 +74,9 @@ public class DefinitionConstructor
|
||||
{
|
||||
final ColoredItemDefinition definition = new ColoredItemDefinition();
|
||||
|
||||
for ( Item targetItem : target.maybeItem().asSet() )
|
||||
for( Item targetItem : target.maybeItem().asSet() )
|
||||
{
|
||||
for ( AEColor color : AEColor.VALID_COLORS )
|
||||
for( AEColor color : AEColor.VALID_COLORS )
|
||||
{
|
||||
definition.add( color, new ItemStackSrc( targetItem, offset + color.ordinal() ) );
|
||||
}
|
||||
@@ -89,12 +89,12 @@ public class DefinitionConstructor
|
||||
{
|
||||
final ColoredItemDefinition definition = new ColoredItemDefinition();
|
||||
|
||||
for ( AEColor color : AEColor.values() )
|
||||
for( AEColor color : AEColor.values() )
|
||||
{
|
||||
ItemStackSrc multiPartSource = target.createPart( type, color );
|
||||
final Optional<ItemStackSrc> maybeSource = Optional.fromNullable( multiPartSource );
|
||||
|
||||
if ( maybeSource.isPresent() )
|
||||
if( maybeSource.isPresent() )
|
||||
{
|
||||
definition.add( color, multiPartSource );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.api.imc;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -27,6 +28,7 @@ import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.api.IIMCProcessor;
|
||||
|
||||
|
||||
public class IMCBlackListSpatial implements IIMCProcessor
|
||||
{
|
||||
|
||||
@@ -35,10 +37,10 @@ public class IMCBlackListSpatial implements IIMCProcessor
|
||||
{
|
||||
|
||||
ItemStack is = m.getItemStackValue();
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
Block blk = Block.getBlockFromItem( is.getItem() );
|
||||
if ( blk != null )
|
||||
if( blk != null )
|
||||
{
|
||||
AEApi.instance().registries().movable().blacklistBlock( blk );
|
||||
return;
|
||||
@@ -46,7 +48,5 @@ public class IMCBlackListSpatial implements IIMCProcessor
|
||||
}
|
||||
|
||||
AELog.info( "Bad Block blacklisted by " + m.getSender() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,8 +49,10 @@ msg.setInteger( "turns", 8 );
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-grindable", msg );
|
||||
|
||||
*/
|
||||
|
||||
package appeng.core.api.imc;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -59,6 +61,7 @@ import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.api.IIMCProcessor;
|
||||
|
||||
|
||||
public class IMCGrinder implements IIMCProcessor
|
||||
{
|
||||
@Override
|
||||
@@ -73,18 +76,18 @@ public class IMCGrinder implements IIMCProcessor
|
||||
|
||||
int turns = msg.getInteger( "turns" );
|
||||
|
||||
if ( in == null )
|
||||
if( in == null )
|
||||
throw new RuntimeException( "invalid input" );
|
||||
|
||||
if ( out == null )
|
||||
if( out == null )
|
||||
throw new RuntimeException( "invalid output" );
|
||||
|
||||
if ( msg.hasKey( "optional" ) )
|
||||
if( msg.hasKey( "optional" ) )
|
||||
{
|
||||
NBTTagCompound optionalTag = (NBTTagCompound) msg.getTag( "optional" );
|
||||
ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag );
|
||||
|
||||
if ( optional == null )
|
||||
if( optional == null )
|
||||
throw new RuntimeException( "invalid optional" );
|
||||
|
||||
float chance = msg.getFloat( "chance" );
|
||||
|
||||
@@ -28,8 +28,10 @@ msg.setDouble( "weight", 32.0 );
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-mattercannon-ammo", msg );
|
||||
|
||||
*/
|
||||
|
||||
package appeng.core.api.imc;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -38,6 +40,7 @@ import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.api.IIMCProcessor;
|
||||
|
||||
|
||||
public class IMCMatterCannon implements IIMCProcessor
|
||||
{
|
||||
|
||||
@@ -50,7 +53,7 @@ public class IMCMatterCannon implements IIMCProcessor
|
||||
ItemStack ammo = ItemStack.loadItemStackFromNBT( item );
|
||||
double weight = msg.getDouble( "weight" );
|
||||
|
||||
if ( ammo == null )
|
||||
if( ammo == null )
|
||||
throw new RuntimeException( "invalid item" );
|
||||
|
||||
AEApi.instance().registries().matterCannon().registerAmmo( ammo, weight );
|
||||
|
||||
@@ -26,8 +26,10 @@ FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-fluid",
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-item", new ItemStack( myBlockOrItem ) );
|
||||
|
||||
*/
|
||||
|
||||
package appeng.core.api.imc;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
@@ -36,6 +38,7 @@ import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.core.api.IIMCProcessor;
|
||||
|
||||
|
||||
public class IMCP2PAttunement implements IIMCProcessor
|
||||
{
|
||||
|
||||
@@ -46,10 +49,10 @@ public class IMCP2PAttunement implements IIMCProcessor
|
||||
|
||||
TunnelType type = TunnelType.valueOf( key );
|
||||
|
||||
if ( type != null )
|
||||
if( type != null )
|
||||
{
|
||||
ItemStack is = m.getItemStackValue();
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type );
|
||||
else
|
||||
throw new RuntimeException( "invalid item" );
|
||||
@@ -57,5 +60,4 @@ public class IMCP2PAttunement implements IIMCProcessor
|
||||
else
|
||||
throw new RuntimeException( "invalid type" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,14 +21,17 @@
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "whitelist-spatial", "mymod.tileentities.MyTileEntity" );
|
||||
|
||||
*/
|
||||
|
||||
package appeng.core.api.imc;
|
||||
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.api.IIMCProcessor;
|
||||
|
||||
|
||||
public class IMCSpatial implements IIMCProcessor
|
||||
{
|
||||
|
||||
@@ -41,11 +44,9 @@ public class IMCSpatial implements IIMCProcessor
|
||||
Class classInstance = Class.forName( m.getStringValue() );
|
||||
AEApi.instance().registries().movable().whiteListTileEntity( classInstance );
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
catch( ClassNotFoundException e )
|
||||
{
|
||||
AELog.info( "Bad Class Registered: " + m.getStringValue() + " by " + m.getSender() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.crash;
|
||||
|
||||
|
||||
public enum CrashInfo
|
||||
{
|
||||
MOD_VERSION, INTEGRATION
|
||||
|
||||
@@ -64,14 +64,14 @@ public final class AEBlockFeatureHandler implements IFeatureHandler
|
||||
@Override
|
||||
public void register()
|
||||
{
|
||||
if ( this.enabled )
|
||||
if( this.enabled )
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.featured.setCreativeTab( CreativeTab.instance );
|
||||
this.featured.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
this.featured.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( this.featured.getTileEntityClass(), this.featured );
|
||||
}
|
||||
|
||||
@@ -18,73 +18,74 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
public enum AEFeature
|
||||
{
|
||||
Core(null), // stuff that has no reason for ever being turned off, or that
|
||||
// is just flat out required by tons of
|
||||
// important stuff.
|
||||
Core( null ), // stuff that has no reason for ever being turned off, or that
|
||||
// is just flat out required by tons of
|
||||
// important stuff.
|
||||
|
||||
CertusQuartzWorldGen("World"), MeteoriteWorldGen("World"),
|
||||
CertusQuartzWorldGen( "World" ), MeteoriteWorldGen( "World" ),
|
||||
|
||||
DecorativeLights("World"), DecorativeQuartzBlocks("World"), SkyStoneChests("World"), SpawnPressesInMeteorites("World"),
|
||||
DecorativeLights( "World" ), DecorativeQuartzBlocks( "World" ), SkyStoneChests( "World" ), SpawnPressesInMeteorites( "World" ),
|
||||
|
||||
GrindStone("World"), Flour("World"), Inscriber("World"),
|
||||
GrindStone( "World" ), Flour( "World" ), Inscriber( "World" ),
|
||||
|
||||
ChestLoot("World"), VillagerTrading("World"),
|
||||
ChestLoot( "World" ), VillagerTrading( "World" ),
|
||||
|
||||
TinyTNT("World"),
|
||||
TinyTNT( "World" ),
|
||||
|
||||
PoweredTools("ToolsClassifications"),
|
||||
PoweredTools( "ToolsClassifications" ),
|
||||
|
||||
CertusQuartzTools("ToolsClassifications"),
|
||||
CertusQuartzTools( "ToolsClassifications" ),
|
||||
|
||||
NetherQuartzTools("ToolsClassifications"),
|
||||
NetherQuartzTools( "ToolsClassifications" ),
|
||||
|
||||
QuartzHoe("Tools"), QuartzSpade("Tools"), QuartzSword("Tools"), QuartzPickaxe("Tools"), QuartzAxe("Tools"), QuartzKnife("Tools"), QuartzWrench("Tools"),
|
||||
QuartzHoe( "Tools" ), QuartzSpade( "Tools" ), QuartzSword( "Tools" ), QuartzPickaxe( "Tools" ), QuartzAxe( "Tools" ), QuartzKnife( "Tools" ), QuartzWrench( "Tools" ),
|
||||
|
||||
ChargedStaff("Tools"), EntropyManipulator("Tools"), MatterCannon("Tools"), WirelessAccessTerminal("Tools"), ColorApplicator("Tools"),
|
||||
ChargedStaff( "Tools" ), EntropyManipulator( "Tools" ), MatterCannon( "Tools" ), WirelessAccessTerminal( "Tools" ), ColorApplicator( "Tools" ),
|
||||
|
||||
CraftingCPU("CraftingFeatures"), PowerGen("NetworkFeatures"), Security("NetworkFeatures"),
|
||||
CraftingCPU( "CraftingFeatures" ), PowerGen( "NetworkFeatures" ), Security( "NetworkFeatures" ),
|
||||
|
||||
SpatialIO("NetworkFeatures"), QuantumNetworkBridge("NetworkFeatures"), Channels("NetworkFeatures"),
|
||||
SpatialIO( "NetworkFeatures" ), QuantumNetworkBridge( "NetworkFeatures" ), Channels( "NetworkFeatures" ),
|
||||
|
||||
LevelEmitter("NetworkBuses"), CraftingTerminal("NetworkBuses"), StorageMonitor("NetworkBuses"), P2PTunnel("NetworkBuses"), FormationPlane("NetworkBuses"), AnnihilationPlane(
|
||||
"NetworkBuses"), ImportBus("NetworkBuses"), ExportBus("NetworkBuses"), StorageBus("NetworkBuses"), PartConversionMonitor("NetworkBuses"),
|
||||
LevelEmitter( "NetworkBuses" ), CraftingTerminal( "NetworkBuses" ), StorageMonitor( "NetworkBuses" ), P2PTunnel( "NetworkBuses" ), FormationPlane( "NetworkBuses" ), AnnihilationPlane( "NetworkBuses" ), ImportBus( "NetworkBuses" ), ExportBus( "NetworkBuses" ), StorageBus( "NetworkBuses" ), PartConversionMonitor( "NetworkBuses" ),
|
||||
|
||||
StorageCells("Storage"), PortableCell("PortableCell"), MEChest("Storage"), MEDrive("Storage"), IOPort("Storage"),
|
||||
StorageCells( "Storage" ), PortableCell( "PortableCell" ), MEChest( "Storage" ), MEDrive( "Storage" ), IOPort( "Storage" ),
|
||||
|
||||
NetworkTool("NetworkTool"),
|
||||
NetworkTool( "NetworkTool" ),
|
||||
|
||||
DenseEnergyCells("HigherCapacity"), DenseCables("HigherCapacity"),
|
||||
DenseEnergyCells( "HigherCapacity" ), DenseCables( "HigherCapacity" ),
|
||||
|
||||
P2PTunnelRF("P2PTunnels"), P2PTunnelME("P2PTunnels"), P2PTunnelItems("P2PTunnels"), P2PTunnelRedstone("P2PTunnels"), P2PTunnelEU("P2PTunnels"), P2PTunnelMJ(
|
||||
"P2PTunnels"), P2PTunnelLiquids("P2PTunnels"), P2PTunnelLight("P2PTunnels"),
|
||||
P2PTunnelRF( "P2PTunnels" ), P2PTunnelME( "P2PTunnels" ), P2PTunnelItems( "P2PTunnels" ), P2PTunnelRedstone( "P2PTunnels" ), P2PTunnelEU( "P2PTunnels" ), P2PTunnelMJ( "P2PTunnels" ), P2PTunnelLiquids( "P2PTunnels" ), P2PTunnelLight( "P2PTunnels" ),
|
||||
|
||||
MassCannonBlockDamage("BlockFeatures"), TinyTNTBlockDamage("BlockFeatures"), Facades("Facades"),
|
||||
MassCannonBlockDamage( "BlockFeatures" ), TinyTNTBlockDamage( "BlockFeatures" ), Facades( "Facades" ),
|
||||
|
||||
UnsupportedDeveloperTools("Misc", false), Creative("Misc"),
|
||||
UnsupportedDeveloperTools( "Misc", false ), Creative( "Misc" ),
|
||||
|
||||
GrinderLogging("Misc", false), Logging("Misc"), IntegrationLogging("Misc", false), CustomRecipes("Crafting", false), WebsiteRecipes("Misc", false),
|
||||
GrinderLogging( "Misc", false ), Logging( "Misc" ), IntegrationLogging( "Misc", false ), CustomRecipes( "Crafting", false ), WebsiteRecipes( "Misc", false ),
|
||||
|
||||
enableFacadeCrafting("Crafting"), inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false),
|
||||
enableFacadeCrafting( "Crafting" ), inWorldSingularity( "Crafting" ), inWorldFluix( "Crafting" ), inWorldPurification( "Crafting" ), UpdateLogging( "Misc", false ),
|
||||
|
||||
AlphaPass("Rendering"), PaintBalls("Tools"), PacketLogging("Misc", false), CraftingLog("Misc", false), InterfaceTerminal("Crafting"), LightDetector("Misc"),
|
||||
AlphaPass( "Rendering" ), PaintBalls( "Tools" ), PacketLogging( "Misc", false ), CraftingLog( "Misc", false ), InterfaceTerminal( "Crafting" ), LightDetector( "Misc" ),
|
||||
|
||||
enableDisassemblyCrafting("Crafting"), MolecularAssembler("CraftingFeatures"), MeteoriteCompass("Tools"), Patterns("CraftingFeatures"),
|
||||
enableDisassemblyCrafting( "Crafting" ), MolecularAssembler( "CraftingFeatures" ), MeteoriteCompass( "Tools" ), Patterns( "CraftingFeatures" ),
|
||||
|
||||
ChunkLoggerTrace("Commands", false), LogSecurityAudits("Misc", false), Achievements("Misc");
|
||||
ChunkLoggerTrace( "Commands", false ), LogSecurityAudits( "Misc", false ), Achievements( "Misc" );
|
||||
|
||||
public final String category;
|
||||
public final boolean isVisible;
|
||||
public final boolean defaultValue;
|
||||
|
||||
AEFeature( String cat ) {
|
||||
AEFeature( String cat )
|
||||
{
|
||||
this.category = cat;
|
||||
this.isVisible = !this.name().equals( "Core" );
|
||||
this.defaultValue = true;
|
||||
}
|
||||
|
||||
AEFeature( String cat, boolean defaultValue ) {
|
||||
AEFeature( String cat, boolean defaultValue )
|
||||
{
|
||||
this.category = cat;
|
||||
this.isVisible = !this.name().equals( "Core" );
|
||||
this.defaultValue = defaultValue;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
||||
@Override
|
||||
public Optional<ItemBlock> maybeItemBlock()
|
||||
{
|
||||
if ( this.enabled )
|
||||
if( this.enabled )
|
||||
{
|
||||
return Optional.of( new ItemBlock( this.block ) );
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
||||
@Override
|
||||
public final Optional<ItemStack> maybeStack( int stackSize )
|
||||
{
|
||||
if ( this.enabled )
|
||||
if( this.enabled )
|
||||
{
|
||||
return Optional.of( new ItemStack( this.block ) );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -26,68 +27,68 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
|
||||
|
||||
public final class ColoredItemDefinition implements AEColoredItemDefinition
|
||||
{
|
||||
|
||||
final ItemStackSrc[] colors = new ItemStackSrc[17];
|
||||
|
||||
public void add( AEColor v, ItemStackSrc is )
|
||||
{
|
||||
this.colors[v.ordinal()] = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item(AEColor color)
|
||||
public Block block( AEColor color )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item( AEColor color )
|
||||
{
|
||||
ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
if ( is == null )
|
||||
if( is == null )
|
||||
return null;
|
||||
|
||||
return is.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(AEColor color, int stackSize)
|
||||
public Class<? extends TileEntity> entity( AEColor color )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack( AEColor color, int stackSize )
|
||||
{
|
||||
ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
if ( is == null )
|
||||
if( is == null )
|
||||
return null;
|
||||
|
||||
return is.stack( stackSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAs(AEColor color, ItemStack comparableItem)
|
||||
{
|
||||
ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
if ( comparableItem == null || is == null )
|
||||
return false;
|
||||
|
||||
return comparableItem.getItem() == is.item && comparableItem.getItemDamage() == is.damage;
|
||||
}
|
||||
|
||||
public void add(AEColor v, ItemStackSrc is)
|
||||
{
|
||||
this.colors[v.ordinal()] = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block(AEColor color)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity(AEColor color)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] allStacks(int stackSize)
|
||||
public ItemStack[] allStacks( int stackSize )
|
||||
{
|
||||
ItemStack[] is = new ItemStack[this.colors.length];
|
||||
for (int x = 0; x < is.length; x++)
|
||||
for( int x = 0; x < is.length; x++ )
|
||||
is[x] = this.colors[x].stack( 1 );
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAs( AEColor color, ItemStack comparableItem )
|
||||
{
|
||||
ItemStackSrc is = this.colors[color.ordinal()];
|
||||
|
||||
if( comparableItem == null || is == null )
|
||||
return false;
|
||||
|
||||
return comparableItem.getItem() == is.item && comparableItem.getItemDamage() == is.damage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class DamagedItemDefinition implements IItemDefinition
|
||||
@Override
|
||||
public boolean isSameAs( ItemStack comparableStack )
|
||||
{
|
||||
if ( comparableStack == null )
|
||||
if( comparableStack == null )
|
||||
return false;
|
||||
|
||||
return comparableStack.getItem() == this.source.getItem() && comparableStack.getItemDamage() == this.source.getDamage();
|
||||
|
||||
@@ -92,6 +92,7 @@ public final class DefinitionConverter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class AEItem extends AEComparable
|
||||
{
|
||||
private final IItemDefinition definition;
|
||||
@@ -118,6 +119,7 @@ public final class DefinitionConverter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class AEBlock extends AEItem
|
||||
{
|
||||
private final IBlockDefinition definition;
|
||||
@@ -137,6 +139,7 @@ public final class DefinitionConverter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class AETile extends AEBlock
|
||||
{
|
||||
private final ITileDefinition definition;
|
||||
@@ -155,6 +158,4 @@ public final class DefinitionConverter
|
||||
return this.definition.maybeEntity().orNull();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -43,29 +43,29 @@ public class FeatureNameExtractor
|
||||
{
|
||||
String name = this.clazz.getSimpleName();
|
||||
|
||||
if ( name.startsWith( "ItemMultiPart" ) )
|
||||
if( name.startsWith( "ItemMultiPart" ) )
|
||||
{
|
||||
name = PATTERN_ITEM_MULTI_PART.matcher( name ).replaceAll( "ItemPart" );
|
||||
}
|
||||
else if ( name.startsWith( "ItemMultiMaterial" ) )
|
||||
else if( name.startsWith( "ItemMultiMaterial" ) )
|
||||
{
|
||||
name = PATTERN_ITEM_MULTI_MATERIAL.matcher( name ).replaceAll( "ItemMaterial" );
|
||||
}
|
||||
|
||||
if ( this.subName.isPresent() )
|
||||
if( this.subName.isPresent() )
|
||||
{
|
||||
final String subName = this.subName.get();
|
||||
// simple hack to allow me to do get nice names for these without
|
||||
// mode code outside of AEBaseItem
|
||||
if ( subName.startsWith( "P2PTunnel" ) )
|
||||
if( subName.startsWith( "P2PTunnel" ) )
|
||||
{
|
||||
return "ItemPart.P2PTunnel";
|
||||
}
|
||||
else if ( subName.equals( "CertusQuartzTools" ) )
|
||||
else if( subName.equals( "CertusQuartzTools" ) )
|
||||
{
|
||||
return PATTERN_QUARTZ.matcher( name ).replaceAll( "CertusQuartz" );
|
||||
}
|
||||
else if ( subName.equals( "NetherQuartzTools" ) )
|
||||
else if( subName.equals( "NetherQuartzTools" ) )
|
||||
{
|
||||
return PATTERN_QUARTZ.matcher( name ).replaceAll( "NetherQuartz" );
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ public class FeaturedActiveChecker
|
||||
|
||||
public ActivityState getActivityState()
|
||||
{
|
||||
for ( AEFeature f : this.features )
|
||||
for( AEFeature f : this.features )
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( f ) )
|
||||
if( !AEConfig.instance.isFeatureEnabled( f ) )
|
||||
{
|
||||
return ActivityState.Disabled;
|
||||
}
|
||||
|
||||
@@ -18,16 +18,17 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public interface IStackSrc
|
||||
{
|
||||
|
||||
ItemStack stack(int i);
|
||||
ItemStack stack( int i );
|
||||
|
||||
Item getItem();
|
||||
|
||||
int getDamage();
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ItemDefinition implements IItemDefinition
|
||||
@Override
|
||||
public Optional<ItemStack> maybeStack( int stackSize )
|
||||
{
|
||||
if ( this.enabled )
|
||||
if( this.enabled )
|
||||
{
|
||||
return Optional.of( new ItemStack( this.item ) );
|
||||
}
|
||||
|
||||
@@ -65,13 +65,13 @@ public final class ItemFeatureHandler implements IFeatureHandler
|
||||
@Override
|
||||
public void register()
|
||||
{
|
||||
if ( this.enabled )
|
||||
if( this.enabled )
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.item.setTextureName( "appliedenergistics2:" + name );
|
||||
this.item.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( this.item instanceof ItemFacade )
|
||||
if( this.item instanceof ItemFacade )
|
||||
{
|
||||
this.item.setCreativeTab( CreativeTabFacade.instance );
|
||||
}
|
||||
@@ -80,11 +80,11 @@ public final class ItemFeatureHandler implements IFeatureHandler
|
||||
this.item.setCreativeTab( CreativeTab.instance );
|
||||
}
|
||||
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
if( name.equals( "ItemMaterial" ) )
|
||||
{
|
||||
name = "ItemMultiMaterial";
|
||||
}
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
else if( name.equals( "ItemPart" ) )
|
||||
{
|
||||
name = "ItemMultiPart";
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class ItemStackSrc implements IStackSrc
|
||||
{
|
||||
|
||||
@@ -29,25 +31,27 @@ public class ItemStackSrc implements IStackSrc
|
||||
public final Block block;
|
||||
public final int damage;
|
||||
|
||||
public ItemStackSrc(Item i, int dmg) {
|
||||
public ItemStackSrc( Item i, int dmg )
|
||||
{
|
||||
this.block = null;
|
||||
this.item = i;
|
||||
this.damage = dmg;
|
||||
}
|
||||
|
||||
public ItemStackSrc(Block b, int dmg) {
|
||||
public ItemStackSrc( Block b, int dmg )
|
||||
{
|
||||
this.item = null;
|
||||
this.block = b;
|
||||
this.damage = dmg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int i)
|
||||
public ItemStack stack( int i )
|
||||
{
|
||||
if ( this.block != null )
|
||||
if( this.block != null )
|
||||
return new ItemStack( this.block, i, this.damage );
|
||||
|
||||
if ( this.item != null )
|
||||
if( this.item != null )
|
||||
return new ItemStack( this.item, i, this.damage );
|
||||
|
||||
return null;
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class NameResolver
|
||||
|
||||
private final Class<? extends AEBaseItem> withOriginalName;
|
||||
|
||||
public NameResolver( Class<? extends AEBaseItem> withOriginalName)
|
||||
public NameResolver( Class<? extends AEBaseItem> withOriginalName )
|
||||
{
|
||||
this.withOriginalName = withOriginalName;
|
||||
}
|
||||
@@ -50,21 +50,21 @@ public final class NameResolver
|
||||
{
|
||||
String name = this.withOriginalName.getSimpleName();
|
||||
|
||||
if ( name.startsWith( "ItemMultiPart" ) )
|
||||
if( name.startsWith( "ItemMultiPart" ) )
|
||||
name = ITEM_MULTI_PART.matcher( name ).replaceAll( "ItemPart" );
|
||||
else if ( name.startsWith( "ItemMultiMaterial" ) )
|
||||
else if( name.startsWith( "ItemMultiMaterial" ) )
|
||||
name = ITEM_MULTI_MATERIAL.matcher( name ).replaceAll( "ItemMaterial" );
|
||||
|
||||
if ( subName != null )
|
||||
if( subName != null )
|
||||
{
|
||||
// simple hack to allow me to do get nice names for these without
|
||||
// mode code outside of AEBaseItem
|
||||
if ( subName.startsWith( "P2PTunnel" ) )
|
||||
if( subName.startsWith( "P2PTunnel" ) )
|
||||
return "ItemPart.P2PTunnel";
|
||||
|
||||
if ( subName.equals( "CertusQuartzTools" ) )
|
||||
if( subName.equals( "CertusQuartzTools" ) )
|
||||
return QUARTZ.matcher( name ).replaceAll( "CertusQuartz" );
|
||||
if ( subName.equals( "NetherQuartzTools" ) )
|
||||
if( subName.equals( "NetherQuartzTools" ) )
|
||||
return QUARTZ.matcher( name ).replaceAll( "NetherQuartz" );
|
||||
|
||||
name += '.' + subName;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class StairBlockFeatureHandler implements IFeatureHandler
|
||||
@Override
|
||||
public final void register()
|
||||
{
|
||||
if ( this.enabled )
|
||||
if( this.enabled )
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
this.stairs.setCreativeTab( CreativeTab.instance );
|
||||
|
||||
@@ -78,7 +78,7 @@ public final class WrappedDamageItemDefinition implements ITileDefinition
|
||||
@Override
|
||||
public boolean isSameAs( ItemStack comparableStack )
|
||||
{
|
||||
if ( comparableStack == null )
|
||||
if( comparableStack == null )
|
||||
return false;
|
||||
|
||||
return this.definition.isSameAs( comparableStack ) && comparableStack.getItemDamage() == this.damage;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,41 +30,43 @@ import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
|
||||
|
||||
public class CellRegistry implements ICellRegistry
|
||||
{
|
||||
|
||||
final List<ICellHandler> handlers;
|
||||
|
||||
public CellRegistry() {
|
||||
public CellRegistry()
|
||||
{
|
||||
this.handlers = new ArrayList<ICellHandler>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellHandler(ICellHandler h)
|
||||
public void addCellHandler( ICellHandler h )
|
||||
{
|
||||
if ( h != null )
|
||||
if( h != null )
|
||||
this.handlers.add( h );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellHandled(ItemStack is)
|
||||
public boolean isCellHandled( ItemStack is )
|
||||
{
|
||||
if ( is == null )
|
||||
if( is == null )
|
||||
return false;
|
||||
for (ICellHandler ch : this.handlers)
|
||||
if ( ch.isCell( is ) )
|
||||
for( ICellHandler ch : this.handlers )
|
||||
if( ch.isCell( is ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICellHandler getHandler(ItemStack is)
|
||||
public ICellHandler getHandler( ItemStack is )
|
||||
{
|
||||
if ( is == null )
|
||||
if( is == null )
|
||||
return null;
|
||||
for (ICellHandler ch : this.handlers)
|
||||
for( ICellHandler ch : this.handlers )
|
||||
{
|
||||
if ( ch.isCell( is ) )
|
||||
if( ch.isCell( is ) )
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
@@ -72,13 +75,13 @@ public class CellRegistry implements ICellRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel chan)
|
||||
public IMEInventoryHandler getCellInventory( ItemStack is, ISaveProvider container, StorageChannel chan )
|
||||
{
|
||||
if ( is == null )
|
||||
if( is == null )
|
||||
return null;
|
||||
for (ICellHandler ch : this.handlers)
|
||||
for( ICellHandler ch : this.handlers )
|
||||
{
|
||||
if ( ch.isCell( is ) )
|
||||
if( ch.isCell( is ) )
|
||||
{
|
||||
return ch.getCellInventory( is, container, chan );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -30,35 +31,36 @@ import appeng.api.storage.IExternalStorageRegistry;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.core.features.registries.entries.ExternalIInv;
|
||||
|
||||
|
||||
public class ExternalStorageRegistry implements IExternalStorageRegistry
|
||||
{
|
||||
|
||||
final List<IExternalStorageHandler> Handlers;
|
||||
final ExternalIInv lastHandler = new ExternalIInv();
|
||||
|
||||
public ExternalStorageRegistry() {
|
||||
public ExternalStorageRegistry()
|
||||
{
|
||||
this.Handlers = new ArrayList<IExternalStorageHandler>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExternalStorageHandler getHandler(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
|
||||
{
|
||||
for (IExternalStorageHandler x : this.Handlers)
|
||||
{
|
||||
if ( x.canHandle( te, d, chan, mySrc ) )
|
||||
return x;
|
||||
}
|
||||
|
||||
if ( this.lastHandler.canHandle( te, d, chan, mySrc ) )
|
||||
return this.lastHandler;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExternalStorageInterface(IExternalStorageHandler ei)
|
||||
public void addExternalStorageInterface( IExternalStorageHandler ei )
|
||||
{
|
||||
this.Handlers.add( ei );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExternalStorageHandler getHandler( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc )
|
||||
{
|
||||
for( IExternalStorageHandler x : this.Handlers )
|
||||
{
|
||||
if( x.canHandle( te, d, chan, mySrc ) )
|
||||
return x;
|
||||
}
|
||||
|
||||
if( this.lastHandler.canHandle( te, d, chan, mySrc ) )
|
||||
return this.lastHandler;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -26,33 +27,34 @@ import appeng.api.networking.IGridCache;
|
||||
import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.core.AELog;
|
||||
|
||||
|
||||
public class GridCacheRegistry implements IGridCacheRegistry
|
||||
{
|
||||
|
||||
final private HashMap<Class<? extends IGridCache>, Class<? extends IGridCache>> caches = new HashMap<Class<? extends IGridCache>, Class<? extends IGridCache>>();
|
||||
|
||||
@Override
|
||||
public void registerGridCache(Class<? extends IGridCache> iface, Class<? extends IGridCache> implementation)
|
||||
public void registerGridCache( Class<? extends IGridCache> iface, Class<? extends IGridCache> implementation )
|
||||
{
|
||||
if ( iface.isAssignableFrom( implementation ) )
|
||||
if( iface.isAssignableFrom( implementation ) )
|
||||
this.caches.put( iface, implementation );
|
||||
else
|
||||
throw new RuntimeException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Class<? extends IGridCache>, IGridCache> createCacheInstance(IGrid g)
|
||||
public HashMap<Class<? extends IGridCache>, IGridCache> createCacheInstance( IGrid g )
|
||||
{
|
||||
HashMap<Class<? extends IGridCache>, IGridCache> map = new HashMap<Class<? extends IGridCache>, IGridCache>();
|
||||
|
||||
for (Class<? extends IGridCache> iface : this.caches.keySet())
|
||||
for( Class<? extends IGridCache> iface : this.caches.keySet() )
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor<? extends IGridCache> c = this.caches.get( iface ).getConstructor( IGrid.class );
|
||||
map.put( iface, c.newInstance( g ) );
|
||||
}
|
||||
catch (Throwable e)
|
||||
catch( Throwable e )
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new RuntimeException( e );
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
@Override
|
||||
public void addRecipe( ItemStack in, ItemStack out, int cost )
|
||||
{
|
||||
if ( in == null || out == null )
|
||||
if( in == null || out == null )
|
||||
{
|
||||
this.log( "Invalid Grinder Recipe Specified." );
|
||||
return;
|
||||
@@ -98,7 +98,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
@Override
|
||||
public void addRecipe( ItemStack in, ItemStack out, ItemStack optional, float chance, int cost )
|
||||
{
|
||||
if ( in == null || ( optional == null && out == null ) )
|
||||
if( in == null || ( optional == null && out == null ) )
|
||||
{
|
||||
this.log( "Invalid Grinder Recipe Specified." );
|
||||
return;
|
||||
@@ -111,7 +111,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
@Override
|
||||
public void addRecipe( ItemStack in, ItemStack out, ItemStack optional, float chance, ItemStack optional2, float chance2, int cost )
|
||||
{
|
||||
if ( in == null || ( optional == null && out == null && optional2 == null ) )
|
||||
if( in == null || ( optional == null && out == null && optional2 == null ) )
|
||||
{
|
||||
this.log( "Invalid Grinder Recipe Specified." );
|
||||
return;
|
||||
@@ -123,8 +123,8 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
|
||||
private void injectRecipe( AppEngGrinderRecipe appEngGrinderRecipe )
|
||||
{
|
||||
for ( IGrinderEntry gr : this.recipes )
|
||||
if ( Platform.isSameItemPrecise( gr.getInput(), appEngGrinderRecipe.getInput() ) )
|
||||
for( IGrinderEntry gr : this.recipes )
|
||||
if( Platform.isSameItemPrecise( gr.getInput(), appEngGrinderRecipe.getInput() ) )
|
||||
return;
|
||||
|
||||
this.recipes.add( appEngGrinderRecipe );
|
||||
@@ -132,7 +132,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
|
||||
private ItemStack copy( ItemStack is )
|
||||
{
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
return is.copy();
|
||||
return null;
|
||||
}
|
||||
@@ -141,11 +141,11 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
public IGrinderEntry getRecipeForInput( ItemStack input )
|
||||
{
|
||||
this.log( "Looking up recipe for " + Platform.getItemDisplayName( input ) );
|
||||
if ( input != null )
|
||||
if( input != null )
|
||||
{
|
||||
for ( IGrinderEntry r : this.recipes )
|
||||
for( IGrinderEntry r : this.recipes )
|
||||
{
|
||||
if ( Platform.isSameItem( input, r.getInput() ) )
|
||||
if( Platform.isSameItem( input, r.getInput() ) )
|
||||
{
|
||||
this.log( "Recipe for " + input.getUnlocalizedName() + " found " + Platform.getItemDisplayName( r.getOutput() ) );
|
||||
return r;
|
||||
@@ -165,28 +165,28 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
|
||||
private int getDustToOreRatio( String name )
|
||||
{
|
||||
if ( name.equals( "Obsidian" ) )
|
||||
if( name.equals( "Obsidian" ) )
|
||||
return 1;
|
||||
if ( name.equals( "Charcoal" ) )
|
||||
if( name.equals( "Charcoal" ) )
|
||||
return 1;
|
||||
if ( name.equals( "Coal" ) )
|
||||
if( name.equals( "Coal" ) )
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
private void addOre( String name, ItemStack item )
|
||||
{
|
||||
if ( item == null )
|
||||
if( item == null )
|
||||
return;
|
||||
this.log( "Adding Ore - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
|
||||
this.ores.put( item, name );
|
||||
|
||||
if ( this.dusts.containsKey( name ) )
|
||||
if( this.dusts.containsKey( name ) )
|
||||
{
|
||||
ItemStack is = this.dusts.get( name ).copy();
|
||||
int ratio = this.getDustToOreRatio( name );
|
||||
if ( ratio > 1 )
|
||||
if( ratio > 1 )
|
||||
{
|
||||
ItemStack extra = is.copy();
|
||||
extra.stackSize = ratio - 1;
|
||||
@@ -199,13 +199,13 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
|
||||
private void addIngot( String name, ItemStack item )
|
||||
{
|
||||
if ( item == null )
|
||||
if( item == null )
|
||||
return;
|
||||
this.log( "Adding Ingot - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
|
||||
this.ingots.put( item, name );
|
||||
|
||||
if ( this.dusts.containsKey( name ) )
|
||||
if( this.dusts.containsKey( name ) )
|
||||
{
|
||||
this.addRecipe( item, this.dusts.get( name ), 4 );
|
||||
}
|
||||
@@ -213,9 +213,9 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
|
||||
private void addDust( String name, ItemStack item )
|
||||
{
|
||||
if ( item == null )
|
||||
if( item == null )
|
||||
return;
|
||||
if ( this.dusts.containsKey( name ) )
|
||||
if( this.dusts.containsKey( name ) )
|
||||
{
|
||||
this.log( "Rejecting Dust - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
return;
|
||||
@@ -225,13 +225,13 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
|
||||
this.dusts.put( name, item );
|
||||
|
||||
for ( Entry<ItemStack, String> d : this.ores.entrySet() )
|
||||
if ( name.equals( d.getValue() ) )
|
||||
for( Entry<ItemStack, String> d : this.ores.entrySet() )
|
||||
if( name.equals( d.getValue() ) )
|
||||
{
|
||||
ItemStack is = item.copy();
|
||||
is.stackSize = 1;
|
||||
int ratio = this.getDustToOreRatio( name );
|
||||
if ( ratio > 1 )
|
||||
if( ratio > 1 )
|
||||
{
|
||||
ItemStack extra = is.copy();
|
||||
extra.stackSize = ratio - 1;
|
||||
@@ -241,27 +241,27 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
|
||||
this.addRecipe( d.getKey(), is, 8 );
|
||||
}
|
||||
|
||||
for ( Entry<ItemStack, String> d : this.ingots.entrySet() )
|
||||
if ( name.equals( d.getValue() ) )
|
||||
for( Entry<ItemStack, String> d : this.ingots.entrySet() )
|
||||
if( name.equals( d.getValue() ) )
|
||||
this.addRecipe( d.getKey(), item, 4 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void oreRegistered( String name, ItemStack item )
|
||||
{
|
||||
if ( name.startsWith( "ore" ) || name.startsWith( "crystal" ) || name.startsWith( "gem" ) || name.startsWith( "ingot" ) || name.startsWith( "dust" ) )
|
||||
if( name.startsWith( "ore" ) || name.startsWith( "crystal" ) || name.startsWith( "gem" ) || name.startsWith( "ingot" ) || name.startsWith( "dust" ) )
|
||||
{
|
||||
for ( String ore : AEConfig.instance.grinderOres )
|
||||
for( String ore : AEConfig.instance.grinderOres )
|
||||
{
|
||||
if ( name.equals( "ore" + ore ) )
|
||||
if( name.equals( "ore" + ore ) )
|
||||
{
|
||||
this.addOre( ore, item );
|
||||
}
|
||||
else if ( name.equals( "crystal" + ore ) || name.equals( "ingot" + ore ) || name.equals( "gem" + ore ) )
|
||||
else if( name.equals( "crystal" + ore ) || name.equals( "ingot" + ore ) || name.equals( "gem" + ore ) )
|
||||
{
|
||||
this.addIngot( ore, item );
|
||||
}
|
||||
else if ( name.equals( "dust" + ore ) )
|
||||
else if( name.equals( "dust" + ore ) )
|
||||
{
|
||||
this.addDust( ore, item );
|
||||
}
|
||||
|
||||
@@ -46,14 +46,14 @@ public final class LocatableRegistry implements ILocatableRegistry
|
||||
@SubscribeEvent
|
||||
public void updateLocatable( LocatableEventAnnounce e )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return; // IGNORE!
|
||||
|
||||
if ( e.change == LocatableEvent.Register )
|
||||
if( e.change == LocatableEvent.Register )
|
||||
{
|
||||
this.set.put( e.target.getLocatableSerial(), e.target );
|
||||
}
|
||||
else if ( e.change == LocatableEvent.Unregister )
|
||||
else if( e.change == LocatableEvent.Unregister )
|
||||
{
|
||||
this.set.remove( e.target.getLocatableSerial() );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
@@ -28,29 +29,39 @@ import appeng.recipes.ores.IOreListener;
|
||||
import appeng.recipes.ores.OreDictionaryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmoRegistry
|
||||
{
|
||||
|
||||
private final HashMap<ItemStack, Double> DamageModifiers = new HashMap<ItemStack, Double>();
|
||||
|
||||
public MatterCannonAmmoRegistry()
|
||||
{
|
||||
OreDictionaryHandler.INSTANCE.observe( this );
|
||||
this.registerAmmo( new ItemStack( Items.gold_nugget ), 196.96655 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAmmo(ItemStack ammo, double weight)
|
||||
public void registerAmmo( ItemStack ammo, double weight )
|
||||
{
|
||||
this.DamageModifiers.put( ammo, weight );
|
||||
}
|
||||
|
||||
private void considerItem(String ore, ItemStack item, String Name, double weight)
|
||||
@Override
|
||||
public float getPenetration( ItemStack is )
|
||||
{
|
||||
if ( ore.equals( "berry" + Name ) || ore.equals( "nugget" + Name ) )
|
||||
for( ItemStack o : this.DamageModifiers.keySet() )
|
||||
{
|
||||
this.registerAmmo( item, weight );
|
||||
if( Platform.isSameItem( o, is ) )
|
||||
return this.DamageModifiers.get( o ).floatValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void oreRegistered(String name, ItemStack item)
|
||||
public void oreRegistered( String name, ItemStack item )
|
||||
{
|
||||
if ( !(name.startsWith( "berry" ) || name.startsWith( "nugget" )) )
|
||||
if( !( name.startsWith( "berry" ) || name.startsWith( "nugget" ) ) )
|
||||
return;
|
||||
|
||||
// addNugget( "Cobble", 18 ); // ?
|
||||
@@ -122,24 +133,15 @@ public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmo
|
||||
this.considerItem( name, item, "Plutonium", 244 );
|
||||
|
||||
// TE stuff...
|
||||
this.considerItem( name, item, "Invar", (58.6934 + 55.845 + 55.845) / 3.0 );
|
||||
this.considerItem( name, item, "Electrum", (107.8682 + 196.96655) / 2.0 );
|
||||
this.considerItem( name, item, "Invar", ( 58.6934 + 55.845 + 55.845 ) / 3.0 );
|
||||
this.considerItem( name, item, "Electrum", ( 107.8682 + 196.96655 ) / 2.0 );
|
||||
}
|
||||
|
||||
public MatterCannonAmmoRegistry() {
|
||||
OreDictionaryHandler.INSTANCE.observe( this );
|
||||
this.registerAmmo( new ItemStack( Items.gold_nugget ), 196.96655 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPenetration(ItemStack is)
|
||||
private void considerItem( String ore, ItemStack item, String Name, double weight )
|
||||
{
|
||||
for (ItemStack o : this.DamageModifiers.keySet())
|
||||
if( ore.equals( "berry" + Name ) || ore.equals( "nugget" + Name ) )
|
||||
{
|
||||
if ( Platform.isSameItem( o, is ) )
|
||||
return this.DamageModifiers.get( o ).floatValue();
|
||||
this.registerAmmo( item, weight );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
@@ -31,6 +32,7 @@ import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import appeng.spatial.DefaultSpatialHandler;
|
||||
|
||||
|
||||
public class MovableTileRegistry implements IMovableRegistry
|
||||
{
|
||||
|
||||
@@ -43,14 +45,53 @@ public class MovableTileRegistry implements IMovableRegistry
|
||||
|
||||
private final IMovableHandler nullHandler = new DefaultSpatialHandler();
|
||||
|
||||
private IMovableHandler testClass(Class myClass, TileEntity te)
|
||||
@Override
|
||||
public void blacklistBlock( Block blk )
|
||||
{
|
||||
this.blacklisted.add( blk );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whiteListTileEntity( Class<? extends TileEntity> c )
|
||||
{
|
||||
|
||||
if( c.getName().equals( TileEntity.class.getName() ) )
|
||||
{
|
||||
throw new RuntimeException( new AppEngException( "Someone tried to make all tiles movable, this is a clear violation of the purpose of the white list." ) );
|
||||
}
|
||||
|
||||
this.test.add( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean askToMove( TileEntity te )
|
||||
{
|
||||
Class myClass = te.getClass();
|
||||
IMovableHandler canMove = this.Valid.get( myClass );
|
||||
|
||||
if( canMove == null )
|
||||
canMove = this.testClass( myClass, te );
|
||||
|
||||
if( canMove != this.nullHandler )
|
||||
{
|
||||
if( te instanceof IMovableTile )
|
||||
( (IMovableTile) te ).prepareToMove();
|
||||
|
||||
te.invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private IMovableHandler testClass( Class myClass, TileEntity te )
|
||||
{
|
||||
IMovableHandler handler = null;
|
||||
|
||||
// ask handlers...
|
||||
for (IMovableHandler han : this.handlers)
|
||||
for( IMovableHandler han : this.handlers )
|
||||
{
|
||||
if ( han.canHandle( myClass, te ) )
|
||||
if( han.canHandle( myClass, te ) )
|
||||
{
|
||||
handler = han;
|
||||
break;
|
||||
@@ -58,24 +99,23 @@ public class MovableTileRegistry implements IMovableRegistry
|
||||
}
|
||||
|
||||
// if you have a handler your opted in
|
||||
if ( handler != null )
|
||||
if( handler != null )
|
||||
{
|
||||
this.Valid.put( myClass, handler );
|
||||
return handler;
|
||||
|
||||
}
|
||||
|
||||
// if your movable our opted in
|
||||
if ( te instanceof IMovableTile )
|
||||
if( te instanceof IMovableTile )
|
||||
{
|
||||
this.Valid.put( myClass, this.dsh );
|
||||
return this.dsh;
|
||||
}
|
||||
|
||||
// if you are on the white list your opted in.
|
||||
for (Class<? extends TileEntity> testClass : this.test)
|
||||
for( Class<? extends TileEntity> testClass : this.test )
|
||||
{
|
||||
if ( testClass.isAssignableFrom( myClass ) )
|
||||
if( testClass.isAssignableFrom( myClass ) )
|
||||
{
|
||||
this.Valid.put( myClass, this.dsh );
|
||||
return this.dsh;
|
||||
@@ -87,30 +127,9 @@ public class MovableTileRegistry implements IMovableRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean askToMove(TileEntity te)
|
||||
public void doneMoving( TileEntity te )
|
||||
{
|
||||
Class myClass = te.getClass();
|
||||
IMovableHandler canMove = this.Valid.get( myClass );
|
||||
|
||||
if ( canMove == null )
|
||||
canMove = this.testClass( myClass, te );
|
||||
|
||||
if ( canMove != this.nullHandler )
|
||||
{
|
||||
if ( te instanceof IMovableTile )
|
||||
((IMovableTile) te).prepareToMove();
|
||||
|
||||
te.invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneMoving(TileEntity te)
|
||||
{
|
||||
if ( te instanceof IMovableTile )
|
||||
if( te instanceof IMovableTile )
|
||||
{
|
||||
IMovableTile mt = (IMovableTile) te;
|
||||
mt.doneMoving();
|
||||
@@ -118,26 +137,13 @@ public class MovableTileRegistry implements IMovableRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whiteListTileEntity(Class<? extends TileEntity> c)
|
||||
{
|
||||
|
||||
if ( c.getName().equals( TileEntity.class.getName() ) )
|
||||
{
|
||||
throw new RuntimeException( new AppEngException(
|
||||
"Someone tried to make all tiles movable, this is a clear violation of the purpose of the white list." ) );
|
||||
}
|
||||
|
||||
this.test.add( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHandler(IMovableHandler han)
|
||||
public void addHandler( IMovableHandler han )
|
||||
{
|
||||
this.handlers.add( han );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableHandler getHandler(TileEntity te)
|
||||
public IMovableHandler getHandler( TileEntity te )
|
||||
{
|
||||
Class myClass = te.getClass();
|
||||
IMovableHandler h = this.Valid.get( myClass );
|
||||
@@ -151,15 +157,8 @@ public class MovableTileRegistry implements IMovableRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blacklistBlock(Block blk)
|
||||
{
|
||||
this.blacklisted.add( blk );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlacklisted(Block blk)
|
||||
public boolean isBlacklisted( Block blk )
|
||||
{
|
||||
return this.blacklisted.contains( blk );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -38,22 +39,12 @@ import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
{
|
||||
|
||||
final HashMap<ItemStack, TunnelType> Tunnels = new HashMap<ItemStack, TunnelType>();
|
||||
|
||||
public ItemStack getModItem(String modID, String Name, int meta)
|
||||
{
|
||||
ItemStack myItemStack = GameRegistry.findItemStack( modID, Name, 1 );
|
||||
|
||||
if ( myItemStack == null )
|
||||
return null;
|
||||
|
||||
myItemStack.setItemDamage( meta );
|
||||
return myItemStack;
|
||||
}
|
||||
|
||||
public void configure()
|
||||
{
|
||||
/**
|
||||
@@ -111,7 +102,7 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
this.addNewAttunement( this.getModItem( "ExtraUtilities", "drum", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
||||
this.addNewAttunement( this.getModItem( "EnderIO", "itemLiquidConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
||||
|
||||
for (AEColor c : AEColor.values())
|
||||
for( AEColor c : AEColor.values() )
|
||||
{
|
||||
this.addNewAttunement( parts.cableGlass().stack( c, 1 ), TunnelType.ME );
|
||||
this.addNewAttunement( parts.cableCovered().stack( c, 1 ), TunnelType.ME );
|
||||
@@ -120,42 +111,52 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewAttunement( ItemStack trigger, TunnelType type )
|
||||
{
|
||||
if( type == null || trigger == null )
|
||||
return;
|
||||
|
||||
this.Tunnels.put( trigger, type );
|
||||
}
|
||||
|
||||
public ItemStack getModItem( String modID, String Name, int meta )
|
||||
{
|
||||
ItemStack myItemStack = GameRegistry.findItemStack( modID, Name, 1 );
|
||||
|
||||
if( myItemStack == null )
|
||||
return null;
|
||||
|
||||
myItemStack.setItemDamage( meta );
|
||||
return myItemStack;
|
||||
}
|
||||
|
||||
private void addNewAttunement( IItemDefinition definition, TunnelType type )
|
||||
{
|
||||
for ( ItemStack definitionStack : definition.maybeStack( 1 ).asSet() )
|
||||
for( ItemStack definitionStack : definition.maybeStack( 1 ).asSet() )
|
||||
{
|
||||
this.addNewAttunement( definitionStack, type );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewAttunement(ItemStack trigger, TunnelType type)
|
||||
public TunnelType getTunnelTypeByItem( ItemStack trigger )
|
||||
{
|
||||
if ( type == null || trigger == null )
|
||||
return;
|
||||
|
||||
this.Tunnels.put( trigger, type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TunnelType getTunnelTypeByItem(ItemStack trigger)
|
||||
{
|
||||
if ( trigger != null )
|
||||
if( trigger != null )
|
||||
{
|
||||
if ( FluidContainerRegistry.isContainer( trigger ) )
|
||||
if( FluidContainerRegistry.isContainer( trigger ) )
|
||||
return TunnelType.FLUID;
|
||||
|
||||
for (ItemStack is : this.Tunnels.keySet())
|
||||
for( ItemStack is : this.Tunnels.keySet() )
|
||||
{
|
||||
if ( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
|
||||
if( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
|
||||
return this.Tunnels.get( is );
|
||||
|
||||
if ( Platform.isSameItem( is, trigger ) )
|
||||
if( Platform.isSameItem( is, trigger ) )
|
||||
return this.Tunnels.get( is );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,32 +18,33 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import appeng.api.features.IPlayerRegistry;
|
||||
import appeng.core.WorldSettings;
|
||||
|
||||
|
||||
public class PlayerRegistry implements IPlayerRegistry
|
||||
{
|
||||
|
||||
@Override
|
||||
public int getID(GameProfile username)
|
||||
public int getID( GameProfile username )
|
||||
{
|
||||
return WorldSettings.getInstance().getPlayerID( username );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID(EntityPlayer player)
|
||||
public int getID( EntityPlayer player )
|
||||
{
|
||||
return WorldSettings.getInstance().getPlayerID( player.getGameProfile() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer findPlayer(int playerID)
|
||||
public EntityPlayer findPlayer( int playerID )
|
||||
{
|
||||
return WorldSettings.getInstance().getPlayerFromID( playerID );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -28,6 +29,7 @@ import appeng.api.recipes.ISubItemResolver;
|
||||
import appeng.core.AELog;
|
||||
import appeng.recipes.RecipeHandler;
|
||||
|
||||
|
||||
public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
|
||||
{
|
||||
|
||||
@@ -35,22 +37,28 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
|
||||
final LinkedList<ISubItemResolver> resolvers = new LinkedList<ISubItemResolver>();
|
||||
|
||||
@Override
|
||||
public void addNewCraftHandler(String name, Class<? extends ICraftHandler> handler)
|
||||
public void addNewCraftHandler( String name, Class<? extends ICraftHandler> handler )
|
||||
{
|
||||
this.handlers.put( name.toLowerCase(), handler );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftHandler getCraftHandlerFor(String name)
|
||||
public void addNewSubItemResolver( ISubItemResolver sir )
|
||||
{
|
||||
this.resolvers.add( sir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftHandler getCraftHandlerFor( String name )
|
||||
{
|
||||
Class<? extends ICraftHandler> clz = this.handlers.get( name );
|
||||
if ( clz == null )
|
||||
if( clz == null )
|
||||
return null;
|
||||
try
|
||||
{
|
||||
return clz.newInstance();
|
||||
}
|
||||
catch (Throwable e)
|
||||
catch( Throwable e )
|
||||
{
|
||||
AELog.severe( "Error Caused when trying to construct " + clz.getName() );
|
||||
AELog.error( e );
|
||||
@@ -66,15 +74,9 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewSubItemResolver(ISubItemResolver sir)
|
||||
public Object resolveItem( String nameSpace, String itemName )
|
||||
{
|
||||
this.resolvers.add( sir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveItem(String nameSpace, String itemName)
|
||||
{
|
||||
for (ISubItemResolver sir : this.resolvers)
|
||||
for( ISubItemResolver sir : this.resolvers )
|
||||
{
|
||||
Object rr = null;
|
||||
|
||||
@@ -82,16 +84,15 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
|
||||
{
|
||||
rr = sir.resolveItemByName( nameSpace, itemName );
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch( Throwable t )
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
if ( rr != null )
|
||||
if( rr != null )
|
||||
return rr;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import appeng.api.features.IGrinderRegistry;
|
||||
import appeng.api.features.ILocatableRegistry;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
@@ -33,6 +34,7 @@ import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.api.storage.ICellRegistry;
|
||||
import appeng.api.storage.IExternalStorageRegistry;
|
||||
|
||||
|
||||
public class RegistryContainer implements IRegistryContainer
|
||||
{
|
||||
|
||||
@@ -49,6 +51,30 @@ public class RegistryContainer implements IRegistryContainer
|
||||
private final PlayerRegistry playerRegistry = new PlayerRegistry();
|
||||
private final IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry();
|
||||
|
||||
@Override
|
||||
public IMovableRegistry movable()
|
||||
{
|
||||
return this.MovableReg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridCacheRegistry gridCache()
|
||||
{
|
||||
return this.GridCacheRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExternalStorageRegistry externalStorage()
|
||||
{
|
||||
return this.ExternalStorageHandlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpecialComparisonRegistry specialComparison()
|
||||
{
|
||||
return this.SpecialComparisonRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWirelessTermRegistry wireless()
|
||||
{
|
||||
@@ -67,36 +93,12 @@ public class RegistryContainer implements IRegistryContainer
|
||||
return this.GrinderRecipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpecialComparisonRegistry specialComparison()
|
||||
{
|
||||
return this.SpecialComparisonRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExternalStorageRegistry externalStorage()
|
||||
{
|
||||
return this.ExternalStorageHandlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILocatableRegistry locatable()
|
||||
{
|
||||
return this.LocatableRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridCacheRegistry gridCache()
|
||||
{
|
||||
return this.GridCacheRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableRegistry movable()
|
||||
{
|
||||
return this.MovableReg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IP2PTunnelRegistry p2pTunnel()
|
||||
{
|
||||
@@ -126,5 +128,4 @@ public class RegistryContainer implements IRegistryContainer
|
||||
{
|
||||
return WorldGenRegistry.INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,22 +28,24 @@ import appeng.api.features.IItemComparison;
|
||||
import appeng.api.features.IItemComparisonProvider;
|
||||
import appeng.api.features.ISpecialComparisonRegistry;
|
||||
|
||||
|
||||
public class SpecialComparisonRegistry implements ISpecialComparisonRegistry
|
||||
{
|
||||
|
||||
private final List<IItemComparisonProvider> CompRegistry;
|
||||
|
||||
public SpecialComparisonRegistry() {
|
||||
public SpecialComparisonRegistry()
|
||||
{
|
||||
this.CompRegistry = new ArrayList<IItemComparisonProvider>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemComparison getSpecialComparison(ItemStack stack)
|
||||
public IItemComparison getSpecialComparison( ItemStack stack )
|
||||
{
|
||||
for (IItemComparisonProvider i : this.CompRegistry)
|
||||
for( IItemComparisonProvider i : this.CompRegistry )
|
||||
{
|
||||
IItemComparison comp = i.getComparison( stack );
|
||||
if ( comp != null )
|
||||
if( comp != null )
|
||||
{
|
||||
return comp;
|
||||
}
|
||||
@@ -52,9 +55,8 @@ public class SpecialComparisonRegistry implements ISpecialComparisonRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComparisonProvider(IItemComparisonProvider prov)
|
||||
public void addComparisonProvider( IItemComparisonProvider prov )
|
||||
{
|
||||
this.CompRegistry.add( prov );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,17 +18,19 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
||||
public class WirelessRangeResult
|
||||
{
|
||||
|
||||
public WirelessRangeResult(TileEntity t, float d) {
|
||||
this.dist = d;
|
||||
this.te = t;
|
||||
}
|
||||
|
||||
final public float dist;
|
||||
final public TileEntity te;
|
||||
|
||||
public WirelessRangeResult( TileEntity t, float d )
|
||||
{
|
||||
this.dist = d;
|
||||
this.te = t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,50 +34,52 @@ import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public final class WirelessRegistry implements IWirelessTermRegistry
|
||||
{
|
||||
private final List<IWirelessTermHandler> handlers;
|
||||
|
||||
public WirelessRegistry() {
|
||||
public WirelessRegistry()
|
||||
{
|
||||
this.handlers = new ArrayList<IWirelessTermHandler>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWirelessHandler(IWirelessTermHandler handler)
|
||||
public void registerWirelessHandler( IWirelessTermHandler handler )
|
||||
{
|
||||
if ( handler != null )
|
||||
if( handler != null )
|
||||
this.handlers.add( handler );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWirelessTerminal(ItemStack is)
|
||||
public boolean isWirelessTerminal( ItemStack is )
|
||||
{
|
||||
for (IWirelessTermHandler h : this.handlers)
|
||||
for( IWirelessTermHandler h : this.handlers )
|
||||
{
|
||||
if ( h.canHandle( is ) )
|
||||
if( h.canHandle( is ) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWirelessTermHandler getWirelessTerminalHandler(ItemStack is)
|
||||
public IWirelessTermHandler getWirelessTerminalHandler( ItemStack is )
|
||||
{
|
||||
for (IWirelessTermHandler h : this.handlers)
|
||||
for( IWirelessTermHandler h : this.handlers )
|
||||
{
|
||||
if ( h.canHandle( is ) )
|
||||
if( h.canHandle( is ) )
|
||||
return h;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openWirelessTerminalGui(ItemStack item, World w, EntityPlayer player)
|
||||
public void openWirelessTerminalGui( ItemStack item, World w, EntityPlayer player )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
return;
|
||||
|
||||
if ( !this.isWirelessTerminal( item ) )
|
||||
if( !this.isWirelessTerminal( item ) )
|
||||
{
|
||||
player.addChatMessage( PlayerMessages.DeviceNotWirelessTerminal.get() );
|
||||
return;
|
||||
@@ -85,7 +87,7 @@ public final class WirelessRegistry implements IWirelessTermRegistry
|
||||
|
||||
final IWirelessTermHandler handler = this.getWirelessTerminalHandler( item );
|
||||
final String unparsedKey = handler.getEncryptionKey( item );
|
||||
if ( unparsedKey.length() == 0 )
|
||||
if( unparsedKey.length() == 0 )
|
||||
{
|
||||
player.addChatMessage( PlayerMessages.DeviceNotLinked.get() );
|
||||
return;
|
||||
@@ -93,19 +95,17 @@ public final class WirelessRegistry implements IWirelessTermRegistry
|
||||
|
||||
final long parsedKey = Long.parseLong( unparsedKey );
|
||||
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy( parsedKey );
|
||||
if ( securityStation == null )
|
||||
if( securityStation == null )
|
||||
{
|
||||
player.addChatMessage( PlayerMessages.StationCanNotBeLocated.get() );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( handler.hasPower( player, 0.5, item ) )
|
||||
if( handler.hasPower( player, 0.5, item ) )
|
||||
{
|
||||
Platform.openGUI( player, null, null, GuiBridge.GUI_WIRELESS_TERM );
|
||||
}
|
||||
else
|
||||
player.addChatMessage( PlayerMessages.DeviceNotPowered.get() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries;
|
||||
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
@@ -25,75 +26,49 @@ import net.minecraft.world.WorldProvider;
|
||||
|
||||
import appeng.api.features.IWorldGen;
|
||||
|
||||
|
||||
public final class WorldGenRegistry implements IWorldGen
|
||||
{
|
||||
|
||||
private static class TypeSet
|
||||
{
|
||||
|
||||
final HashSet<Class<? extends WorldProvider>> badProviders = new HashSet<Class<? extends WorldProvider>>();
|
||||
final HashSet<Integer> badDimensions = new HashSet<Integer>();
|
||||
final HashSet<Integer> enabledDimensions = new HashSet<Integer>();
|
||||
|
||||
}
|
||||
|
||||
static final public WorldGenRegistry INSTANCE = new WorldGenRegistry();
|
||||
final TypeSet[] types;
|
||||
|
||||
static final public WorldGenRegistry INSTANCE = new WorldGenRegistry();
|
||||
|
||||
private WorldGenRegistry() {
|
||||
private WorldGenRegistry()
|
||||
{
|
||||
|
||||
this.types = new TypeSet[WorldGenType.values().length];
|
||||
|
||||
for (WorldGenType type : WorldGenType.values())
|
||||
for( WorldGenType type : WorldGenType.values() )
|
||||
{
|
||||
this.types[type.ordinal()] = new TypeSet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldGenEnabled(WorldGenType type, World w)
|
||||
public void disableWorldGenForProviderID( WorldGenType type, Class<? extends WorldProvider> provider )
|
||||
{
|
||||
if ( type == null )
|
||||
if( type == null )
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
|
||||
if ( w == null )
|
||||
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||
|
||||
boolean isBadProvider = this.types[type.ordinal()].badProviders.contains( w.provider.getClass() );
|
||||
boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains( w.provider.dimensionId );
|
||||
boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains( w.provider.dimensionId );
|
||||
|
||||
if ( isBadProvider || isBadDimension )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !isGoodDimension && type == WorldGenType.Meteorites)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableWorldGenForProviderID(WorldGenType type, Class<? extends WorldProvider> provider)
|
||||
{
|
||||
if ( type == null )
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
|
||||
if ( provider == null )
|
||||
if( provider == null )
|
||||
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||
|
||||
this.types[type.ordinal()].badProviders.add( provider );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableWorldGenForDimension(WorldGenType type, int dimensionID)
|
||||
public void enableWorldGenForDimension( WorldGenType type, int dimensionID )
|
||||
{
|
||||
if ( type == null )
|
||||
if( type == null )
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
|
||||
this.types[type.ordinal()].enabledDimensions.add( dimensionID );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableWorldGenForDimension( WorldGenType type, int dimensionID )
|
||||
{
|
||||
if( type == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
}
|
||||
@@ -102,12 +77,36 @@ public final class WorldGenRegistry implements IWorldGen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableWorldGenForDimension(WorldGenType type, int dimensionID)
|
||||
public boolean isWorldGenEnabled( WorldGenType type, World w )
|
||||
{
|
||||
if ( type == null )
|
||||
if( type == null )
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
|
||||
this.types[type.ordinal()].enabledDimensions.add( dimensionID );
|
||||
if( w == null )
|
||||
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||
|
||||
boolean isBadProvider = this.types[type.ordinal()].badProviders.contains( w.provider.getClass() );
|
||||
boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains( w.provider.dimensionId );
|
||||
boolean isGoodDimension = this.types[type.ordinal()].enabledDimensions.contains( w.provider.dimensionId );
|
||||
|
||||
if( isBadProvider || isBadDimension )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !isGoodDimension && type == WorldGenType.Meteorites )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class TypeSet
|
||||
{
|
||||
|
||||
final HashSet<Class<? extends WorldProvider>> badProviders = new HashSet<Class<? extends WorldProvider>>();
|
||||
final HashSet<Integer> badDimensions = new HashSet<Integer>();
|
||||
final HashSet<Integer> enabledDimensions = new HashSet<Integer>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.features.IGrinderEntry;
|
||||
|
||||
|
||||
public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
{
|
||||
|
||||
@@ -36,13 +38,15 @@ public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
|
||||
private int energy;
|
||||
|
||||
public AppEngGrinderRecipe(ItemStack a, ItemStack b, int cost) {
|
||||
public AppEngGrinderRecipe( ItemStack a, ItemStack b, int cost )
|
||||
{
|
||||
this.in = a;
|
||||
this.out = b;
|
||||
this.energy = cost;
|
||||
}
|
||||
|
||||
public AppEngGrinderRecipe(ItemStack a, ItemStack b, ItemStack c, float chance, int cost) {
|
||||
public AppEngGrinderRecipe( ItemStack a, ItemStack b, ItemStack c, float chance, int cost )
|
||||
{
|
||||
this.in = a;
|
||||
this.out = b;
|
||||
|
||||
@@ -52,7 +56,8 @@ public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
this.energy = cost;
|
||||
}
|
||||
|
||||
public AppEngGrinderRecipe(ItemStack a, ItemStack b, ItemStack c, ItemStack d, float chance, float chance2, int cost) {
|
||||
public AppEngGrinderRecipe( ItemStack a, ItemStack b, ItemStack c, ItemStack d, float chance, float chance2, int cost )
|
||||
{
|
||||
this.in = a;
|
||||
this.out = b;
|
||||
|
||||
@@ -72,7 +77,7 @@ public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInput(ItemStack i)
|
||||
public void setInput( ItemStack i )
|
||||
{
|
||||
this.in = i.copy();
|
||||
}
|
||||
@@ -84,23 +89,11 @@ public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutput(ItemStack o)
|
||||
public void setOutput( ItemStack o )
|
||||
{
|
||||
this.out = o.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyCost()
|
||||
{
|
||||
return this.energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyCost(int c)
|
||||
{
|
||||
this.energy = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOptionalOutput()
|
||||
{
|
||||
@@ -108,7 +101,13 @@ public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionalOutput(ItemStack output, float chance)
|
||||
public ItemStack getSecondOptionalOutput()
|
||||
{
|
||||
return this.optionalOutput2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionalOutput( ItemStack output, float chance )
|
||||
{
|
||||
this.optionalOutput = output.copy();
|
||||
this.optionalChance = chance;
|
||||
@@ -121,13 +120,7 @@ public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSecondOptionalOutput()
|
||||
{
|
||||
return this.optionalOutput2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondOptionalOutput(ItemStack output, float chance)
|
||||
public void setSecondOptionalOutput( ItemStack output, float chance )
|
||||
{
|
||||
this.optionalChance2 = chance;
|
||||
this.optionalOutput2 = output.copy();
|
||||
@@ -139,4 +132,15 @@ public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
return this.optionalChance2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyCost()
|
||||
{
|
||||
return this.energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyCost( int c )
|
||||
{
|
||||
this.energy = c;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -37,29 +38,24 @@ import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BasicCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isCell(ItemStack is)
|
||||
public boolean isCell( ItemStack is )
|
||||
{
|
||||
return CellInventory.isCell( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel channel)
|
||||
public IMEInventoryHandler getCellInventory( ItemStack is, ISaveProvider container, StorageChannel channel )
|
||||
{
|
||||
if ( channel == StorageChannel.ITEMS )
|
||||
if( channel == StorageChannel.ITEMS )
|
||||
return CellInventory.getCell( is, container );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Dark()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Dark.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Light()
|
||||
{
|
||||
@@ -73,15 +69,21 @@ public class BasicCellHandler implements ICellHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui(EntityPlayer player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler inv, ItemStack is, StorageChannel chan)
|
||||
public IIcon getTopTexture_Dark()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Dark.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui( EntityPlayer player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler inv, ItemStack is, StorageChannel chan )
|
||||
{
|
||||
Platform.openGUI( player, (AEBaseTile) chest, chest.getUp(), GuiBridge.GUI_ME );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell(ItemStack is, IMEInventory handler)
|
||||
public int getStatusForCell( ItemStack is, IMEInventory handler )
|
||||
{
|
||||
if ( handler instanceof CellInventoryHandler )
|
||||
if( handler instanceof CellInventoryHandler )
|
||||
{
|
||||
CellInventoryHandler ci = (CellInventoryHandler) handler;
|
||||
return ci.getStatusForCell();
|
||||
@@ -90,9 +92,9 @@ public class BasicCellHandler implements ICellHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain(ItemStack is, IMEInventory handler)
|
||||
public double cellIdleDrain( ItemStack is, IMEInventory handler )
|
||||
{
|
||||
ICellInventory inv = ((ICellInventoryHandler) handler).getCellInv();
|
||||
ICellInventory inv = ( (ICellInventoryHandler) handler ).getCellInv();
|
||||
return inv.getIdleDrain();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -35,41 +36,24 @@ import appeng.me.storage.CreativeCellInventory;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class CreativeCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isCell(ItemStack is)
|
||||
public boolean isCell( ItemStack is )
|
||||
{
|
||||
return is != null && is.getItem() instanceof ItemCreativeStorageCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel channel)
|
||||
public IMEInventoryHandler getCellInventory( ItemStack is, ISaveProvider container, StorageChannel channel )
|
||||
{
|
||||
if ( channel == StorageChannel.ITEMS && is != null && is.getItem() instanceof ItemCreativeStorageCell )
|
||||
if( channel == StorageChannel.ITEMS && is != null && is.getItem() instanceof ItemCreativeStorageCell )
|
||||
return CreativeCellInventory.getCell( is );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui(EntityPlayer player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler inv, ItemStack is, StorageChannel chan)
|
||||
{
|
||||
Platform.openGUI( player, (AEBaseTile) chest, chest.getUp(), GuiBridge.GUI_ME );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell(ItemStack is, IMEInventory handler)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain(ItemStack is, IMEInventory handler)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Light()
|
||||
{
|
||||
@@ -88,4 +72,21 @@ public class CreativeCellHandler implements ICellHandler
|
||||
return ExtraBlockTextures.BlockMEChestItems_Dark.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui( EntityPlayer player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler inv, ItemStack is, StorageChannel chan )
|
||||
{
|
||||
Platform.openGUI( player, (AEBaseTile) chest, chest.getUp(), GuiBridge.GUI_ME );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell( ItemStack is, IMEInventory handler )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain( ItemStack is, IMEInventory handler )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -29,24 +30,24 @@ import appeng.api.storage.StorageChannel;
|
||||
import appeng.me.storage.MEMonitorIInventory;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
|
||||
public class ExternalIInv implements IExternalStorageHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc)
|
||||
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc )
|
||||
{
|
||||
return channel == StorageChannel.ITEMS && te instanceof IInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src)
|
||||
public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src )
|
||||
{
|
||||
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, d );
|
||||
|
||||
if ( channel == StorageChannel.ITEMS && ad != null )
|
||||
if( channel == StorageChannel.ITEMS && ad != null )
|
||||
return new MEMonitorIInventory( ad );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,14 +72,14 @@ public enum ButtonToolTips
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
{
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
|
||||
public String getLocal()
|
||||
{
|
||||
return StatCollector.translateToLocal( this.getUnlocalized() );
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
{
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
|
||||
package appeng.core.localization;
|
||||
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
|
||||
public enum GuiText
|
||||
{
|
||||
inventory("container"), // mc's default Inventory localization.
|
||||
inventory( "container" ), // mc's default Inventory localization.
|
||||
|
||||
Chest, StoredEnergy, Of, Condenser, Drive, GrindStone, SkyChest,
|
||||
|
||||
@@ -72,17 +74,14 @@ public enum GuiText
|
||||
|
||||
final String root;
|
||||
|
||||
GuiText() {
|
||||
GuiText()
|
||||
{
|
||||
this.root = "gui.appliedenergistics2";
|
||||
}
|
||||
|
||||
GuiText(String r) {
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
GuiText( String r )
|
||||
{
|
||||
return this.root + '.' + this.toString();
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
public String getLocal()
|
||||
@@ -90,4 +89,9 @@ public enum GuiText
|
||||
return StatCollector.translateToLocal( this.getUnlocalized() );
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
{
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
|
||||
package appeng.core.localization;
|
||||
|
||||
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
|
||||
public enum PlayerMessages
|
||||
{
|
||||
ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, MachineNotPowered,
|
||||
@@ -30,14 +32,14 @@ public enum PlayerMessages
|
||||
CommunicationError, OutOfRange, DeviceNotPowered, DeviceNotWirelessTerminal, DeviceNotLinked, StationCanNotBeLocated,
|
||||
SettingCleared,;
|
||||
|
||||
String getName()
|
||||
{
|
||||
return "chat.appliedenergistics2." + this.toString();
|
||||
}
|
||||
|
||||
public IChatComponent get()
|
||||
{
|
||||
return new ChatComponentTranslation( this.getName() );
|
||||
}
|
||||
|
||||
String getName()
|
||||
{
|
||||
return "chat.appliedenergistics2." + this.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
package appeng.core.localization;
|
||||
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
|
||||
public enum WailaText
|
||||
{
|
||||
Crafting,
|
||||
@@ -32,17 +34,14 @@ public enum WailaText
|
||||
|
||||
final String root;
|
||||
|
||||
WailaText() {
|
||||
WailaText()
|
||||
{
|
||||
this.root = "waila.appliedenergistics2";
|
||||
}
|
||||
|
||||
WailaText(String r) {
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
WailaText( String r )
|
||||
{
|
||||
return this.root + '.' + this.toString();
|
||||
this.root = r;
|
||||
}
|
||||
|
||||
public String getLocal()
|
||||
@@ -50,4 +49,9 @@ public enum WailaText
|
||||
return StatCollector.translateToLocal( this.getUnlocalized() );
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
{
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,48 +18,49 @@
|
||||
|
||||
package appeng.core.settings;
|
||||
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
|
||||
public enum TickRates
|
||||
{
|
||||
|
||||
Interface(5, 120),
|
||||
Interface( 5, 120 ),
|
||||
|
||||
ImportBus(5, 40),
|
||||
ImportBus( 5, 40 ),
|
||||
|
||||
ExportBus(5, 60),
|
||||
ExportBus( 5, 60 ),
|
||||
|
||||
AnnihilationPlane(2, 120),
|
||||
AnnihilationPlane( 2, 120 ),
|
||||
|
||||
MJTunnel(1, 20),
|
||||
MJTunnel( 1, 20 ),
|
||||
|
||||
METunnel(5, 20),
|
||||
METunnel( 5, 20 ),
|
||||
|
||||
Inscriber(1, 1),
|
||||
Inscriber( 1, 1 ),
|
||||
|
||||
IOPort(1, 5),
|
||||
IOPort( 1, 5 ),
|
||||
|
||||
VibrationChamber(10, 40),
|
||||
VibrationChamber( 10, 40 ),
|
||||
|
||||
StorageBus(5, 60),
|
||||
StorageBus( 5, 60 ),
|
||||
|
||||
ItemTunnel(5, 60),
|
||||
ItemTunnel( 5, 60 ),
|
||||
|
||||
LightTunnel(5, 120);
|
||||
LightTunnel( 5, 120 );
|
||||
|
||||
public int min;
|
||||
public int max;
|
||||
|
||||
TickRates( int min, int max ) {
|
||||
TickRates( int min, int max )
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public void Load(AEConfig config)
|
||||
public void Load( AEConfig config )
|
||||
{
|
||||
config.addCustomCategoryComment(
|
||||
"TickRates",
|
||||
" Min / Max Tickrates for dynamic ticking, most of these components also use sleeping, to prevent constant ticking, adjust with care, non standard rates are not supported or tested." );
|
||||
config.addCustomCategoryComment( "TickRates", " Min / Max Tickrates for dynamic ticking, most of these components also use sleeping, to prevent constant ticking, adjust with care, non standard rates are not supported or tested." );
|
||||
this.min = config.get( "TickRates", this.name() + ".min", this.min ).getInt( this.min );
|
||||
this.max = config.get( "TickRates", this.name() + ".max", this.max ).getInt( this.max );
|
||||
}
|
||||
|
||||
@@ -44,22 +44,22 @@ public class AchievementCraftingHandler
|
||||
@SubscribeEvent
|
||||
public void onPlayerCraftingEvent( PlayerEvent.ItemCraftedEvent event )
|
||||
{
|
||||
if ( this.differentiator.isNoPlayer( event.player ) || event.crafting == null )
|
||||
if( this.differentiator.isNoPlayer( event.player ) || event.crafting == null )
|
||||
return;
|
||||
|
||||
for ( Achievements achievement : Achievements.values() )
|
||||
for( Achievements achievement : Achievements.values() )
|
||||
{
|
||||
switch ( achievement.type )
|
||||
switch( achievement.type )
|
||||
{
|
||||
case Craft:
|
||||
if ( Platform.isSameItemPrecise( achievement.stack, event.crafting ) )
|
||||
if( Platform.isSameItemPrecise( achievement.stack, event.crafting ) )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case CraftItem:
|
||||
if ( achievement.stack != null && achievement.stack.getItem().getClass() == event.crafting.getItem().getClass() )
|
||||
if( achievement.stack != null && achievement.stack.getItem().getClass() == event.crafting.getItem().getClass() )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
|
||||
@@ -46,14 +46,14 @@ public class AchievementPickupHandler
|
||||
@SubscribeEvent
|
||||
public void onItemPickUp( PlayerEvent.ItemPickupEvent event )
|
||||
{
|
||||
if ( this.differentiator.isNoPlayer( event.player ) || event.pickedUp == null || event.pickedUp.getEntityItem() == null )
|
||||
if( this.differentiator.isNoPlayer( event.player ) || event.pickedUp == null || event.pickedUp.getEntityItem() == null )
|
||||
return;
|
||||
|
||||
ItemStack is = event.pickedUp.getEntityItem();
|
||||
|
||||
for ( Achievements achievement : Achievements.values() )
|
||||
for( Achievements achievement : Achievements.values() )
|
||||
{
|
||||
if ( achievement.type == AchievementType.Pickup && Platform.isSameItemPrecise( achievement.stack, is ) )
|
||||
if( achievement.type == AchievementType.Pickup && Platform.isSameItemPrecise( achievement.stack, is ) )
|
||||
{
|
||||
achievement.addToPlayer( event.player );
|
||||
return;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
public enum AchievementType
|
||||
{
|
||||
|
||||
|
||||
@@ -114,25 +114,9 @@ public enum Achievements
|
||||
private Achievement parent;
|
||||
private Achievement stat;
|
||||
|
||||
public void setParent( Achievements parent )
|
||||
{
|
||||
this.parent = parent.getAchievement();
|
||||
}
|
||||
|
||||
public Achievement getAchievement()
|
||||
{
|
||||
if ( this.stat == null && this.stack != null )
|
||||
{
|
||||
this.stat = new Achievement( "achievement.ae2." + this.name(), "ae2." + this.name(), this.x, this.y, this.stack, this.parent );
|
||||
this.stat.registerStat();
|
||||
}
|
||||
|
||||
return this.stat;
|
||||
}
|
||||
|
||||
Achievements( int x, int y, AEColoredItemDefinition which, AchievementType type )
|
||||
{
|
||||
this.stack = (which != null) ? which.stack( AEColor.Transparent, 1 ) : null;
|
||||
this.stack = ( which != null ) ? which.stack( AEColor.Transparent, 1 ) : null;
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -154,6 +138,22 @@ public enum Achievements
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setParent( Achievements parent )
|
||||
{
|
||||
this.parent = parent.getAchievement();
|
||||
}
|
||||
|
||||
public Achievement getAchievement()
|
||||
{
|
||||
if( this.stat == null && this.stack != null )
|
||||
{
|
||||
this.stat = new Achievement( "achievement.ae2." + this.name(), "ae2." + this.name(), this.x, this.y, this.stack, this.parent );
|
||||
this.stat.registerStat();
|
||||
}
|
||||
|
||||
return this.stat;
|
||||
}
|
||||
|
||||
public void addToPlayer( EntityPlayer player )
|
||||
{
|
||||
player.addStat( this.getAchievement(), 1 );
|
||||
|
||||
@@ -38,7 +38,8 @@ public class PlayerDifferentiator
|
||||
* - dead
|
||||
* - fake
|
||||
*
|
||||
* @param player to be checked player
|
||||
* @param player to be checked player
|
||||
*
|
||||
* @return true if {@param player} is not a real player
|
||||
*/
|
||||
public boolean isNoPlayer( EntityPlayer player )
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PlayerStatsRegistration
|
||||
*/
|
||||
public void registerAchievementHandlers()
|
||||
{
|
||||
if ( this.isAchievementFeatureEnabled )
|
||||
if( this.isAchievementFeatureEnabled )
|
||||
{
|
||||
final PlayerDifferentiator differentiator = new PlayerDifferentiator();
|
||||
final AchievementCraftingHandler craftingHandler = new AchievementCraftingHandler( differentiator );
|
||||
@@ -80,12 +80,12 @@ public class PlayerStatsRegistration
|
||||
*/
|
||||
public void registerAchievements()
|
||||
{
|
||||
if ( this.isAchievementFeatureEnabled )
|
||||
if( this.isAchievementFeatureEnabled )
|
||||
{
|
||||
final AchievementHierarchy hierarchy = new AchievementHierarchy();
|
||||
hierarchy.registerAchievementHierarchy();
|
||||
|
||||
for ( Stats s : Stats.values() )
|
||||
for( Stats s : Stats.values() )
|
||||
s.getStat();
|
||||
|
||||
/**
|
||||
@@ -93,10 +93,10 @@ public class PlayerStatsRegistration
|
||||
*/
|
||||
ArrayList<Achievement> list = new ArrayList<Achievement>();
|
||||
|
||||
for ( Achievements a : Achievements.values() )
|
||||
for( Achievements a : Achievements.values() )
|
||||
{
|
||||
Achievement ach = a.getAchievement();
|
||||
if ( ach != null )
|
||||
if( ach != null )
|
||||
list.add( ach );
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
|
||||
package appeng.core.stats;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.stats.StatBasic;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
|
||||
public enum Stats
|
||||
{
|
||||
|
||||
@@ -36,9 +38,18 @@ public enum Stats
|
||||
|
||||
private StatBasic stat;
|
||||
|
||||
Stats()
|
||||
{
|
||||
}
|
||||
|
||||
public void addToPlayer( EntityPlayer player, int howMany )
|
||||
{
|
||||
player.addStat( this.getStat(), howMany );
|
||||
}
|
||||
|
||||
public StatBasic getStat()
|
||||
{
|
||||
if ( this.stat == null )
|
||||
if( this.stat == null )
|
||||
{
|
||||
this.stat = new StatBasic( "stat.ae2." + this.name(), new ChatComponentTranslation( "stat.ae2." + this.name() ) );
|
||||
this.stat.registerStat();
|
||||
@@ -47,12 +58,4 @@ public enum Stats
|
||||
return this.stat;
|
||||
}
|
||||
|
||||
Stats() {
|
||||
}
|
||||
|
||||
public void addToPlayer(EntityPlayer player, int howMany)
|
||||
{
|
||||
player.addStat( this.getStat(), howMany );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -30,29 +31,29 @@ import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
|
||||
|
||||
public abstract class AppEngPacket
|
||||
{
|
||||
|
||||
AppEngPacketHandlerBase.PacketTypes id;
|
||||
private ByteBuf p;
|
||||
|
||||
AppEngPacketHandlerBase.PacketTypes id;
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
throw new RuntimeException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." );
|
||||
}
|
||||
|
||||
final public int getPacketID()
|
||||
{
|
||||
return AppEngPacketHandlerBase.PacketTypes.getID( this.getClass() ).ordinal();
|
||||
}
|
||||
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
throw new RuntimeException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." );
|
||||
}
|
||||
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
throw new RuntimeException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." );
|
||||
}
|
||||
|
||||
protected void configureWrite(ByteBuf data)
|
||||
protected void configureWrite( ByteBuf data )
|
||||
{
|
||||
data.capacity( data.readableBytes() );
|
||||
this.p = data;
|
||||
@@ -60,15 +61,14 @@ public abstract class AppEngPacket
|
||||
|
||||
public FMLProxyPacket getProxy()
|
||||
{
|
||||
if ( this.p.array().length > 2 * 1024 * 1024 ) // 2k walking room :)
|
||||
if( this.p.array().length > 2 * 1024 * 1024 ) // 2k walking room :)
|
||||
throw new IllegalArgumentException( "Sorry AE2 made a " + this.p.array().length + " byte packet by accident!" );
|
||||
|
||||
FMLProxyPacket pp = new FMLProxyPacket( this.p, NetworkHandler.instance.getChannel() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.PacketLogging ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.PacketLogging ) )
|
||||
AELog.info( this.getClass().getName() + " : " + pp.payload().readableBytes() );
|
||||
|
||||
return pp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -123,116 +123,120 @@ import static appeng.core.sync.GuiHostType.ITEM;
|
||||
import static appeng.core.sync.GuiHostType.ITEM_OR_WORLD;
|
||||
import static appeng.core.sync.GuiHostType.WORLD;
|
||||
|
||||
|
||||
public enum GuiBridge implements IGuiHandler
|
||||
{
|
||||
GUI_Handler(),
|
||||
|
||||
GUI_GRINDER(ContainerGrinder.class, TileGrinder.class, WORLD, null),
|
||||
GUI_GRINDER( ContainerGrinder.class, TileGrinder.class, WORLD, null ),
|
||||
|
||||
GUI_QNB(ContainerQNB.class, TileQuantumBridge.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_QNB( ContainerQNB.class, TileQuantumBridge.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_SKYCHEST(ContainerSkyChest.class, TileSkyChest.class, WORLD, null),
|
||||
GUI_SKYCHEST( ContainerSkyChest.class, TileSkyChest.class, WORLD, null ),
|
||||
|
||||
GUI_CHEST(ContainerChest.class, TileChest.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_CHEST( ContainerChest.class, TileChest.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_WIRELESS(ContainerWireless.class, TileWireless.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_WIRELESS( ContainerWireless.class, TileWireless.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_ME(ContainerMEMonitorable.class, ITerminalHost.class, WORLD, null),
|
||||
GUI_ME( ContainerMEMonitorable.class, ITerminalHost.class, WORLD, null ),
|
||||
|
||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, ITEM, null),
|
||||
GUI_PORTABLE_CELL( ContainerMEPortableCell.class, IPortableCell.class, ITEM, null ),
|
||||
|
||||
GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, ITEM, null),
|
||||
GUI_WIRELESS_TERM( ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, ITEM, null ),
|
||||
|
||||
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, ITEM, null),
|
||||
GUI_NETWORK_STATUS( ContainerNetworkStatus.class, INetworkTool.class, ITEM, null ),
|
||||
|
||||
GUI_CRAFTING_CPU(ContainerCraftingCPU.class, TileCraftingTile.class, WORLD, SecurityPermissions.CRAFT),
|
||||
GUI_CRAFTING_CPU( ContainerCraftingCPU.class, TileCraftingTile.class, WORLD, SecurityPermissions.CRAFT ),
|
||||
|
||||
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, ITEM, null),
|
||||
GUI_NETWORK_TOOL( ContainerNetworkTool.class, INetworkTool.class, ITEM, null ),
|
||||
|
||||
GUI_QUARTZ_KNIFE(ContainerQuartzKnife.class, QuartzKnifeObj.class, ITEM, null),
|
||||
GUI_QUARTZ_KNIFE( ContainerQuartzKnife.class, QuartzKnifeObj.class, ITEM, null ),
|
||||
|
||||
GUI_DRIVE(ContainerDrive.class, TileDrive.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_DRIVE( ContainerDrive.class, TileDrive.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_VIBRATION_CHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class, WORLD, null),
|
||||
GUI_VIBRATION_CHAMBER( ContainerVibrationChamber.class, TileVibrationChamber.class, WORLD, null ),
|
||||
|
||||
GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class, WORLD, null),
|
||||
GUI_CONDENSER( ContainerCondenser.class, TileCondenser.class, WORLD, null ),
|
||||
|
||||
GUI_INTERFACE(ContainerInterface.class, IInterfaceHost.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_INTERFACE( ContainerInterface.class, IInterfaceHost.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_BUS(ContainerUpgradeable.class, IUpgradeableHost.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_BUS( ContainerUpgradeable.class, IUpgradeableHost.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_IOPORT( ContainerIOPort.class, TileIOPort.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_STORAGEBUS( ContainerStorageBus.class, PartStorageBus.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_FORMATION_PLANE(ContainerFormationPlane.class, PartFormationPlane.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_FORMATION_PLANE( ContainerFormationPlane.class, PartFormationPlane.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_PRIORITY( ContainerPriority.class, IPriorityHost.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_SECURITY(ContainerSecurity.class, TileSecurity.class, WORLD, SecurityPermissions.SECURITY),
|
||||
GUI_SECURITY( ContainerSecurity.class, TileSecurity.class, WORLD, SecurityPermissions.SECURITY ),
|
||||
|
||||
GUI_CRAFTING_TERMINAL(ContainerCraftingTerm.class, PartCraftingTerminal.class, WORLD, SecurityPermissions.CRAFT),
|
||||
GUI_CRAFTING_TERMINAL( ContainerCraftingTerm.class, PartCraftingTerminal.class, WORLD, SecurityPermissions.CRAFT ),
|
||||
|
||||
GUI_PATTERN_TERMINAL(ContainerPatternTerm.class, PartPatternTerminal.class, WORLD, SecurityPermissions.CRAFT),
|
||||
GUI_PATTERN_TERMINAL( ContainerPatternTerm.class, PartPatternTerminal.class, WORLD, SecurityPermissions.CRAFT ),
|
||||
|
||||
// extends (Container/Gui) + Bus
|
||||
GUI_LEVEL_EMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_LEVEL_EMITTER( ContainerLevelEmitter.class, PartLevelEmitter.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_SPATIAL_IO_PORT(ContainerSpatialIOPort.class, TileSpatialIOPort.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_SPATIAL_IO_PORT( ContainerSpatialIOPort.class, TileSpatialIOPort.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_INSCRIBER(ContainerInscriber.class, TileInscriber.class, WORLD, null),
|
||||
GUI_INSCRIBER( ContainerInscriber.class, TileInscriber.class, WORLD, null ),
|
||||
|
||||
GUI_CELL_WORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.class, WORLD, null),
|
||||
GUI_CELL_WORKBENCH( ContainerCellWorkbench.class, TileCellWorkbench.class, WORLD, null ),
|
||||
|
||||
GUI_MAC(ContainerMAC.class, TileMolecularAssembler.class, WORLD, null),
|
||||
GUI_MAC( ContainerMAC.class, TileMolecularAssembler.class, WORLD, null ),
|
||||
|
||||
GUI_CRAFTING_AMOUNT(ContainerCraftAmount.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT),
|
||||
GUI_CRAFTING_AMOUNT( ContainerCraftAmount.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT ),
|
||||
|
||||
GUI_CRAFTING_CONFIRM(ContainerCraftConfirm.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT),
|
||||
GUI_CRAFTING_CONFIRM( ContainerCraftConfirm.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT ),
|
||||
|
||||
GUI_INTERFACE_TERMINAL(ContainerInterfaceTerminal.class, PartMonitor.class, WORLD, SecurityPermissions.BUILD),
|
||||
GUI_INTERFACE_TERMINAL( ContainerInterfaceTerminal.class, PartMonitor.class, WORLD, SecurityPermissions.BUILD ),
|
||||
|
||||
GUI_CRAFTING_STATUS(ContainerCraftingStatus.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT);
|
||||
GUI_CRAFTING_STATUS( ContainerCraftingStatus.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT );
|
||||
|
||||
private final Class Tile;
|
||||
private Class Gui;
|
||||
private final Class Container;
|
||||
private Class Gui;
|
||||
private GuiHostType type;
|
||||
private SecurityPermissions requiredPermission;
|
||||
|
||||
GuiBridge() {
|
||||
GuiBridge()
|
||||
{
|
||||
this.Tile = null;
|
||||
this.Gui = null;
|
||||
this.Container = null;
|
||||
}
|
||||
|
||||
GuiBridge( Class _Container, SecurityPermissions requiredPermission )
|
||||
{
|
||||
this.requiredPermission = requiredPermission;
|
||||
this.Container = _Container;
|
||||
this.Tile = null;
|
||||
this.getGui();
|
||||
}
|
||||
|
||||
/**
|
||||
* I honestly wish I could just use the GuiClass Names myself, but I can't access them without MC's Server
|
||||
* Exploding.
|
||||
*/
|
||||
private void getGui()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
final String start = this.Container.getName();
|
||||
String guiClass = start.replaceFirst( "container.", "client.gui." ).replace( ".Container", ".Gui" );
|
||||
|
||||
if ( start.equals( guiClass ) )
|
||||
if( start.equals( guiClass ) )
|
||||
throw new RuntimeException( "Unable to find gui class" );
|
||||
this.Gui = ReflectionHelper.getClass( this.getClass().getClassLoader(), guiClass );
|
||||
if ( this.Gui == null )
|
||||
if( this.Gui == null )
|
||||
throw new RuntimeException( "Cannot Load class: " + guiClass );
|
||||
}
|
||||
}
|
||||
|
||||
GuiBridge( Class _Container, SecurityPermissions requiredPermission ) {
|
||||
this.requiredPermission = requiredPermission;
|
||||
this.Container = _Container;
|
||||
this.Tile = null;
|
||||
this.getGui();
|
||||
}
|
||||
|
||||
GuiBridge( Class _Container, Class _Tile, GuiHostType type, SecurityPermissions requiredPermission ) {
|
||||
GuiBridge( Class _Container, Class _Tile, GuiHostType type, SecurityPermissions requiredPermission )
|
||||
{
|
||||
this.requiredPermission = requiredPermission;
|
||||
this.Container = _Container;
|
||||
this.type = type;
|
||||
@@ -240,125 +244,69 @@ public enum GuiBridge implements IGuiHandler
|
||||
this.getGui();
|
||||
}
|
||||
|
||||
public boolean CorrectTileOrPart(Object tE)
|
||||
@Override
|
||||
public Object getServerGuiElement( int ID_ORDINAL, EntityPlayer player, World w, int x, int y, int z )
|
||||
{
|
||||
if ( this.Tile == null )
|
||||
ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 );
|
||||
GuiBridge ID = values()[ID_ORDINAL >> 4];
|
||||
boolean stem = ( ( ID_ORDINAL >> 3 ) & 1 ) == 1;
|
||||
|
||||
if( ID.type.isItem() && stem )
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
Object myItem = this.getGuiObject( it, player, w, x, y, z );
|
||||
if( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side, myItem );
|
||||
}
|
||||
|
||||
if( ID.type.isTile() )
|
||||
{
|
||||
TileEntity TE = w.getTileEntity( x, y, z );
|
||||
if( TE instanceof IPartHost )
|
||||
{
|
||||
( (IPartHost) TE ).getPart( side );
|
||||
IPart part = ( (IPartHost) TE ).getPart( side );
|
||||
if( ID.CorrectTileOrPart( part ) )
|
||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, part ), w, x, y, z, side, part );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ID.CorrectTileOrPart( TE ) )
|
||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side, TE );
|
||||
}
|
||||
}
|
||||
|
||||
return new ContainerNull();
|
||||
}
|
||||
|
||||
private Object getGuiObject( ItemStack it, EntityPlayer player, World w, int x, int y, int z )
|
||||
{
|
||||
if( it != null )
|
||||
{
|
||||
if( it.getItem() instanceof IGuiItem )
|
||||
{
|
||||
return ( (IGuiItem) it.getItem() ).getGuiObject( it, w, x, y, z );
|
||||
}
|
||||
|
||||
IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler( it );
|
||||
if( wh != null )
|
||||
return new WirelessTerminalGuiObject( wh, it, player, w, x, y, z );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean CorrectTileOrPart( Object tE )
|
||||
{
|
||||
if( this.Tile == null )
|
||||
throw new RuntimeException( "This Gui Cannot use the standard Handler." );
|
||||
|
||||
return this.Tile.isInstance( tE );
|
||||
}
|
||||
|
||||
public Object ConstructContainer(InventoryPlayer inventory, ForgeDirection side, Object tE)
|
||||
private Object updateGui( Object newContainer, World w, int x, int y, int z, ForgeDirection side, Object myItem )
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor[] c = this.Container.getConstructors();
|
||||
if ( c.length == 0 )
|
||||
throw new AppEngException( "Invalid Gui Class" );
|
||||
|
||||
Constructor target = this.findConstructor( c, inventory, tE );
|
||||
|
||||
if ( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
Object o = target.newInstance( inventory, tE );
|
||||
|
||||
/**
|
||||
* triggers achievement when the player sees presses.
|
||||
*/
|
||||
if ( o instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer bc = (AEBaseContainer) o;
|
||||
for (Object so : bc.inventorySlots)
|
||||
{
|
||||
if ( so instanceof Slot )
|
||||
{
|
||||
ItemStack is = ((Slot) so).getStack();
|
||||
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
this.addPressAchievementToPlayer( is, materials, inventory.player );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
private void addPressAchievementToPlayer( ItemStack newItem, IMaterials possibleMaterials, EntityPlayer player )
|
||||
{
|
||||
final IComparableDefinition logic = possibleMaterials.logicProcessorPress();
|
||||
final IComparableDefinition eng = possibleMaterials.engProcessorPress();
|
||||
final IComparableDefinition calc = possibleMaterials.calcProcessorPress();
|
||||
final IComparableDefinition silicon = possibleMaterials.siliconPress();
|
||||
|
||||
final List<IComparableDefinition> presses = Lists.newArrayList( logic, eng, calc, silicon );
|
||||
|
||||
for ( IComparableDefinition press : presses )
|
||||
{
|
||||
if ( press.isSameAs( newItem ) )
|
||||
{
|
||||
Achievements.Presses.addToPlayer( player );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object ConstructGui(InventoryPlayer inventory, ForgeDirection side, Object tE)
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor[] c = this.Gui.getConstructors();
|
||||
if ( c.length == 0 )
|
||||
throw new AppEngException( "Invalid Gui Class" );
|
||||
|
||||
Constructor target = this.findConstructor( c, inventory, tE );
|
||||
|
||||
if ( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
return target.newInstance( inventory, tE );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
private String typeName(Object inventory)
|
||||
{
|
||||
if ( inventory == null )
|
||||
return "NULL";
|
||||
|
||||
return inventory.getClass().getName();
|
||||
}
|
||||
|
||||
private Constructor findConstructor(Constructor[] c, InventoryPlayer inventory, Object tE)
|
||||
{
|
||||
for (Constructor con : c)
|
||||
{
|
||||
Class[] types = con.getParameterTypes();
|
||||
if ( types.length == 2 )
|
||||
{
|
||||
if ( types[0].isAssignableFrom( inventory.getClass() ) && types[1].isAssignableFrom( tE.getClass() ) )
|
||||
return con;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Object updateGui(Object newContainer, World w, int x, int y, int z, ForgeDirection side, Object myItem)
|
||||
{
|
||||
if ( newContainer instanceof AEBaseContainer )
|
||||
if( newContainer instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer bc = (AEBaseContainer) newContainer;
|
||||
bc.openContext = new ContainerOpenContext( myItem );
|
||||
@@ -372,87 +320,120 @@ public enum GuiBridge implements IGuiHandler
|
||||
return newContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID_ORDINAL, EntityPlayer player, World w, int x, int y, int z)
|
||||
public Object ConstructContainer( InventoryPlayer inventory, ForgeDirection side, Object tE )
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 );
|
||||
GuiBridge ID = values()[ID_ORDINAL >> 4];
|
||||
boolean stem = ((ID_ORDINAL >> 3) & 1) == 1;
|
||||
|
||||
if ( ID.type.isItem() && stem )
|
||||
try
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
Object myItem = this.getGuiObject( it, player, w, x, y, z );
|
||||
if ( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side, myItem );
|
||||
}
|
||||
Constructor[] c = this.Container.getConstructors();
|
||||
if( c.length == 0 )
|
||||
throw new AppEngException( "Invalid Gui Class" );
|
||||
|
||||
if ( ID.type.isTile() )
|
||||
Constructor target = this.findConstructor( c, inventory, tE );
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
Object o = target.newInstance( inventory, tE );
|
||||
|
||||
/**
|
||||
* triggers achievement when the player sees presses.
|
||||
*/
|
||||
if( o instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer bc = (AEBaseContainer) o;
|
||||
for( Object so : bc.inventorySlots )
|
||||
{
|
||||
if( so instanceof Slot )
|
||||
{
|
||||
ItemStack is = ( (Slot) so ).getStack();
|
||||
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
this.addPressAchievementToPlayer( is, materials, inventory.player );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
TileEntity TE = w.getTileEntity( x, y, z );
|
||||
if ( TE instanceof IPartHost )
|
||||
{
|
||||
((IPartHost) TE).getPart( side );
|
||||
IPart part = ((IPartHost) TE).getPart( side );
|
||||
if ( ID.CorrectTileOrPart( part ) )
|
||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, part ), w, x, y, z, side, part );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ID.CorrectTileOrPart( TE ) )
|
||||
return this.updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side, TE );
|
||||
}
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
|
||||
return new ContainerNull();
|
||||
}
|
||||
|
||||
private Object getGuiObject(ItemStack it, EntityPlayer player, World w, int x, int y, int z)
|
||||
private Constructor findConstructor( Constructor[] c, InventoryPlayer inventory, Object tE )
|
||||
{
|
||||
if ( it != null )
|
||||
for( Constructor con : c )
|
||||
{
|
||||
if ( it.getItem() instanceof IGuiItem )
|
||||
Class[] types = con.getParameterTypes();
|
||||
if( types.length == 2 )
|
||||
{
|
||||
return ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z );
|
||||
if( types[0].isAssignableFrom( inventory.getClass() ) && types[1].isAssignableFrom( tE.getClass() ) )
|
||||
return con;
|
||||
}
|
||||
|
||||
IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler( it );
|
||||
if ( wh != null )
|
||||
return new WirelessTerminalGuiObject( wh, it, player, w, x, y, z );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String typeName( Object inventory )
|
||||
{
|
||||
if( inventory == null )
|
||||
return "NULL";
|
||||
|
||||
return inventory.getClass().getName();
|
||||
}
|
||||
|
||||
private void addPressAchievementToPlayer( ItemStack newItem, IMaterials possibleMaterials, EntityPlayer player )
|
||||
{
|
||||
final IComparableDefinition logic = possibleMaterials.logicProcessorPress();
|
||||
final IComparableDefinition eng = possibleMaterials.engProcessorPress();
|
||||
final IComparableDefinition calc = possibleMaterials.calcProcessorPress();
|
||||
final IComparableDefinition silicon = possibleMaterials.siliconPress();
|
||||
|
||||
final List<IComparableDefinition> presses = Lists.newArrayList( logic, eng, calc, silicon );
|
||||
|
||||
for( IComparableDefinition press : presses )
|
||||
{
|
||||
if( press.isSameAs( newItem ) )
|
||||
{
|
||||
Achievements.Presses.addToPlayer( player );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID_ORDINAL, EntityPlayer player, World w, int x, int y, int z)
|
||||
public Object getClientGuiElement( int ID_ORDINAL, EntityPlayer player, World w, int x, int y, int z )
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 );
|
||||
GuiBridge ID = values()[ID_ORDINAL >> 4];
|
||||
boolean stem = ((ID_ORDINAL >> 3) & 1) == 1;
|
||||
boolean stem = ( ( ID_ORDINAL >> 3 ) & 1 ) == 1;
|
||||
|
||||
if ( ID.type.isItem() && stem )
|
||||
if( ID.type.isItem() && stem )
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
Object myItem = this.getGuiObject( it, player, w, x, y, z );
|
||||
if ( ID.CorrectTileOrPart( myItem ) )
|
||||
if( ID.CorrectTileOrPart( myItem ) )
|
||||
return ID.ConstructGui( player.inventory, side, myItem );
|
||||
}
|
||||
|
||||
if ( ID.type.isTile() )
|
||||
if( ID.type.isTile() )
|
||||
{
|
||||
TileEntity TE = w.getTileEntity( x, y, z );
|
||||
|
||||
if ( TE instanceof IPartHost )
|
||||
if( TE instanceof IPartHost )
|
||||
{
|
||||
((IPartHost) TE).getPart( side );
|
||||
IPart part = ((IPartHost) TE).getPart( side );
|
||||
if ( ID.CorrectTileOrPart( part ) )
|
||||
( (IPartHost) TE ).getPart( side );
|
||||
IPart part = ( (IPartHost) TE ).getPart( side );
|
||||
if( ID.CorrectTileOrPart( part ) )
|
||||
return ID.ConstructGui( player.inventory, side, part );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ID.CorrectTileOrPart( TE ) )
|
||||
if( ID.CorrectTileOrPart( TE ) )
|
||||
return ID.ConstructGui( player.inventory, side, TE );
|
||||
}
|
||||
}
|
||||
@@ -460,38 +441,61 @@ public enum GuiBridge implements IGuiHandler
|
||||
return new GuiNull( new ContainerNull() );
|
||||
}
|
||||
|
||||
public boolean hasPermissions(TileEntity te, int x, int y, int z, ForgeDirection side, EntityPlayer player)
|
||||
public Object ConstructGui( InventoryPlayer inventory, ForgeDirection side, Object tE )
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor[] c = this.Gui.getConstructors();
|
||||
if( c.length == 0 )
|
||||
throw new AppEngException( "Invalid Gui Class" );
|
||||
|
||||
Constructor target = this.findConstructor( c, inventory, tE );
|
||||
|
||||
if( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" );
|
||||
}
|
||||
|
||||
return target.newInstance( inventory, tE );
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPermissions( TileEntity te, int x, int y, int z, ForgeDirection side, EntityPlayer player )
|
||||
{
|
||||
World w = player.getEntityWorld();
|
||||
|
||||
if ( Platform.hasPermissions( te != null ? new DimensionalCoord( te ) : new DimensionalCoord( player.worldObj, x, y, z ), player ) )
|
||||
if( Platform.hasPermissions( te != null ? new DimensionalCoord( te ) : new DimensionalCoord( player.worldObj, x, y, z ), player ) )
|
||||
{
|
||||
if ( this.type.isItem() )
|
||||
if( this.type.isItem() )
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
if ( it != null && it.getItem() instanceof IGuiItem )
|
||||
if( it != null && it.getItem() instanceof IGuiItem )
|
||||
{
|
||||
Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z );
|
||||
if ( this.CorrectTileOrPart( myItem ) )
|
||||
Object myItem = ( (IGuiItem) it.getItem() ).getGuiObject( it, w, x, y, z );
|
||||
if( this.CorrectTileOrPart( myItem ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( this.type.isTile() )
|
||||
if( this.type.isTile() )
|
||||
{
|
||||
TileEntity TE = w.getTileEntity( x, y, z );
|
||||
if ( TE instanceof IPartHost )
|
||||
if( TE instanceof IPartHost )
|
||||
{
|
||||
((IPartHost) TE).getPart( side );
|
||||
IPart part = ((IPartHost) TE).getPart( side );
|
||||
if ( this.CorrectTileOrPart( part ) )
|
||||
( (IPartHost) TE ).getPart( side );
|
||||
IPart part = ( (IPartHost) TE ).getPart( side );
|
||||
if( this.CorrectTileOrPart( part ) )
|
||||
return this.securityCheck( part, player );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( this.CorrectTileOrPart( TE ) )
|
||||
if( this.CorrectTileOrPart( TE ) )
|
||||
return this.securityCheck( TE, player );
|
||||
}
|
||||
}
|
||||
@@ -499,29 +503,29 @@ public enum GuiBridge implements IGuiHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean securityCheck(Object te, EntityPlayer player)
|
||||
private boolean securityCheck( Object te, EntityPlayer player )
|
||||
{
|
||||
if ( te instanceof IActionHost && this.requiredPermission != null )
|
||||
if( te instanceof IActionHost && this.requiredPermission != null )
|
||||
{
|
||||
boolean requirePower = false;
|
||||
|
||||
IGridNode gn = ((IActionHost) te).getActionableNode();
|
||||
if ( gn != null )
|
||||
IGridNode gn = ( (IActionHost) te ).getActionableNode();
|
||||
if( gn != null )
|
||||
{
|
||||
IGrid g = gn.getGrid();
|
||||
if ( g != null )
|
||||
if( g != null )
|
||||
{
|
||||
if ( requirePower )
|
||||
if( requirePower )
|
||||
{
|
||||
IEnergyGrid eg = g.getCache( IEnergyGrid.class );
|
||||
if ( !eg.isNetworkPowered() )
|
||||
if( !eg.isNetworkPowered() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ISecurityGrid sg = g.getCache( ISecurityGrid.class );
|
||||
if ( sg.hasPermission( player, this.requiredPermission ) )
|
||||
if( sg.hasPermission( player, this.requiredPermission ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync;
|
||||
|
||||
|
||||
public enum GuiHostType
|
||||
{
|
||||
ITEM_OR_WORLD, ITEM, WORLD;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -31,11 +32,12 @@ import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.AppEngPacketHandlerBase;
|
||||
|
||||
|
||||
public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkInfo network, FMLProxyPacket packet, EntityPlayer player)
|
||||
public void onPacketData( INetworkInfo network, FMLProxyPacket packet, EntityPlayer player )
|
||||
{
|
||||
ByteBuf stream = packet.payload();
|
||||
int packetType = -1;
|
||||
@@ -48,22 +50,21 @@ public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implement
|
||||
AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( stream );
|
||||
pack.clientPacketData( network, pack, player );
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
catch( InstantiationException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -30,11 +31,12 @@ import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.AppEngPacketHandlerBase;
|
||||
|
||||
|
||||
public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkInfo manager, FMLProxyPacket packet, EntityPlayer player)
|
||||
public void onPacketData( INetworkInfo manager, FMLProxyPacket packet, EntityPlayer player )
|
||||
{
|
||||
ByteBuf stream = packet.payload();
|
||||
int packetType = -1;
|
||||
@@ -45,22 +47,21 @@ public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase imp
|
||||
AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( stream );
|
||||
pack.serverPacketData( manager, pack, player );
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
catch( InstantiationException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
catch( IllegalArgumentException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
catch( InvocationTargetException e )
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
|
||||
public interface IPacketHandler
|
||||
{
|
||||
|
||||
void onPacketData(INetworkInfo manager, FMLProxyPacket packet, EntityPlayer player);
|
||||
|
||||
void onPacketData( INetworkInfo manager, FMLProxyPacket packet, EntityPlayer player );
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import appeng.core.WorldSettings;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
|
||||
|
||||
public class NetworkHandler
|
||||
{
|
||||
|
||||
@@ -45,7 +46,8 @@ public class NetworkHandler
|
||||
final IPacketHandler clientHandler;
|
||||
final IPacketHandler serveHandler;
|
||||
|
||||
public NetworkHandler(String channelName) {
|
||||
public NetworkHandler( String channelName )
|
||||
{
|
||||
FMLCommonHandler.instance().bus().register( this );
|
||||
this.ec = NetworkRegistry.INSTANCE.newEventDrivenChannel( this.myChannelName = channelName );
|
||||
this.ec.register( this );
|
||||
@@ -54,55 +56,55 @@ public class NetworkHandler
|
||||
this.serveHandler = this.createServerSide();
|
||||
}
|
||||
|
||||
private IPacketHandler createServerSide()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new AppEngServerPacketHandler();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IPacketHandler createClientSide()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new AppEngClientPacketHandler();
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch( Throwable t )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IPacketHandler createServerSide()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new AppEngServerPacketHandler();
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConnection(ServerConnectionFromClientEvent ev)
|
||||
public void newConnection( ServerConnectionFromClientEvent ev )
|
||||
{
|
||||
WorldSettings.getInstance().sendToPlayer( ev.manager );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConnection(PlayerLoggedInEvent loginEvent)
|
||||
public void newConnection( PlayerLoggedInEvent loginEvent )
|
||||
{
|
||||
if ( loginEvent.player instanceof EntityPlayerMP )
|
||||
if( loginEvent.player instanceof EntityPlayerMP )
|
||||
WorldSettings.getInstance().sendToPlayer( null );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverPacket(ServerCustomPacketEvent ev)
|
||||
public void serverPacket( ServerCustomPacketEvent ev )
|
||||
{
|
||||
NetHandlerPlayServer srv = (NetHandlerPlayServer) ev.packet.handler();
|
||||
if ( this.serveHandler != null )
|
||||
if( this.serveHandler != null )
|
||||
this.serveHandler.onPacketData( null, ev.packet, srv.playerEntity );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientPacket(ClientCustomPacketEvent ev)
|
||||
public void clientPacket( ClientCustomPacketEvent ev )
|
||||
{
|
||||
if ( this.clientHandler != null )
|
||||
if( this.clientHandler != null )
|
||||
this.clientHandler.onPacketData( null, ev.packet, null );
|
||||
}
|
||||
|
||||
@@ -111,29 +113,28 @@ public class NetworkHandler
|
||||
return this.myChannelName;
|
||||
}
|
||||
|
||||
public void sendToAll(AppEngPacket message)
|
||||
public void sendToAll( AppEngPacket message )
|
||||
{
|
||||
this.ec.sendToAll( message.getProxy() );
|
||||
}
|
||||
|
||||
public void sendTo(AppEngPacket message, EntityPlayerMP player)
|
||||
public void sendTo( AppEngPacket message, EntityPlayerMP player )
|
||||
{
|
||||
this.ec.sendTo( message.getProxy(), player );
|
||||
}
|
||||
|
||||
public void sendToAllAround(AppEngPacket message, NetworkRegistry.TargetPoint point)
|
||||
public void sendToAllAround( AppEngPacket message, NetworkRegistry.TargetPoint point )
|
||||
{
|
||||
this.ec.sendToAllAround( message.getProxy(), point );
|
||||
}
|
||||
|
||||
public void sendToDimension(AppEngPacket message, int dimensionId)
|
||||
public void sendToDimension( AppEngPacket message, int dimensionId )
|
||||
{
|
||||
this.ec.sendToDimension( message.getProxy(), dimensionId );
|
||||
}
|
||||
|
||||
public void sendToServer(AppEngPacket message)
|
||||
public void sendToServer( AppEngPacket message )
|
||||
{
|
||||
this.ec.sendToServer( message.getProxy() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -35,6 +36,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class PacketAssemblerAnimation extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -45,7 +47,8 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
final public IAEItemStack is;
|
||||
|
||||
// automatic.
|
||||
public PacketAssemblerAnimation(ByteBuf stream) throws IOException {
|
||||
public PacketAssemblerAnimation( ByteBuf stream ) throws IOException
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
this.z = stream.readInt();
|
||||
@@ -53,19 +56,9 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
this.is = AEItemStack.loadItemStackFromPacket( stream );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
double d2 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
|
||||
CommonHelper.proxy.spawnEffect( EffectType.Assembler, player.getEntityWorld(), this.x + d0, this.y + d1, this.z + d2, this );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketAssemblerAnimation(int x, int y, int z, byte rate, IAEItemStack is) throws IOException {
|
||||
public PacketAssemblerAnimation( int x, int y, int z, byte rate, IAEItemStack is ) throws IOException
|
||||
{
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
@@ -79,4 +72,15 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
double d2 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
|
||||
CommonHelper.proxy.spawnEffect( EffectType.Assembler, player.getEntityWorld(), this.x + d0, this.y + d1, this.z + d2, this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -34,6 +35,7 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.items.tools.powered.ToolColorApplicator;
|
||||
|
||||
|
||||
public class PacketClick extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -46,7 +48,8 @@ public class PacketClick extends AppEngPacket
|
||||
final float hitZ;
|
||||
|
||||
// automatic.
|
||||
public PacketClick(ByteBuf stream) {
|
||||
public PacketClick( ByteBuf stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
this.z = stream.readInt();
|
||||
@@ -56,39 +59,9 @@ public class PacketClick extends AppEngPacket
|
||||
this.hitZ = stream.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
ItemStack is = player.inventory.getCurrentItem();
|
||||
final IItems items = AEApi.instance().definitions().items();
|
||||
final IComparableDefinition maybeMemoryCard = items.memoryCard();
|
||||
final IComparableDefinition maybeColorApplicator = items.colorApplicator();
|
||||
|
||||
if ( is != null )
|
||||
{
|
||||
if ( is.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
tnt.serverSideToolLogic( is, player, player.worldObj, this.x, this.y, this.z, this.side, this.hitX, this.hitY, this.hitZ );
|
||||
}
|
||||
|
||||
else if ( maybeMemoryCard.isSameAs( is ) )
|
||||
{
|
||||
IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
}
|
||||
|
||||
else if ( maybeColorApplicator.isSameAs( is ) )
|
||||
{
|
||||
ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors( is, mem.getColor( is ), 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketClick(int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
|
||||
public PacketClick( int x, int y, int z, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
@@ -103,4 +76,35 @@ public class PacketClick extends AppEngPacket
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
ItemStack is = player.inventory.getCurrentItem();
|
||||
final IItems items = AEApi.instance().definitions().items();
|
||||
final IComparableDefinition maybeMemoryCard = items.memoryCard();
|
||||
final IComparableDefinition maybeColorApplicator = items.colorApplicator();
|
||||
|
||||
if( is != null )
|
||||
{
|
||||
if( is.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
tnt.serverSideToolLogic( is, player, player.worldObj, this.x, this.y, this.z, this.side, this.hitX, this.hitY, this.hitZ );
|
||||
}
|
||||
|
||||
else if( maybeMemoryCard.isSameAs( is ) )
|
||||
{
|
||||
IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
}
|
||||
|
||||
else if( maybeColorApplicator.isSameAs( is ) )
|
||||
{
|
||||
ToolColorApplicator mem = (ToolColorApplicator) is.getItem();
|
||||
mem.cycleColors( is, mem.getColor( is ), 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -31,6 +32,7 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.services.compass.ICompassCallback;
|
||||
|
||||
|
||||
public class PacketCompassRequest extends AppEngPacket implements ICompassCallback
|
||||
{
|
||||
|
||||
@@ -42,30 +44,17 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
|
||||
EntityPlayer talkBackTo;
|
||||
|
||||
// automatic.
|
||||
public PacketCompassRequest(ByteBuf stream) {
|
||||
public PacketCompassRequest( ByteBuf stream )
|
||||
{
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
this.cz = stream.readInt();
|
||||
this.cdy = stream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculatedDirection(boolean hasResult, boolean spin, double radians, double dist)
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketCompassResponse( this, hasResult, spin, radians ), (EntityPlayerMP) this.talkBackTo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
this.talkBackTo = player;
|
||||
|
||||
DimensionalCoord loc = new DimensionalCoord( player.worldObj, this.cx << 4, this.cdy << 5, this.cz << 4 );
|
||||
WorldSettings.getInstance().getCompass().getCompassDirection( loc, 174, this );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketCompassRequest(long attunement, int cx, int cz, int cdy) {
|
||||
public PacketCompassRequest( long attunement, int cx, int cz, int cdy )
|
||||
{
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
@@ -76,6 +65,20 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
|
||||
data.writeInt( this.cdy = cdy );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculatedDirection( boolean hasResult, boolean spin, double radians, double dist )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketCompassResponse( this, hasResult, spin, radians ), (EntityPlayerMP) this.talkBackTo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
this.talkBackTo = player;
|
||||
|
||||
DimensionalCoord loc = new DimensionalCoord( player.worldObj, this.cx << 4, this.cdy << 5, this.cz << 4 );
|
||||
WorldSettings.getInstance().getCompass().getCompassDirection( loc, 174, this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -28,6 +29,7 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.hooks.CompassManager;
|
||||
import appeng.hooks.CompassResult;
|
||||
|
||||
|
||||
public class PacketCompassResponse extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -39,7 +41,8 @@ public class PacketCompassResponse extends AppEngPacket
|
||||
public CompassResult cr;
|
||||
|
||||
// automatic.
|
||||
public PacketCompassResponse(ByteBuf stream) {
|
||||
public PacketCompassResponse( ByteBuf stream )
|
||||
{
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
this.cz = stream.readInt();
|
||||
@@ -48,14 +51,9 @@ public class PacketCompassResponse extends AppEngPacket
|
||||
this.cr = new CompassResult( stream.readBoolean(), stream.readBoolean(), stream.readDouble() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
CompassManager.INSTANCE.postResult( this.attunement, this.cx << 4, this.cdy << 5, this.cz << 4, this.cr );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketCompassResponse(PacketCompassRequest req, boolean hasResult, boolean spin, double radians) {
|
||||
public PacketCompassResponse( PacketCompassRequest req, boolean hasResult, boolean spin, double radians )
|
||||
{
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
@@ -70,6 +68,11 @@ public class PacketCompassResponse extends AppEngPacket
|
||||
data.writeDouble( radians );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
CompassManager.INSTANCE.postResult( this.attunement, this.cx << 4, this.cdy << 5, this.cz << 4, this.cr );
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -42,36 +43,35 @@ import appeng.client.gui.implementations.GuiInterfaceTerminal;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
public class PacketCompressedNBT extends AppEngPacket
|
||||
{
|
||||
|
||||
// input.
|
||||
final NBTTagCompound in;
|
||||
// output...
|
||||
final private ByteBuf data;
|
||||
final private GZIPOutputStream compressFrame;
|
||||
|
||||
int writtenBytes = 0;
|
||||
|
||||
boolean empty = true;
|
||||
|
||||
// input.
|
||||
final NBTTagCompound in;
|
||||
|
||||
// automatic.
|
||||
public PacketCompressedNBT(final ByteBuf stream) throws IOException {
|
||||
public PacketCompressedNBT( final ByteBuf stream ) throws IOException
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
|
||||
GZIPInputStream gzReader = new GZIPInputStream( new InputStream() {
|
||||
GZIPInputStream gzReader = new GZIPInputStream( new InputStream()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
{
|
||||
if ( stream.readableBytes() <= 0 )
|
||||
if( stream.readableBytes() <= 0 )
|
||||
return -1;
|
||||
|
||||
return stream.readByte() & 0xff;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
DataInputStream inStream = new DataInputStream( gzReader );
|
||||
@@ -79,33 +79,23 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
inStream.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
|
||||
if ( gs instanceof GuiInterfaceTerminal )
|
||||
((GuiInterfaceTerminal) gs).postUpdate( this.in );
|
||||
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketCompressedNBT(NBTTagCompound din) throws IOException {
|
||||
public PacketCompressedNBT( NBTTagCompound din ) throws IOException
|
||||
{
|
||||
|
||||
this.data = Unpooled.buffer( 2048 );
|
||||
this.data.writeInt( this.getPacketID() );
|
||||
|
||||
this.in = din;
|
||||
|
||||
this.compressFrame = new GZIPOutputStream( new OutputStream() {
|
||||
this.compressFrame = new GZIPOutputStream( new OutputStream()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void write(int value) throws IOException
|
||||
public void write( int value ) throws IOException
|
||||
{
|
||||
PacketCompressedNBT.this.data.writeByte( value );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
CompressedStreamTools.write( din, new DataOutputStream( this.compressFrame ) );
|
||||
@@ -114,4 +104,13 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
this.configureWrite( this.data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
|
||||
if( gs instanceof GuiInterfaceTerminal )
|
||||
( (GuiInterfaceTerminal) gs ).postUpdate( this.in );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -32,6 +33,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PacketConfigButton extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -39,26 +41,15 @@ public class PacketConfigButton extends AppEngPacket
|
||||
final public boolean rotationDirection;
|
||||
|
||||
// automatic.
|
||||
public PacketConfigButton(ByteBuf stream) {
|
||||
public PacketConfigButton( ByteBuf stream )
|
||||
{
|
||||
this.option = Settings.values()[stream.readInt()];
|
||||
this.rotationDirection = stream.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
if ( baseContainer.getTarget() instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) baseContainer.getTarget()).getConfigManager();
|
||||
Enum newState = Platform.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() );
|
||||
cm.putSetting( this.option, newState );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketConfigButton(Settings option, boolean rotationDirection) {
|
||||
public PacketConfigButton( Settings option, boolean rotationDirection )
|
||||
{
|
||||
this.option = option;
|
||||
this.rotationDirection = rotationDirection;
|
||||
|
||||
@@ -70,4 +61,17 @@ public class PacketConfigButton extends AppEngPacket
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
if( baseContainer.getTarget() instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ( (IConfigurableObject) baseContainer.getTarget() ).getConfigManager();
|
||||
Enum newState = Platform.rotateEnum( cm.getSetting( this.option ), this.rotationDirection, this.option.getPossibleValues() );
|
||||
cm.putSetting( this.option, newState );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -41,6 +42,7 @@ import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PacketCraftRequest extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -48,66 +50,13 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
final public boolean heldShift;
|
||||
|
||||
// automatic.
|
||||
public PacketCraftRequest(ByteBuf stream)
|
||||
public PacketCraftRequest( ByteBuf stream )
|
||||
{
|
||||
this.heldShift = stream.readBoolean();
|
||||
this.amount = stream.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
if ( player.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer;
|
||||
Object target = cca.getTarget();
|
||||
if ( target instanceof IGridHost )
|
||||
{
|
||||
IGridHost gh = (IGridHost) target;
|
||||
IGridNode gn = gh.getGridNode( ForgeDirection.UNKNOWN );
|
||||
if ( gn == null )
|
||||
return;
|
||||
|
||||
IGrid g = gn.getGrid();
|
||||
if ( g == null || cca.whatToMake == null )
|
||||
return;
|
||||
|
||||
Future<ICraftingJob> futureJob = null;
|
||||
|
||||
cca.whatToMake.setStackSize( this.amount );
|
||||
|
||||
try
|
||||
{
|
||||
ICraftingGrid cg = g.getCache( ICraftingGrid.class );
|
||||
futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.whatToMake, null );
|
||||
|
||||
ContainerOpenContext context = cca.openContext;
|
||||
if ( context != null )
|
||||
{
|
||||
TileEntity te = context.getTile();
|
||||
Platform.openGUI( player, te, cca.openContext.side, GuiBridge.GUI_CRAFTING_CONFIRM );
|
||||
|
||||
if ( player.openContainer instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
|
||||
ccc.autoStart = this.heldShift;
|
||||
ccc.job = futureJob;
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
if ( futureJob != null )
|
||||
futureJob.cancel( true );
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PacketCraftRequest(int craftAmt, boolean shift)
|
||||
public PacketCraftRequest( int craftAmt, boolean shift )
|
||||
{
|
||||
this.amount = craftAmt;
|
||||
this.heldShift = shift;
|
||||
@@ -121,4 +70,55 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
if( player.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer;
|
||||
Object target = cca.getTarget();
|
||||
if( target instanceof IGridHost )
|
||||
{
|
||||
IGridHost gh = (IGridHost) target;
|
||||
IGridNode gn = gh.getGridNode( ForgeDirection.UNKNOWN );
|
||||
if( gn == null )
|
||||
return;
|
||||
|
||||
IGrid g = gn.getGrid();
|
||||
if( g == null || cca.whatToMake == null )
|
||||
return;
|
||||
|
||||
Future<ICraftingJob> futureJob = null;
|
||||
|
||||
cca.whatToMake.setStackSize( this.amount );
|
||||
|
||||
try
|
||||
{
|
||||
ICraftingGrid cg = g.getCache( ICraftingGrid.class );
|
||||
futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.whatToMake, null );
|
||||
|
||||
ContainerOpenContext context = cca.openContext;
|
||||
if( context != null )
|
||||
{
|
||||
TileEntity te = context.getTile();
|
||||
Platform.openGUI( player, te, cca.openContext.side, GuiBridge.GUI_CRAFTING_CONFIRM );
|
||||
|
||||
if( player.openContainer instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
|
||||
ccc.autoStart = this.heldShift;
|
||||
ccc.job = futureJob;
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Throwable e )
|
||||
{
|
||||
if( futureJob != null )
|
||||
futureJob.cancel( true );
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -39,6 +40,7 @@ import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class PacketInventoryAction extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -48,37 +50,87 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
final public IAEItemStack slotItem;
|
||||
|
||||
// automatic.
|
||||
public PacketInventoryAction(ByteBuf stream) throws IOException {
|
||||
public PacketInventoryAction( ByteBuf stream ) throws IOException
|
||||
{
|
||||
this.action = InventoryAction.values()[stream.readInt()];
|
||||
this.slot = stream.readInt();
|
||||
this.id = stream.readLong();
|
||||
boolean hasItem = stream.readBoolean();
|
||||
if ( hasItem )
|
||||
if( hasItem )
|
||||
this.slotItem = AEItemStack.loadItemStackFromPacket( stream );
|
||||
else
|
||||
this.slotItem = null;
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketInventoryAction( InventoryAction action, int slot, IAEItemStack slotItem ) throws IOException
|
||||
{
|
||||
|
||||
if( Platform.isClient() )
|
||||
throw new RuntimeException( "invalid packet, client cannot post inv actions with stacks." );
|
||||
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = 0;
|
||||
this.slotItem = slotItem;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( this.id );
|
||||
|
||||
if( slotItem == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
slotItem.writeToPacket( data );
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketInventoryAction( InventoryAction action, int slot, long id )
|
||||
{
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = id;
|
||||
this.slotItem = null;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( id );
|
||||
data.writeBoolean( false );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
if ( sender.openContainer instanceof AEBaseContainer )
|
||||
if( sender.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
if ( this.action == InventoryAction.AUTO_CRAFT )
|
||||
if( this.action == InventoryAction.AUTO_CRAFT )
|
||||
{
|
||||
ContainerOpenContext context = baseContainer.openContext;
|
||||
if ( context != null )
|
||||
if( context != null )
|
||||
{
|
||||
TileEntity te = context.getTile();
|
||||
Platform.openGUI( sender, te, baseContainer.openContext.side, GuiBridge.GUI_CRAFTING_AMOUNT );
|
||||
|
||||
if ( sender.openContainer instanceof ContainerCraftAmount )
|
||||
if( sender.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
||||
|
||||
if ( baseContainer.getTargetStack() != null )
|
||||
if( baseContainer.getTargetStack() != null )
|
||||
{
|
||||
cca.craftingItem.putStack( baseContainer.getTargetStack().getItemStack() );
|
||||
cca.whatToMake = baseContainer.getTargetStack();
|
||||
@@ -96,62 +148,14 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
if ( this.action == InventoryAction.UPDATE_HAND )
|
||||
if( this.action == InventoryAction.UPDATE_HAND )
|
||||
{
|
||||
if ( this.slotItem == null )
|
||||
if( this.slotItem == null )
|
||||
ClientHelper.proxy.getPlayers().get( 0 ).inventory.setItemStack( null );
|
||||
else
|
||||
ClientHelper.proxy.getPlayers().get( 0 ).inventory.setItemStack( this.slotItem.getItemStack() );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketInventoryAction(InventoryAction action, int slot, IAEItemStack slotItem) throws IOException {
|
||||
|
||||
if ( Platform.isClient() )
|
||||
throw new RuntimeException( "invalid packet, client cannot post inv actions with stacks." );
|
||||
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = 0;
|
||||
this.slotItem = slotItem;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( this.id );
|
||||
|
||||
if ( slotItem == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
slotItem.writeToPacket( data );
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketInventoryAction(InventoryAction action, int slot, long id)
|
||||
{
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = id;
|
||||
this.slotItem = null;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( id );
|
||||
data.writeBoolean( false );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -34,6 +35,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PacketLightning extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -42,31 +44,15 @@ public class PacketLightning extends AppEngPacket
|
||||
final double z;
|
||||
|
||||
// automatic.
|
||||
public PacketLightning(ByteBuf stream) {
|
||||
public PacketLightning( ByteBuf stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
this.z = stream.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( Platform.isClient() && AEConfig.instance.enableEffects )
|
||||
{
|
||||
LightningFX fx = new LightningFX( ClientHelper.proxy.getWorld(), this.x, this.y, this.z, 0.0f, 0.0f, 0.0f );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketLightning(double x, double y, double z)
|
||||
public PacketLightning( double x, double y, double z )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -82,4 +68,20 @@ public class PacketLightning extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( Platform.isClient() && AEConfig.instance.enableEffects )
|
||||
{
|
||||
LightningFX fx = new LightningFX( ClientHelper.proxy.getWorld(), this.x, this.y, this.z, 0.0f, 0.0f, 0.0f );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
catch( Exception ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -34,6 +35,7 @@ import appeng.client.render.effects.MatterCannonFX;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
public class PacketMatterCannon extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -46,7 +48,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
final byte len;
|
||||
|
||||
// automatic.
|
||||
public PacketMatterCannon(ByteBuf stream)
|
||||
public PacketMatterCannon( ByteBuf stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
@@ -57,28 +59,8 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
this.len = stream.readByte();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
World world = FMLClientHandler.instance().getClient().theWorld;
|
||||
for (int a = 1; a < this.len; a++)
|
||||
{
|
||||
MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx * a, this.y + this.dy * a, this.z + this.dz * a, Items.diamond );
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMatterCannon(double x, double y, double z, float dx, float dy, float dz, byte len)
|
||||
public PacketMatterCannon( double x, double y, double z, float dx, float dy, float dz, byte len )
|
||||
{
|
||||
float dl = dx * dx + dy * dy + dz * dz;
|
||||
float dlz = (float) Math.sqrt( dl );
|
||||
@@ -105,4 +87,23 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
World world = FMLClientHandler.instance().getClient().theWorld;
|
||||
for( int a = 1; a < this.len; a++ )
|
||||
{
|
||||
MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx * a, this.y + this.dy * a, this.z + this.dz * a, Items.diamond );
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
catch( Exception ignored )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -31,6 +32,7 @@ import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
public class PacketMockExplosion extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -38,16 +40,8 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
final public double y;
|
||||
final public double z;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
World world = CommonHelper.proxy.getWorld();
|
||||
world.spawnParticle( "largeexplode", this.x, this.y, this.z, 1.0D, 0.0D, 0.0D );
|
||||
}
|
||||
|
||||
// automatic.
|
||||
public PacketMockExplosion(ByteBuf stream)
|
||||
public PacketMockExplosion( ByteBuf stream )
|
||||
{
|
||||
this.x = stream.readDouble();
|
||||
this.y = stream.readDouble();
|
||||
@@ -55,7 +49,7 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMockExplosion(double x, double y, double z)
|
||||
public PacketMockExplosion( double x, double y, double z )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -71,4 +65,11 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
World world = CommonHelper.proxy.getWorld();
|
||||
world.spawnParticle( "largeexplode", this.x, this.y, this.z, 1.0D, 0.0D, 0.0D );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -31,25 +32,15 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.IFMP;
|
||||
|
||||
|
||||
public class PacketMultiPart extends AppEngPacket
|
||||
{
|
||||
|
||||
// automatic.
|
||||
public PacketMultiPart(ByteBuf stream)
|
||||
public PacketMultiPart( ByteBuf stream )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
IFMP fmp = (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP );
|
||||
if ( fmp != null )
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
MinecraftForge.EVENT_BUS.post( fmp.newFMPPacketEvent( sender ) ); // when received it just posts this event.
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMultiPart()
|
||||
{
|
||||
@@ -60,4 +51,14 @@ public class PacketMultiPart extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
IFMP fmp = (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP );
|
||||
if( fmp != null )
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
MinecraftForge.EVENT_BUS.post( fmp.newFMPPacketEvent( sender ) ); // when received it just posts this event.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,16 +69,16 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
ByteArrayInputStream bytes = new ByteArrayInputStream( stream.array() );
|
||||
bytes.skip( stream.readerIndex() );
|
||||
NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes );
|
||||
if ( comp != null )
|
||||
if( comp != null )
|
||||
{
|
||||
this.recipe = new ItemStack[9][];
|
||||
for ( int x = 0; x < this.recipe.length; x++ )
|
||||
for( int x = 0; x < this.recipe.length; x++ )
|
||||
{
|
||||
NBTTagList list = comp.getTagList( "#" + x, 10 );
|
||||
if ( list.tagCount() > 0 )
|
||||
if( list.tagCount() > 0 )
|
||||
{
|
||||
this.recipe[x] = new ItemStack[list.tagCount()];
|
||||
for ( int y = 0; y < list.tagCount(); y++ )
|
||||
for( int y = 0; y < list.tagCount(); y++ )
|
||||
{
|
||||
this.recipe[x][y] = ItemStack.loadItemStackFromNBT( list.getCompoundTagAt( y ) );
|
||||
}
|
||||
@@ -87,20 +87,36 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketNEIRecipe( NBTTagCompound recipe ) throws IOException
|
||||
{
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream outputStream = new DataOutputStream( bytes );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
|
||||
CompressedStreamTools.writeCompressed( recipe, outputStream );
|
||||
data.writeBytes( bytes.toByteArray() );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
EntityPlayerMP pmp = ( EntityPlayerMP ) player;
|
||||
EntityPlayerMP pmp = (EntityPlayerMP) player;
|
||||
Container con = pmp.openContainer;
|
||||
|
||||
if ( con instanceof IContainerCraftingPacket )
|
||||
if( con instanceof IContainerCraftingPacket )
|
||||
{
|
||||
IContainerCraftingPacket cct = ( IContainerCraftingPacket ) con;
|
||||
IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
||||
IGridNode node = cct.getNetworkNode();
|
||||
if ( node != null )
|
||||
if( node != null )
|
||||
{
|
||||
IGrid grid = node.getGrid();
|
||||
if ( grid == null )
|
||||
if( grid == null )
|
||||
return;
|
||||
|
||||
IStorageGrid inv = grid.getCache( IStorageGrid.class );
|
||||
@@ -111,12 +127,12 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
|
||||
Actionable realForFake = cct.useRealItems() ? Actionable.MODULATE : Actionable.SIMULATE;
|
||||
|
||||
if ( inv != null && this.recipe != null && security != null )
|
||||
if( inv != null && this.recipe != null && security != null )
|
||||
{
|
||||
InventoryCrafting testInv = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
for ( int x = 0; x < 9; x++ )
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
if ( this.recipe[x] != null && this.recipe[x].length > 0 )
|
||||
if( this.recipe[x] != null && this.recipe[x].length > 0 )
|
||||
{
|
||||
testInv.setInventorySlotContents( x, this.recipe[x][0] );
|
||||
}
|
||||
@@ -124,35 +140,34 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
|
||||
IRecipe r = Platform.findMatchingRecipe( testInv, pmp.worldObj );
|
||||
|
||||
if ( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
|
||||
if( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
|
||||
{
|
||||
ItemStack is = r.getCraftingResult( testInv );
|
||||
|
||||
if ( is != null )
|
||||
if( is != null )
|
||||
{
|
||||
IMEMonitor<IAEItemStack> storage = inv.getItemInventory();
|
||||
IItemList all = storage.getStorageList();
|
||||
IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
|
||||
|
||||
for ( int x = 0; x < craftMatrix.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < craftMatrix.getSizeInventory(); x++ )
|
||||
{
|
||||
ItemStack PatternItem = testInv.getStackInSlot( x );
|
||||
|
||||
ItemStack currentItem = craftMatrix.getStackInSlot( x );
|
||||
if ( currentItem != null )
|
||||
if( currentItem != null )
|
||||
{
|
||||
testInv.setInventorySlotContents( x, currentItem );
|
||||
ItemStack newItemStack = r.matches( testInv, pmp.worldObj ) ? r.getCraftingResult( testInv ) : null;
|
||||
testInv.setInventorySlotContents( x, PatternItem );
|
||||
|
||||
if ( newItemStack == null || !Platform.isSameItemPrecise( newItemStack, is ) )
|
||||
if( newItemStack == null || !Platform.isSameItemPrecise( newItemStack, is ) )
|
||||
{
|
||||
IAEItemStack in = AEItemStack.create( currentItem );
|
||||
if ( in != null )
|
||||
if( in != null )
|
||||
{
|
||||
IAEItemStack out = realForFake == Actionable.SIMULATE ? null : Platform.poweredInsert( energy, storage, in,
|
||||
cct.getSource() );
|
||||
if ( out != null )
|
||||
IAEItemStack out = realForFake == Actionable.SIMULATE ? null : Platform.poweredInsert( energy, storage, in, cct.getSource() );
|
||||
if( out != null )
|
||||
craftMatrix.setInventorySlotContents( x, out.getItemStack() );
|
||||
else
|
||||
craftMatrix.setInventorySlotContents( x, null );
|
||||
@@ -163,26 +178,25 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
}
|
||||
|
||||
// True if we need to fetch an item for the recipe
|
||||
if ( PatternItem != null && currentItem == null )
|
||||
if( PatternItem != null && currentItem == null )
|
||||
{
|
||||
// Grab from network by recipe
|
||||
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), storage, player.worldObj, r, is, testInv,
|
||||
PatternItem, x, all, realForFake, filter );
|
||||
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), storage, player.worldObj, r, is, testInv, PatternItem, x, all, realForFake, filter );
|
||||
|
||||
// If that doesn't get it, grab exact items from network (?)
|
||||
// TODO see if this code is necessary
|
||||
if ( whichItem == null )
|
||||
if( whichItem == null )
|
||||
{
|
||||
for ( int y = 0; y < this.recipe[x].length; y++ )
|
||||
for( int y = 0; y < this.recipe[x].length; y++ )
|
||||
{
|
||||
IAEItemStack request = AEItemStack.create( this.recipe[x][y] );
|
||||
if ( request != null )
|
||||
if( request != null )
|
||||
{
|
||||
if ( filter == null || filter.isListed( request ) )
|
||||
if( filter == null || filter.isListed( request ) )
|
||||
{
|
||||
request.setStackSize( 1 );
|
||||
IAEItemStack out = Platform.poweredExtraction( energy, storage, request, cct.getSource() );
|
||||
if ( out != null )
|
||||
if( out != null )
|
||||
{
|
||||
whichItem = out.getItemStack();
|
||||
break;
|
||||
@@ -193,18 +207,18 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
}
|
||||
|
||||
// If that doesn't work, grab from the player's inventory
|
||||
if ( whichItem == null && playerInventory != null )
|
||||
if( whichItem == null && playerInventory != null )
|
||||
{
|
||||
for ( int y = 0; y < this.recipe[x].length; y++ )
|
||||
for( int y = 0; y < this.recipe[x].length; y++ )
|
||||
{
|
||||
ItemStack playerItemStack = null;
|
||||
for ( int i = 0; i < playerInventory.getSizeInventory(); i++ )
|
||||
for( int i = 0; i < playerInventory.getSizeInventory(); i++ )
|
||||
{
|
||||
// check if the item in slot y matches the required item.
|
||||
playerItemStack = playerInventory.getStackInSlot( i );
|
||||
if ( playerItemStack != null && this.recipe[x][y] != null && playerItemStack.getItem() == this.recipe[x][y].getItem() )
|
||||
if( playerItemStack != null && this.recipe[x][y] != null && playerItemStack.getItem() == this.recipe[x][y].getItem() )
|
||||
{
|
||||
if ( realForFake == Actionable.SIMULATE )
|
||||
if( realForFake == Actionable.SIMULATE )
|
||||
{
|
||||
whichItem = playerInventory.getStackInSlot( i ).copy();
|
||||
whichItem.stackSize = 1;
|
||||
@@ -229,20 +243,4 @@ public class PacketNEIRecipe extends AppEngPacket
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketNEIRecipe( NBTTagCompound recipe ) throws IOException
|
||||
{
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream outputStream = new DataOutputStream( bytes );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
|
||||
CompressedStreamTools.writeCompressed( recipe, outputStream );
|
||||
data.writeBytes( bytes.toByteArray() );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -31,33 +32,20 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
public class PacketNewStorageDimension extends AppEngPacket
|
||||
{
|
||||
|
||||
final int newDim;
|
||||
|
||||
// automatic.
|
||||
public PacketNewStorageDimension(ByteBuf stream)
|
||||
public PacketNewStorageDimension( ByteBuf stream )
|
||||
{
|
||||
this.newDim = stream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
try
|
||||
{
|
||||
DimensionManager.registerDimension( this.newDim, AEConfig.instance.storageProviderID );
|
||||
}
|
||||
catch (IllegalArgumentException iae)
|
||||
{
|
||||
// ok!
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketNewStorageDimension(int newDim)
|
||||
public PacketNewStorageDimension( int newDim )
|
||||
{
|
||||
this.newDim = newDim;
|
||||
|
||||
@@ -69,4 +57,17 @@ public class PacketNewStorageDimension extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
try
|
||||
{
|
||||
DimensionManager.registerDimension( this.newDim, AEConfig.instance.storageProviderID );
|
||||
}
|
||||
catch( IllegalArgumentException iae )
|
||||
{
|
||||
// ok!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -29,6 +30,7 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
|
||||
|
||||
public class PacketPaintedEntity extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -37,30 +39,31 @@ public class PacketPaintedEntity extends AppEngPacket
|
||||
private int ticks;
|
||||
|
||||
// automatic.
|
||||
public PacketPaintedEntity(ByteBuf stream)
|
||||
public PacketPaintedEntity( ByteBuf stream )
|
||||
{
|
||||
this.entityId = stream.readInt();
|
||||
this.myColor = AEColor.values()[stream.readByte()];
|
||||
this.ticks = stream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
PlayerColor pc = new PlayerColor( this.entityId, this.myColor, this.ticks );
|
||||
TickHandler.INSTANCE.getPlayerColors().put( this.entityId, pc );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketPaintedEntity(int myEntity, AEColor myColor, int ticksLeft) {
|
||||
public PacketPaintedEntity( int myEntity, AEColor myColor, int ticksLeft )
|
||||
{
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.entityId = myEntity );
|
||||
data.writeByte( (this.myColor = myColor).ordinal() );
|
||||
data.writeByte( ( this.myColor = myColor ).ordinal() );
|
||||
data.writeInt( ticksLeft );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
PlayerColor pc = new PlayerColor( this.entityId, this.myColor, this.ticks );
|
||||
TickHandler.INSTANCE.getPlayerColors().put( this.entityId, pc );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -29,6 +30,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.parts.PartPlacement;
|
||||
|
||||
|
||||
public class PacketPartPlacement extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -39,7 +41,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
float eyeHeight;
|
||||
|
||||
// automatic.
|
||||
public PacketPartPlacement(ByteBuf stream)
|
||||
public PacketPartPlacement( ByteBuf stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
@@ -48,18 +50,8 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
this.eyeHeight = stream.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
CommonHelper.proxy.updateRenderMode( sender );
|
||||
PartPlacement.eyeHeight = this.eyeHeight;
|
||||
PartPlacement.place( sender.getHeldItem(), this.x, this.y, this.z, this.face, sender, sender.worldObj, PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 );
|
||||
CommonHelper.proxy.updateRenderMode( null );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketPartPlacement(int x, int y, int z, int face, float eyeHeight )
|
||||
public PacketPartPlacement( int x, int y, int z, int face, float eyeHeight )
|
||||
{
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
@@ -73,4 +65,13 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
CommonHelper.proxy.updateRenderMode( sender );
|
||||
PartPlacement.eyeHeight = this.eyeHeight;
|
||||
PartPlacement.place( sender.getHeldItem(), this.x, this.y, this.z, this.face, sender, sender.worldObj, PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 );
|
||||
CommonHelper.proxy.updateRenderMode( null );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -27,6 +28,7 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
public class PacketPartialItem extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -34,28 +36,19 @@ public class PacketPartialItem extends AppEngPacket
|
||||
final byte[] data;
|
||||
|
||||
// automatic.
|
||||
public PacketPartialItem(ByteBuf stream)
|
||||
public PacketPartialItem( ByteBuf stream )
|
||||
{
|
||||
this.pageNum = stream.readShort();
|
||||
stream.readBytes( this.data = new byte[stream.readableBytes()] );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
if ( player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
((AEBaseContainer) player.openContainer).postPartial( this );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketPartialItem(int page, int maxPages, byte[] buf)
|
||||
public PacketPartialItem( int page, int maxPages, byte[] buf )
|
||||
{
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
this.pageNum = (short) (page | (maxPages << 8));
|
||||
this.pageNum = (short) ( page | ( maxPages << 8 ) );
|
||||
this.data = buf;
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeShort( this.pageNum );
|
||||
@@ -64,6 +57,15 @@ public class PacketPartialItem extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
if( player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
( (AEBaseContainer) player.openContainer ).postPartial( this );
|
||||
}
|
||||
}
|
||||
|
||||
public int getPageCount()
|
||||
{
|
||||
return this.pageNum >> 8;
|
||||
@@ -74,7 +76,7 @@ public class PacketPartialItem extends AppEngPacket
|
||||
return this.data.length;
|
||||
}
|
||||
|
||||
public int write(byte[] buffer, int cursor)
|
||||
public int write( byte[] buffer, int cursor )
|
||||
{
|
||||
System.arraycopy( this.data, 0, buffer, cursor, this.data.length );
|
||||
return cursor + this.data.length;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -34,6 +35,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class PacketPatternSlot extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -43,51 +45,31 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
|
||||
final public boolean shift;
|
||||
|
||||
public IAEItemStack readItem(ByteBuf stream) throws IOException
|
||||
{
|
||||
boolean hasItem = stream.readBoolean();
|
||||
|
||||
if ( hasItem )
|
||||
return AEItemStack.loadItemStackFromPacket( stream );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// automatic.
|
||||
public PacketPatternSlot(ByteBuf stream) throws IOException {
|
||||
public PacketPatternSlot( ByteBuf stream ) throws IOException
|
||||
{
|
||||
|
||||
this.shift = stream.readBoolean();
|
||||
|
||||
this.slotItem = this.readItem( stream );
|
||||
|
||||
for (int x = 0; x < 9; x++)
|
||||
for( int x = 0; x < 9; x++ )
|
||||
this.pattern[x] = this.readItem( stream );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
public IAEItemStack readItem( ByteBuf stream ) throws IOException
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
if ( sender.openContainer instanceof ContainerPatternTerm )
|
||||
{
|
||||
ContainerPatternTerm patternTerminal = (ContainerPatternTerm) sender.openContainer;
|
||||
patternTerminal.craftOrGetItem( this );
|
||||
}
|
||||
}
|
||||
boolean hasItem = stream.readBoolean();
|
||||
|
||||
private void writeItem(IAEItemStack slotItem, ByteBuf data) throws IOException
|
||||
{
|
||||
if ( slotItem == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
slotItem.writeToPacket( data );
|
||||
}
|
||||
if( hasItem )
|
||||
return AEItemStack.loadItemStackFromPacket( stream );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketPatternSlot(IInventory pat, IAEItemStack slotItem, boolean shift) throws IOException {
|
||||
public PacketPatternSlot( IInventory pat, IAEItemStack slotItem, boolean shift ) throws IOException
|
||||
{
|
||||
|
||||
this.slotItem = slotItem;
|
||||
this.shift = shift;
|
||||
@@ -99,7 +81,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
data.writeBoolean( shift );
|
||||
|
||||
this.writeItem( slotItem, data );
|
||||
for (int x = 0; x < 9; x++)
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
this.pattern[x] = AEApi.instance().storage().createItemStack( pat.getStackInSlot( x ) );
|
||||
this.writeItem( this.pattern[x], data );
|
||||
@@ -108,4 +90,25 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
private void writeItem( IAEItemStack slotItem, ByteBuf data ) throws IOException
|
||||
{
|
||||
if( slotItem == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
slotItem.writeToPacket( data );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
if( sender.openContainer instanceof ContainerPatternTerm )
|
||||
{
|
||||
ContainerPatternTerm patternTerminal = (ContainerPatternTerm) sender.openContainer;
|
||||
patternTerminal.craftOrGetItem( this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -28,6 +29,7 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
public class PacketProgressBar extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -35,30 +37,14 @@ public class PacketProgressBar extends AppEngPacket
|
||||
final long value;
|
||||
|
||||
// automatic.
|
||||
public PacketProgressBar(ByteBuf stream)
|
||||
public PacketProgressBar( ByteBuf stream )
|
||||
{
|
||||
this.id = stream.readShort();
|
||||
this.value = stream.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
if ( c instanceof AEBaseContainer )
|
||||
((AEBaseContainer) c).updateFullProgressBar( this.id, this.value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
if ( c instanceof AEBaseContainer )
|
||||
((AEBaseContainer) c).updateFullProgressBar( this.id, this.value );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketProgressBar(int short_id, long value)
|
||||
public PacketProgressBar( int short_id, long value )
|
||||
{
|
||||
this.id = (short) short_id;
|
||||
this.value = value;
|
||||
@@ -71,4 +57,20 @@ public class PacketProgressBar extends AppEngPacket
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
if( c instanceof AEBaseContainer )
|
||||
( (AEBaseContainer) c ).updateFullProgressBar( this.id, this.value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
if( c instanceof AEBaseContainer )
|
||||
( (AEBaseContainer) c ).updateFullProgressBar( this.id, this.value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -27,6 +28,7 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
public class PacketSwapSlots extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -34,23 +36,14 @@ public class PacketSwapSlots extends AppEngPacket
|
||||
final int slotB;
|
||||
|
||||
// automatic.
|
||||
public PacketSwapSlots(ByteBuf stream)
|
||||
public PacketSwapSlots( ByteBuf stream )
|
||||
{
|
||||
this.slotA = stream.readInt();
|
||||
this.slotB = stream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
if ( player != null && player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
((AEBaseContainer) player.openContainer).swapSlotContents( this.slotA, this.slotB );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketSwapSlots(int slotA, int slotB)
|
||||
public PacketSwapSlots( int slotA, int slotB )
|
||||
{
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
@@ -60,4 +53,13 @@ public class PacketSwapSlots extends AppEngPacket
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
if( player != null && player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
( (AEBaseContainer) player.openContainer ).swapSlotContents( this.slotA, this.slotB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -33,45 +34,24 @@ import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PacketSwitchGuis extends AppEngPacket
|
||||
{
|
||||
|
||||
final GuiBridge newGui;
|
||||
|
||||
// automatic.
|
||||
public PacketSwitchGuis(ByteBuf stream)
|
||||
public PacketSwitchGuis( ByteBuf stream )
|
||||
{
|
||||
this.newGui = GuiBridge.values()[stream.readInt()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
if ( c instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer bc = (AEBaseContainer) c;
|
||||
ContainerOpenContext context = bc.openContext;
|
||||
if ( context != null )
|
||||
{
|
||||
TileEntity te = context.getTile();
|
||||
Platform.openGUI( player, te, context.side, this.newGui );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
AEBaseGui.switchingGuis = true;
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketSwitchGuis(GuiBridge newGui)
|
||||
public PacketSwitchGuis( GuiBridge newGui )
|
||||
{
|
||||
this.newGui = newGui;
|
||||
|
||||
if ( Platform.isClient() )
|
||||
if( Platform.isClient() )
|
||||
AEBaseGui.switchingGuis = true;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
@@ -81,4 +61,26 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
if( c instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer bc = (AEBaseContainer) c;
|
||||
ContainerOpenContext context = bc.openContext;
|
||||
if( context != null )
|
||||
{
|
||||
TileEntity te = context.getTile();
|
||||
Platform.openGUI( player, te, context.side, this.newGui );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
AEBaseGui.switchingGuis = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@@ -40,17 +41,18 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PacketTransitionEffect extends AppEngPacket
|
||||
{
|
||||
|
||||
final public boolean mode;
|
||||
final double x;
|
||||
final double y;
|
||||
final double z;
|
||||
final ForgeDirection d;
|
||||
final public boolean mode;
|
||||
|
||||
// automatic.
|
||||
public PacketTransitionEffect(ByteBuf stream)
|
||||
public PacketTransitionEffect( ByteBuf stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
@@ -59,44 +61,8 @@ public class PacketTransitionEffect extends AppEngPacket
|
||||
this.mode = stream.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
World world = ClientHelper.proxy.getWorld();
|
||||
|
||||
for (int zz = 0; zz < (this.mode ? 32 : 8); zz++)
|
||||
if ( CommonHelper.proxy.shouldAddParticles( Platform.getRandom() ) )
|
||||
{
|
||||
EnergyFx fx = new EnergyFx( world, this.x + (this.mode ? (Platform.getRandomInt() % 100) * 0.01 : (Platform.getRandomInt() % 100) * 0.005 - 0.25), this.y
|
||||
+ (this.mode ? (Platform.getRandomInt() % 100) * 0.01 : (Platform.getRandomInt() % 100) * 0.005 - 0.25), this.z
|
||||
+ (this.mode ? (Platform.getRandomInt() % 100) * 0.01 : (Platform.getRandomInt() % 100) * 0.005 - 0.25), Items.diamond );
|
||||
|
||||
if ( !this.mode )
|
||||
fx.fromItem( this.d );
|
||||
|
||||
fx.motionX = -0.1 * this.d.offsetX;
|
||||
fx.motionY = -0.1 * this.d.offsetY;
|
||||
fx.motionZ = -0.1 * this.d.offsetZ;
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
|
||||
if ( this.mode )
|
||||
{
|
||||
Block block = world.getBlock( (int) this.x, (int) this.y, (int) this.z );
|
||||
|
||||
Minecraft
|
||||
.getMinecraft()
|
||||
.getSoundHandler()
|
||||
.playSound(
|
||||
new PositionedSoundRecord( new ResourceLocation( block.stepSound.getBreakSound() ), (block.stepSound.getVolume() + 1.0F) / 2.0F,
|
||||
block.stepSound.getPitch() * 0.8F, (float) this.x + 0.5F, (float) this.y + 0.5F, (float) this.z + 0.5F ) );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketTransitionEffect(double x, double y, double z, ForgeDirection dir, boolean wasBlock)
|
||||
public PacketTransitionEffect( double x, double y, double z, ForgeDirection dir, boolean wasBlock )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -116,4 +82,32 @@ public class PacketTransitionEffect extends AppEngPacket
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
World world = ClientHelper.proxy.getWorld();
|
||||
|
||||
for( int zz = 0; zz < ( this.mode ? 32 : 8 ); zz++ )
|
||||
if( CommonHelper.proxy.shouldAddParticles( Platform.getRandom() ) )
|
||||
{
|
||||
EnergyFx fx = new EnergyFx( world, this.x + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 ), this.y + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 ), this.z + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 ), Items.diamond );
|
||||
|
||||
if( !this.mode )
|
||||
fx.fromItem( this.d );
|
||||
|
||||
fx.motionX = -0.1 * this.d.offsetX;
|
||||
fx.motionY = -0.1 * this.d.offsetY;
|
||||
fx.motionZ = -0.1 * this.d.offsetZ;
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
|
||||
}
|
||||
|
||||
if( this.mode )
|
||||
{
|
||||
Block block = world.getBlock( (int) this.x, (int) this.y, (int) this.z );
|
||||
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound( new PositionedSoundRecord( new ResourceLocation( block.stepSound.getBreakSound() ), ( block.stepSound.getVolume() + 1.0F ) / 2.0F, block.stepSound.getPitch() * 0.8F, (float) this.x + 0.5F, (float) this.y + 0.5F, (float) this.z + 0.5F ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
@@ -54,6 +55,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
|
||||
|
||||
public class PacketValueConfig extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -61,198 +63,17 @@ public class PacketValueConfig extends AppEngPacket
|
||||
final public String Value;
|
||||
|
||||
// automatic.
|
||||
public PacketValueConfig(ByteBuf stream) throws IOException {
|
||||
public PacketValueConfig( ByteBuf stream ) throws IOException
|
||||
{
|
||||
DataInputStream dis = new DataInputStream( new ByteArrayInputStream( stream.array(), stream.readerIndex(), stream.readableBytes() ) );
|
||||
this.Name = dis.readUTF();
|
||||
this.Value = dis.readUTF();
|
||||
// dis.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
|
||||
if ( this.Name.equals( "Item" ) && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IMouseWheelItem )
|
||||
{
|
||||
ItemStack is = player.getHeldItem();
|
||||
IMouseWheelItem si = (IMouseWheelItem) is.getItem();
|
||||
si.onWheel( is, this.Value.equals( "WheelUp" ) );
|
||||
}
|
||||
else if ( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftingStatus )
|
||||
{
|
||||
ContainerCraftingStatus qk = (ContainerCraftingStatus) c;
|
||||
qk.cycleCpu( this.Value.equals( "Next" ) );
|
||||
}
|
||||
else if ( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.cycleCpu( this.Value.equals( "Next" ) );
|
||||
}
|
||||
else if ( this.Name.equals( "Terminal.Start" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.startJob();
|
||||
}
|
||||
else if ( this.Name.equals( "TileCrafting.Cancel" ) && c instanceof ContainerCraftingCPU )
|
||||
{
|
||||
ContainerCraftingCPU qk = (ContainerCraftingCPU) c;
|
||||
qk.cancelCrafting();
|
||||
}
|
||||
else if ( this.Name.equals( "QuartzKnife.Name" ) && c instanceof ContainerQuartzKnife )
|
||||
{
|
||||
ContainerQuartzKnife qk = (ContainerQuartzKnife) c;
|
||||
qk.setName( this.Value );
|
||||
}
|
||||
else if ( this.Name.equals( "TileSecurity.ToggleOption" ) && c instanceof ContainerSecurity )
|
||||
{
|
||||
ContainerSecurity sc = (ContainerSecurity) c;
|
||||
sc.toggleSetting( this.Value, player );
|
||||
}
|
||||
else if ( this.Name.equals( "PriorityHost.Priority" ) && c instanceof ContainerPriority )
|
||||
{
|
||||
ContainerPriority pc = (ContainerPriority) c;
|
||||
pc.setPriority( Integer.parseInt( this.Value ), player );
|
||||
}
|
||||
else if ( this.Name.equals( "LevelEmitter.Value" ) && c instanceof ContainerLevelEmitter )
|
||||
{
|
||||
ContainerLevelEmitter lvc = (ContainerLevelEmitter) c;
|
||||
lvc.setLevel( Long.parseLong( this.Value ), player );
|
||||
}
|
||||
else if ( this.Name.startsWith( "PatternTerminal." ) && c instanceof ContainerPatternTerm )
|
||||
{
|
||||
ContainerPatternTerm cpt = (ContainerPatternTerm) c;
|
||||
if ( this.Name.equals( "PatternTerminal.CraftMode" ) )
|
||||
{
|
||||
cpt.ct.setCraftingRecipe( this.Value.equals( "1" ) );
|
||||
}
|
||||
else if ( this.Name.equals( "PatternTerminal.Encode" ) )
|
||||
{
|
||||
cpt.encode();
|
||||
}
|
||||
else if ( this.Name.equals( "PatternTerminal.Clear" ) )
|
||||
{
|
||||
cpt.clear();
|
||||
}
|
||||
}
|
||||
else if ( this.Name.startsWith( "StorageBus." ) && c instanceof ContainerStorageBus )
|
||||
{
|
||||
ContainerStorageBus ccw = (ContainerStorageBus) c;
|
||||
if ( this.Name.equals( "StorageBus.Action" ) )
|
||||
{
|
||||
if ( this.Value.equals( "Partition" ) )
|
||||
{
|
||||
ccw.partition();
|
||||
}
|
||||
else if ( this.Value.equals( "Clear" ) )
|
||||
{
|
||||
ccw.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( this.Name.startsWith( "CellWorkbench." ) && c instanceof ContainerCellWorkbench )
|
||||
{
|
||||
ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;
|
||||
if ( this.Name.equals( "CellWorkbench.Action" ) )
|
||||
{
|
||||
if ( this.Value.equals( "CopyMode" ) )
|
||||
{
|
||||
ccw.nextCopyMode();
|
||||
}
|
||||
else if ( this.Value.equals( "Partition" ) )
|
||||
{
|
||||
ccw.partition();
|
||||
}
|
||||
else if ( this.Value.equals( "Clear" ) )
|
||||
{
|
||||
ccw.clear();
|
||||
}
|
||||
}
|
||||
else if ( this.Name.equals( "CellWorkbench.Fuzzy" ) )
|
||||
{
|
||||
ccw.setFuzzy( FuzzyMode.valueOf( this.Value ) );
|
||||
}
|
||||
}
|
||||
else if ( c instanceof ContainerNetworkTool )
|
||||
{
|
||||
if ( this.Name.equals( "NetworkTool" ) && this.Value.equals( "Toggle" ) )
|
||||
{
|
||||
((ContainerNetworkTool) c).toggleFacadeMode();
|
||||
}
|
||||
}
|
||||
else if ( c instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for (Settings e : cm.getSettings())
|
||||
{
|
||||
if ( e.name().equals( this.Name ) )
|
||||
{
|
||||
Enum<?> def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) );
|
||||
}
|
||||
catch (IllegalArgumentException err)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
|
||||
if ( this.Name.equals( "CustomName" ) && c instanceof AEBaseContainer )
|
||||
{
|
||||
((AEBaseContainer) c).customName = this.Value;
|
||||
}
|
||||
else if ( this.Name.startsWith( "SyncDat." ) )
|
||||
{
|
||||
((AEBaseContainer) c).stringSync( Integer.parseInt( this.Name.substring( 8 ) ), this.Value );
|
||||
}
|
||||
else if ( this.Name.equals( "CraftingStatus" ) && this.Value.equals( "Clear" ) )
|
||||
{
|
||||
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if ( gs instanceof GuiCraftingCPU )
|
||||
((GuiCraftingCPU) gs).clearItems();
|
||||
}
|
||||
else if ( c instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for (Settings e : cm.getSettings())
|
||||
{
|
||||
if ( e.name().equals( this.Name ) )
|
||||
{
|
||||
Enum<?> def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) );
|
||||
}
|
||||
catch (IllegalArgumentException err)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketValueConfig(String Name, String Value) throws IOException {
|
||||
public PacketValueConfig( String Name, String Value ) throws IOException
|
||||
{
|
||||
this.Name = Name;
|
||||
this.Value = Value;
|
||||
|
||||
@@ -270,4 +91,185 @@ public class PacketValueConfig extends AppEngPacket
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
|
||||
if( this.Name.equals( "Item" ) && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IMouseWheelItem )
|
||||
{
|
||||
ItemStack is = player.getHeldItem();
|
||||
IMouseWheelItem si = (IMouseWheelItem) is.getItem();
|
||||
si.onWheel( is, this.Value.equals( "WheelUp" ) );
|
||||
}
|
||||
else if( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftingStatus )
|
||||
{
|
||||
ContainerCraftingStatus qk = (ContainerCraftingStatus) c;
|
||||
qk.cycleCpu( this.Value.equals( "Next" ) );
|
||||
}
|
||||
else if( this.Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.cycleCpu( this.Value.equals( "Next" ) );
|
||||
}
|
||||
else if( this.Name.equals( "Terminal.Start" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.startJob();
|
||||
}
|
||||
else if( this.Name.equals( "TileCrafting.Cancel" ) && c instanceof ContainerCraftingCPU )
|
||||
{
|
||||
ContainerCraftingCPU qk = (ContainerCraftingCPU) c;
|
||||
qk.cancelCrafting();
|
||||
}
|
||||
else if( this.Name.equals( "QuartzKnife.Name" ) && c instanceof ContainerQuartzKnife )
|
||||
{
|
||||
ContainerQuartzKnife qk = (ContainerQuartzKnife) c;
|
||||
qk.setName( this.Value );
|
||||
}
|
||||
else if( this.Name.equals( "TileSecurity.ToggleOption" ) && c instanceof ContainerSecurity )
|
||||
{
|
||||
ContainerSecurity sc = (ContainerSecurity) c;
|
||||
sc.toggleSetting( this.Value, player );
|
||||
}
|
||||
else if( this.Name.equals( "PriorityHost.Priority" ) && c instanceof ContainerPriority )
|
||||
{
|
||||
ContainerPriority pc = (ContainerPriority) c;
|
||||
pc.setPriority( Integer.parseInt( this.Value ), player );
|
||||
}
|
||||
else if( this.Name.equals( "LevelEmitter.Value" ) && c instanceof ContainerLevelEmitter )
|
||||
{
|
||||
ContainerLevelEmitter lvc = (ContainerLevelEmitter) c;
|
||||
lvc.setLevel( Long.parseLong( this.Value ), player );
|
||||
}
|
||||
else if( this.Name.startsWith( "PatternTerminal." ) && c instanceof ContainerPatternTerm )
|
||||
{
|
||||
ContainerPatternTerm cpt = (ContainerPatternTerm) c;
|
||||
if( this.Name.equals( "PatternTerminal.CraftMode" ) )
|
||||
{
|
||||
cpt.ct.setCraftingRecipe( this.Value.equals( "1" ) );
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.Encode" ) )
|
||||
{
|
||||
cpt.encode();
|
||||
}
|
||||
else if( this.Name.equals( "PatternTerminal.Clear" ) )
|
||||
{
|
||||
cpt.clear();
|
||||
}
|
||||
}
|
||||
else if( this.Name.startsWith( "StorageBus." ) && c instanceof ContainerStorageBus )
|
||||
{
|
||||
ContainerStorageBus ccw = (ContainerStorageBus) c;
|
||||
if( this.Name.equals( "StorageBus.Action" ) )
|
||||
{
|
||||
if( this.Value.equals( "Partition" ) )
|
||||
{
|
||||
ccw.partition();
|
||||
}
|
||||
else if( this.Value.equals( "Clear" ) )
|
||||
{
|
||||
ccw.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( this.Name.startsWith( "CellWorkbench." ) && c instanceof ContainerCellWorkbench )
|
||||
{
|
||||
ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;
|
||||
if( this.Name.equals( "CellWorkbench.Action" ) )
|
||||
{
|
||||
if( this.Value.equals( "CopyMode" ) )
|
||||
{
|
||||
ccw.nextCopyMode();
|
||||
}
|
||||
else if( this.Value.equals( "Partition" ) )
|
||||
{
|
||||
ccw.partition();
|
||||
}
|
||||
else if( this.Value.equals( "Clear" ) )
|
||||
{
|
||||
ccw.clear();
|
||||
}
|
||||
}
|
||||
else if( this.Name.equals( "CellWorkbench.Fuzzy" ) )
|
||||
{
|
||||
ccw.setFuzzy( FuzzyMode.valueOf( this.Value ) );
|
||||
}
|
||||
}
|
||||
else if( c instanceof ContainerNetworkTool )
|
||||
{
|
||||
if( this.Name.equals( "NetworkTool" ) && this.Value.equals( "Toggle" ) )
|
||||
{
|
||||
( (ContainerNetworkTool) c ).toggleFacadeMode();
|
||||
}
|
||||
}
|
||||
else if( c instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ( (IConfigurableObject) c ).getConfigManager();
|
||||
|
||||
for( Settings e : cm.getSettings() )
|
||||
{
|
||||
if( e.name().equals( this.Name ) )
|
||||
{
|
||||
Enum<?> def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) );
|
||||
}
|
||||
catch( IllegalArgumentException err )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player )
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
|
||||
if( this.Name.equals( "CustomName" ) && c instanceof AEBaseContainer )
|
||||
{
|
||||
( (AEBaseContainer) c ).customName = this.Value;
|
||||
}
|
||||
else if( this.Name.startsWith( "SyncDat." ) )
|
||||
{
|
||||
( (AEBaseContainer) c ).stringSync( Integer.parseInt( this.Name.substring( 8 ) ), this.Value );
|
||||
}
|
||||
else if( this.Name.equals( "CraftingStatus" ) && this.Value.equals( "Clear" ) )
|
||||
{
|
||||
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if( gs instanceof GuiCraftingCPU )
|
||||
( (GuiCraftingCPU) gs ).clearItems();
|
||||
}
|
||||
else if( c instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ( (IConfigurableObject) c ).getConfigManager();
|
||||
|
||||
for( Settings e : cm.getSettings() )
|
||||
{
|
||||
if( e.name().equals( this.Name ) )
|
||||
{
|
||||
Enum<?> def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), this.Value ) );
|
||||
}
|
||||
catch( IllegalArgumentException err )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user