Add pattern conversion hooks for Reborn Storage. Fixes #1850
This commit is contained in:
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.api.util;
|
|||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -26,7 +27,7 @@ public interface IOneSixMigrationHelper {
|
|||||||
boolean migrateDisk(World world, ItemStack disk);
|
boolean migrateDisk(World world, ItemStack disk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migrates an entire inventory.
|
* Migrates an entire disk inventory.
|
||||||
* Loops over every slot in the inventory and calls {@link #migrateDisk(World, ItemStack)}.
|
* Loops over every slot in the inventory and calls {@link #migrateDisk(World, ItemStack)}.
|
||||||
* All the docs from {@link #migrateDisk(World, ItemStack)} apply here as well!
|
* All the docs from {@link #migrateDisk(World, ItemStack)} apply here as well!
|
||||||
* Don't forget to mark your tile dirty if this call returns true!
|
* Don't forget to mark your tile dirty if this call returns true!
|
||||||
@@ -36,4 +37,23 @@ public interface IOneSixMigrationHelper {
|
|||||||
* @return true if it migrated something in the inventory, false otherwise
|
* @return true if it migrated something in the inventory, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean migrateDiskInventory(World world, IItemHandlerModifiable handler);
|
boolean migrateDiskInventory(World world, IItemHandlerModifiable handler);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrates an entire pattern inventory.
|
||||||
|
* Returns true if there were changes, and the caller should then mark their inventory dirty.
|
||||||
|
*
|
||||||
|
* @param handler the pattern inventory
|
||||||
|
* @return true if a pattern has been converted, false otherwise
|
||||||
|
*/
|
||||||
|
boolean migratePatternInventory(IItemHandler handler);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrates a single pattern stack.
|
||||||
|
* Returns true if the stack was modified, and the caller should then mark their inventory dirty.
|
||||||
|
* You most likely need {@link #migratePatternInventory(IItemHandler)}.
|
||||||
|
*
|
||||||
|
* @param pattern the pattern
|
||||||
|
* @return true if the pattern has been converted, false otherwise
|
||||||
|
*/
|
||||||
|
boolean migratePattern(ItemStack pattern);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternProvider
|
|||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
|
||||||
@@ -134,7 +133,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
|
|||||||
|
|
||||||
StackUtils.readItems(patterns, 0, tag);
|
StackUtils.readItems(patterns, 0, tag);
|
||||||
|
|
||||||
if (OneSixMigrationHelper.migratePatternInventory(patterns)) {
|
if (API.instance().getOneSixMigrationHelper().migratePatternInventory(patterns)) {
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,8 @@ public class OneSixMigrationHelper implements IOneSixMigrationHelper {
|
|||||||
private static final String NBT_OUTPUTS = "Outputs";
|
private static final String NBT_OUTPUTS = "Outputs";
|
||||||
private static final String NBT_SLOT = "Slot_%d";
|
private static final String NBT_SLOT = "Slot_%d";
|
||||||
|
|
||||||
public static boolean migratePattern(ItemStack pattern) {
|
@Override
|
||||||
|
public boolean migratePattern(ItemStack pattern) {
|
||||||
NBTTagCompound tag = pattern.getTagCompound();
|
NBTTagCompound tag = pattern.getTagCompound();
|
||||||
|
|
||||||
if (pattern.hasTagCompound() && !tag.hasKey(ItemPattern.NBT_PROCESSING)) {
|
if (pattern.hasTagCompound() && !tag.hasKey(ItemPattern.NBT_PROCESSING)) {
|
||||||
@@ -180,7 +181,8 @@ public class OneSixMigrationHelper implements IOneSixMigrationHelper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean migratePatternInventory(IItemHandler handler) {
|
@Override
|
||||||
|
public boolean migratePatternInventory(IItemHandler handler) {
|
||||||
boolean migrated = false;
|
boolean migrated = false;
|
||||||
|
|
||||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import com.raoulvdberge.refinedstorage.RSItems;
|
|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
|
||||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
@@ -182,7 +182,7 @@ public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
|
|||||||
super.onUpdate(stack, world, entity, slot, isSelected);
|
super.onUpdate(stack, world, entity, slot, isSelected);
|
||||||
|
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
OneSixMigrationHelper.migratePattern(stack);
|
API.instance().getOneSixMigrationHelper().migratePattern(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user