Skip to content

Commit

Permalink
Merge branch '1.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Feb 25, 2023
2 parents a61de77 + 2ed2897 commit 4854cc1
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 94 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ run

# Files from Forge MDK
forge*changelog.txt
includedMods/
includedMods/

.DS_Store
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"type": "minecraft:crafting_shaped",
"category": "redstone",
"key": {
"d": {
"tag": "forge:gems/lapis"
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/com/direwolf20/charginggadgets/ChargingGadgets.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,24 +17,13 @@
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
{
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();

Expand All @@ -44,6 +34,7 @@ public ChargingGadgets() {

event.addListener(this::setup);
event.addListener(this::clientSetup);
event.addListener(this::setupCreativeTabs);

MinecraftForge.EVENT_BUS.register(this);

Expand All @@ -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());
}
}
112 changes: 58 additions & 54 deletions src/main/java/com/direwolf20/charginggadgets/DataGenerators.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,89 +2,91 @@

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;
import net.minecraft.world.level.storage.loot.LootTables;
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;
import net.minecraftforge.client.model.generators.BlockStateProvider;
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;
import net.minecraftforge.eventbus.api.SubscribeEvent;
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)));
}

Expand All @@ -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
Expand All @@ -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<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootContextParamSet>> getTables() {
return ImmutableList.of(Pair.of(Blocks::new, LootContextParamSets.BLOCK));
protected void validate(Map<ResourceLocation, LootTable> 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())
Expand All @@ -135,26 +143,22 @@ protected void addTables() {

@Override
protected Iterable<Block> getKnownBlocks() {
return ImmutableList.of(BlockRegistry.CHARGING_STATION.get());
return Collections.singletonList(BlockRegistry.CHARGING_STATION.get());
}
}

@Override
protected void validate(Map<ResourceLocation, LootTable> 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<FinishedRecipe> consumer) {
protected void buildRecipes(Consumer<FinishedRecipe> 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)
Expand All @@ -168,12 +172,12 @@ protected void buildCraftingRecipes(Consumer<FinishedRecipe> consumer) {
}

static class GeneratorBlockTags extends BlockTagsProvider {
public GeneratorBlockTags(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) {
super(generator, ChargingGadgets.MOD_ID, existingFileHelper);
public GeneratorBlockTags(PackOutput output, CompletableFuture<HolderLookup.Provider> 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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ public class BlockRegistry {
* items... so... when we add items. Move this!
*/
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ChargingGadgets.MOD_ID);
public static final RegistryObject<Item> CHARGING_STATION_BI = ITEMS.register("charging_station", () -> new ChargingStationItem(CHARGING_STATION.get(), ChargingGadgets.ITEM_PROPS));
public static final RegistryObject<Item> CHARGING_STATION_BI = ITEMS.register("charging_station", () -> new ChargingStationItem(CHARGING_STATION.get(), new Item.Properties()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 4854cc1

Please sign in to comment.