-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ook, Firework Rocket, Clone Map, Extend Map, Decorate Shield, Dye Shulker Box, Suspicious Stew)
- Loading branch information
Showing
15 changed files
with
830 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
.../java/me/shedaniel/rei/plugin/client/categories/crafting/filler/ArmorDyeRecipeFiller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* This file is licensed under the MIT License, part of Roughly Enough Items. | ||
* Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package me.shedaniel.rei.plugin.client.categories.crafting.filler; | ||
|
||
import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; | ||
import me.shedaniel.rei.api.common.display.Display; | ||
import me.shedaniel.rei.api.common.entry.EntryIngredient; | ||
import me.shedaniel.rei.api.common.entry.EntryStack; | ||
import me.shedaniel.rei.api.common.util.EntryIngredients; | ||
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomShapelessDisplay; | ||
import net.minecraft.world.item.DyeColor; | ||
import net.minecraft.world.item.DyeItem; | ||
import net.minecraft.world.item.DyeableLeatherItem; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.crafting.ArmorDyeRecipe; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
public class ArmorDyeRecipeFiller implements CraftingRecipeFiller<ArmorDyeRecipe> { | ||
@Override | ||
public Collection<Display> apply(ArmorDyeRecipe recipe) { | ||
List<Display> displays = new ArrayList<>(); | ||
List<EntryStack<?>> toDye = EntryRegistry.getInstance().getEntryStacks().filter(entry -> entry.getValueType() == ItemStack.class && entry.<ItemStack>castValue().getItem() instanceof DyeableLeatherItem).toList(); | ||
DyeColor[] colors = DyeColor.values(); | ||
|
||
for (EntryStack<?> armor : toDye) { | ||
ItemStack armorStack = armor.castValue(); | ||
for (DyeColor color : colors) { | ||
ItemStack output = armorStack.copy(); | ||
DyeItem dyeItem = DyeItem.byColor(color); | ||
output = DyeableLeatherItem.dyeArmor(output, List.of(dyeItem)); | ||
displays.add(new DefaultCustomShapelessDisplay(recipe, | ||
List.of(EntryIngredient.of(armor.copy()), | ||
EntryIngredients.of(dyeItem)), | ||
List.of(EntryIngredients.of(output)))); | ||
} | ||
|
||
for (int i = 0; i < 9; i++) { | ||
int dyes = new Random().nextInt(2) + 2; | ||
List<EntryIngredient> inputs = new ArrayList<>(); | ||
List<DyeItem> dyeItems = new ArrayList<>(); | ||
inputs.add(EntryIngredient.of(armor.copy())); | ||
for (int j = 0; j < dyes; j++) { | ||
DyeColor color = colors[new Random().nextInt(colors.length)]; | ||
DyeItem dyeItem = DyeItem.byColor(color); | ||
dyeItems.add(dyeItem); | ||
inputs.add(EntryIngredients.of(dyeItem)); | ||
} | ||
ItemStack output = armorStack.copy(); | ||
output = DyeableLeatherItem.dyeArmor(output, dyeItems); | ||
displays.add(new DefaultCustomShapelessDisplay(recipe, | ||
inputs, List.of(EntryIngredients.of(output)))); | ||
} | ||
} | ||
|
||
return displays; | ||
} | ||
|
||
@Override | ||
public Class<ArmorDyeRecipe> getRecipeClass() { | ||
return ArmorDyeRecipe.class; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...e/shedaniel/rei/plugin/client/categories/crafting/filler/BannerDuplicateRecipeFiller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* This file is licensed under the MIT License, part of Roughly Enough Items. | ||
* Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package me.shedaniel.rei.plugin.client.categories.crafting.filler; | ||
|
||
import com.mojang.datafixers.util.Pair; | ||
import me.shedaniel.rei.api.common.display.Display; | ||
import me.shedaniel.rei.api.common.entry.EntryIngredient; | ||
import me.shedaniel.rei.api.common.entry.EntryStack; | ||
import me.shedaniel.rei.api.common.util.EntryStacks; | ||
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomShapelessDisplay; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.DyeColor; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.crafting.BannerDuplicateRecipe; | ||
|
||
import java.util.*; | ||
|
||
public class BannerDuplicateRecipeFiller implements CraftingRecipeFiller<BannerDuplicateRecipe> { | ||
@Override | ||
public Collection<Display> apply(BannerDuplicateRecipe recipe) { | ||
List<Display> displays = new ArrayList<>(); | ||
Map<DyeColor, Pair<EntryIngredient.Builder, EntryStack<?>>> displayMap = new HashMap<>(); | ||
|
||
for (Pair<DyeColor, ItemStack> pair : ShieldDecorationRecipeFiller.randomizeBanners()) { | ||
Optional<Item> bannerOptional = Registry.ITEM.getOptional(new ResourceLocation(pair.getFirst().getName() + "_banner")); | ||
if (bannerOptional.isEmpty()) continue; | ||
Pair<EntryIngredient.Builder, EntryStack<?>> builderPair = displayMap.computeIfAbsent(pair.getFirst(), color -> Pair.of(EntryIngredient.builder(), EntryStacks.of(bannerOptional.get()))); | ||
builderPair.getFirst().add(EntryStacks.of(pair.getSecond())); | ||
} | ||
|
||
for (Pair<EntryIngredient.Builder, EntryStack<?>> pair : displayMap.values()) { | ||
EntryIngredient inputsFirst = pair.getFirst().build(); | ||
EntryStack<?> inputsSecond = pair.getSecond(); | ||
EntryIngredient.unifyFocuses(inputsFirst); | ||
displays.add(new DefaultCustomShapelessDisplay(recipe, | ||
List.of(inputsFirst, EntryIngredient.of(inputsSecond)), | ||
List.of(inputsFirst))); | ||
} | ||
|
||
return displays; | ||
} | ||
|
||
@Override | ||
public Class<BannerDuplicateRecipe> getRecipeClass() { | ||
return BannerDuplicateRecipe.class; | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
...va/me/shedaniel/rei/plugin/client/categories/crafting/filler/BookCloningRecipeFiller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* This file is licensed under the MIT License, part of Roughly Enough Items. | ||
* Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package me.shedaniel.rei.plugin.client.categories.crafting.filler; | ||
|
||
import me.shedaniel.rei.api.common.display.Display; | ||
import me.shedaniel.rei.api.common.entry.EntryIngredient; | ||
import me.shedaniel.rei.api.common.util.CollectionUtils; | ||
import me.shedaniel.rei.api.common.util.EntryStacks; | ||
import me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomShapelessDisplay; | ||
import net.minecraft.nbt.IntTag; | ||
import net.minecraft.nbt.StringTag; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.item.WrittenBookItem; | ||
import net.minecraft.world.item.crafting.BookCloningRecipe; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
public class BookCloningRecipeFiller implements CraftingRecipeFiller<BookCloningRecipe> { | ||
private static final String[] TITLES = new String[]{ | ||
"Adventurer's Dreams", "Adventurer's Diary", "The Lost Journal", | ||
"The Lost Diary", "The Lost Book", "The Lost Tome", "The Lost Codex", | ||
"The Last Journal", "The Last Diary", "The Last Book", "The Last Tome", | ||
"Secrets of the World", "Secrets of the Universe", "Secrets of the Cosmos", | ||
"Myths of the World", "Myths of the Universe", "Myths of the Cosmos", | ||
"Old Tales of the World", "Old Tales of the Universe", "Old Tales of the Cosmos", | ||
"The World of the Legends", "The Universe of the Heroes", "The Cosmos of the Gods", | ||
"Diary of a Villager", "Diary of a Farmer", "Diary of a Fisherman", | ||
"Dungeon Journal", "Dungeon Diary", "Dungeon Book", "Dungeon Tome", | ||
"Dunk Memes", "Top 10 Memes of 2019", "Top 10 Memes of 2020", | ||
"Plastic Memories", "Kizumonogatari" | ||
}; | ||
private static final String[] AUTHORS = new String[]{ | ||
"shedaniel", "Steve", "Alex", "Notch", "Herobrine", "God", | ||
"Santa Claus", "The Easter Bunny", "The Tooth Fairy" | ||
}; | ||
|
||
@Override | ||
public Collection<Display> apply(BookCloningRecipe recipe) { | ||
List<Display> displays = new ArrayList<>(); | ||
|
||
for (int i = 1; i <= 8; i++) { | ||
EntryIngredient.Builder[] inputs = new EntryIngredient.Builder[9]; | ||
for (int j = 0; j < 9; j++) { | ||
inputs[j] = EntryIngredient.builder(); | ||
} | ||
EntryIngredient.Builder output = EntryIngredient.builder(); | ||
for (int j = 0; j < 10; j++) { | ||
ItemStack writtenBook = generateBook(); | ||
ItemStack bookAndQuill = new ItemStack(Items.WRITABLE_BOOK); | ||
inputs[0].add(EntryStacks.of(writtenBook)); | ||
for (int k = 0; k < i; k++) { | ||
inputs[k + 1].add(EntryStacks.of(bookAndQuill)); | ||
} | ||
ItemStack cloned = writtenBook.copy(); | ||
cloned.addTagElement(WrittenBookItem.TAG_GENERATION, IntTag.valueOf(1)); | ||
cloned.setCount(i); | ||
output.add(EntryStacks.of(cloned)); | ||
} | ||
displays.add(new DefaultCustomShapelessDisplay(recipe, | ||
CollectionUtils.map(inputs, EntryIngredient.Builder::build), | ||
List.of(output.build()))); | ||
} | ||
|
||
return displays; | ||
} | ||
|
||
private ItemStack generateBook() { | ||
ItemStack stack = new ItemStack(Items.WRITTEN_BOOK); | ||
stack.addTagElement(WrittenBookItem.TAG_AUTHOR, StringTag.valueOf(AUTHORS[new Random().nextInt(AUTHORS.length)])); | ||
stack.addTagElement(WrittenBookItem.TAG_TITLE, StringTag.valueOf(TITLES[new Random().nextInt(TITLES.length)])); | ||
stack.addTagElement(WrittenBookItem.TAG_GENERATION, IntTag.valueOf(0)); | ||
return stack; | ||
} | ||
|
||
@Override | ||
public Class<BookCloningRecipe> getRecipeClass() { | ||
return BookCloningRecipe.class; | ||
} | ||
} |
Oops, something went wrong.