Skip to content

Commit

Permalink
Changed Duracite to Steel.
Browse files Browse the repository at this point in the history
Removed Duracite World Gen.
Signed-off-by: SuperScary
  • Loading branch information
SuperScary committed Oct 23, 2024
1 parent db4ec77 commit 386e350
Show file tree
Hide file tree
Showing 68 changed files with 408 additions and 478 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeType;
import net.superscary.fluxmachines.api.inventory.InventoryHolder;

import java.util.Optional;

public interface Crafter<T extends Recipe<?>> {
public interface Crafter<T extends Recipe<?>> extends InventoryHolder {

void craftItem ();

Expand All @@ -24,4 +25,6 @@ public interface Crafter<T extends Recipe<?>> {

boolean hasFinished ();

boolean isCrafting();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.superscary.fluxmachines.api.inventory;

import net.neoforged.neoforge.items.ItemStackHandler;

public interface InventoryHolder {

ItemStackHandler getInventory();

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.SimpleContainer;
import net.minecraft.world.*;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
Expand All @@ -23,14 +20,13 @@
import net.minecraft.world.phys.BlockHitResult;
import net.neoforged.neoforge.items.ItemStackHandler;
import net.superscary.fluxmachines.api.data.BlockData;
import net.superscary.fluxmachines.api.inventory.InventoryHolder;
import net.superscary.fluxmachines.hook.WrenchHook;
import net.superscary.fluxmachines.util.keys.Keys;
import org.jetbrains.annotations.MustBeInvokedByOverriders;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public abstract class FMBaseBlockEntity extends BlockEntity implements MenuProvider, BlockData {
public abstract class FMBaseBlockEntity extends BlockEntity implements MenuProvider, BlockData, InventoryHolder {

public final ItemStackHandler INVENTORY_SINGLE = new ItemStackHandler(1) {
@Override
Expand Down Expand Up @@ -87,11 +83,6 @@ public Packet<ClientGamePacketListener> getUpdatePacket () {
return ClientboundBlockEntityDataPacket.create(this);
}

@MustBeInvokedByOverriders
public void addAdditionalDrops (Level level, BlockPos pos, List<ItemStack> drops) {

}

@Override
public @NotNull CompoundTag getUpdateTag (HolderLookup.@NotNull Provider registries) {
return saveWithoutMetadata(registries);
Expand All @@ -112,6 +103,11 @@ public void handleUpdateTag (@NotNull CompoundTag tag, HolderLookup.@NotNull Pro
loadClientData(tag, lookupProvider);
}

/**
* Save entity data to the dropped item
* @param stack
* @param registries
*/
@Override
public void saveToItem (@NotNull ItemStack stack, HolderLookup.@NotNull Provider registries) {
super.saveToItem(stack, registries);
Expand All @@ -132,6 +128,15 @@ public void drops () {
Containers.dropContents(level, worldPosition, container);
}

/**
* TODO: save data to item and drop that item rather than drop contents.
* Allows disassembly with wrench. Called by {@link WrenchHook#onPlayerUseBlock(Player, Level, InteractionHand, BlockHitResult)}
* @param player {@link Player} the player
* @param level {@link Level} the level
* @param hitResult {@link BlockHitResult} hit result of the interaction
* @param wrench the {@link ItemStack} used. Already checked to contain {@link net.superscary.fluxmachines.util.tags.FMTag.Items#WRENCH}
* @return {@link InteractionResult}
*/
public InteractionResult disassembleWithWrench (Player player, Level level, BlockHitResult hitResult, ItemStack wrench) {
var pos = hitResult.getBlockPos();
var state = level.getBlockState(pos);
Expand All @@ -141,7 +146,7 @@ public InteractionResult disassembleWithWrench (Player player, Level level, Bloc
var drops = Block.getDrops(state, serverLevel, pos, this, player, wrench);

for (var item : drops) {
player.getInventory().placeItemBackInInventory(item);
Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), item);
}
}

Expand All @@ -151,6 +156,7 @@ public InteractionResult disassembleWithWrench (Player player, Level level, Bloc
return InteractionResult.sidedSuccess(level.isClientSide());
}

@Override
public ItemStackHandler getInventory () {
return inventory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public int getEnergyAmount () {
return 8;
}

@Override
public boolean isCrafting () {
return isCrafting;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
import net.neoforged.neoforge.registries.RegisterEvent;
import net.neoforged.neoforge.server.ServerLifecycleHooks;
import net.superscary.fluxmachines.datagen.DataGenerators;
import net.superscary.fluxmachines.hook.HammerHook;
import net.superscary.fluxmachines.hook.WrenchHook;
import net.superscary.fluxmachines.impl.top.FMTopPlugin;
import net.superscary.fluxmachines.item.material.FMArmorMaterials;
Expand Down Expand Up @@ -59,6 +59,7 @@ public FluxMachinesBase (IEventBus modEventBus) {
NeoForge.EVENT_BUS.addListener(this::serverStopped);
NeoForge.EVENT_BUS.addListener(this::serverStopping);
NeoForge.EVENT_BUS.addListener(WrenchHook::onPlayerUseBlockEvent);
NeoForge.EVENT_BUS.addListener(HammerHook::onPlayerUseBlockEvent);

}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/superscary/fluxmachines/core/Tab.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Tab {
public static void init (Registry<CreativeModeTab> registry) {
var tab = CreativeModeTab.builder()
.title(Component.translatable("itemGroup.fluxmachines"))
.icon(FMItems.DURACITE_INGOT::stack)
.icon(FMItems.STEEL_INGOT::stack)
.displayItems(Tab::buildDisplayItems)
.build();
Registry.register(registry, Keys.MAIN, tab);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

import static net.superscary.fluxmachines.registries.FMItems.DURACITE_INGOT;
import static net.superscary.fluxmachines.registries.FMItems.STEEL_INGOT;
import static net.superscary.fluxmachines.registries.FMItems.HARD_BOILED_EGG;

public class AchievementProvider extends AdvancementProvider {
Expand Down Expand Up @@ -78,7 +78,7 @@ private static void buildParents (Consumer<AdvancementHolder> consumer, Existing
.save(consumer, FluxMachines.getResource("advancements/newworld"), existingFileHelper);

strongerThanIron = Advancement.Builder.advancement()
.display(DURACITE_INGOT,
.display(STEEL_INGOT,
Component.translatable("advancement.fluxmachines.strongerthaniron.title"),
Component.translatable("advancement.fluxmachines.strongerthaniron.desc"),
null,
Expand All @@ -89,7 +89,7 @@ private static void buildParents (Consumer<AdvancementHolder> consumer, Existing
)
.parent(parent)
.requirements(AdvancementRequirements.Strategy.OR)
.addCriterion("has_duracite", InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(DURACITE_INGOT)))
.addCriterion("has_steel", InventoryChangeTrigger.TriggerInstance.hasItems(ItemPredicate.Builder.item().of(STEEL_INGOT)))
.save(consumer, FluxMachines.getResource("advancements/stronger_than_iron"), existingFileHelper);

buildCasing = Advancement.Builder.advancement()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.data.DataGenerator;
import net.neoforged.neoforge.common.data.LanguageProvider;
import net.superscary.fluxmachines.api.data.IDataProvider;
import net.superscary.fluxmachines.block.machine.FluxFurnaceBlock;
import net.superscary.fluxmachines.core.FluxMachines;

import static net.superscary.fluxmachines.registries.FMBlocks.*;
Expand All @@ -24,31 +23,26 @@ protected void addTranslations () {
}

protected void blocks () {
add(DURACITE_ORE.block(), "Duracite Ore");
add(DURACITE_DEEPSLATE_ORE.block(), "Deepslate Duracite Ore");
add(DURACITE_NETHER_ORE.block(), "Duracite Nether Ore");
add(DURACITE_BLOCK_RAW.block(), "Raw Duracite Block");
add(DURACITE_BLOCK.block(), "Duracite Block");
add(STEEL_BLOCK.block(), "Steel Block");
add(MACHINE_CASING.block(), "Machine Casing");
add(FLUX_FURNACE.block(), "Flux Furnace");
}

protected void items () {
add(RAW_DURACITE.asItem(), "Raw Duracite");
add(DURACITE_DUST.asItem(), "Duracite Dust");
add(DURACITE_INGOT.asItem(), "Duracite Ingot");
add(DURACITE_NUGGET.asItem(), "Duracite Nugget");
add(DURACITE_HELMET.asItem(), "Duracite Helmet");
add(DURACITE_CHESTPLATE.asItem(), "Duracite Chestplate");
add(DURACITE_LEGGINGS.asItem(), "Duracite Leggings");
add(DURACITE_BOOTS.asItem(), "Duracite Boots");
add(DURACITE_SWORD.asItem(), "Duracite Sword");
add(DURACITE_PICKAXE.asItem(), "Duracite Pickaxe");
add(DURACITE_SHOVEL.asItem(), "Duracite Shovel");
add(DURACITE_AXE.asItem(), "Duracite Axe");
add(DURACITE_HOE.asItem(), "Duracite Hoe");
add(DURACITE_PAXEL.asItem(), "Duracite Paxel");
add(DURACITE_HAMMER.asItem(), "Duracite Hammer");
add(STEEL_DUST.asItem(), "Steel Dust");
add(STEEL_INGOT.asItem(), "Steel Ingot");
add(STEEL_NUGGET.asItem(), "Steel Nugget");
add(STEEL_HELMET.asItem(), "Steel Helmet");
add(STEEL_CHESTPLATE.asItem(), "Steel Chestplate");
add(STEEL_LEGGINGS.asItem(), "Steel Leggings");
add(STEEL_BOOTS.asItem(), "Steel Boots");
add(STEEL_SWORD.asItem(), "Steel Sword");
add(STEEL_PICKAXE.asItem(), "Steel Pickaxe");
add(STEEL_SHOVEL.asItem(), "Steel Shovel");
add(STEEL_AXE.asItem(), "Steel Axe");
add(STEEL_HOE.asItem(), "Steel Hoe");
add(STEEL_PAXEL.asItem(), "Steel Paxel");
add(STEEL_HAMMER.asItem(), "Steel Hammer");
add(WRENCH.asItem(), "Wrench");

add(HONEY_BUN.asItem(), "Honey Bun");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ public class DropProvider extends BlockLootSubProvider {
@NotNull
private ImmutableMap<Block, Function<Block, LootTable.Builder>> createOverrides () {
return ImmutableMap.<Block, Function<Block, LootTable.Builder>>builder()
.put(DURACITE_ORE.block(), oreBlock(DURACITE_ORE.block(), RAW_DURACITE.asItem()))
.put(DURACITE_DEEPSLATE_ORE.block(), oreBlock(DURACITE_DEEPSLATE_ORE.block(), RAW_DURACITE.asItem()))
.put(DURACITE_NETHER_ORE.block(), oreBlock(DURACITE_NETHER_ORE.block(), DURACITE_NUGGET.asItem()))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ public BlockModelProvider (PackOutput output, ExistingFileHelper exFileHelper) {

@Override
protected void registerStatesAndModels () {
blockWithItem(DURACITE_ORE);
blockWithItem(DURACITE_DEEPSLATE_ORE);
blockWithItem(DURACITE_NETHER_ORE);
blockWithItem(DURACITE_BLOCK_RAW);
blockWithItem(DURACITE_BLOCK);
blockWithItem(STEEL_BLOCK);
blockWithItem(MACHINE_CASING);

machine(FLUX_FURNACE, "flux_furnace");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.core.Direction;
import net.minecraft.data.PackOutput;
import net.minecraft.data.models.blockstates.*;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.level.block.StairBlock;
import net.minecraft.world.level.block.WallBlock;
Expand All @@ -18,8 +17,6 @@
import net.superscary.fluxmachines.core.FluxMachines;
import net.superscary.fluxmachines.util.block.BlockDefinition;

import java.util.function.Supplier;

public abstract class FMBlockStateProvider extends BlockStateProvider implements IDataProvider {

private static final VariantProperty<VariantProperties.Rotation> Z_ROT = new VariantProperty<>("fluxmachines:z", r -> new JsonPrimitive(r.ordinal() * 90));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.armortrim.TrimMaterial;
import net.minecraft.world.item.armortrim.TrimMaterials;
import net.neoforged.neoforge.client.model.generators.ItemModelBuilder;
import net.neoforged.neoforge.client.model.generators.ItemModelProvider;
import net.neoforged.neoforge.client.model.generators.ModelFile;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.neoforged.neoforge.registries.DeferredItem;
import net.superscary.fluxmachines.api.data.IDataProvider;
import net.superscary.fluxmachines.core.FluxMachines;
import net.superscary.fluxmachines.util.block.BlockDefinition;
Expand Down Expand Up @@ -49,28 +47,27 @@ private static ResourceLocation makeId (String id) {

@Override
protected void registerModels () {
handheldItem(RAW_DURACITE.asItem());
handheldItem(DURACITE_DUST.asItem());
handheldItem(DURACITE_INGOT.asItem());
handheldItem(DURACITE_NUGGET.asItem());
handheldItem(DURACITE_SWORD.asItem());
handheldItem(DURACITE_PICKAXE.asItem());
handheldItem(DURACITE_SHOVEL.asItem());
handheldItem(DURACITE_AXE.asItem());
handheldItem(DURACITE_HOE.asItem());
handheldItem(DURACITE_PAXEL.asItem());
handheldItem(DURACITE_HAMMER.asItem());
handheldItem(STEEL_DUST.asItem());
handheldItem(STEEL_INGOT.asItem());
handheldItem(STEEL_NUGGET.asItem());
handheldItem(STEEL_SWORD.asItem());
handheldItem(STEEL_PICKAXE.asItem());
handheldItem(STEEL_SHOVEL.asItem());
handheldItem(STEEL_AXE.asItem());
handheldItem(STEEL_HOE.asItem());
handheldItem(STEEL_PAXEL.asItem());
handheldItem(STEEL_HAMMER.asItem());
handheldItem(WRENCH.asItem());

basicItem(HONEY_BUN.asItem());
basicItem(HARD_BOILED_EGG.asItem());

blockOff(FLUX_FURNACE);

trimmedArmorItem(DURACITE_HELMET);
trimmedArmorItem(DURACITE_CHESTPLATE);
trimmedArmorItem(DURACITE_LEGGINGS);
trimmedArmorItem(DURACITE_BOOTS);
trimmedArmorItem(STEEL_HELMET);
trimmedArmorItem(STEEL_CHESTPLATE);
trimmedArmorItem(STEEL_LEGGINGS);
trimmedArmorItem(STEEL_BOOTS);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

import java.util.concurrent.CompletableFuture;

import static net.superscary.fluxmachines.registries.FMBlocks.*;
import static net.superscary.fluxmachines.registries.FMBlocks.DURACITE_DEEPSLATE_ORE;
import static net.superscary.fluxmachines.registries.FMItems.DURACITE_DUST;
import static net.superscary.fluxmachines.registries.FMItems.RAW_DURACITE;
import static net.superscary.fluxmachines.registries.FMItems.STEEL_DUST;

public class BlastingRecipes extends FMRecipeProvider {

Expand All @@ -28,40 +25,15 @@ public BlastingRecipes (PackOutput packOutput, CompletableFuture<HolderLookup.Pr

@Override
public @NotNull String getName () {
return "FluxMachines Blasting Recipes";
return "Flux Machines Blasting Recipes";
}

@Override
public void buildRecipes(@NotNull RecipeOutput consumer) {
public void buildRecipes (@NotNull RecipeOutput consumer) {
SimpleCookingRecipeBuilder
.blasting(Ingredient.of(RAW_DURACITE), RecipeCategory.MISC, FMItems.DURACITE_INGOT, .35f, DEFAULT_BLASTING_TIME)
.unlockedBy("has_duracite_raw", has(RAW_DURACITE))
.save(consumer, FluxMachines.getResource("blasting/duracite_from_raw_duracite"));

SimpleCookingRecipeBuilder
.blasting(Ingredient.of(DURACITE_ORE), RecipeCategory.MISC, FMItems.DURACITE_INGOT, .35f, DEFAULT_BLASTING_TIME)
.unlockedBy("has_duracite_ore", has(DURACITE_ORE))
.save(consumer, FluxMachines.getResource("blasting/duracite_from_duracite_ore"));

SimpleCookingRecipeBuilder
.blasting(Ingredient.of(DURACITE_NETHER_ORE), RecipeCategory.MISC, FMItems.DURACITE_INGOT, .35f, DEFAULT_BLASTING_TIME)
.unlockedBy("has_duracite_ore", has(DURACITE_NETHER_ORE))
.save(consumer, FluxMachines.getResource("blasting/duracite_from_duracite_nether_ore"));

SimpleCookingRecipeBuilder
.blasting(Ingredient.of(DURACITE_DEEPSLATE_ORE), RecipeCategory.MISC, FMItems.DURACITE_INGOT, .35f, DEFAULT_BLASTING_TIME)
.unlockedBy("has_duracite_ore", has(DURACITE_DEEPSLATE_ORE))
.save(consumer, FluxMachines.getResource("blasting/duracite_from_duracite_deepslate_ore"));

SimpleCookingRecipeBuilder
.blasting(Ingredient.of(DURACITE_DUST), RecipeCategory.MISC, new ItemStack(FMItems.DURACITE_INGOT, 2), .35f, DEFAULT_BLASTING_TIME)
.unlockedBy("has_duracite_dust", has(DURACITE_DUST))
.save(consumer, FluxMachines.getResource("blasting/duracite_from_duracite_dust"));

SimpleCookingRecipeBuilder
.blasting(Ingredient.of(DURACITE_BLOCK_RAW), RecipeCategory.MISC, DURACITE_BLOCK, 3.15f, DEFAULT_BLASTING_TIME * 9)
.unlockedBy("has_duracite_block", has(DURACITE_BLOCK_RAW))
.save(consumer, FluxMachines.getResource("blasting/duracite_block_from_duracite_block_raw"));
.blasting(Ingredient.of(STEEL_DUST), RecipeCategory.MISC, new ItemStack(FMItems.STEEL_INGOT, 2), .35f, DEFAULT_BLASTING_TIME)
.unlockedBy("has_steel_dust", has(STEEL_DUST))
.save(consumer, FluxMachines.getResource("blasting/steel_from_steel_dust"));
}

}
Loading

0 comments on commit 386e350

Please sign in to comment.