mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-09 15:25:56 -04:00
Merge branch 'master' of https://github.com/MightyPirates/OpenComputers into MC1.7
Conflicts: src/main/scala/li/cil/oc/server/driver/CompoundBlockDriver.scala
This commit is contained in:
commit
4e71de049a
19
src/main/java/li/cil/oc/api/driver/NamedBlock.java
Normal file
19
src/main/java/li/cil/oc/api/driver/NamedBlock.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package li.cil.oc.api.driver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface can be added to block drivers to provide a 'preferred name' in
|
||||||
|
* case the driver is merged with other block drivers (interface based drivers
|
||||||
|
* such as for <tt>IInventory</tt>).
|
||||||
|
*/
|
||||||
|
public interface NamedBlock {
|
||||||
|
/**
|
||||||
|
* The preferred name, in case the driver is merged with others.
|
||||||
|
* <p/>
|
||||||
|
* If multiple drivers with a preferred name are merged, the first one is
|
||||||
|
* picked. This should usually not happen, since this is only intended to
|
||||||
|
* be implemented by drivers for actual tile entities (not interfaces).
|
||||||
|
*
|
||||||
|
* @return the preferred name.
|
||||||
|
*/
|
||||||
|
String preferredName();
|
||||||
|
}
|
@ -3,6 +3,7 @@ package li.cil.oc.server.driver
|
|||||||
import com.google.common.base.Strings
|
import com.google.common.base.Strings
|
||||||
import cpw.mods.fml.relauncher.ReflectionHelper
|
import cpw.mods.fml.relauncher.ReflectionHelper
|
||||||
import li.cil.oc.api.driver
|
import li.cil.oc.api.driver
|
||||||
|
import li.cil.oc.api.driver.NamedBlock
|
||||||
import net.minecraft.inventory.IInventory
|
import net.minecraft.inventory.IInventory
|
||||||
import net.minecraft.item.{Item, ItemStack}
|
import net.minecraft.item.{Item, ItemStack}
|
||||||
import net.minecraft.tileentity.TileEntity
|
import net.minecraft.tileentity.TileEntity
|
||||||
@ -30,6 +31,10 @@ class CompoundBlockDriver(val blocks: driver.Block*) extends driver.Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def tryGetName(world: World, x: Int, y: Int, z: Int): String = {
|
private def tryGetName(world: World, x: Int, y: Int, z: Int): String = {
|
||||||
|
for (block <- blocks) block match {
|
||||||
|
case named: NamedBlock => return named.preferredName
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
try world.getTileEntity(x, y, z) match {
|
try world.getTileEntity(x, y, z) match {
|
||||||
case inventory: IInventory => return inventory.getInventoryName.stripPrefix("container.")
|
case inventory: IInventory => return inventory.getInventoryName.stripPrefix("container.")
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user