tangled
alpha
login
or
join now
codexarchonic.nekoweb.org
/
ProjectInfinity
0
fork
atom
Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
0
fork
atom
overview
issues
6
pulls
pipelines
Iridescence recipes
cassian.cc
9 months ago
7eb106c6
6b6b66d1
+199
-5
5 changed files
expand all
collapse all
unified
split
common
src
main
java
net
lerariemann
infinity
compat
eiv
EivIntegration.java
iridescence_crafting
IridescenceCraftingServerRecipe.java
IridescenceCraftingViewRecipe.java
IridescenceCraftingViewType.java
portal_crafting
PortalCraftingViewRecipe.java
+6
common/src/main/java/net/lerariemann/infinity/compat/eiv/EivIntegration.java
reviewed
···
3
3
import de.crafty.eiv.common.api.IExtendedItemViewIntegration;
4
4
import de.crafty.eiv.common.api.recipe.ItemView;
5
5
import de.crafty.eiv.common.recipe.ServerRecipeManager;
6
6
+
import net.lerariemann.infinity.compat.eiv.iridescence_crafting.IridescenceCraftingServerRecipe;
7
7
+
import net.lerariemann.infinity.compat.eiv.iridescence_crafting.IridescenceCraftingViewRecipe;
6
8
import net.lerariemann.infinity.compat.eiv.portal_crafting.PortalCraftingServerRecipe;
7
9
import net.lerariemann.infinity.compat.eiv.portal_crafting.PortalCraftingViewRecipe;
8
10
import net.lerariemann.infinity.item.function.CollisionCraftingRecipe;
···
17
19
ItemView.addRecipeProvider(recipeList -> {
18
20
// Portal Crafting - serverside
19
21
ServerRecipeManager.INSTANCE.getRecipesForType(CollisionCraftingRecipe.Type.PORTAL).forEach(recipe -> recipeList.add(new PortalCraftingServerRecipe(recipe.getInput(), recipe.getResult(), recipe.getLore())));
22
22
+
// Iridescence Crafting - serverside
23
23
+
ServerRecipeManager.INSTANCE.getRecipesForType(CollisionCraftingRecipe.Type.IRIDESCENCE).forEach(recipe -> recipeList.add(new IridescenceCraftingServerRecipe(recipe.getInput(), recipe.getResult(), recipe.getLore())));
20
24
});
21
25
// Portal Crafting - Clientside
22
26
ItemView.registerRecipeWrapper(PortalCraftingServerRecipe.TYPE, modRecipe -> Collections.singletonList(new PortalCraftingViewRecipe(modRecipe)));
27
27
+
// Iridescence Crafting - Clientside
28
28
+
ItemView.registerRecipeWrapper(IridescenceCraftingServerRecipe.TYPE, modRecipe -> Collections.singletonList(new IridescenceCraftingViewRecipe(modRecipe)));
23
29
}
24
30
}
+59
common/src/main/java/net/lerariemann/infinity/compat/eiv/iridescence_crafting/IridescenceCraftingServerRecipe.java
reviewed
···
1
1
+
package net.lerariemann.infinity.compat.eiv.iridescence_crafting;
2
2
+
3
3
+
import de.crafty.eiv.common.api.recipe.EivRecipeType;
4
4
+
import de.crafty.eiv.common.api.recipe.IEivServerRecipe;
5
5
+
import de.crafty.eiv.common.recipe.util.EivTagUtil;
6
6
+
import net.lerariemann.infinity.util.InfinityMethods;
7
7
+
import net.minecraft.item.ItemStack;
8
8
+
import net.minecraft.nbt.NbtCompound;
9
9
+
import net.minecraft.nbt.NbtString;
10
10
+
import net.minecraft.recipe.Ingredient;
11
11
+
12
12
+
public class IridescenceCraftingServerRecipe implements IEivServerRecipe {
13
13
+
14
14
+
//Create a server recipe type (the id does not have to match your client side viewtype id)
15
15
+
public static final EivRecipeType<IridescenceCraftingServerRecipe> TYPE = EivRecipeType.register(
16
16
+
InfinityMethods.getId("iridescence_crafting"),
17
17
+
() -> new IridescenceCraftingServerRecipe(null, null, null)
18
18
+
);
19
19
+
private Ingredient input;
20
20
+
private ItemStack output;
21
21
+
private String lore;
22
22
+
23
23
+
public IridescenceCraftingServerRecipe(Ingredient input, ItemStack output, String lore) {
24
24
+
this.input = input;
25
25
+
this.output = output;
26
26
+
this.lore = lore;
27
27
+
}
28
28
+
29
29
+
public Ingredient getIngredient() {
30
30
+
return this.input;
31
31
+
}
32
32
+
33
33
+
public ItemStack getResult() {
34
34
+
return this.output;
35
35
+
}
36
36
+
37
37
+
public String getLore() {
38
38
+
return this.lore;
39
39
+
}
40
40
+
41
41
+
@Override
42
42
+
public void writeToTag(NbtCompound tag) {
43
43
+
tag.put("ingredient", EivTagUtil.writeIngredient(this.input));
44
44
+
tag.put("result", EivTagUtil.encodeItemStack(this.output));
45
45
+
tag.put("lore", NbtString.of(this.lore));
46
46
+
}
47
47
+
48
48
+
@Override
49
49
+
public void loadFromTag(NbtCompound tag) {
50
50
+
this.input = EivTagUtil.readIngredient(tag.getCompound("ingredient"));
51
51
+
this.output = EivTagUtil.decodeItemStack(tag.getCompound("result"));
52
52
+
this.lore = tag.getString("lore");
53
53
+
}
54
54
+
55
55
+
@Override
56
56
+
public EivRecipeType<? extends IEivServerRecipe> getRecipeType() {
57
57
+
return TYPE;
58
58
+
}
59
59
+
}
+70
common/src/main/java/net/lerariemann/infinity/compat/eiv/iridescence_crafting/IridescenceCraftingViewRecipe.java
reviewed
···
1
1
+
package net.lerariemann.infinity.compat.eiv.iridescence_crafting;
2
2
+
3
3
+
import de.crafty.eiv.common.api.recipe.IEivRecipeViewType;
4
4
+
import de.crafty.eiv.common.api.recipe.IEivViewRecipe;
5
5
+
import de.crafty.eiv.common.recipe.inventory.RecipeViewMenu;
6
6
+
import de.crafty.eiv.common.recipe.inventory.SlotContent;
7
7
+
import net.lerariemann.infinity.item.PortalDataHolder;
8
8
+
import net.lerariemann.infinity.registry.core.ModBlocks;
9
9
+
import net.lerariemann.infinity.registry.core.ModComponentTypes;
10
10
+
import net.lerariemann.infinity.registry.core.ModItems;
11
11
+
import net.lerariemann.infinity.util.InfinityMethods;
12
12
+
import net.lerariemann.infinity.util.var.ColorLogic;
13
13
+
import net.minecraft.client.resource.language.I18n;
14
14
+
import net.minecraft.component.ComponentChanges;
15
15
+
import net.minecraft.component.DataComponentTypes;
16
16
+
import net.minecraft.item.ItemStack;
17
17
+
import net.minecraft.recipe.Ingredient;
18
18
+
import net.minecraft.text.Text;
19
19
+
import net.minecraft.util.Identifier;
20
20
+
21
21
+
import java.util.List;
22
22
+
23
23
+
public class IridescenceCraftingViewRecipe implements IEivViewRecipe {
24
24
+
25
25
+
private final SlotContent input, output;
26
26
+
private String lore;
27
27
+
28
28
+
public IridescenceCraftingViewRecipe(IridescenceCraftingServerRecipe modRecipe) {
29
29
+
var output = modRecipe.getResult();
30
30
+
ComponentChanges.Builder b = ComponentChanges.builder();
31
31
+
if (output.getItem() instanceof PortalDataHolder) {
32
32
+
b = b.add(ModComponentTypes.COLOR.get(), ColorLogic.defaultPortal);
33
33
+
b = b.add(DataComponentTypes.CUSTOM_MODEL_DATA, InfinityMethods.getColoredModel(ColorLogic.defaultPortal));
34
34
+
}
35
35
+
if (output.getItem() instanceof PortalDataHolder.Destinable) {
36
36
+
b = b.add(ModComponentTypes.DESTINATION.get(), Identifier.of("infinity:generated_0"));
37
37
+
}
38
38
+
output.applyChanges(b.build());
39
39
+
this.lore = modRecipe.getLore();
40
40
+
this.input = SlotContent.of(modRecipe.getIngredient());
41
41
+
this.output = SlotContent.of(output);
42
42
+
}
43
43
+
44
44
+
@Override
45
45
+
public IEivRecipeViewType getViewType() {
46
46
+
return IridescenceCraftingViewType.INSTANCE;
47
47
+
}
48
48
+
49
49
+
@Override
50
50
+
public void bindSlots(RecipeViewMenu.SlotFillContext slotFillContext) {
51
51
+
slotFillContext.bindOptionalSlot(0, this.input, RecipeViewMenu.OptionalSlotRenderer.DEFAULT);
52
52
+
slotFillContext.bindOptionalSlot(1, SlotContent.of(Ingredient.ofItem(ModBlocks.IRIDESCENCE.get())), RecipeViewMenu.OptionalSlotRenderer.DEFAULT);
53
53
+
slotFillContext.bindOptionalSlot(2, this.output, RecipeViewMenu.OptionalSlotRenderer.DEFAULT);
54
54
+
if (this.lore != null && I18n.hasTranslation(this.lore)) {
55
55
+
slotFillContext.addAdditionalStackModifier(2, (stack, tooltip) -> {
56
56
+
tooltip.add(Text.translatable(this.lore));
57
57
+
});
58
58
+
}
59
59
+
}
60
60
+
61
61
+
@Override
62
62
+
public List<SlotContent> getIngredients() {
63
63
+
return List.of(this.input);
64
64
+
}
65
65
+
66
66
+
@Override
67
67
+
public List<SlotContent> getResults() {
68
68
+
return List.of(this.output);
69
69
+
}
70
70
+
}
+64
common/src/main/java/net/lerariemann/infinity/compat/eiv/iridescence_crafting/IridescenceCraftingViewType.java
reviewed
···
1
1
+
package net.lerariemann.infinity.compat.eiv.iridescence_crafting;
2
2
+
3
3
+
import de.crafty.eiv.common.api.recipe.IEivRecipeViewType;
4
4
+
import de.crafty.eiv.common.recipe.inventory.RecipeViewMenu;
5
5
+
import net.lerariemann.infinity.registry.core.ModItems;
6
6
+
import net.lerariemann.infinity.util.InfinityMethods;
7
7
+
import net.minecraft.item.ItemStack;
8
8
+
import net.minecraft.text.Text;
9
9
+
import net.minecraft.util.Identifier;
10
10
+
11
11
+
import java.util.List;
12
12
+
13
13
+
public class IridescenceCraftingViewType implements IEivRecipeViewType {
14
14
+
15
15
+
protected static final IridescenceCraftingViewType INSTANCE = new IridescenceCraftingViewType();
16
16
+
17
17
+
@Override
18
18
+
public Text getDisplayName() {
19
19
+
return Text.translatable("emi.category.infinity.collision_iridescence");
20
20
+
}
21
21
+
22
22
+
@Override
23
23
+
public int getDisplayWidth() {
24
24
+
return 100;
25
25
+
}
26
26
+
27
27
+
@Override
28
28
+
public int getDisplayHeight() {
29
29
+
return 25;
30
30
+
}
31
31
+
32
32
+
@Override
33
33
+
public Identifier getGuiTexture() {
34
34
+
return InfinityMethods.getId("textures/gui/collision.png");
35
35
+
}
36
36
+
37
37
+
@Override
38
38
+
public int getSlotCount() {
39
39
+
return 3;
40
40
+
}
41
41
+
42
42
+
@Override
43
43
+
public void placeSlots(RecipeViewMenu.SlotDefinition slotDefinition) {
44
44
+
slotDefinition.addItemSlot(0, 5, 5);
45
45
+
slotDefinition.addItemSlot(1, 42, 5);
46
46
+
slotDefinition.addItemSlot(2, 80, 5);
47
47
+
}
48
48
+
49
49
+
@Override
50
50
+
public Identifier getId() {
51
51
+
return InfinityMethods.getId("portal_crafting");
52
52
+
}
53
53
+
54
54
+
@Override
55
55
+
public ItemStack getIcon() {
56
56
+
return ModItems.IRIDESCENCE_BUCKET.get().getDefaultStack();
57
57
+
}
58
58
+
59
59
+
@Override
60
60
+
public List<ItemStack> getCraftReferences() {
61
61
+
return List.of(ModItems.IRIDESCENCE_BUCKET.get().getDefaultStack());
62
62
+
}
63
63
+
64
64
+
}
-5
common/src/main/java/net/lerariemann/infinity/compat/eiv/portal_crafting/PortalCraftingViewRecipe.java
reviewed
···
25
25
private final SlotContent input, output;
26
26
private String lore;
27
27
28
28
-
public PortalCraftingViewRecipe(ItemStack input, ItemStack output) {
29
29
-
this.input = SlotContent.of(input);
30
30
-
this.output = SlotContent.of(output);
31
31
-
}
32
32
-
33
28
public PortalCraftingViewRecipe(PortalCraftingServerRecipe modRecipe) {
34
29
var output = modRecipe.getResult();
35
30
ComponentChanges.Builder b = ComponentChanges.builder();