blob: 40463b31d5c94783cecce791528148ce79c1c864 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* Copyright (c) 2018, 2019, 2020 shedaniel
* Licensed under the MIT License (the "License").
*/
package me.shedaniel.rei.tests.plugin;
import me.shedaniel.rei.api.EntryRegistry;
import me.shedaniel.rei.api.EntryStack;
import me.shedaniel.rei.api.plugins.REIPluginV0;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import org.apache.logging.log4j.LogManager;
import org.jetbrains.annotations.TestOnly;
import java.util.Collections;
import java.util.Random;
@TestOnly
public class REITestPlugin implements REIPluginV0 {
private Random random = new Random();
@Override
public void preRegister() {
LogManager.getLogger().error("REI Test Plugin is enabled! If you see this unintentionally, please report this!");
}
@Override
public Identifier getPluginIdentifier() {
return new Identifier("roughlyenoughitems:test_dev_plugin");
}
@Override
public void registerEntries(EntryRegistry entryRegistry) {
int times = 100;
for (Item item : Registry.ITEM) {
for (int i = 0; i < times; i++)
entryRegistry.queueRegisterEntryAfter(EntryStack.create(item), Collections.singleton(transformStack(EntryStack.create(item))));
try {
for (ItemStack stack : entryRegistry.appendStacksForItem(item)) {
for (int i = 0; i < times; i++)
entryRegistry.registerEntry(transformStack(EntryStack.create(stack)));
}
} catch (Exception ignored) {
}
}
}
public EntryStack transformStack(EntryStack stack) {
stack.setAmount(random.nextInt(Byte.MAX_VALUE));
return stack;
}
}
|