Skip to content

Commit

Permalink
Fix Upgrade Items in Creative mode tab, and handler for Modification …
Browse files Browse the repository at this point in the history
…table
  • Loading branch information
Direwolf20-MC committed Feb 15, 2024
1 parent 8878ab6 commit 9805e03
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.direwolf20.mininggadgets.common.capabilities.EnergisedItem;
import com.direwolf20.mininggadgets.common.items.MiningGadget;
import com.direwolf20.mininggadgets.common.network.PacketHandler;
import com.direwolf20.mininggadgets.common.tiles.ModificationTableTileEntity;
import com.direwolf20.mininggadgets.setup.ClientSetup;
import com.direwolf20.mininggadgets.setup.Config;
import com.direwolf20.mininggadgets.setup.ModSetup;
Expand Down Expand Up @@ -49,6 +50,10 @@ private void registerCapabilities(RegisterCapabilitiesEvent event) {
Registration.MININGGADGET_FANCY.get(),
Registration.MININGGADGET_SIMPLE.get()
);
event.registerBlock(Capabilities.ItemHandler.BLOCK,
(level, pos, state, be, side) -> ((ModificationTableTileEntity) be).handler,
// blocks to register for
Registration.MODIFICATION_TABLE.get());
}

@SubscribeEvent
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/com/direwolf20/mininggadgets/setup/ModSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void init(final FMLCommonSetupEvent event) {
public static final String TAB_NAME = "mininggadgets";
public static DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MiningGadgets.MOD_ID);
public static DeferredHolder<CreativeModeTab, CreativeModeTab> TAB_MININGGADGETS = TABS.register(TAB_NAME, () -> CreativeModeTab.builder()
.title(Component.literal("MiningGadgets"))
.title(Component.literal("Mining Gadgets"))
.icon(() -> new ItemStack(Registration.MININGGADGET.get()))
.withTabsBefore(CreativeModeTabs.SPAWN_EGGS)
.displayItems((featureFlags, output) -> {
Expand All @@ -40,6 +40,19 @@ public static void init(final FMLCommonSetupEvent event) {
output.accept(stack);
}
});
Registration.UPGRADE_ITEMS.getEntries().stream().filter(e -> e != Registration.MINERS_LIGHT_ITEM)
.forEach(e -> {
// Normal
Item item = e.get();
output.accept(item);

// Charged
if (item instanceof MiningGadget) {
ItemStack stack = new ItemStack(item);
stack.getOrCreateTag().putInt("energy", UpgradeBatteryLevels.BATTERY.getPower());
output.accept(stack);
}
});
})
.build());
}

0 comments on commit 9805e03

Please sign in to comment.