Skip to content

Commit

Permalink
Updated mod from 1.19.2 -> 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Sephta committed Mar 29, 2023
1 parent 4b9e5e1 commit 9207051
Show file tree
Hide file tree
Showing 29 changed files with 617 additions and 310 deletions.
3 changes: 3 additions & 0 deletions src/main/java/net/stal/alloys/StalAlloys.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.stal.alloys;

import net.fabricmc.api.ModInitializer;
import net.stal.alloys.item.StalAlloysItemGroup;
// import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.stal.alloys.item.StalAlloysItems;
import net.stal.alloys.networking.StalAlloysMessages;
Expand Down Expand Up @@ -28,6 +29,8 @@ public void onInitialize() {
// Configured Features Must be called first
StalAlloysConfiguredFeatures.registerConfiguredFeatures();

StalAlloysItemGroup.registerItemGroup();

StalAlloysItems.registerModItems();

StalAlloysBlocks.registerModBlocks();
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/net/stal/alloys/StalAlloysDataGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@

import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.stal.alloys.datagen.StalAlloysLootTableGenerator;
import net.minecraft.registry.RegistryBuilder;
import net.minecraft.registry.RegistryKeys;
import net.stal.alloys.datagen.*;
import net.stal.alloys.world.StalAlloysConfiguredFeatures;
import net.stal.alloys.world.StalAlloysPlacedFeatures;

public class StalAlloysDataGenerator implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
StalAlloys.LOGGER.debug("Initializing Data Generator for " + StalAlloys.MOD_ID);

fabricDataGenerator.addProvider(StalAlloysLootTableGenerator::new);
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();

pack.addProvider(StalAlloysLootTableGenerator::new);
pack.addProvider(StalAlloysWorldGenerator::new);
}

@Override
public void buildRegistry(RegistryBuilder registryBuilder) {
DataGeneratorEntrypoint.super.buildRegistry(registryBuilder);

// Frustratingly the lambda is necessary here...
registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, (context) -> StalAlloysConfiguredFeatures.bootstrap(context));
registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, StalAlloysPlacedFeatures::bootstrap);
}
}
88 changes: 22 additions & 66 deletions src/main/java/net/stal/alloys/block/StalAlloysBlocks.java
Original file line number Diff line number Diff line change
@@ -1,72 +1,24 @@
package net.stal.alloys.block;

import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemGroup.Builder;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.intprovider.UniformIntProvider;
import net.minecraft.util.registry.Registry;
import net.stal.alloys.StalAlloys;
import net.stal.alloys.item.StalAlloysItemGroup;

public class StalAlloysBlocks {

// Block: Steel
// public static final Block STEEL_ORE = registerBlock(
// "steel_ore",
// new OreBlock(
// FabricBlockSettings
// .of(Material.STONE)
// .sounds(BlockSoundGroup.STONE)
// .strength(3.0F, 8.0F)
// .requiresTool(),
// UniformIntProvider.create(3, 8)
// ),
// StalAlloysItemGroup.STAL_ALLOYS
// );

// public static final Block DEEPSLATE_STEEL_ORE = registerBlock(
// "deepslate_steel_ore",
// new OreBlock(
// FabricBlockSettings
// .of(Material.STONE)
// .sounds(BlockSoundGroup.DEEPSLATE)
// .strength(4.5F, 8.0F)
// .requiresTool(),
// UniformIntProvider.create(4, 9)
// ),
// StalAlloysItemGroup.STAL_ALLOYS
// );

// public static final Block NETHERRACK_STEEL_ORE = registerBlock(
// "netherrack_steel_ore",
// new OreBlock(
// FabricBlockSettings
// .of(Material.STONE)
// .sounds(BlockSoundGroup.NETHERRACK)
// .strength(0.4F)
// .requiresTool(),
// UniformIntProvider.create(4, 9)
// ),
// StalAlloysItemGroup.STAL_ALLOYS
// );

// public static final Block ENDSTONE_STEEL_ORE = registerBlock(
// "endstone_steel_ore",
// new OreBlock(
// FabricBlockSettings
// .of(Material.STONE)
// .sounds(BlockSoundGroup.STONE)
// .strength(3.0F, 9.0F)
// .requiresTool(),
// UniformIntProvider.create(4, 9)
// ),
// StalAlloysItemGroup.STAL_ALLOYS
// );

public static final Block STEEL_BLOCK = registerBlock(
"steel_block",
Expand All @@ -83,7 +35,7 @@ public class StalAlloysBlocks {
// Block: Nickel
public static final Block NICKEL_ORE = registerBlock(
"nickel_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.STONE)
Expand All @@ -96,7 +48,7 @@ public class StalAlloysBlocks {

public static final Block DEEPSLATE_NICKEL_ORE = registerBlock(
"deepslate_nickel_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.DEEPSLATE)
Expand All @@ -109,7 +61,7 @@ public class StalAlloysBlocks {

public static final Block NETHERRACK_NICKEL_ORE = registerBlock(
"netherrack_nickel_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.NETHERRACK)
Expand Down Expand Up @@ -172,7 +124,7 @@ public class StalAlloysBlocks {
// Block: Chromium
public static final Block CHROMIUM_ORE = registerBlock(
"chromium_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.STONE)
Expand All @@ -185,7 +137,7 @@ public class StalAlloysBlocks {

public static final Block DEEPSLATE_CHROMIUM_ORE = registerBlock(
"deepslate_chromium_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.DEEPSLATE)
Expand All @@ -198,7 +150,7 @@ public class StalAlloysBlocks {

public static final Block NETHERRACK_CHROMIUM_ORE = registerBlock(
"netherrack_chromium_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.NETHERRACK)
Expand All @@ -224,7 +176,7 @@ public class StalAlloysBlocks {
// Block: Carbon
public static final Block CARBON_ORE = registerBlock(
"carbon_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.STONE)
Expand All @@ -237,7 +189,7 @@ public class StalAlloysBlocks {

public static final Block DEEPSLATE_CARBON_ORE = registerBlock(
"deepslate_carbon_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.DEEPSLATE)
Expand All @@ -251,7 +203,7 @@ public class StalAlloysBlocks {
// Block: Zinc
public static final Block ZINC_ORE = registerBlock(
"zinc_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.STONE)
Expand All @@ -264,7 +216,7 @@ public class StalAlloysBlocks {

public static final Block DEEPSLATE_ZINC_ORE = registerBlock(
"deepslate_zinc_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.DEEPSLATE)
Expand All @@ -290,7 +242,7 @@ public class StalAlloysBlocks {
// Block: Tin
public static final Block TIN_ORE = registerBlock(
"tin_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.STONE)
Expand All @@ -303,7 +255,7 @@ public class StalAlloysBlocks {

public static final Block DEEPSLATE_TIN_ORE = registerBlock(
"deepslate_tin_ore",
new OreBlock(
new ExperienceDroppingBlock(
FabricBlockSettings
.of(Material.STONE)
.sounds(BlockSoundGroup.DEEPSLATE)
Expand Down Expand Up @@ -331,11 +283,15 @@ public class StalAlloysBlocks {
private static Block registerBlock(String name, Block block, ItemGroup group) {
registerBlockItem(name, block, group);

return Registry.register(Registry.BLOCK, new Identifier(StalAlloys.MOD_ID, name), block);
return Registry.register(Registries.BLOCK, new Identifier(StalAlloys.MOD_ID, name), block);
}

private static Item registerBlockItem(String name, Block block, ItemGroup group) {
return Registry.register(Registry.ITEM, new Identifier(StalAlloys.MOD_ID, name), new BlockItem(block, new FabricItemSettings().group(group)));
Item item = Registry.register(Registries.ITEM, new Identifier(StalAlloys.MOD_ID, name), new BlockItem(block, new FabricItemSettings()));

ItemGroupEvents.modifyEntriesEvent(group).register(entries -> entries.add(item));

return item;
}

public static void registerModBlocks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.stal.alloys.StalAlloys;
import net.stal.alloys.block.StalAlloysBlocks;

Expand All @@ -14,7 +15,7 @@ public static void registerModBlockEntities() {
StalAlloys.LOGGER.debug("Registering Block Entities for " + StalAlloys.MOD_ID);

ALLOY_SMELTER_ENTITY = Registry.register(
Registry.BLOCK_ENTITY_TYPE,
Registries.BLOCK_ENTITY_TYPE,
new Identifier(
StalAlloys.MOD_ID,
"alloy_smelter"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,56 +1,38 @@
package net.stal.alloys.datagen;

import java.util.function.BiConsumer;

import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableProvider;
import net.minecraft.data.server.BlockLootTableGenerator;
import net.minecraft.loot.LootTable.Builder;
import net.minecraft.loot.context.*;
import net.minecraft.loot.provider.number.*;
import net.minecraft.util.Identifier;
import net.stal.alloys.StalAlloys;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
import net.stal.alloys.block.StalAlloysBlocks;
import net.stal.alloys.item.StalAlloysItems;

public class StalAlloysLootTableGenerator extends SimpleFabricLootTableProvider {
public StalAlloysLootTableGenerator(FabricDataGenerator dataGenerator) {
super(dataGenerator, LootContextTypes.BLOCK);
public class StalAlloysLootTableGenerator extends FabricBlockLootTableProvider {

public StalAlloysLootTableGenerator(FabricDataOutput dataOutput) {
super(dataOutput);
}

@Override
public void accept(BiConsumer<Identifier, Builder> biConsumer) {
// Alloy Smelter
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/alloy_smelter"), BlockLootTableGenerator.drops(StalAlloysBlocks.ALLOY_SMELTER, StalAlloysBlocks.ALLOY_SMELTER, ConstantLootNumberProvider.create(1.0F)));

// Nickel
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/nickel_block"), BlockLootTableGenerator.drops(StalAlloysBlocks.NICKEL_BLOCK, StalAlloysBlocks.NICKEL_BLOCK, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/cut_nickel"), BlockLootTableGenerator.drops(StalAlloysBlocks.CUT_NICKEL, StalAlloysBlocks.CUT_NICKEL, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/cut_nickel_slab"), BlockLootTableGenerator.drops(StalAlloysBlocks.CUT_NICKEL_SLAB, StalAlloysBlocks.CUT_NICKEL_SLAB, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/cut_nickel_stairs"), BlockLootTableGenerator.drops(StalAlloysBlocks.CUT_NICKEL_STAIRS, StalAlloysBlocks.CUT_NICKEL_STAIRS, ConstantLootNumberProvider.create(1.0F)));

biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/nickel_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.NICKEL_ORE, StalAlloysItems.RAW_NICKEL, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/deepslate_nickel_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.DEEPSLATE_NICKEL_ORE, StalAlloysItems.RAW_NICKEL, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/netherrack_nickel_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.NETHERRACK_NICKEL_ORE, StalAlloysItems.RAW_NICKEL, ConstantLootNumberProvider.create(1.0F)));

// Chromium
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/chromium_block"), BlockLootTableGenerator.drops(StalAlloysBlocks.CHROMIUM_BLOCK, StalAlloysBlocks.CHROMIUM_BLOCK, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/chromium_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.CHROMIUM_ORE, StalAlloysItems.RAW_CHROMIUM, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/deepslate_chromium_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.DEEPSLATE_CHROMIUM_ORE, StalAlloysItems.RAW_CHROMIUM, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/netherrack_chromium_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.NETHERRACK_CHROMIUM_ORE, StalAlloysItems.RAW_CHROMIUM, ConstantLootNumberProvider.create(1.0F)));

// Zinc
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/zinc_block"), BlockLootTableGenerator.drops(StalAlloysBlocks.ZINC_BLOCK, StalAlloysBlocks.ZINC_BLOCK, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/zinc_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.ZINC_ORE, StalAlloysItems.RAW_ZINC, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/deepslate_zinc_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.DEEPSLATE_ZINC_ORE, StalAlloysItems.RAW_ZINC, ConstantLootNumberProvider.create(1.0F)));

// Tin
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/tin_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.TIN_ORE, StalAlloysItems.RAW_TIN, ConstantLootNumberProvider.create(1.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/deepslate_tin_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.DEEPSLATE_TIN_ORE, StalAlloysItems.RAW_TIN, ConstantLootNumberProvider.create(1.0F)));

// Carbon
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/carbon_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.CARBON_ORE, StalAlloysItems.RAW_CARBON, UniformLootNumberProvider.create(2.0F, 6.0F)));
biConsumer.accept(new Identifier(StalAlloys.MOD_ID, "blocks/deepslate_carbon_ore"), BlockLootTableGenerator.drops(StalAlloysBlocks.DEEPSLATE_CARBON_ORE, StalAlloysItems.RAW_CARBON, UniformLootNumberProvider.create(2.0F, 6.0F)));
public void generate() {
addDrop(StalAlloysBlocks.ALLOY_SMELTER, nameableContainerDrops(StalAlloysBlocks.ALLOY_SMELTER));

addDrop(StalAlloysBlocks.NICKEL_BLOCK);
addDrop(StalAlloysBlocks.CUT_NICKEL);
addDrop(StalAlloysBlocks.CUT_NICKEL_SLAB);
addDrop(StalAlloysBlocks.CUT_NICKEL_STAIRS);
addDrop(StalAlloysBlocks.NICKEL_ORE, oreDrops(StalAlloysBlocks.NICKEL_ORE, StalAlloysItems.RAW_NICKEL));
addDrop(StalAlloysBlocks.DEEPSLATE_NICKEL_ORE, oreDrops(StalAlloysBlocks.DEEPSLATE_NICKEL_ORE, StalAlloysItems.RAW_NICKEL));
addDrop(StalAlloysBlocks.NETHERRACK_NICKEL_ORE, oreDrops(StalAlloysBlocks.NETHERRACK_NICKEL_ORE, StalAlloysItems.RAW_NICKEL));

addDrop(StalAlloysBlocks.CHROMIUM_BLOCK);
addDrop(StalAlloysBlocks.NETHERRACK_CHROMIUM_ORE, oreDrops(StalAlloysBlocks.NETHERRACK_CHROMIUM_ORE, StalAlloysItems.RAW_CHROMIUM));

addDrop(StalAlloysBlocks.ZINC_BLOCK);
addDrop(StalAlloysBlocks.ZINC_ORE, oreDrops(StalAlloysBlocks.ZINC_ORE, StalAlloysItems.RAW_ZINC));
addDrop(StalAlloysBlocks.DEEPSLATE_ZINC_ORE, oreDrops(StalAlloysBlocks.DEEPSLATE_ZINC_ORE, StalAlloysItems.RAW_ZINC));

addDrop(StalAlloysBlocks.TIN_ORE, oreDrops(StalAlloysBlocks.TIN_ORE, StalAlloysItems.RAW_TIN));
addDrop(StalAlloysBlocks.DEEPSLATE_TIN_ORE, oreDrops(StalAlloysBlocks.DEEPSLATE_TIN_ORE, StalAlloysItems.RAW_TIN));

addDrop(StalAlloysBlocks.DEEPSLATE_CARBON_ORE, oreDrops(StalAlloysBlocks.DEEPSLATE_CARBON_ORE, StalAlloysItems.RAW_CARBON));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.stal.alloys.datagen;

import java.util.concurrent.CompletableFuture;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.stal.alloys.StalAlloys;

public class StalAlloysWorldGenerator extends FabricDynamicRegistryProvider {

public StalAlloysWorldGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}

@Override
protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) {
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE));
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE));
}

@Override
public String getName() {
return StalAlloys.MOD_ID;
}

}
Loading

0 comments on commit 9207051

Please sign in to comment.