Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,507 @@
|
||||
package appeng.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.client.event.ConfigChangedEvent;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class AEConfig extends Configuration implements IConfigurableObject, IConfigManagerHost
|
||||
{
|
||||
|
||||
public static AEConfig instance;
|
||||
|
||||
public static double TunnelPowerLoss = 0.05;
|
||||
|
||||
public String latestVersion = VERSION;
|
||||
public long latestTimeStamp = 0;
|
||||
|
||||
public static final String VERSION = "@version@";
|
||||
public static final String CHANNEL = "@aechannel@";
|
||||
|
||||
public final static String PACKET_CHANNEL = "AE";
|
||||
|
||||
public IConfigManager settings = new ConfigManager( this );
|
||||
public EnumSet<AEFeature> featureFlags = EnumSet.noneOf( AEFeature.class );
|
||||
PowerUnits selectedPowerUnit = PowerUnits.AE;
|
||||
|
||||
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 = minMeteoriteDistance * minMeteoriteDistance;
|
||||
|
||||
private double WirelessBaseCost = 8;
|
||||
private double WirelessCostMultiplier = 1;
|
||||
private 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 WirelessTerminalDrainMultiplier * range;
|
||||
}
|
||||
|
||||
public double wireless_getMaxRange(int boosters)
|
||||
{
|
||||
return WirelessBaseRange + WirelessBoosterRangeMultiplier * Math.pow( boosters, WirelessBoosterExp );
|
||||
}
|
||||
|
||||
public double wireless_getPowerDrain(int boosters)
|
||||
{
|
||||
return WirelessBaseCost + WirelessCostMultiplier * Math.pow( boosters, 1 + boosters / 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 spatialPowerScaler = 1.35;
|
||||
public double spatialPowerMultiplier = 1250.0;
|
||||
|
||||
public String grinderOres[] = {
|
||||
// Vanilla Items
|
||||
"Obsidian", "Ender", "EnderPearl", "Coal", "Iron", "Gold", "Charcoal", "NetherQuartz",
|
||||
// Common Mod Ores
|
||||
"Copper", "Tin", "Silver", "Lead", "Bronze",
|
||||
// AE
|
||||
"CertusQuartz", "Wheat", "Fluix",
|
||||
// Other Mod Ores
|
||||
"Brass", "Platinum", "Nickel", "Invar", "Aluminium", "Electrum", "Osmium" };
|
||||
|
||||
public double oreDoublePercentage = 90.0;
|
||||
|
||||
public boolean enableEffects = true;
|
||||
public boolean useLargeFonts = false;
|
||||
public int[] craftByStacks = new int[] { 1, 10, 100, 1000 };
|
||||
public int[] priorityByStacks = new int[] { 1, 10, 100, 1000 };
|
||||
public int[] levelByStacks = new int[] { 1, 10, 100, 1000 };
|
||||
|
||||
public int wireless_battery = 1600000;
|
||||
public int manipulator_battery = 200000;
|
||||
public int mattercannon_battery = 200000;
|
||||
public int portablecell_battery = 20000;
|
||||
public int colorapplicator_battery = 20000;
|
||||
public int staff_battery = 8000;
|
||||
|
||||
public boolean disableColoredCableRecipesInNEI = true;
|
||||
|
||||
public boolean updatable = false;
|
||||
final private File myPath;
|
||||
|
||||
public double meteoriteClusterChance = 0.1;
|
||||
public double meteoriteSpawnChance = 0.3;
|
||||
|
||||
public int craftingCalculationTimePerTick = 5;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs)
|
||||
{
|
||||
if ( eventArgs.modID.equals( AppEng.modid ) )
|
||||
{
|
||||
clientSync();
|
||||
}
|
||||
}
|
||||
|
||||
private void clientSync()
|
||||
{
|
||||
disableColoredCableRecipesInNEI = get( "Client", "disableColoredCableRecipesInNEI", true ).getBoolean( true );
|
||||
enableEffects = get( "Client", "enableEffects", true ).getBoolean( true );
|
||||
useLargeFonts = get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false );
|
||||
|
||||
// load buttons..
|
||||
for (int btnNum = 0; btnNum < 4; btnNum++)
|
||||
{
|
||||
Property cmb = get( "Client", "craftAmtButton" + (btnNum + 1), craftByStacks[btnNum] );
|
||||
Property pmb = get( "Client", "priorityAmtButton" + (btnNum + 1), priorityByStacks[btnNum] );
|
||||
Property lmb = get( "Client", "levelAmtButton" + (btnNum + 1), levelByStacks[btnNum] );
|
||||
|
||||
int buttonCap = (int) (Math.pow( 10, btnNum + 1 ) - 1);
|
||||
|
||||
craftByStacks[btnNum] = Math.abs( cmb.getInt( craftByStacks[btnNum] ) );
|
||||
priorityByStacks[btnNum] = Math.abs( pmb.getInt( priorityByStacks[btnNum] ) );
|
||||
levelByStacks[btnNum] = Math.abs( pmb.getInt( 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;
|
||||
|
||||
craftByStacks[btnNum] = Math.min( craftByStacks[btnNum], buttonCap );
|
||||
priorityByStacks[btnNum] = Math.min( priorityByStacks[btnNum], buttonCap );
|
||||
levelByStacks[btnNum] = Math.min( levelByStacks[btnNum], buttonCap );
|
||||
}
|
||||
|
||||
for (Enum e : settings.getSettings())
|
||||
{
|
||||
String Category = "Client"; // e.getClass().getSimpleName();
|
||||
Enum value = settings.getSetting( e );
|
||||
|
||||
Property p = this.get( Category, e.name(), value.name(), 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" );
|
||||
}
|
||||
|
||||
settings.putSetting( e, value );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean disableColoredCableRecipesInNEI()
|
||||
{
|
||||
return disableColoredCableRecipesInNEI;
|
||||
}
|
||||
|
||||
public String getFilePath()
|
||||
{
|
||||
return myPath.toString();
|
||||
}
|
||||
|
||||
public AEConfig(String path) {
|
||||
super( new File( path + "AppliedEnergistics2.cfg" ) );
|
||||
myPath = new File( path + "AppliedEnergistics2.cfg" );
|
||||
|
||||
FMLCommonHandler.instance().bus().register( this );
|
||||
|
||||
final double DEFAULT_BC_EXCHANGE = 5.0;
|
||||
final double DEFAULT_IC2_EXCHANGE = 2.0;
|
||||
final double DEFAULT_RTC_EXCHANGE = 1.0 / 11256.0;
|
||||
final double DEFAULT_RF_EXCHANGE = 0.5;
|
||||
final double DEFAULT_MEKANISM_EXCHANGE = 0.2;
|
||||
|
||||
PowerUnits.MJ.conversionRatio = get( "PowerRatios", "BuildCraft", DEFAULT_BC_EXCHANGE ).getDouble( DEFAULT_BC_EXCHANGE );
|
||||
PowerUnits.MK.conversionRatio = get( "PowerRatios", "Mekanism", DEFAULT_MEKANISM_EXCHANGE ).getDouble( DEFAULT_MEKANISM_EXCHANGE );
|
||||
PowerUnits.EU.conversionRatio = get( "PowerRatios", "IC2", DEFAULT_IC2_EXCHANGE ).getDouble( DEFAULT_IC2_EXCHANGE );
|
||||
PowerUnits.WA.conversionRatio = get( "PowerRatios", "RotaryCraft", DEFAULT_RTC_EXCHANGE ).getDouble( DEFAULT_RTC_EXCHANGE );
|
||||
PowerUnits.RF.conversionRatio = get( "PowerRatios", "ThermalExpansion", DEFAULT_RF_EXCHANGE ).getDouble( DEFAULT_RF_EXCHANGE );
|
||||
|
||||
double usageEffective = get( "PowerRatios", "UsageMultiplier", 1.0 ).getDouble( 1.0 );
|
||||
PowerMultiplier.CONFIG.multiplier = Math.max( 0.01, usageEffective );
|
||||
|
||||
CondenserOutput.MATTER_BALLS.requiredPower = get( "Condenser", "MatterBalls", 256 ).getInt( 256 );
|
||||
CondenserOutput.SINGULARITY.requiredPower = get( "Condenser", "Singularity", 256000 ).getInt( 256000 );
|
||||
|
||||
grinderOres = get( "GrindStone", "grinderOres", grinderOres ).getStringList();
|
||||
oreDoublePercentage = get( "GrindStone", "oreDoublePercentage", oreDoublePercentage ).getDouble( oreDoublePercentage );
|
||||
|
||||
settings.registerSetting( Settings.SEARCH_TOOLTIPS, YesNo.YES );
|
||||
settings.registerSetting( Settings.TERMINAL_STYLE, TerminalStyle.TALL );
|
||||
settings.registerSetting( Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH );
|
||||
|
||||
spawnChargedChance = (float) (1.0 - get( "worldGen", "spawnChargedChance", 1.0 - spawnChargedChance ).getDouble( 1.0 - spawnChargedChance ));
|
||||
minMeteoriteDistance = get( "worldGen", "minMeteoriteDistance", minMeteoriteDistance ).getInt( minMeteoriteDistance );
|
||||
meteoriteClusterChance = get( "worldGen", "meteoriteClusterChance", meteoriteClusterChance ).getDouble( meteoriteClusterChance );
|
||||
meteoriteSpawnChance = get( "worldGen", "meteoriteSpawnChance", meteoriteSpawnChance ).getDouble( meteoriteSpawnChance );
|
||||
quartzOresPerCluster = get( "worldGen", "quartzOresPerCluster", quartzOresPerCluster ).getInt( quartzOresPerCluster );
|
||||
quartzOresClusterAmount = get( "worldGen", "quartzOresClusterAmount", quartzOresClusterAmount ).getInt( quartzOresClusterAmount );
|
||||
|
||||
minMeteoriteDistanceSq = minMeteoriteDistance * minMeteoriteDistance;
|
||||
|
||||
addCustomCategoryComment(
|
||||
"wireless",
|
||||
"Range= WirelessBaseRange + WirelessBoosterRangeMultiplier * Math.pow( boosters, WirelessBoosterExp )\nPowerDrain= WirelessBaseCost + WirelessCostMultiplier * Math.pow( boosters, 1 + boosters / WirelessHighWirelessCount )" );
|
||||
|
||||
WirelessBaseCost = get( "wireless", "WirelessBaseCost", WirelessBaseCost ).getDouble( WirelessBaseCost );
|
||||
WirelessCostMultiplier = get( "wireless", "WirelessCostMultiplier", WirelessCostMultiplier ).getDouble( WirelessCostMultiplier );
|
||||
WirelessBaseRange = get( "wireless", "WirelessBaseRange", WirelessBaseRange ).getDouble( WirelessBaseRange );
|
||||
WirelessBoosterRangeMultiplier = get( "wireless", "WirelessBoosterRangeMultiplier", WirelessBoosterRangeMultiplier ).getDouble(
|
||||
WirelessBoosterRangeMultiplier );
|
||||
WirelessBoosterExp = get( "wireless", "WirelessBoosterExp", WirelessBoosterExp ).getDouble( WirelessBoosterExp );
|
||||
WirelessTerminalDrainMultiplier = get( "wireless", "WirelessTerminalDrainMultiplier", WirelessTerminalDrainMultiplier ).getDouble(
|
||||
WirelessTerminalDrainMultiplier );
|
||||
|
||||
formationPlaneEntityLimit = get( "automation", "formationPlaneEntityLimit", formationPlaneEntityLimit ).getInt( formationPlaneEntityLimit );
|
||||
|
||||
wireless_battery = get( "battery", "wireless", wireless_battery ).getInt( wireless_battery );
|
||||
staff_battery = get( "battery", "staff", staff_battery ).getInt( staff_battery );
|
||||
manipulator_battery = get( "battery", "manipulator", manipulator_battery ).getInt( manipulator_battery );
|
||||
portablecell_battery = get( "battery", "portablecell", portablecell_battery ).getInt( portablecell_battery );
|
||||
colorapplicator_battery = get( "battery", "colorapplicator", colorapplicator_battery ).getInt( colorapplicator_battery );
|
||||
mattercannon_battery = get( "battery", "mattercannon", mattercannon_battery ).getInt( mattercannon_battery );
|
||||
|
||||
clientSync();
|
||||
|
||||
for (AEFeature feature : AEFeature.values())
|
||||
{
|
||||
if ( feature.isVisible() )
|
||||
{
|
||||
if ( get( "Features." + feature.getCategory(), feature.name(), feature.defaultValue() ).getBoolean( feature.defaultValue() ) )
|
||||
featureFlags.add( feature );
|
||||
}
|
||||
else
|
||||
featureFlags.add( feature );
|
||||
}
|
||||
|
||||
ModContainer imb = cpw.mods.fml.common.Loader.instance().getIndexedModList().get( "ImmibisCore" );
|
||||
if ( imb != null )
|
||||
{
|
||||
List<String> version = Arrays.asList( new String[] { "59.0.0", "59.0.1", "59.0.2" } );
|
||||
if ( version.contains( imb.getVersion() ) )
|
||||
featureFlags.remove( AEFeature.AlphaPass );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
selectedPowerUnit = PowerUnits.valueOf( get( "Client", "PowerUnit", selectedPowerUnit.name(), getListComment( selectedPowerUnit ) ).getString() );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
selectedPowerUnit = PowerUnits.AE;
|
||||
}
|
||||
|
||||
for (TickRates tr : TickRates.values())
|
||||
{
|
||||
tr.Load( this );
|
||||
}
|
||||
|
||||
if ( isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
{
|
||||
storageBiomeID = get( "spatialio", "storageBiomeID", storageBiomeID ).getInt( storageBiomeID );
|
||||
storageProviderID = get( "spatialio", "storageProviderID", storageProviderID ).getInt( storageProviderID );
|
||||
spatialPowerMultiplier = get( "spatialio", "spatialPowerMultiplier", spatialPowerMultiplier ).getDouble( spatialPowerMultiplier );
|
||||
spatialPowerScaler = get( "spatialio", "spatialPowerScaler", spatialPowerScaler ).getDouble( spatialPowerScaler );
|
||||
}
|
||||
|
||||
if ( isFeatureEnabled( AEFeature.CraftingCPU ) )
|
||||
{
|
||||
craftingCalculationTimePerTick = get( "craftingcpu", "craftingCalculationTimePerTick", craftingCalculationTimePerTick ).getInt(
|
||||
craftingCalculationTimePerTick );
|
||||
}
|
||||
|
||||
if ( isFeatureEnabled( AEFeature.VersionChecker ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
latestVersion = get( "VersionChecker", "LatestVersion", "" ).getString();
|
||||
latestTimeStamp = Long.parseLong( get( "VersionChecker", "LatestTimeStamp", "" ).getString() );
|
||||
}
|
||||
catch (NumberFormatException err)
|
||||
{
|
||||
latestTimeStamp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
updatable = true;
|
||||
}
|
||||
|
||||
public boolean useAEVersion(MaterialType mt)
|
||||
{
|
||||
if ( isFeatureEnabled( AEFeature.WebsiteRecipes ) )
|
||||
return true;
|
||||
|
||||
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 = get( "OreCamouflage", mt.name(), true );
|
||||
p.comment = "OreDictionary Names: " + mt.getOreName();
|
||||
|
||||
return !p.getBoolean( true );
|
||||
}
|
||||
|
||||
private String getListComment(Enum value)
|
||||
{
|
||||
String comment = null;
|
||||
|
||||
if ( value != null )
|
||||
{
|
||||
EnumSet set = EnumSet.allOf( value.getClass() );
|
||||
|
||||
for (Object Oeg : set)
|
||||
{
|
||||
Enum eg = (Enum) Oeg;
|
||||
if ( comment == null )
|
||||
comment = "Possible Values: " + eg.name();
|
||||
else
|
||||
comment += ", " + eg.name();
|
||||
}
|
||||
}
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum setting, Enum newValue)
|
||||
{
|
||||
for (Enum e : settings.getSettings())
|
||||
{
|
||||
if ( e == setting )
|
||||
{
|
||||
String Category = "Client";
|
||||
Property p = this.get( Category, e.name(), settings.getSetting( e ).name(), getListComment( newValue ) );
|
||||
p.set( newValue.name() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( updatable )
|
||||
save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if ( isFeatureEnabled( AEFeature.VersionChecker ) )
|
||||
{
|
||||
get( "VersionChecker", "LatestVersion", latestVersion ).set( latestVersion );
|
||||
get( "VersionChecker", "LatestTimeStamp", "" ).set( Long.toString( latestTimeStamp ) );
|
||||
}
|
||||
|
||||
if ( isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
{
|
||||
get( "spatialio", "storageBiomeID", storageBiomeID ).set( storageBiomeID );
|
||||
get( "spatialio", "storageProviderID", storageProviderID ).set( storageProviderID );
|
||||
}
|
||||
|
||||
get( "Client", "PowerUnit", selectedPowerUnit.name(), getListComment( selectedPowerUnit ) ).set( selectedPowerUnit.name() );
|
||||
|
||||
if ( hasChanged() )
|
||||
super.save();
|
||||
}
|
||||
|
||||
public int getFreeIDSLot(int varID, String Category)
|
||||
{
|
||||
boolean alreadyUsed = false;
|
||||
int min = 0;
|
||||
|
||||
for (Property p : getCategory( Category ).getValues().values())
|
||||
{
|
||||
int thisInt = p.getInt();
|
||||
|
||||
if ( varID == thisInt )
|
||||
alreadyUsed = true;
|
||||
|
||||
min = Math.max( min, thisInt + 1 );
|
||||
}
|
||||
|
||||
if ( alreadyUsed )
|
||||
{
|
||||
if ( min < 16383 )
|
||||
min = 16383;
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
return varID;
|
||||
}
|
||||
|
||||
public int getFreeMaterial(int varID)
|
||||
{
|
||||
return getFreeIDSLot( varID, "materials" );
|
||||
}
|
||||
|
||||
public int getFreePart(int varID)
|
||||
{
|
||||
return getFreeIDSLot( varID, "parts" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
|
||||
public boolean isFeatureEnabled(AEFeature f)
|
||||
{
|
||||
return featureFlags.contains( f );
|
||||
}
|
||||
|
||||
public boolean useTerminalUseLargeFont()
|
||||
{
|
||||
return useLargeFonts;
|
||||
}
|
||||
|
||||
public int craftItemsByStackAmounts(int i)
|
||||
{
|
||||
return craftByStacks[i];
|
||||
}
|
||||
|
||||
public int priorityByStacksAmounts(int i)
|
||||
{
|
||||
return priorityByStacks[i];
|
||||
}
|
||||
|
||||
public int levelByStackAmounts(int i)
|
||||
{
|
||||
return levelByStacks[i];
|
||||
}
|
||||
|
||||
public Enum getSetting(String Category, Class<? extends Enum> class1, Enum myDefault)
|
||||
{
|
||||
String name = class1.getSimpleName();
|
||||
Property p = get( Category, name, myDefault.name() );
|
||||
|
||||
try
|
||||
{
|
||||
return (Enum) class1.getField( p.toString() ).get( class1 );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// :{
|
||||
}
|
||||
|
||||
return myDefault;
|
||||
}
|
||||
|
||||
public void setSetting(String Category, Enum s)
|
||||
{
|
||||
String name = s.getClass().getSimpleName();
|
||||
get( Category, name, s.name() ).set( s.name() );
|
||||
save();
|
||||
}
|
||||
|
||||
public PowerUnits selectedPowerUnit()
|
||||
{
|
||||
return selectedPowerUnit;
|
||||
}
|
||||
|
||||
public void nextPowerUnit(boolean backwards)
|
||||
{
|
||||
selectedPowerUnit = Platform.rotateEnum( selectedPowerUnit, backwards, Settings.POWER_UNITS.getPossibleValues() );
|
||||
save();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package appeng.core;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
|
||||
public class AELog
|
||||
{
|
||||
|
||||
public static cpw.mods.fml.relauncher.FMLRelaunchLog instance = cpw.mods.fml.relauncher.FMLRelaunchLog.log;
|
||||
|
||||
private AELog() {
|
||||
}
|
||||
|
||||
private static void log(Level level, String format, Object... data)
|
||||
{
|
||||
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)
|
||||
{
|
||||
log( Level.WARN, format, data );
|
||||
}
|
||||
|
||||
public static void info(String format, Object... data)
|
||||
{
|
||||
log( Level.INFO, format, data );
|
||||
}
|
||||
|
||||
public static void grinder(String o)
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.GrinderLogging ) )
|
||||
{
|
||||
log( Level.DEBUG, "grinder: " + o );
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.IntegrationLogging ) )
|
||||
{
|
||||
error( exception );
|
||||
}
|
||||
}
|
||||
|
||||
public static void blockUpdate(int xCoord, int yCoord, int zCoord, AEBaseTile aeBaseTile)
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.UpdateLogging ) )
|
||||
{
|
||||
info( aeBaseTile.getClass().getName() + " @ " + xCoord + ", " + yCoord + ", " + zCoord );
|
||||
}
|
||||
}
|
||||
|
||||
public static void crafting(String format, Object... data)
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CraftingLog ) )
|
||||
{
|
||||
log( Level.INFO, format, data );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package appeng.core;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.IAppEngApi;
|
||||
import appeng.api.definitions.Blocks;
|
||||
import appeng.api.definitions.Items;
|
||||
import appeng.api.definitions.Materials;
|
||||
import appeng.api.definitions.Parts;
|
||||
import appeng.api.exceptions.FailedConnection;
|
||||
import appeng.api.features.IRegistryContainer;
|
||||
import appeng.api.networking.IGridBlock;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.api.storage.IStorageHelper;
|
||||
import appeng.core.api.ApiPart;
|
||||
import appeng.core.api.ApiStorage;
|
||||
import appeng.core.features.registries.RegistryContainer;
|
||||
import appeng.me.GridConnection;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class Api implements IAppEngApi
|
||||
{
|
||||
|
||||
public static final Api instance = new Api();
|
||||
|
||||
private Api() {
|
||||
|
||||
}
|
||||
|
||||
// private MovableTileRegistry MovableRegistry = new MovableTileRegistry();
|
||||
private RegistryContainer rc = new RegistryContainer();
|
||||
private ApiStorage storageHelper = new ApiStorage();
|
||||
|
||||
public ApiPart partHelper = new ApiPart();
|
||||
|
||||
private Materials materials = new Materials();
|
||||
private Items items = new Items();
|
||||
private Blocks blocks = new Blocks();
|
||||
private Parts parts = new Parts();
|
||||
|
||||
@Override
|
||||
public IRegistryContainer registries()
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Items items()
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Materials materials()
|
||||
{
|
||||
return materials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blocks blocks()
|
||||
{
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parts parts()
|
||||
{
|
||||
return parts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageHelper storage()
|
||||
{
|
||||
return storageHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartHelper partHelper()
|
||||
{
|
||||
return partHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode createGridNode(IGridBlock blk)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
throw new RuntimeException( "Grid Features are Server Side Only." );
|
||||
return new GridNode( blk );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridConnection createGridConnection(IGridNode a, IGridNode b) throws FailedConnection
|
||||
{
|
||||
return new GridConnection( a, b, ForgeDirection.UNKNOWN );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
package appeng.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.core.api.IIMCHandler;
|
||||
import appeng.core.api.imc.IMCBlackListSpatial;
|
||||
import appeng.core.api.imc.IMCGrinder;
|
||||
import appeng.core.api.imc.IMCMatterCannon;
|
||||
import appeng.core.api.imc.IMCP2PAttunement;
|
||||
import appeng.core.api.imc.IMCSpatial;
|
||||
import appeng.core.crash.CrashEnhancement;
|
||||
import appeng.core.crash.CrashInfo;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.server.AECommand;
|
||||
import appeng.services.VersionChecker;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
@Mod(modid = AppEng.modid, acceptedMinecraftVersions = "[1.7.10]", name = AppEng.name, version = AEConfig.VERSION, dependencies = AppEng.dependencies, guiFactory = "appeng.client.gui.config.AEConfigGuiFactory")
|
||||
public class AppEng
|
||||
{
|
||||
|
||||
private String configPath;
|
||||
|
||||
public String getConfigPath()
|
||||
{
|
||||
return configPath;
|
||||
}
|
||||
|
||||
public final static String modid = "appliedenergistics2";
|
||||
public final static String name = "Applied Energistics 2";
|
||||
|
||||
HashMap<String, IIMCHandler> IMCHandlers = new HashMap();
|
||||
|
||||
public static AppEng instance;
|
||||
|
||||
public final static String dependencies =
|
||||
|
||||
// a few mods, AE should load after, probably.
|
||||
// required-after:AppliedEnergistics2API|all;
|
||||
// "after:gregtech_addon;after:Mekanism;after:IC2;after:ThermalExpansion;after:BuildCraft|Core;" +
|
||||
|
||||
// depend on version of forge used for build.
|
||||
"after:appliedenergistics2-core;" + "required-after:Forge@[" // require forge.
|
||||
+ net.minecraftforge.common.ForgeVersion.majorVersion + "." // majorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.minorVersion + "." // minorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.revisionVersion + "." // revisionVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.buildVersion + ",)"; // buildVersion
|
||||
|
||||
public AppEng() {
|
||||
instance = this;
|
||||
|
||||
IMCHandlers.put( "blacklist-block-spatial", new IMCBlackListSpatial() );
|
||||
IMCHandlers.put( "whitelist-spatial", new IMCSpatial() );
|
||||
IMCHandlers.put( "add-grindable", new IMCGrinder() );
|
||||
IMCHandlers.put( "add-mattercannon-ammo", new IMCMatterCannon() );
|
||||
|
||||
for (TunnelType type : TunnelType.values())
|
||||
{
|
||||
IMCHandlers.put( "add-p2p-attunement-" + type.name().replace( '_', '-' ).toLowerCase(), new IMCP2PAttunement() );
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( CrashInfo.MOD_VERSION ) );
|
||||
}
|
||||
|
||||
public boolean isIntegrationEnabled(IntegrationType Name)
|
||||
{
|
||||
return IntegrationRegistry.instance.isEnabled( Name );
|
||||
}
|
||||
|
||||
public Object getIntegration(IntegrationType Name)
|
||||
{
|
||||
return IntegrationRegistry.instance.getInstance( Name );
|
||||
}
|
||||
|
||||
private void startService(String serviceName, Thread thread)
|
||||
{
|
||||
thread.setName( serviceName );
|
||||
thread.setPriority( Thread.MIN_PRIORITY );
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void PreInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
if ( !Loader.isModLoaded( "appliedenergistics2-core" ) )
|
||||
{
|
||||
CommonHelper.proxy.missingCoreMod();
|
||||
}
|
||||
|
||||
Stopwatch star = Stopwatch.createStarted();
|
||||
configPath = event.getModConfigurationDirectory().getPath() + File.separator + "AppliedEnergistics2" + File.separator;
|
||||
|
||||
AEConfig.instance = new AEConfig( configPath );
|
||||
FacadeConfig.instance = new FacadeConfig( configPath );
|
||||
|
||||
AELog.info( "Starting ( PreInit )" );
|
||||
|
||||
CreativeTab.init();
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) )
|
||||
CreativeTabFacade.init();
|
||||
|
||||
if ( Platform.isClient() )
|
||||
CommonHelper.proxy.init();
|
||||
|
||||
Registration.instance.PreInit( event );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.VersionChecker ) )
|
||||
{
|
||||
AELog.info( "Starting VersionChecker" );
|
||||
startService( "AE2 VersionChecker", new Thread( VersionChecker.instance = new VersionChecker() ) );
|
||||
}
|
||||
|
||||
AELog.info( "PreInit ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void Init(FMLInitializationEvent event)
|
||||
{
|
||||
Stopwatch star = Stopwatch.createStarted();
|
||||
AELog.info( "Init" );
|
||||
|
||||
Registration.instance.Init( event );
|
||||
IntegrationRegistry.instance.init();
|
||||
|
||||
AELog.info( "Init ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void PostInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
Stopwatch star = Stopwatch.createStarted();
|
||||
AELog.info( "PostInit" );
|
||||
|
||||
Registration.instance.PostInit( event );
|
||||
IntegrationRegistry.instance.postinit();
|
||||
FMLCommonHandler.instance().registerCrashCallable( new CrashEnhancement( CrashInfo.INTEGRATION ) );
|
||||
|
||||
CommonHelper.proxy.postinit();
|
||||
AEConfig.instance.save();
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler( this, GuiBridge.GUI_Handler );
|
||||
NetworkHandler.instance = new NetworkHandler( "AE2" );
|
||||
|
||||
AELog.info( "PostInit ( end " + star.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void processIMC(FMLInterModComms.IMCEvent event)
|
||||
{
|
||||
for (IMCMessage m : event.getMessages())
|
||||
{
|
||||
try
|
||||
{
|
||||
IIMCHandler handler = IMCHandlers.get( m.key );
|
||||
if ( handler != null )
|
||||
handler.post( m );
|
||||
else
|
||||
throw new RuntimeException( "Invalid IMC Called: " + m.key );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.warning( "Problem detected when processing IMC " + m.key + " from " + m.getSender() );
|
||||
AELog.error( t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStopping(FMLServerStoppingEvent event)
|
||||
{
|
||||
WorldSettings.getInstance().shutdown();
|
||||
TickHandler.instance.shutdown();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerAboutToStartEvent evt)
|
||||
{
|
||||
WorldSettings.getInstance().init();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent evt)
|
||||
{
|
||||
evt.registerServerCommand( new AECommand( evt.getServer() ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
diff a/core/AppEng.java b/core/AppEng.java (rejected hunks)
|
||||
@@ -34,7 +34,6 @@
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
-import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package appeng.core;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
|
||||
public abstract class CommonHelper
|
||||
{
|
||||
|
||||
@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 List<EntityPlayer> getPlayers();
|
||||
|
||||
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 boolean shouldAddParticles(Random r);
|
||||
|
||||
public abstract MovingObjectPosition getMOP();
|
||||
|
||||
public abstract void doRenderItem(ItemStack itemstack, World w);
|
||||
|
||||
public abstract void postinit();
|
||||
|
||||
public abstract CableRenderMode getRenderMode();
|
||||
|
||||
public abstract void triggerUpdates();
|
||||
|
||||
public abstract void updateRenderMode(EntityPlayer player);
|
||||
|
||||
public abstract void missingCoreMod();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package appeng.core;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
public final class CreativeTab extends CreativeTabs
|
||||
{
|
||||
|
||||
public static CreativeTab instance = null;
|
||||
|
||||
public CreativeTab() {
|
||||
super( "appliedenergistics2" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getTabIconItem()
|
||||
{
|
||||
return getIconItemStack().getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
return findFirst( AEApi.instance().blocks().blockController, AEApi.instance().blocks().blockChest, AEApi.instance().blocks().blockCellWorkbench, AEApi
|
||||
.instance().blocks().blockFluix, AEApi.instance().items().itemCell1k, AEApi.instance().items().itemNetworkTool,
|
||||
AEApi.instance().materials().materialFluixCrystal, AEApi.instance().materials().materialCertusQuartzCrystal );
|
||||
}
|
||||
|
||||
private ItemStack findFirst(AEItemDefinition... choices)
|
||||
{
|
||||
for (AEItemDefinition a : choices)
|
||||
{
|
||||
ItemStack is = a.stack( 1 );
|
||||
if ( is != null )
|
||||
return is;
|
||||
}
|
||||
|
||||
return new ItemStack( Blocks.chest );
|
||||
}
|
||||
|
||||
public static void init()
|
||||
{
|
||||
instance = new CreativeTab();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package appeng.core;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
|
||||
public final class CreativeTabFacade extends CreativeTabs
|
||||
{
|
||||
|
||||
public static CreativeTabFacade instance = null;
|
||||
|
||||
public CreativeTabFacade() {
|
||||
super( "appliedenergistics2.facades" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getTabIconItem()
|
||||
{
|
||||
return getIconItemStack().getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack()
|
||||
{
|
||||
return ((ItemFacade) AEApi.instance().items().itemFacade.item()).getCreativeTabIcon();
|
||||
}
|
||||
|
||||
public static void init()
|
||||
{
|
||||
instance = new CreativeTabFacade();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package appeng.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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;
|
||||
Pattern replacementPattern;
|
||||
|
||||
public FacadeConfig(String path) {
|
||||
super( new File( path + "Facades.cfg" ) );
|
||||
replacementPattern = Pattern.compile( "[^a-zA-Z0-9]" );
|
||||
}
|
||||
|
||||
public boolean checkEnabled(Block id, int metadata, boolean automatic)
|
||||
{
|
||||
if ( id == null )
|
||||
return false;
|
||||
|
||||
UniqueIdentifier blk = GameRegistry.findUniqueIdentifierFor( id );
|
||||
if ( blk == null )
|
||||
{
|
||||
for (Field f : Block.class.getFields())
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( f.get( Block.class ) == id )
|
||||
return get( "minecraft", f.getName() + (metadata == 0 ? "" : "." + metadata), automatic ).getBoolean( automatic );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Matcher mod = replacementPattern.matcher( blk.modId );
|
||||
Matcher name = replacementPattern.matcher( blk.name );
|
||||
return get( mod.replaceAll( "" ), name.replaceAll( "" ) + (metadata == 0 ? "" : "." + metadata), automatic ).getBoolean( automatic );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,779 @@
|
||||
package appeng.core;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.ChestGenHooks;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.RecipeSorter.Category;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.Blocks;
|
||||
import appeng.api.definitions.Items;
|
||||
import appeng.api.definitions.Materials;
|
||||
import appeng.api.definitions.Parts;
|
||||
import appeng.api.features.IRecipeHandlerRegistry;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWorldGen.WorldGenType;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.pathing.IPathingGrid;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.spatial.ISpatialCache;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.block.crafting.BlockCraftingMonitor;
|
||||
import appeng.block.crafting.BlockCraftingStorage;
|
||||
import appeng.block.crafting.BlockCraftingUnit;
|
||||
import appeng.block.crafting.BlockMolecularAssembler;
|
||||
import appeng.block.grindstone.BlockCrank;
|
||||
import appeng.block.grindstone.BlockGrinder;
|
||||
import appeng.block.misc.BlockCellWorkbench;
|
||||
import appeng.block.misc.BlockCharger;
|
||||
import appeng.block.misc.BlockCondenser;
|
||||
import appeng.block.misc.BlockInscriber;
|
||||
import appeng.block.misc.BlockInterface;
|
||||
import appeng.block.misc.BlockLightDetector;
|
||||
import appeng.block.misc.BlockPaint;
|
||||
import appeng.block.misc.BlockQuartzGrowthAccelerator;
|
||||
import appeng.block.misc.BlockQuartzTorch;
|
||||
import appeng.block.misc.BlockSecurity;
|
||||
import appeng.block.misc.BlockSkyCompass;
|
||||
import appeng.block.misc.BlockTinyTNT;
|
||||
import appeng.block.misc.BlockVibrationChamber;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.block.networking.BlockController;
|
||||
import appeng.block.networking.BlockCreativeEnergyCell;
|
||||
import appeng.block.networking.BlockDenseEnergyCell;
|
||||
import appeng.block.networking.BlockEnergyAcceptor;
|
||||
import appeng.block.networking.BlockEnergyCell;
|
||||
import appeng.block.networking.BlockWireless;
|
||||
import appeng.block.qnb.BlockQuantumLinkChamber;
|
||||
import appeng.block.qnb.BlockQuantumRing;
|
||||
import appeng.block.solids.BlockFluix;
|
||||
import appeng.block.solids.BlockQuartz;
|
||||
import appeng.block.solids.BlockQuartzChiseled;
|
||||
import appeng.block.solids.BlockQuartzGlass;
|
||||
import appeng.block.solids.BlockQuartzLamp;
|
||||
import appeng.block.solids.BlockQuartzPillar;
|
||||
import appeng.block.solids.BlockSkyStone;
|
||||
import appeng.block.solids.OreQuartz;
|
||||
import appeng.block.solids.OreQuartzCharged;
|
||||
import appeng.block.spatial.BlockMatrixFrame;
|
||||
import appeng.block.spatial.BlockSpatialIOPort;
|
||||
import appeng.block.spatial.BlockSpatialPylon;
|
||||
import appeng.block.storage.BlockChest;
|
||||
import appeng.block.storage.BlockDrive;
|
||||
import appeng.block.storage.BlockIOPort;
|
||||
import appeng.block.storage.BlockSkyChest;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.ColoredItemDefinition;
|
||||
import appeng.core.features.DamagedItemDefinition;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IStackSrc;
|
||||
import appeng.core.features.ItemStackSrc;
|
||||
import appeng.core.features.NullItemDefinition;
|
||||
import appeng.core.features.WrappedDamageItemDefinition;
|
||||
import appeng.core.features.registries.P2PTunnelRegistry;
|
||||
import appeng.core.features.registries.entries.BasicCellHandler;
|
||||
import appeng.core.features.registries.entries.CreativeCellHandler;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.stats.PlayerStatsRegistration;
|
||||
import appeng.debug.BlockChunkloader;
|
||||
import appeng.debug.BlockCubeGenerator;
|
||||
import appeng.debug.BlockItemGen;
|
||||
import appeng.debug.BlockPhantomNode;
|
||||
import appeng.debug.ToolDebugCard;
|
||||
import appeng.debug.ToolEraser;
|
||||
import appeng.debug.ToolMeteoritePlacer;
|
||||
import appeng.debug.ToolReplicatorCard;
|
||||
import appeng.hooks.AETrading;
|
||||
import appeng.hooks.MeteoriteWorldGen;
|
||||
import appeng.hooks.QuartzWorldGen;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.items.materials.ItemMultiMaterial;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import appeng.items.misc.ItemCrystalSeed;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.items.parts.ItemMultiPart;
|
||||
import appeng.items.parts.PartType;
|
||||
import appeng.items.storage.ItemBasicStorageCell;
|
||||
import appeng.items.storage.ItemCreativeStorageCell;
|
||||
import appeng.items.storage.ItemSpatialStorageCell;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.items.tools.ToolBiometricCard;
|
||||
import appeng.items.tools.ToolMemoryCard;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.items.tools.powered.ToolChargedStaff;
|
||||
import appeng.items.tools.powered.ToolColorApplicator;
|
||||
import appeng.items.tools.powered.ToolEntropyManipulator;
|
||||
import appeng.items.tools.powered.ToolMassCannon;
|
||||
import appeng.items.tools.powered.ToolPortableCell;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.items.tools.quartz.ToolQuartzAxe;
|
||||
import appeng.items.tools.quartz.ToolQuartzCuttingKnife;
|
||||
import appeng.items.tools.quartz.ToolQuartzHoe;
|
||||
import appeng.items.tools.quartz.ToolQuartzPickaxe;
|
||||
import appeng.items.tools.quartz.ToolQuartzSpade;
|
||||
import appeng.items.tools.quartz.ToolQuartzSword;
|
||||
import appeng.items.tools.quartz.ToolQuartzWrench;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.me.cache.EnergyGridCache;
|
||||
import appeng.me.cache.GridStorageCache;
|
||||
import appeng.me.cache.P2PCache;
|
||||
import appeng.me.cache.PathGridCache;
|
||||
import appeng.me.cache.SecurityCache;
|
||||
import appeng.me.cache.SpatialPylonCache;
|
||||
import appeng.me.cache.TickManagerCache;
|
||||
import appeng.me.storage.AEExternalHandler;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.recipes.AEItemResolver;
|
||||
import appeng.recipes.RecipeHandler;
|
||||
import appeng.recipes.game.DisassembleRecipe;
|
||||
import appeng.recipes.game.FacadeRecipe;
|
||||
import appeng.recipes.game.ShapedRecipe;
|
||||
import appeng.recipes.game.ShapelessRecipe;
|
||||
import appeng.recipes.handlers.Crusher;
|
||||
import appeng.recipes.handlers.Grind;
|
||||
import appeng.recipes.handlers.GrindFZ;
|
||||
import appeng.recipes.handlers.HCCrusher;
|
||||
import appeng.recipes.handlers.Inscribe;
|
||||
import appeng.recipes.handlers.Macerator;
|
||||
import appeng.recipes.handlers.MekCrusher;
|
||||
import appeng.recipes.handlers.MekEnrichment;
|
||||
import appeng.recipes.handlers.Press;
|
||||
import appeng.recipes.handlers.Pulverizer;
|
||||
import appeng.recipes.handlers.Shaped;
|
||||
import appeng.recipes.handlers.Shapeless;
|
||||
import appeng.recipes.handlers.Smelt;
|
||||
import appeng.recipes.loader.ConfigLoader;
|
||||
import appeng.recipes.loader.JarLoader;
|
||||
import appeng.recipes.ores.OreDictionaryHandler;
|
||||
import appeng.spatial.BiomeGenStorage;
|
||||
import appeng.spatial.StorageWorldProvider;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
|
||||
public class Registration
|
||||
{
|
||||
|
||||
final public static Registration instance = new Registration();
|
||||
|
||||
public RecipeHandler recipeHandler;
|
||||
public BiomeGenBase storageBiome;
|
||||
|
||||
private Registration()
|
||||
{
|
||||
recipeHandler = new RecipeHandler();
|
||||
}
|
||||
|
||||
final private Multimap<AEFeature, Class> featuresToEntities = ArrayListMultimap.create();
|
||||
|
||||
public void PreInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
registerSpatial( false );
|
||||
|
||||
IRecipeHandlerRegistry recipeRegistry = AEApi.instance().registries().recipes();
|
||||
recipeRegistry.addNewSubItemResolver( new AEItemResolver() );
|
||||
|
||||
recipeRegistry.addNewCraftHandler( "hccrusher", HCCrusher.class );
|
||||
recipeRegistry.addNewCraftHandler( "mekcrusher", MekCrusher.class );
|
||||
recipeRegistry.addNewCraftHandler( "mekechamber", MekEnrichment.class );
|
||||
recipeRegistry.addNewCraftHandler( "grind", Grind.class );
|
||||
recipeRegistry.addNewCraftHandler( "crusher", Crusher.class );
|
||||
recipeRegistry.addNewCraftHandler( "grindfz", GrindFZ.class );
|
||||
recipeRegistry.addNewCraftHandler( "pulverizer", Pulverizer.class );
|
||||
recipeRegistry.addNewCraftHandler( "macerator", Macerator.class );
|
||||
|
||||
recipeRegistry.addNewCraftHandler( "smelt", Smelt.class );
|
||||
recipeRegistry.addNewCraftHandler( "inscribe", Inscribe.class );
|
||||
recipeRegistry.addNewCraftHandler( "press", Press.class );
|
||||
|
||||
recipeRegistry.addNewCraftHandler( "shaped", Shaped.class );
|
||||
recipeRegistry.addNewCraftHandler( "shapeless", Shapeless.class );
|
||||
|
||||
RecipeSorter.register( "AE2-Facade", FacadeRecipe.class, Category.SHAPED, "" );
|
||||
RecipeSorter.register( "AE2-Shaped", ShapedRecipe.class, Category.SHAPED, "" );
|
||||
RecipeSorter.register( "AE2-Shapeless", ShapelessRecipe.class, Category.SHAPELESS, "" );
|
||||
|
||||
MinecraftForge.EVENT_BUS.register( OreDictionaryHandler.instance );
|
||||
|
||||
Items items = appeng.core.Api.instance.items();
|
||||
Materials materials = appeng.core.Api.instance.materials();
|
||||
Parts parts = appeng.core.Api.instance.parts();
|
||||
Blocks blocks = appeng.core.Api.instance.blocks();
|
||||
|
||||
AEItemDefinition materialItem = (AEFeatureHandler) addFeature( ItemMultiMaterial.class );
|
||||
|
||||
Class materialClass = materials.getClass();
|
||||
for (MaterialType mat : MaterialType.values())
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( mat == MaterialType.InvalidType )
|
||||
((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
||||
else
|
||||
{
|
||||
Field f = materialClass.getField( "material" + mat.name() );
|
||||
IStackSrc is = ((ItemMultiMaterial) materialItem.item()).createMaterial( mat );
|
||||
if ( is != null )
|
||||
f.set( materials, new DamagedItemDefinition( is ) );
|
||||
else
|
||||
f.set( materials, new NullItemDefinition() );
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
AELog.severe( "Error creating material: " + mat.name() );
|
||||
throw new RuntimeException( err );
|
||||
}
|
||||
}
|
||||
|
||||
AEItemDefinition partItem = (AEFeatureHandler) addFeature( ItemMultiPart.class );
|
||||
|
||||
Class partClass = parts.getClass();
|
||||
for (PartType type : PartType.values())
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( type == PartType.InvalidType )
|
||||
((ItemMultiPart) partItem.item()).createPart( type, null );
|
||||
else
|
||||
{
|
||||
Field f = partClass.getField( "part" + type.name() );
|
||||
Enum variants[] = type.getVariants();
|
||||
if ( variants == null )
|
||||
{
|
||||
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, null );
|
||||
if ( is != null )
|
||||
f.set( parts, new DamagedItemDefinition( is ) );
|
||||
else
|
||||
f.set( parts, new NullItemDefinition() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( variants[0] instanceof AEColor )
|
||||
{
|
||||
ColoredItemDefinition def = new ColoredItemDefinition();
|
||||
|
||||
for (Enum v : variants)
|
||||
{
|
||||
ItemStackSrc is = ((ItemMultiPart) partItem.item()).createPart( type, v );
|
||||
if ( is != null )
|
||||
def.add( (AEColor) v, is );
|
||||
}
|
||||
|
||||
f.set( parts, def );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
AELog.severe( "Error creating part: " + type.name() );
|
||||
throw new RuntimeException( err );
|
||||
}
|
||||
}
|
||||
|
||||
// very important block!
|
||||
blocks.blockMultiPart = addFeature( BlockCableBus.class );
|
||||
|
||||
blocks.blockCraftingUnit = addFeature( BlockCraftingUnit.class );
|
||||
blocks.blockCraftingAccelerator = new WrappedDamageItemDefinition( blocks.blockCraftingUnit, 1 );
|
||||
blocks.blockCraftingMonitor = addFeature( BlockCraftingMonitor.class );
|
||||
blocks.blockCraftingStorage1k = addFeature( BlockCraftingStorage.class );
|
||||
blocks.blockCraftingStorage4k = new WrappedDamageItemDefinition( blocks.blockCraftingStorage1k, 1 );
|
||||
blocks.blockCraftingStorage16k = new WrappedDamageItemDefinition( blocks.blockCraftingStorage1k, 2 );
|
||||
blocks.blockCraftingStorage64k = new WrappedDamageItemDefinition( blocks.blockCraftingStorage1k, 3 );
|
||||
blocks.blockMolecularAssembler = addFeature( BlockMolecularAssembler.class );
|
||||
|
||||
blocks.blockQuartzOre = addFeature( OreQuartz.class );
|
||||
blocks.blockQuartzOreCharged = addFeature( OreQuartzCharged.class );
|
||||
blocks.blockMatrixFrame = addFeature( BlockMatrixFrame.class );
|
||||
blocks.blockQuartz = addFeature( BlockQuartz.class );
|
||||
blocks.blockFluix = addFeature( BlockFluix.class );
|
||||
blocks.blockSkyStone = addFeature( BlockSkyStone.class );
|
||||
blocks.blockSkyChest = addFeature( BlockSkyChest.class );
|
||||
blocks.blockSkyCompass = addFeature( BlockSkyCompass.class );
|
||||
|
||||
blocks.blockQuartzGlass = addFeature( BlockQuartzGlass.class );
|
||||
blocks.blockQuartzVibrantGlass = addFeature( BlockQuartzLamp.class );
|
||||
blocks.blockQuartzPillar = addFeature( BlockQuartzPillar.class );
|
||||
blocks.blockQuartzChiseled = addFeature( BlockQuartzChiseled.class );
|
||||
blocks.blockQuartzTorch = addFeature( BlockQuartzTorch.class );
|
||||
blocks.blockLightDetector = addFeature( BlockLightDetector.class );
|
||||
blocks.blockCharger = addFeature( BlockCharger.class );
|
||||
blocks.blockQuartzGrowthAccelerator = addFeature( BlockQuartzGrowthAccelerator.class );
|
||||
|
||||
blocks.blockGrindStone = addFeature( BlockGrinder.class );
|
||||
blocks.blockCrankHandle = addFeature( BlockCrank.class );
|
||||
blocks.blockInscriber = addFeature( BlockInscriber.class );
|
||||
blocks.blockWireless = addFeature( BlockWireless.class );
|
||||
blocks.blockTinyTNT = addFeature( BlockTinyTNT.class );
|
||||
|
||||
blocks.blockQuantumRing = addFeature( BlockQuantumRing.class );
|
||||
blocks.blockQuantumLink = addFeature( BlockQuantumLinkChamber.class );
|
||||
|
||||
blocks.blockSpatialPylon = addFeature( BlockSpatialPylon.class );
|
||||
blocks.blockSpatialIOPort = addFeature( BlockSpatialIOPort.class );
|
||||
|
||||
blocks.blockController = addFeature( BlockController.class );
|
||||
blocks.blockDrive = addFeature( BlockDrive.class );
|
||||
blocks.blockChest = addFeature( BlockChest.class );
|
||||
blocks.blockInterface = addFeature( BlockInterface.class );
|
||||
blocks.blockCellWorkbench = addFeature( BlockCellWorkbench.class );
|
||||
blocks.blockIOPort = addFeature( BlockIOPort.class );
|
||||
blocks.blockCondenser = addFeature( BlockCondenser.class );
|
||||
blocks.blockEnergyAcceptor = addFeature( BlockEnergyAcceptor.class );
|
||||
blocks.blockVibrationChamber = addFeature( BlockVibrationChamber.class );
|
||||
|
||||
blocks.blockEnergyCell = addFeature( BlockEnergyCell.class );
|
||||
blocks.blockEnergyCellDense = addFeature( BlockDenseEnergyCell.class );
|
||||
blocks.blockEnergyCellCreative = addFeature( BlockCreativeEnergyCell.class );
|
||||
|
||||
blocks.blockSecurity = addFeature( BlockSecurity.class );
|
||||
blocks.blockPaint = addFeature( BlockPaint.class );
|
||||
|
||||
items.itemCellCreative = addFeature( ItemCreativeStorageCell.class );
|
||||
items.itemViewCell = addFeature( ItemViewCell.class );
|
||||
items.itemEncodedPattern = addFeature( ItemEncodedPattern.class );
|
||||
|
||||
items.itemCell1k = addFeature( ItemBasicStorageCell.class, MaterialType.Cell1kPart, 1 );
|
||||
items.itemCell4k = addFeature( ItemBasicStorageCell.class, MaterialType.Cell4kPart, 4 );
|
||||
items.itemCell16k = addFeature( ItemBasicStorageCell.class, MaterialType.Cell16kPart, 16 );
|
||||
items.itemCell64k = addFeature( ItemBasicStorageCell.class, MaterialType.Cell64kPart, 64 );
|
||||
|
||||
items.itemSpatialCell2 = addFeature( ItemSpatialStorageCell.class, MaterialType.Cell2SpatialPart, 2 );
|
||||
items.itemSpatialCell16 = addFeature( ItemSpatialStorageCell.class, MaterialType.Cell16SpatialPart, 16 );
|
||||
items.itemSpatialCell128 = addFeature( ItemSpatialStorageCell.class, MaterialType.Cell128SpatialPart, 128 );
|
||||
|
||||
items.itemCertusQuartzKnife = addFeature( ToolQuartzCuttingKnife.class, AEFeature.CertusQuartzTools );
|
||||
items.itemCertusQuartzWrench = addFeature( ToolQuartzWrench.class, AEFeature.CertusQuartzTools );
|
||||
items.itemCertusQuartzAxe = addFeature( ToolQuartzAxe.class, AEFeature.CertusQuartzTools );
|
||||
items.itemCertusQuartzHoe = addFeature( ToolQuartzHoe.class, AEFeature.CertusQuartzTools );
|
||||
items.itemCertusQuartzPick = addFeature( ToolQuartzPickaxe.class, AEFeature.CertusQuartzTools );
|
||||
items.itemCertusQuartzShovel = addFeature( ToolQuartzSpade.class, AEFeature.CertusQuartzTools );
|
||||
items.itemCertusQuartzSword = addFeature( ToolQuartzSword.class, AEFeature.CertusQuartzTools );
|
||||
|
||||
items.itemNetherQuartzKnife = addFeature( ToolQuartzCuttingKnife.class, AEFeature.NetherQuartzTools );
|
||||
items.itemNetherQuartzWrench = addFeature( ToolQuartzWrench.class, AEFeature.NetherQuartzTools );
|
||||
items.itemNetherQuartzAxe = addFeature( ToolQuartzAxe.class, AEFeature.NetherQuartzTools );
|
||||
items.itemNetherQuartzHoe = addFeature( ToolQuartzHoe.class, AEFeature.NetherQuartzTools );
|
||||
items.itemNetherQuartzPick = addFeature( ToolQuartzPickaxe.class, AEFeature.NetherQuartzTools );
|
||||
items.itemNetherQuartzShovel = addFeature( ToolQuartzSpade.class, AEFeature.NetherQuartzTools );
|
||||
items.itemNetherQuartzSword = addFeature( ToolQuartzSword.class, AEFeature.NetherQuartzTools );
|
||||
|
||||
items.itemMassCannon = addFeature( ToolMassCannon.class );
|
||||
items.itemMemoryCard = addFeature( ToolMemoryCard.class );
|
||||
items.itemChargedStaff = addFeature( ToolChargedStaff.class );
|
||||
items.itemEntropyManipulator = addFeature( ToolEntropyManipulator.class );
|
||||
items.itemColorApplicator = addFeature( ToolColorApplicator.class );
|
||||
|
||||
items.itemWirelessTerminal = addFeature( ToolWirelessTerminal.class );
|
||||
items.itemNetworkTool = addFeature( ToolNetworkTool.class );
|
||||
items.itemPortableCell = addFeature( ToolPortableCell.class );
|
||||
items.itemBiometricCard = addFeature( ToolBiometricCard.class );
|
||||
|
||||
items.itemFacade = addFeature( ItemFacade.class );
|
||||
items.itemCrystalSeed = addFeature( ItemCrystalSeed.class );
|
||||
|
||||
ColoredItemDefinition pbreg, pbregl;
|
||||
items.itemPaintBall = pbreg = new ColoredItemDefinition();
|
||||
items.itemLumenPaintBall = pbregl = new ColoredItemDefinition();
|
||||
AEItemDefinition pb = addFeature( ItemPaintBall.class );
|
||||
|
||||
for (AEColor c : AEColor.values())
|
||||
{
|
||||
if ( c != AEColor.Transparent )
|
||||
{
|
||||
pbreg.add( c, new ItemStackSrc( pb.item(), c.ordinal() ) );
|
||||
pbregl.add( c, new ItemStackSrc( pb.item(), 20 + c.ordinal() ) );
|
||||
}
|
||||
}
|
||||
|
||||
addFeature( ToolEraser.class );
|
||||
addFeature( ToolMeteoritePlacer.class );
|
||||
addFeature( ToolDebugCard.class );
|
||||
addFeature( ToolReplicatorCard.class );
|
||||
addFeature( BlockItemGen.class );
|
||||
addFeature( BlockChunkloader.class );
|
||||
addFeature( BlockPhantomNode.class );
|
||||
addFeature( BlockCubeGenerator.class );
|
||||
}
|
||||
|
||||
private AEItemDefinition addFeature(Class c, Object... Args)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
java.lang.reflect.Constructor[] con = c.getConstructors();
|
||||
Object obj = null;
|
||||
|
||||
for (Constructor conItem : con)
|
||||
{
|
||||
Class paramTypes[] = conItem.getParameterTypes();
|
||||
if ( paramTypes.length == Args.length )
|
||||
{
|
||||
boolean valid = true;
|
||||
|
||||
for (int idx = 0; idx < paramTypes.length; idx++)
|
||||
{
|
||||
Class cz = Args[idx].getClass();
|
||||
if ( !isClassMatch( paramTypes[idx], cz, Args[idx] ) )
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if ( valid )
|
||||
{
|
||||
obj = conItem.newInstance( Args );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( obj instanceof IAEFeature )
|
||||
{
|
||||
IAEFeature feature = (IAEFeature) obj;
|
||||
|
||||
for (AEFeature f : feature.feature().getFeatures())
|
||||
featuresToEntities.put( f, c );
|
||||
|
||||
feature.feature().register();
|
||||
|
||||
feature.postInit();
|
||||
|
||||
return feature.feature();
|
||||
}
|
||||
else if ( obj == null )
|
||||
throw new RuntimeException( "No valid constructor found." );
|
||||
else
|
||||
throw new RuntimeException( "Non AE Feature Registered" );
|
||||
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw new RuntimeException( "Error with Feature: " + c.getName(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isClassMatch(Class expected, Class got, Object value)
|
||||
{
|
||||
if ( value == null && !expected.isPrimitive() )
|
||||
return true;
|
||||
|
||||
expected = condense( expected, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class );
|
||||
got = condense( got, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class );
|
||||
|
||||
if ( expected == got || expected.isAssignableFrom( got ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Class condense(Class expected, Class... wrappers)
|
||||
{
|
||||
if ( expected.isPrimitive() )
|
||||
{
|
||||
for (Class clz : wrappers)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( expected == clz.getField( "TYPE" ).get( null ) )
|
||||
return clz;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
}
|
||||
}
|
||||
return expected;
|
||||
}
|
||||
|
||||
public void Init(FMLInitializationEvent event)
|
||||
{
|
||||
// Perform ore camouflage!
|
||||
ItemMultiMaterial.instance.unduplicate();
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CustomRecipes ) )
|
||||
recipeHandler.parseRecipes( new ConfigLoader( AppEng.instance.getConfigPath() ), "index.recipe" );
|
||||
else
|
||||
recipeHandler.parseRecipes( new JarLoader( "/assets/appliedenergistics2/recipes/" ), "index.recipe" );
|
||||
|
||||
IPartHelper ph = AEApi.instance().partHelper();
|
||||
ph.registerNewLayer( "appeng.parts.layers.LayerISidedInventory", "net.minecraft.inventory.ISidedInventory" );
|
||||
ph.registerNewLayer( "appeng.parts.layers.LayerIFluidHandler", "net.minecraftforge.fluids.IFluidHandler" );
|
||||
ph.registerNewLayer( "appeng.parts.layers.LayerITileStorageMonitorable", "appeng.api.implementations.tiles.ITileStorageMonitorable" );
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.IC2 ) )
|
||||
{
|
||||
ph.registerNewLayer( "appeng.parts.layers.LayerIEnergySink", "ic2.api.energy.tile.IEnergySink" );
|
||||
ph.registerNewLayer( "appeng.parts.layers.LayerIEnergySource", "ic2.api.energy.tile.IEnergySource" );
|
||||
}
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.MJ5 ) )
|
||||
{
|
||||
ph.registerNewLayer( "appeng.parts.layers.LayerIPowerEmitter", "buildcraft.api.power.IPowerEmitter" );
|
||||
ph.registerNewLayer( "appeng.parts.layers.LayerIPowerReceptor", "buildcraft.api.power.IPowerReceptor" );
|
||||
}
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.MJ6 ) )
|
||||
ph.registerNewLayer( "appeng.parts.layers.LayerIBatteryProvider", "buildcraft.api.mj.IBatteryProvider" );
|
||||
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) )
|
||||
ph.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyHandler" );
|
||||
|
||||
FMLCommonHandler.instance().bus().register( TickHandler.instance );
|
||||
MinecraftForge.EVENT_BUS.register( TickHandler.instance );
|
||||
|
||||
PartPlacement pp = new PartPlacement();
|
||||
MinecraftForge.EVENT_BUS.register( pp );
|
||||
FMLCommonHandler.instance().bus().register( pp );
|
||||
|
||||
IGridCacheRegistry gcr = AEApi.instance().registries().gridCache();
|
||||
gcr.registerGridCache( ITickManager.class, TickManagerCache.class );
|
||||
gcr.registerGridCache( IEnergyGrid.class, EnergyGridCache.class );
|
||||
gcr.registerGridCache( IPathingGrid.class, PathGridCache.class );
|
||||
gcr.registerGridCache( IStorageGrid.class, GridStorageCache.class );
|
||||
gcr.registerGridCache( P2PCache.class, P2PCache.class );
|
||||
gcr.registerGridCache( ISpatialCache.class, SpatialPylonCache.class );
|
||||
gcr.registerGridCache( ISecurityGrid.class, SecurityCache.class );
|
||||
gcr.registerGridCache( ICraftingGrid.class, CraftingGridCache.class );
|
||||
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface( new AEExternalHandler() );
|
||||
|
||||
AEApi.instance().registries().cell().addCellHandler( new BasicCellHandler() );
|
||||
AEApi.instance().registries().cell().addCellHandler( new CreativeCellHandler() );
|
||||
|
||||
AEApi.instance().registries().matterCannon().registerAmmo( AEApi.instance().materials().materialMatterBall.stack( 1 ), 32.0 );
|
||||
|
||||
recipeHandler.injectRecipes();
|
||||
|
||||
PlayerStatsRegistration.instance.init();
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting ) )
|
||||
CraftingManager.getInstance().getRecipeList().add( new DisassembleRecipe() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.enableFacadeCrafting ) )
|
||||
CraftingManager.getInstance().getRecipeList().add( new FacadeRecipe() );
|
||||
}
|
||||
|
||||
public void PostInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
registerSpatial( true );
|
||||
|
||||
// default settings..
|
||||
((P2PTunnelRegistry) AEApi.instance().registries().p2pTunnel()).configure();
|
||||
|
||||
// add to localizaiton..
|
||||
PlayerMessages.values();
|
||||
GuiText.values();
|
||||
|
||||
Api.instance.partHelper.initFMPSupport();
|
||||
((BlockCableBus) AEApi.instance().blocks().blockMultiPart.block()).setupTile();
|
||||
|
||||
// Interface
|
||||
Upgrades.CRAFTING.registerItem( AEApi.instance().parts().partInterface.stack( 1 ), 1 );
|
||||
Upgrades.CRAFTING.registerItem( AEApi.instance().blocks().blockInterface.stack( 1 ), 1 );
|
||||
|
||||
// IO Port!
|
||||
Upgrades.SPEED.registerItem( AEApi.instance().blocks().blockIOPort.stack( 1 ), 3 );
|
||||
Upgrades.REDSTONE.registerItem( AEApi.instance().blocks().blockIOPort.stack( 1 ), 1 );
|
||||
|
||||
// Level Emitter!
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().parts().partLevelEmitter.stack( 1 ), 1 );
|
||||
Upgrades.CRAFTING.registerItem( AEApi.instance().parts().partLevelEmitter.stack( 1 ), 1 );
|
||||
|
||||
// Import Bus
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().parts().partImportBus.stack( 1 ), 1 );
|
||||
Upgrades.REDSTONE.registerItem( AEApi.instance().parts().partImportBus.stack( 1 ), 1 );
|
||||
Upgrades.CAPACITY.registerItem( AEApi.instance().parts().partImportBus.stack( 1 ), 2 );
|
||||
Upgrades.SPEED.registerItem( AEApi.instance().parts().partImportBus.stack( 1 ), 4 );
|
||||
|
||||
// Export Bus
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().parts().partExportBus.stack( 1 ), 1 );
|
||||
Upgrades.REDSTONE.registerItem( AEApi.instance().parts().partExportBus.stack( 1 ), 1 );
|
||||
Upgrades.CAPACITY.registerItem( AEApi.instance().parts().partExportBus.stack( 1 ), 2 );
|
||||
Upgrades.SPEED.registerItem( AEApi.instance().parts().partExportBus.stack( 1 ), 4 );
|
||||
Upgrades.CRAFTING.registerItem( AEApi.instance().parts().partExportBus.stack( 1 ), 1 );
|
||||
|
||||
// Storage Cells
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().items().itemCell1k.stack( 1 ), 1 );
|
||||
Upgrades.INVERTER.registerItem( AEApi.instance().items().itemCell1k.stack( 1 ), 1 );
|
||||
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().items().itemCell4k.stack( 1 ), 1 );
|
||||
Upgrades.INVERTER.registerItem( AEApi.instance().items().itemCell4k.stack( 1 ), 1 );
|
||||
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().items().itemCell16k.stack( 1 ), 1 );
|
||||
Upgrades.INVERTER.registerItem( AEApi.instance().items().itemCell16k.stack( 1 ), 1 );
|
||||
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().items().itemCell64k.stack( 1 ), 1 );
|
||||
Upgrades.INVERTER.registerItem( AEApi.instance().items().itemCell64k.stack( 1 ), 1 );
|
||||
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().items().itemPortableCell.stack( 1 ), 1 );
|
||||
Upgrades.INVERTER.registerItem( AEApi.instance().items().itemPortableCell.stack( 1 ), 1 );
|
||||
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().items().itemViewCell.stack( 1 ), 1 );
|
||||
Upgrades.INVERTER.registerItem( AEApi.instance().items().itemViewCell.stack( 1 ), 1 );
|
||||
|
||||
// Storage Bus
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().parts().partStorageBus.stack( 1 ), 1 );
|
||||
Upgrades.INVERTER.registerItem( AEApi.instance().parts().partStorageBus.stack( 1 ), 1 );
|
||||
Upgrades.CAPACITY.registerItem( AEApi.instance().parts().partStorageBus.stack( 1 ), 5 );
|
||||
|
||||
// Formation Plane
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().parts().partFormationPlane.stack( 1 ), 1 );
|
||||
Upgrades.INVERTER.registerItem( AEApi.instance().parts().partFormationPlane.stack( 1 ), 1 );
|
||||
Upgrades.CAPACITY.registerItem( AEApi.instance().parts().partFormationPlane.stack( 1 ), 5 );
|
||||
|
||||
// Matter Cannon
|
||||
Upgrades.FUZZY.registerItem( AEApi.instance().items().itemMassCannon.stack( 1 ), 1 );
|
||||
Upgrades.INVERTER.registerItem( AEApi.instance().items().itemMassCannon.stack( 1 ), 1 );
|
||||
Upgrades.SPEED.registerItem( AEApi.instance().items().itemMassCannon.stack( 1 ), 4 );
|
||||
|
||||
// Molecular Assembler
|
||||
Upgrades.SPEED.registerItem( AEApi.instance().blocks().blockMolecularAssembler.stack( 1 ), 5 );
|
||||
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler( (IWirelessTermHandler) AEApi.instance().items().itemWirelessTerminal.item() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChestLoot ) )
|
||||
{
|
||||
ChestGenHooks d = ChestGenHooks.getInfo( ChestGenHooks.MINESHAFT_CORRIDOR );
|
||||
d.addItem( new WeightedRandomChestContent( AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 ), 1, 4, 2 ) );
|
||||
d.addItem( new WeightedRandomChestContent( AEApi.instance().materials().materialCertusQuartzDust.stack( 1 ), 1, 4, 2 ) );
|
||||
}
|
||||
|
||||
// add villager trading to black smiths for a few basic materials
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.VillagerTrading ) )
|
||||
VillagerRegistry.instance().registerVillageTradeHandler( 3, new AETrading() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.CertusQuartzWorldGen ) )
|
||||
GameRegistry.registerWorldGenerator( new QuartzWorldGen(), 0 );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) )
|
||||
GameRegistry.registerWorldGenerator( new MeteoriteWorldGen(), 0 );
|
||||
|
||||
IMovableRegistry mr = AEApi.instance().registries().movable();
|
||||
|
||||
/**
|
||||
* You can't move bed rock.
|
||||
*/
|
||||
mr.blacklistBlock( net.minecraft.init.Blocks.bedrock );
|
||||
|
||||
/*
|
||||
* White List Vanilla...
|
||||
*/
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityBeacon.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityBrewingStand.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityChest.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityCommandBlock.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityComparator.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityDaylightDetector.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityDispenser.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityDropper.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityEnchantmentTable.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityEnderChest.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityEndPortal.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySkull.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityFurnace.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityMobSpawner.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySign.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityPiston.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityFlowerPot.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityHopper.class );
|
||||
|
||||
// very silly fix cause Reika decided to pair the item with a block.
|
||||
OreDictionary.registerOre( "itemWheat", net.minecraft.init.Items.wheat );
|
||||
|
||||
/**
|
||||
* Whitelist AE2
|
||||
*/
|
||||
mr.whiteListTileEntity( AEBaseTile.class );
|
||||
|
||||
/**
|
||||
* world gen
|
||||
*/
|
||||
for (WorldGenType type : WorldGenType.values())
|
||||
{
|
||||
AEApi.instance().registries().worldgen().disableWorldGenForProviderID( type, StorageWorldProvider.class );
|
||||
|
||||
// end
|
||||
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, 1 );
|
||||
|
||||
// nether
|
||||
AEApi.instance().registries().worldgen().disableWorldGenForDimension( type, -1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* initial recipe bake, if ore dictionary changes after this it re-bakes.
|
||||
*/
|
||||
OreDictionaryHandler.instance.bakeRecipes();
|
||||
}
|
||||
|
||||
private void registerSpatial(boolean force)
|
||||
{
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) )
|
||||
return;
|
||||
|
||||
AEConfig config = AEConfig.instance;
|
||||
|
||||
if ( storageBiome == null )
|
||||
{
|
||||
if ( force && config.storageBiomeID == -1 )
|
||||
{
|
||||
config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() );
|
||||
if ( config.storageBiomeID == -1 )
|
||||
throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." );
|
||||
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
config.save();
|
||||
}
|
||||
|
||||
if ( !force && config.storageBiomeID != -1 )
|
||||
storageBiome = new BiomeGenStorage( config.storageBiomeID );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID != -1 )
|
||||
{
|
||||
DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false );
|
||||
}
|
||||
|
||||
if ( config.storageProviderID == -1 && force )
|
||||
{
|
||||
config.storageProviderID = -11;
|
||||
|
||||
while (!DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false ))
|
||||
config.storageProviderID--;
|
||||
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,470 @@
|
||||
package appeng.core;
|
||||
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketNewStorageDimension;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
import appeng.me.GridStorage;
|
||||
import appeng.me.GridStorageSearch;
|
||||
import appeng.services.CompassService;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class WorldSettings extends Configuration
|
||||
{
|
||||
|
||||
private static WorldSettings instance;
|
||||
|
||||
long lastGridStorage = 0;
|
||||
int lastPlayer = 0;
|
||||
|
||||
private CompassService compass;
|
||||
|
||||
File AEFolder;
|
||||
|
||||
public WorldSettings(File aeFolder)
|
||||
{
|
||||
super( new File( aeFolder.getPath() + File.separatorChar + "settings.cfg" ) );
|
||||
AEFolder = aeFolder;
|
||||
|
||||
compass = new CompassService( AEFolder );
|
||||
|
||||
for (int dimID : get( "DimensionManager", "StorageCells", new int[0] ).getIntList())
|
||||
{
|
||||
storageCellDims.add( dimID );
|
||||
DimensionManager.registerDimension( dimID, AEConfig.instance.storageProviderID );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lastGridStorage = Long.parseLong( get( "Counters", "lastGridStorage", 0 ).getString() );
|
||||
lastPlayer = get( "Counters", "lastPlayer", 0 ).getInt();
|
||||
}
|
||||
catch (NumberFormatException err)
|
||||
{
|
||||
lastGridStorage = 0;
|
||||
lastPlayer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagCompound loadSpawnData(int dim, int chunkX, int chunkZ)
|
||||
{
|
||||
if ( !Thread.holdsLock( WorldSettings.class ) )
|
||||
throw new RuntimeException( "Invalid Request" );
|
||||
|
||||
File f = new File( AEFolder, "spawndata" + File.separatorChar + dim + "_" + (chunkX >> 4) + "_" + (chunkZ >> 4) + ".dat" );
|
||||
|
||||
if ( f.isFile() && f.exists() )
|
||||
{
|
||||
// open
|
||||
FileInputStream fis;
|
||||
try
|
||||
{
|
||||
fis = new FileInputStream( f );
|
||||
|
||||
NBTTagCompound data = null;
|
||||
|
||||
try
|
||||
{
|
||||
data = CompressedStreamTools.readCompressed( fis );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
data = new NBTTagCompound();
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
fis.close();
|
||||
|
||||
return data;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
void writeSpawnData(int dim, int chunkX, int chunkZ, NBTTagCompound data)
|
||||
{
|
||||
if ( !Thread.holdsLock( WorldSettings.class ) )
|
||||
throw new RuntimeException( "Invalid Request" );
|
||||
|
||||
File f = new File( AEFolder, "spawndata" + File.separatorChar + dim + "_" + (chunkX >> 4) + "_" + (chunkZ >> 4) + ".dat" );
|
||||
|
||||
try
|
||||
{
|
||||
// save
|
||||
FileOutputStream fos = new FileOutputStream( f );
|
||||
|
||||
try
|
||||
{
|
||||
CompressedStreamTools.writeCompressed( data, fos );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
fos.close();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<NBTTagCompound> getNearByMeteorites(int dim, int chunkX, int chunkZ)
|
||||
{
|
||||
LinkedList<NBTTagCompound> ll = new LinkedList<NBTTagCompound>();
|
||||
|
||||
synchronized (WorldSettings.class)
|
||||
{
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int z = -1; z <= 1; z++)
|
||||
{
|
||||
int cx = x + (chunkX >> 4);
|
||||
int cz = z + (chunkZ >> 4);
|
||||
|
||||
NBTTagCompound data = loadSpawnData( dim, cx << 4, cz << 4 );
|
||||
|
||||
if ( data != null )
|
||||
{
|
||||
// edit.
|
||||
int size = data.getInteger( "num" );
|
||||
for (int s = 0; s < size; s++)
|
||||
ll.add( data.getCompoundTag( "" + s ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ll;
|
||||
}
|
||||
|
||||
public boolean hasGenerated(int dim, int chunkX, int chunkZ)
|
||||
{
|
||||
synchronized (WorldSettings.class)
|
||||
{
|
||||
NBTTagCompound data = loadSpawnData( dim, chunkX, chunkZ );
|
||||
return data.getBoolean( chunkX + "," + chunkZ );
|
||||
}
|
||||
}
|
||||
|
||||
public void setGenerated(int dim, int chunkX, int chunkZ)
|
||||
{
|
||||
synchronized (WorldSettings.class)
|
||||
{
|
||||
NBTTagCompound data = loadSpawnData( dim, chunkX, chunkZ );
|
||||
|
||||
// edit.
|
||||
data.setBoolean( chunkX + "," + chunkZ, true );
|
||||
|
||||
writeSpawnData( dim, chunkX, chunkZ, data );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addNearByMeteorites(int dim, int chunkX, int chunkZ, NBTTagCompound newData)
|
||||
{
|
||||
synchronized (WorldSettings.class)
|
||||
{
|
||||
NBTTagCompound data = loadSpawnData( dim, chunkX, chunkZ );
|
||||
|
||||
// edit.
|
||||
int size = data.getInteger( "num" );
|
||||
data.setTag( "" + size, newData );
|
||||
data.setInteger( "num", size + 1 );
|
||||
|
||||
writeSpawnData( dim, chunkX, chunkZ, data );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
save();
|
||||
|
||||
for (Integer dimID : storageCellDims)
|
||||
DimensionManager.unregisterDimension( dimID );
|
||||
|
||||
storageCellDims.clear();
|
||||
|
||||
compass.kill();
|
||||
instance = null;
|
||||
}
|
||||
|
||||
List<Integer> storageCellDims = new ArrayList();
|
||||
HashMap<Integer, UUID> idToUUID;
|
||||
|
||||
public void addStorageCellDim(int newDim)
|
||||
{
|
||||
storageCellDims.add( newDim );
|
||||
DimensionManager.registerDimension( newDim, AEConfig.instance.storageProviderID );
|
||||
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToAll( new PacketNewStorageDimension( newDim ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String[] values = new String[storageCellDims.size()];
|
||||
|
||||
for (int x = 0; x < values.length; x++)
|
||||
values[x] = "" + storageCellDims.get( x );
|
||||
|
||||
get( "DimensionManager", "StorageCells", new int[0] ).set( values );
|
||||
save();
|
||||
}
|
||||
|
||||
public CompassService getCompass()
|
||||
{
|
||||
return compass;
|
||||
}
|
||||
|
||||
public static WorldSettings getInstance()
|
||||
{
|
||||
if ( instance == null )
|
||||
{
|
||||
File world = DimensionManager.getCurrentSaveRootDirectory();
|
||||
|
||||
File aeBaseFolder = new File( world.getPath() + File.separatorChar + "AE2" );
|
||||
|
||||
if ( !aeBaseFolder.exists() || !aeBaseFolder.isDirectory() )
|
||||
if ( !aeBaseFolder.mkdir() || !aeBaseFolder.exists() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + aeBaseFolder.getAbsolutePath() );
|
||||
}
|
||||
|
||||
File compass = new File( aeBaseFolder, "compass" );
|
||||
if ( !compass.exists() || !compass.isDirectory() )
|
||||
if ( !compass.mkdir() || !compass.exists() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + compass.getAbsolutePath() );
|
||||
}
|
||||
|
||||
File spawnData = new File( aeBaseFolder, "spawndata" );
|
||||
if ( !spawnData.exists() || !spawnData.isDirectory() )
|
||||
if ( !spawnData.mkdir() || !spawnData.exists() )
|
||||
{
|
||||
throw new RuntimeException( "Failed to create " + spawnData.getAbsolutePath() );
|
||||
}
|
||||
|
||||
instance = new WorldSettings( aeBaseFolder );
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void sendToPlayer(NetworkManager manager, EntityPlayerMP player)
|
||||
{
|
||||
if ( manager != null )
|
||||
{
|
||||
for (int newDim : get( "DimensionManager", "StorageCells", new int[0] ).getIntList())
|
||||
{
|
||||
try
|
||||
{
|
||||
manager.scheduleOutboundPacket( (new PacketNewStorageDimension( newDim )).getProxy(), new GenericFutureListener[0] );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (PlayerColor pc : TickHandler.instance.getPlayerColors().values())
|
||||
NetworkHandler.instance.sendToAll( pc.getPacket() );
|
||||
}
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
private WeakHashMap<GridStorageSearch, WeakReference<GridStorageSearch>> loadedStorage = new WeakHashMap();
|
||||
|
||||
public WorldCoord getStoredSize(int dim)
|
||||
{
|
||||
int x = get( "StorageCell" + dim, "scaleX", 0 ).getInt();
|
||||
int y = get( "StorageCell" + dim, "scaleY", 0 ).getInt();
|
||||
int z = get( "StorageCell" + dim, "scaleZ", 0 ).getInt();
|
||||
return new WorldCoord( x, y, z );
|
||||
}
|
||||
|
||||
public void setStoredSize(int dim, int targetX, int targetY, int targetZ)
|
||||
{
|
||||
get( "StorageCell" + dim, "scaleX", 0 ).set( targetX );
|
||||
get( "StorageCell" + dim, "scaleY", 0 ).set( targetY );
|
||||
get( "StorageCell" + dim, "scaleZ", 0 ).set( targetZ );
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy loading, can load any id, even ones that don't exist anymore.
|
||||
*
|
||||
* @param storageID
|
||||
* @return
|
||||
*/
|
||||
public GridStorage getGridStorage(long storageID)
|
||||
{
|
||||
GridStorageSearch gss = new GridStorageSearch( storageID );
|
||||
WeakReference<GridStorageSearch> result = loadedStorage.get( gss );
|
||||
|
||||
if ( result == null || result.get() == null )
|
||||
{
|
||||
String Data = get( "gridstorage", "" + storageID, "" ).getString();
|
||||
GridStorage thisStorage = new GridStorage( Data, storageID, gss );
|
||||
gss.gridStorage = new WeakReference<GridStorage>( thisStorage );
|
||||
loadedStorage.put( gss, new WeakReference<GridStorageSearch>( gss ) );
|
||||
return thisStorage;
|
||||
}
|
||||
return result.get().gridStorage.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new storage
|
||||
*/
|
||||
public GridStorage getNewGridStorage()
|
||||
{
|
||||
long storageID = nextGridStorage();
|
||||
GridStorageSearch gss = new GridStorageSearch( storageID );
|
||||
GridStorage newStorage = new GridStorage( storageID, gss );
|
||||
gss.gridStorage = new WeakReference<GridStorage>( newStorage );
|
||||
loadedStorage.put( gss, new WeakReference<GridStorageSearch>( gss ) );
|
||||
return newStorage;
|
||||
}
|
||||
|
||||
public void destroyGridStorage(long id)
|
||||
{
|
||||
this.getCategory( "gridstorage" ).remove( "" + id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
// populate new data
|
||||
for (GridStorageSearch gs : loadedStorage.keySet())
|
||||
{
|
||||
GridStorage thisStorage = gs.gridStorage.get();
|
||||
if ( thisStorage != null && thisStorage.getGrid() != null && !thisStorage.getGrid().isEmpty() )
|
||||
{
|
||||
String value = thisStorage.getValue();
|
||||
get( "gridstorage", "" + thisStorage.getID(), value ).set( value );
|
||||
}
|
||||
}
|
||||
|
||||
// save to files
|
||||
if ( hasChanged() )
|
||||
super.save();
|
||||
}
|
||||
|
||||
private long nextGridStorage()
|
||||
{
|
||||
long r = lastGridStorage++;
|
||||
get( "Counters", "lastGridStorage", lastGridStorage ).set( Long.toString( lastGridStorage ) );
|
||||
return r;
|
||||
}
|
||||
|
||||
private long nextPlayer()
|
||||
{
|
||||
long r = lastPlayer++;
|
||||
get( "Counters", "lastPlayer", lastPlayer ).set( lastPlayer );
|
||||
return r;
|
||||
}
|
||||
|
||||
public int getNextOrderedValue(String name)
|
||||
{
|
||||
Property p = this.get( "orderedValues", name, 0 );
|
||||
int myValue = p.getInt();
|
||||
p.set( myValue + 1 );
|
||||
return myValue;
|
||||
}
|
||||
|
||||
public int getPlayerID(GameProfile profile)
|
||||
{
|
||||
ConfigCategory playerList = this.getCategory( "players" );
|
||||
|
||||
if ( playerList == null || profile == null || !profile.isComplete() )
|
||||
return -1;
|
||||
|
||||
String uuid = profile.getId().toString();
|
||||
|
||||
Property prop = playerList.get( uuid );
|
||||
if ( prop != null && prop.isIntValue() )
|
||||
return prop.getInt();
|
||||
else
|
||||
{
|
||||
playerList.put( uuid, prop = new Property( uuid, "" + nextPlayer(), Property.Type.INTEGER ) );
|
||||
getUUIDMap().put( prop.getInt(), profile.getId() ); // add to reverse map
|
||||
save();
|
||||
return prop.getInt();
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<Integer, UUID> getUUIDMap()
|
||||
{
|
||||
if ( idToUUID == null )
|
||||
{
|
||||
idToUUID = new HashMap<Integer, UUID>();
|
||||
|
||||
ConfigCategory playerList = this.getCategory( "players" );
|
||||
|
||||
for (Entry<String, Property> b : playerList.getValues().entrySet())
|
||||
idToUUID.put( b.getValue().getInt(), UUID.fromString( b.getKey() ) );
|
||||
}
|
||||
|
||||
return idToUUID;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayerFromID(int playerID)
|
||||
{
|
||||
UUID id = getUUIDMap().get( playerID );
|
||||
|
||||
if ( id != null )
|
||||
{
|
||||
for (EntityPlayer player : CommonHelper.proxy.getPlayers())
|
||||
{
|
||||
if ( player.getUniqueID().equals( id ) )
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,356 @@
|
||||
package appeng.core.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
import org.objectweb.asm.commons.RemappingClassAdapter;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.parts.LayerBase;
|
||||
import appeng.client.render.BusRenderer;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.IFMP;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class ApiPart implements IPartHelper
|
||||
{
|
||||
|
||||
int classNum = 1;
|
||||
|
||||
HashMap<String, Class> TileImplementations = new HashMap();
|
||||
HashMap<String, ClassNode> readerCache = new HashMap();
|
||||
HashMap<Class, String> interfaces2Layer = new HashMap();
|
||||
HashMap<String, Class> roots = new HashMap();
|
||||
|
||||
List<String> desc = new LinkedList();
|
||||
|
||||
public void initFMPSupport()
|
||||
{
|
||||
for (Class layerInterface : interfaces2Layer.keySet())
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).registerPassThrough( layerInterface );
|
||||
}
|
||||
}
|
||||
|
||||
private Class loadClass(String Name, byte[] b)
|
||||
{
|
||||
// override classDefine (as it is protected) and define the class.
|
||||
Class clazz = null;
|
||||
try
|
||||
{
|
||||
ClassLoader loader = getClass().getClassLoader();// ClassLoader.getSystemClassLoader();
|
||||
Class root = ClassLoader.class;
|
||||
Class cls = loader.getClass();
|
||||
java.lang.reflect.Method defineClassMethod = root.getDeclaredMethod( "defineClass",
|
||||
new Class[] { String.class, byte[].class, int.class, int.class } );
|
||||
java.lang.reflect.Method runTransformersMethod = cls
|
||||
.getDeclaredMethod( "runTransformers", new Class[] { String.class, String.class, byte[].class } );
|
||||
|
||||
runTransformersMethod.setAccessible( true );
|
||||
defineClassMethod.setAccessible( true );
|
||||
try
|
||||
{
|
||||
Object[] argsA = new Object[] { Name, Name, b };
|
||||
b = (byte[]) runTransformersMethod.invoke( loader, argsA );
|
||||
|
||||
Object[] args = new Object[] { Name, b, new Integer( 0 ), new Integer( b.length ) };
|
||||
clazz = (Class) defineClassMethod.invoke( loader, args );
|
||||
}
|
||||
finally
|
||||
{
|
||||
runTransformersMethod.setAccessible( false );
|
||||
defineClassMethod.setAccessible( false );
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AELog.error( e );
|
||||
throw new RuntimeException( "Unable to manage part API.", e );
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public ClassNode getReader(String name) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
ClassReader cr;
|
||||
String path = "/" + name.replace( ".", "/" ) + ".class";
|
||||
InputStream is = 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 ( desc.size() == 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Class.forName( base );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
String description = base + ":" + Joiner.on( ";" ).skipNulls().join( desc.iterator() );
|
||||
|
||||
if ( TileImplementations.get( description ) != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
return 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 : desc)
|
||||
{
|
||||
try
|
||||
{
|
||||
String newPath = path + ";" + name;
|
||||
myCLass = getClassByDesc( Addendum, newPath, f, 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();
|
||||
}
|
||||
|
||||
TileImplementations.put( description, myCLass );
|
||||
|
||||
try
|
||||
{
|
||||
return myCLass;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
class DefaultPackageClassNameRemapper extends Remapper
|
||||
{
|
||||
|
||||
public HashMap<String, String> inputOutput = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public String map(String typeName)
|
||||
{
|
||||
String o = inputOutput.get( typeName );
|
||||
if ( o == null )
|
||||
return typeName;
|
||||
return o;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Class getClassByDesc(String Addendum, String fullPath, String root, String next) throws IOException
|
||||
{
|
||||
if ( roots.get( fullPath ) != null )
|
||||
return roots.get( fullPath );
|
||||
|
||||
ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );
|
||||
ClassNode n = 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())
|
||||
{
|
||||
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[] barray = cw.toByteArray();
|
||||
int size = barray.length;
|
||||
Class nclass = loadClass( n.name.replace( "/", "." ), barray );
|
||||
|
||||
try
|
||||
{
|
||||
Object fish = nclass.newInstance();
|
||||
Class rootC = Class.forName( root );
|
||||
|
||||
boolean bads = false;
|
||||
|
||||
if ( !rootC.isInstance( fish ) )
|
||||
{
|
||||
bads = true;
|
||||
AELog.severe( "Error, Expected layer to implement " + root + " did not." );
|
||||
}
|
||||
|
||||
if ( fish instanceof LayerBase )
|
||||
{
|
||||
bads = true;
|
||||
AELog.severe( "Error, Expected layer to NOT implement LayerBase but it DID." );
|
||||
}
|
||||
|
||||
if ( !fullPath.contains( ".fmp." ) )
|
||||
{
|
||||
if ( !(fish instanceof TileCableBus) )
|
||||
{
|
||||
bads = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileCableBus did not." );
|
||||
}
|
||||
|
||||
if ( !(fish instanceof TileEntity) )
|
||||
{
|
||||
bads = true;
|
||||
AELog.severe( "Error, Expected layer to implement TileEntity did not." );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !bads )
|
||||
{
|
||||
AELog.info( "Layer: " + n.name + " loaded successfully - " + size + " bytes" );
|
||||
}
|
||||
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.severe( "Layer: " + n.name + " Failed." );
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
roots.put( fullPath, nclass );
|
||||
return nclass;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( interfaces2Layer.get( layerInterface ) == null )
|
||||
{
|
||||
interfaces2Layer.put( Class.forName( layerInterface ), layer );
|
||||
desc.add( layerInterface );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
AELog.info( "Layer " + layer + " not registered, " + layerInterface + " already has a layer." );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableRenderMode getCableRenderMode()
|
||||
{
|
||||
return CommonHelper.proxy.getRenderMode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package appeng.core.api;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingRequester;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IStorageHelper;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.crafting.CraftingLink;
|
||||
import appeng.util.Platform;
|
||||
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)
|
||||
{
|
||||
return AEItemStack.create( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack createFluidStack(FluidStack is)
|
||||
{
|
||||
return AEFluidStack.create( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> createItemList()
|
||||
{
|
||||
return new ItemList( IAEItemStack.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> createFluidList()
|
||||
{
|
||||
return new ItemList( IAEFluidStack.class );
|
||||
}
|
||||
|
||||
@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
|
||||
{
|
||||
return AEItemStack.loadItemStackFromPacket( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack readFluidFromPacket(ByteBuf input) throws IOException
|
||||
{
|
||||
return AEFluidStack.loadFluidStackFromPacket( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingLink loadCraftingLink(NBTTagCompound data, ICraftingRequester req)
|
||||
{
|
||||
return new CraftingLink( data, req );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.core.api;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public interface IIMCHandler
|
||||
{
|
||||
|
||||
void post(IMCMessage m);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package appeng.core.api.imc;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.api.IIMCHandler;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public class IMCBlackListSpatial implements IIMCHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void post(IMCMessage m)
|
||||
{
|
||||
|
||||
ItemStack is = m.getItemStackValue();
|
||||
if ( is != null )
|
||||
{
|
||||
Block blk = Block.getBlockFromItem( is.getItem() );
|
||||
if ( blk != null )
|
||||
{
|
||||
AEApi.instance().registries().movable().blacklistBlock( blk );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AELog.info( "Bad Block blacklisted by " + m.getSender() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/* Example:
|
||||
|
||||
NBTTagCompound msg = new NBTTagCompound();
|
||||
NBTTagCompound in = new NBTTagCompound();
|
||||
NBTTagCompound out = new NBTTagCompound();
|
||||
|
||||
new ItemStack( Blocks.iron_ore ).writeToNBT( in );
|
||||
new ItemStack( Items.iron_ingot ).writeToNBT( out );
|
||||
msg.setTag( "in", in );
|
||||
msg.setTag( "out", out );
|
||||
msg.setInteger( "turns", 8 );
|
||||
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-grindable", msg );
|
||||
|
||||
-- or --
|
||||
|
||||
NBTTagCompound msg = new NBTTagCompound();
|
||||
NBTTagCompound in = new NBTTagCompound();
|
||||
NBTTagCompound out = new NBTTagCompound();
|
||||
NBTTagCompound optional = new NBTTagCompound();
|
||||
|
||||
new ItemStack( Blocks.iron_ore ).writeToNBT( in );
|
||||
new ItemStack( Items.iron_ingot ).writeToNBT( out );
|
||||
new ItemStack( Blocks.gravel ).writeToNBT( optional );
|
||||
msg.setTag( "in", in );
|
||||
msg.setTag( "out", out );
|
||||
msg.setTag( "optional", optional );
|
||||
msg.setFloat( "chance", 0.5 );
|
||||
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;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.api.IIMCHandler;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public class IMCGrinder implements IIMCHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void post(IMCMessage m)
|
||||
{
|
||||
NBTTagCompound msg = m.getNBTValue();
|
||||
NBTTagCompound inTag = (NBTTagCompound) msg.getTag( "in" );
|
||||
NBTTagCompound outTag = (NBTTagCompound) msg.getTag( "out" );
|
||||
|
||||
ItemStack in = ItemStack.loadItemStackFromNBT( inTag );
|
||||
ItemStack out = ItemStack.loadItemStackFromNBT( outTag );
|
||||
|
||||
int turns = msg.getInteger( "turns" );
|
||||
|
||||
if ( in == null )
|
||||
throw new RuntimeException( "invalid input" );
|
||||
|
||||
if ( out == null )
|
||||
throw new RuntimeException( "invalid output" );
|
||||
|
||||
if ( msg.hasKey( "optional" ) )
|
||||
{
|
||||
NBTTagCompound optionalTag = (NBTTagCompound) msg.getTag( "optional" );
|
||||
ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag );
|
||||
|
||||
if ( optional == null )
|
||||
throw new RuntimeException( "invalid optional" );
|
||||
|
||||
float chance = msg.getFloat( "chance" );
|
||||
|
||||
AEApi.instance().registries().grinder().addRecipe( in, out, optional, chance, turns );
|
||||
}
|
||||
else
|
||||
AEApi.instance().registries().grinder().addRecipe( in, out, turns );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/* Example:
|
||||
|
||||
NBTTagCompound msg = new NBTTagCompound();
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
|
||||
new ItemStack( Blocks.anvil ).writeToNBT( item );
|
||||
msg.setTag( "item", item );
|
||||
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;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.api.IIMCHandler;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public class IMCMatterCannon implements IIMCHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void post(IMCMessage m)
|
||||
{
|
||||
NBTTagCompound msg = m.getNBTValue();
|
||||
NBTTagCompound item = (NBTTagCompound) msg.getTag( "item" );
|
||||
|
||||
ItemStack ammo = ItemStack.loadItemStackFromNBT( item );
|
||||
double weight = msg.getDouble( "weight" );
|
||||
|
||||
if ( ammo == null )
|
||||
throw new RuntimeException( "invalid item" );
|
||||
|
||||
AEApi.instance().registries().matterCannon().registerAmmo( ammo, weight );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/* Example:
|
||||
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-me", new ItemStack( myBlockOrItem ) );
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-bc-power", new ItemStack( myBlockOrItem ) );
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-ic2-power", new ItemStack( myBlockOrItem ) );
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-redstone", new ItemStack( myBlockOrItem ) );
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-fluid", new ItemStack( myBlockOrItem ) );
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-item", new ItemStack( myBlockOrItem ) );
|
||||
|
||||
*/
|
||||
package appeng.core.api.imc;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.core.api.IIMCHandler;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public class IMCP2PAttunement implements IIMCHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void post(IMCMessage m)
|
||||
{
|
||||
String key = m.key.substring( "add-p2p-attunement-".length() ).replace( '-', '_' ).toUpperCase();
|
||||
|
||||
TunnelType type = TunnelType.valueOf( key );
|
||||
|
||||
if ( type != null )
|
||||
{
|
||||
ItemStack is = m.getItemStackValue();
|
||||
if ( is != null )
|
||||
AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type );
|
||||
else
|
||||
throw new RuntimeException( "invalid item" );
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "invalid type" );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Example:
|
||||
|
||||
FMLInterModComms.sendMessage( "appliedenergistics2", "whitelist-spatial", "mymod.tileentities.MyTileEntity" );
|
||||
|
||||
*/
|
||||
package appeng.core.api.imc;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.api.IIMCHandler;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public class IMCSpatial implements IIMCHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void post(IMCMessage m)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Class classInstance = Class.forName( m.getStringValue() );
|
||||
AEApi.instance().registries().movable().whiteListTileEntity( classInstance );
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
AELog.info( "Bad Class Registered: " + m.getStringValue() + " by " + m.getSender() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package appeng.core.crash;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import cpw.mods.fml.common.ICrashCallable;
|
||||
|
||||
public class CrashEnhancement implements ICrashCallable
|
||||
{
|
||||
|
||||
private final String name;
|
||||
private final String value;
|
||||
|
||||
private final String ModVersion = AEConfig.CHANNEL + " " + AEConfig.VERSION + " for Forge " + // WHAT?
|
||||
net.minecraftforge.common.ForgeVersion.majorVersion + "." // majorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.minorVersion + "." // minorVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.revisionVersion + "." // revisionVersion
|
||||
+ net.minecraftforge.common.ForgeVersion.buildVersion;
|
||||
|
||||
public CrashEnhancement(CrashInfo Output) {
|
||||
|
||||
if ( Output == CrashInfo.MOD_VERSION )
|
||||
{
|
||||
name = "AE2 Version";
|
||||
value = ModVersion;
|
||||
}
|
||||
else if ( Output == CrashInfo.INTEGRATION )
|
||||
{
|
||||
name ="AE2 Integration";
|
||||
if ( IntegrationRegistry.instance != null )
|
||||
value = IntegrationRegistry.instance.getStatus();
|
||||
else
|
||||
value = "N/A";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "AE2_UNKNOWN";
|
||||
value = "UNKNOWN_VALUE";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String call() throws Exception
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package appeng.core.crash;
|
||||
|
||||
public enum CrashInfo
|
||||
{
|
||||
MOD_VERSION, INTEGRATION
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
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.
|
||||
|
||||
CertusQuartzWorldGen("World"), MeteoriteWorldGen("World"),
|
||||
|
||||
DecorativeLights("World"), DecorativeQuartzBlocks("World"), SkyStoneChests("World"), SpawnPressesInMeteorites("World"),
|
||||
|
||||
GrindStone("World"), Flour("World"), Inscriber("World"),
|
||||
|
||||
ChestLoot("World"), VillagerTrading("World"),
|
||||
|
||||
TinyTNT("World"),
|
||||
|
||||
PoweredTools("ToolsClassifications"),
|
||||
|
||||
CertusQuartzTools("ToolsClassifications"),
|
||||
|
||||
NetherQuartzTools("ToolsClassifications"),
|
||||
|
||||
QuartzHoe("Tools"), QuartzSpade("Tools"), QuartzSword("Tools"), QuartzPickaxe("Tools"), QuartzAxe("Tools"), QuartzKnife("Tools"), QuartzWrench("Tools"),
|
||||
|
||||
ChargedStaff("Tools"), EntropyManipulator("Tools"), MatterCannon("Tools"), WirelessAccessTerminal("Tools"), ColorApplicator("Tools"),
|
||||
|
||||
CraftingCPU("CraftingFeatures"), PowerGen("NetworkFeatures"), Security("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"),
|
||||
|
||||
StorageCells("Storage"), PortableCell("PortableCell"), MEChest("Storage"), MEDrive("Storage"), IOPort("Storage"),
|
||||
|
||||
NetworkTool("NetworkTool"),
|
||||
|
||||
DenseEnergyCells("HigherCapacity"), DenseCables("HigherCapacity"),
|
||||
|
||||
P2PTunnelRF("P2PTunnels"), P2PTunnelME("P2PTunnels"), P2PTunnelItems("P2PTunnels"), P2PTunnelRedstone("P2PTunnels"), P2PTunnelEU("P2PTunnels"), P2PTunnelMJ(
|
||||
"P2PTunnels"), P2PTunnelLiquids("P2PTunnels"), P2PTunnelLight("P2PTunnels"),
|
||||
|
||||
MassCannonBlockDamage("BlockFeatures"), TinyTNTBlockDamage("BlockFeatures"), Facades("Facades"),
|
||||
|
||||
VersionChecker("Services"), UnsupportedDeveloperTools("Misc", false), Creative("Misc"),
|
||||
|
||||
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),
|
||||
|
||||
AlphaPass("Rendering"), PaintBalls("Tools"), PacketLogging("Misc", false), CraftingLog("Misc", false), InterfaceTerminal("Crafting"), LightDetector("Misc"),
|
||||
|
||||
enableDisassemblyCrafting("Crafting"), MolecularAssembler("CraftingFeatures"), MeteoriteCompass("Tools"), Patterns("CraftingFeatures"),
|
||||
|
||||
ChunkLoggerTrace("Commands", false), LogSecurityAudits("Misc", false), Achievements("Misc");
|
||||
|
||||
String Category;
|
||||
boolean visible = true;
|
||||
boolean defValue = true;
|
||||
|
||||
private AEFeature(String cat) {
|
||||
Category = cat;
|
||||
visible = !this.name().equals( "Core" );
|
||||
}
|
||||
|
||||
private AEFeature(String cat, boolean defv) {
|
||||
this( cat );
|
||||
defValue = defv;
|
||||
}
|
||||
|
||||
public String getCategory()
|
||||
{
|
||||
return Category;
|
||||
}
|
||||
|
||||
public Boolean defaultValue()
|
||||
{
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public Boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class AEFeatureHandler implements AEItemDefinition
|
||||
{
|
||||
|
||||
private final EnumSet<AEFeature> myFeatures;
|
||||
|
||||
private final String subname;
|
||||
private IAEFeature obj;
|
||||
|
||||
private Item ItemData;
|
||||
private Block BlockData;
|
||||
|
||||
public AEFeatureHandler(EnumSet<AEFeature> featureSet, IAEFeature _obj, String _subname) {
|
||||
myFeatures = featureSet;
|
||||
obj = _obj;
|
||||
subname = _subname;
|
||||
}
|
||||
|
||||
public void register()
|
||||
{
|
||||
if ( isFeatureAvailable() )
|
||||
{
|
||||
if ( obj instanceof Item )
|
||||
initItem( (Item) obj );
|
||||
if ( obj instanceof Block )
|
||||
initBlock( (Block) obj );
|
||||
}
|
||||
}
|
||||
|
||||
public static String getName(Class o, String subname)
|
||||
{
|
||||
String name = o.getSimpleName();
|
||||
|
||||
if ( name.startsWith( "ItemMultiPart" ) )
|
||||
name = name.replace( "ItemMultiPart", "ItemPart" );
|
||||
else if ( name.startsWith( "ItemMultiMaterial" ) )
|
||||
name = name.replace( "ItemMultiMaterial", "ItemMaterial" );
|
||||
|
||||
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" ) )
|
||||
return "ItemPart.P2PTunnel";
|
||||
|
||||
if ( subname.equals( "CertusQuartzTools" ) )
|
||||
return name.replace( "Quartz", "CertusQuartz" );
|
||||
if ( subname.equals( "NetherQuartzTools" ) )
|
||||
return name.replace( "Quartz", "NetherQuartz" );
|
||||
|
||||
name += "." + subname;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
private void initItem(Item i)
|
||||
{
|
||||
ItemData = i;
|
||||
|
||||
String name = getName( i.getClass(), subname );
|
||||
i.setTextureName( "appliedenergistics2:" + name );
|
||||
i.setUnlocalizedName( /* "item." */"appliedenergistics2." + name );
|
||||
|
||||
if ( i instanceof ItemFacade )
|
||||
i.setCreativeTab( CreativeTabFacade.instance );
|
||||
else
|
||||
i.setCreativeTab( CreativeTab.instance );
|
||||
|
||||
if ( name.equals( "ItemMaterial" ) )
|
||||
name = "ItemMultiMaterial";
|
||||
else if ( name.equals( "ItemPart" ) )
|
||||
name = "ItemMultiPart";
|
||||
|
||||
GameRegistry.registerItem( i, "item." + name );
|
||||
}
|
||||
|
||||
private void initBlock(Block b)
|
||||
{
|
||||
BlockData = b;
|
||||
|
||||
String name = getName( b.getClass(), subname );
|
||||
b.setCreativeTab( CreativeTab.instance );
|
||||
b.setBlockName( /* "tile." */"appliedenergistics2." + name );
|
||||
b.setBlockTextureName( "appliedenergistics2:" + name );
|
||||
|
||||
if ( Platform.isClient() && BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = (AEBaseBlock) b;
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( bb.getTileEntityClass(), bb );
|
||||
}
|
||||
|
||||
Class itemBlock = AEBaseItemBlock.class;
|
||||
if ( b instanceof AEBaseBlock )
|
||||
itemBlock = ((AEBaseBlock) b).getItemBlockClass();
|
||||
|
||||
GameRegistry.registerBlock( b, itemBlock, "tile." + name );
|
||||
}
|
||||
|
||||
public EnumSet<AEFeature> getFeatures()
|
||||
{
|
||||
return myFeatures.clone();
|
||||
}
|
||||
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
boolean enabled = true;
|
||||
|
||||
for (AEFeature f : myFeatures)
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return BlockData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
if ( BlockData instanceof AEBaseBlock )
|
||||
{
|
||||
AEBaseBlock bb = (AEBaseBlock) BlockData;
|
||||
return bb.getTileEntityClass();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
if ( ItemData == null && BlockData != null )
|
||||
return Item.getItemFromBlock( BlockData );
|
||||
return ItemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
if ( isFeatureAvailable() )
|
||||
{
|
||||
ItemStack rv = null;
|
||||
|
||||
if ( ItemData != null )
|
||||
rv = new ItemStack( ItemData );
|
||||
else
|
||||
rv = new ItemStack( BlockData );
|
||||
|
||||
rv.stackSize = stackSize;
|
||||
return rv;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack is)
|
||||
{
|
||||
if ( isFeatureAvailable() )
|
||||
return Platform.isSameItemType( is, stack( 1 ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if ( isFeatureAvailable() && BlockData != null )
|
||||
return world.getBlock( x, y, z ) == block();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
|
||||
public class ColoredItemDefinition implements AEColoredItemDefinition
|
||||
{
|
||||
|
||||
ItemStackSrc colors[] = new ItemStackSrc[17];
|
||||
|
||||
@Override
|
||||
public Item item(AEColor color)
|
||||
{
|
||||
ItemStackSrc is = colors[color.ordinal()];
|
||||
|
||||
if ( is == null )
|
||||
return null;
|
||||
|
||||
return is.item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(AEColor color, int stackSize)
|
||||
{
|
||||
ItemStackSrc is = colors[color.ordinal()];
|
||||
|
||||
if ( is == null )
|
||||
return null;
|
||||
|
||||
return is.stack( stackSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAs(AEColor color, ItemStack comparableItem)
|
||||
{
|
||||
ItemStackSrc is = 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
ItemStack is[] = new ItemStack[colors.length];
|
||||
for (int x = 0; x < is.length; x++)
|
||||
is[x] = colors[x].stack( 1 );
|
||||
return is;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
public class DamagedItemDefinition implements AEItemDefinition
|
||||
{
|
||||
|
||||
final IStackSrc src;
|
||||
|
||||
public DamagedItemDefinition(IStackSrc is) {
|
||||
src = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return src.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
return src.stack( stackSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack comparableItem)
|
||||
{
|
||||
if ( comparableItem == null )
|
||||
return false;
|
||||
|
||||
return comparableItem.getItem() == src.getItem() && comparableItem.getItemDamage() == src.getDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package appeng.core.features;
|
||||
|
||||
public interface IAEFeature
|
||||
{
|
||||
|
||||
public AEFeatureHandler feature();
|
||||
|
||||
void postInit();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IStackSrc
|
||||
{
|
||||
|
||||
ItemStack stack(int i);
|
||||
|
||||
Item getItem();
|
||||
|
||||
int getDamage();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemStackSrc implements IStackSrc
|
||||
{
|
||||
|
||||
public final Item item;
|
||||
public final Block block;
|
||||
public final int damage;
|
||||
|
||||
public ItemStackSrc(Item i, int dmg) {
|
||||
block = null;
|
||||
item = i;
|
||||
damage = dmg;
|
||||
}
|
||||
|
||||
public ItemStackSrc(Block b, int dmg) {
|
||||
item = null;
|
||||
block = b;
|
||||
damage = dmg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int i)
|
||||
{
|
||||
if ( block != null )
|
||||
return new ItemStack( block, i, damage );
|
||||
|
||||
if ( item != null )
|
||||
return new ItemStack( item, i, damage );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem()
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamage()
|
||||
{
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.items.materials.MaterialType;
|
||||
|
||||
public class MaterialStackSrc implements IStackSrc
|
||||
{
|
||||
|
||||
MaterialType src;
|
||||
|
||||
public MaterialStackSrc(MaterialType src) {
|
||||
this.src = src;
|
||||
if ( src == null )
|
||||
throw new RuntimeException( "Invalid Item Stack" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
return src.stack( stackSize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItem()
|
||||
{
|
||||
return src.itemInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamage()
|
||||
{
|
||||
return src.damageValue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
public class NullItemDefinition implements AEItemDefinition
|
||||
{
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack comparableItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package appeng.core.features;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
|
||||
public class WrappedDamageItemDefinition implements AEItemDefinition
|
||||
{
|
||||
|
||||
final AEItemDefinition baseItem;
|
||||
final int damage;
|
||||
|
||||
public WrappedDamageItemDefinition(AEItemDefinition def, int dmg) {
|
||||
baseItem = def;
|
||||
damage = dmg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block block()
|
||||
{
|
||||
return baseItem.block();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item item()
|
||||
{
|
||||
return baseItem.item();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileEntity> entity()
|
||||
{
|
||||
return baseItem.entity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack stack(int stackSize)
|
||||
{
|
||||
if ( baseItem == null )
|
||||
return null;
|
||||
|
||||
return new ItemStack( baseItem.block(), stackSize, damage );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsStack(ItemStack comparableItem)
|
||||
{
|
||||
if ( comparableItem == null )
|
||||
return false;
|
||||
|
||||
return comparableItem.getItem() == baseItem.item() && comparableItem.getItemDamage() == damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameAsBlock(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if ( block() != null )
|
||||
return world.getBlock( x, y, z ) == block() && world.getBlockMetadata( x, y, z ) == damage;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellRegistry;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
|
||||
public class CellRegistry implements ICellRegistry
|
||||
{
|
||||
|
||||
List<ICellHandler> handlers;
|
||||
|
||||
public CellRegistry() {
|
||||
handlers = new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellHandler(ICellHandler h)
|
||||
{
|
||||
if ( h != null )
|
||||
handlers.add( h );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellHandled(ItemStack is)
|
||||
{
|
||||
if ( is == null )
|
||||
return false;
|
||||
for (ICellHandler ch : handlers)
|
||||
if ( ch.isCell( is ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICellHandler getHandler(ItemStack is)
|
||||
{
|
||||
if ( is == null )
|
||||
return null;
|
||||
for (ICellHandler ch : handlers)
|
||||
{
|
||||
if ( ch.isCell( is ) )
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel chan)
|
||||
{
|
||||
if ( is == null )
|
||||
return null;
|
||||
for (ICellHandler ch : handlers)
|
||||
{
|
||||
if ( ch.isCell( is ) )
|
||||
{
|
||||
return ch.getCellInventory( is, container, chan );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IExternalStorageRegistry;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.core.features.registries.entries.ExternalIInv;
|
||||
|
||||
public class ExternalStorageRegistry implements IExternalStorageRegistry
|
||||
{
|
||||
|
||||
List<IExternalStorageHandler> Handlers;
|
||||
final ExternalIInv lastHandler = new ExternalIInv();
|
||||
|
||||
public ExternalStorageRegistry() {
|
||||
Handlers = new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExternalStorageHandler getHandler(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
|
||||
{
|
||||
for (IExternalStorageHandler x : Handlers)
|
||||
{
|
||||
if ( x.canHandle( te, d, chan, mySrc ) )
|
||||
return x;
|
||||
}
|
||||
|
||||
if ( lastHandler.canHandle( te, d, chan, mySrc ) )
|
||||
return lastHandler;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExternalStorageInterface(IExternalStorageHandler ei)
|
||||
{
|
||||
Handlers.add( ei );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
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();
|
||||
|
||||
@Override
|
||||
public void registerGridCache(Class<? extends IGridCache> iface, Class<? extends IGridCache> implementation)
|
||||
{
|
||||
if ( iface.isAssignableFrom( implementation ) )
|
||||
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)
|
||||
{
|
||||
HashMap<Class<? extends IGridCache>, IGridCache> map = new HashMap();
|
||||
|
||||
for (Class<? extends IGridCache> iface : caches.keySet())
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor<? extends IGridCache> c = caches.get( iface ).getConstructor( IGrid.class );
|
||||
map.put( iface, c.newInstance( g ) );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." );
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IGrinderEntry;
|
||||
import appeng.api.features.IGrinderRegistry;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.registries.entries.AppEngGrinderRecipe;
|
||||
import appeng.recipes.ores.IOreListener;
|
||||
import appeng.recipes.ores.OreDictionaryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GrinderRecipeManager implements IGrinderRegistry, IOreListener
|
||||
{
|
||||
|
||||
public List<IGrinderEntry> RecipeList;
|
||||
|
||||
private ItemStack copy(ItemStack is)
|
||||
{
|
||||
if ( is != null )
|
||||
return is.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
public GrinderRecipeManager() {
|
||||
RecipeList = new ArrayList();
|
||||
|
||||
addOre( "Coal", new ItemStack( Items.coal ) );
|
||||
addOre( "Charcoal", new ItemStack( Items.coal, 1, 1 ) );
|
||||
|
||||
addOre( "NetherQuartz", new ItemStack( Blocks.quartz_ore ) );
|
||||
addIngot( "NetherQuartz", new ItemStack( Items.quartz ) );
|
||||
|
||||
addOre( "Gold", new ItemStack( Blocks.gold_ore ) );
|
||||
addIngot( "Gold", new ItemStack( Items.gold_ingot ) );
|
||||
|
||||
addOre( "Iron", new ItemStack( Blocks.iron_ore ) );
|
||||
addIngot( "Iron", new ItemStack( Items.iron_ingot ) );
|
||||
|
||||
addOre( "Obsidian", new ItemStack( Blocks.obsidian ) );
|
||||
|
||||
addIngot( "Ender", new ItemStack( Items.ender_pearl ) );
|
||||
addIngot( "EnderPearl", new ItemStack( Items.ender_pearl ) );
|
||||
|
||||
addIngot( "Wheat", new ItemStack( Items.wheat ) );
|
||||
|
||||
OreDictionaryHandler.instance.observe( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IGrinderEntry> getRecipes()
|
||||
{
|
||||
log( "API - getRecipes" );
|
||||
return RecipeList;
|
||||
}
|
||||
|
||||
private void injectRecipe(AppEngGrinderRecipe appEngGrinderRecipe)
|
||||
{
|
||||
for (IGrinderEntry gr : RecipeList)
|
||||
if ( Platform.isSameItemPrecise( gr.getInput(), appEngGrinderRecipe.getInput() ) )
|
||||
return;
|
||||
|
||||
RecipeList.add( appEngGrinderRecipe );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(ItemStack in, ItemStack out, int cost)
|
||||
{
|
||||
if ( in == null || out == null )
|
||||
{
|
||||
log( "Invalid Grinder Recipe Specified." );
|
||||
return;
|
||||
}
|
||||
|
||||
log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " for " + cost );
|
||||
injectRecipe( new AppEngGrinderRecipe( copy( in ), copy( out ), cost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(ItemStack in, ItemStack out, ItemStack optional, float chance, int cost)
|
||||
{
|
||||
if ( in == null || (optional == null && out == null) )
|
||||
{
|
||||
log( "Invalid Grinder Recipe Specified." );
|
||||
return;
|
||||
}
|
||||
|
||||
log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " with optional "
|
||||
+ Platform.getItemDisplayName( optional ) + " for " + cost );
|
||||
injectRecipe( new AppEngGrinderRecipe( copy( in ), copy( out ), copy( optional ), chance, cost ) );
|
||||
}
|
||||
|
||||
@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) )
|
||||
{
|
||||
log( "Invalid Grinder Recipe Specified." );
|
||||
return;
|
||||
}
|
||||
|
||||
log( "Allow Grinding of " + Platform.getItemDisplayName( in ) + " to " + Platform.getItemDisplayName( out ) + " with optional "
|
||||
+ Platform.getItemDisplayName( optional ) + " for " + cost );
|
||||
injectRecipe( new AppEngGrinderRecipe( copy( in ), copy( out ), copy( optional ), chance, cost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrinderEntry getRecipeForInput(ItemStack input)
|
||||
{
|
||||
log( "Looking up recipe for " + Platform.getItemDisplayName( input ) );
|
||||
if ( input != null )
|
||||
{
|
||||
for (IGrinderEntry r : RecipeList)
|
||||
{
|
||||
if ( Platform.isSameItem( input, r.getInput() ) )
|
||||
{
|
||||
log( "Recipe for " + input.getUnlocalizedName() + " found " + Platform.getItemDisplayName( r.getOutput() ) );
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
log( "Could not find recipe for " + Platform.getItemDisplayName( input ) );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void log(String o)
|
||||
{
|
||||
AELog.grinder( o );
|
||||
}
|
||||
|
||||
private int getDustToOreRatio(String name)
|
||||
{
|
||||
if ( name.equals( "Obsidian" ) )
|
||||
return 1;
|
||||
if ( name.equals( "Charcoal" ) )
|
||||
return 1;
|
||||
if ( name.equals( "Coal" ) )
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
public Map<ItemStack, String> Ores = new HashMap<ItemStack, String>();
|
||||
public Map<ItemStack, String> Ingots = new HashMap<ItemStack, String>();
|
||||
public Map<String, ItemStack> Dusts = new HashMap<String, ItemStack>();
|
||||
|
||||
private void addOre(String name, ItemStack item)
|
||||
{
|
||||
if ( item == null )
|
||||
return;
|
||||
log( "Adding Ore - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
|
||||
Ores.put( item, name );
|
||||
|
||||
if ( Dusts.containsKey( name ) )
|
||||
{
|
||||
ItemStack is = Dusts.get( name ).copy();
|
||||
int ratio = getDustToOreRatio( name );
|
||||
if ( ratio > 1 )
|
||||
{
|
||||
ItemStack extra = is.copy();
|
||||
extra.stackSize = ratio - 1;
|
||||
addRecipe( item, is, extra, (float) (AEConfig.instance.oreDoublePercentage / 100.0), 8 );
|
||||
}
|
||||
else
|
||||
addRecipe( item, is, 8 );
|
||||
}
|
||||
}
|
||||
|
||||
private void addIngot(String name, ItemStack item)
|
||||
{
|
||||
if ( item == null )
|
||||
return;
|
||||
log( "Adding Ingot - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
|
||||
Ingots.put( item, name );
|
||||
|
||||
if ( Dusts.containsKey( name ) )
|
||||
{
|
||||
addRecipe( item, Dusts.get( name ), 4 );
|
||||
}
|
||||
}
|
||||
|
||||
private void addDust(String name, ItemStack item)
|
||||
{
|
||||
if ( item == null )
|
||||
return;
|
||||
if ( Dusts.containsKey( name ) )
|
||||
{
|
||||
log( "Rejecting Dust - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
return;
|
||||
}
|
||||
|
||||
log( "Adding Dust - " + name + " : " + Platform.getItemDisplayName( item ) );
|
||||
|
||||
Dusts.put( name, item );
|
||||
|
||||
for (Entry<ItemStack, String> d : Ores.entrySet())
|
||||
if ( name.equals( d.getValue() ) )
|
||||
{
|
||||
ItemStack is = item.copy();
|
||||
is.stackSize = 1;
|
||||
int ratio = getDustToOreRatio( name );
|
||||
if ( ratio > 1 )
|
||||
{
|
||||
ItemStack extra = is.copy();
|
||||
extra.stackSize = ratio - 1;
|
||||
addRecipe( d.getKey(), is, extra, (float) (AEConfig.instance.oreDoublePercentage / 100.0), 8 );
|
||||
}
|
||||
else
|
||||
addRecipe( d.getKey(), is, 8 );
|
||||
}
|
||||
|
||||
for (Entry<ItemStack, String> d : Ingots.entrySet())
|
||||
if ( name.equals( d.getValue() ) )
|
||||
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" ) )
|
||||
{
|
||||
for (String ore : AEConfig.instance.grinderOres)
|
||||
{
|
||||
if ( Name.equals( "ore" + ore ) )
|
||||
{
|
||||
addOre( ore, item );
|
||||
}
|
||||
else if ( Name.equals( "crystal" + ore ) || Name.equals( "ingot" + ore ) || Name.equals( "gem" + ore ) )
|
||||
{
|
||||
addIngot( ore, item );
|
||||
}
|
||||
else if ( Name.equals( "dust" + ore ) )
|
||||
{
|
||||
addDust( ore, item );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import appeng.api.events.LocatableEventAnnounce;
|
||||
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.ILocatableRegistry;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class LocatableRegistry implements ILocatableRegistry
|
||||
{
|
||||
|
||||
private HashMap<Long, ILocatable> set;
|
||||
|
||||
@SubscribeEvent
|
||||
public void updateLocatable(LocatableEventAnnounce e)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return; // IGNORE!
|
||||
|
||||
if ( e.change == LocatableEvent.Register )
|
||||
{
|
||||
set.put( e.target.getLocatableSerial(), e.target );
|
||||
}
|
||||
else if ( e.change == LocatableEvent.Unregister )
|
||||
{
|
||||
set.remove( e.target.getLocatableSerial() );
|
||||
}
|
||||
}
|
||||
|
||||
public LocatableRegistry() {
|
||||
set = new HashMap();
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a locate-able object by its serial.
|
||||
*/
|
||||
@Override
|
||||
public Object findLocatableBySerial(long ser)
|
||||
{
|
||||
return set.get( ser );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
import appeng.recipes.ores.IOreListener;
|
||||
import appeng.recipes.ores.OreDictionaryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmoRegistry
|
||||
{
|
||||
|
||||
private HashMap<ItemStack, Double> DamageModifiers = new HashMap<ItemStack, Double>();
|
||||
|
||||
@Override
|
||||
public void registerAmmo(ItemStack ammo, double weight)
|
||||
{
|
||||
DamageModifiers.put( ammo, weight );
|
||||
}
|
||||
|
||||
private void considerItem(String ore, ItemStack item, String Name, double weight)
|
||||
{
|
||||
if ( ore.equals( "berry" + Name ) || ore.equals( "nugget" + Name ) )
|
||||
{
|
||||
registerAmmo( item, weight );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void oreRegistered(String Name, ItemStack item)
|
||||
{
|
||||
if ( !(Name.startsWith( "berry" ) || Name.startsWith( "nugget" )) )
|
||||
return;
|
||||
|
||||
// addNugget( "Cobble", 18 ); // ?
|
||||
considerItem( Name, item, "MeatRaw", 32 );
|
||||
considerItem( Name, item, "MeatCooked", 32 );
|
||||
considerItem( Name, item, "Meat", 32 );
|
||||
considerItem( Name, item, "Chicken", 32 );
|
||||
considerItem( Name, item, "Beef", 32 );
|
||||
considerItem( Name, item, "Sheep", 32 );
|
||||
considerItem( Name, item, "Fish", 32 );
|
||||
|
||||
// real world...
|
||||
considerItem( Name, item, "Lithium", 6.941 );
|
||||
considerItem( Name, item, "Beryllium", 9.0122 );
|
||||
considerItem( Name, item, "Boron", 10.811 );
|
||||
considerItem( Name, item, "Carbon", 12.0107 );
|
||||
considerItem( Name, item, "Coal", 12.0107 );
|
||||
considerItem( Name, item, "Charcoal", 12.0107 );
|
||||
considerItem( Name, item, "Sodium", 22.9897 );
|
||||
considerItem( Name, item, "Magnesium", 24.305 );
|
||||
considerItem( Name, item, "Aluminum", 26.9815 );
|
||||
considerItem( Name, item, "Silicon", 28.0855 );
|
||||
considerItem( Name, item, "Phosphorus", 30.9738 );
|
||||
considerItem( Name, item, "Sulfur", 32.065 );
|
||||
considerItem( Name, item, "Potassium", 39.0983 );
|
||||
considerItem( Name, item, "Calcium", 40.078 );
|
||||
considerItem( Name, item, "Scandium", 44.9559 );
|
||||
considerItem( Name, item, "Titanium", 47.867 );
|
||||
considerItem( Name, item, "Vanadium", 50.9415 );
|
||||
considerItem( Name, item, "Manganese", 54.938 );
|
||||
considerItem( Name, item, "Iron", 55.845 );
|
||||
considerItem( Name, item, "Nickel", 58.6934 );
|
||||
considerItem( Name, item, "Cobalt", 58.9332 );
|
||||
considerItem( Name, item, "Copper", 63.546 );
|
||||
considerItem( Name, item, "Zinc", 65.39 );
|
||||
considerItem( Name, item, "Gallium", 69.723 );
|
||||
considerItem( Name, item, "Germanium", 72.64 );
|
||||
considerItem( Name, item, "Bromine", 79.904 );
|
||||
considerItem( Name, item, "Krypton", 83.8 );
|
||||
considerItem( Name, item, "Rubidium", 85.4678 );
|
||||
considerItem( Name, item, "Strontium", 87.62 );
|
||||
considerItem( Name, item, "Yttrium", 88.9059 );
|
||||
considerItem( Name, item, "Zirconiumm", 91.224 );
|
||||
considerItem( Name, item, "Niobiumm", 92.9064 );
|
||||
considerItem( Name, item, "Technetium", 98 );
|
||||
considerItem( Name, item, "Ruthenium", 101.07 );
|
||||
considerItem( Name, item, "Rhodium", 102.9055 );
|
||||
considerItem( Name, item, "Palladium", 106.42 );
|
||||
considerItem( Name, item, "Silver", 107.8682 );
|
||||
considerItem( Name, item, "Cadmium", 112.411 );
|
||||
considerItem( Name, item, "Indium", 114.818 );
|
||||
considerItem( Name, item, "Tin", 118.71 );
|
||||
considerItem( Name, item, "Antimony", 121.76 );
|
||||
considerItem( Name, item, "Iodine", 126.9045 );
|
||||
considerItem( Name, item, "Tellurium", 127.6 );
|
||||
considerItem( Name, item, "Xenon", 131.293 );
|
||||
considerItem( Name, item, "Cesium", 132.9055 );
|
||||
considerItem( Name, item, "Barium", 137.327 );
|
||||
considerItem( Name, item, "Lanthanum", 138.9055 );
|
||||
considerItem( Name, item, "Cerium", 140.116 );
|
||||
considerItem( Name, item, "Tantalum", 180.9479 );
|
||||
considerItem( Name, item, "Tungsten", 183.84 );
|
||||
considerItem( Name, item, "Osmium", 190.23 );
|
||||
considerItem( Name, item, "Iridium", 192.217 );
|
||||
considerItem( Name, item, "Platinum", 195.078 );
|
||||
considerItem( Name, item, "Lead", 207.2 );
|
||||
considerItem( Name, item, "Bismuth", 208.9804 );
|
||||
considerItem( Name, item, "Uranium", 238.0289 );
|
||||
considerItem( Name, item, "Plutonium", 244 );
|
||||
|
||||
// TE stuff...
|
||||
considerItem( Name, item, "Invar", (58.6934 + 55.845 + 55.845) / 3.0 );
|
||||
considerItem( Name, item, "Electrum", (107.8682 + 196.96655) / 2.0 );
|
||||
}
|
||||
|
||||
public MatterCannonAmmoRegistry() {
|
||||
OreDictionaryHandler.instance.observe( this );
|
||||
registerAmmo( new ItemStack( Items.gold_nugget ), 196.96655 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPenetration(ItemStack is)
|
||||
{
|
||||
for (ItemStack o : DamageModifiers.keySet())
|
||||
{
|
||||
if ( Platform.isSameItem( o, is ) )
|
||||
return DamageModifiers.get( o ).floatValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.movable.IMovableHandler;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.movable.IMovableTile;
|
||||
import appeng.spatial.DefaultSpatialHandler;
|
||||
|
||||
public class MovableTileRegistry implements IMovableRegistry
|
||||
{
|
||||
|
||||
private HashSet<Block> blacklisted = new HashSet();
|
||||
|
||||
private HashMap<Class<? extends TileEntity>, IMovableHandler> Valid = new HashMap<Class<? extends TileEntity>, IMovableHandler>();
|
||||
private LinkedList<Class<? extends TileEntity>> test = new LinkedList<Class<? extends TileEntity>>();
|
||||
private LinkedList<IMovableHandler> handlers = new LinkedList<IMovableHandler>();
|
||||
private DefaultSpatialHandler dsh = new DefaultSpatialHandler();
|
||||
|
||||
private IMovableHandler nullHandler = new DefaultSpatialHandler();
|
||||
|
||||
private IMovableHandler testClass(Class myClass, TileEntity te)
|
||||
{
|
||||
IMovableHandler handler = null;
|
||||
|
||||
// ask handlers...
|
||||
for (IMovableHandler han : handlers)
|
||||
{
|
||||
if ( han.canHandle( myClass, te ) )
|
||||
{
|
||||
handler = han;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if you have a handler your opted in
|
||||
if ( handler != null )
|
||||
{
|
||||
Valid.put( myClass, handler );
|
||||
return handler;
|
||||
|
||||
}
|
||||
|
||||
// if your movable our opted in
|
||||
if ( te instanceof IMovableTile )
|
||||
{
|
||||
Valid.put( myClass, dsh );
|
||||
return dsh;
|
||||
}
|
||||
|
||||
// if you are on the white list your opted in.
|
||||
for (Class<? extends TileEntity> testClass : test)
|
||||
{
|
||||
if ( testClass.isAssignableFrom( myClass ) )
|
||||
{
|
||||
Valid.put( myClass, dsh );
|
||||
return dsh;
|
||||
}
|
||||
}
|
||||
|
||||
Valid.put( myClass, nullHandler );
|
||||
return nullHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean askToMove(TileEntity te)
|
||||
{
|
||||
Class myClass = te.getClass();
|
||||
IMovableHandler canMove = Valid.get( myClass );
|
||||
|
||||
if ( canMove == null )
|
||||
canMove = testClass( myClass, te );
|
||||
|
||||
if ( canMove != nullHandler )
|
||||
{
|
||||
if ( te instanceof IMovableTile )
|
||||
((IMovableTile) te).prepareToMove();
|
||||
|
||||
te.invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doneMoving(TileEntity te)
|
||||
{
|
||||
if ( te instanceof IMovableTile )
|
||||
{
|
||||
IMovableTile mt = (IMovableTile) te;
|
||||
mt.doneMoving();
|
||||
}
|
||||
}
|
||||
|
||||
@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." ) );
|
||||
}
|
||||
|
||||
test.add( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHandler(IMovableHandler han)
|
||||
{
|
||||
handlers.add( han );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableHandler getHandler(TileEntity te)
|
||||
{
|
||||
Class myClass = te.getClass();
|
||||
IMovableHandler h = Valid.get( myClass );
|
||||
return h == null ? dsh : h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableHandler getDefaultHandler()
|
||||
{
|
||||
return dsh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blacklistBlock(Block blk)
|
||||
{
|
||||
blacklisted.add( blk );
|
||||
}
|
||||
|
||||
public boolean isBlacklisted(Block blk)
|
||||
{
|
||||
return blacklisted.contains( blk );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.TunnelType;
|
||||
import appeng.api.definitions.Parts;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
||||
{
|
||||
|
||||
HashMap<ItemStack, TunnelType> Tunnels = new HashMap();
|
||||
|
||||
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()
|
||||
{
|
||||
/**
|
||||
* light!
|
||||
*/
|
||||
addNewAttunement( new ItemStack( Blocks.torch ), TunnelType.LIGHT );
|
||||
addNewAttunement( new ItemStack( Blocks.glowstone ), TunnelType.LIGHT );
|
||||
|
||||
/**
|
||||
* attune based on most redstone base items.
|
||||
*/
|
||||
addNewAttunement( new ItemStack( Items.redstone ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Items.repeater ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.redstone_lamp ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.unpowered_comparator ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.powered_comparator ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.powered_repeater ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.unpowered_repeater ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.daylight_detector ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.redstone_wire ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.redstone_block ), TunnelType.REDSTONE );
|
||||
addNewAttunement( new ItemStack( Blocks.lever ), TunnelType.REDSTONE );
|
||||
addNewAttunement( getModItem( "EnderIO", "itemRedstoneConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.REDSTONE );
|
||||
|
||||
/**
|
||||
* attune based on lots of random item related stuff
|
||||
*/
|
||||
appeng.api.definitions.Blocks AEBlocks = AEApi.instance().blocks();
|
||||
Parts Parts = AEApi.instance().parts();
|
||||
|
||||
addNewAttunement( AEBlocks.blockInterface.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( Parts.partInterface.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( Parts.partStorageBus.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( Parts.partImportBus.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( Parts.partExportBus.stack( 1 ), TunnelType.ITEM );
|
||||
addNewAttunement( new ItemStack( Blocks.hopper ), TunnelType.ITEM );
|
||||
addNewAttunement( new ItemStack( Blocks.chest ), TunnelType.ITEM );
|
||||
addNewAttunement( new ItemStack( Blocks.trapped_chest ), TunnelType.ITEM );
|
||||
addNewAttunement( getModItem( "ExtraUtilities", "extractor_base", 0 ), TunnelType.ITEM );
|
||||
addNewAttunement( getModItem( "Mekanism", "PartTransmitter", 9 ), TunnelType.ITEM );
|
||||
addNewAttunement( getModItem( "EnderIO", "itemItemConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.ITEM );
|
||||
|
||||
/**
|
||||
* attune based on lots of random item related stuff
|
||||
*/
|
||||
addNewAttunement( new ItemStack( Items.bucket ), TunnelType.FLUID );
|
||||
addNewAttunement( new ItemStack( Items.lava_bucket ), TunnelType.FLUID );
|
||||
addNewAttunement( new ItemStack( Items.milk_bucket ), TunnelType.FLUID );
|
||||
addNewAttunement( new ItemStack( Items.water_bucket ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "Mekanism", "MachineBlock2", 11 ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "Mekanism", "PartTransmitter", 4 ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "ExtraUtilities", "extractor_base", 6 ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "ExtraUtilities", "drum", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
||||
addNewAttunement( getModItem( "EnderIO", "itemLiquidConduit", OreDictionary.WILDCARD_VALUE ), TunnelType.FLUID );
|
||||
|
||||
for (AEColor c : AEColor.values())
|
||||
{
|
||||
addNewAttunement( Parts.partCableGlass.stack( c, 1 ), TunnelType.ME );
|
||||
addNewAttunement( Parts.partCableCovered.stack( c, 1 ), TunnelType.ME );
|
||||
addNewAttunement( Parts.partCableSmart.stack( c, 1 ), TunnelType.ME );
|
||||
addNewAttunement( Parts.partCableDense.stack( c, 1 ), TunnelType.ME );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewAttunement(ItemStack trigger, TunnelType type)
|
||||
{
|
||||
if ( type == null || trigger == null )
|
||||
return;
|
||||
|
||||
Tunnels.put( trigger, type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TunnelType getTunnelTypeByItem(ItemStack trigger)
|
||||
{
|
||||
if ( trigger != null )
|
||||
{
|
||||
if ( FluidContainerRegistry.isContainer( trigger ) )
|
||||
return TunnelType.FLUID;
|
||||
|
||||
for (ItemStack is : Tunnels.keySet())
|
||||
{
|
||||
if ( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
|
||||
return Tunnels.get( is );
|
||||
|
||||
if ( Platform.isSameItem( is, trigger ) )
|
||||
return Tunnels.get( is );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.api.features.IPlayerRegistry;
|
||||
import appeng.core.WorldSettings;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class PlayerRegistry implements IPlayerRegistry
|
||||
{
|
||||
|
||||
@Override
|
||||
public int getID(GameProfile username)
|
||||
{
|
||||
return WorldSettings.getInstance().getPlayerID( username );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID(EntityPlayer player)
|
||||
{
|
||||
return WorldSettings.getInstance().getPlayerID( player.getGameProfile() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer findPlayer(int playerID)
|
||||
{
|
||||
return WorldSettings.getInstance().getPlayerFromID( playerID );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import appeng.api.features.IRecipeHandlerRegistry;
|
||||
import appeng.api.recipes.ICraftHandler;
|
||||
import appeng.api.recipes.IRecipeHandler;
|
||||
import appeng.api.recipes.ISubItemResolver;
|
||||
import appeng.core.AELog;
|
||||
import appeng.recipes.RecipeHandler;
|
||||
|
||||
public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
|
||||
{
|
||||
|
||||
HashMap<String, Class<? extends ICraftHandler>> handlers = new HashMap<String, Class<? extends ICraftHandler>>();
|
||||
LinkedList<ISubItemResolver> resolvers = new LinkedList<ISubItemResolver>();
|
||||
|
||||
@Override
|
||||
public void addNewCraftHandler(String name, Class<? extends ICraftHandler> handler)
|
||||
{
|
||||
handlers.put( name.toLowerCase(), handler );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftHandler getCraftHandlerFor(String name)
|
||||
{
|
||||
Class<? extends ICraftHandler> clz = handlers.get( name );
|
||||
if ( clz == null )
|
||||
return null;
|
||||
try
|
||||
{
|
||||
return clz.newInstance();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.severe( "Error Caused when trying to construct " + clz.getName() );
|
||||
AELog.error( e );
|
||||
handlers.put( name, null ); // clear it..
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeHandler createNewRecipehandler()
|
||||
{
|
||||
return new RecipeHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewSubItemResolver(ISubItemResolver sir)
|
||||
{
|
||||
resolvers.add( sir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveItem(String nameSpace, String itemName)
|
||||
{
|
||||
for (ISubItemResolver sir : resolvers)
|
||||
{
|
||||
Object rr = null;
|
||||
|
||||
try
|
||||
{
|
||||
rr = sir.resolveItemByName( nameSpace, itemName );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
AELog.error( t );
|
||||
}
|
||||
|
||||
if ( rr != null )
|
||||
return rr;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import appeng.api.features.IGrinderRegistry;
|
||||
import appeng.api.features.ILocatableRegistry;
|
||||
import appeng.api.features.IMatterCannonAmmoRegistry;
|
||||
import appeng.api.features.IP2PTunnelRegistry;
|
||||
import appeng.api.features.IPlayerRegistry;
|
||||
import appeng.api.features.IRecipeHandlerRegistry;
|
||||
import appeng.api.features.IRegistryContainer;
|
||||
import appeng.api.features.ISpecialComparisonRegistry;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.api.features.IWorldGen;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.api.storage.ICellRegistry;
|
||||
import appeng.api.storage.IExternalStorageRegistry;
|
||||
|
||||
public class RegistryContainer implements IRegistryContainer
|
||||
{
|
||||
|
||||
private GrinderRecipeManager GrinderRecipes = new GrinderRecipeManager();
|
||||
private ExternalStorageRegistry ExternalStorageHandlers = new ExternalStorageRegistry();
|
||||
private CellRegistry CellRegistry = new CellRegistry();
|
||||
private LocatableRegistry LocatableRegistry = new LocatableRegistry();
|
||||
private SpecialComparisonRegistry SpecialComparisonRegistry = new SpecialComparisonRegistry();
|
||||
private WirelessRegistry WirelessRegistry = new WirelessRegistry();
|
||||
private GridCacheRegistry GridCacheRegistry = new GridCacheRegistry();
|
||||
private P2PTunnelRegistry P2PRegistry = new P2PTunnelRegistry();
|
||||
private MovableTileRegistry MovableReg = new MovableTileRegistry();
|
||||
private MatterCannonAmmoRegistry matterCannonReg = new MatterCannonAmmoRegistry();
|
||||
private PlayerRegistry playerreg = new PlayerRegistry();
|
||||
private IRecipeHandlerRegistry recipeReg = new RecipeHandlerRegistry();
|
||||
|
||||
@Override
|
||||
public IWirelessTermRegistry wireless()
|
||||
{
|
||||
return WirelessRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICellRegistry cell()
|
||||
{
|
||||
return CellRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGrinderRegistry grinder()
|
||||
{
|
||||
return GrinderRecipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpecialComparisonRegistry specialComparison()
|
||||
{
|
||||
return SpecialComparisonRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExternalStorageRegistry externalStorage()
|
||||
{
|
||||
return ExternalStorageHandlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILocatableRegistry locatable()
|
||||
{
|
||||
return LocatableRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridCacheRegistry gridCache()
|
||||
{
|
||||
return GridCacheRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMovableRegistry movable()
|
||||
{
|
||||
return MovableReg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IP2PTunnelRegistry p2pTunnel()
|
||||
{
|
||||
return P2PRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMatterCannonAmmoRegistry matterCannon()
|
||||
{
|
||||
return matterCannonReg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayerRegistry players()
|
||||
{
|
||||
return playerreg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeHandlerRegistry recipes()
|
||||
{
|
||||
return recipeReg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorldGen worldgen()
|
||||
{
|
||||
return WorldGenRegistry.instance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IItemComparisonProvider;
|
||||
import appeng.api.features.IItemComparison;
|
||||
import appeng.api.features.ISpecialComparisonRegistry;
|
||||
|
||||
public class SpecialComparisonRegistry implements ISpecialComparisonRegistry
|
||||
{
|
||||
|
||||
private List<IItemComparisonProvider> CompRegistry;
|
||||
|
||||
public SpecialComparisonRegistry() {
|
||||
CompRegistry = new ArrayList<IItemComparisonProvider>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemComparison getSpecialComparison(ItemStack stack)
|
||||
{
|
||||
for (IItemComparisonProvider i : CompRegistry)
|
||||
{
|
||||
IItemComparison comp = i.getComparison( stack );
|
||||
if ( comp != null )
|
||||
{
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComparisonProvider(IItemComparisonProvider prov)
|
||||
{
|
||||
CompRegistry.add( prov );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class WirelessRangeResult
|
||||
{
|
||||
|
||||
public WirelessRangeResult(TileEntity t, float d) {
|
||||
dist = d;
|
||||
te = t;
|
||||
}
|
||||
|
||||
final public float dist;
|
||||
final public TileEntity te;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessRegistry implements IWirelessTermRegistry
|
||||
{
|
||||
|
||||
List<IWirelessTermHandler> handlers;
|
||||
|
||||
public WirelessRegistry() {
|
||||
handlers = new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWirelessHandler(IWirelessTermHandler handler)
|
||||
{
|
||||
if ( handler != null )
|
||||
handlers.add( handler );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWirelessTerminal(ItemStack is)
|
||||
{
|
||||
for (IWirelessTermHandler h : handlers)
|
||||
{
|
||||
if ( h.canHandle( is ) )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWirelessTermHandler getWirelessTerminalHandler(ItemStack is)
|
||||
{
|
||||
for (IWirelessTermHandler h : handlers)
|
||||
{
|
||||
if ( h.canHandle( is ) )
|
||||
return h;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openWirelessTerminalGui(ItemStack item, World w, EntityPlayer player)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
IWirelessTermHandler handler = getWirelessTerminalHandler( item );
|
||||
if ( handler == null )
|
||||
{
|
||||
player.addChatMessage( new ChatComponentText( "Item is not a wireless terminal." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( handler.hasPower( player, 0.5, item ) )
|
||||
{
|
||||
Platform.openGUI( player, null, null, GuiBridge.GUI_WIRELESS_TERM );
|
||||
}
|
||||
else
|
||||
player.addChatMessage( PlayerMessages.DeviceNotPowered.get() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package appeng.core.features.registries;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import appeng.api.features.IWorldGen;
|
||||
|
||||
public class WorldGenRegistry implements IWorldGen
|
||||
{
|
||||
|
||||
private class TypeSet
|
||||
{
|
||||
|
||||
HashSet<Class<? extends WorldProvider>> badProviders = new HashSet();
|
||||
HashSet<Integer> badDimensions = new HashSet();
|
||||
|
||||
};
|
||||
|
||||
TypeSet[] types;
|
||||
|
||||
static final public WorldGenRegistry instance = new WorldGenRegistry();
|
||||
|
||||
private WorldGenRegistry() {
|
||||
|
||||
types = new TypeSet[WorldGenType.values().length];
|
||||
|
||||
for (WorldGenType type : WorldGenType.values())
|
||||
{
|
||||
types[type.ordinal()] = new TypeSet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldGenEnabled(WorldGenType type, World w)
|
||||
{
|
||||
if ( type == null )
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
|
||||
if ( w == null )
|
||||
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||
|
||||
if ( types[type.ordinal()].badProviders.contains( w.provider.getClass() ) || types[type.ordinal()].badDimensions.contains( w.provider.dimensionId ) )
|
||||
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 )
|
||||
throw new IllegalArgumentException( "Bad Provider Passed" );
|
||||
|
||||
types[type.ordinal()].badProviders.add( provider );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableWorldGenForDimension(WorldGenType type, int dimid)
|
||||
{
|
||||
if ( type == null )
|
||||
throw new IllegalArgumentException( "Bad Type Passed" );
|
||||
|
||||
types[type.ordinal()].badDimensions.add( dimid );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.features.IGrinderEntry;
|
||||
|
||||
public class AppEngGrinderRecipe implements IGrinderEntry
|
||||
{
|
||||
|
||||
private ItemStack in;
|
||||
private ItemStack out;
|
||||
|
||||
private float optionalChance;
|
||||
private ItemStack optionalOutput;
|
||||
|
||||
private float optionalChance2;
|
||||
private ItemStack optionalOutput2;
|
||||
|
||||
private int energy;
|
||||
|
||||
public AppEngGrinderRecipe(ItemStack a, ItemStack b, int cost) {
|
||||
in = a;
|
||||
out = b;
|
||||
energy = cost;
|
||||
}
|
||||
|
||||
public AppEngGrinderRecipe(ItemStack a, ItemStack b, ItemStack c, float chance, int cost) {
|
||||
in = a;
|
||||
out = b;
|
||||
|
||||
optionalOutput = c;
|
||||
optionalChance = chance;
|
||||
|
||||
energy = cost;
|
||||
}
|
||||
|
||||
public AppEngGrinderRecipe(ItemStack a, ItemStack b, ItemStack c, ItemStack d, float chance, float chance2, int cost) {
|
||||
in = a;
|
||||
out = b;
|
||||
|
||||
optionalOutput = c;
|
||||
optionalChance = chance;
|
||||
|
||||
optionalOutput2 = d;
|
||||
optionalChance2 = chance2;
|
||||
|
||||
energy = cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getInput()
|
||||
{
|
||||
return in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInput(ItemStack i)
|
||||
{
|
||||
in = i.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutput()
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutput(ItemStack o)
|
||||
{
|
||||
out = o.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyCost()
|
||||
{
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergyCost(int c)
|
||||
{
|
||||
energy = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOptionalOutput()
|
||||
{
|
||||
return optionalOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionalOutput(ItemStack output, float chance)
|
||||
{
|
||||
optionalOutput = output.copy();
|
||||
optionalChance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getOptionalChance()
|
||||
{
|
||||
return optionalChance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSecondOptionalOutput()
|
||||
{
|
||||
return optionalOutput2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondOptionalOutput(ItemStack output, float chance)
|
||||
{
|
||||
optionalChance2 = chance;
|
||||
optionalOutput2 = output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSecondOptionalChance()
|
||||
{
|
||||
return optionalChance2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.storage.CellInventory;
|
||||
import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BasicCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isCell(ItemStack is)
|
||||
{
|
||||
return CellInventory.isCell( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel channel)
|
||||
{
|
||||
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()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Light.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Medium()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Medium.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)
|
||||
{
|
||||
if ( handler instanceof CellInventoryHandler )
|
||||
{
|
||||
CellInventoryHandler ci = (CellInventoryHandler) handler;
|
||||
return ci.getStatusForCell();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain(ItemStack is, IMEInventory handler)
|
||||
{
|
||||
ICellInventory inv = ((ICellInventoryHandler) handler).getCellInv();
|
||||
return inv.getIdleDrain();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.storage.ItemCreativeStorageCell;
|
||||
import appeng.me.storage.CreativeCellInventory;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CreativeCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isCell(ItemStack is)
|
||||
{
|
||||
return is != null && is.getItem() instanceof ItemCreativeStorageCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack is, ISaveProvider container, StorageChannel channel)
|
||||
{
|
||||
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()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Light.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Medium()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Medium.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getTopTexture_Dark()
|
||||
{
|
||||
return ExtraBlockTextures.BlockMEChestItems_Dark.getIcon();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package appeng.core.features.registries.entries;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
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)
|
||||
{
|
||||
return channel == StorageChannel.ITEMS && te instanceof IInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src)
|
||||
{
|
||||
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( (IInventory) te, d );
|
||||
|
||||
if ( channel == StorageChannel.ITEMS && ad != null )
|
||||
return new MEMonitorIInventory( ad );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package appeng.core.localization;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public enum ButtonToolTips
|
||||
{
|
||||
PowerUnits, IOMode, CondenserOutput, RedstoneMode, MatchingFuzzy,
|
||||
|
||||
MatchingMode, TransferDirection, SortOrder, SortBy, View,
|
||||
|
||||
PartitionStorage, Clear, FuzzyMode, OperationMode, TrashController,
|
||||
|
||||
InterfaceBlockingMode, InterfaceCraftingMode, Trash, MatterBalls,
|
||||
|
||||
Singularity, Read, Write, ReadWrite, AlwaysActive,
|
||||
|
||||
ActiveWithoutSignal, ActiveWithSignal, ActiveOnPulse,
|
||||
|
||||
EmitLevelsBelow, EmitLevelAbove, MatchingExact, TransferToNetwork,
|
||||
|
||||
TransferToStorageCell, ToggleSortDirection, SearchMode_Auto,
|
||||
|
||||
SearchMode_Standard, SearchMode_NEIAuto, SearchMode_NEIStandard,
|
||||
|
||||
SearchMode, ItemName, NumberOfItems, PartitionStorageHint,
|
||||
|
||||
ClearSettings, StoredItems, StoredCraftable, Craftable,
|
||||
|
||||
FZPercent_25, FZPercent_50, FZPercent_75, FZPercent_99, FZIgnoreAll,
|
||||
|
||||
MoveWhenEmpty, MoveWhenWorkIsDone, MoveWhenFull, Disabled, Enable,
|
||||
|
||||
Blocking, NonBlocking,
|
||||
|
||||
LevelType, LevelType_Energy, LevelType_Item, InventoryTweaks, TerminalStyle, TerminalStyle_Full, TerminalStyle_Tall, TerminalStyle_Small,
|
||||
|
||||
Stash, StashDesc, Encode, EncodeDescription, Substitutions, SubstitutionsOn, SubstitutionsOff, SubstitutionsDesc, CraftOnly, CraftEither,
|
||||
|
||||
Craft, Mod, DoesntDespawn, EmitterMode, CraftViaRedstone, EmitWhenCrafting, ReportInaccessibleItems, ReportInaccessibleItemsYes, ReportInaccessibleItemsNo;
|
||||
|
||||
String root;
|
||||
|
||||
ButtonToolTips() {
|
||||
root = "gui.tooltips.appliedenergistics2";
|
||||
}
|
||||
|
||||
ButtonToolTips(String r) {
|
||||
root = r;
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
{
|
||||
return root + "." + toString();
|
||||
}
|
||||
|
||||
public String getLocal()
|
||||
{
|
||||
return StatCollector.translateToLocal( getUnlocalized() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package appeng.core.localization;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public enum GuiText
|
||||
{
|
||||
inventory("container"), // mc's default Inventory localization.
|
||||
|
||||
Chest, StoredEnergy, Of, Condenser, Drive, GrindStone, SkyChest,
|
||||
|
||||
VibrationChamber, SpatialIOPort, LevelEmitter, Terminal,
|
||||
|
||||
Interface, Config, StoredItems, Patterns, ImportBus, ExportBus,
|
||||
|
||||
CellWorkbench, NetworkDetails, StorageCells, IOBuses,
|
||||
|
||||
IOPort, BytesUsed, Types, QuantumLinkChamber, PortableCell,
|
||||
|
||||
NetworkTool, PowerUsageRate, PowerInputRate, Installed, EnergyDrain,
|
||||
|
||||
StorageBus, Priority, Security, Encoded, Blank, Unlinked, Linked,
|
||||
|
||||
SecurityCardEditor, NoPermissions, WirelessTerminal, Wireless,
|
||||
|
||||
CraftingTerminal, FormationPlane, Inscriber, QuartzCuttingKnife,
|
||||
|
||||
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel,
|
||||
|
||||
StoredSize, CopyMode, CopyModeDesc, PatternTerminal, CraftingPattern,
|
||||
|
||||
ProcessingPattern, Crafts, Creates, And, With, MolecularAssembler,
|
||||
|
||||
StoredPower, MaxPower, RequiredPower, Efficiency, InWorldCrafting,
|
||||
|
||||
inWorldFluix, inWorldPurificationCertus, inWorldPurificationNether,
|
||||
|
||||
inWorldPurificationFluix, inWorldSingularity, ChargedQuartz, OfSecondOutput,
|
||||
|
||||
NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty,
|
||||
|
||||
ConfirmCrafting, Stored, Crafting, Scheduled, CraftingStatus, Cancel,
|
||||
|
||||
FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes,
|
||||
|
||||
CraftingCPU, Automatic, CoProcessors, Simulation, Missing,
|
||||
|
||||
InterfaceTerminal, NoCraftingCPUs, LightTunnel, Clean, InvalidPattern,
|
||||
|
||||
InterfaceTerminalHint, Range, TransparentFacades, TransparentFacadesHint,
|
||||
|
||||
NoCraftingJobs, CPUs, FacadeCrafting, inWorldCraftingPresses, ChargedQuartzFind,
|
||||
|
||||
Included, Excluded, Partitioned, Precise, Fuzzy;
|
||||
|
||||
String root;
|
||||
|
||||
GuiText() {
|
||||
root = "gui.appliedenergistics2";
|
||||
}
|
||||
|
||||
GuiText(String r) {
|
||||
root = r;
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
{
|
||||
return root + "." + toString();
|
||||
}
|
||||
|
||||
public String getLocal()
|
||||
{
|
||||
return StatCollector.translateToLocal( getUnlocalized() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package appeng.core.localization;
|
||||
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public enum PlayerMessages
|
||||
{
|
||||
ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, MachineNotPowered,
|
||||
|
||||
isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError, OutOfRange, DeviceNotPowered, SettingCleared;
|
||||
|
||||
String getName()
|
||||
{
|
||||
return "chat.appliedenergistics2." + toString();
|
||||
}
|
||||
|
||||
public IChatComponent get()
|
||||
{
|
||||
return new ChatComponentTranslation( getName() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package appeng.core.localization;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public enum WailaText
|
||||
{
|
||||
|
||||
DeviceOnline, DeviceOffline, DeviceMissingChannel,
|
||||
|
||||
Locked, Unlocked, Showing,
|
||||
|
||||
Contains, Channels;
|
||||
|
||||
String root;
|
||||
|
||||
WailaText() {
|
||||
root = "waila.appliedenergistics2";
|
||||
}
|
||||
|
||||
WailaText(String r) {
|
||||
root = r;
|
||||
}
|
||||
|
||||
public String getUnlocalized()
|
||||
{
|
||||
return root + "." + toString();
|
||||
}
|
||||
|
||||
public String getLocal()
|
||||
{
|
||||
return StatCollector.translateToLocal( getUnlocalized() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package appeng.core.settings;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
public enum TickRates
|
||||
{
|
||||
|
||||
Interface(5, 120),
|
||||
|
||||
ImportBus(5, 40),
|
||||
|
||||
ExportBus(5, 60),
|
||||
|
||||
AnnihilationPlane(2, 120),
|
||||
|
||||
MJTunnel(1, 20),
|
||||
|
||||
METunnel(5, 20),
|
||||
|
||||
Inscriber(1, 1),
|
||||
|
||||
IOPort(1, 5),
|
||||
|
||||
VibrationChamber(10, 40),
|
||||
|
||||
StorageBus(5, 60),
|
||||
|
||||
ItemTunnel(5, 60),
|
||||
|
||||
LightTunnel(5, 120);
|
||||
|
||||
public int min;
|
||||
public int max;
|
||||
|
||||
private TickRates(int min, int max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
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." );
|
||||
min = config.get( "TickRates", name() + ".min", min ).getInt( min );
|
||||
max = config.get( "TickRates", name() + ".max", max ).getInt( max );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package appeng.core.stats;
|
||||
|
||||
public enum AchievementType
|
||||
{
|
||||
|
||||
Craft, CraftItem, Pickup, Custom
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package appeng.core.stats;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
|
||||
public enum Achievements
|
||||
{
|
||||
|
||||
// done
|
||||
Compass(-2, -4, AEApi.instance().blocks().blockSkyCompass, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
Presses(-2, -2, AEApi.instance().materials().materialLogicProcessorPress, AchievementType.Custom),
|
||||
|
||||
// done
|
||||
SpatialIO(-4, -4, AEApi.instance().blocks().blockSpatialIOPort, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
SpatialIOExplorer(-4, -2, AEApi.instance().items().itemSpatialCell128, AchievementType.Custom),
|
||||
|
||||
// done
|
||||
StorageCell(-6, -4, AEApi.instance().items().itemCell64k, AchievementType.CraftItem),
|
||||
|
||||
// done
|
||||
IOPort(-6, -2, AEApi.instance().blocks().blockIOPort, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
CraftingTerminal(-8, -4, AEApi.instance().parts().partCraftingTerminal, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
PatternTerminal(-8, -2, AEApi.instance().parts().partPatternTerminal, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
ChargedQuartz(0, -4, AEApi.instance().materials().materialCertusQuartzCrystalCharged, AchievementType.Pickup),
|
||||
|
||||
// done
|
||||
Fluix(0, -2, AEApi.instance().materials().materialFluixCrystal, AchievementType.Pickup),
|
||||
|
||||
// done
|
||||
Charger(0, 0, AEApi.instance().blocks().blockCharger, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
CrystalGrowthAccelerator(-2, 0, AEApi.instance().blocks().blockQuartzGrowthAccelerator, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
GlassCable(2, 0, AEApi.instance().parts().partCableGlass, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
Networking1(4, -6, AEApi.instance().parts().partCableCovered, AchievementType.Custom),
|
||||
|
||||
// done
|
||||
Controller(4, -4, AEApi.instance().blocks().blockController, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
Networking2(4, 0, AEApi.instance().parts().partCableSmart, AchievementType.Custom),
|
||||
|
||||
// done
|
||||
Networking3(4, 2, AEApi.instance().parts().partCableDense, AchievementType.Custom),
|
||||
|
||||
// done
|
||||
P2P(2, -2, AEApi.instance().parts().partP2PTunnelME, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
Recursive(6, -2, AEApi.instance().blocks().blockInterface, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
CraftingCPU(6, 0, AEApi.instance().blocks().blockCraftingStorage64k, AchievementType.CraftItem),
|
||||
|
||||
// done
|
||||
Facade(6, 2, ((ItemFacade) AEApi.instance().items().itemFacade.item()).createFacadeForItem( new ItemStack( Blocks.iron_block ), false ),
|
||||
AchievementType.CraftItem),
|
||||
|
||||
// done
|
||||
NetworkTool(8, 0, AEApi.instance().items().itemNetworkTool, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
PortableCell(8, 2, AEApi.instance().items().itemPortableCell, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
StorageBus(10, 0, AEApi.instance().parts().partStorageBus, AchievementType.Craft),
|
||||
|
||||
// done
|
||||
QNB(10, 2, AEApi.instance().blocks().blockQuantumLink, AchievementType.Craft);
|
||||
|
||||
public final ItemStack stack;
|
||||
public final AchievementType type;
|
||||
private final int x, y;
|
||||
|
||||
private Achievement parent;
|
||||
private Achievement stat;
|
||||
|
||||
public void setParent(Achievements parent)
|
||||
{
|
||||
this.parent = parent.getAchievement();
|
||||
}
|
||||
|
||||
public Achievement getAchievement()
|
||||
{
|
||||
if ( stat == null && stack != null )
|
||||
{
|
||||
stat = new Achievement( "achievement.ae2." + name(), "ae2." + name(), x, y, stack, parent );
|
||||
stat.registerStat();
|
||||
}
|
||||
|
||||
return stat;
|
||||
}
|
||||
|
||||
private Achievements(int x, int y, AEColoredItemDefinition which, AchievementType type)
|
||||
{
|
||||
stack = which.stack( AEColor.Transparent, 1 );
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
private Achievements(int x, int y, AEItemDefinition which, AchievementType type)
|
||||
{
|
||||
stack = which.stack( 1 );
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
private Achievements(int x, int y, ItemStack which, AchievementType type)
|
||||
{
|
||||
stack = which;
|
||||
this.type = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void addToPlayer(EntityPlayer player)
|
||||
{
|
||||
player.addStat( getAchievement(), 1 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package appeng.core.stats;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraftforge.common.AchievementPage;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
|
||||
public class PlayerStatsRegistration
|
||||
{
|
||||
|
||||
public final static PlayerStatsRegistration instance = new PlayerStatsRegistration();
|
||||
|
||||
AchievementPage ae2AchievementPage;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCrafting(PlayerEvent.ItemCraftedEvent event)
|
||||
{
|
||||
if ( notPlayer( event.player ) || event.crafting == null )
|
||||
return;
|
||||
|
||||
for (Achievements a : Achievements.values())
|
||||
{
|
||||
switch (a.type)
|
||||
{
|
||||
case Craft:
|
||||
if ( Platform.isSameItemPrecise( a.stack, event.crafting ) )
|
||||
{
|
||||
a.addToPlayer( event.player );
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case CraftItem:
|
||||
if ( a.stack.getItem().getClass() == event.crafting.getItem().getClass() )
|
||||
{
|
||||
a.addToPlayer( event.player );
|
||||
return;
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCrafting(PlayerEvent.ItemPickupEvent event)
|
||||
{
|
||||
if ( notPlayer( event.player ) || event.pickedUp == null || event.pickedUp.getEntityItem() == null )
|
||||
return;
|
||||
|
||||
ItemStack is = event.pickedUp.getEntityItem();
|
||||
|
||||
for (Achievements a : Achievements.values())
|
||||
{
|
||||
switch (a.type)
|
||||
{
|
||||
case Pickup:
|
||||
if ( Platform.isSameItemPrecise( a.stack, is ) )
|
||||
{
|
||||
a.addToPlayer( event.player );
|
||||
return;
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean notPlayer(EntityPlayer player)
|
||||
{
|
||||
if ( player == null || player.isDead || player instanceof FakePlayer )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign Parents and hierarchy.
|
||||
*/
|
||||
private void initHierarchy()
|
||||
{
|
||||
Achievements.Presses.setParent( Achievements.Compass );
|
||||
|
||||
Achievements.Fluix.setParent( Achievements.ChargedQuartz );
|
||||
|
||||
Achievements.Charger.setParent( Achievements.Fluix );
|
||||
|
||||
Achievements.CrystalGrowthAccelerator.setParent( Achievements.Charger );
|
||||
|
||||
Achievements.GlassCable.setParent( Achievements.Charger );
|
||||
|
||||
Achievements.SpatialIOExplorer.setParent( Achievements.SpatialIO );
|
||||
|
||||
Achievements.IOPort.setParent( Achievements.StorageCell );
|
||||
|
||||
Achievements.PatternTerminal.setParent( Achievements.CraftingTerminal );
|
||||
|
||||
Achievements.Controller.setParent( Achievements.Networking1 );
|
||||
|
||||
Achievements.Networking2.setParent( Achievements.Controller );
|
||||
|
||||
Achievements.Networking3.setParent( Achievements.Networking2 );
|
||||
|
||||
Achievements.P2P.setParent( Achievements.Controller );
|
||||
|
||||
Achievements.Recursive.setParent( Achievements.Controller );
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.Achievements ) )
|
||||
{
|
||||
FMLCommonHandler.instance().bus().register( this );
|
||||
initHierarchy();
|
||||
|
||||
for (Stats s : Stats.values())
|
||||
s.getStat();
|
||||
|
||||
/**
|
||||
* register
|
||||
*/
|
||||
ArrayList<Achievement> list = new ArrayList();
|
||||
|
||||
for (Achievements a : Achievements.values())
|
||||
{
|
||||
Achievement ach = a.getAchievement();
|
||||
if ( ach != null )
|
||||
list.add( ach );
|
||||
}
|
||||
|
||||
ae2AchievementPage = new AchievementPage( "Applied Energistics 2", list.toArray( new Achievement[list.size()] ) );
|
||||
AchievementPage.registerAchievementPage( ae2AchievementPage );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package appeng.core.stats;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.stats.StatBasic;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
|
||||
public enum Stats
|
||||
{
|
||||
|
||||
// done
|
||||
ItemsInserted,
|
||||
|
||||
// done
|
||||
ItemsExtracted,
|
||||
|
||||
// done
|
||||
TurnedCranks;
|
||||
|
||||
private StatBasic stat;
|
||||
|
||||
public StatBasic getStat()
|
||||
{
|
||||
if ( stat == null )
|
||||
{
|
||||
stat = new StatBasic( "stat.ae2." + name(), new ChatComponentTranslation( "stat.ae2." + name(), new Object[0] ) );
|
||||
stat.registerStat();
|
||||
}
|
||||
|
||||
return stat;
|
||||
}
|
||||
|
||||
private Stats() {
|
||||
}
|
||||
|
||||
public void addToPlayer(EntityPlayer player, int howMany)
|
||||
{
|
||||
player.addStat( getStat(), howMany );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package appeng.core.sync;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
public abstract class AppEngPacket
|
||||
{
|
||||
|
||||
private ByteBuf p;
|
||||
|
||||
AppEngPacketHandlerBase.PacketTypes id;
|
||||
|
||||
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 ( " + getPacketID() + " does not implement a server side handler." );
|
||||
}
|
||||
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
throw new RuntimeException( "This packet ( " + getPacketID() + " does not implement a client side handler." );
|
||||
}
|
||||
|
||||
protected void configureWrite(ByteBuf data)
|
||||
{
|
||||
data.capacity( data.readableBytes() );
|
||||
p = data;
|
||||
}
|
||||
|
||||
public FMLProxyPacket getProxy()
|
||||
{
|
||||
if ( p.array().length > 2 * 1024 * 1024 ) // 2k walking room :)
|
||||
throw new IllegalArgumentException( "Sorry AE2 made a " + p.array().length + " byte packet by accident!" );
|
||||
|
||||
FMLProxyPacket pp = new FMLProxyPacket( p, NetworkHandler.instance.getChannel() );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.PacketLogging ) )
|
||||
AELog.info( getClass().getName() + " : " + pp.payload().readableBytes() );
|
||||
|
||||
return pp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package appeng.core.sync;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.core.sync.packets.PacketCompassRequest;
|
||||
import appeng.core.sync.packets.PacketCompassResponse;
|
||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketLightning;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketMatterCannon;
|
||||
import appeng.core.sync.packets.PacketMockExplosion;
|
||||
import appeng.core.sync.packets.PacketMultiPart;
|
||||
import appeng.core.sync.packets.PacketNEIRecipe;
|
||||
import appeng.core.sync.packets.PacketNewStorageDimension;
|
||||
import appeng.core.sync.packets.PacketPaintedEntity;
|
||||
import appeng.core.sync.packets.PacketPartPlacement;
|
||||
import appeng.core.sync.packets.PacketPartialItem;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.core.sync.packets.PacketProgressBar;
|
||||
import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketTransitionEffect;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class AppEngPacketHandlerBase
|
||||
{
|
||||
|
||||
public static Map<Class, PacketTypes> reverseLookup = new HashMap<Class, AppEngPacketHandlerBase.PacketTypes>();
|
||||
|
||||
public enum PacketTypes
|
||||
{
|
||||
PACKET_COMPASS_REQUEST(PacketCompassRequest.class),
|
||||
|
||||
PACKET_COMPASS_RESPONSE(PacketCompassResponse.class),
|
||||
|
||||
PACKET_INVENTORY_ACTION(PacketInventoryAction.class),
|
||||
|
||||
PACKET_ME_INVENTORY_UPDATE(PacketMEInventoryUpdate.class),
|
||||
|
||||
PACKET_CONFIG_BUTTON(PacketConfigButton.class),
|
||||
|
||||
PACKET_MULTIPART(PacketMultiPart.class),
|
||||
|
||||
PACKET_PARTPLACEMENT(PacketPartPlacement.class),
|
||||
|
||||
PACKET_LIGHTNING(PacketLightning.class),
|
||||
|
||||
PACKET_MATTERCANNON(PacketMatterCannon.class),
|
||||
|
||||
PACKET_MOCKEXPLOSION(PacketMockExplosion.class),
|
||||
|
||||
PACKET_VALUE_CONFIG(PacketValueConfig.class),
|
||||
|
||||
PACKET_TRANSITION_EFFECT(PacketTransitionEffect.class),
|
||||
|
||||
PACKET_PROGRESS_VALUE(PacketProgressBar.class),
|
||||
|
||||
PACKET_CLICK(PacketClick.class),
|
||||
|
||||
PACKET_NEW_STORAGE_DIMENSION(PacketNewStorageDimension.class),
|
||||
|
||||
PACKET_SWITCH_GUIS(PacketSwitchGuis.class),
|
||||
|
||||
PACKET_SWAP_SLOTS(PacketSwapSlots.class),
|
||||
|
||||
PACKET_PATTERN_SLOT(PacketPatternSlot.class),
|
||||
|
||||
PACKET_RECIPE_NEI(PacketNEIRecipe.class),
|
||||
|
||||
PACKET_PARTIAL_ITEM(PacketPartialItem.class),
|
||||
|
||||
PACKET_CRAFTING_REQUEST(PacketCraftRequest.class),
|
||||
|
||||
PACKET_ASSEMBLER_ANIMATION(PacketAssemblerAnimation.class),
|
||||
|
||||
PACKET_COMPRESSED_NBT(PacketCompressedNBT.class),
|
||||
|
||||
PACKET_PAINTED_ENTITY(PacketPaintedEntity.class);
|
||||
|
||||
final public Class pc;
|
||||
final public Constructor con;
|
||||
|
||||
private PacketTypes(Class c) {
|
||||
pc = c;
|
||||
|
||||
Constructor x = null;
|
||||
try
|
||||
{
|
||||
x = pc.getConstructor( ByteBuf.class );
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
}
|
||||
catch (SecurityException e)
|
||||
{
|
||||
}
|
||||
|
||||
con = x;
|
||||
AppEngPacketHandlerBase.reverseLookup.put( pc, this );
|
||||
|
||||
if ( con == null )
|
||||
throw new RuntimeException( "Invalid Packet Class, must be constructable on DataInputStream" );
|
||||
}
|
||||
|
||||
public AppEngPacket parsePacket(ByteBuf in) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
||||
{
|
||||
return (AppEngPacket) con.newInstance( in );
|
||||
}
|
||||
|
||||
public static PacketTypes getPacket(int id)
|
||||
{
|
||||
return (values())[id];
|
||||
}
|
||||
|
||||
public static PacketTypes getID(Class<? extends AppEngPacket> c)
|
||||
{
|
||||
return AppEngPacketHandlerBase.reverseLookup.get( c );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,497 @@
|
||||
package appeng.core.sync;
|
||||
|
||||
import static appeng.core.sync.GuiHostType.ITEM;
|
||||
import static appeng.core.sync.GuiHostType.ITEM_OR_WORLD;
|
||||
import static appeng.core.sync.GuiHostType.WORLD;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.definitions.Materials;
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.gui.GuiNull;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.container.implementations.ContainerCondenser;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
import appeng.container.implementations.ContainerGrinder;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.container.implementations.ContainerInterfaceTerminal;
|
||||
import appeng.container.implementations.ContainerLevelEmitter;
|
||||
import appeng.container.implementations.ContainerMAC;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.container.implementations.ContainerSecurity;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.container.implementations.ContainerSpatialIOPort;
|
||||
import appeng.container.implementations.ContainerStorageBus;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.container.implementations.ContainerWirelessTerm;
|
||||
import appeng.core.stats.Achievements;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartMonitor;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
public enum GuiBridge implements IGuiHandler
|
||||
{
|
||||
GUI_Handler(),
|
||||
|
||||
GUI_GRINDER(ContainerGrinder.class, TileGrinder.class, WORLD, null),
|
||||
|
||||
GUI_QNB(ContainerQNB.class, TileQuantumBridge.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_SKYCHEST(ContainerSkyChest.class, TileSkyChest.class, WORLD, null),
|
||||
|
||||
GUI_CHEST(ContainerChest.class, TileChest.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_WIRELESS(ContainerWireless.class, TileWireless.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_ME(ContainerMEMonitorable.class, ITerminalHost.class, WORLD, null),
|
||||
|
||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, ITEM, null),
|
||||
|
||||
GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, ITEM, null),
|
||||
|
||||
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, ITEM, null),
|
||||
|
||||
GUI_CRAFTING_CPU(ContainerCraftingCPU.class, TileCraftingTile.class, WORLD, SecurityPermissions.CRAFT),
|
||||
|
||||
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, ITEM, null),
|
||||
|
||||
GUI_QUARTZ_KNIFE(ContainerQuartzKnife.class, QuartzKnifeObj.class, ITEM, null),
|
||||
|
||||
GUI_DRIVE(ContainerDrive.class, TileDrive.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_VIBRATIONCHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class, WORLD, null),
|
||||
|
||||
GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class, WORLD, null),
|
||||
|
||||
GUI_INTERFACE(ContainerInterface.class, IInterfaceHost.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_BUS(ContainerUpgradeable.class, IUpgradeableHost.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_IOPORT(ContainerIOPort.class, TileIOPort.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_FPLANE(ContainerFormationPlane.class, PartFormationPlane.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_SECURITY(ContainerSecurity.class, TileSecurity.class, WORLD, SecurityPermissions.SECURITY),
|
||||
|
||||
GUI_CRAFTING_TERMINAL(ContainerCraftingTerm.class, PartCraftingTerminal.class, WORLD, SecurityPermissions.CRAFT),
|
||||
|
||||
GUI_PATTERN_TERMINAL(ContainerPatternTerm.class, PartPatternTerminal.class, WORLD, SecurityPermissions.CRAFT),
|
||||
|
||||
// extends (Container/Gui) + Bus
|
||||
GUI_LEVELEMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_SPATIALIOPORT(ContainerSpatialIOPort.class, TileSpatialIOPort.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_INSCRIBER(ContainerInscriber.class, TileInscriber.class, WORLD, null),
|
||||
|
||||
GUI_CELLWORKBENCH(ContainerCellWorkbench.class, TileCellWorkbench.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_CONFIRM(ContainerCraftConfirm.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT),
|
||||
|
||||
GUI_INTERFACE_TERMINAL(ContainerInterfaceTerminal.class, PartMonitor.class, WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_CRAFTING_STATUS(ContainerCraftingStatus.class, ITerminalHost.class, ITEM_OR_WORLD, SecurityPermissions.CRAFT);
|
||||
|
||||
private Class Tile;
|
||||
private Class Gui;
|
||||
private Class Container;
|
||||
private GuiHostType type;
|
||||
private SecurityPermissions requiredPermission;
|
||||
|
||||
private GuiBridge() {
|
||||
Tile = null;
|
||||
Gui = null;
|
||||
Container = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() )
|
||||
{
|
||||
String start = Container.getName();
|
||||
String GuiClass = start.replaceFirst( "container.", "client.gui." ).replace( ".Container", ".Gui" );
|
||||
if ( start.equals( GuiClass ) )
|
||||
throw new RuntimeException( "Unable to find gui class" );
|
||||
Gui = ReflectionHelper.getClass( this.getClass().getClassLoader(), GuiClass );
|
||||
if ( Gui == null )
|
||||
throw new RuntimeException( "Cannot Load class: " + GuiClass );
|
||||
}
|
||||
}
|
||||
|
||||
private GuiBridge(Class _Container, SecurityPermissions requiredPermission) {
|
||||
this.requiredPermission = requiredPermission;
|
||||
Container = _Container;
|
||||
Tile = null;
|
||||
getGui();
|
||||
}
|
||||
|
||||
private GuiBridge(Class _Container, Class _Tile, GuiHostType type, SecurityPermissions requiredPermission) {
|
||||
this.requiredPermission = requiredPermission;
|
||||
Container = _Container;
|
||||
this.type = type;
|
||||
Tile = _Tile;
|
||||
getGui();
|
||||
}
|
||||
|
||||
public boolean CorrectTileOrPart(Object tE)
|
||||
{
|
||||
if ( Tile == null )
|
||||
throw new RuntimeException( "This Gui Cannot use the standard Handler." );
|
||||
|
||||
return Tile.isInstance( tE );
|
||||
}
|
||||
|
||||
public Object ConstructContainer(InventoryPlayer inventory, ForgeDirection side, Object tE)
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor[] c = Container.getConstructors();
|
||||
if ( c.length == 0 )
|
||||
throw new AppEngException( "Invalid Gui Class" );
|
||||
|
||||
Constructor target = findConstructor( c, inventory, tE );
|
||||
|
||||
if ( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + 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();
|
||||
|
||||
Materials m = AEApi.instance().materials();
|
||||
if ( m.materialLogicProcessorPress.sameAsStack( is ) || m.materialEngProcessorPress.sameAsStack( is )
|
||||
|| m.materialCalcProcessorPress.sameAsStack( is ) || m.materialSiliconPress.sameAsStack( is ) )
|
||||
{
|
||||
Achievements.Presses.addToPlayer( inventory.player );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
public Object ConstructGui(InventoryPlayer inventory, ForgeDirection side, Object tE)
|
||||
{
|
||||
try
|
||||
{
|
||||
Constructor[] c = Gui.getConstructors();
|
||||
if ( c.length == 0 )
|
||||
throw new AppEngException( "Invalid Gui Class" );
|
||||
|
||||
Constructor target = findConstructor( c, inventory, tE );
|
||||
|
||||
if ( target == null )
|
||||
{
|
||||
throw new RuntimeException( "Cannot find " + Container.getName() + "( " + typeName( inventory ) + ", " + 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 )
|
||||
{
|
||||
AEBaseContainer bc = (AEBaseContainer) newContainer;
|
||||
bc.openContext = new ContainerOpenContext( myItem );
|
||||
bc.openContext.w = w;
|
||||
bc.openContext.x = x;
|
||||
bc.openContext.y = y;
|
||||
bc.openContext.z = z;
|
||||
bc.openContext.side = side;
|
||||
}
|
||||
|
||||
return newContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(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 istem = ((ID_ORDINAL >> 3) & 1) == 1;
|
||||
|
||||
if ( ID.type.isItem() && istem )
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
Object myItem = getGuiObject( it, player, w, x, y, z );
|
||||
if ( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||
return 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 updateGui( ID.ConstructContainer( player.inventory, side, part ), w, x, y, z, side, part );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ID.CorrectTileOrPart( TE ) )
|
||||
return 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 istem = ((ID_ORDINAL >> 3) & 1) == 1;
|
||||
|
||||
if ( ID.type.isItem() && istem )
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
Object myItem = getGuiObject( it, player, w, x, y, z );
|
||||
if ( ID.CorrectTileOrPart( myItem ) )
|
||||
return ID.ConstructGui( player.inventory, 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 ID.ConstructGui( player.inventory, side, part );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ID.CorrectTileOrPart( TE ) )
|
||||
return ID.ConstructGui( player.inventory, side, TE );
|
||||
}
|
||||
}
|
||||
|
||||
return new GuiNull( new ContainerNull() );
|
||||
}
|
||||
|
||||
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 ( type.isItem() )
|
||||
{
|
||||
ItemStack it = player.inventory.getCurrentItem();
|
||||
if ( it != null && it.getItem() instanceof IGuiItem )
|
||||
{
|
||||
Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z );
|
||||
if ( CorrectTileOrPart( myItem ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( type.isTile() )
|
||||
{
|
||||
TileEntity TE = w.getTileEntity( x, y, z );
|
||||
if ( TE instanceof IPartHost )
|
||||
{
|
||||
((IPartHost) TE).getPart( side );
|
||||
IPart part = ((IPartHost) TE).getPart( side );
|
||||
if ( CorrectTileOrPart( part ) )
|
||||
return securityCheck( part, player );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( CorrectTileOrPart( TE ) )
|
||||
return securityCheck( TE, player );
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean securityCheck(Object te, EntityPlayer player)
|
||||
{
|
||||
if ( te instanceof IActionHost && requiredPermission != null )
|
||||
{
|
||||
boolean requirePower = false;
|
||||
|
||||
IGridNode gn = ((IActionHost) te).getActionableNode();
|
||||
if ( gn != null )
|
||||
{
|
||||
IGrid g = gn.getGrid();
|
||||
if ( g != null )
|
||||
{
|
||||
if ( requirePower )
|
||||
{
|
||||
IEnergyGrid eg = g.getCache( IEnergyGrid.class );
|
||||
if ( !eg.isNetworkPowered() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ISecurityGrid sg = g.getCache( ISecurityGrid.class );
|
||||
if ( sg.hasPermission( player, requiredPermission ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public GuiHostType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package appeng.core.sync;
|
||||
|
||||
public enum GuiHostType
|
||||
{
|
||||
ITEM_OR_WORLD, ITEM, WORLD;
|
||||
|
||||
public boolean isItem()
|
||||
{
|
||||
return this != WORLD;
|
||||
}
|
||||
|
||||
public boolean isTile()
|
||||
{
|
||||
return this != ITEM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package appeng.core.sync.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.AppEngPacketHandlerBase;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
public class AppEngClientPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkInfo network, FMLProxyPacket packet, EntityPlayer player)
|
||||
{
|
||||
ByteBuf stream = packet.payload();
|
||||
int packetType = -1;
|
||||
|
||||
player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
try
|
||||
{
|
||||
packetType = stream.readInt();
|
||||
AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( stream );
|
||||
pack.clientPacketData( network, pack, player );
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package appeng.core.sync.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.AppEngPacketHandlerBase;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
public final class AppEngServerPacketHandler extends AppEngPacketHandlerBase implements IPacketHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onPacketData(INetworkInfo manager, FMLProxyPacket packet, EntityPlayer player)
|
||||
{
|
||||
ByteBuf stream = packet.payload();
|
||||
int packetType = -1;
|
||||
|
||||
try
|
||||
{
|
||||
packetType = stream.readInt();
|
||||
AppEngPacket pack = PacketTypes.getPacket( packetType ).parsePacket( stream );
|
||||
pack.serverPacketData( manager, pack, (EntityPlayer) player );
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package appeng.core.sync.network;
|
||||
|
||||
|
||||
public interface INetworkInfo
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package appeng.core.sync.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import appeng.core.WorldSettings;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
||||
import cpw.mods.fml.common.network.FMLEventChannel;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
public class NetworkHandler
|
||||
{
|
||||
|
||||
public static NetworkHandler instance;
|
||||
|
||||
final FMLEventChannel ec;
|
||||
final String myChannelName;
|
||||
|
||||
final IPacketHandler clientHandler;
|
||||
final IPacketHandler serveHandler;
|
||||
|
||||
public NetworkHandler(String channelName) {
|
||||
FMLCommonHandler.instance().bus().register( this );
|
||||
ec = NetworkRegistry.INSTANCE.newEventDrivenChannel( myChannelName = channelName );
|
||||
ec.register( this );
|
||||
|
||||
clientHandler = createClientSide();
|
||||
serveHandler = createServerSide();
|
||||
}
|
||||
|
||||
private IPacketHandler createServerSide()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new AppEngServerPacketHandler();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IPacketHandler createClientSide()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new AppEngClientPacketHandler();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConnection(ServerConnectionFromClientEvent ev)
|
||||
{
|
||||
WorldSettings.getInstance().sendToPlayer( ev.manager, null );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConnection(PlayerLoggedInEvent loginEvent)
|
||||
{
|
||||
if ( loginEvent.player instanceof EntityPlayerMP )
|
||||
WorldSettings.getInstance().sendToPlayer( null, (EntityPlayerMP) loginEvent.player );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverPacket(ServerCustomPacketEvent ev)
|
||||
{
|
||||
NetHandlerPlayServer srv = (NetHandlerPlayServer) ev.packet.handler();
|
||||
if ( serveHandler != null )
|
||||
serveHandler.onPacketData( null, ev.packet, srv.playerEntity );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clientPacket(ClientCustomPacketEvent ev)
|
||||
{
|
||||
if ( clientHandler != null )
|
||||
clientHandler.onPacketData( null, ev.packet, null );
|
||||
}
|
||||
|
||||
public String getChannel()
|
||||
{
|
||||
return myChannelName;
|
||||
}
|
||||
|
||||
public void sendToAll(AppEngPacket message)
|
||||
{
|
||||
ec.sendToAll( message.getProxy() );
|
||||
}
|
||||
|
||||
public void sendTo(AppEngPacket message, EntityPlayerMP player)
|
||||
{
|
||||
ec.sendTo( message.getProxy(), player );
|
||||
}
|
||||
|
||||
public void sendToAllAround(AppEngPacket message, NetworkRegistry.TargetPoint point)
|
||||
{
|
||||
ec.sendToAllAround( message.getProxy(), point );
|
||||
}
|
||||
|
||||
public void sendToDimension(AppEngPacket message, int dimensionId)
|
||||
{
|
||||
ec.sendToDimension( message.getProxy(), dimensionId );
|
||||
}
|
||||
|
||||
public void sendToServer(AppEngPacket message)
|
||||
{
|
||||
ec.sendToServer( message.getProxy() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketAssemblerAnimation extends AppEngPacket
|
||||
{
|
||||
|
||||
final public int x, y, z;
|
||||
final public byte rate;
|
||||
final public IAEItemStack is;
|
||||
|
||||
// automatic.
|
||||
public PacketAssemblerAnimation(ByteBuf stream) throws IOException {
|
||||
x = stream.readInt();
|
||||
y = stream.readInt();
|
||||
z = stream.readInt();
|
||||
rate = stream.readByte();
|
||||
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(), x + d0, y + d1, z + d2, this );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketAssemblerAnimation(int x, int y, int z, byte rate, IAEItemStack is) throws IOException {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( this.x = x );
|
||||
data.writeInt( this.y = y );
|
||||
data.writeInt( this.z = z );
|
||||
data.writeByte( this.rate = rate );
|
||||
is.writeToPacket( data );
|
||||
this.is = is;
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.items.tools.powered.ToolColorApplicator;
|
||||
|
||||
public class PacketClick extends AppEngPacket
|
||||
{
|
||||
|
||||
int x, y, z, side;
|
||||
float hitX, hitY, hitZ;
|
||||
|
||||
// automatic.
|
||||
public PacketClick(ByteBuf stream) throws IOException {
|
||||
x = stream.readInt();
|
||||
y = stream.readInt();
|
||||
z = stream.readInt();
|
||||
side = stream.readInt();
|
||||
hitX = stream.readFloat();
|
||||
hitY = stream.readFloat();
|
||||
hitZ = stream.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
ItemStack is = player.inventory.getCurrentItem();
|
||||
if ( is != null && is.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
ToolNetworkTool tnt = (ToolNetworkTool) is.getItem();
|
||||
tnt.serverSideToolLogic( is, player, player.worldObj, x, y, z, side, hitX, hitY, hitZ );
|
||||
}
|
||||
else if ( is != null && AEApi.instance().items().itemMemoryCard.sameAsStack( is ) )
|
||||
{
|
||||
IMemoryCard mem = (IMemoryCard) is.getItem();
|
||||
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
|
||||
is.setTagCompound( null );
|
||||
}
|
||||
else if ( is != null && AEApi.instance().items().itemColorApplicator.sameAsStack( 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) throws IOException {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( this.x = x );
|
||||
data.writeInt( this.y = y );
|
||||
data.writeInt( this.z = z );
|
||||
data.writeInt( this.side = side );
|
||||
data.writeFloat( this.hitX = hitX );
|
||||
data.writeFloat( this.hitY = hitY );
|
||||
data.writeFloat( this.hitZ = hitZ );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.WorldSettings;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.services.helpers.ICompassCallback;
|
||||
|
||||
public class PacketCompassRequest extends AppEngPacket implements ICompassCallback
|
||||
{
|
||||
|
||||
final public long attunement;
|
||||
final public int cx, cz, cdy;
|
||||
|
||||
EntityPlayer talkBackTo;
|
||||
|
||||
// automatic.
|
||||
public PacketCompassRequest(ByteBuf stream) throws IOException {
|
||||
attunement = stream.readLong();
|
||||
cx = stream.readInt();
|
||||
cz = stream.readInt();
|
||||
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) talkBackTo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
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) throws IOException {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeLong( this.attunement = attunement );
|
||||
data.writeInt( this.cx = cx );
|
||||
data.writeInt( this.cz = cz );
|
||||
data.writeInt( this.cdy = cdy );
|
||||
|
||||
configureWrite( data );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.hooks.CompassManager;
|
||||
import appeng.hooks.CompassResult;
|
||||
|
||||
public class PacketCompassResponse extends AppEngPacket
|
||||
{
|
||||
|
||||
final public long attunement;
|
||||
final public int cx, cz, cdy;
|
||||
|
||||
public CompassResult cr;
|
||||
|
||||
// automatic.
|
||||
public PacketCompassResponse(ByteBuf stream) throws IOException {
|
||||
attunement = stream.readLong();
|
||||
cx = stream.readInt();
|
||||
cz = stream.readInt();
|
||||
cdy = stream.readInt();
|
||||
|
||||
cr = new CompassResult( stream.readBoolean(), stream.readBoolean(), stream.readDouble() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
CompassManager.instance.postResult( attunement, cx << 4, cdy << 5, cz << 4, cr );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketCompassResponse(PacketCompassRequest req, boolean hasResult, boolean spin, double radians) {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeLong( this.attunement = req.attunement );
|
||||
data.writeInt( this.cx = req.cx );
|
||||
data.writeInt( this.cz = req.cz );
|
||||
data.writeInt( this.cdy = req.cdy );
|
||||
|
||||
data.writeBoolean( hasResult );
|
||||
data.writeBoolean( spin );
|
||||
data.writeDouble( radians );
|
||||
|
||||
configureWrite( data );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.client.gui.implementations.GuiInterfaceTerminal;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketCompressedNBT extends AppEngPacket
|
||||
{
|
||||
|
||||
// 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 {
|
||||
data = null;
|
||||
compressFrame = null;
|
||||
|
||||
GZIPInputStream gzReader = new GZIPInputStream( new InputStream() {
|
||||
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
{
|
||||
if ( stream.readableBytes() <= 0 )
|
||||
return -1;
|
||||
|
||||
return (int) stream.readByte() & 0xff;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
in = CompressedStreamTools.read( new DataInputStream( gzReader ) );
|
||||
}
|
||||
|
||||
@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( in );
|
||||
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketCompressedNBT(NBTTagCompound din) throws IOException {
|
||||
|
||||
data = Unpooled.buffer( 2048 );
|
||||
data.writeInt( getPacketID() );
|
||||
|
||||
in = din;
|
||||
|
||||
compressFrame = new GZIPOutputStream( new OutputStream() {
|
||||
|
||||
@Override
|
||||
public void write(int value) throws IOException
|
||||
{
|
||||
data.writeByte( value );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
CompressedStreamTools.write( din, new DataOutputStream( compressFrame ) );
|
||||
compressFrame.close();
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PacketConfigButton extends AppEngPacket
|
||||
{
|
||||
|
||||
final public Settings option;
|
||||
final public boolean rotationDirection;
|
||||
|
||||
// automatic.
|
||||
public PacketConfigButton(ByteBuf stream) throws IOException {
|
||||
option = Settings.values()[stream.readInt()];
|
||||
rotationDirection = stream.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
AEBaseContainer aebc = (AEBaseContainer) sender.openContainer;
|
||||
if ( aebc.getTarget() instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) aebc.getTarget()).getConfigManager();
|
||||
Enum newState = Platform.rotateEnum( cm.getSetting( option ), rotationDirection, option.getPossibleValues() );
|
||||
cm.putSetting( option, newState );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketConfigButton(Settings option, boolean rotationDirection) throws IOException {
|
||||
this.option = option;
|
||||
this.rotationDirection = rotationDirection;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( option.ordinal() );
|
||||
data.writeBoolean( rotationDirection );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PacketCraftRequest extends AppEngPacket
|
||||
{
|
||||
|
||||
final public long amount;
|
||||
final public boolean heldShift;
|
||||
|
||||
// automatic.
|
||||
public PacketCraftRequest(ByteBuf stream) throws IOException {
|
||||
heldShift = stream.readBoolean();
|
||||
amount = stream.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
if ( player.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer;
|
||||
Object targ = cca.getTarget();
|
||||
if ( targ instanceof IGridHost )
|
||||
{
|
||||
IGridHost gh = (IGridHost) targ;
|
||||
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( 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 = heldShift;
|
||||
ccc.job = futureJob;
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
if ( futureJob != null )
|
||||
futureJob.cancel( true );
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PacketCraftRequest(int craftAmt, boolean shift) throws IOException {
|
||||
|
||||
this.amount = craftAmt;
|
||||
this.heldShift = shift;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeBoolean( shift );
|
||||
data.writeLong( amount );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class PacketInventoryAction extends AppEngPacket
|
||||
{
|
||||
|
||||
final public InventoryAction action;
|
||||
final public int slot;
|
||||
final public long id;
|
||||
final public IAEItemStack slotItem;
|
||||
|
||||
// automatic.
|
||||
public PacketInventoryAction(ByteBuf stream) throws IOException {
|
||||
action = InventoryAction.values()[stream.readInt()];
|
||||
slot = stream.readInt();
|
||||
id = stream.readLong();
|
||||
boolean hasItem = stream.readBoolean();
|
||||
if ( hasItem )
|
||||
slotItem = AEItemStack.loadItemStackFromPacket( stream );
|
||||
else
|
||||
slotItem = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
if ( sender.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer aebc = (AEBaseContainer) sender.openContainer;
|
||||
if ( action == InventoryAction.AUTOCRAFT )
|
||||
{
|
||||
ContainerOpenContext context = aebc.openContext;
|
||||
if ( context != null )
|
||||
{
|
||||
TileEntity te = context.getTile();
|
||||
Platform.openGUI( sender, te, aebc.openContext.side, GuiBridge.GUI_CRAFTING_AMOUNT );
|
||||
|
||||
if ( sender.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
||||
|
||||
if ( aebc.getTargetStack() != null )
|
||||
{
|
||||
cca.craftingItem.putStack( aebc.getTargetStack().getItemStack() );
|
||||
cca.whatToMake = aebc.getTargetStack();
|
||||
}
|
||||
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aebc.doAction( sender, action, slot, id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
if ( action == InventoryAction.UPDATE_HAND )
|
||||
{
|
||||
if ( slotItem == null )
|
||||
ClientHelper.proxy.getPlayers().get( 0 ).inventory.setItemStack( null );
|
||||
else
|
||||
ClientHelper.proxy.getPlayers().get( 0 ).inventory.setItemStack( 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( getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( id );
|
||||
|
||||
if ( slotItem == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
slotItem.writeToPacket( data );
|
||||
}
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketInventoryAction(InventoryAction action, int slot, long id) throws IOException {
|
||||
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = id;
|
||||
this.slotItem = null;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( id );
|
||||
data.writeBoolean( false );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketLightning extends AppEngPacket
|
||||
{
|
||||
|
||||
final double x;
|
||||
final double y;
|
||||
final double z;
|
||||
|
||||
// automatic.
|
||||
public PacketLightning(ByteBuf stream) throws IOException {
|
||||
x = stream.readFloat();
|
||||
y = stream.readFloat();
|
||||
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(), x, y, z, 0.0f, 0.0f, 0.0f );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketLightning(double x, double y, double z) throws IOException {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
data.writeFloat( (float) y );
|
||||
data.writeFloat( (float) z );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.client.gui.implementations.GuiNetworkStatus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
{
|
||||
|
||||
// output...
|
||||
final private byte ref;
|
||||
final private ByteBuf data;
|
||||
final private GZIPOutputStream compressFrame;
|
||||
|
||||
int writtenBytes = 0;
|
||||
|
||||
boolean empty = true;
|
||||
|
||||
// input.
|
||||
final List<IAEItemStack> list;
|
||||
|
||||
// automatic.
|
||||
public PacketMEInventoryUpdate(final ByteBuf stream) throws IOException {
|
||||
data = null;
|
||||
compressFrame = null;
|
||||
list = new LinkedList();
|
||||
ref = stream.readByte();
|
||||
|
||||
// int originalBytes = stream.readableBytes();
|
||||
|
||||
GZIPInputStream gzReader = new GZIPInputStream( new InputStream() {
|
||||
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
{
|
||||
if ( stream.readableBytes() <= 0 )
|
||||
return -1;
|
||||
|
||||
return (int) stream.readByte() & 0xff;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
ByteBuf uncompressed = Unpooled.buffer( stream.readableBytes() );
|
||||
byte tmp[] = new byte[1024];
|
||||
while (gzReader.available() != 0)
|
||||
{
|
||||
int bytes = gzReader.read( tmp );
|
||||
if ( bytes > 0 )
|
||||
uncompressed.writeBytes( tmp, 0, bytes );
|
||||
}
|
||||
gzReader.close();
|
||||
|
||||
// int uncompressedBytes = uncompressed.readableBytes();
|
||||
// AELog.info( "Recv: " + originalBytes + " -> " + uncompressedBytes );
|
||||
|
||||
while (uncompressed.readableBytes() > 0)
|
||||
list.add( AEItemStack.loadItemStackFromPacket( uncompressed ) );
|
||||
|
||||
empty = list.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
|
||||
if ( gs instanceof GuiCraftConfirm )
|
||||
((GuiCraftConfirm) gs).postUpdate( list, ref );
|
||||
|
||||
if ( gs instanceof GuiCraftingCPU )
|
||||
((GuiCraftingCPU) gs).postUpdate( list, ref );
|
||||
|
||||
if ( gs instanceof GuiMEMonitorable )
|
||||
((GuiMEMonitorable) gs).postUpdate( list );
|
||||
|
||||
if ( gs instanceof GuiNetworkStatus )
|
||||
((GuiNetworkStatus) gs).postUpdate( list );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FMLProxyPacket getProxy()
|
||||
{
|
||||
try
|
||||
{
|
||||
compressFrame.close();
|
||||
|
||||
configureWrite( data );
|
||||
return super.getProxy();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMEInventoryUpdate() throws IOException {
|
||||
this( (byte) 0 );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMEInventoryUpdate(byte ref) throws IOException {
|
||||
|
||||
data = Unpooled.buffer( 2048 );
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeByte( this.ref = ref );
|
||||
|
||||
compressFrame = new GZIPOutputStream( new OutputStream() {
|
||||
|
||||
@Override
|
||||
public void write(int value) throws IOException
|
||||
{
|
||||
data.writeByte( value );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
list = null;
|
||||
}
|
||||
|
||||
public void appendItem(IAEItemStack is) throws IOException, BufferOverflowException
|
||||
{
|
||||
ByteBuf tmp = Unpooled.buffer( 2048 );
|
||||
is.writeToPacket( tmp );
|
||||
|
||||
compressFrame.flush();
|
||||
if ( writtenBytes + tmp.readableBytes() > 2 * 1024 * 1024 ) // 2mb!
|
||||
throw new BufferOverflowException();
|
||||
else
|
||||
{
|
||||
writtenBytes += tmp.readableBytes();
|
||||
compressFrame.write( tmp.array(), 0, tmp.readableBytes() );
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return data.readableBytes();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return empty;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.client.render.effects.MatterCannonFX;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketMatterCannon extends AppEngPacket
|
||||
{
|
||||
|
||||
final double x;
|
||||
final double y;
|
||||
final double z;
|
||||
final double dx;
|
||||
final double dy;
|
||||
final double dz;
|
||||
final byte len;
|
||||
|
||||
// automatic.
|
||||
public PacketMatterCannon(ByteBuf stream) throws IOException {
|
||||
x = stream.readFloat();
|
||||
y = stream.readFloat();
|
||||
z = stream.readFloat();
|
||||
dx = stream.readFloat();
|
||||
dy = stream.readFloat();
|
||||
dz = stream.readFloat();
|
||||
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 < len; a++)
|
||||
{
|
||||
MatterCannonFX fx = new MatterCannonFX( world, x + dx * a, y + dy * a, z + dz * a, Items.diamond );
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMatterCannon(double x, double y, double z, float dx, float dy, float dz, byte len) throws IOException {
|
||||
float dl = dx * dx + dy * dy + dz * dz;
|
||||
float dlz = (float) Math.sqrt( dl );
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.dx = dx / dlz;
|
||||
this.dy = dy / dlz;
|
||||
this.dz = dz / dlz;
|
||||
this.len = len;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
data.writeFloat( (float) y );
|
||||
data.writeFloat( (float) z );
|
||||
data.writeFloat( (float) this.dx );
|
||||
data.writeFloat( (float) this.dy );
|
||||
data.writeFloat( (float) this.dz );
|
||||
data.writeByte( len );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketMockExplosion extends AppEngPacket
|
||||
{
|
||||
|
||||
final public double x;
|
||||
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) throws IOException {
|
||||
x = stream.readDouble();
|
||||
y = stream.readDouble();
|
||||
z = stream.readDouble();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMockExplosion(double x, double y, double z) throws IOException {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeDouble( x );
|
||||
data.writeDouble( y );
|
||||
data.writeDouble( z );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
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) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@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 pots this event.
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMultiPart() throws IOException {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.prioitylist.IPartitionList;
|
||||
|
||||
public class PacketNEIRecipe extends AppEngPacket
|
||||
{
|
||||
|
||||
ItemStack[][] recipe;
|
||||
|
||||
// automatic.
|
||||
public PacketNEIRecipe(ByteBuf stream) throws IOException
|
||||
{
|
||||
ByteArrayInputStream bytes = new ByteArrayInputStream( stream.array() );
|
||||
bytes.skip( stream.readerIndex() );
|
||||
NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes );
|
||||
if ( comp != null )
|
||||
{
|
||||
recipe = new ItemStack[9][];
|
||||
for (int x = 0; x < recipe.length; x++)
|
||||
{
|
||||
NBTTagList list = comp.getTagList( "#" + x, 10 );
|
||||
if ( list.tagCount() > 0 )
|
||||
{
|
||||
recipe[x] = new ItemStack[list.tagCount()];
|
||||
for (int y = 0; y < list.tagCount(); y++)
|
||||
{
|
||||
recipe[x][y] = ItemStack.loadItemStackFromNBT( list.getCompoundTagAt( y ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP pmp = (EntityPlayerMP) player;
|
||||
Container con = pmp.openContainer;
|
||||
|
||||
if ( con != null && con instanceof IContainerCraftingPacket )
|
||||
{
|
||||
IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
||||
IGridNode node = cct.getNetworkNode();
|
||||
if ( node != null )
|
||||
{
|
||||
IGrid grid = node.getGrid();
|
||||
if ( grid == null )
|
||||
return;
|
||||
|
||||
IStorageGrid inv = grid.getCache( IStorageGrid.class );
|
||||
IEnergyGrid energy = grid.getCache( IEnergyGrid.class );
|
||||
ISecurityGrid security = grid.getCache( ISecurityGrid.class );
|
||||
IInventory craftMatrix = cct.getInventoryByName( "crafting" );
|
||||
|
||||
Actionable realForFake = cct.useRealItems() ? Actionable.MODULATE : Actionable.SIMULATE;
|
||||
|
||||
if ( inv != null && recipe != null && security != null )
|
||||
{
|
||||
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
if ( recipe[x] != null && recipe[x].length > 0 )
|
||||
{
|
||||
ic.setInventorySlotContents( x, recipe[x][0] );
|
||||
}
|
||||
}
|
||||
|
||||
IRecipe r = Platform.findMatchingRecipe( ic, pmp.worldObj );
|
||||
|
||||
if ( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
|
||||
{
|
||||
ItemStack is = r.getCraftingResult( ic );
|
||||
|
||||
if ( is != null )
|
||||
{
|
||||
IMEMonitor<IAEItemStack> stor = inv.getItemInventory();
|
||||
IItemList all = stor.getStorageList();
|
||||
IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
|
||||
|
||||
for (int x = 0; x < craftMatrix.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack PatternItem = ic.getStackInSlot( x );
|
||||
|
||||
ItemStack currentItem = craftMatrix.getStackInSlot( x );
|
||||
if ( currentItem != null )
|
||||
{
|
||||
ic.setInventorySlotContents( x, currentItem );
|
||||
ItemStack newis = r.matches( ic, pmp.worldObj ) ? r.getCraftingResult( ic ) : null;
|
||||
ic.setInventorySlotContents( x, PatternItem );
|
||||
|
||||
if ( newis == null || !Platform.isSameItemPrecise( newis, is ) )
|
||||
{
|
||||
IAEItemStack in = AEItemStack.create( currentItem );
|
||||
if ( in != null )
|
||||
{
|
||||
IAEItemStack out = realForFake == Actionable.SIMULATE ? null : Platform.poweredInsert( energy, stor, in,
|
||||
cct.getSource() );
|
||||
if ( out != null )
|
||||
craftMatrix.setInventorySlotContents( x, out.getItemStack() );
|
||||
else
|
||||
craftMatrix.setInventorySlotContents( x, null );
|
||||
|
||||
currentItem = craftMatrix.getStackInSlot( x );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( PatternItem != null && currentItem == null )
|
||||
{
|
||||
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getSource(), stor, player.worldObj, r, is, ic,
|
||||
PatternItem, x, all, realForFake, filter );
|
||||
|
||||
if ( whichItem == null )
|
||||
{
|
||||
for (int y = 0; y < recipe[x].length; y++)
|
||||
{
|
||||
IAEItemStack request = AEItemStack.create( recipe[x][y] );
|
||||
if ( request != null )
|
||||
{
|
||||
if ( filter == null || filter.isListed( request ) )
|
||||
{
|
||||
request.setStackSize( 1 );
|
||||
IAEItemStack out = Platform.poweredExtraction( energy, stor, request, cct.getSource() );
|
||||
if ( out != null )
|
||||
{
|
||||
whichItem = out.getItemStack();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
craftMatrix.setInventorySlotContents( x, whichItem );
|
||||
}
|
||||
}
|
||||
con.onCraftMatrixChanged( craftMatrix );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketNEIRecipe(NBTTagCompound recipe) throws IOException
|
||||
{
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream datao = new DataOutputStream( bytes );
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
|
||||
CompressedStreamTools.writeCompressed( recipe, datao );
|
||||
data.writeBytes( bytes.toByteArray() );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketNewStorageDimension extends AppEngPacket
|
||||
{
|
||||
|
||||
final int newDim;
|
||||
|
||||
// automatic.
|
||||
public PacketNewStorageDimension(ByteBuf stream) throws IOException {
|
||||
newDim = stream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
try
|
||||
{
|
||||
DimensionManager.registerDimension( newDim, AEConfig.instance.storageProviderID );
|
||||
}
|
||||
catch (IllegalArgumentException iae)
|
||||
{
|
||||
// ok!
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketNewStorageDimension(int newDim) throws IOException {
|
||||
|
||||
this.newDim = newDim;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( newDim );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
|
||||
public class PacketPaintedEntity extends AppEngPacket
|
||||
{
|
||||
|
||||
private AEColor myColor;
|
||||
private int entityId;
|
||||
private int ticks;
|
||||
|
||||
// automatic.
|
||||
public PacketPaintedEntity(ByteBuf stream) throws IOException {
|
||||
entityId = stream.readInt();
|
||||
myColor = AEColor.values()[stream.readByte()];
|
||||
ticks = stream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
PlayerColor pc = new PlayerColor( entityId, myColor, ticks );
|
||||
TickHandler.instance.getPlayerColors().put( entityId, pc );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketPaintedEntity(int myEntity, AEColor myColor, int ticksLeft) {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( this.entityId = myEntity );
|
||||
data.writeByte( (this.myColor = myColor).ordinal() );
|
||||
data.writeInt( ticksLeft );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.parts.PartPlacement;
|
||||
|
||||
public class PacketPartPlacement extends AppEngPacket
|
||||
{
|
||||
|
||||
int x, y, z, face;
|
||||
float eyeHeight;
|
||||
|
||||
// automatic.
|
||||
public PacketPartPlacement(ByteBuf stream) throws IOException {
|
||||
x = stream.readInt();
|
||||
y = stream.readInt();
|
||||
z = stream.readInt();
|
||||
face = stream.readByte();
|
||||
eyeHeight = stream.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
CommonHelper.proxy.updateRenderMode( sender );
|
||||
PartPlacement.eyeHeight = eyeHeight;
|
||||
PartPlacement.place( sender.getHeldItem(), x, y, z, 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 ) throws IOException {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( x );
|
||||
data.writeInt( y );
|
||||
data.writeInt( z );
|
||||
data.writeByte( face );
|
||||
data.writeFloat( eyeHeight );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
public class PacketPartialItem extends AppEngPacket
|
||||
{
|
||||
|
||||
short pageNum;
|
||||
byte[] data;
|
||||
|
||||
// automatic.
|
||||
public PacketPartialItem(ByteBuf stream) throws IOException {
|
||||
pageNum = stream.readShort();
|
||||
stream.readBytes( 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) throws IOException {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
pageNum = (short) (page | (maxPages << 8));
|
||||
this.data = buf;
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeShort( pageNum );
|
||||
data.writeBytes( buf );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
public int getPageCount()
|
||||
{
|
||||
return pageNum >> 8;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return data.length;
|
||||
}
|
||||
|
||||
public int write(byte[] buffer, int cursor)
|
||||
{
|
||||
System.arraycopy( data, 0, buffer, cursor, data.length );
|
||||
return cursor + data.length;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class PacketPatternSlot extends AppEngPacket
|
||||
{
|
||||
|
||||
final public IAEItemStack slotItem;
|
||||
|
||||
final public IAEItemStack pattern[] = new IAEItemStack[9];
|
||||
|
||||
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 {
|
||||
|
||||
shift = stream.readBoolean();
|
||||
|
||||
slotItem = readItem( stream );
|
||||
|
||||
for (int x = 0; x < 9; x++)
|
||||
pattern[x] = readItem( stream );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
if ( sender.openContainer instanceof ContainerPatternTerm )
|
||||
{
|
||||
ContainerPatternTerm aebc = (ContainerPatternTerm) sender.openContainer;
|
||||
aebc.craftOrGetItem( this );
|
||||
}
|
||||
}
|
||||
|
||||
private void writeItem(IAEItemStack slotItem, ByteBuf data) throws IOException
|
||||
{
|
||||
if ( slotItem == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
slotItem.writeToPacket( data );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketPatternSlot(IInventory pat, IAEItemStack slotItem, boolean shift) throws IOException {
|
||||
|
||||
this.slotItem = slotItem;
|
||||
this.shift = shift;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
|
||||
data.writeBoolean( shift );
|
||||
|
||||
writeItem( slotItem, data );
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
pattern[x] = AEApi.instance().storage().createItemStack( pat.getStackInSlot( x ) );
|
||||
writeItem( pattern[x], data );
|
||||
}
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
public class PacketProgressBar extends AppEngPacket
|
||||
{
|
||||
|
||||
short id;
|
||||
long value;
|
||||
|
||||
// automatic.
|
||||
public PacketProgressBar(ByteBuf stream) throws IOException {
|
||||
id = stream.readShort();
|
||||
value = stream.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
if ( c instanceof AEBaseContainer )
|
||||
((AEBaseContainer) c).updateFullProgressBar( id, value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
if ( c instanceof AEBaseContainer )
|
||||
((AEBaseContainer) c).updateFullProgressBar( id, value );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketProgressBar(int short_id, long value) throws IOException {
|
||||
|
||||
this.id = (short) short_id;
|
||||
this.value = value;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeShort( short_id );
|
||||
data.writeLong( value );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
public class PacketSwapSlots extends AppEngPacket
|
||||
{
|
||||
|
||||
int slotA, slotB;
|
||||
|
||||
// automatic.
|
||||
public PacketSwapSlots(ByteBuf stream) throws IOException {
|
||||
slotA = stream.readInt();
|
||||
slotB = stream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
if ( player != null && player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
((AEBaseContainer) player.openContainer).swapSlotContents( slotA, slotB );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketSwapSlots(int slotA, int slotB) throws IOException {
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( this.slotA = slotA );
|
||||
data.writeInt( this.slotB = slotB );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
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) throws IOException {
|
||||
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, newGui );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
AEBaseGui.switchingGuis = true;
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketSwitchGuis(GuiBridge newGui) throws IOException {
|
||||
|
||||
this.newGui = newGui;
|
||||
|
||||
if ( Platform.isClient() )
|
||||
AEBaseGui.switchingGuis = true;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( newGui.ordinal() );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.render.effects.EnergyFx;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketTransitionEffect extends AppEngPacket
|
||||
{
|
||||
|
||||
final double x;
|
||||
final double y;
|
||||
final double z;
|
||||
final ForgeDirection d;
|
||||
final public boolean mode;
|
||||
|
||||
// automatic.
|
||||
public PacketTransitionEffect(ByteBuf stream) throws IOException {
|
||||
x = stream.readFloat();
|
||||
y = stream.readFloat();
|
||||
z = stream.readFloat();
|
||||
d = ForgeDirection.getOrientation( stream.readByte() );
|
||||
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 < (mode ? 32 : 8); zz++)
|
||||
if ( CommonHelper.proxy.shouldAddParticles( Platform.getRandom() ) )
|
||||
{
|
||||
EnergyFx fx = new EnergyFx( world, x + (mode ? (Platform.getRandomInt() % 100) * 0.01 : (Platform.getRandomInt() % 100) * 0.005 - 0.25), y
|
||||
+ (mode ? (Platform.getRandomInt() % 100) * 0.01 : (Platform.getRandomInt() % 100) * 0.005 - 0.25), z
|
||||
+ (mode ? (Platform.getRandomInt() % 100) * 0.01 : (Platform.getRandomInt() % 100) * 0.005 - 0.25), Items.diamond );
|
||||
|
||||
if ( !mode )
|
||||
fx.fromItem( d );
|
||||
|
||||
fx.motionX = -0.1 * d.offsetX;
|
||||
fx.motionY = -0.1 * d.offsetY;
|
||||
fx.motionZ = -0.1 * d.offsetZ;
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
|
||||
if ( mode )
|
||||
{
|
||||
Block block = world.getBlock( (int) x, (int) y, (int) 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) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F ) );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketTransitionEffect(double x, double y, double z, ForgeDirection dir, boolean wasBlock) throws IOException {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.d = dir;
|
||||
this.mode = wasBlock;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
data.writeFloat( (float) y );
|
||||
data.writeFloat( (float) z );
|
||||
data.writeByte( this.d.ordinal() );
|
||||
data.writeBoolean( wasBlock );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.gui.implementations.GuiCraftingCPU;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import appeng.container.implementations.ContainerLevelEmitter;
|
||||
import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.container.implementations.ContainerSecurity;
|
||||
import appeng.container.implementations.ContainerStorageBus;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
|
||||
public class PacketValueConfig extends AppEngPacket
|
||||
{
|
||||
|
||||
final public String Name;
|
||||
final public String Value;
|
||||
|
||||
// automatic.
|
||||
public PacketValueConfig(ByteBuf stream) throws IOException {
|
||||
DataInputStream dis = new DataInputStream( new ByteArrayInputStream( stream.array(), stream.readerIndex(), stream.readableBytes() ) );
|
||||
Name = dis.readUTF();
|
||||
Value = dis.readUTF();
|
||||
// dis.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
|
||||
if ( Name.equals( "Item" ) && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IMouseWheelItem )
|
||||
{
|
||||
ItemStack is = player.getHeldItem();
|
||||
IMouseWheelItem si = (IMouseWheelItem) is.getItem();
|
||||
si.onWheel( is, Value.equals( "WheelUp" ) );
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftingStatus )
|
||||
{
|
||||
ContainerCraftingStatus qk = (ContainerCraftingStatus) c;
|
||||
qk.cycleCpu( Value.equals( "Next" ) );
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.cycleCpu( Value.equals( "Next" ) );
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "Terminal.Start" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.startJob();
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "TileCrafting.Cancel" ) && c instanceof ContainerCraftingCPU )
|
||||
{
|
||||
ContainerCraftingCPU qk = (ContainerCraftingCPU) c;
|
||||
qk.cancelCrafting();
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "QuartzKnife.Name" ) && c instanceof ContainerQuartzKnife )
|
||||
{
|
||||
ContainerQuartzKnife qk = (ContainerQuartzKnife) c;
|
||||
qk.setName( Value );
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "TileSecurity.ToggleOption" ) && c instanceof ContainerSecurity )
|
||||
{
|
||||
ContainerSecurity sc = (ContainerSecurity) c;
|
||||
sc.toggleSetting( Value, player );
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "PriorityHost.Priority" ) && c instanceof ContainerPriority )
|
||||
{
|
||||
ContainerPriority pc = (ContainerPriority) c;
|
||||
pc.setPriority( Integer.parseInt( Value ), player );
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "LevelEmitter.Value" ) && c instanceof ContainerLevelEmitter )
|
||||
{
|
||||
ContainerLevelEmitter lvc = (ContainerLevelEmitter) c;
|
||||
lvc.setLevel( Long.parseLong( Value ), player );
|
||||
return;
|
||||
}
|
||||
else if ( Name.startsWith( "PatternTerminal." ) && c instanceof ContainerPatternTerm )
|
||||
{
|
||||
ContainerPatternTerm cpt = (ContainerPatternTerm) c;
|
||||
if ( Name.equals( "PatternTerminal.CraftMode" ) )
|
||||
{
|
||||
cpt.ct.setCraftingRecipe( Value.equals( "1" ) );
|
||||
}
|
||||
else if ( Name.equals( "PatternTerminal.Encode" ) )
|
||||
{
|
||||
cpt.encode();
|
||||
}
|
||||
else if ( Name.equals( "PatternTerminal.Clear" ) )
|
||||
{
|
||||
cpt.clear();
|
||||
}
|
||||
}
|
||||
else if ( Name.startsWith( "StorageBus." ) && c instanceof ContainerStorageBus )
|
||||
{
|
||||
ContainerStorageBus ccw = (ContainerStorageBus) c;
|
||||
if ( Name.equals( "StorageBus.Action" ) )
|
||||
{
|
||||
if ( Value.equals( "Partition" ) )
|
||||
{
|
||||
ccw.partition();
|
||||
}
|
||||
else if ( Value.equals( "Clear" ) )
|
||||
{
|
||||
ccw.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( Name.startsWith( "CellWorkbench." ) && c instanceof ContainerCellWorkbench )
|
||||
{
|
||||
ContainerCellWorkbench ccw = (ContainerCellWorkbench) c;
|
||||
if ( Name.equals( "CellWorkbench.Action" ) )
|
||||
{
|
||||
if ( Value.equals( "CopyMode" ) )
|
||||
{
|
||||
ccw.nextCopyMode();
|
||||
}
|
||||
else if ( Value.equals( "Partition" ) )
|
||||
{
|
||||
ccw.partition();
|
||||
}
|
||||
else if ( Value.equals( "Clear" ) )
|
||||
{
|
||||
ccw.clear();
|
||||
}
|
||||
}
|
||||
else if ( Name.equals( "CellWorkbench.Fuzzy" ) )
|
||||
{
|
||||
ccw.setFuzzy( FuzzyMode.valueOf( Value ) );
|
||||
}
|
||||
}
|
||||
else if ( c instanceof ContainerNetworkTool )
|
||||
{
|
||||
if ( Name.equals( "NetworkTool" ) && Value.equals( "Toggle" ) )
|
||||
{
|
||||
((ContainerNetworkTool) c).toggleFacadeMode();
|
||||
}
|
||||
}
|
||||
else if ( c instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for (Enum e : cm.getSettings())
|
||||
{
|
||||
if ( e.name().equals( Name ) )
|
||||
{
|
||||
Enum def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), Value ) );
|
||||
}
|
||||
catch (IllegalArgumentException err)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
|
||||
if ( Name.equals( "CustomName" ) && c instanceof AEBaseContainer )
|
||||
{
|
||||
((AEBaseContainer) c).customName = Value;
|
||||
}
|
||||
else if ( Name.startsWith( "SyncDat." ) )
|
||||
{
|
||||
((AEBaseContainer) c).stringSync( Integer.parseInt( Name.substring( 8 ) ), Value );
|
||||
}
|
||||
else if ( Name.equals( "CraftingStatus" ) && Value.equals( "Clear" ) )
|
||||
{
|
||||
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if ( gs instanceof GuiCraftingCPU )
|
||||
((GuiCraftingCPU) gs).clearItems();
|
||||
return;
|
||||
}
|
||||
else if ( c instanceof IConfigurableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for (Enum e : cm.getSettings())
|
||||
{
|
||||
if ( e.name().equals( Name ) )
|
||||
{
|
||||
Enum def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), Value ) );
|
||||
}
|
||||
catch (IllegalArgumentException err)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketValueConfig(String Name, String Value) throws IOException {
|
||||
this.Name = Name;
|
||||
this.Value = Value;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream( bos );
|
||||
dos.writeUTF( Name );
|
||||
dos.writeUTF( Value );
|
||||
// dos.close();
|
||||
|
||||
data.writeBytes( bos.toByteArray() );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user