mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -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
|
||||
registerItem(new item.FloppyDisk(multi) {
|
||||
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")
|
||||
|
||||
// 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 onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
|
||||
if (player.isSneaking) {
|
||||
if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) {
|
||||
stack.setTagCompound(null)
|
||||
player.swingItem()
|
||||
}
|
||||
}
|
||||
stack
|
||||
}
|
||||
def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = stack
|
||||
|
||||
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.inventory.InventoryCrafting
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.item.crafting.IRecipe
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
@ -29,6 +30,7 @@ object ExtendedRecipe {
|
||||
private lazy val navigationUpgrade = api.Items.get("navigationUpgrade")
|
||||
private lazy val linkedCard = api.Items.get("linkedCard")
|
||||
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 tablet = api.Items.get("tablet")
|
||||
private lazy val print = api.Items.get("print")
|
||||
@ -40,7 +42,7 @@ object ExtendedRecipe {
|
||||
stack
|
||||
}
|
||||
|
||||
def addNBTToResult(craftedStack: ItemStack, inventory: InventoryCrafting): ItemStack = {
|
||||
def addNBTToResult(recipe: IRecipe, craftedStack: ItemStack, inventory: InventoryCrafting): ItemStack = {
|
||||
if (api.Items.get(craftedStack) == navigationUpgrade) {
|
||||
Option(api.Driver.driverFor(craftedStack)).foreach(driver =>
|
||||
for (slot <- 0 until inventory.getSizeInventory) {
|
||||
@ -64,16 +66,22 @@ object ExtendedRecipe {
|
||||
}
|
||||
|
||||
if (api.Items.get(craftedStack) == floppy) {
|
||||
if (!craftedStack.hasTagCompound) {
|
||||
craftedStack.setTagCompound(new NBTTagCompound())
|
||||
if (recipe.getRecipeSize == 1) {
|
||||
// Formatting / loot to normal disk conversion.
|
||||
craftedStack.setTagCompound(null)
|
||||
}
|
||||
val nbt = craftedStack.getTagCompound
|
||||
for (slot <- 0 until inventory.getSizeInventory) {
|
||||
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())
|
||||
else {
|
||||
if (!craftedStack.hasTagCompound) {
|
||||
craftedStack.setTagCompound(new NBTTagCompound())
|
||||
}
|
||||
val nbt = craftedStack.getTagCompound
|
||||
for (slot <- 0 until inventory.getSizeInventory) {
|
||||
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: _*) {
|
||||
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: _*) {
|
||||
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 mcu = api.Items.get("microcontroller")
|
||||
val floppy = api.Items.get("floppy")
|
||||
val lootDisk = api.Items.get("lootDisk")
|
||||
val drone = api.Items.get("drone")
|
||||
val eeprom = api.Items.get("eeprom")
|
||||
val robot = api.Items.get("robot")
|
||||
@ -203,6 +204,10 @@ object Recipes {
|
||||
beaconPrint,
|
||||
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 {
|
||||
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.padTo(2, null)
|
||||
|
||||
if (inputs(0) != null) {
|
||||
for (input1 <- inputs(0)) {
|
||||
if (inputs(1) != null) {
|
||||
for (input2 <- inputs(1))
|
||||
if (inputs.head != null) {
|
||||
for (input1 <- inputs.head) {
|
||||
if (inputs.last != null) {
|
||||
for (input2 <- inputs.last)
|
||||
gregtech.api.GregTech_API.sRecipeAdder.addAssemblerRecipe(input1, input2, output, duration, eu)
|
||||
}
|
||||
else gregtech.api.GregTech_API.sRecipeAdder.addAssemblerRecipe(input1, null, output, duration, eu)
|
||||
|
Loading…
x
Reference in New Issue
Block a user