forked from MightyPirates/OpenComputers
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept capability for IBasicEnergyContainer & IGregTechDeviceInformat…
…ion (#151)
- Loading branch information
Showing
6 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package li.cil.oc.util; | ||
|
||
import com.gtnewhorizon.gtnhlib.capability.Capabilities; | ||
import cpw.mods.fml.common.Loader; | ||
import net.minecraft.tileentity.TileEntity; | ||
|
||
public final class CapabilityUtil { | ||
|
||
private static final boolean isGTNHLibLoaded = Loader.isModLoaded("gtnhlib"); | ||
|
||
public static <T> boolean hasCapability(TileEntity tileEntity, Class<T> capability) { | ||
if (isGTNHLibLoaded) { | ||
return Capabilities.getCapability(tileEntity, capability) != null; | ||
} else { | ||
return tileEntity != null && capability.isAssignableFrom(tileEntity.getClass()); | ||
} | ||
} | ||
|
||
public static <T> T getCapability(TileEntity tileEntity, Class<T> capability) { | ||
if (isGTNHLibLoaded) { | ||
return Capabilities.getCapability(tileEntity, capability); | ||
} else { | ||
if (tileEntity != null && capability.isAssignableFrom(tileEntity.getClass())) { | ||
return capability.cast(tileEntity); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
src/main/scala/li/cil/oc/integration/gregtech/EventHandlerGregTech.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters