Merge branch 'master-MC1.9.4' of github.com:MightyPirates/OpenComputers into master-MC1.10

This commit is contained in:
Florian Nücke 2016-12-17 21:47:20 +01:00
commit 6c098e799c
4 changed files with 38 additions and 1 deletions

View File

@ -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.
*/

View File

@ -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.
*/

View File

@ -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) {

View File

@ -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.")