Fix more SonarQube warnings.
This commit is contained in:
@@ -24,6 +24,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|||||||
@Mod(RS.ID)
|
@Mod(RS.ID)
|
||||||
public final class RS {
|
public final class RS {
|
||||||
public static final String ID = "refinedstorage";
|
public static final String ID = "refinedstorage";
|
||||||
|
public static final String NAME = "Refined Storage";
|
||||||
|
|
||||||
public static final NetworkHandler NETWORK_HANDLER = new NetworkHandler();
|
public static final NetworkHandler NETWORK_HANDLER = new NetworkHandler();
|
||||||
public static final ItemGroup MAIN_GROUP = new MainItemGroup();
|
public static final ItemGroup MAIN_GROUP = new MainItemGroup();
|
||||||
|
@@ -18,10 +18,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public final class RSItems {
|
public final class RSItems {
|
||||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, RS.ID);
|
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, RS.ID);
|
||||||
@@ -47,17 +44,17 @@ public final class RSItems {
|
|||||||
public static final RegistryObject<WirelessCraftingMonitorItem> CREATIVE_WIRELESS_CRAFTING_MONITOR;
|
public static final RegistryObject<WirelessCraftingMonitorItem> CREATIVE_WIRELESS_CRAFTING_MONITOR;
|
||||||
public static final RegistryObject<BlockItem> MACHINE_CASING;
|
public static final RegistryObject<BlockItem> MACHINE_CASING;
|
||||||
|
|
||||||
public static final Map<ProcessorItem.Type, RegistryObject<ProcessorItem>> PROCESSORS = new HashMap<>();
|
public static final Map<ProcessorItem.Type, RegistryObject<ProcessorItem>> PROCESSORS = new EnumMap<>(ProcessorItem.Type.class);
|
||||||
|
|
||||||
public static final Map<ItemStorageType, RegistryObject<StoragePartItem>> ITEM_STORAGE_PARTS = new HashMap<>();
|
public static final Map<ItemStorageType, RegistryObject<StoragePartItem>> ITEM_STORAGE_PARTS = new EnumMap<>(ItemStorageType.class);
|
||||||
public static final Map<ItemStorageType, RegistryObject<StorageDiskItem>> ITEM_STORAGE_DISKS = new HashMap<>();
|
public static final Map<ItemStorageType, RegistryObject<StorageDiskItem>> ITEM_STORAGE_DISKS = new EnumMap<>(ItemStorageType.class);
|
||||||
public static final Map<ItemStorageType, RegistryObject<StorageBlockItem>> STORAGE_BLOCKS = new HashMap<>();
|
public static final Map<ItemStorageType, RegistryObject<StorageBlockItem>> STORAGE_BLOCKS = new EnumMap<>(ItemStorageType.class);
|
||||||
|
|
||||||
public static final Map<FluidStorageType, RegistryObject<FluidStoragePartItem>> FLUID_STORAGE_PARTS = new HashMap<>();
|
public static final Map<FluidStorageType, RegistryObject<FluidStoragePartItem>> FLUID_STORAGE_PARTS = new EnumMap<>(FluidStorageType.class);
|
||||||
public static final Map<FluidStorageType, RegistryObject<FluidStorageDiskItem>> FLUID_STORAGE_DISKS = new HashMap<>();
|
public static final Map<FluidStorageType, RegistryObject<FluidStorageDiskItem>> FLUID_STORAGE_DISKS = new EnumMap<>(FluidStorageType.class);
|
||||||
public static final Map<FluidStorageType, RegistryObject<FluidStorageBlockItem>> FLUID_STORAGE_BLOCKS = new HashMap<>();
|
public static final Map<FluidStorageType, RegistryObject<FluidStorageBlockItem>> FLUID_STORAGE_BLOCKS = new EnumMap<>(FluidStorageType.class);
|
||||||
|
|
||||||
public static final Map<UpgradeItem.Type, RegistryObject<UpgradeItem>> UPGRADE_ITEMS = new HashMap<>();
|
public static final Map<UpgradeItem.Type, RegistryObject<UpgradeItem>> UPGRADE_ITEMS = new EnumMap<>(UpgradeItem.Type.class);
|
||||||
|
|
||||||
public static final Map<Tags.IOptionalNamedTag<Item>, ColorMap<BlockItem>> COLORED_ITEM_TAGS = new HashMap<>();
|
public static final Map<Tags.IOptionalNamedTag<Item>, ColorMap<BlockItem>> COLORED_ITEM_TAGS = new HashMap<>();
|
||||||
|
|
||||||
@@ -202,6 +199,9 @@ public final class RSItems {
|
|||||||
LATE_REGISTRATION.forEach(Runnable::run);
|
LATE_REGISTRATION.forEach(Runnable::run);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private RSItems() {
|
||||||
|
}
|
||||||
|
|
||||||
private static <T extends BaseBlock> RegistryObject<BlockItem> registerBlockItemFor(RegistryObject<T> block) {
|
private static <T extends BaseBlock> RegistryObject<BlockItem> registerBlockItemFor(RegistryObject<T> block) {
|
||||||
return ITEMS.register(block.getId().getPath(), () -> new BaseBlockItem(block.get(), new Item.Properties().group(RS.MAIN_GROUP)));
|
return ITEMS.register(block.getId().getPath(), () -> new BaseBlockItem(block.get(), new Item.Properties().group(RS.MAIN_GROUP)));
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ public final class RSKeyBindings {
|
|||||||
KeyConflictContext.GUI,
|
KeyConflictContext.GUI,
|
||||||
InputMappings.Type.KEYSYM,
|
InputMappings.Type.KEYSYM,
|
||||||
GLFW.GLFW_KEY_TAB,
|
GLFW.GLFW_KEY_TAB,
|
||||||
"Refined Storage"
|
RS.NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final KeyBinding CLEAR_GRID_CRAFTING_MATRIX = new KeyBinding(
|
public static final KeyBinding CLEAR_GRID_CRAFTING_MATRIX = new KeyBinding(
|
||||||
@@ -21,34 +21,37 @@ public final class RSKeyBindings {
|
|||||||
KeyModifier.CONTROL,
|
KeyModifier.CONTROL,
|
||||||
InputMappings.Type.KEYSYM,
|
InputMappings.Type.KEYSYM,
|
||||||
GLFW.GLFW_KEY_X,
|
GLFW.GLFW_KEY_X,
|
||||||
"Refined Storage"
|
RS.NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final KeyBinding OPEN_WIRELESS_GRID = new KeyBinding(
|
public static final KeyBinding OPEN_WIRELESS_GRID = new KeyBinding(
|
||||||
"key.refinedstorage.openWirelessGrid",
|
"key.refinedstorage.openWirelessGrid",
|
||||||
KeyConflictContext.IN_GAME,
|
KeyConflictContext.IN_GAME,
|
||||||
InputMappings.INPUT_INVALID,
|
InputMappings.INPUT_INVALID,
|
||||||
"Refined Storage"
|
RS.NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final KeyBinding OPEN_WIRELESS_FLUID_GRID = new KeyBinding(
|
public static final KeyBinding OPEN_WIRELESS_FLUID_GRID = new KeyBinding(
|
||||||
"key.refinedstorage.openWirelessFluidGrid",
|
"key.refinedstorage.openWirelessFluidGrid",
|
||||||
KeyConflictContext.IN_GAME,
|
KeyConflictContext.IN_GAME,
|
||||||
InputMappings.INPUT_INVALID,
|
InputMappings.INPUT_INVALID,
|
||||||
"Refined Storage"
|
RS.NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final KeyBinding OPEN_WIRELESS_CRAFTING_MONITOR = new KeyBinding(
|
public static final KeyBinding OPEN_WIRELESS_CRAFTING_MONITOR = new KeyBinding(
|
||||||
"key.refinedstorage.openWirelessCraftingMonitor",
|
"key.refinedstorage.openWirelessCraftingMonitor",
|
||||||
KeyConflictContext.IN_GAME,
|
KeyConflictContext.IN_GAME,
|
||||||
InputMappings.INPUT_INVALID,
|
InputMappings.INPUT_INVALID,
|
||||||
"Refined Storage"
|
RS.NAME
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final KeyBinding OPEN_PORTABLE_GRID = new KeyBinding(
|
public static final KeyBinding OPEN_PORTABLE_GRID = new KeyBinding(
|
||||||
"key.refinedstorage.openPortableGrid",
|
"key.refinedstorage.openPortableGrid",
|
||||||
KeyConflictContext.IN_GAME,
|
KeyConflictContext.IN_GAME,
|
||||||
InputMappings.INPUT_INVALID,
|
InputMappings.INPUT_INVALID,
|
||||||
"Refined Storage"
|
RS.NAME
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
private RSKeyBindings() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -14,6 +14,9 @@ public final class RSLootFunctions {
|
|||||||
public static LootFunctionType CRAFTER;
|
public static LootFunctionType CRAFTER;
|
||||||
public static LootFunctionType CONTROLLER;
|
public static LootFunctionType CONTROLLER;
|
||||||
|
|
||||||
|
private RSLootFunctions() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
STORAGE_BLOCK = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "storage_block"), new LootFunctionType(new StorageBlockLootFunction.Serializer()));
|
STORAGE_BLOCK = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "storage_block"), new LootFunctionType(new StorageBlockLootFunction.Serializer()));
|
||||||
PORTABLE_GRID = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "portable_grid"), new LootFunctionType(new PortableGridBlockLootFunction.Serializer()));
|
PORTABLE_GRID = Registry.register(Registry.LOOT_FUNCTION_TYPE, new ResourceLocation(RS.ID, "portable_grid"), new LootFunctionType(new PortableGridBlockLootFunction.Serializer()));
|
||||||
|
@@ -85,4 +85,7 @@ public final class RSTiles {
|
|||||||
public static final TileEntityType<CrafterManagerTile> CRAFTER_MANAGER = null;
|
public static final TileEntityType<CrafterManagerTile> CRAFTER_MANAGER = null;
|
||||||
@ObjectHolder("crafting_monitor")
|
@ObjectHolder("crafting_monitor")
|
||||||
public static final TileEntityType<CraftingMonitorTile> CRAFTING_MONITOR = null;
|
public static final TileEntityType<CraftingMonitorTile> CRAFTING_MONITOR = null;
|
||||||
|
|
||||||
|
private RSTiles() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -151,7 +151,7 @@ public interface IRSAPI {
|
|||||||
* @param type the type
|
* @param type the type
|
||||||
* @return a set of external storage providers
|
* @return a set of external storage providers
|
||||||
*/
|
*/
|
||||||
Set<IExternalStorageProvider> getExternalStorageProviders(StorageType type);
|
Set<IExternalStorageProvider<?>> getExternalStorageProviders(StorageType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world the world
|
* @param world the world
|
||||||
|
@@ -14,7 +14,7 @@ public interface IStorageDiskRegistry {
|
|||||||
* @param id the id of this factory
|
* @param id the id of this factory
|
||||||
* @param factory the factory
|
* @param factory the factory
|
||||||
*/
|
*/
|
||||||
void add(ResourceLocation id, IStorageDiskFactory factory);
|
void add(ResourceLocation id, IStorageDiskFactory<?> factory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a factory.
|
* Gets a factory.
|
||||||
|
@@ -75,7 +75,7 @@ public class API implements IRSAPI {
|
|||||||
private final ICraftingGridBehavior craftingGridBehavior = new CraftingGridBehavior();
|
private final ICraftingGridBehavior craftingGridBehavior = new CraftingGridBehavior();
|
||||||
private final IStorageDiskRegistry storageDiskRegistry = new StorageDiskRegistry();
|
private final IStorageDiskRegistry storageDiskRegistry = new StorageDiskRegistry();
|
||||||
private final IStorageDiskSync storageDiskSync = new StorageDiskSync();
|
private final IStorageDiskSync storageDiskSync = new StorageDiskSync();
|
||||||
private final Map<StorageType, TreeSet<IExternalStorageProvider>> externalStorageProviders = new HashMap<>();
|
private final Map<StorageType, TreeSet<IExternalStorageProvider<?>>> externalStorageProviders = new EnumMap<>(StorageType.class);
|
||||||
private final List<ICraftingPatternRenderHandler> patternRenderHandlers = new LinkedList<>();
|
private final List<ICraftingPatternRenderHandler> patternRenderHandlers = new LinkedList<>();
|
||||||
|
|
||||||
public static IRSAPI instance() {
|
public static IRSAPI instance() {
|
||||||
@@ -206,13 +206,13 @@ public class API implements IRSAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addExternalStorageProvider(StorageType type, IExternalStorageProvider provider) {
|
public void addExternalStorageProvider(StorageType type, IExternalStorageProvider<?> provider) {
|
||||||
externalStorageProviders.computeIfAbsent(type, k -> new TreeSet<>((a, b) -> Integer.compare(b.getPriority(), a.getPriority()))).add(provider);
|
externalStorageProviders.computeIfAbsent(type, k -> new TreeSet<>((a, b) -> Integer.compare(b.getPriority(), a.getPriority()))).add(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<IExternalStorageProvider> getExternalStorageProviders(StorageType type) {
|
public Set<IExternalStorageProvider<?>> getExternalStorageProviders(StorageType type) {
|
||||||
TreeSet<IExternalStorageProvider> providers = externalStorageProviders.get(type);
|
TreeSet<IExternalStorageProvider<?>> providers = externalStorageProviders.get(type);
|
||||||
|
|
||||||
return providers == null ? Collections.emptySet() : providers;
|
return providers == null ? Collections.emptySet() : providers;
|
||||||
}
|
}
|
||||||
|
@@ -19,36 +19,23 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CraftingPattern implements ICraftingPattern {
|
public class CraftingPattern implements ICraftingPattern {
|
||||||
private final ICraftingPatternContainer container;
|
private final CraftingPatternContext context;
|
||||||
private final ItemStack stack;
|
|
||||||
private final boolean processing;
|
private final boolean processing;
|
||||||
private final boolean exact;
|
private final boolean exact;
|
||||||
private final boolean valid;
|
|
||||||
@Nullable
|
|
||||||
private final ITextComponent errorMessage;
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final ICraftingRecipe recipe;
|
private final ICraftingRecipe recipe;
|
||||||
private final List<NonNullList<ItemStack>> inputs;
|
private final CraftingPatternInputs inputs;
|
||||||
private final NonNullList<ItemStack> outputs;
|
private final CraftingPatternOutputs outputs;
|
||||||
private final NonNullList<ItemStack> byproducts;
|
|
||||||
private final List<NonNullList<FluidStack>> fluidInputs;
|
|
||||||
private final NonNullList<FluidStack> fluidOutputs;
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final AllowedTagList allowedTagList;
|
private final AllowedTagList allowedTagList;
|
||||||
|
|
||||||
public CraftingPattern(ICraftingPatternContainer container, ItemStack stack, boolean processing, boolean exact, @Nullable ITextComponent errorMessage, boolean valid, @Nullable ICraftingRecipe recipe, List<NonNullList<ItemStack>> inputs, NonNullList<ItemStack> outputs, NonNullList<ItemStack> byproducts, List<NonNullList<FluidStack>> fluidInputs, NonNullList<FluidStack> fluidOutputs, @Nullable AllowedTagList allowedTagList) {
|
public CraftingPattern(CraftingPatternContext context, boolean processing, boolean exact, @Nullable ICraftingRecipe recipe, CraftingPatternInputs inputs, CraftingPatternOutputs outputs, @Nullable AllowedTagList allowedTagList) {
|
||||||
this.container = container;
|
this.context = context;
|
||||||
this.stack = stack;
|
|
||||||
this.processing = processing;
|
this.processing = processing;
|
||||||
this.exact = exact;
|
this.exact = exact;
|
||||||
this.valid = valid;
|
|
||||||
this.errorMessage = errorMessage;
|
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
this.inputs = inputs;
|
this.inputs = inputs;
|
||||||
this.outputs = outputs;
|
this.outputs = outputs;
|
||||||
this.byproducts = byproducts;
|
|
||||||
this.fluidInputs = fluidInputs;
|
|
||||||
this.fluidOutputs = fluidOutputs;
|
|
||||||
this.allowedTagList = allowedTagList;
|
this.allowedTagList = allowedTagList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,23 +46,23 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICraftingPatternContainer getContainer() {
|
public ICraftingPatternContainer getContainer() {
|
||||||
return container;
|
return context.getContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStack() {
|
public ItemStack getStack() {
|
||||||
return stack;
|
return context.getStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return valid;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getErrorMessage() {
|
public ITextComponent getErrorMessage() {
|
||||||
return errorMessage;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,12 +72,12 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NonNullList<ItemStack>> getInputs() {
|
public List<NonNullList<ItemStack>> getInputs() {
|
||||||
return inputs;
|
return inputs.getInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NonNullList<ItemStack> getOutputs() {
|
public NonNullList<ItemStack> getOutputs() {
|
||||||
return outputs;
|
return outputs.getOutputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getOutput(NonNullList<ItemStack> took) {
|
public ItemStack getOutput(NonNullList<ItemStack> took) {
|
||||||
@@ -98,8 +85,8 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
throw new IllegalStateException("Cannot get crafting output from processing pattern");
|
throw new IllegalStateException("Cannot get crafting output from processing pattern");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (took.size() != inputs.size()) {
|
if (took.size() != inputs.getInputs().size()) {
|
||||||
throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.size() + ")");
|
throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.getInputs().size() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
CraftingInventory inv = new DummyCraftingInventory();
|
CraftingInventory inv = new DummyCraftingInventory();
|
||||||
@@ -122,7 +109,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
throw new IllegalStateException("Cannot get byproduct outputs from processing pattern");
|
throw new IllegalStateException("Cannot get byproduct outputs from processing pattern");
|
||||||
}
|
}
|
||||||
|
|
||||||
return byproducts;
|
return outputs.getByproducts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -131,8 +118,8 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
throw new IllegalStateException("Cannot get byproduct outputs from processing pattern");
|
throw new IllegalStateException("Cannot get byproduct outputs from processing pattern");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (took.size() != inputs.size()) {
|
if (took.size() != inputs.getInputs().size()) {
|
||||||
throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.size() + ")");
|
throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.getInputs().size() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
CraftingInventory inv = new DummyCraftingInventory();
|
CraftingInventory inv = new DummyCraftingInventory();
|
||||||
@@ -155,12 +142,12 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NonNullList<FluidStack>> getFluidInputs() {
|
public List<NonNullList<FluidStack>> getFluidInputs() {
|
||||||
return fluidInputs;
|
return inputs.getFluidInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NonNullList<FluidStack> getFluidOutputs() {
|
public NonNullList<FluidStack> getFluidOutputs() {
|
||||||
return fluidOutputs;
|
return outputs.getFluidOutputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -180,62 +167,62 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((other.getInputs().size() != inputs.size()) ||
|
if ((other.getInputs().size() != inputs.getInputs().size()) ||
|
||||||
(other.getFluidInputs().size() != fluidInputs.size()) ||
|
(other.getFluidInputs().size() != inputs.getFluidInputs().size()) ||
|
||||||
(other.getOutputs().size() != outputs.size()) ||
|
(other.getOutputs().size() != outputs.getOutputs().size()) ||
|
||||||
(other.getFluidOutputs().size() != fluidOutputs.size())) {
|
(other.getFluidOutputs().size() != outputs.getFluidOutputs().size())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!processing && other.getByproducts().size() != byproducts.size()) {
|
if (!processing && other.getByproducts().size() != outputs.getByproducts().size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < inputs.size(); ++i) {
|
for (int i = 0; i < inputs.getInputs().size(); ++i) {
|
||||||
List<ItemStack> inputs = this.inputs.get(i);
|
List<ItemStack> inputsForSlot = inputs.getInputs().get(i);
|
||||||
List<ItemStack> otherInputs = other.getInputs().get(i);
|
List<ItemStack> otherInputsForSlot = other.getInputs().get(i);
|
||||||
|
|
||||||
if (inputs.size() != otherInputs.size()) {
|
if (inputsForSlot.size() != otherInputsForSlot.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < inputs.size(); ++j) {
|
for (int j = 0; j < inputsForSlot.size(); ++j) {
|
||||||
if (!API.instance().getComparer().isEqual(inputs.get(j), otherInputs.get(j))) {
|
if (!API.instance().getComparer().isEqual(inputsForSlot.get(j), otherInputsForSlot.get(j))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fluidInputs.size(); ++i) {
|
for (int i = 0; i < inputs.getFluidInputs().size(); ++i) {
|
||||||
List<FluidStack> inputs = this.fluidInputs.get(i);
|
List<FluidStack> inputsForSlot = inputs.getFluidInputs().get(i);
|
||||||
List<FluidStack> otherInputs = other.getFluidInputs().get(i);
|
List<FluidStack> otherInputsForSlot = other.getFluidInputs().get(i);
|
||||||
|
|
||||||
if (inputs.size() != otherInputs.size()) {
|
if (inputsForSlot.size() != otherInputsForSlot.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < inputs.size(); ++j) {
|
for (int j = 0; j < inputsForSlot.size(); ++j) {
|
||||||
if (!API.instance().getComparer().isEqual(inputs.get(j), otherInputs.get(j), IComparer.COMPARE_NBT | IComparer.COMPARE_QUANTITY)) {
|
if (!API.instance().getComparer().isEqual(inputsForSlot.get(j), otherInputsForSlot.get(j), IComparer.COMPARE_NBT | IComparer.COMPARE_QUANTITY)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < outputs.size(); ++i) {
|
for (int i = 0; i < outputs.getOutputs().size(); ++i) {
|
||||||
if (!API.instance().getComparer().isEqual(outputs.get(i), other.getOutputs().get(i))) {
|
if (!API.instance().getComparer().isEqual(outputs.getOutputs().get(i), other.getOutputs().get(i))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fluidOutputs.size(); ++i) {
|
for (int i = 0; i < outputs.getFluidOutputs().size(); ++i) {
|
||||||
if (!API.instance().getComparer().isEqual(fluidOutputs.get(i), other.getFluidOutputs().get(i), IComparer.COMPARE_NBT | IComparer.COMPARE_QUANTITY)) {
|
if (!API.instance().getComparer().isEqual(outputs.getFluidOutputs().get(i), other.getFluidOutputs().get(i), IComparer.COMPARE_NBT | IComparer.COMPARE_QUANTITY)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!processing) {
|
if (!processing) {
|
||||||
for (int i = 0; i < byproducts.size(); ++i) {
|
for (int i = 0; i < outputs.getByproducts().size(); ++i) {
|
||||||
if (!API.instance().getComparer().isEqual(byproducts.get(i), other.getByproducts().get(i))) {
|
if (!API.instance().getComparer().isEqual(outputs.getByproducts().get(i), other.getByproducts().get(i))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,27 +238,27 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
result = 31 * result + (processing ? 1 : 0);
|
result = 31 * result + (processing ? 1 : 0);
|
||||||
result = 31 * result + (exact ? 1 : 0);
|
result = 31 * result + (exact ? 1 : 0);
|
||||||
|
|
||||||
for (List<ItemStack> inputs : this.inputs) {
|
for (List<ItemStack> inputsForSlot : inputs.getInputs()) {
|
||||||
for (ItemStack input : inputs) {
|
for (ItemStack input : inputsForSlot) {
|
||||||
result = 31 * result + API.instance().getItemStackHashCode(input);
|
result = 31 * result + API.instance().getItemStackHashCode(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (List<FluidStack> inputs : this.fluidInputs) {
|
for (List<FluidStack> inputsForSlot : inputs.getFluidInputs()) {
|
||||||
for (FluidStack input : inputs) {
|
for (FluidStack input : inputsForSlot) {
|
||||||
result = 31 * result + API.instance().getFluidStackHashCode(input);
|
result = 31 * result + API.instance().getFluidStackHashCode(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack output : this.outputs) {
|
for (ItemStack output : outputs.getOutputs()) {
|
||||||
result = 31 * result + API.instance().getItemStackHashCode(output);
|
result = 31 * result + API.instance().getItemStackHashCode(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (FluidStack output : this.fluidOutputs) {
|
for (FluidStack output : outputs.getFluidOutputs()) {
|
||||||
result = 31 * result + API.instance().getFluidStackHashCode(output);
|
result = 31 * result + API.instance().getFluidStackHashCode(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack byproduct : this.byproducts) {
|
for (ItemStack byproduct : outputs.getByproducts()) {
|
||||||
result = 31 * result + API.instance().getItemStackHashCode(byproduct);
|
result = 31 * result + API.instance().getItemStackHashCode(byproduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,22 @@
|
|||||||
|
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||||
|
|
||||||
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class CraftingPatternContext {
|
||||||
|
private final ICraftingPatternContainer container;
|
||||||
|
private final ItemStack stack;
|
||||||
|
|
||||||
|
public CraftingPatternContext(ICraftingPatternContainer container, ItemStack stack) {
|
||||||
|
this.container = container;
|
||||||
|
this.stack = stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICraftingPatternContainer getContainer() {
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getStack() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||||
|
|
||||||
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
@@ -12,7 +13,6 @@ import net.minecraft.tags.FluidTags;
|
|||||||
import net.minecraft.tags.ItemTags;
|
import net.minecraft.tags.ItemTags;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
@@ -23,7 +23,9 @@ import java.util.*;
|
|||||||
public class CraftingPatternFactory {
|
public class CraftingPatternFactory {
|
||||||
public static final CraftingPatternFactory INSTANCE = new CraftingPatternFactory();
|
public static final CraftingPatternFactory INSTANCE = new CraftingPatternFactory();
|
||||||
|
|
||||||
public CraftingPattern create(World world, ICraftingPatternContainer container, ItemStack stack) {
|
public ICraftingPattern create(World world, ICraftingPatternContainer container, ItemStack stack) {
|
||||||
|
CraftingPatternContext context = new CraftingPatternContext(container, stack);
|
||||||
|
|
||||||
boolean processing = PatternItem.isProcessing(stack);
|
boolean processing = PatternItem.isProcessing(stack);
|
||||||
boolean exact = PatternItem.isExact(stack);
|
boolean exact = PatternItem.isExact(stack);
|
||||||
AllowedTagList allowedTagList = PatternItem.getAllowedTags(stack);
|
AllowedTagList allowedTagList = PatternItem.getAllowedTags(stack);
|
||||||
@@ -34,8 +36,6 @@ public class CraftingPatternFactory {
|
|||||||
List<NonNullList<FluidStack>> fluidInputs = new ArrayList<>();
|
List<NonNullList<FluidStack>> fluidInputs = new ArrayList<>();
|
||||||
NonNullList<FluidStack> fluidOutputs = NonNullList.create();
|
NonNullList<FluidStack> fluidOutputs = NonNullList.create();
|
||||||
ICraftingRecipe recipe = null;
|
ICraftingRecipe recipe = null;
|
||||||
boolean valid = true;
|
|
||||||
ITextComponent errorMessage = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (processing) {
|
if (processing) {
|
||||||
@@ -76,11 +76,18 @@ public class CraftingPatternFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CraftingPatternFactoryException e) {
|
} catch (CraftingPatternFactoryException e) {
|
||||||
valid = false;
|
return new InvalidCraftingPattern(context, e.getErrorMessage());
|
||||||
errorMessage = e.getErrorMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CraftingPattern(container, stack, processing, exact, errorMessage, valid, recipe, inputs, outputs, byproducts, fluidInputs, fluidOutputs, allowedTagList);
|
return new CraftingPattern(
|
||||||
|
context,
|
||||||
|
processing,
|
||||||
|
exact,
|
||||||
|
recipe,
|
||||||
|
new CraftingPatternInputs(inputs, fluidInputs),
|
||||||
|
new CraftingPatternOutputs(outputs, byproducts, fluidOutputs),
|
||||||
|
allowedTagList
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillProcessingInputs(int i, ItemStack stack, List<NonNullList<ItemStack>> inputs, NonNullList<ItemStack> outputs, @Nullable AllowedTagList allowedTagList) throws CraftingPatternFactoryException {
|
private void fillProcessingInputs(int i, ItemStack stack, List<NonNullList<ItemStack>> inputs, NonNullList<ItemStack> outputs, @Nullable AllowedTagList allowedTagList) throws CraftingPatternFactoryException {
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CraftingPatternInputs {
|
||||||
|
private final List<NonNullList<ItemStack>> inputs;
|
||||||
|
private final List<NonNullList<FluidStack>> fluidInputs;
|
||||||
|
|
||||||
|
public CraftingPatternInputs(List<NonNullList<ItemStack>> inputs, List<NonNullList<FluidStack>> fluidInputs) {
|
||||||
|
this.inputs = inputs;
|
||||||
|
this.fluidInputs = fluidInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NonNullList<ItemStack>> getInputs() {
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NonNullList<FluidStack>> getFluidInputs() {
|
||||||
|
return fluidInputs;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,29 @@
|
|||||||
|
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
public class CraftingPatternOutputs {
|
||||||
|
private final NonNullList<ItemStack> outputs;
|
||||||
|
private final NonNullList<ItemStack> byproducts;
|
||||||
|
private final NonNullList<FluidStack> fluidOutputs;
|
||||||
|
|
||||||
|
public CraftingPatternOutputs(NonNullList<ItemStack> outputs, NonNullList<ItemStack> byproducts, NonNullList<FluidStack> fluidOutputs) {
|
||||||
|
this.outputs = outputs;
|
||||||
|
this.byproducts = byproducts;
|
||||||
|
this.fluidOutputs = fluidOutputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NonNullList<ItemStack> getOutputs() {
|
||||||
|
return outputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NonNullList<ItemStack> getByproducts() {
|
||||||
|
return byproducts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NonNullList<FluidStack> getFluidOutputs() {
|
||||||
|
return fluidOutputs;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,90 @@
|
|||||||
|
package com.refinedmods.refinedstorage.apiimpl.autocrafting;
|
||||||
|
|
||||||
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InvalidCraftingPattern implements ICraftingPattern {
|
||||||
|
private static final String EXCEPTION_MESSAGE = "Crafting pattern is invalid";
|
||||||
|
|
||||||
|
private final CraftingPatternContext context;
|
||||||
|
private final ITextComponent errorMessage;
|
||||||
|
|
||||||
|
public InvalidCraftingPattern(CraftingPatternContext context, ITextComponent errorMessage) {
|
||||||
|
this.context = context;
|
||||||
|
this.errorMessage = errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ICraftingPatternContainer getContainer() {
|
||||||
|
return context.getContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStack() {
|
||||||
|
return context.getStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public ITextComponent getErrorMessage() {
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isProcessing() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NonNullList<ItemStack>> getInputs() {
|
||||||
|
throw new IllegalStateException(EXCEPTION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NonNullList<ItemStack> getOutputs() {
|
||||||
|
throw new IllegalStateException(EXCEPTION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getOutput(NonNullList<ItemStack> took) {
|
||||||
|
throw new IllegalStateException(EXCEPTION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NonNullList<ItemStack> getByproducts() {
|
||||||
|
throw new IllegalStateException(EXCEPTION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NonNullList<ItemStack> getByproducts(NonNullList<ItemStack> took) {
|
||||||
|
throw new IllegalStateException(EXCEPTION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NonNullList<FluidStack>> getFluidInputs() {
|
||||||
|
throw new IllegalStateException(EXCEPTION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NonNullList<FluidStack> getFluidOutputs() {
|
||||||
|
throw new IllegalStateException(EXCEPTION_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation getCraftingTaskFactoryId() {
|
||||||
|
throw new IllegalStateException(EXCEPTION_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
@@ -212,17 +212,17 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
|||||||
|
|
||||||
if (facing != null) {
|
if (facing != null) {
|
||||||
if (type == IType.ITEMS) {
|
if (type == IType.ITEMS) {
|
||||||
for (IExternalStorageProvider<ItemStack> provider : API.instance().getExternalStorageProviders(StorageType.ITEM)) {
|
for (IExternalStorageProvider<?> provider : API.instance().getExternalStorageProviders(StorageType.ITEM)) {
|
||||||
if (provider.canProvide(facing, getDirection())) {
|
if (provider.canProvide(facing, getDirection())) {
|
||||||
itemStorages.add(provider.provide(this, getFacingTile(), getDirection()));
|
itemStorages.add((IExternalStorage<ItemStack>) provider.provide(this, getFacingTile(), getDirection()));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == IType.FLUIDS) {
|
} else if (type == IType.FLUIDS) {
|
||||||
for (IExternalStorageProvider<FluidStack> provider : API.instance().getExternalStorageProviders(StorageType.FLUID)) {
|
for (IExternalStorageProvider<?> provider : API.instance().getExternalStorageProviders(StorageType.FLUID)) {
|
||||||
if (provider.canProvide(facing, getDirection())) {
|
if (provider.canProvide(facing, getDirection())) {
|
||||||
fluidStorages.add(provider.provide(this, getFacingTile(), getDirection()));
|
fluidStorages.add((IExternalStorage<FluidStack>) provider.provide(this, getFacingTile(), getDirection()));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -4,8 +4,8 @@ import com.mojang.brigadier.Command;
|
|||||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.AllowedTagList;
|
import com.refinedmods.refinedstorage.apiimpl.autocrafting.AllowedTagList;
|
||||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
|
||||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||||
import com.refinedmods.refinedstorage.render.Styles;
|
import com.refinedmods.refinedstorage.render.Styles;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
@@ -30,7 +30,7 @@ public class PatternDumpCommand implements Command<CommandSource> {
|
|||||||
boolean exact = PatternItem.isExact(stack);
|
boolean exact = PatternItem.isExact(stack);
|
||||||
AllowedTagList allowedTagList = PatternItem.getAllowedTags(stack);
|
AllowedTagList allowedTagList = PatternItem.getAllowedTags(stack);
|
||||||
|
|
||||||
CraftingPattern pattern = PatternItem.fromCache(context.getSource().getWorld(), stack);
|
ICraftingPattern pattern = PatternItem.fromCache(context.getSource().getWorld(), stack);
|
||||||
|
|
||||||
context.getSource().sendFeedback(new StringTextComponent("Crafting task factory ID: ").setStyle(Styles.YELLOW).append(new StringTextComponent(pattern.getCraftingTaskFactoryId().toString()).setStyle(Styles.WHITE)), false);
|
context.getSource().sendFeedback(new StringTextComponent("Crafting task factory ID: ").setStyle(Styles.YELLOW).append(new StringTextComponent(pattern.getCraftingTaskFactoryId().toString()).setStyle(Styles.WHITE)), false);
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package com.refinedmods.refinedstorage.container;
|
package com.refinedmods.refinedstorage.container;
|
||||||
|
|
||||||
import com.refinedmods.refinedstorage.RSContainers;
|
import com.refinedmods.refinedstorage.RSContainers;
|
||||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.refinedmods.refinedstorage.apiimpl.network.node.CrafterManagerNetworkNode;
|
import com.refinedmods.refinedstorage.apiimpl.network.node.CrafterManagerNetworkNode;
|
||||||
import com.refinedmods.refinedstorage.container.slot.CrafterManagerSlot;
|
import com.refinedmods.refinedstorage.container.slot.CrafterManagerSlot;
|
||||||
import com.refinedmods.refinedstorage.inventory.item.BaseItemHandler;
|
import com.refinedmods.refinedstorage.inventory.item.BaseItemHandler;
|
||||||
@@ -114,7 +114,7 @@ public class CrafterManagerContainer extends BaseContainer {
|
|||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
visible = false;
|
visible = false;
|
||||||
} else {
|
} else {
|
||||||
CraftingPattern pattern = PatternItem.fromCache(crafterManager.getWorld(), stack);
|
ICraftingPattern pattern = PatternItem.fromCache(crafterManager.getWorld(), stack);
|
||||||
|
|
||||||
visible = false;
|
visible = false;
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PatternItem extends Item implements ICraftingPatternProvider {
|
public class PatternItem extends Item implements ICraftingPatternProvider {
|
||||||
private static final Map<ItemStack, CraftingPattern> CACHE = new HashMap<>();
|
private static final Map<ItemStack, ICraftingPattern> CACHE = new HashMap<>();
|
||||||
|
|
||||||
private static final String NBT_VERSION = "Version";
|
private static final String NBT_VERSION = "Version";
|
||||||
private static final String NBT_INPUT_SLOT = "Input_%d";
|
private static final String NBT_INPUT_SLOT = "Input_%d";
|
||||||
@@ -52,7 +52,7 @@ public class PatternItem extends Item implements ICraftingPatternProvider {
|
|||||||
super(new Item.Properties().group(RS.MAIN_GROUP).setISTER(() -> PatternItemStackTileRenderer::new));
|
super(new Item.Properties().group(RS.MAIN_GROUP).setISTER(() -> PatternItemStackTileRenderer::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CraftingPattern fromCache(World world, ItemStack stack) {
|
public static ICraftingPattern fromCache(World world, ItemStack stack) {
|
||||||
if (!CACHE.containsKey(stack)) {
|
if (!CACHE.containsKey(stack)) {
|
||||||
CACHE.put(stack, CraftingPatternFactory.INSTANCE.create(world, null, stack));
|
CACHE.put(stack, CraftingPatternFactory.INSTANCE.create(world, null, stack));
|
||||||
}
|
}
|
||||||
@@ -68,14 +68,14 @@ public class PatternItem extends Item implements ICraftingPatternProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CraftingPattern pattern = fromCache(world, stack);
|
ICraftingPattern pattern = fromCache(world, stack);
|
||||||
|
|
||||||
if (pattern.isValid()) {
|
if (pattern.isValid()) {
|
||||||
if (ContainerScreen.hasShiftDown() || isProcessing(stack)) {
|
if (ContainerScreen.hasShiftDown() || isProcessing(stack)) {
|
||||||
tooltip.add(new TranslationTextComponent("misc.refinedstorage.pattern.inputs").setStyle(Styles.YELLOW));
|
tooltip.add(new TranslationTextComponent("misc.refinedstorage.pattern.inputs").setStyle(Styles.YELLOW));
|
||||||
|
|
||||||
RenderUtils.addCombinedItemsToTooltip(tooltip, true, pattern.getInputs().stream().map(i -> i.size() > 0 ? i.get(0) : ItemStack.EMPTY).collect(Collectors.toList()));
|
RenderUtils.addCombinedItemsToTooltip(tooltip, true, pattern.getInputs().stream().map(i -> !i.isEmpty() ? i.get(0) : ItemStack.EMPTY).collect(Collectors.toList()));
|
||||||
RenderUtils.addCombinedFluidsToTooltip(tooltip, true, pattern.getFluidInputs().stream().map(i -> i.size() > 0 ? i.get(0) : FluidStack.EMPTY).collect(Collectors.toList()));
|
RenderUtils.addCombinedFluidsToTooltip(tooltip, true, pattern.getFluidInputs().stream().map(i -> !i.isEmpty() ? i.get(0) : FluidStack.EMPTY).collect(Collectors.toList()));
|
||||||
|
|
||||||
tooltip.add(new TranslationTextComponent("misc.refinedstorage.pattern.outputs").setStyle(Styles.YELLOW));
|
tooltip.add(new TranslationTextComponent("misc.refinedstorage.pattern.outputs").setStyle(Styles.YELLOW));
|
||||||
}
|
}
|
||||||
@@ -83,30 +83,8 @@ public class PatternItem extends Item implements ICraftingPatternProvider {
|
|||||||
RenderUtils.addCombinedItemsToTooltip(tooltip, true, pattern.getOutputs());
|
RenderUtils.addCombinedItemsToTooltip(tooltip, true, pattern.getOutputs());
|
||||||
RenderUtils.addCombinedFluidsToTooltip(tooltip, true, pattern.getFluidOutputs());
|
RenderUtils.addCombinedFluidsToTooltip(tooltip, true, pattern.getFluidOutputs());
|
||||||
|
|
||||||
if (pattern.getAllowedTagList() != null) {
|
if (pattern instanceof CraftingPattern && ((CraftingPattern) pattern).getAllowedTagList() != null) {
|
||||||
for (int i = 0; i < pattern.getAllowedTagList().getAllowedItemTags().size(); ++i) {
|
addAllowedTags(tooltip, (CraftingPattern) pattern);
|
||||||
Set<ResourceLocation> allowedTags = pattern.getAllowedTagList().getAllowedItemTags().get(i);
|
|
||||||
|
|
||||||
for (ResourceLocation tag : allowedTags) {
|
|
||||||
tooltip.add(new TranslationTextComponent(
|
|
||||||
"misc.refinedstorage.pattern.allowed_item_tag",
|
|
||||||
tag.toString(),
|
|
||||||
pattern.getInputs().get(i).get(0).getDisplayName()
|
|
||||||
).setStyle(Styles.AQUA));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < pattern.getAllowedTagList().getAllowedFluidTags().size(); ++i) {
|
|
||||||
Set<ResourceLocation> allowedTags = pattern.getAllowedTagList().getAllowedFluidTags().get(i);
|
|
||||||
|
|
||||||
for (ResourceLocation tag : allowedTags) {
|
|
||||||
tooltip.add(new TranslationTextComponent(
|
|
||||||
"misc.refinedstorage.pattern.allowed_fluid_tag",
|
|
||||||
tag.toString(),
|
|
||||||
pattern.getFluidInputs().get(i).get(0).getDisplayName()
|
|
||||||
).setStyle(Styles.AQUA));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isExact(stack)) {
|
if (isExact(stack)) {
|
||||||
@@ -122,6 +100,32 @@ public class PatternItem extends Item implements ICraftingPatternProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAllowedTags(List<ITextComponent> tooltip, CraftingPattern pattern) {
|
||||||
|
for (int i = 0; i < pattern.getAllowedTagList().getAllowedItemTags().size(); ++i) {
|
||||||
|
Set<ResourceLocation> allowedTags = pattern.getAllowedTagList().getAllowedItemTags().get(i);
|
||||||
|
|
||||||
|
for (ResourceLocation tag : allowedTags) {
|
||||||
|
tooltip.add(new TranslationTextComponent(
|
||||||
|
"misc.refinedstorage.pattern.allowed_item_tag",
|
||||||
|
tag.toString(),
|
||||||
|
pattern.getInputs().get(i).get(0).getDisplayName()
|
||||||
|
).setStyle(Styles.AQUA));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < pattern.getAllowedTagList().getAllowedFluidTags().size(); ++i) {
|
||||||
|
Set<ResourceLocation> allowedTags = pattern.getAllowedTagList().getAllowedFluidTags().get(i);
|
||||||
|
|
||||||
|
for (ResourceLocation tag : allowedTags) {
|
||||||
|
tooltip.add(new TranslationTextComponent(
|
||||||
|
"misc.refinedstorage.pattern.allowed_fluid_tag",
|
||||||
|
tag.toString(),
|
||||||
|
pattern.getFluidInputs().get(i).get(0).getDisplayName()
|
||||||
|
).setStyle(Styles.AQUA));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||||
if (!world.isRemote && player.isCrouching()) {
|
if (!world.isRemote && player.isCrouching()) {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package com.refinedmods.refinedstorage.render.color;
|
package com.refinedmods.refinedstorage.render.color;
|
||||||
|
|
||||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||||
import com.refinedmods.refinedstorage.render.model.PatternBakedModel;
|
import com.refinedmods.refinedstorage.render.model.PatternBakedModel;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
public class PatternItemColor implements IItemColor {
|
public class PatternItemColor implements IItemColor {
|
||||||
@Override
|
@Override
|
||||||
public int getColor(ItemStack stack, int tintIndex) {
|
public int getColor(ItemStack stack, int tintIndex) {
|
||||||
CraftingPattern pattern = PatternItem.fromCache(Minecraft.getInstance().world, stack);
|
ICraftingPattern pattern = PatternItem.fromCache(Minecraft.getInstance().world, stack);
|
||||||
|
|
||||||
if (PatternBakedModel.canDisplayOutput(stack, pattern)) {
|
if (PatternBakedModel.canDisplayOutput(stack, pattern)) {
|
||||||
int color = Minecraft.getInstance().getItemColors().getColor(pattern.getOutputs().get(0), tintIndex);
|
int color = Minecraft.getInstance().getItemColors().getColor(pattern.getOutputs().get(0), tintIndex);
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
package com.refinedmods.refinedstorage.render.model;
|
package com.refinedmods.refinedstorage.render.model;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternRenderHandler;
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPatternRenderHandler;
|
||||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
|
||||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
@@ -27,7 +27,7 @@ public class PatternBakedModel extends DelegateBakedModel {
|
|||||||
@Override
|
@Override
|
||||||
public IBakedModel func_239290_a_(IBakedModel model, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity) {
|
public IBakedModel func_239290_a_(IBakedModel model, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity) {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
CraftingPattern pattern = PatternItem.fromCache(entity.world, stack);
|
ICraftingPattern pattern = PatternItem.fromCache(entity.world, stack);
|
||||||
|
|
||||||
if (canDisplayOutput(stack, pattern)) {
|
if (canDisplayOutput(stack, pattern)) {
|
||||||
ItemStack outputToRender = pattern.getOutputs().get(0);
|
ItemStack outputToRender = pattern.getOutputs().get(0);
|
||||||
@@ -46,7 +46,7 @@ public class PatternBakedModel extends DelegateBakedModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canDisplayOutput(ItemStack patternStack, CraftingPattern pattern) {
|
public static boolean canDisplayOutput(ItemStack patternStack, ICraftingPattern pattern) {
|
||||||
if (pattern.isValid() && pattern.getOutputs().size() == 1) {
|
if (pattern.isValid() && pattern.getOutputs().size() == 1) {
|
||||||
for (ICraftingPatternRenderHandler renderHandler : API.instance().getPatternRenderHandlers()) {
|
for (ICraftingPatternRenderHandler renderHandler : API.instance().getPatternRenderHandlers()) {
|
||||||
if (renderHandler.canRenderOutput(patternStack)) {
|
if (renderHandler.canRenderOutput(patternStack)) {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package com.refinedmods.refinedstorage.render.tesr;
|
package com.refinedmods.refinedstorage.render.tesr;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
import com.refinedmods.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
import com.refinedmods.refinedstorage.item.PatternItem;
|
import com.refinedmods.refinedstorage.item.PatternItem;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
@@ -11,10 +11,10 @@ import net.minecraft.item.ItemStack;
|
|||||||
public class PatternItemStackTileRenderer extends ItemStackTileEntityRenderer {
|
public class PatternItemStackTileRenderer extends ItemStackTileEntityRenderer {
|
||||||
@Override
|
@Override
|
||||||
public void func_239207_a_(ItemStack stack, ItemCameraTransforms.TransformType transformType, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int p_239207_5_, int p_239207_6_) {
|
public void func_239207_a_(ItemStack stack, ItemCameraTransforms.TransformType transformType, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int p_239207_5_, int p_239207_6_) {
|
||||||
CraftingPattern pattern = PatternItem.fromCache(null, stack);
|
ICraftingPattern pattern = PatternItem.fromCache(null, stack);
|
||||||
|
|
||||||
ItemStack outputStack = pattern.getOutputs().get(0);
|
ItemStack outputStack = pattern.getOutputs().get(0);
|
||||||
|
|
||||||
outputStack.getItem().getItemStackTileEntityRenderer().func_239207_a_(outputStack, transformType, matrixStack, renderTypeBuffer, p_239207_5_, p_239207_6_);
|
outputStack.getItem().getItemStackTileEntityRenderer().func_239207_a_(outputStack, transformType, matrixStack, renderTypeBuffer, p_239207_5_, p_239207_6_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user