Skip to content

Commit a112be6

Browse files
committed
Updated ME Bridge to work with ae2 rv3 beta 5
1 parent 74deacf commit a112be6

File tree

247 files changed

+4494
-2573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+4494
-2573
lines changed
-2.3 MB
Binary file not shown.
2.75 MB
Binary file not shown.

src/api/java/appeng/api/AEApi.java

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* The MIT License (MIT)
3-
*
3+
*
44
* Copyright (c) 2013 AlgorithmX2
5-
*
5+
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy of
77
* this software and associated documentation files (the "Software"), to deal in
88
* the Software without restriction, including without limitation the rights to
99
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1010
* the Software, and to permit persons to whom the Software is furnished to do so,
1111
* subject to the following conditions:
12-
*
12+
*
1313
* The above copyright notice and this permission notice shall be included in all
1414
* copies or substantial portions of the Software.
15-
*
15+
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1818
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
@@ -23,39 +23,56 @@
2323

2424
package appeng.api;
2525

26+
27+
import java.lang.reflect.Field;
28+
29+
import appeng.api.exceptions.CoreInaccessibleException;
30+
31+
2632
/**
27-
*
2833
* Entry point for api.
29-
*
34+
*
3035
* Available IMCs:
31-
*
3236
*/
33-
public class AEApi
37+
public enum AEApi
3438
{
39+
;
40+
41+
private static final String CORE_API_FQN = "appeng.core.Api";
42+
private static final String CORE_API_FIELD = "INSTANCE";
43+
private static final IAppEngApi HELD_API;
3544

36-
static private IAppEngApi api = null;
45+
static
46+
{
47+
try
48+
{
49+
final Class<?> apiClass = Class.forName( CORE_API_FQN );
50+
final Field apiField = apiClass.getField( CORE_API_FIELD );
51+
52+
HELD_API = (IAppEngApi) apiField.get( apiClass );
53+
}
54+
catch( final ClassNotFoundException e )
55+
{
56+
throw new CoreInaccessibleException( "AE2 API tried to access the " + CORE_API_FQN + " class, without it being declared." );
57+
}
58+
catch( final NoSuchFieldException e )
59+
{
60+
throw new CoreInaccessibleException( "AE2 API tried to access the " + CORE_API_FIELD + " field in " + CORE_API_FQN + " without it being declared." );
61+
}
62+
catch( final IllegalAccessException e )
63+
{
64+
throw new CoreInaccessibleException( "AE2 API tried to access the " + CORE_API_FIELD + " field in " + CORE_API_FQN + " without enough access permissions." );
65+
}
66+
}
3767

3868
/**
3969
* API Entry Point.
40-
*
41-
* @return the {@link IAppEngApi} or null if the INSTANCE could not be retrieved
70+
*
71+
* @return the {@link IAppEngApi}
4272
*/
4373
public static IAppEngApi instance()
4474
{
45-
if ( api == null )
46-
{
47-
try
48-
{
49-
Class c = Class.forName( "appeng.core.Api" );
50-
api = (IAppEngApi) c.getField( "INSTANCE" ).get( c );
51-
}
52-
catch (Throwable e)
53-
{
54-
return null;
55-
}
56-
}
57-
58-
return api;
75+
return HELD_API;
5976
}
6077

6178
}

src/api/java/appeng/api/IAppEngApi.java

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* The MIT License (MIT)
3-
*
3+
*
44
* Copyright (c) 2013 AlgorithmX2
5-
*
5+
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy of
77
* this software and associated documentation files (the "Software"), to deal in
88
* the Software without restriction, including without limitation the rights to
99
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1010
* the Software, and to permit persons to whom the Software is furnished to do so,
1111
* subject to the following conditions:
12-
*
12+
*
1313
* The above copyright notice and this permission notice shall be included in all
1414
* copies or substantial portions of the Software.
15-
*
15+
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1818
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
@@ -23,19 +23,21 @@
2323

2424
package appeng.api;
2525

26+
2627
import appeng.api.definitions.Blocks;
28+
import appeng.api.definitions.IDefinitions;
2729
import appeng.api.definitions.Items;
2830
import appeng.api.definitions.Materials;
2931
import appeng.api.definitions.Parts;
3032
import appeng.api.exceptions.FailedConnection;
3133
import appeng.api.features.IRegistryContainer;
3234
import appeng.api.networking.IGridBlock;
3335
import appeng.api.networking.IGridConnection;
34-
import appeng.api.networking.IGridHost;
3536
import appeng.api.networking.IGridNode;
3637
import appeng.api.parts.IPartHelper;
3738
import appeng.api.storage.IStorageHelper;
3839

40+
3941
public interface IAppEngApi
4042
{
4143

@@ -56,39 +58,57 @@ public interface IAppEngApi
5658

5759
/**
5860
* @return an accessible list of all of AE's Items
61+
*
62+
* @deprecated use {@link appeng.api.definitions.IDefinitions#items()}
5963
*/
64+
@Deprecated
6065
Items items();
6166

6267
/**
6368
* @return an accessible list of all of AE's materials; materials are items
69+
*
70+
* @deprecated use {@link appeng.api.definitions.IDefinitions#materials()}
6471
*/
72+
@Deprecated
6573
Materials materials();
6674

6775
/**
6876
* @return an accessible list of all of AE's blocks
77+
*
78+
* @deprecated use {@link appeng.api.definitions.IDefinitions#blocks()}
6979
*/
80+
@Deprecated
7081
Blocks blocks();
7182

7283
/**
7384
* @return an accessible list of all of AE's parts, parts are items
85+
*
86+
* @deprecated use {@link appeng.api.definitions.IDefinitions#parts()}
7487
*/
88+
@Deprecated
7589
Parts parts();
7690

7791
/**
78-
* create a grid node for your {@link IGridHost}
79-
*
92+
* @return an accessible list of all AE definitions
93+
*/
94+
IDefinitions definitions();
95+
96+
/**
97+
* create a grid node for your {@link appeng.api.networking.IGridHost}
98+
*
8099
* @param block grid block
100+
*
81101
* @return grid node of block
82102
*/
83-
IGridNode createGridNode(IGridBlock block);
103+
IGridNode createGridNode( IGridBlock block );
84104

85105
/**
86-
* create a connection between two {@link IGridNode}
87-
*
106+
* create a connection between two {@link appeng.api.networking.IGridNode}
107+
*
88108
* @param a to be connected gridnode
89109
* @param b to be connected gridnode
90-
* @throws FailedConnection
110+
*
111+
* @throws appeng.api.exceptions.FailedConnection
91112
*/
92-
IGridConnection createGridConnection(IGridNode a, IGridNode b) throws FailedConnection;
93-
113+
IGridConnection createGridConnection( IGridNode a, IGridNode b ) throws FailedConnection;
94114
}
Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* The MIT License (MIT)
3-
*
3+
*
44
* Copyright (c) 2013 AlgorithmX2
5-
*
5+
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy of
77
* this software and associated documentation files (the "Software"), to deal in
88
* the Software without restriction, including without limitation the rights to
99
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1010
* the Software, and to permit persons to whom the Software is furnished to do so,
1111
* subject to the following conditions:
12-
*
12+
*
1313
* The above copyright notice and this permission notice shall be included in all
1414
* copies or substantial portions of the Software.
15-
*
15+
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1818
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
@@ -23,49 +23,51 @@
2323

2424
package appeng.api.config;
2525

26+
2627
public enum AccessRestriction
2728
{
28-
NO_ACCESS(0), READ(1), WRITE(2), READ_WRITE(3);
29+
NO_ACCESS( 0 ), READ( 1 ), WRITE( 2 ), READ_WRITE( 3 );
2930

3031
private final int permissionBit;
3132

32-
private AccessRestriction(int v) {
33+
AccessRestriction( final int v )
34+
{
3335
this.permissionBit = v;
3436
}
3537

36-
public boolean hasPermission(AccessRestriction ar)
38+
public boolean hasPermission( final AccessRestriction ar )
3739
{
38-
return ( this.permissionBit & ar.permissionBit) == ar.permissionBit;
40+
return ( this.permissionBit & ar.permissionBit ) == ar.permissionBit;
3941
}
4042

41-
public AccessRestriction restrictPermissions(AccessRestriction ar)
43+
public AccessRestriction restrictPermissions( final AccessRestriction ar )
4244
{
43-
return this.getPermByBit( this.permissionBit & ar.permissionBit);
45+
return this.getPermByBit( this.permissionBit & ar.permissionBit );
4446
}
4547

46-
public AccessRestriction addPermissions(AccessRestriction ar)
48+
private AccessRestriction getPermByBit( final int bit )
4749
{
48-
return this.getPermByBit( this.permissionBit | ar.permissionBit);
50+
switch( bit )
51+
{
52+
default:
53+
case 0:
54+
return NO_ACCESS;
55+
case 1:
56+
return READ;
57+
case 2:
58+
return WRITE;
59+
case 3:
60+
return READ_WRITE;
61+
}
4962
}
5063

51-
public AccessRestriction removePermissions(AccessRestriction ar)
64+
public AccessRestriction addPermissions( final AccessRestriction ar )
5265
{
53-
return this.getPermByBit( this.permissionBit & (~ar.permissionBit) );
66+
return this.getPermByBit( this.permissionBit | ar.permissionBit );
5467
}
5568

56-
private AccessRestriction getPermByBit(int bit)
69+
public AccessRestriction removePermissions( final AccessRestriction ar )
5770
{
58-
switch (bit)
59-
{
60-
default:
61-
case 0:
62-
return NO_ACCESS;
63-
case 1:
64-
return READ;
65-
case 2:
66-
return WRITE;
67-
case 3:
68-
return READ_WRITE;
69-
}
71+
return this.getPermByBit( this.permissionBit & ( ~ar.permissionBit ) );
7072
}
7173
}

src/api/java/appeng/api/config/ActionItems.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* The MIT License (MIT)
3-
*
3+
*
44
* Copyright (c) 2013 AlgorithmX2
5-
*
5+
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy of
77
* this software and associated documentation files (the "Software"), to deal in
88
* the Software without restriction, including without limitation the rights to
99
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1010
* the Software, and to permit persons to whom the Software is furnished to do so,
1111
* subject to the following conditions:
12-
*
12+
*
1313
* The above copyright notice and this permission notice shall be included in all
1414
* copies or substantial portions of the Software.
15-
*
15+
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1818
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
@@ -23,6 +23,7 @@
2323

2424
package appeng.api.config;
2525

26+
2627
public enum ActionItems
2728
{
2829
WRENCH, CLOSE, STASH, ENCODE, SUBSTITUTION

src/api/java/appeng/api/config/Actionable.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* The MIT License (MIT)
3-
*
3+
*
44
* Copyright (c) 2013 AlgorithmX2
5-
*
5+
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy of
77
* this software and associated documentation files (the "Software"), to deal in
88
* the Software without restriction, including without limitation the rights to
99
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1010
* the Software, and to permit persons to whom the Software is furnished to do so,
1111
* subject to the following conditions:
12-
*
12+
*
1313
* The above copyright notice and this permission notice shall be included in all
1414
* copies or substantial portions of the Software.
15-
*
15+
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1818
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
@@ -23,6 +23,7 @@
2323

2424
package appeng.api.config;
2525

26+
2627
public enum Actionable
2728
{
2829
/**

src/api/java/appeng/api/config/CondenserOutput.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
22
* The MIT License (MIT)
3-
*
3+
*
44
* Copyright (c) 2013 AlgorithmX2
5-
*
5+
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy of
77
* this software and associated documentation files (the "Software"), to deal in
88
* the Software without restriction, including without limitation the rights to
99
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1010
* the Software, and to permit persons to whom the Software is furnished to do so,
1111
* subject to the following conditions:
12-
*
12+
*
1313
* The above copyright notice and this permission notice shall be included in all
1414
* copies or substantial portions of the Software.
15-
*
15+
*
1616
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1818
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR

0 commit comments

Comments
 (0)