Skip to content

Commit

Permalink
Recipe Repair (#208)
Browse files Browse the repository at this point in the history
Co-authored-by: Clayton T <[email protected]>
Co-authored-by: MagicMaan <[email protected]>
  • Loading branch information
3 people authored Mar 25, 2024
1 parent 0f60374 commit dcc2c9c
Show file tree
Hide file tree
Showing 31 changed files with 62 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.slf4j.Logger;
import whocraft.tardis_refined.client.TRParticles;
import whocraft.tardis_refined.common.capability.upgrades.Upgrades;
import whocraft.tardis_refined.common.crafting.ManipulatorCrafting;
import whocraft.tardis_refined.common.hum.TardisHums;
import whocraft.tardis_refined.common.network.TardisNetwork;
import whocraft.tardis_refined.common.network.messages.sync.SyncConsolePatternsMessage;
Expand All @@ -21,7 +20,6 @@
import whocraft.tardis_refined.common.tardis.themes.ShellTheme;
import whocraft.tardis_refined.common.world.ChunkGenerators;
import whocraft.tardis_refined.common.world.Features;
import whocraft.tardis_refined.registry.ARSStructurePieceRegistry;
import whocraft.tardis_refined.patterns.ConsolePatterns;
import whocraft.tardis_refined.patterns.ShellPatterns;
import whocraft.tardis_refined.registry.*;
Expand Down Expand Up @@ -72,7 +70,6 @@ public static void init() {
TardisHums.registerDefaultHums();

ARSStructurePieceRegistry.register();
ManipulatorCrafting.registerRecipes();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
import net.minecraft.resources.ResourceLocation;
import whocraft.tardis_refined.common.capability.upgrades.Upgrade;
import whocraft.tardis_refined.common.capability.upgrades.Upgrades;
import whocraft.tardis_refined.common.tardis.TardisDesktops;
import whocraft.tardis_refined.common.tardis.themes.DesktopTheme;
import whocraft.tardis_refined.common.tardis.themes.ShellTheme;
import whocraft.tardis_refined.constants.ModMessages;

import java.util.Collection;
Expand All @@ -28,6 +25,7 @@ public class UpgradeArgumentType implements ArgumentType<ResourceLocation> {
private static final Collection<String> EXAMPLES = Stream.of(Upgrades.COORDINATE_INPUT).map((upgrade) -> {
return upgrade != null ? upgrade.getId().toString() : "";
}).collect(Collectors.toList());

public static final DynamicCommandExceptionType INVALID_UPGRADE_EXCEPTION = new DynamicCommandExceptionType((upgrade) -> Component.translatable(ModMessages.CMD_ARG_UPGRADE_INVALID, upgrade));

public static UpgradeArgumentType upgradeArgumentType() {
Expand All @@ -41,11 +39,13 @@ public ResourceLocation parse(StringReader reader) throws CommandSyntaxException

@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {

return SharedSuggestionProvider.suggestResource(Upgrades.UPGRADE_REGISTRY.keySet(), builder);
}

@Override
public Collection<String> getExamples() {
EXAMPLES.add("*");
return EXAMPLES;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Blocks;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.common.blockentity.device.ManipulatorCraftingRecipe;
import whocraft.tardis_refined.common.blockentity.device.ManipulatorCraftingRecipeItem;
import whocraft.tardis_refined.registry.BlockRegistry;
Expand All @@ -18,6 +17,8 @@ public class ManipulatorCrafting {

public static void registerRecipes() {

MANIPULATOR_CRAFTING_RECIPES.clear();

register(new ManipulatorCraftingRecipe(Arrays.asList(
new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 0), Blocks.SMOOTH_STONE_SLAB),
new ManipulatorCraftingRecipeItem(new BlockPos(0, 0, 1), BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ public class ARSStructurePieceRegistry {
public static List<ARSStructurePiece> ROOMS = new ArrayList<>();

public static void register() {

registerCorridors();
registerRooms();

}

public static void registerCorridors() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package whocraft.tardis_refined.fabric.events;

import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.minecraft.server.level.ServerLevel;
Expand All @@ -14,6 +13,7 @@
import whocraft.tardis_refined.client.TardisClientData;
import whocraft.tardis_refined.command.TardisRefinedCommand;
import whocraft.tardis_refined.common.capability.TardisLevelOperator;
import whocraft.tardis_refined.common.crafting.ManipulatorCrafting;
import whocraft.tardis_refined.common.dimension.TardisTeleportData;
import whocraft.tardis_refined.common.dimension.fabric.DimensionHandlerImpl;
import whocraft.tardis_refined.common.util.MiscHelper;
Expand All @@ -36,8 +36,13 @@ public static void addCommonEvents() {
}
});
ServerLifecycleEvents.SERVER_STARTED.register(server -> {

// Load Levels
ServerLevel world = server.getLevel(Level.OVERWORLD);
DimensionHandlerImpl.loadLevels(world);

//Register Recipes
ManipulatorCrafting.registerRecipes();
});

ServerLifecycleEvents.SERVER_STOPPING.register(server -> DimensionHandlerImpl.clear());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void onLevelTick(TickEvent.LevelTickEvent event) {
}

public static Optional<TardisLevelOperator> get(ServerLevel level) {
if(level == null) {
if (level == null) {
return Optional.empty();
}
return level.getCapability(TARDIS_DATA).resolve();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,21 @@
package whocraft.tardis_refined.common.data;

import com.google.common.collect.ImmutableList;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.HolderSet;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DataProvider;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraft.world.level.levelgen.placement.RarityFilter;
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest;
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
import net.neoforged.neoforge.common.world.BiomeModifier;
import net.neoforged.neoforge.common.world.BiomeModifiers;
import net.neoforged.neoforge.data.event.GatherDataEvent;
import net.neoforged.neoforge.registries.NeoForgeRegistries;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.common.world.Features;
import whocraft.tardis_refined.common.world.feature.NbtTemplateFeature;
import whocraft.tardis_refined.common.world.feature.config.NbtTemplateFeatureConfig;
import whocraft.tardis_refined.registry.BlockRegistry;
import whocraft.tardis_refined.registry.FeatureKeys;
import whocraft.tardis_refined.registry.TagKeys;

import java.util.List;
import java.util.Set;

import static net.minecraft.data.worldgen.features.FeatureUtils.createKey;
import static whocraft.tardis_refined.common.data.ProviderConfiguredFeatures.TARDIS_ROOT_CLUSTER_CONF_FEATURE;
import static whocraft.tardis_refined.common.data.ProviderPlacedFeatures.TARDIS_ROOT_CLUSTER_PLACED_FEATUE;

public class BiomeModifierProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import net.minecraft.data.DataProvider;
import net.minecraft.resources.ResourceLocation;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;
import whocraft.tardis_refined.patterns.ConsolePattern;
import whocraft.tardis_refined.patterns.ConsolePatternCollection;
import whocraft.tardis_refined.patterns.ConsolePatterns;

import java.nio.file.Path;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

public class ConsolePatternProvider implements DataProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.common.hum.HumEntry;
import whocraft.tardis_refined.common.hum.TardisHums;
import whocraft.tardis_refined.registry.SoundRegistry;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ protected void registerModels() {
basicItem(ItemRegistry.RAW_ZEITON.getId());






}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
import whocraft.tardis_refined.registry.ItemRegistry;
import whocraft.tardis_refined.registry.SoundRegistry;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class LangProviderEnglish extends LanguageProvider {

public LangProviderEnglish(DataGenerator gen) {
Expand Down Expand Up @@ -216,7 +210,6 @@ protected void addTranslations() {
}



public void addControl(ConsoleControl control, String name) {
add(control.getTranslationKey(), name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.jetbrains.annotations.Nullable;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.registry.BlockRegistry;
import whocraft.tardis_refined.registry.RegistrySupplier;

import java.util.concurrent.CompletableFuture;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
ConfiguredFeature<NbtTemplateFeatureConfig, NbtTemplateFeature> tardisRootCluster = new ConfiguredFeature<>(Features.NBT_FEATURE.get(), new NbtTemplateFeatureConfig(templateLocation, 0));

HolderGetter<ConfiguredFeature<?, ?>> configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE);
register(context, ORE_ZEITON, Feature.ORE, new OreConfiguration(ImmutableList.of(OreConfiguration.target(stoneReplaceable, BlockRegistry.ZEITON_ORE.get().defaultBlockState()), OreConfiguration.target(deepslateReplaceable, BlockRegistry.ZEITON_ORE_DEEPSLATE.get().defaultBlockState())), 9));
register(context, ORE_ZEITON_SMALL, Feature.ORE, new OreConfiguration(ImmutableList.of(OreConfiguration.target(stoneReplaceable,BlockRegistry.ZEITON_ORE.get().defaultBlockState()), OreConfiguration.target(deepslateReplaceable, BlockRegistry.ZEITON_ORE_DEEPSLATE.get().defaultBlockState())), 4));
register(context, ORE_ZEITON, Feature.ORE, new OreConfiguration(ImmutableList.of(OreConfiguration.target(stoneReplaceable, BlockRegistry.ZEITON_ORE.get().defaultBlockState()), OreConfiguration.target(deepslateReplaceable, BlockRegistry.ZEITON_ORE_DEEPSLATE.get().defaultBlockState())), 9));
register(context, ORE_ZEITON_SMALL, Feature.ORE, new OreConfiguration(ImmutableList.of(OreConfiguration.target(stoneReplaceable, BlockRegistry.ZEITON_ORE.get().defaultBlockState()), OreConfiguration.target(deepslateReplaceable, BlockRegistry.ZEITON_ORE_DEEPSLATE.get().defaultBlockState())), 4));
context.register(TARDIS_ROOT_CLUSTER_CONF_FEATURE, tardisRootCluster);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class ProviderEntityTags extends EntityTypeTagsProvider {
public static final TagKey<EntityType<?>> ENTITY_BLACKLIST = TagKey.create(Registries.ENTITY_TYPE, new ResourceLocation("carryon", "entity_blacklist"));



public ProviderEntityTags(PackOutput output, CompletableFuture<HolderLookup.Provider> completableFuture, @Nullable ExistingFileHelper existingFileHelper) {
super(output, completableFuture, TardisRefined.MODID, existingFileHelper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import org.jetbrains.annotations.NotNull;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.registry.BlockRegistry;
import whocraft.tardis_refined.registry.EntityRegistry;
import whocraft.tardis_refined.registry.ItemRegistry;
Expand Down Expand Up @@ -48,7 +47,7 @@ protected Iterable<Block> getKnownBlocks() {
ArrayList<@NotNull Block> blocks = new ArrayList<>();
for (Block entry : BlockRegistry.BLOCKS.getRegistry().stream().toList()) {
ResourceLocation blockId = BlockRegistry.BLOCKS.getRegistry().getKey(entry);
if(!blockId.toString().contains("minecraft")) {
if (!blockId.toString().contains("minecraft")) {
blocks.add(entry);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void buildRecipes(RecipeOutput consumer) {
ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, BlockRegistry.ZEITON_FUSED_COPPER_BLOCK.get()).requires(ItemRegistry.ZEITON_INGOT.get()).requires(Items.COPPER_BLOCK).unlockedBy("has_crafting_table", has(ItemRegistry.ZEITON_INGOT.get())).save(consumer);
ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, BlockRegistry.ZEITON_FUSED_IRON_BLOCK.get()).requires(ItemRegistry.ZEITON_INGOT.get()).requires(Items.IRON_BLOCK).unlockedBy("has_crafting_table", has(ItemRegistry.ZEITON_INGOT.get())).save(consumer);

ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockRegistry.ZEITON_BLOCK.get()).pattern("ZZZ").pattern("ZZZ").pattern("ZZZ").define('Z', ItemRegistry.ZEITON_INGOT.get()).unlockedBy("has_crafting_table", has(ItemRegistry.ZEITON_INGOT.get())).save(consumer);
ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, BlockRegistry.ZEITON_BLOCK.get()).pattern("ZZZ").pattern("ZZZ").pattern("ZZZ").define('Z', ItemRegistry.ZEITON_INGOT.get()).unlockedBy("has_crafting_table", has(ItemRegistry.ZEITON_INGOT.get())).save(consumer);

// Smelting
SimpleCookingRecipeBuilder.smelting(Ingredient.of(ItemRegistry.RAW_ZEITON.get()), RecipeCategory.MISC, ItemRegistry.ZEITON_INGOT.get(), 0.7F, 300).unlockedBy("has_any_zeiton", has(ItemRegistry.RAW_ZEITON.get())).save(consumer, new ResourceLocation(TardisRefined.MODID, "smelt_zeiton"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
import whocraft.tardis_refined.patterns.ShellPatterns;

import java.nio.file.Path;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

public class ShellPatternProvider implements DataProvider {

protected final DataGenerator generator;
private final boolean addDefaults;
protected Map<ResourceLocation, ShellPatternCollection> data = new HashMap<>();
private final String modid;
protected Map<ResourceLocation, ShellPatternCollection> data = new HashMap<>();

public ShellPatternProvider(DataGenerator generator, String modid) {
this(generator, modid, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import whocraft.tardis_refined.common.block.device.TerraformerBlock;
import whocraft.tardis_refined.registry.BlockRegistry;

import java.io.IOException;

import static whocraft.tardis_refined.registry.BlockRegistry.BLOCKS;

public class TRBlockModelProvider extends BlockStateProvider {
Expand All @@ -31,7 +29,6 @@ public JsonObject emptyBlockState(Block block) {
}



public JsonObject terraformer(Block block) {
VariantBlockStateBuilder builder = getVariantBuilder(block).forAllStates(blockState -> blockState.getValue(TerraformerBlock.ACTIVE) ?
ConfiguredModel.builder().modelFile(models().getExistingFile(new ResourceLocation(TardisRefined.MODID, "block/terraformer_on"))).build() :
Expand Down Expand Up @@ -79,7 +76,6 @@ public JsonObject antiGravityBlock(Block block) {
}



@Override
protected void registerStatesAndModels() {
ResourceLocation leavesTexture = new ResourceLocation("tardis_refined:block/ars_leaves");
Expand All @@ -98,7 +94,6 @@ protected void registerStatesAndModels() {
emptyBlockState(BlockRegistry.ARS_EGG.get());



threeDeeRotating(BlockRegistry.LANDING_PAD.get(), new ResourceLocation(TardisRefined.MODID, "block/landing_pad"));
threeDeeRotating(BlockRegistry.FLIGHT_DETECTOR.get(), new ResourceLocation(TardisRefined.MODID, "block/flight_detector"));

Expand Down Expand Up @@ -137,5 +132,4 @@ protected void registerStatesAndModels() {
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.neoforged.neoforge.registries.NeoForgeRegistries;
import whocraft.tardis_refined.TardisRefined;


import java.util.Set;
import java.util.concurrent.CompletableFuture;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import java.util.function.Consumer;
import java.util.function.Function;

public class CodecJsonReloadListenerImpl{
public class CodecJsonReloadListenerImpl {

public static <T> CodecJsonReloadListener<T> create(String folderName, Codec<T> codec) {
return new Impl(folderName, codec);
}

public static class Impl<T> extends CodecJsonReloadListener<T>{
public static class Impl<T> extends CodecJsonReloadListener<T> {
public Impl(String folderName, Codec<T> codec) {
super(folderName, codec);
}
Expand All @@ -29,8 +29,10 @@ public CodecJsonReloadListener setSyncPacket(NetworkManager networkManager, Func
return this;
}

/** Generate an event listener function for Forge's dedicated on-datapack-sync event which is timed at the correct point when datapack registries are synced.
* The event is fired when a player logs in or if server resources were reloaded successfully, so there is no need to add it in the login event **/
/**
* Generate an event listener function for Forge's dedicated on-datapack-sync event which is timed at the correct point when datapack registries are synced.
* The event is fired when a player logs in or if server resources were reloaded successfully, so there is no need to add it in the login event
**/
private Consumer<OnDatapackSyncEvent> getDatapackSyncListener(final NetworkManager networkManager, final Function<Map<ResourceLocation, T>, MessageS2C> packetFactory) {
return event -> {
this.handleSyncPacket(event.getPlayer(), networkManager, packetFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public MergeableCodecJsonReloadListener setSyncPacket(NetworkManager networkMana
return this;
}

/** Generate an event listener function for Forge's dedicated on-datapack-sync event which is timed at the correct point when datapack registries are synced.
* The event is fired when a player logs in or if server resources were reloaded successfully, so there is no need to add it in the login event **/
/**
* Generate an event listener function for Forge's dedicated on-datapack-sync event which is timed at the correct point when datapack registries are synced.
* The event is fired when a player logs in or if server resources were reloaded successfully, so there is no need to add it in the login event
**/
private Consumer<OnDatapackSyncEvent> getDatapackSyncListener(final NetworkManager networkManager, final Function<Map<ResourceLocation, PROCESSED>, MessageS2C> packetFactory) {
return event -> {
this.handleSyncPacket(event.getPlayer(), networkManager, packetFactory);
Expand Down
Loading

0 comments on commit dcc2c9c

Please sign in to comment.