Skip to content

Commit

Permalink
vendor ghost slot compat for EMI/JEI
Browse files Browse the repository at this point in the history
  • Loading branch information
techno-sam committed Jul 24, 2024
1 parent 987f4df commit 28057af
Show file tree
Hide file tree
Showing 28 changed files with 781 additions and 24 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Changes
- Redid Bank Terminal texture to match other Create textures
- You can now insert or extract items from all sides of a vendor
- The buying/selling item slot in the vendor gui now acts like a ghost item (does not require actual items).
Backwards compatible with existing vendors, so the items will remain 'real' until you remove them
Backwards compatible with existing vendors, so the items will remain 'real' until you remove them.
Additionally, enchantments and dyes can be applied to some items by shift-dragging items when using EMI on fabric or JEI on forge
------------------------------------------------------
Numismatics 1.0.6
------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2024-07-21T20:22:37.447106096 Create: Numismatics/Numismatics' Advancements
// 1.20.1 2024-07-24T07:41:10.619577249 Create: Numismatics/Numismatics' Advancements
4ab84595dc44460d6d89ff3608940dd8694b93d6 data/numismatics/advancements/is_this_legal.json
645c92e6e449889ed4cf617432fd6fa87ffe355b data/numismatics/advancements/questionable_investment.json
8f32fb49ef81058e2e660fac983dbef2f554db38 data/numismatics/advancements/root.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2024-07-21T20:22:37.445651836 Create: Numismatics/Numismatics Standard Recipes
// 1.20.1 2024-07-24T07:41:10.617662486 Create: Numismatics/Numismatics Standard Recipes
0e1680b878cfa51c04809504b3542cb6312027a1 data/numismatics/recipes/crafting/gray_id_card.json
61954216f844eecdbee266da7e517a983993d2f8 data/numismatics/advancements/recipes/misc/crafting/brown_card.json
2c732f9c3bc02a29a4d86a0552f4dbbae986a34a data/numismatics/recipes/crafting/blue_authorized_card.json
Expand All @@ -21,8 +21,8 @@ a9acb103fdf3c06e561b7252083fae594074ba40 data/numismatics/advancements/recipes/m
da540ae92c84519149c1b37ad49290814f507a8a data/numismatics/advancements/recipes/misc/crafting/white_authorized_card.json
12014c6c5ac12fdddc45d61bdb3841e2f930125d data/numismatics/recipes/crafting/red_card.json
858305a3537cdcb5bb19b883e688ddb876f0473c data/numismatics/recipes/crafting/brown_id_card.json
ce32a3a7c2a5564e84b30bb1b71007ca4adc985d data/numismatics/recipes/crafting/lime_authorized_card.json
35d3c0460a2ba41603bea8e1453b26d662a1f2d5 data/numismatics/advancements/recipes/misc/crafting/yellow_authorized_card.json
ce32a3a7c2a5564e84b30bb1b71007ca4adc985d data/numismatics/recipes/crafting/lime_authorized_card.json
501f27ee03faeb675a05b63b0c8058f1473f02d5 data/numismatics/advancements/recipes/misc/crafting/purple_id_card.json
8d863132d01d516db98d228e9038425923b7354d data/numismatics/recipes/crafting/black_card.json
78af0a7f17e04133eae7172df3255aaa34034537 data/numismatics/advancements/recipes/misc/crafting/red_id_card.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.20.1 2024-07-24T07:41:10.61410668 Create: Numismatics/Numismatics EMI excluded tags
b57edab6f7e7a6e1b1211daa4c3b217ffd09ce62 assets/emi/tag/exclusions/numismatics.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// 1.20.1 2024-07-21T20:22:37.446740402 Create: Numismatics/Numismatics' Sequenced Assembly Recipes
// 1.20.1 2024-07-24T07:41:10.619204352 Create: Numismatics/Numismatics' Sequenced Assembly Recipes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2024-07-21T20:22:37.442752776 Create: Numismatics/Registrate Provider for numismatics [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
// 1.20.1 2024-07-24T07:41:10.615215734 Create: Numismatics/Registrate Provider for numismatics [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
2f1dad2a2e0086d54cf4b88378feacc04341d87f data/numismatics/tags/items/internal/ingots/iron_ingots.json
dc5c60bbbaf3a5d7bc1f9bc0c9377757dbd8de49 data/numismatics/loot_tables/blocks/bank_terminal.json
5b0244502972f49d063d98fa0cb3f6fc65af82b2 data/numismatics/tags/items/internal/string.json
Expand All @@ -8,7 +8,7 @@ a96d3d02794064cd9be1bca25a9ba6217675e6c5 assets/numismatics/models/item/white_id
bb2a77462e6213eddde134f3cc3e9a3f07f07f3f assets/numismatics/models/item/yellow_authorized_card.json
74a4c7ca7a48382782e5dba33018dfc8255192c5 assets/numismatics/models/block/brass_depositor_locked.json
3f0d912779200aaaf55bef102d9b96acead1a636 data/numismatics/tags/items/internal/dyes/purple_dyes.json
60932ebc47cf9e9a14fc5bd8b4f8d30506a1d074 assets/numismatics/lang/en_us.json
bf4853dab3c317eaaf2f1196def7cda67212b493 assets/numismatics/lang/en_us.json
377e460c0dcf6d7de1b7ae235959105a7c45e4c4 assets/numismatics/models/item/cyan_authorized_card.json
bde18ccd9c21484154597c6271750c0406082f61 data/forge/tags/blocks/relocation_not_supported.json
eca751589c40725750e2c2baa6607e83255fd5f4 assets/numismatics/models/item/brown_authorized_card.json
Expand All @@ -18,7 +18,7 @@ ad712dd2a2a7268dfa773f38a50d526952758d5c data/numismatics/tags/items/internal/dy
8550097149cebbfd50bdeac2003327b60a4aee9a assets/numismatics/models/item/light_gray_card.json
95b492bd9230dc90fca9395c823cef39e644d8f2 assets/numismatics/models/item/sprocket.json
70c481f36a9718ac48632e6939ac6ba785be4c9e assets/numismatics/models/item/black_id_card.json
b6539c792df61fc097c1dc8f843f7c4e9999cb73 assets/numismatics/lang/en_ud.json
64524e27a031690bba14cf8ea1f1d92e03f2ad54 assets/numismatics/lang/en_ud.json
1e78f650091a4a2c43e36fb815f23d0591e058a6 assets/numismatics/models/item/magenta_card.json
909f5d14f23199c064f6b91a421bb7b15e0f1a7d assets/numismatics/models/item/orange_authorized_card.json
d6f017479b3cc538f73d7fb0a1e65d1742bab266 assets/numismatics/models/item/light_blue_id_card.json
Expand Down Expand Up @@ -53,8 +53,8 @@ bde18ccd9c21484154597c6271750c0406082f61 data/c/tags/blocks/relocation_not_suppo
d048d04208faa63f0014d614d6026a66fe118c11 data/numismatics/loot_tables/blocks/brass_depositor.json
790ff3c5da6a67a5de1ceb7138fa3e1c0fe97f80 data/numismatics/tags/items/internal/dyes/lime_dyes.json
a8cb82f19034a0e724e12df45c883e9cd469c210 assets/numismatics/models/item/green_card.json
e1087e56db7b4d8812ab4617344f0ac8b0f0e6c7 assets/numismatics/models/item/light_gray_authorized_card.json
390db78c5393fca4f90018df51d1a79d11a64f72 assets/numismatics/models/item/light_blue_authorized_card.json
e1087e56db7b4d8812ab4617344f0ac8b0f0e6c7 assets/numismatics/models/item/light_gray_authorized_card.json
c09892d2d189f147997d77f4ce39b0570729f030 assets/numismatics/models/item/lime_authorized_card.json
06ecd28cd97f4e8200dc396858695cad57b871c8 assets/numismatics/blockstates/blaze_banker.json
95ef415a564eba1d212053195d25b199427b94e3 assets/numismatics/blockstates/creative_vendor.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"block": [
"numismatics:internal/relocation_not_supported"
],
"item": [
"numismatics:internal/string",
"numismatics:internal/nuggets/iron_nuggets",
"numismatics:internal/nuggets/zinc_nuggets",
"numismatics:internal/nuggets/brass_nuggets",
"numismatics:internal/plates/iron_plates",
"numismatics:internal/plates/gold_plates",
"numismatics:internal/ingots/copper_ingots",
"numismatics:internal/ingots/iron_ingots",
"numismatics:internal/dyes/white_dyes",
"numismatics:internal/dyes/orange_dyes",
"numismatics:internal/dyes/magenta_dyes",
"numismatics:internal/dyes/light_blue_dyes",
"numismatics:internal/dyes/yellow_dyes",
"numismatics:internal/dyes/lime_dyes",
"numismatics:internal/dyes/pink_dyes",
"numismatics:internal/dyes/gray_dyes",
"numismatics:internal/dyes/light_gray_dyes",
"numismatics:internal/dyes/cyan_dyes",
"numismatics:internal/dyes/purple_dyes",
"numismatics:internal/dyes/blue_dyes",
"numismatics:internal/dyes/brown_dyes",
"numismatics:internal/dyes/green_dyes",
"numismatics:internal/dyes/red_dyes",
"numismatics:internal/dyes/black_dyes"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,12 @@
"numismatics.authorization_type.trusted_players": "ʎןuO sɹǝʎɐןԀ pǝʇsnɹ⟘",
"numismatics.authorization_type.trusted_players.description": "ʇsıן ʇsnɹʇ ǝɥʇ uo sɹǝʎɐןd ʎןuO",
"numismatics.special.ltr": "ǝnɹʇ",
"numismatics.trust_list.configure": "ʇsıꞀ ʇsnɹ⟘ ǝɹnbıɟuoƆ"
"numismatics.trust_list.configure": "ʇsıꞀ ʇsnɹ⟘ ǝɹnbıɟuoƆ",
"tag.block.numismatics.numismatics_blocks": "sʞɔoןᗺ sɔıʇɐɯsıɯnN",
"tag.item.forge.string": "buıɹʇS",
"tag.item.numismatics.authorized_cards": "spɹɐƆ pǝzıɹoɥʇnⱯ",
"tag.item.numismatics.cards": "spɹɐƆ",
"tag.item.numismatics.coins": "suıoƆ",
"tag.item.numismatics.id_cards": "spɹɐƆ pI",
"tag.item.numismatics.numismatics_items": "sɯǝʇI sɔıʇɐɯsıɯnN"
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,12 @@
"numismatics.authorization_type.trusted_players": "Trusted Players Only",
"numismatics.authorization_type.trusted_players.description": "Only players on the trust list",
"numismatics.special.ltr": "true",
"numismatics.trust_list.configure": "Configure Trust List"
"numismatics.trust_list.configure": "Configure Trust List",
"tag.block.numismatics.numismatics_blocks": "Numismatics Blocks",
"tag.item.forge.string": "String",
"tag.item.numismatics.authorized_cards": "Authorized Cards",
"tag.item.numismatics.cards": "Cards",
"tag.item.numismatics.coins": "Coins",
"tag.item.numismatics.id_cards": "Id Cards",
"tag.item.numismatics.numismatics_items": "Numismatics Items"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.tterrag.registrate.providers.ProviderType;
import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.ithundxr.createnumismatics.base.data.NumismaticsTagGen;
import dev.ithundxr.createnumismatics.base.data.emi.EmiExcludedTagGen;
import dev.ithundxr.createnumismatics.base.data.lang.NumismaticsLangGen;
import dev.ithundxr.createnumismatics.base.data.recipe.NumismaticsSequencedAssemblyRecipeGen;
import dev.ithundxr.createnumismatics.base.data.recipe.NumismaticsStandardRecipeGen;
Expand Down Expand Up @@ -106,6 +107,7 @@ public static void gatherData(DataGenerator.PackGenerator gen) {
gen.addProvider(NumismaticsSequencedAssemblyRecipeGen::new);
gen.addProvider(NumismaticsStandardRecipeGen::new);
gen.addProvider(NumismaticsAdvancements::new);
gen.addProvider(EmiExcludedTagGen::new);
}

public static ResourceLocation asResource(String path) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Steam 'n' Rails
* Copyright (c) 2022-2024 The Railways Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package dev.ithundxr.createnumismatics.base.data.emi;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import dev.ithundxr.createnumismatics.multiloader.CommonTag;
import dev.ithundxr.createnumismatics.multiloader.CommonTags;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.NotNull;

import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;

public class EmiExcludedTagGen implements DataProvider {
private static final String INDENT = " ";
private final PackOutput packOutput;

public EmiExcludedTagGen(PackOutput packOutput) {
this.packOutput = packOutput;
}

@Override
public @NotNull CompletableFuture<?> run(@NotNull CachedOutput output) {
Path path = this.packOutput.getOutputFolder()
.resolve("assets/emi/tag/exclusions/numismatics.json");

return DataProvider.saveStable(output, run(), path);
}

private JsonElement run() {
JsonObject object = new JsonObject();
{
JsonArray item = new JsonArray();
// fill in items
for (CommonTag<Item> itemTag : CommonTags.ALL_ITEMS) {
item.add(itemTag.tag.location().toString());
}
object.add("item", item);
}
{
JsonArray block = new JsonArray();
// fill in blocks
for (CommonTag<Block> blockTag : CommonTags.ALL_BLOCKS) {
block.add(blockTag.tag.location().toString());
}
object.add("block", block);
}
return object;
}

@Override
public String getName() {
return "Numismatics EMI excluded tags";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import dev.ithundxr.createnumismatics.content.backend.Coin;
import dev.ithundxr.createnumismatics.content.backend.sub_authorization.AuthorizationType;
import dev.ithundxr.createnumismatics.registry.NumismaticsAdvancements;
import dev.ithundxr.createnumismatics.registry.NumismaticsTags;

import java.util.Map;
import java.util.function.BiConsumer;
Expand All @@ -38,6 +39,7 @@ public static void generate(RegistrateLangProvider provider) {
NumismaticsAdvancements.provideLang(langConsumer);
AuthorizationType.provideLang(langConsumer);
Coin.provideLang(langConsumer);
NumismaticsTags.provideLang(langConsumer);

/* ================= */
/* Special data keys */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
public enum Mods {
CARRYON("carryon"),
SODIUM("sodium"),
COMPUTERCRAFT("computercraft")
COMPUTERCRAFT("computercraft"),
EMI("emi"),
JEI("jei")
;

public final boolean isLoaded;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Numismatics
* Copyright (c) 2024 The Railways Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package dev.ithundxr.createnumismatics.content.backend;

import net.minecraft.world.item.ItemStack;

public interface IGhostItemMenu {
void setGhostStackInSlot(int slotID, ItemStack stack);
boolean isSlotGhost(int slotID);
default boolean shouldGhostApplyEnchantsAndDye(int slotID) {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.simibubi.create.foundation.gui.menu.MenuBase;
import dev.ithundxr.createnumismatics.content.backend.BigStackSizeContainerSynchronizer;
import dev.ithundxr.createnumismatics.content.backend.Coin;
import dev.ithundxr.createnumismatics.content.backend.IGhostItemMenu;
import dev.ithundxr.createnumismatics.content.backend.IScrollableSlotMenu;
import dev.ithundxr.createnumismatics.content.bank.AnyCardSlot;
import dev.ithundxr.createnumismatics.content.coins.CoinDisplaySlot;
Expand All @@ -41,7 +42,7 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import org.jetbrains.annotations.NotNull;

public class VendorMenu extends MenuBase<VendorBlockEntity> implements IScrollableSlotMenu {
public class VendorMenu extends MenuBase<VendorBlockEntity> implements IScrollableSlotMenu, IGhostItemMenu {
public static final int COIN_SLOTS = Coin.values().length;
public static final int CARD_SLOT_INDEX = COIN_SLOTS;
public static final int FILTER_SLOT_INDEX = CARD_SLOT_INDEX + 1;
Expand Down Expand Up @@ -225,7 +226,7 @@ public void setSynchronizer(@NotNull ContainerSynchronizer synchronizer) {

@Override
public void scrollSlot(int slotID, double delta, boolean shift) {
if (slotID == FILTER_SLOT_INDEX && !contentHolder.isFilterSlotLegacy()) {
if (isSlotGhost(slotID)) {
Slot slot = getSlot(slotID);
if (!slot.hasItem())
return;
Expand All @@ -240,4 +241,16 @@ public void scrollSlot(int slotID, double delta, boolean shift) {
slot.set(count == 0 ? ItemStack.EMPTY : stack.copyWithCount(count));
}
}

@Override
public void setGhostStackInSlot(int slotID, ItemStack stack) {
if (isSlotGhost(slotID)) {
getSlot(slotID).set(stack);
}
}

@Override
public boolean isSlotGhost(int slotID) {
return slotID == FILTER_SLOT_INDEX && !contentHolder.isFilterSlotLegacy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;

import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;

public class CommonTags {
public static final List<CommonTag<Item>> ALL_ITEMS = new ArrayList<>();
public static final List<CommonTag<Block>> ALL_BLOCKS = new ArrayList<>();

public static final CommonTag<Item>
STRING = item("string"),
IRON_NUGGETS = item("nuggets/iron_nuggets", "iron_nuggets", "nuggets/iron"),
Expand Down Expand Up @@ -55,11 +60,15 @@ public class CommonTags {
RELOCATION_NOT_SUPPORTED = block("relocation_not_supported");

public static CommonTag<Block> block(String path) {
return CommonTag.conventional(Registries.BLOCK, path);
CommonTag<Block> tag = CommonTag.conventional(Registries.BLOCK, path);
ALL_BLOCKS.add(tag);
return tag;
}

public static CommonTag<Item> item(String common, String fabric, String forge) {
return CommonTag.conventional(Registries.ITEM, common, fabric, forge);
CommonTag<Item> tag = CommonTag.conventional(Registries.ITEM, common, fabric, forge);
ALL_ITEMS.add(tag);
return tag;
}

public static CommonTag<Item> item(String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class NumismaticsPackets {
.c2s(ConfigureSubAccountPacket.class, ConfigureSubAccountPacket::new)
.c2s(AddSubAccountPacket.class, AddSubAccountPacket::new)
.c2s(ScrollSlotPacket.class, ScrollSlotPacket::new)
.c2s(GhostItemSubmitPacket.class, GhostItemSubmitPacket::new)

.s2c(BankAccountLabelPacket.class, BankAccountLabelPacket::new)
.s2c(VarIntContainerSetDataPacket.class, VarIntContainerSetDataPacket::new)
Expand Down
Loading

0 comments on commit 28057af

Please sign in to comment.