mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
More worldgen tweaks
- Pass RegistryAccess to builtin worldgen object creation methods - Do not cache builtin worldgen objects - Remove unused fluid layer code
This commit is contained in:
parent
42ffe443ac
commit
544b9699d9
6 changed files with 21 additions and 51 deletions
|
@ -10,15 +10,11 @@ import com.simibubi.create.content.palettes.AllPaletteStoneTypes;
|
||||||
import com.simibubi.create.foundation.data.CreateRegistrate;
|
import com.simibubi.create.foundation.data.CreateRegistrate;
|
||||||
import com.tterrag.registrate.util.entry.FluidEntry;
|
import com.tterrag.registrate.util.entry.FluidEntry;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.BlockAndTintGetter;
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.material.Fluid;
|
import net.minecraft.world.level.material.Fluid;
|
||||||
import net.minecraft.world.level.material.FluidState;
|
import net.minecraft.world.level.material.FluidState;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.fluids.FluidAttributes;
|
import net.minecraftforge.fluids.FluidAttributes;
|
||||||
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||||
|
|
||||||
|
@ -28,17 +24,17 @@ public class AllFluids {
|
||||||
|
|
||||||
public static final FluidEntry<PotionFluid> POTION =
|
public static final FluidEntry<PotionFluid> POTION =
|
||||||
REGISTRATE.virtualFluid("potion", PotionFluidAttributes::new, PotionFluid::new)
|
REGISTRATE.virtualFluid("potion", PotionFluidAttributes::new, PotionFluid::new)
|
||||||
.lang(f -> "fluid.create.potion", "Potion")
|
.lang("Potion")
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final FluidEntry<VirtualFluid> TEA = REGISTRATE.virtualFluid("tea")
|
public static final FluidEntry<VirtualFluid> TEA = REGISTRATE.virtualFluid("tea")
|
||||||
.lang(f -> "fluid.create.tea", "Builder's Tea")
|
.lang("Builder's Tea")
|
||||||
.tag(AllTags.forgeFluidTag("tea"))
|
.tag(AllTags.forgeFluidTag("tea"))
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final FluidEntry<ForgeFlowingFluid.Flowing> HONEY =
|
public static final FluidEntry<ForgeFlowingFluid.Flowing> HONEY =
|
||||||
REGISTRATE.standardFluid("honey", NoColorFluidAttributes::new)
|
REGISTRATE.standardFluid("honey", NoColorFluidAttributes::new)
|
||||||
.lang(f -> "fluid.create.honey", "Honey")
|
.lang("Honey")
|
||||||
.attributes(b -> b.viscosity(2000)
|
.attributes(b -> b.viscosity(2000)
|
||||||
.density(1400))
|
.density(1400))
|
||||||
.properties(p -> p.levelDecreasePerBlock(2)
|
.properties(p -> p.levelDecreasePerBlock(2)
|
||||||
|
@ -54,7 +50,7 @@ public class AllFluids {
|
||||||
|
|
||||||
public static final FluidEntry<ForgeFlowingFluid.Flowing> CHOCOLATE =
|
public static final FluidEntry<ForgeFlowingFluid.Flowing> CHOCOLATE =
|
||||||
REGISTRATE.standardFluid("chocolate", NoColorFluidAttributes::new)
|
REGISTRATE.standardFluid("chocolate", NoColorFluidAttributes::new)
|
||||||
.lang(f -> "fluid.create.chocolate", "Chocolate")
|
.lang("Chocolate")
|
||||||
.tag(AllTags.forgeFluidTag("chocolate"))
|
.tag(AllTags.forgeFluidTag("chocolate"))
|
||||||
.attributes(b -> b.viscosity(1500)
|
.attributes(b -> b.viscosity(1500)
|
||||||
.density(1400))
|
.density(1400))
|
||||||
|
@ -68,16 +64,6 @@ public class AllFluids {
|
||||||
|
|
||||||
public static void register() {}
|
public static void register() {}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public static void assignRenderLayers() {}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private static void makeTranslucent(FluidEntry<?> entry) {
|
|
||||||
ForgeFlowingFluid fluid = entry.get();
|
|
||||||
ItemBlockRenderTypes.setRenderLayer(fluid, RenderType.translucent());
|
|
||||||
ItemBlockRenderTypes.setRenderLayer(fluid.getSource(), RenderType.translucent());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static BlockState getLavaInteraction(FluidState fluidState) {
|
public static BlockState getLavaInteraction(FluidState fluidState) {
|
||||||
Fluid fluid = fluidState.getType();
|
Fluid fluid = fluidState.getType();
|
||||||
|
|
|
@ -38,6 +38,7 @@ import com.simibubi.create.foundation.data.recipe.StandardRecipeGen;
|
||||||
import com.simibubi.create.foundation.networking.AllPackets;
|
import com.simibubi.create.foundation.networking.AllPackets;
|
||||||
import com.simibubi.create.foundation.utility.CreateRegistry;
|
import com.simibubi.create.foundation.utility.CreateRegistry;
|
||||||
import com.simibubi.create.foundation.worldgen.AllFeatures;
|
import com.simibubi.create.foundation.worldgen.AllFeatures;
|
||||||
|
import com.simibubi.create.foundation.worldgen.AllOreFeatureConfigEntries;
|
||||||
import com.simibubi.create.foundation.worldgen.AllPlacementModifiers;
|
import com.simibubi.create.foundation.worldgen.AllPlacementModifiers;
|
||||||
import com.simibubi.create.foundation.worldgen.BuiltinRegistration;
|
import com.simibubi.create.foundation.worldgen.BuiltinRegistration;
|
||||||
import com.tterrag.registrate.util.nullness.NonNullSupplier;
|
import com.tterrag.registrate.util.nullness.NonNullSupplier;
|
||||||
|
@ -112,6 +113,7 @@ public class Create {
|
||||||
AllParticleTypes.register(modEventBus);
|
AllParticleTypes.register(modEventBus);
|
||||||
AllStructureProcessorTypes.register(modEventBus);
|
AllStructureProcessorTypes.register(modEventBus);
|
||||||
AllEntityDataSerializers.register(modEventBus);
|
AllEntityDataSerializers.register(modEventBus);
|
||||||
|
AllOreFeatureConfigEntries.init();
|
||||||
AllFeatures.register(modEventBus);
|
AllFeatures.register(modEventBus);
|
||||||
AllPlacementModifiers.register(modEventBus);
|
AllPlacementModifiers.register(modEventBus);
|
||||||
BuiltinRegistration.register(modEventBus);
|
BuiltinRegistration.register(modEventBus);
|
||||||
|
|
|
@ -84,7 +84,6 @@ public class CreateClient {
|
||||||
BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20);
|
BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20);
|
||||||
|
|
||||||
AllKeys.register();
|
AllKeys.register();
|
||||||
// AllFluids.assignRenderLayers();
|
|
||||||
AllBlockPartials.init();
|
AllBlockPartials.init();
|
||||||
AllStitchedTextures.init();
|
AllStitchedTextures.init();
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class AllOreFeatureConfigEntries {
|
||||||
for (Map.Entry<ResourceLocation, OreFeatureConfigEntry> entry : OreFeatureConfigEntry.ALL.entrySet()) {
|
for (Map.Entry<ResourceLocation, OreFeatureConfigEntry> entry : OreFeatureConfigEntry.ALL.entrySet()) {
|
||||||
DatagenExtension datagenExt = entry.getValue().datagenExt();
|
DatagenExtension datagenExt = entry.getValue().datagenExt();
|
||||||
if (datagenExt != null) {
|
if (datagenExt != null) {
|
||||||
configuredFeatures.put(entry.getKey(), datagenExt.getConfiguredFeature());
|
configuredFeatures.put(entry.getKey(), datagenExt.createConfiguredFeature(registryAccess));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ public class AllOreFeatureConfigEntries {
|
||||||
for (Map.Entry<ResourceLocation, OreFeatureConfigEntry> entry : OreFeatureConfigEntry.ALL.entrySet()) {
|
for (Map.Entry<ResourceLocation, OreFeatureConfigEntry> entry : OreFeatureConfigEntry.ALL.entrySet()) {
|
||||||
DatagenExtension datagenExt = entry.getValue().datagenExt();
|
DatagenExtension datagenExt = entry.getValue().datagenExt();
|
||||||
if (datagenExt != null) {
|
if (datagenExt != null) {
|
||||||
placedFeatures.put(entry.getKey(), datagenExt.getPlacedFeature());
|
placedFeatures.put(entry.getKey(), datagenExt.createPlacedFeature(registryAccess));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.foundation.worldgen.OreFeatureConfigEntry.DatagenExtension;
|
import com.simibubi.create.foundation.worldgen.OreFeatureConfigEntry.DatagenExtension;
|
||||||
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.data.BuiltinRegistries;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||||
|
@ -22,8 +23,8 @@ public class BuiltinRegistration {
|
||||||
if (id.getNamespace().equals(Create.ID)) {
|
if (id.getNamespace().equals(Create.ID)) {
|
||||||
DatagenExtension datagenExt = entry.getValue().datagenExt();
|
DatagenExtension datagenExt = entry.getValue().datagenExt();
|
||||||
if (datagenExt != null) {
|
if (datagenExt != null) {
|
||||||
CONFIGURED_FEATURE_REGISTER.register(id.getPath(), () -> datagenExt.getConfiguredFeature());
|
CONFIGURED_FEATURE_REGISTER.register(id.getPath(), () -> datagenExt.createConfiguredFeature(BuiltinRegistries.ACCESS));
|
||||||
PLACED_FEATURE_REGISTER.register(id.getPath(), () -> datagenExt.getPlacedFeature());
|
PLACED_FEATURE_REGISTER.register(id.getPath(), () -> datagenExt.createPlacedFeature(BuiltinRegistries.ACCESS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import com.tterrag.registrate.util.nullness.NonNullSupplier;
|
||||||
|
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.data.worldgen.features.OreFeatures;
|
import net.minecraft.data.worldgen.features.OreFeatures;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -140,19 +141,12 @@ public class OreFeatureConfigEntry extends ConfigBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class DatagenExtension {
|
public abstract class DatagenExtension {
|
||||||
protected ConfiguredFeature<?, ?> configuredFeature;
|
public abstract ConfiguredFeature<?, ?> createConfiguredFeature(RegistryAccess registryAccess);
|
||||||
protected PlacedFeature placedFeature;
|
|
||||||
|
|
||||||
public abstract ConfiguredFeature<?, ?> getConfiguredFeature();
|
public PlacedFeature createPlacedFeature(RegistryAccess registryAccess) {
|
||||||
|
Registry<ConfiguredFeature<?, ?>> featureRegistry = registryAccess.registryOrThrow(Registry.CONFIGURED_FEATURE_REGISTRY);
|
||||||
public PlacedFeature getPlacedFeature() {
|
Holder<ConfiguredFeature<?, ?>> featureHolder = featureRegistry.getOrCreateHolder(ResourceKey.create(Registry.CONFIGURED_FEATURE_REGISTRY, id));
|
||||||
if (placedFeature != null) {
|
return new PlacedFeature(featureHolder, List.of(new ConfigDrivenPlacement(OreFeatureConfigEntry.this)));
|
||||||
return placedFeature;
|
|
||||||
}
|
|
||||||
|
|
||||||
placedFeature = new PlacedFeature(Holder.direct(getConfiguredFeature()), List.of(new ConfigDrivenPlacement(OreFeatureConfigEntry.this)));
|
|
||||||
|
|
||||||
return placedFeature;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OreFeatureConfigEntry parent() {
|
public OreFeatureConfigEntry parent() {
|
||||||
|
@ -183,11 +177,7 @@ public class OreFeatureConfigEntry extends ConfigBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfiguredFeature<?, ?> getConfiguredFeature() {
|
public ConfiguredFeature<?, ?> createConfiguredFeature(RegistryAccess registryAccess) {
|
||||||
if (configuredFeature != null) {
|
|
||||||
return configuredFeature;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<TargetBlockState> targetStates = new ArrayList<>();
|
List<TargetBlockState> targetStates = new ArrayList<>();
|
||||||
if (block != null)
|
if (block != null)
|
||||||
targetStates.add(OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, block.get()
|
targetStates.add(OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, block.get()
|
||||||
|
@ -200,9 +190,7 @@ public class OreFeatureConfigEntry extends ConfigBase {
|
||||||
.defaultBlockState()));
|
.defaultBlockState()));
|
||||||
|
|
||||||
ConfigDrivenOreFeatureConfiguration config = new ConfigDrivenOreFeatureConfiguration(OreFeatureConfigEntry.this, 0, targetStates);
|
ConfigDrivenOreFeatureConfiguration config = new ConfigDrivenOreFeatureConfiguration(OreFeatureConfigEntry.this, 0, targetStates);
|
||||||
configuredFeature = new ConfiguredFeature<>(AllFeatures.STANDARD_ORE.get(), config);
|
return new ConfiguredFeature<>(AllFeatures.STANDARD_ORE.get(), config);
|
||||||
|
|
||||||
return configuredFeature;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,19 +203,13 @@ public class OreFeatureConfigEntry extends ConfigBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfiguredFeature<?, ?> getConfiguredFeature() {
|
public ConfiguredFeature<?, ?> createConfiguredFeature(RegistryAccess registryAccess) {
|
||||||
if (configuredFeature != null) {
|
|
||||||
return configuredFeature;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<LayerPattern> layerPatterns = this.layerPatterns.stream()
|
List<LayerPattern> layerPatterns = this.layerPatterns.stream()
|
||||||
.map(NonNullSupplier::get)
|
.map(NonNullSupplier::get)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
ConfigDrivenLayeredOreFeatureConfiguration config = new ConfigDrivenLayeredOreFeatureConfiguration(OreFeatureConfigEntry.this, 0, layerPatterns);
|
ConfigDrivenLayeredOreFeatureConfiguration config = new ConfigDrivenLayeredOreFeatureConfiguration(OreFeatureConfigEntry.this, 0, layerPatterns);
|
||||||
configuredFeature = new ConfiguredFeature<>(AllFeatures.LAYERED_ORE.get(), config);
|
return new ConfiguredFeature<>(AllFeatures.LAYERED_ORE.get(), config);
|
||||||
|
|
||||||
return configuredFeature;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue