From 2ed2897ec2dcdfb82cae371709e395bed76db873 Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Sat, 25 Feb 2023 23:30:10 +0000 Subject: [PATCH] feat: ported to 1.19.3 --- .gitignore | 4 +- gradle.properties | 6 +- .../2e50376a258ceefdeaf48c21f919aaa551c1fbe8 | 2 +- .../2e54bed26e13ab7b72d353ac0abde95be4a1e42d | 4 +- ... 59eb3dbb5f86130e09b3c62d89b9525ee01cf52d} | 2 +- .../9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e | 6 +- .../c622617f6fabf890a00b9275cd5f643584a8a2c8 | 2 +- ... fba13718ce95758c44cf7c624d058e09dd14e517} | 2 +- .../models/block/charging_station.json | 8 +- .../charging_station.json | 0 .../recipes/charging_station.json | 1 + .../charginggadgets/ChargingGadgets.java | 28 ++--- .../charginggadgets/DataGenerators.java | 112 +++++++++--------- .../charginggadgets/blocks/BlockRegistry.java | 2 +- .../ChargingStationContainer.java | 3 +- .../chargingstation/ChargingStationTile.java | 9 +- .../capabilities/ChargerItemHandler.java | 3 +- src/main/resources/META-INF/mods.toml | 4 +- .../charging_station_bottom.png | Bin .../charging_station_frontoff.png | Bin .../charging_station_fronton.png | Bin .../charging_station_side.png | Bin .../charging_station_top.png | Bin 23 files changed, 104 insertions(+), 94 deletions(-) rename src/generated/resources/.cache/{67cce32b1c3cbbcb1f646605f4914e3f196986c2 => 59eb3dbb5f86130e09b3c62d89b9525ee01cf52d} (67%) rename src/generated/resources/.cache/{75bcd4dba6ca7d365462b0ec45e291d1056349c4 => fba13718ce95758c44cf7c624d058e09dd14e517} (51%) rename src/generated/resources/data/charginggadgets/advancements/recipes/{charginggadgets => redstone}/charging_station.json (100%) rename src/main/resources/assets/charginggadgets/textures/{blocks => block}/charging_station_bottom.png (100%) rename src/main/resources/assets/charginggadgets/textures/{blocks => block}/charging_station_frontoff.png (100%) rename src/main/resources/assets/charginggadgets/textures/{blocks => block}/charging_station_fronton.png (100%) rename src/main/resources/assets/charginggadgets/textures/{blocks => block}/charging_station_side.png (100%) rename src/main/resources/assets/charginggadgets/textures/{blocks => block}/charging_station_top.png (100%) diff --git a/.gitignore b/.gitignore index 9c1b936..aaf6359 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ run # Files from Forge MDK forge*changelog.txt -includedMods/ \ No newline at end of file +includedMods/ + +.DS_Store diff --git a/gradle.properties b/gradle.properties index 82a3736..e829b02 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,9 +2,9 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false #Mod Info -mod_version=1.9.0 +mod_version=1.10.0 #Dependencies -forge_version=43.1.3 -minecraft_version=1.19.2 +forge_version=44.1.20 +minecraft_version=1.19.3 jei_version=1.18.2:9.5.5.174 diff --git a/src/generated/resources/.cache/2e50376a258ceefdeaf48c21f919aaa551c1fbe8 b/src/generated/resources/.cache/2e50376a258ceefdeaf48c21f919aaa551c1fbe8 index 9652cae..39f8ea2 100644 --- a/src/generated/resources/.cache/2e50376a258ceefdeaf48c21f919aaa551c1fbe8 +++ b/src/generated/resources/.cache/2e50376a258ceefdeaf48c21f919aaa551c1fbe8 @@ -1,2 +1,2 @@ -// 1.19.2 2022-08-28T19:04:27.816323 Item Models +// 1.19.3 2023-02-25T23:18:30.173577 Item Models 179c9e6b61afd4b4014ffe3b8fef6632ed61966a assets/charginggadgets/models/item/charging_station.json diff --git a/src/generated/resources/.cache/2e54bed26e13ab7b72d353ac0abde95be4a1e42d b/src/generated/resources/.cache/2e54bed26e13ab7b72d353ac0abde95be4a1e42d index 247546e..1e57e9f 100644 --- a/src/generated/resources/.cache/2e54bed26e13ab7b72d353ac0abde95be4a1e42d +++ b/src/generated/resources/.cache/2e54bed26e13ab7b72d353ac0abde95be4a1e42d @@ -1,3 +1,3 @@ -// 1.19.2 2022-08-28T19:04:27.814872 Block States: charginggadgets +// 1.19.3 2023-02-25T23:25:49.140306 Block States: charginggadgets 394cf5f3c2f3b54def172894da14caac4693b95e assets/charginggadgets/blockstates/charging_station.json -47fabdf90fe2f04dabe7bc29aca1f4f092a2d888 assets/charginggadgets/models/block/charging_station.json +afcd533096c1b06fec0762b490286d26ae2bd464 assets/charginggadgets/models/block/charging_station.json diff --git a/src/generated/resources/.cache/67cce32b1c3cbbcb1f646605f4914e3f196986c2 b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d similarity index 67% rename from src/generated/resources/.cache/67cce32b1c3cbbcb1f646605f4914e3f196986c2 rename to src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d index 1b02e5c..17adf12 100644 --- a/src/generated/resources/.cache/67cce32b1c3cbbcb1f646605f4914e3f196986c2 +++ b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d @@ -1,2 +1,2 @@ -// 1.19.2 2022-08-28T19:04:27.816496 LootTables +// 1.19.3 2023-02-25T23:18:30.175265 Loot Tables 772d813ff4f65a76def4ce66185c2aaf0ea113a7 data/charginggadgets/loot_tables/blocks/charging_station.json diff --git a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index 60fd66a..8925618 100644 --- a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,3 +1,3 @@ -// 1.19.2 2022-08-28T19:04:27.816648 Recipes -386648047015a410926a8f9291e51c086bb57a58 data/charginggadgets/advancements/recipes/charginggadgets/charging_station.json -ace1686a7b90d6b7d3fb2d1f047f682fe9d9aa9e data/charginggadgets/recipes/charging_station.json +// 1.19.3 2023-02-25T23:18:30.175704 Recipes +386648047015a410926a8f9291e51c086bb57a58 data/charginggadgets/advancements/recipes/redstone/charging_station.json +98de667d631a524ca536ef508dd411d1f72a1ef3 data/charginggadgets/recipes/charging_station.json diff --git a/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 b/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 index dfb5aa6..7a315c7 100644 --- a/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 +++ b/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 @@ -1,2 +1,2 @@ -// 1.19.2 2022-08-28T19:04:27.817071 Languages: en_us +// 1.19.3 2023-02-25T23:18:30.175864 Languages: en_us a1a869500e77208a86a7acea2ddb42701af9c943 assets/charginggadgets/lang/en_us.json diff --git a/src/generated/resources/.cache/75bcd4dba6ca7d365462b0ec45e291d1056349c4 b/src/generated/resources/.cache/fba13718ce95758c44cf7c624d058e09dd14e517 similarity index 51% rename from src/generated/resources/.cache/75bcd4dba6ca7d365462b0ec45e291d1056349c4 rename to src/generated/resources/.cache/fba13718ce95758c44cf7c624d058e09dd14e517 index 02f8cd4..8423b89 100644 --- a/src/generated/resources/.cache/75bcd4dba6ca7d365462b0ec45e291d1056349c4 +++ b/src/generated/resources/.cache/fba13718ce95758c44cf7c624d058e09dd14e517 @@ -1,2 +1,2 @@ -// 1.19.2 2022-08-28T19:04:27.816915 Tags for minecraft:block +// 1.19.3 2023-02-25T23:18:30.175553 Tags for minecraft:block mod id charginggadgets b0da0ac207375abfdfcffa6ae8271ad92293108c data/minecraft/tags/blocks/mineable/pickaxe.json diff --git a/src/generated/resources/assets/charginggadgets/models/block/charging_station.json b/src/generated/resources/assets/charginggadgets/models/block/charging_station.json index f17fae5..d653ae1 100644 --- a/src/generated/resources/assets/charginggadgets/models/block/charging_station.json +++ b/src/generated/resources/assets/charginggadgets/models/block/charging_station.json @@ -1,9 +1,9 @@ { "parent": "minecraft:block/orientable_with_bottom", "textures": { - "bottom": "charginggadgets:blocks/charging_station_bottom", - "front": "charginggadgets:blocks/charging_station_fronton", - "side": "charginggadgets:blocks/charging_station_side", - "top": "charginggadgets:blocks/charging_station_top" + "bottom": "charginggadgets:block/charging_station_bottom", + "front": "charginggadgets:block/charging_station_fronton", + "side": "charginggadgets:block/charging_station_side", + "top": "charginggadgets:block/charging_station_top" } } \ No newline at end of file diff --git a/src/generated/resources/data/charginggadgets/advancements/recipes/charginggadgets/charging_station.json b/src/generated/resources/data/charginggadgets/advancements/recipes/redstone/charging_station.json similarity index 100% rename from src/generated/resources/data/charginggadgets/advancements/recipes/charginggadgets/charging_station.json rename to src/generated/resources/data/charginggadgets/advancements/recipes/redstone/charging_station.json diff --git a/src/generated/resources/data/charginggadgets/recipes/charging_station.json b/src/generated/resources/data/charginggadgets/recipes/charging_station.json index feb05ef..0dc767f 100644 --- a/src/generated/resources/data/charginggadgets/recipes/charging_station.json +++ b/src/generated/resources/data/charginggadgets/recipes/charging_station.json @@ -1,5 +1,6 @@ { "type": "minecraft:crafting_shaped", + "category": "redstone", "key": { "d": { "tag": "forge:gems/lapis" diff --git a/src/main/java/com/direwolf20/charginggadgets/ChargingGadgets.java b/src/main/java/com/direwolf20/charginggadgets/ChargingGadgets.java index 4aca0df..504c9b4 100644 --- a/src/main/java/com/direwolf20/charginggadgets/ChargingGadgets.java +++ b/src/main/java/com/direwolf20/charginggadgets/ChargingGadgets.java @@ -1,12 +1,13 @@ package com.direwolf20.charginggadgets; -import com.direwolf20.charginggadgets.blocks.chargingstation.ChargingStationScreen; import com.direwolf20.charginggadgets.blocks.BlockRegistry; +import com.direwolf20.charginggadgets.blocks.chargingstation.ChargingStationScreen; import net.minecraft.client.gui.screens.MenuScreens; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; @@ -16,7 +17,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.NotNull; @Mod(ChargingGadgets.MOD_ID) public class ChargingGadgets @@ -24,16 +24,6 @@ public class ChargingGadgets public static final String MOD_ID = "charginggadgets"; private static final Logger LOGGER = LogManager.getLogger(); - // Item Groups - public static final CreativeModeTab ITEM_GROUP = new CreativeModeTab(MOD_ID) { - @Override - public @NotNull ItemStack makeIcon() { - return new ItemStack(BlockRegistry.CHARGING_STATION.get()); - } - }; - - public static final Item.Properties ITEM_PROPS = new Item.Properties().tab(ITEM_GROUP); - public ChargingGadgets() { IEventBus event = FMLJavaModLoadingContext.get().getModEventBus(); @@ -44,6 +34,7 @@ public ChargingGadgets() { event.addListener(this::setup); event.addListener(this::clientSetup); + event.addListener(this::setupCreativeTabs); MinecraftForge.EVENT_BUS.register(this); @@ -56,4 +47,13 @@ private void setup(final FMLCommonSetupEvent event) { private void clientSetup(final FMLClientSetupEvent event) { MenuScreens.register(BlockRegistry.CHARGING_STATION_CONTAINER.get(), ChargingStationScreen::new); } + + private void setupCreativeTabs(final CreativeModeTabEvent.Register event) { + event.registerCreativeModeTab(new ResourceLocation(MOD_ID, MOD_ID), builder -> builder.title(Component.translatable("itemGroup." + MOD_ID)) + .icon(() -> new ItemStack(BlockRegistry.CHARGING_STATION_BI.get())) + .displayItems((enabledFlags, populator, hasPermissions) -> { + populator.accept(BlockRegistry.CHARGING_STATION_BI.get()); + }) + .build()); + } } diff --git a/src/main/java/com/direwolf20/charginggadgets/DataGenerators.java b/src/main/java/com/direwolf20/charginggadgets/DataGenerators.java index 1926088..e8f7abc 100644 --- a/src/main/java/com/direwolf20/charginggadgets/DataGenerators.java +++ b/src/main/java/com/direwolf20/charginggadgets/DataGenerators.java @@ -2,17 +2,17 @@ import com.direwolf20.charginggadgets.blocks.BlockRegistry; import com.google.common.collect.ImmutableList; -import com.mojang.datafixers.util.Pair; -import net.minecraft.core.Registry; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.loot.BlockLoot; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; +import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.data.loot.LootTableProvider; import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.data.recipes.ShapedRecipeBuilder; -import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; +import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.LootTable; @@ -20,7 +20,6 @@ import net.minecraft.world.level.storage.loot.ValidationContext; import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.functions.CopyNameFunction; -import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; @@ -28,6 +27,7 @@ import net.minecraftforge.client.model.generators.ItemModelProvider; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.Tags; +import net.minecraftforge.common.data.BlockTagsProvider; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.LanguageProvider; import net.minecraftforge.data.event.GatherDataEvent; @@ -35,56 +35,58 @@ import net.minecraftforge.fml.common.Mod; import javax.annotation.Nullable; -import java.util.List; +import java.util.Collections; import java.util.Map; -import java.util.function.BiConsumer; +import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; -import java.util.function.Supplier; @Mod.EventBusSubscriber(modid = ChargingGadgets.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public final class DataGenerators { @SubscribeEvent public static void gatherData(GatherDataEvent event) { - DataGenerator generator = event.getGenerator(); - - if (event.includeServer()) { - generator.addProvider(event.includeServer(), new GeneratorRecipes(generator)); - generator.addProvider(event.includeServer(), new GeneratorLoots(generator)); - } - - if (event.includeClient()) { - generator.addProvider(event.includeServer(), new GeneratorBlockTags(generator, event.getExistingFileHelper())); - generator.addProvider(event.includeServer(), new GeneratorLanguage(generator)); - generator.addProvider(event.includeServer(), new GeneratorBlockStates(generator, event.getExistingFileHelper())); - generator.addProvider(event.includeServer(), new GeneratorItemModels(generator, event.getExistingFileHelper())); - } + var includeServer = event.includeServer(); + var includeClient = event.includeClient(); + var generator = event.getGenerator(); + var helper = event.getExistingFileHelper(); + var packOutput = event.getGenerator().getPackOutput(); + + // Client + generator.addProvider(includeClient, new GeneratorLanguage(packOutput)); + generator.addProvider(includeClient, new GeneratorBlockStates(packOutput, event.getExistingFileHelper())); + generator.addProvider(includeClient, new GeneratorLoots(packOutput)); + + // Server + generator.addProvider(includeServer, new GeneratorRecipes(packOutput)); + generator.addProvider(includeServer, new GeneratorBlockTags(packOutput, event.getLookupProvider(), event.getExistingFileHelper())); + generator.addProvider(includeServer, new GeneratorItemModels(packOutput, event.getExistingFileHelper())); } static class GeneratorBlockStates extends BlockStateProvider { - public GeneratorBlockStates(DataGenerator gen, ExistingFileHelper exFileHelper) { - super(gen, ChargingGadgets.MOD_ID, exFileHelper); + public GeneratorBlockStates(PackOutput output, ExistingFileHelper exFileHelper) { + super(output, ChargingGadgets.MOD_ID, exFileHelper); } @Override protected void registerStatesAndModels() { horizontalBlock(BlockRegistry.CHARGING_STATION.get(), models().orientableWithBottom( - Registry.BLOCK.getKey(BlockRegistry.CHARGING_STATION.get()).getPath(), - modLoc("blocks/charging_station_side"), - modLoc("blocks/charging_station_fronton"), - modLoc("blocks/charging_station_bottom"), - modLoc("blocks/charging_station_top") + BlockRegistry.CHARGING_STATION.getId().getPath(), + modLoc("block/charging_station_side"), + modLoc("block/charging_station_fronton"), + modLoc("block/charging_station_bottom"), + modLoc("block/charging_station_top") )); } } static class GeneratorItemModels extends ItemModelProvider { - public GeneratorItemModels(DataGenerator generator, ExistingFileHelper existingFileHelper) { - super(generator, ChargingGadgets.MOD_ID, existingFileHelper); + public GeneratorItemModels(PackOutput output, ExistingFileHelper existingFileHelper) { + super(output, ChargingGadgets.MOD_ID, existingFileHelper); } @Override protected void registerModels() { - String path = Registry.BLOCK.getKey(BlockRegistry.CHARGING_STATION.get()).getPath(); + String path = BlockRegistry.CHARGING_STATION.getId().getPath(); getBuilder(path).parent(new ModelFile.UncheckedModelFile(modLoc("block/" + path))); } @@ -95,8 +97,8 @@ public String getName() { } static class GeneratorLanguage extends LanguageProvider { - public GeneratorLanguage(DataGenerator gen) { - super(gen, ChargingGadgets.MOD_ID, "en_us"); + public GeneratorLanguage(PackOutput output) { + super(output, ChargingGadgets.MOD_ID, "en_us"); } @Override @@ -111,20 +113,26 @@ protected void addTranslations() { static class GeneratorLoots extends LootTableProvider { - public GeneratorLoots(DataGenerator dataGeneratorIn) { - super(dataGeneratorIn); + public GeneratorLoots(PackOutput output) { + super(output, Set.of(), ImmutableList.of( + new SubProviderEntry(Blocks::new, LootContextParamSets.BLOCK) + )); } @Override - protected List>>, LootContextParamSet>> getTables() { - return ImmutableList.of(Pair.of(Blocks::new, LootContextParamSets.BLOCK)); + protected void validate(Map map, ValidationContext validationContext) { + map.forEach((name, table) -> LootTables.validate(validationContext, name, table)); } - private static class Blocks extends BlockLoot { + private static class Blocks extends BlockLootSubProvider { + protected Blocks() { + super(Set.of(), FeatureFlags.REGISTRY.allFlags()); + } + @Override - protected void addTables() { + protected void generate() { LootPool.Builder builder = LootPool.lootPool() - .name(Registry.BLOCK.getKey(BlockRegistry.CHARGING_STATION.get()).toString()) + .name(BlockRegistry.CHARGING_STATION.getId().toString()) .setRolls(ConstantValue.exactly(1)) .when(ExplosionCondition.survivesExplosion()) .add(LootItem.lootTableItem(BlockRegistry.CHARGING_STATION.get()) @@ -135,26 +143,22 @@ protected void addTables() { @Override protected Iterable getKnownBlocks() { - return ImmutableList.of(BlockRegistry.CHARGING_STATION.get()); + return Collections.singletonList(BlockRegistry.CHARGING_STATION.get()); } } - - @Override - protected void validate(Map map, ValidationContext validationtracker) { - map.forEach((name, table) -> LootTables.validate(validationtracker, name, table)); - } } static class GeneratorRecipes extends RecipeProvider { - public GeneratorRecipes(DataGenerator generator) { - super(generator); + public GeneratorRecipes(PackOutput output) { + super(output); } + @Override - protected void buildCraftingRecipes(Consumer consumer) { + protected void buildRecipes(Consumer consumer) { Block block = BlockRegistry.CHARGING_STATION.get(); ShapedRecipeBuilder - .shaped(block) + .shaped(RecipeCategory.REDSTONE, block) .define('i', Tags.Items.INGOTS_IRON) .define('r', Tags.Items.DUSTS_REDSTONE) .define('l', Tags.Items.STORAGE_BLOCKS_COAL) @@ -168,12 +172,12 @@ protected void buildCraftingRecipes(Consumer consumer) { } static class GeneratorBlockTags extends BlockTagsProvider { - public GeneratorBlockTags(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) { - super(generator, ChargingGadgets.MOD_ID, existingFileHelper); + public GeneratorBlockTags(PackOutput output, CompletableFuture lookupProvider, @Nullable ExistingFileHelper existingFileHelper) { + super(output, lookupProvider, ChargingGadgets.MOD_ID, existingFileHelper); } @Override - protected void addTags() { + protected void addTags(HolderLookup.Provider lookup) { tag(BlockTags.MINEABLE_WITH_PICKAXE).add(BlockRegistry.CHARGING_STATION.get()); } } diff --git a/src/main/java/com/direwolf20/charginggadgets/blocks/BlockRegistry.java b/src/main/java/com/direwolf20/charginggadgets/blocks/BlockRegistry.java index 6994e85..20f4708 100644 --- a/src/main/java/com/direwolf20/charginggadgets/blocks/BlockRegistry.java +++ b/src/main/java/com/direwolf20/charginggadgets/blocks/BlockRegistry.java @@ -37,5 +37,5 @@ public class BlockRegistry { * items... so... when we add items. Move this! */ public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ChargingGadgets.MOD_ID); - public static final RegistryObject CHARGING_STATION_BI = ITEMS.register("charging_station", () -> new ChargingStationItem(CHARGING_STATION.get(), ChargingGadgets.ITEM_PROPS)); + public static final RegistryObject CHARGING_STATION_BI = ITEMS.register("charging_station", () -> new ChargingStationItem(CHARGING_STATION.get(), new Item.Properties())); } diff --git a/src/main/java/com/direwolf20/charginggadgets/blocks/chargingstation/ChargingStationContainer.java b/src/main/java/com/direwolf20/charginggadgets/blocks/chargingstation/ChargingStationContainer.java index eff1713..0fbcc10 100644 --- a/src/main/java/com/direwolf20/charginggadgets/blocks/chargingstation/ChargingStationContainer.java +++ b/src/main/java/com/direwolf20/charginggadgets/blocks/chargingstation/ChargingStationContainer.java @@ -13,6 +13,7 @@ import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; @@ -123,7 +124,7 @@ public RestrictedSlot(IItemHandler itemHandler, int index, int xPosition, int yP @Override public boolean mayPlace(@Nonnull ItemStack stack) { if (getSlotIndex() == ChargingStationTile.Slots.CHARGE.getId()) - return stack.getCapability(CapabilityEnergy.ENERGY).isPresent(); + return stack.getCapability(ForgeCapabilities.ENERGY).isPresent(); if (getSlotIndex() == ChargingStationTile.Slots.FUEL.getId()) return ForgeHooks.getBurnTime(stack, RecipeType.SMELTING) != 0; diff --git a/src/main/java/com/direwolf20/charginggadgets/blocks/chargingstation/ChargingStationTile.java b/src/main/java/com/direwolf20/charginggadgets/blocks/chargingstation/ChargingStationTile.java index d82e489..24f2e57 100644 --- a/src/main/java/com/direwolf20/charginggadgets/blocks/chargingstation/ChargingStationTile.java +++ b/src/main/java/com/direwolf20/charginggadgets/blocks/chargingstation/ChargingStationTile.java @@ -25,6 +25,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; @@ -109,7 +110,7 @@ public static void ticker(Level level, BlockPos blockPos private void chargeItem(ItemStack stack) { - this.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(itemEnergy -> { + this.getCapability(ForgeCapabilities.ENERGY).ifPresent(energyStorage -> stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(itemEnergy -> { if (!isChargingItem(itemEnergy)) return; @@ -126,7 +127,7 @@ private void tryBurn() { if (level == null) return; - this.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyStorage -> { + this.getCapability(ForgeCapabilities.ENERGY).ifPresent(energyStorage -> { boolean canInsertEnergy = energyStorage.receiveEnergy(625, true) > 0; if (counter > 0 && canInsertEnergy) { burn(energyStorage); @@ -189,10 +190,10 @@ public void saveAdditional(CompoundTag compound) { @Nonnull @Override public LazyOptional getCapability(@Nonnull Capability cap, final @Nullable Direction side) { - if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + if (cap == ForgeCapabilities.ITEM_HANDLER) return inventory.cast(); - if (cap == CapabilityEnergy.ENERGY) + if (cap == ForgeCapabilities.ENERGY) return energy.cast(); return super.getCapability(cap, side); diff --git a/src/main/java/com/direwolf20/charginggadgets/capabilities/ChargerItemHandler.java b/src/main/java/com/direwolf20/charginggadgets/capabilities/ChargerItemHandler.java index 973bc85..1860ddc 100644 --- a/src/main/java/com/direwolf20/charginggadgets/capabilities/ChargerItemHandler.java +++ b/src/main/java/com/direwolf20/charginggadgets/capabilities/ChargerItemHandler.java @@ -5,6 +5,7 @@ import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.RecipeType; import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.items.ItemStackHandler; @@ -32,7 +33,7 @@ public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate if (slot == ChargingStationTile.Slots.FUEL.getId() && ForgeHooks.getBurnTime(stack, RecipeType.SMELTING) <= 0) return stack; - if (slot == ChargingStationTile.Slots.CHARGE.getId() && (! stack.getCapability(CapabilityEnergy.ENERGY).isPresent() || getStackInSlot(slot).getCount() > 0)) + if (slot == ChargingStationTile.Slots.CHARGE.getId() && (! stack.getCapability(ForgeCapabilities.ENERGY).isPresent() || getStackInSlot(slot).getCount() > 0)) return stack; return super.insertItem(slot, stack, simulate); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 3623043..e4c72c6 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[43,)" +loaderVersion="[44,)" issueTrackerURL="https://github.com/Direwolf20-MC/ChargingGadgets/issues" license="MIT (https://github.com/Direwolf20-MC/ChargingGadgets/blob/master/LICENSE.md)" @@ -19,6 +19,6 @@ description=''' [[dependencies.charginggadgets]] modId="forge" mandatory=true - versionRange="[43,)" + versionRange="[44,)" ordering="NONE" side="BOTH" diff --git a/src/main/resources/assets/charginggadgets/textures/blocks/charging_station_bottom.png b/src/main/resources/assets/charginggadgets/textures/block/charging_station_bottom.png similarity index 100% rename from src/main/resources/assets/charginggadgets/textures/blocks/charging_station_bottom.png rename to src/main/resources/assets/charginggadgets/textures/block/charging_station_bottom.png diff --git a/src/main/resources/assets/charginggadgets/textures/blocks/charging_station_frontoff.png b/src/main/resources/assets/charginggadgets/textures/block/charging_station_frontoff.png similarity index 100% rename from src/main/resources/assets/charginggadgets/textures/blocks/charging_station_frontoff.png rename to src/main/resources/assets/charginggadgets/textures/block/charging_station_frontoff.png diff --git a/src/main/resources/assets/charginggadgets/textures/blocks/charging_station_fronton.png b/src/main/resources/assets/charginggadgets/textures/block/charging_station_fronton.png similarity index 100% rename from src/main/resources/assets/charginggadgets/textures/blocks/charging_station_fronton.png rename to src/main/resources/assets/charginggadgets/textures/block/charging_station_fronton.png diff --git a/src/main/resources/assets/charginggadgets/textures/blocks/charging_station_side.png b/src/main/resources/assets/charginggadgets/textures/block/charging_station_side.png similarity index 100% rename from src/main/resources/assets/charginggadgets/textures/blocks/charging_station_side.png rename to src/main/resources/assets/charginggadgets/textures/block/charging_station_side.png diff --git a/src/main/resources/assets/charginggadgets/textures/blocks/charging_station_top.png b/src/main/resources/assets/charginggadgets/textures/block/charging_station_top.png similarity index 100% rename from src/main/resources/assets/charginggadgets/textures/blocks/charging_station_top.png rename to src/main/resources/assets/charginggadgets/textures/block/charging_station_top.png