mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 02:12:42 -04:00
Floppy disks can no longer be "formatted" by shift-rightclicking, added crafting as alternative.
Simply recrafting a single floppy (no other items in the crafting grid) will now format it. Same for loot disk, they can be converted to normal floppies the same way. In general, this removes the "shift-right-click to remove NBT tag" functionality, so you also can't format HHDs like this anymore - use `rm /*` or such. If you notice any items that needed the old functionality (looked through the list, didn't see one), let me know.
This commit is contained in:
parent
7fd0ddac22
commit
e24e2dfc76
@ -370,11 +370,6 @@ object Items extends ItemAPI {
|
|||||||
// v1.2.3
|
// v1.2.3
|
||||||
registerItem(new item.FloppyDisk(multi) {
|
registerItem(new item.FloppyDisk(multi) {
|
||||||
showInItemList = false
|
showInItemList = false
|
||||||
|
|
||||||
override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer) = {
|
|
||||||
if (player.isSneaking) get("floppy").createItemStack(1)
|
|
||||||
else super.onItemRightClick(stack, world, player)
|
|
||||||
}
|
|
||||||
}, "lootDisk")
|
}, "lootDisk")
|
||||||
|
|
||||||
// v1.2.6
|
// v1.2.6
|
||||||
|
@ -46,15 +46,7 @@ trait Delegate {
|
|||||||
|
|
||||||
def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean = false
|
def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean = false
|
||||||
|
|
||||||
def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
|
def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = stack
|
||||||
if (player.isSneaking) {
|
|
||||||
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {
|
|
||||||
stack.setTagCompound(null)
|
|
||||||
player.swingItem()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stack
|
|
||||||
}
|
|
||||||
|
|
||||||
def getItemUseAction(stack: ItemStack): EnumAction = EnumAction.none
|
def getItemUseAction(stack: ItemStack): EnumAction = EnumAction.none
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import li.cil.oc.util.SideTracker
|
|||||||
import net.minecraft.init.Blocks
|
import net.minecraft.init.Blocks
|
||||||
import net.minecraft.inventory.InventoryCrafting
|
import net.minecraft.inventory.InventoryCrafting
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
|
import net.minecraft.item.crafting.IRecipe
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
|
|
||||||
import scala.collection.convert.WrapAsScala._
|
import scala.collection.convert.WrapAsScala._
|
||||||
@ -29,6 +30,7 @@ object ExtendedRecipe {
|
|||||||
private lazy val navigationUpgrade = api.Items.get("navigationUpgrade")
|
private lazy val navigationUpgrade = api.Items.get("navigationUpgrade")
|
||||||
private lazy val linkedCard = api.Items.get("linkedCard")
|
private lazy val linkedCard = api.Items.get("linkedCard")
|
||||||
private lazy val floppy = api.Items.get("floppy")
|
private lazy val floppy = api.Items.get("floppy")
|
||||||
|
private lazy val lootDisk = api.Items.get("lootDisk")
|
||||||
private lazy val robot = api.Items.get("robot")
|
private lazy val robot = api.Items.get("robot")
|
||||||
private lazy val tablet = api.Items.get("tablet")
|
private lazy val tablet = api.Items.get("tablet")
|
||||||
private lazy val print = api.Items.get("print")
|
private lazy val print = api.Items.get("print")
|
||||||
@ -40,7 +42,7 @@ object ExtendedRecipe {
|
|||||||
stack
|
stack
|
||||||
}
|
}
|
||||||
|
|
||||||
def addNBTToResult(craftedStack: ItemStack, inventory: InventoryCrafting): ItemStack = {
|
def addNBTToResult(recipe: IRecipe, craftedStack: ItemStack, inventory: InventoryCrafting): ItemStack = {
|
||||||
if (api.Items.get(craftedStack) == navigationUpgrade) {
|
if (api.Items.get(craftedStack) == navigationUpgrade) {
|
||||||
Option(api.Driver.driverFor(craftedStack)).foreach(driver =>
|
Option(api.Driver.driverFor(craftedStack)).foreach(driver =>
|
||||||
for (slot <- 0 until inventory.getSizeInventory) {
|
for (slot <- 0 until inventory.getSizeInventory) {
|
||||||
@ -64,16 +66,22 @@ object ExtendedRecipe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (api.Items.get(craftedStack) == floppy) {
|
if (api.Items.get(craftedStack) == floppy) {
|
||||||
if (!craftedStack.hasTagCompound) {
|
if (recipe.getRecipeSize == 1) {
|
||||||
craftedStack.setTagCompound(new NBTTagCompound())
|
// Formatting / loot to normal disk conversion.
|
||||||
|
craftedStack.setTagCompound(null)
|
||||||
}
|
}
|
||||||
val nbt = craftedStack.getTagCompound
|
else {
|
||||||
for (slot <- 0 until inventory.getSizeInventory) {
|
if (!craftedStack.hasTagCompound) {
|
||||||
val stack = inventory.getStackInSlot(slot)
|
craftedStack.setTagCompound(new NBTTagCompound())
|
||||||
if (stack != null && api.Items.get(stack) == floppy && stack.hasTagCompound) {
|
}
|
||||||
val oldData = stack.getTagCompound
|
val nbt = craftedStack.getTagCompound
|
||||||
for (oldTagName <- oldData.func_150296_c().map(_.asInstanceOf[String])) {
|
for (slot <- 0 until inventory.getSizeInventory) {
|
||||||
nbt.setTag(oldTagName, oldData.getTag(oldTagName).copy())
|
val stack = inventory.getStackInSlot(slot)
|
||||||
|
if (stack != null && api.Items.get(stack) == floppy && stack.hasTagCompound) {
|
||||||
|
val oldData = stack.getTagCompound
|
||||||
|
for (oldTagName <- oldData.func_150296_c().map(_.asInstanceOf[String])) {
|
||||||
|
nbt.setTag(oldTagName, oldData.getTag(oldTagName).copy())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,5 @@ import net.minecraftforge.oredict.ShapedOreRecipe
|
|||||||
|
|
||||||
class ExtendedShapedOreRecipe(result: ItemStack, ingredients: AnyRef*) extends ShapedOreRecipe(result, ingredients: _*) {
|
class ExtendedShapedOreRecipe(result: ItemStack, ingredients: AnyRef*) extends ShapedOreRecipe(result, ingredients: _*) {
|
||||||
override def getCraftingResult(inventory: InventoryCrafting) =
|
override def getCraftingResult(inventory: InventoryCrafting) =
|
||||||
ExtendedRecipe.addNBTToResult(super.getCraftingResult(inventory), inventory)
|
ExtendedRecipe.addNBTToResult(this, super.getCraftingResult(inventory), inventory)
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,5 @@ import net.minecraftforge.oredict.ShapelessOreRecipe
|
|||||||
|
|
||||||
class ExtendedShapelessOreRecipe(result: ItemStack, ingredients: AnyRef*) extends ShapelessOreRecipe(result, ingredients: _*) {
|
class ExtendedShapelessOreRecipe(result: ItemStack, ingredients: AnyRef*) extends ShapelessOreRecipe(result, ingredients: _*) {
|
||||||
override def getCraftingResult(inventory: InventoryCrafting) =
|
override def getCraftingResult(inventory: InventoryCrafting) =
|
||||||
ExtendedRecipe.addNBTToResult(super.getCraftingResult(inventory), inventory)
|
ExtendedRecipe.addNBTToResult(this, super.getCraftingResult(inventory), inventory)
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,7 @@ object Recipes {
|
|||||||
val navigationUpgrade = api.Items.get("navigationUpgrade")
|
val navigationUpgrade = api.Items.get("navigationUpgrade")
|
||||||
val mcu = api.Items.get("microcontroller")
|
val mcu = api.Items.get("microcontroller")
|
||||||
val floppy = api.Items.get("floppy")
|
val floppy = api.Items.get("floppy")
|
||||||
|
val lootDisk = api.Items.get("lootDisk")
|
||||||
val drone = api.Items.get("drone")
|
val drone = api.Items.get("drone")
|
||||||
val eeprom = api.Items.get("eeprom")
|
val eeprom = api.Items.get("eeprom")
|
||||||
val robot = api.Items.get("robot")
|
val robot = api.Items.get("robot")
|
||||||
@ -203,6 +204,10 @@ object Recipes {
|
|||||||
beaconPrint,
|
beaconPrint,
|
||||||
print.createItemStack(1), new ItemStack(block)))
|
print.createItemStack(1), new ItemStack(block)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Floppy disk formatting.
|
||||||
|
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(floppy.createItemStack(1), floppy.createItemStack(1)))
|
||||||
|
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(floppy.createItemStack(1), lootDisk.createItemStack(1)))
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
case e: Throwable => OpenComputers.log.error("Error parsing recipes, you may not be able to craft any items from this mod!", e)
|
case e: Throwable => OpenComputers.log.error("Error parsing recipes, you may not be able to craft any items from this mod!", e)
|
||||||
@ -328,10 +333,10 @@ object Recipes {
|
|||||||
(inputs, inputCount).zipped.foreach((stacks, count) => stacks.foreach(stack => if (stack != null && count > 0) stack.stackSize = stack.getMaxStackSize min count))
|
(inputs, inputCount).zipped.foreach((stacks, count) => stacks.foreach(stack => if (stack != null && count > 0) stack.stackSize = stack.getMaxStackSize min count))
|
||||||
inputs.padTo(2, null)
|
inputs.padTo(2, null)
|
||||||
|
|
||||||
if (inputs(0) != null) {
|
if (inputs.head != null) {
|
||||||
for (input1 <- inputs(0)) {
|
for (input1 <- inputs.head) {
|
||||||
if (inputs(1) != null) {
|
if (inputs.last != null) {
|
||||||
for (input2 <- inputs(1))
|
for (input2 <- inputs.last)
|
||||||
gregtech.api.GregTech_API.sRecipeAdder.addAssemblerRecipe(input1, input2, output, duration, eu)
|
gregtech.api.GregTech_API.sRecipeAdder.addAssemblerRecipe(input1, input2, output, duration, eu)
|
||||||
}
|
}
|
||||||
else gregtech.api.GregTech_API.sRecipeAdder.addAssemblerRecipe(input1, null, output, duration, eu)
|
else gregtech.api.GregTech_API.sRecipeAdder.addAssemblerRecipe(input1, null, output, duration, eu)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user