Solderer removal.
- Removed Solderer. - Added cutting tool. - Renamed "Printed Processors" to "Cut Processors" - Made autocrafting reuse reusable items like the cutting tool.
This commit is contained in:
@@ -12,7 +12,6 @@ public final class RSBlocks {
|
||||
public static final BlockExporter EXPORTER = new BlockExporter();
|
||||
public static final BlockDetector DETECTOR = new BlockDetector();
|
||||
public static final BlockMachineCasing MACHINE_CASING = new BlockMachineCasing();
|
||||
public static final BlockSolderer SOLDERER = new BlockSolderer();
|
||||
public static final BlockDestructor DESTRUCTOR = new BlockDestructor();
|
||||
public static final BlockConstructor CONSTRUCTOR = new BlockConstructor();
|
||||
public static final BlockStorage STORAGE = new BlockStorage();
|
||||
|
||||
@@ -36,7 +36,6 @@ public class RSConfig {
|
||||
public int interfaceUsage;
|
||||
public int fluidInterfaceUsage;
|
||||
public int relayUsage;
|
||||
public int soldererUsage;
|
||||
public int storageUsage;
|
||||
public int fluidStorageUsage;
|
||||
public int wirelessTransmitterUsage;
|
||||
@@ -103,7 +102,6 @@ public class RSConfig {
|
||||
//region Upgrades
|
||||
public int rangeUpgradeUsage;
|
||||
public int speedUpgradeUsage;
|
||||
public float soldererSpeedIncreasePerSpeedUpgrade;
|
||||
public int craftingUpgradeUsage;
|
||||
public int stackUpgradeUsage;
|
||||
public int interdimensionalUpgradeUsage;
|
||||
@@ -180,7 +178,6 @@ public class RSConfig {
|
||||
interfaceUsage = config.getInt("interface", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Interfaces");
|
||||
fluidInterfaceUsage = config.getInt("fluidInterface", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Fluid Interfaces");
|
||||
relayUsage = config.getInt("relay", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Relays");
|
||||
soldererUsage = config.getInt("solderer", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Solderers");
|
||||
storageUsage = config.getInt("storage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Storage Blocks");
|
||||
fluidStorageUsage = config.getInt("fluidStorage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Fluid Storage Blocks");
|
||||
wirelessTransmitterUsage = config.getInt("wirelessTransmitter", ENERGY, 8, 0, Integer.MAX_VALUE, "The energy used by Wireless Transmitters");
|
||||
@@ -247,7 +244,6 @@ public class RSConfig {
|
||||
//region Upgrades
|
||||
rangeUpgradeUsage = config.getInt("range", UPGRADES, 8, 0, Integer.MAX_VALUE, "The additional energy used per Range Upgrade");
|
||||
speedUpgradeUsage = config.getInt("speed", UPGRADES, 2, 0, Integer.MAX_VALUE, "The additional energy used per Speed Upgrade");
|
||||
soldererSpeedIncreasePerSpeedUpgrade = config.getFloat("soldererSpeedIncreasePerSpeedUpgrade", UPGRADES, 22.5F, 0F, 25F, "The speed increase percentage in the Solderer per Speed Upgrade");
|
||||
craftingUpgradeUsage = config.getInt("crafting", UPGRADES, 5, 0, Integer.MAX_VALUE, "The additional energy used per Crafting Upgrade");
|
||||
stackUpgradeUsage = config.getInt("stack", UPGRADES, 12, 0, Integer.MAX_VALUE, "The additional energy used per Stack Upgrade");
|
||||
interdimensionalUpgradeUsage = config.getInt("interdimensional", UPGRADES, 1000, 0, Integer.MAX_VALUE, "The additional energy used by the Interdimensional Upgrade");
|
||||
|
||||
@@ -7,7 +7,6 @@ public final class RSGui {
|
||||
public static final int IMPORTER = 3;
|
||||
public static final int EXPORTER = 4;
|
||||
public static final int DETECTOR = 5;
|
||||
public static final int SOLDERER = 6;
|
||||
public static final int DESTRUCTOR = 7;
|
||||
public static final int CONSTRUCTOR = 8;
|
||||
public static final int STORAGE = 9;
|
||||
|
||||
@@ -20,4 +20,5 @@ public final class RSItems {
|
||||
public static final ItemFluidStorageDisk FLUID_STORAGE_DISK = new ItemFluidStorageDisk();
|
||||
public static final ItemFluidStoragePart FLUID_STORAGE_PART = new ItemFluidStoragePart();
|
||||
public static final ItemSecurityCard SECURITY_CARD = new ItemSecurityCard();
|
||||
public static final ItemCuttingTool CUTTING_TOOL = new ItemCuttingTool();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskManager;
|
||||
@@ -67,12 +66,6 @@ public interface IRSAPI {
|
||||
*/
|
||||
INetworkNodeManager getNetworkNodeManager(World world);
|
||||
|
||||
/**
|
||||
* @return the solderer registry
|
||||
*/
|
||||
@Nonnull
|
||||
ISoldererRegistry getSoldererRegistry();
|
||||
|
||||
/**
|
||||
* @return the crafting task registry
|
||||
*/
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.solderer;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Represents a recipe in the solderer.
|
||||
*/
|
||||
public interface ISoldererRecipe {
|
||||
/**
|
||||
* @return the name of this solderer recipe
|
||||
*/
|
||||
ResourceLocation getName();
|
||||
|
||||
/**
|
||||
* @param row the row in the solderer that we want the stack for (between 0 - 2)
|
||||
* @return possible stack(s) for the given row, or empty list for no stack
|
||||
*/
|
||||
@Nonnull
|
||||
NonNullList<ItemStack> getRow(int row);
|
||||
|
||||
/**
|
||||
* @return the stack that this recipe gives back
|
||||
*/
|
||||
@Nonnull
|
||||
ItemStack getResult();
|
||||
|
||||
/**
|
||||
* @return the duration in ticks that this recipe takes to give the result back
|
||||
*/
|
||||
int getDuration();
|
||||
|
||||
/**
|
||||
* @return whether this recipe can be used to calculate the EMC value of the resulting item in the ProjectE mod
|
||||
*/
|
||||
default boolean isProjectERecipe() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.solderer;
|
||||
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The recipe registry of the solderer.
|
||||
*/
|
||||
public interface ISoldererRegistry {
|
||||
/**
|
||||
* Adds a recipe to the registry.
|
||||
*
|
||||
* @param recipe the recipe to add
|
||||
*/
|
||||
void addRecipe(@Nonnull ISoldererRecipe recipe);
|
||||
|
||||
/**
|
||||
* Returns a solderer recipe from the rows.
|
||||
*
|
||||
* @param ingredients an item handler, where slots 0 - 2 are the ingredient rows
|
||||
* @return the recipe, or null if no recipe was found
|
||||
*/
|
||||
@Nullable
|
||||
ISoldererRecipe getRecipe(@Nonnull IItemHandler ingredients);
|
||||
|
||||
/**
|
||||
* @return a list with all the solderer recipes
|
||||
*/
|
||||
List<ISoldererRecipe> getRecipes();
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.StorageType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskManager;
|
||||
@@ -37,7 +36,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeRegistry;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.wireless.WirelessGridRegistry;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterChannel;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterHandlerRegistry;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.solderer.SoldererRegistry;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.*;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.*;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
@@ -65,7 +63,6 @@ public class API implements IRSAPI {
|
||||
private IComparer comparer = new Comparer();
|
||||
private IQuantityFormatter quantityFormatter = new QuantityFormatter();
|
||||
private INetworkNodeRegistry networkNodeRegistry = new NetworkNodeRegistry();
|
||||
private ISoldererRegistry soldererRegistry = new SoldererRegistry();
|
||||
private ICraftingTaskRegistry craftingTaskRegistry = new CraftingTaskRegistry();
|
||||
private ICraftingMonitorElementRegistry craftingMonitorElementRegistry = new CraftingMonitorElementRegistry();
|
||||
private ICraftingPreviewElementRegistry craftingPreviewElementRegistry = new CraftingPreviewElementRegistry();
|
||||
@@ -138,12 +135,6 @@ public class API implements IRSAPI {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ISoldererRegistry getSoldererRegistry() {
|
||||
return soldererRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ICraftingTaskRegistry getCraftingTaskRegistry() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskError;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor.CraftingMonitorElementColor;
|
||||
@@ -31,6 +32,7 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -188,8 +190,10 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
took.add(possibleInput);
|
||||
|
||||
ItemStack fromSelf = results.get(possibleInput);
|
||||
ItemStack fromNetwork = mutatedStorage.get(possibleInput);
|
||||
int flags = getFlags(possibleInput);
|
||||
|
||||
ItemStack fromSelf = results.get(possibleInput, flags);
|
||||
ItemStack fromNetwork = mutatedStorage.get(possibleInput, flags);
|
||||
|
||||
int remaining = possibleInput.getCount();
|
||||
|
||||
@@ -199,11 +203,13 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
itemsToExtract.add(possibleInput, toTake);
|
||||
|
||||
results.remove(possibleInput, toTake);
|
||||
results.remove(fromSelf, toTake);
|
||||
|
||||
remaining -= toTake;
|
||||
|
||||
fromSelf = results.get(possibleInput);
|
||||
took.set(took.size() - 1, ItemHandlerHelper.copyStackWithSize(fromSelf, possibleInput.getCount()));
|
||||
|
||||
fromSelf = results.get(possibleInput, flags);
|
||||
} else if (fromNetwork != null) {
|
||||
int toTake = Math.min(remaining, fromNetwork.getCount());
|
||||
|
||||
@@ -211,11 +217,13 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
itemsToExtract.add(possibleInput, toTake);
|
||||
|
||||
mutatedStorage.remove(possibleInput, toTake);
|
||||
mutatedStorage.remove(fromNetwork, toTake);
|
||||
|
||||
remaining -= toTake;
|
||||
|
||||
fromNetwork = mutatedStorage.get(possibleInput);
|
||||
took.set(took.size() - 1, ItemHandlerHelper.copyStackWithSize(fromNetwork, possibleInput.getCount()));
|
||||
|
||||
fromNetwork = mutatedStorage.get(possibleInput, flags);
|
||||
} else {
|
||||
ICraftingPattern subPattern = network.getCraftingManager().getPattern(possibleInput);
|
||||
|
||||
@@ -231,12 +239,12 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
this.steps.add(result.getLeft());
|
||||
|
||||
fromSelf = results.get(possibleInput);
|
||||
fromSelf = results.get(possibleInput, flags);
|
||||
if (fromSelf == null) {
|
||||
throw new IllegalStateException("Recursive calculation didn't yield anything");
|
||||
}
|
||||
|
||||
fromNetwork = mutatedStorage.get(possibleInput);
|
||||
fromNetwork = mutatedStorage.get(possibleInput, flags);
|
||||
|
||||
subPatternChain.cycle();
|
||||
}
|
||||
@@ -586,4 +594,12 @@ public class CraftingTask implements ICraftingTask {
|
||||
throw new CraftingTaskReadException("Crafting pattern container doesn't exist anymore");
|
||||
}
|
||||
}
|
||||
|
||||
public static int getFlags(ItemStack stack) {
|
||||
if (stack.getItem().isDamageable()) {
|
||||
return IComparer.COMPARE_NBT;
|
||||
}
|
||||
|
||||
return IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.extractor;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.CraftingTask;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -68,7 +69,7 @@ public class CraftingExtractor {
|
||||
if (status.get(i) != CraftingExtractorItemStatus.EXTRACTED) {
|
||||
ItemStack stack = items.get(i);
|
||||
|
||||
ItemStack inNetwork = network.extractItem(stack, stack.getCount(), true);
|
||||
ItemStack inNetwork = network.extractItem(stack, stack.getCount(), CraftingTask.getFlags(stack), true);
|
||||
|
||||
CraftingExtractorItemStatus previousStatus = status.get(i);
|
||||
|
||||
@@ -108,7 +109,7 @@ public class CraftingExtractor {
|
||||
public void extractOne(@Nullable IItemHandler processingInventory) {
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
if (status.get(i) == CraftingExtractorItemStatus.AVAILABLE) {
|
||||
ItemStack extracted = network.extractItem(items.get(i), items.get(i).getCount(), false);
|
||||
ItemStack extracted = network.extractItem(items.get(i), items.get(i).getCount(), CraftingTask.getFlags(items.get(i)), false);
|
||||
if (extracted == null) {
|
||||
throw new IllegalStateException("Did not extract anything while available");
|
||||
}
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerProxy;
|
||||
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class NetworkNodeSolderer extends NetworkNode {
|
||||
public static final String ID = "solderer";
|
||||
|
||||
public static final String NBT_WORKING = "Working";
|
||||
private static final String NBT_PROGRESS = "Progress";
|
||||
|
||||
private ItemHandlerBase ingredients = new ItemHandlerBase(3, new ItemHandlerListenerNetworkNode(this)) {
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
for (ISoldererRecipe recipe : API.instance().getSoldererRegistry().getRecipes()) {
|
||||
for (ItemStack possibility : recipe.getRow(slot)) {
|
||||
if (API.instance().getComparer().isEqual(possibility, stack, IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE)) {
|
||||
return super.insertItem(slot, stack, simulate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
super.onContentsChanged(slot);
|
||||
|
||||
recipe = API.instance().getSoldererRegistry().getRecipe(ingredients);
|
||||
}
|
||||
};
|
||||
|
||||
private ItemHandlerBase result = new ItemHandlerBase(1, new ItemHandlerListenerNetworkNode(this)) {
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
return stack;
|
||||
}
|
||||
};
|
||||
|
||||
private ItemHandlerProxy items = new ItemHandlerProxy(ingredients, result);
|
||||
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED);
|
||||
|
||||
private boolean wasWorking;
|
||||
private boolean working;
|
||||
private ISoldererRecipe recipe;
|
||||
private int progress;
|
||||
|
||||
public NetworkNodeSolderer(World world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return RS.INSTANCE.config.soldererUsage + upgrades.getEnergyUsage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (wasWorking != working) {
|
||||
wasWorking = working;
|
||||
|
||||
markDirty();
|
||||
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
}
|
||||
|
||||
if (network == null || !canUpdate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (working) {
|
||||
if (recipe == null) {
|
||||
working = false;
|
||||
progress = 0;
|
||||
|
||||
markDirty();
|
||||
} else if ((result.getStackInSlot(0).isEmpty() || API.instance().getComparer().isEqualNoQuantity(recipe.getResult(), result.getStackInSlot(0))) && result.getStackInSlot(0).getCount() + recipe.getResult().getCount() <= result.getStackInSlot(0).getMaxStackSize()) {
|
||||
progress++;
|
||||
|
||||
if (progress >= getDuration()) {
|
||||
ItemStack resultSlot = result.getStackInSlot(0);
|
||||
|
||||
if (resultSlot.isEmpty()) {
|
||||
result.setStackInSlot(0, recipe.getResult().copy());
|
||||
} else {
|
||||
resultSlot.grow(recipe.getResult().getCount());
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
ItemStack ingredientSlot = ingredients.getStackInSlot(i);
|
||||
|
||||
if (!ingredientSlot.isEmpty()) {
|
||||
ingredientSlot.shrink(recipe.getRow(i).get(0).getCount());
|
||||
}
|
||||
}
|
||||
|
||||
recipe = API.instance().getSoldererRegistry().getRecipe(ingredients);
|
||||
progress = 0;
|
||||
}
|
||||
|
||||
markDirty();
|
||||
}
|
||||
} else if (recipe != null) {
|
||||
working = true;
|
||||
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectedStateChange(INetwork network, boolean state) {
|
||||
super.onConnectedStateChange(network, state);
|
||||
|
||||
if (!state) {
|
||||
recipe = null;
|
||||
progress = 0;
|
||||
working = false;
|
||||
} else {
|
||||
recipe = API.instance().getSoldererRegistry().getRecipe(ingredients);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(ingredients, 0, tag);
|
||||
StackUtils.readItems(upgrades, 1, tag);
|
||||
StackUtils.readItems(result, 2, tag);
|
||||
|
||||
recipe = API.instance().getSoldererRegistry().getRecipe(ingredients);
|
||||
|
||||
if (tag.hasKey(NBT_WORKING)) {
|
||||
working = tag.getBoolean(NBT_WORKING);
|
||||
wasWorking = working;
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_PROGRESS)) {
|
||||
progress = tag.getInteger(NBT_PROGRESS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(ingredients, 0, tag);
|
||||
StackUtils.writeItems(upgrades, 1, tag);
|
||||
StackUtils.writeItems(result, 2, tag);
|
||||
|
||||
tag.setBoolean(NBT_WORKING, working);
|
||||
tag.setInteger(NBT_PROGRESS, progress);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public ItemHandlerBase getIngredients() {
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
public ItemHandlerBase getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public ItemHandlerProxy getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
public boolean isWorking() {
|
||||
return working;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
if (recipe == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) ((float) recipe.getDuration() - ((float) recipe.getDuration() / 100F * ((float) upgrades.getUpgradeCount(ItemUpgrade.TYPE_SPEED) * RS.INSTANCE.config.soldererSpeedIncreasePerSpeedUpgrade)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getDrops() {
|
||||
return new CombinedInvWrapper(ingredients, result, upgrades);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.solderer;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SoldererRecipeFactory {
|
||||
private final ResourceLocation name;
|
||||
private JsonObject json;
|
||||
|
||||
public SoldererRecipeFactory(ResourceLocation name, JsonObject json) {
|
||||
this.name = name;
|
||||
this.json = json;
|
||||
}
|
||||
|
||||
public ISoldererRecipe create(JsonContext context) {
|
||||
JsonArray rowsArray = JsonUtils.getJsonArray(json, "rows");
|
||||
|
||||
if (rowsArray.size() != 3) {
|
||||
throw new JsonSyntaxException("Expected 3 rows, got " + rowsArray.size() + " rows");
|
||||
}
|
||||
|
||||
List<NonNullList<ItemStack>> rows = new ArrayList<>(3);
|
||||
|
||||
for (JsonElement element : rowsArray) {
|
||||
if (element.isJsonNull()) {
|
||||
rows.add(StackUtils.emptyNonNullList());
|
||||
} else {
|
||||
rows.add(NonNullList.from(ItemStack.EMPTY, CraftingHelper.getIngredient(element, context).getMatchingStacks()));
|
||||
}
|
||||
}
|
||||
|
||||
final ItemStack result = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context);
|
||||
final int duration = JsonUtils.getInt(json, "duration");
|
||||
final boolean projectERecipe = JsonUtils.getBoolean(json, "projecte", true);
|
||||
|
||||
return new ISoldererRecipe() {
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRow(int row) {
|
||||
return rows.get(row);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProjectERecipe() {
|
||||
return projectERecipe;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.solderer;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class SoldererRecipeLoader {
|
||||
private static Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
|
||||
public static void load() {
|
||||
for (ModContainer container : Loader.instance().getActiveModList()) {
|
||||
JsonContext context = new JsonContext(container.getModId());
|
||||
|
||||
CraftingHelper.findFiles(container, "assets/" + container.getModId() + "/solderer_recipes", root -> true, (root, file) -> {
|
||||
String relative = root.relativize(file).toString();
|
||||
|
||||
if (!"json".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String name = FilenameUtils.removeExtension(relative).replaceAll("\\\\", "/");
|
||||
ResourceLocation key = new ResourceLocation(container.getModId(), name);
|
||||
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = Files.newBufferedReader(file);
|
||||
|
||||
API.instance().getSoldererRegistry().addRecipe(new SoldererRecipeFactory(key, JsonUtils.fromJson(GSON, reader, JsonObject.class)).create(context));
|
||||
} catch (JsonParseException e) {
|
||||
FMLLog.log.error("Parsing error while reading JSON solderer recipe {}", key);
|
||||
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
FMLLog.log.error("Couldn't read JSON solderer recipe {}", key);
|
||||
|
||||
return false;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(reader);
|
||||
}
|
||||
|
||||
return true;
|
||||
}, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.solderer;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class SoldererRegistry implements ISoldererRegistry {
|
||||
private List<ISoldererRecipe> recipes = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public void addRecipe(@Nonnull ISoldererRecipe recipe) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ISoldererRecipe getRecipe(@Nonnull IItemHandler ingredients) {
|
||||
for (ISoldererRecipe recipe : recipes) {
|
||||
int rowsFound = 0;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
NonNullList<ItemStack> possibilities = recipe.getRow(i);
|
||||
|
||||
if (possibilities.isEmpty() && ingredients.getStackInSlot(i).isEmpty()) {
|
||||
rowsFound++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
for (ItemStack possibility : possibilities) {
|
||||
if (API.instance().getComparer().isEqual(possibility, ingredients.getStackInSlot(i), IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE)) {
|
||||
if (ingredients.getStackInSlot(i).getCount() >= possibility.getCount()) {
|
||||
rowsFound++;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rowsFound == 3) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ISoldererRecipe> getRecipes() {
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.block;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSGui;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileSolderer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockSolderer extends BlockNode {
|
||||
public BlockSolderer() {
|
||||
super("solderer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
return new TileSolderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (!world.isRemote) {
|
||||
tryOpenNetworkGui(RSGui.SOLDERER, player, world, pos, side);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileSolderer && ((TileSolderer) tile).isWorking()) {
|
||||
EnumFacing direction = getActualState(state, world, pos).getValue(getDirection().getProperty());
|
||||
|
||||
double x = 0;
|
||||
double y = (double) pos.getY() + 0.6D + rand.nextDouble() / 32F;
|
||||
double z = 0;
|
||||
|
||||
if (direction == EnumFacing.NORTH) {
|
||||
x = (double) pos.getX() + 0.4D;
|
||||
z = (double) pos.getZ() + 0.4D;
|
||||
} else if (direction == EnumFacing.EAST) {
|
||||
x = (double) pos.getX() + 0.6D;
|
||||
z = (double) pos.getZ() + 0.4D;
|
||||
} else if (direction == EnumFacing.SOUTH) {
|
||||
x = (double) pos.getX() + 0.6D;
|
||||
z = (double) pos.getZ() + 0.6D;
|
||||
} else if (direction == EnumFacing.WEST) {
|
||||
x = (double) pos.getX() + 0.4D;
|
||||
z = (double) pos.getZ() + 0.6D;
|
||||
}
|
||||
|
||||
int particles = rand.nextInt(5);
|
||||
|
||||
for (int i = 0; i < 1 + particles; ++i) {
|
||||
world.spawnParticle(
|
||||
EnumParticleTypes.SMOKE_NORMAL,
|
||||
x + (rand.nextDouble() / 16F * (rand.nextBoolean() ? 1 : -1)),
|
||||
y,
|
||||
z + (rand.nextDouble() / 16F * (rand.nextBoolean() ? 1 : -1)),
|
||||
0.0D,
|
||||
0.0D,
|
||||
0.0D
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.container;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.SlotOutput;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileSolderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class ContainerSolderer extends ContainerBase {
|
||||
public ContainerSolderer(TileSolderer solderer, EntityPlayer player) {
|
||||
super(solderer, player);
|
||||
|
||||
int x = 44;
|
||||
int y = 20;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
addSlotToContainer(new SlotItemHandler(solderer.getNode().getIngredients(), i, x, y));
|
||||
|
||||
y += 18;
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotOutput(solderer.getNode().getResult(), 0, 127, 38));
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotItemHandler(solderer.getNode().getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 89);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
|
||||
Slot slot = getSlot(index);
|
||||
|
||||
if (slot.getHasStack()) {
|
||||
stack = slot.getStack();
|
||||
|
||||
if (index < 4) {
|
||||
if (!mergeItemStack(stack, 4 + 4, inventorySlots.size(), false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (index < 4 + 4) {
|
||||
if (!mergeItemStack(stack, 4 + 4, inventorySlots.size(), false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else {
|
||||
if (stack.getItem() != RSItems.UPGRADE || !mergeItemStack(stack, 4, 4 + 4, false)) {
|
||||
if (!mergeItemStack(stack, 0, 3, false)) { // 0 - 3 because we can't shift click to output slot
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getCount() == 0) {
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,6 @@ public class GuiHandler implements IGuiHandler {
|
||||
return new ContainerExporter((TileExporter) tile, player);
|
||||
case RSGui.DETECTOR:
|
||||
return new ContainerDetector((TileDetector) tile, player);
|
||||
case RSGui.SOLDERER:
|
||||
return new ContainerSolderer((TileSolderer) tile, player);
|
||||
case RSGui.DESTRUCTOR:
|
||||
return new ContainerDestructor((TileDestructor) tile, player);
|
||||
case RSGui.CONSTRUCTOR:
|
||||
@@ -115,8 +113,6 @@ public class GuiHandler implements IGuiHandler {
|
||||
return new GuiExporter((ContainerExporter) getContainer(ID, player, tile));
|
||||
case RSGui.DETECTOR:
|
||||
return new GuiDetector((ContainerDetector) getContainer(ID, player, tile));
|
||||
case RSGui.SOLDERER:
|
||||
return new GuiSolderer((ContainerSolderer) getContainer(ID, player, tile));
|
||||
case RSGui.DESTRUCTOR:
|
||||
return new GuiDestructor((ContainerDestructor) getContainer(ID, player, tile));
|
||||
case RSGui.CONSTRUCTOR:
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerSolderer;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileSolderer;
|
||||
|
||||
public class GuiSolderer extends GuiBase {
|
||||
public GuiSolderer(ContainerSolderer container) {
|
||||
super(container, 211, 171);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
addSideButton(new SideButtonRedstoneMode(this, TileSolderer.REDSTONE_MODE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/solderer.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
if (TileSolderer.WORKING.getValue()) {
|
||||
drawTexture(x + 83, y + 38 - 1, 212, 0, getProgressScaled(22), 15);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:solderer"));
|
||||
drawString(7, 77, t("container.inventory"));
|
||||
}
|
||||
|
||||
private int getProgressScaled(int scale) {
|
||||
float progress = TileSolderer.PROGRESS.getValue();
|
||||
float duration = TileSolderer.DURATION.getValue();
|
||||
|
||||
if (progress > duration) {
|
||||
return scale;
|
||||
}
|
||||
|
||||
return (int) (progress / duration * (float) scale);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.jei;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerSolderer;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiSolderer;
|
||||
import mezz.jei.api.IJeiRuntime;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@JEIPlugin
|
||||
public class RSJEIPlugin implements IModPlugin {
|
||||
@@ -21,22 +16,8 @@ public class RSJEIPlugin implements IModPlugin {
|
||||
INSTANCE = this;
|
||||
|
||||
registry.getRecipeTransferRegistry().addUniversalRecipeTransferHandler(new RecipeTransferHandlerGrid());
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerSolderer.class, RecipeCategorySolderer.ID, 0, 3, 8, 36);
|
||||
|
||||
registry.handleRecipes(RecipeWrapperSolderer.class, recipe -> recipe, RecipeCategorySolderer.ID);
|
||||
|
||||
registry.addRecipes(RecipeMakerSolderer.getRecipes(registry.getJeiHelpers().getGuiHelper()), RecipeCategorySolderer.ID);
|
||||
|
||||
registry.addRecipeCatalyst(new ItemStack(RSBlocks.SOLDERER), RecipeCategorySolderer.ID);
|
||||
|
||||
registry.addAdvancedGuiHandlers(new GuiHandlerGrid());
|
||||
|
||||
registry.addRecipeClickArea(GuiSolderer.class, 80, 36, 22, 15, RecipeCategorySolderer.ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||
registry.addRecipeCategories(new RecipeCategorySolderer(registry.getJeiHelpers().getGuiHelper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.jei;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RecipeCategorySolderer implements IRecipeCategory<RecipeWrapperSolderer> {
|
||||
public static final String ID = "refinedstorage.solderer";
|
||||
|
||||
private IDrawable background;
|
||||
|
||||
public RecipeCategorySolderer(IGuiHelper helper) {
|
||||
this.background = helper.createDrawable(new ResourceLocation("refinedstorage", "textures/gui/solderer.png"), 43, 19, 101, 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18n.format("gui.refinedstorage:solderer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return I18n.format("itemGroup.refinedstorage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeWrapperSolderer recipeWrapper, @Nonnull IIngredients ingredients) {
|
||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
group.init(i, true, x, y);
|
||||
|
||||
y += 18;
|
||||
}
|
||||
|
||||
group.init(3, false, 83, 18);
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
group.set(i, ingredients.getInputs(ItemStack.class).get(i));
|
||||
}
|
||||
|
||||
group.set(3, ingredients.getOutputs(ItemStack.class).get(0));
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.jei;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.solderer.ISoldererRecipe;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class RecipeMakerSolderer {
|
||||
public static List<RecipeWrapperSolderer> getRecipes(IGuiHelper guiHelper) {
|
||||
List<RecipeWrapperSolderer> recipes = new ArrayList<>();
|
||||
|
||||
for (ISoldererRecipe recipe : API.instance().getSoldererRegistry().getRecipes()) {
|
||||
List<List<ItemStack>> inputs = new ArrayList<>();
|
||||
|
||||
inputs.add(recipe.getRow(0));
|
||||
inputs.add(recipe.getRow(1));
|
||||
inputs.add(recipe.getRow(2));
|
||||
|
||||
ItemStack output = recipe.getResult();
|
||||
|
||||
recipes.add(new RecipeWrapperSolderer(guiHelper, recipe.getDuration(), inputs, output));
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.jei;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RecipeWrapperSolderer implements IRecipeWrapper {
|
||||
private IDrawableAnimated progress;
|
||||
|
||||
private List<List<ItemStack>> inputs;
|
||||
private ItemStack output;
|
||||
|
||||
public RecipeWrapperSolderer(IGuiHelper guiHelper, int duration, List<List<ItemStack>> inputs, ItemStack output) {
|
||||
this.progress = guiHelper.createAnimatedDrawable(
|
||||
guiHelper.createDrawable(
|
||||
new ResourceLocation("refinedstorage", "textures/gui/solderer.png"),
|
||||
212,
|
||||
0,
|
||||
22,
|
||||
15
|
||||
),
|
||||
duration,
|
||||
IDrawableAnimated.StartDirection.LEFT,
|
||||
false
|
||||
);
|
||||
|
||||
this.inputs = inputs;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
ingredients.setInputLists(ItemStack.class, inputs);
|
||||
ingredients.setOutput(ItemStack.class, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
progress.draw(minecraft, 40, 18);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemCuttingTool extends ItemBase {
|
||||
public ItemCuttingTool() {
|
||||
super("cutting_tool");
|
||||
|
||||
setMaxDamage(50);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack stack) {
|
||||
ItemStack copy = stack.copy();
|
||||
|
||||
copy.setItemDamage(stack.getItemDamage() + 1);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,13 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class ItemProcessor extends ItemBase {
|
||||
public static final int TYPE_PRINTED_BASIC = 0;
|
||||
public static final int TYPE_PRINTED_IMPROVED = 1;
|
||||
public static final int TYPE_PRINTED_ADVANCED = 2;
|
||||
public static final int TYPE_CUT_BASIC = 0;
|
||||
public static final int TYPE_CUT_IMPROVED = 1;
|
||||
public static final int TYPE_CUT_ADVANCED = 2;
|
||||
public static final int TYPE_BASIC = 3;
|
||||
public static final int TYPE_IMPROVED = 4;
|
||||
public static final int TYPE_ADVANCED = 5;
|
||||
public static final int TYPE_PRINTED_SILICON = 6;
|
||||
public static final int TYPE_CUT_SILICON = 6;
|
||||
|
||||
public ItemProcessor() {
|
||||
super("processor");
|
||||
|
||||
@@ -167,13 +167,13 @@ public class ProxyClient extends ProxyCommon {
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.FLUID_STORAGE_PART, ItemFluidStoragePart.TYPE_1024K, new ModelResourceLocation("refinedstorage:1024k_fluid_storage_part", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.FLUID_STORAGE_PART, ItemFluidStoragePart.TYPE_4096K, new ModelResourceLocation("refinedstorage:4096k_fluid_storage_part", "inventory"));
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_BASIC, new ModelResourceLocation("refinedstorage:basic_printed_processor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_IMPROVED, new ModelResourceLocation("refinedstorage:improved_printed_processor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_ADVANCED, new ModelResourceLocation("refinedstorage:advanced_printed_processor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_CUT_BASIC, new ModelResourceLocation("refinedstorage:cut_basic_processor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_CUT_IMPROVED, new ModelResourceLocation("refinedstorage:cut_improved_processor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_CUT_ADVANCED, new ModelResourceLocation("refinedstorage:cut_advanced_processor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_BASIC, new ModelResourceLocation("refinedstorage:basic_processor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_IMPROVED, new ModelResourceLocation("refinedstorage:improved_processor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_ADVANCED, new ModelResourceLocation("refinedstorage:advanced_processor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_PRINTED_SILICON, new ModelResourceLocation("refinedstorage:printed_silicon", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.PROCESSOR, ItemProcessor.TYPE_CUT_SILICON, new ModelResourceLocation("refinedstorage:cut_silicon", "inventory"));
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.SILICON, 0, new ModelResourceLocation("refinedstorage:silicon", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.QUARTZ_ENRICHED_IRON, 0, new ModelResourceLocation("refinedstorage:quartz_enriched_iron", "inventory"));
|
||||
@@ -189,6 +189,7 @@ public class ProxyClient extends ProxyCommon {
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.FILTER, 0, new ModelResourceLocation("refinedstorage:filter", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.NETWORK_CARD, 0, new ModelResourceLocation("refinedstorage:network_card", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.SECURITY_CARD, 0, new ModelResourceLocation("refinedstorage:security_card", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.CUTTING_TOOL, 0, new ModelResourceLocation("refinedstorage:cutting_tool", "inventory"));
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, 0, new ModelResourceLocation("refinedstorage:upgrade", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RSItems.UPGRADE, ItemUpgrade.TYPE_RANGE, new ModelResourceLocation("refinedstorage:range_upgrade", "inventory"));
|
||||
@@ -207,7 +208,6 @@ public class ProxyClient extends ProxyCommon {
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.EXPORTER), 0, new ModelResourceLocation("refinedstorage:exporter", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.IMPORTER), 0, new ModelResourceLocation("refinedstorage:importer", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.EXTERNAL_STORAGE), 0, new ModelResourceLocation("refinedstorage:external_storage", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.SOLDERER), 0, new ModelResourceLocation("refinedstorage:solderer", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.INTERFACE), 0, new ModelResourceLocation("refinedstorage:interface", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.FLUID_INTERFACE), 0, new ModelResourceLocation("refinedstorage:fluid_interface", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.STORAGE), ItemStorageType.TYPE_1K.getId(), new ModelResourceLocation("refinedstorage:storage", "type=1k"));
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.raoulvdberge.refinedstorage.proxy;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
@@ -23,7 +21,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterHandlerFluids;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterHandlerItems;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterHandlerRedstone;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.solderer.SoldererRecipeLoader;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryFluid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryItem;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage.ExternalStorageProviderFluid;
|
||||
@@ -43,6 +40,7 @@ import com.raoulvdberge.refinedstorage.integration.funkylocomotion.MoveFactoryRe
|
||||
import com.raoulvdberge.refinedstorage.integration.inventorysorter.IntegrationInventorySorter;
|
||||
import com.raoulvdberge.refinedstorage.integration.oc.DriverNetwork;
|
||||
import com.raoulvdberge.refinedstorage.integration.oc.IntegrationOC;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemProcessor;
|
||||
import com.raoulvdberge.refinedstorage.network.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
|
||||
@@ -55,22 +53,14 @@ import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentData;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemEnchantedBook;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.IIngredientFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
@@ -84,7 +74,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -202,7 +191,6 @@ public class ProxyCommon {
|
||||
registerTile(TileImporter.class, "importer");
|
||||
registerTile(TileExporter.class, "exporter");
|
||||
registerTile(TileDetector.class, "detector");
|
||||
registerTile(TileSolderer.class, "solderer");
|
||||
registerTile(TileDestructor.class, "destructor");
|
||||
registerTile(TileConstructor.class, "constructor");
|
||||
registerTile(TileStorage.class, "storage");
|
||||
@@ -234,7 +222,6 @@ public class ProxyCommon {
|
||||
registerBlock(RSBlocks.DISK_DRIVE);
|
||||
registerBlock(RSBlocks.STORAGE);
|
||||
registerBlock(RSBlocks.FLUID_STORAGE);
|
||||
registerBlock(RSBlocks.SOLDERER);
|
||||
registerBlock(RSBlocks.CABLE);
|
||||
registerBlock(RSBlocks.IMPORTER);
|
||||
registerBlock(RSBlocks.EXPORTER);
|
||||
@@ -256,6 +243,7 @@ public class ProxyCommon {
|
||||
registerBlock(RSBlocks.CRAFTER_MANAGER);
|
||||
|
||||
registerItem(RSItems.QUARTZ_ENRICHED_IRON);
|
||||
registerItem(RSItems.CUTTING_TOOL);
|
||||
registerItem(RSItems.STORAGE_DISK);
|
||||
registerItem(RSItems.FLUID_STORAGE_DISK);
|
||||
registerItem(RSItems.STORAGE_HOUSING);
|
||||
@@ -279,31 +267,16 @@ public class ProxyCommon {
|
||||
public void init(FMLInitializationEvent e) {
|
||||
OreDictionary.registerOre("itemSilicon", RSItems.SILICON);
|
||||
|
||||
GameRegistry.addSmelting(Items.QUARTZ, new ItemStack(RSItems.SILICON), 0.5f);
|
||||
GameRegistry.addSmelting(Items.QUARTZ, new ItemStack(RSItems.SILICON), 0.5F);
|
||||
|
||||
GameRegistry.addSmelting(new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_CUT_BASIC), new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_BASIC), 0.5F);
|
||||
GameRegistry.addSmelting(new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_CUT_IMPROVED), new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED), 0.5F);
|
||||
GameRegistry.addSmelting(new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_CUT_ADVANCED), new ItemStack(RSItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED), 0.5F);
|
||||
|
||||
WirelessGrid.ID = API.instance().getWirelessGridRegistry().add(new WirelessGridFactoryWirelessGrid());
|
||||
WirelessFluidGrid.ID = API.instance().getWirelessGridRegistry().add(new WirelessGridFactoryWirelessFluidGrid());
|
||||
PortableGrid.ID = API.instance().getWirelessGridRegistry().add(new WirelessGridFactoryPortableGrid());
|
||||
|
||||
CraftingHelper.register(new ResourceLocation(RS.ID + ":enchanted_book"), new IIngredientFactory() {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient parse(JsonContext context, JsonObject json) {
|
||||
String id = JsonUtils.getString(json, "id");
|
||||
int level = JsonUtils.getInt(json, "level", 1);
|
||||
|
||||
Enchantment enchantment = Enchantment.getEnchantmentByLocation(id);
|
||||
|
||||
if (enchantment == null) {
|
||||
throw new JsonSyntaxException("Couldn't find enchantment with id '" + id + "'");
|
||||
}
|
||||
|
||||
return Ingredient.fromStacks(ItemEnchantedBook.getEnchantedItemStack(new EnchantmentData(enchantment, level)));
|
||||
}
|
||||
});
|
||||
|
||||
SoldererRecipeLoader.load();
|
||||
|
||||
if (IntegrationOC.isLoaded()) {
|
||||
DriverNetwork.register();
|
||||
}
|
||||
@@ -357,7 +330,18 @@ public class ProxyCommon {
|
||||
OneSixMigrationHelper.removalHook();
|
||||
|
||||
for (RegistryEvent.MissingMappings.Mapping<Item> missing : e.getMappings()) {
|
||||
if (missing.key.getResourceDomain().equals(RS.ID) && missing.key.getResourcePath().equals("wrench")) {
|
||||
if (missing.key.getResourceDomain().equals(RS.ID) && (missing.key.getResourcePath().equals("wrench") || missing.key.getResourcePath().equals("solderer"))) {
|
||||
missing.ignore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void fixBlockMappings(RegistryEvent.MissingMappings<Block> e) {
|
||||
OneSixMigrationHelper.removalHook();
|
||||
|
||||
for (RegistryEvent.MissingMappings.Mapping<Block> missing : e.getMappings()) {
|
||||
if (missing.key.getResourceDomain().equals(RS.ID) && missing.key.getResourcePath().equals("solderer")) {
|
||||
missing.ignore();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.raoulvdberge.refinedstorage.recipe;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentData;
|
||||
import net.minecraft.item.ItemEnchantedBook;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraftforge.common.crafting.IIngredientFactory;
|
||||
import net.minecraftforge.common.crafting.JsonContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class IngredientFactoryEnchantedBook implements IIngredientFactory {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient parse(JsonContext context, JsonObject json) {
|
||||
String id = JsonUtils.getString(json, "id");
|
||||
int level = JsonUtils.getInt(json, "level", 1);
|
||||
|
||||
Enchantment enchantment = Enchantment.getEnchantmentByLocation(id);
|
||||
|
||||
if (enchantment == null) {
|
||||
throw new JsonSyntaxException("Couldn't find enchantment with id '" + id + "'");
|
||||
}
|
||||
|
||||
return Ingredient.fromStacks(ItemEnchantedBook.getEnchantedItemStack(new EnchantmentData(enchantment, level)));
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.tile;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSolderer;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TileSolderer extends TileNode<NetworkNodeSolderer> {
|
||||
public static final TileDataParameter<Integer, TileSolderer> DURATION = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getDuration());
|
||||
public static final TileDataParameter<Integer, TileSolderer> PROGRESS = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getProgress());
|
||||
public static final TileDataParameter<Boolean, TileSolderer> WORKING = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isWorking());
|
||||
|
||||
private boolean working;
|
||||
|
||||
public TileSolderer() {
|
||||
dataManager.addWatchedParameter(DURATION);
|
||||
dataManager.addWatchedParameter(PROGRESS);
|
||||
dataManager.addWatchedParameter(WORKING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItems());
|
||||
}
|
||||
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeUpdate(NBTTagCompound tag) {
|
||||
super.writeUpdate(tag);
|
||||
|
||||
tag.setBoolean(NetworkNodeSolderer.NBT_WORKING, getNode().isWorking());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readUpdate(NBTTagCompound tag) {
|
||||
super.readUpdate(tag);
|
||||
|
||||
if (tag.hasKey(NetworkNodeSolderer.NBT_WORKING)) {
|
||||
working = tag.getBoolean(NetworkNodeSolderer.NBT_WORKING);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWorking() {
|
||||
return working;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canCauseRenderUpdate(NBTTagCompound tag) {
|
||||
EnumFacing receivedDirection = EnumFacing.getFront(tag.getInteger(NBT_DIRECTION));
|
||||
|
||||
return receivedDirection != getDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public NetworkNodeSolderer createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeSolderer(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeSolderer.ID;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user