Skip to content

Commit

Permalink
Recipe Change, add way to ignore placed features
Browse files Browse the repository at this point in the history
  • Loading branch information
UnRealDinnerbone committed Mar 4, 2024
1 parent 0cad941 commit 6140f54
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ fabric/run_client/
logs/

neo/runs/

common/src/generated/resources/.cache/
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
### 4.2.0
### 4.2.2

- Rewrite Features to support complex features
- Add Place Feature blacklist tag
- Changed the nether portal recipe to diamond pick instead of nettherite
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"items": [
{
"items": [
"minecraft:netherite_pickaxe"
"minecraft:diamond_pickaxe"
]
}
]
Expand Down
19 changes: 14 additions & 5 deletions common/src/main/java/com/unrealdinnerbone/jamd/WorldType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.features.OreFeatures;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
Expand Down Expand Up @@ -45,7 +44,9 @@ public class WorldType {
private final RegistryEntry<BlockItem> item;
private final RegistryEntry<BlockEntityType<PortalTileEntity>> blockEntity;

private final TagKey<ConfiguredFeature<?, ?>> ingoredFeatures;
private final TagKey<ConfiguredFeature<?, ?>> ingoredConfigFeatures;

private final TagKey<PlacedFeature> ingoredPlaceFeatures;
private final Path configPath;

private final TagKey<Biome> biomeTag;
Expand All @@ -57,7 +58,8 @@ public WorldType(String name, RegistryEntry<Block> block, RegistryEntry<BlockIte
this.item = item;
this.blockEntity = blockEntity;
this.biomeTag = biomeTag;
this.ingoredFeatures = TagKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(JAMD.MOD_ID, name));
this.ingoredConfigFeatures = TagKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(JAMD.MOD_ID, name));
this.ingoredPlaceFeatures = TagKey.create(Registries.PLACED_FEATURE, new ResourceLocation(JAMD.MOD_ID, name));
this.configPath = JAMD.CONFIG_FOLDER.resolve(name + ".json");
TYPES.add(this);
}
Expand All @@ -79,7 +81,11 @@ public KeySet getKey() {
}

public TagKey<ConfiguredFeature<?, ?>> getIgnoredFeatures() {
return ingoredFeatures;
return ingoredConfigFeatures;
}

public TagKey<PlacedFeature> getIgnoredPlaceFeatures() {
return ingoredPlaceFeatures;
}

@Override
Expand Down Expand Up @@ -113,7 +119,10 @@ public void export(MinecraftServer server) throws IllegalStateException, IOExcep
List<OresCodec> oresCodecs = new ArrayList<>();
List<PlacedFeature> placedFeatures = getFeatures(server);
for (PlacedFeature placedFeature : placedFeatures) {
if (!placedFeature.feature().is(ingoredFeatures)) {

boolean b = server.registryAccess().registryOrThrow(Registries.PLACED_FEATURE).wrapAsHolder(placedFeature).is(ingoredPlaceFeatures);

if (!b && !placedFeature.feature().is(ingoredConfigFeatures)) {
RegistryAccess.Frozen frozen = server.registryAccess();
ConfiguredFeature<?, ?> configuredFeatureReference = placedFeature.feature().value();
Feature<?> feature1 = configuredFeatureReference.feature();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
pack.addProvider(LootTableProvider::new);
pack.addProvider(AdvancementProvider::new);
pack.addProvider(FeatureTagProvider::new);
pack.addProvider(PlaceTagProvider::new);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.unrealdinnerbone.jamd.data;

import com.unrealdinnerbone.jamd.JAMDRegistry;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.features.OreFeatures;
import net.minecraft.data.worldgen.placement.OrePlacements;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;

import java.util.concurrent.CompletableFuture;

public class PlaceTagProvider extends FabricTagProvider<PlacedFeature> {
public PlaceTagProvider(FabricDataOutput output, CompletableFuture<HolderLookup.Provider> registriesFuture) {
super(output, Registries.PLACED_FEATURE, registriesFuture);
}

@Override
protected void addTags(HolderLookup.Provider arg) {
// getOrCreateTagBuilder(JAMDRegistry.OVERWORLD.getIgnoredPlaceFeatures())
// .add(OrePlacements.ORE_CLAY);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void buildRecipes(RecipeOutput exporter) {
.pattern("OOO")
.define('O', Blocks.NETHER_BRICKS)
.define('P', Items.NETHERITE_PICKAXE)
.unlockedBy("has_diamond_pick", has(Items.NETHERITE_PICKAXE))
.unlockedBy("has_diamond_pick", has(Items.DIAMOND_PICKAXE))
.save(exporter, new ResourceLocation(JAMD.MOD_ID, "nether_portal_block"));
ShapedRecipeBuilder.shaped(RecipeCategory.TRANSPORTATION, JAMDRegistry.END.getBlock().get())
.pattern("OOO")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project
mod_version=4.2.0
mod_version=4.2.2
maven_group=com.unrealdinnerbone
curse_id=422981
mod_name=JAMD
Expand Down

0 comments on commit 6140f54

Please sign in to comment.