mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
Merge branch 'master-MC1.9.4' of github.com:MightyPirates/OpenComputers into master-MC1.10
This commit is contained in:
commit
6c098e799c
@ -16,6 +16,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* This API allows registering new drivers with the mod.
|
||||
@ -217,13 +218,31 @@ public final class Driver {
|
||||
*
|
||||
* @param stack the item stack to get the environment type for.
|
||||
* @return the type of environment associated with the stack, or <tt>null</tt>.
|
||||
* @deprecated Use {@link #environmentsFor(ItemStack)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static Class<?> environmentFor(ItemStack stack) {
|
||||
if (API.driver != null)
|
||||
return API.driver.environmentFor(stack);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up the environments associated with the specified item stack.
|
||||
* <p/>
|
||||
* This will use the registered {@link EnvironmentProvider}s to find
|
||||
* environment types for the specified item stack. If none can be
|
||||
* found, returns an empty Set.
|
||||
*
|
||||
* @param stack the item stack to get the environment type for.
|
||||
* @return the type of environment associated with the stack, or an empty Set, or null if the API is not present.
|
||||
*/
|
||||
public static Set<Class<?>> environmentsFor(ItemStack stack) {
|
||||
if (API.driver != null)
|
||||
return API.driver.environmentsFor(stack);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #itemHandlerFor(ItemStack, EntityPlayer)} instead.
|
||||
*/
|
||||
|
@ -16,6 +16,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
public interface DriverAPI {
|
||||
/**
|
||||
@ -167,9 +168,23 @@ public interface DriverAPI {
|
||||
*
|
||||
* @param stack the item stack to get the environment type for.
|
||||
* @return the type of environment associated with the stack, or <tt>null</tt>.
|
||||
* @deprecated Use {@link #environmentsFor(ItemStack)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Class<?> environmentFor(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Looks up the environments associated with the specified item stack.
|
||||
* <p/>
|
||||
* This will use the registered {@link EnvironmentProvider}s to find
|
||||
* environment types for the specified item stack. If none can be
|
||||
* found, returns an empty Set.
|
||||
*
|
||||
* @param stack the item stack to get the environment type for.
|
||||
* @return the type of environment associated with the stack, or an empty Set.
|
||||
*/
|
||||
Set<Class<?>> environmentsFor(ItemStack stack);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #itemHandlerFor(ItemStack, EntityPlayer)} instead.
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ class CallbackDocHandler(pages: Option[Array[String]]) extends PagedUsageHandler
|
||||
if (input == "item") {
|
||||
ingredients.collect {
|
||||
case stack: ItemStack if stack.getItem != null =>
|
||||
val callbacks = getCallbacks(api.Driver.environmentFor(stack)).toBuffer
|
||||
val callbacks = api.Driver.environmentsFor(stack).flatMap(getCallbacks).toBuffer
|
||||
|
||||
// TODO remove in OC 1.7
|
||||
if (callbacks.isEmpty) {
|
||||
|
@ -140,12 +140,15 @@ private[oc] object Registry extends api.detail.DriverAPI {
|
||||
if (stack != null) items.find(_.worksWith(stack)).orNull
|
||||
else null
|
||||
|
||||
@Deprecated
|
||||
override def environmentFor(stack: ItemStack): Class[_] = {
|
||||
environmentProviders.map(provider => provider.getEnvironment(stack)).collectFirst {
|
||||
case clazz: Class[_] => clazz
|
||||
}.orNull
|
||||
}
|
||||
|
||||
override def environmentsFor(stack: ItemStack): util.Set[Class[_]] = environmentProviders.map(_.getEnvironment(stack)).filter(_ != null).toSet[Class[_]]
|
||||
|
||||
@Deprecated
|
||||
override def inventoryFor(stack: ItemStack, player: EntityPlayer):IInventory = {
|
||||
OpenComputers.log.warn("A mod is using the deprecated method li.cil.oc.api.Driver.inventoryFor; use itemHandlerFor instead.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user