-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from Cjsah/1.18
update
- Loading branch information
Showing
26 changed files
with
920 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.xekr.ironstars; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
|
||
public class IronStarsUtil { | ||
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/xekr/ironstars/mixin/AnvilBlockMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.xekr.ironstars.mixin; | ||
|
||
import com.xekr.ironstars.recipe.AnvilFlatteningCraftingManager; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.item.FallingBlockEntity; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.AnvilBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(AnvilBlock.class) | ||
public class AnvilBlockMixin { | ||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;levelEvent(ILnet/minecraft/core/BlockPos;I)V"), method = "onLand") | ||
private void onLand(Level level, BlockPos blockPos, BlockState state, BlockState targetState, FallingBlockEntity entity, CallbackInfo ci) { | ||
AnvilFlatteningCraftingManager.craft(level, entity.blockPosition()); | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
src/main/java/com/xekr/ironstars/recipe/RecipeEventHandler.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.xekr.ironstars.registry; | ||
|
||
import com.xekr.ironstars.IronStars; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.level.biome.Biome; | ||
import net.minecraft.world.level.biome.BiomeGenerationSettings; | ||
import net.minecraft.world.level.biome.BiomeSpecialEffects; | ||
import net.minecraft.world.level.biome.MobSpawnSettings; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.registries.DeferredRegister; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
public class AllBiomes { | ||
private static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, IronStars.ID); | ||
|
||
public static final ResourceKey<Biome> MOON = registerBiome("moon"); | ||
|
||
|
||
private static ResourceKey<Biome> registerBiome(String name) { | ||
BIOMES.register(name, () -> new Biome.BiomeBuilder() | ||
.precipitation(Biome.Precipitation.NONE) | ||
.biomeCategory(Biome.BiomeCategory.NONE) | ||
.downfall(0) | ||
.temperature(0) | ||
.specialEffects(new BiomeSpecialEffects.Builder().fogColor(0).waterColor(0).waterFogColor(0).skyColor(0).build()) | ||
.generationSettings(new BiomeGenerationSettings.Builder().build()) | ||
.mobSpawnSettings(new MobSpawnSettings.Builder().build()) | ||
.temperatureAdjustment(Biome.TemperatureModifier.NONE) | ||
.build()); | ||
return ResourceKey.create(Registry.BIOME_REGISTRY, IronStars.id(name)); | ||
} | ||
|
||
public static void register(IEventBus bus) { | ||
BIOMES.register(bus); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/com/xekr/ironstars/registry/AllDimensions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.xekr.ironstars.registry; | ||
|
||
import com.xekr.ironstars.IronStars; | ||
import com.xekr.ironstars.world.BiomeProvider; | ||
import com.xekr.ironstars.world.ModChunkGenerator; | ||
import net.minecraft.core.Registry; | ||
|
||
public class AllDimensions { | ||
public static long seed; | ||
public static void init() { | ||
Registry.register(Registry.BIOME_SOURCE, IronStars.id("ironstars_biomes"), BiomeProvider.CODEC); | ||
|
||
Registry.register(Registry.CHUNK_GENERATOR, IronStars.id("structure_locating_wrapper"), ModChunkGenerator.CODEC); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.xekr.ironstars.world; | ||
|
||
public interface Area { | ||
int get(int p_76486_, int p_76487_); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.xekr.ironstars.world; | ||
|
||
public interface AreaFactory<A extends Area> { | ||
A make(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/xekr/ironstars/world/AreaTransformer0.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.xekr.ironstars.world; | ||
|
||
public interface AreaTransformer0 { | ||
default <R extends Area> AreaFactory<R> run(BigContext<R> p_76985_) { | ||
return () -> p_76985_.createResult((p_164642_, p_164643_) -> { | ||
p_76985_.initRandom(p_164642_, p_164643_); | ||
return this.applyPixel(p_76985_, p_164642_, p_164643_); | ||
}); | ||
} | ||
|
||
int applyPixel(Context p_76990_, int p_76991_, int p_76992_); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.xekr.ironstars.world; | ||
|
||
public interface BigContext<R extends Area> extends Context { | ||
void initRandom(long p_76508_, long p_76509_); | ||
|
||
R createResult(PixelTransformer p_76510_); | ||
|
||
default R createResult(PixelTransformer p_76511_, R p_76512_) { | ||
return this.createResult(p_76511_); | ||
} | ||
|
||
default R createResult(PixelTransformer p_76513_, R p_76514_, R p_76515_) { | ||
return this.createResult(p_76513_); | ||
} | ||
|
||
default int random(int p_76501_, int p_76502_) { | ||
return this.nextRandom(2) == 0 ? p_76501_ : p_76502_; | ||
} | ||
|
||
default int random(int p_76504_, int p_76505_, int p_76506_, int p_76507_) { | ||
int i = this.nextRandom(4); | ||
if (i == 0) { | ||
return p_76504_; | ||
} else if (i == 1) { | ||
return p_76505_; | ||
} else { | ||
return i == 2 ? p_76506_ : p_76507_; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.xekr.ironstars.world; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import com.xekr.ironstars.registry.AllBiomes; | ||
import com.xekr.ironstars.registry.AllDimensions; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.resources.RegistryLookupCodec; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.level.biome.Biome; | ||
import net.minecraft.world.level.biome.BiomeSource; | ||
import net.minecraft.world.level.biome.Climate; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.function.LongFunction; | ||
|
||
public class BiomeProvider extends BiomeSource { | ||
public static final Codec<BiomeProvider> CODEC = RecordCodecBuilder.create((instance) -> instance.group( | ||
Codec.LONG.fieldOf("seed").stable().orElseGet(() -> AllDimensions.seed).forGetter((obj) -> obj.seed), | ||
RegistryLookupCodec.create(Registry.BIOME_REGISTRY).forGetter(provider -> provider.registry) | ||
).apply(instance, instance.stable(BiomeProvider::new))); | ||
|
||
private static final List<ResourceKey<Biome>> BIOMES = ImmutableList.of(AllBiomes.MOON); | ||
|
||
private final Registry<Biome> registry; | ||
private final Layer genBiomes; | ||
private final long seed; | ||
|
||
public BiomeProvider(long seed, Registry<Biome> registryIn) { | ||
super(BIOMES.stream().map(ResourceKey::location).map(registryIn::getOptional).filter(Optional::isPresent).map(opt -> opt::get)); | ||
this.seed = seed; | ||
registry = registryIn; | ||
genBiomes = makeLayers(seed, registryIn); | ||
|
||
} | ||
|
||
public static int getBiomeId(ResourceKey<Biome> biome, Registry<Biome> registry) { | ||
return registry.getId(registry.get(biome)); | ||
} | ||
|
||
private static <T extends Area, C extends BigContext<T>> AreaFactory<T> makeLayers(LongFunction<C> seed, Registry<Biome> registry, long rawSeed) { | ||
|
||
AreaFactory<T> biomes = GenLayerTFBiomes.INSTANCE.setup(registry).run(seed.apply(1L)); | ||
// biomes = GenLayerTFKeyBiomes.INSTANCE.setup(registry, rawSeed).run(seed.apply(1000L), biomes); | ||
// biomes = GenLayerTFCompanionBiomes.INSTANCE.setup(registry).run(seed.apply(1000L), biomes); | ||
// | ||
// biomes = ZoomLayer.NORMAL.run(seed.apply(1000L), biomes); | ||
// biomes = ZoomLayer.NORMAL.run(seed.apply(1001L), biomes); | ||
// | ||
// biomes = GenLayerTFBiomeStabilize.INSTANCE.run(seed.apply(700L), biomes); | ||
// | ||
// biomes = GenLayerTFThornBorder.INSTANCE.setup(registry).run(seed.apply(500L), biomes); | ||
// | ||
// biomes = ZoomLayer.NORMAL.run(seed.apply(1002), biomes); | ||
// biomes = ZoomLayer.NORMAL.run(seed.apply(1003), biomes); | ||
// biomes = ZoomLayer.NORMAL.run(seed.apply(1004), biomes); | ||
// biomes = ZoomLayer.NORMAL.run(seed.apply(1005), biomes); | ||
// | ||
// AreaFactory<T> riverLayer = GenLayerTFStream.INSTANCE.setup(registry).run(seed.apply(1L), biomes); | ||
// riverLayer = SmoothLayer.INSTANCE.run(seed.apply(7000L), riverLayer); | ||
// biomes = GenLayerTFRiverMix.INSTANCE.setup(registry).run(seed.apply(100L), biomes, riverLayer); | ||
|
||
return biomes; | ||
} | ||
|
||
public static Layer makeLayers(long seed, Registry<Biome> registry) { | ||
AreaFactory<LazyArea> areaFactory = makeLayers((context) -> new LazyAreaContext(25, seed, context), registry, seed); | ||
return new Layer(areaFactory) { | ||
@Override | ||
public Biome get(Registry<Biome> p_242936_1_, int p_242936_2_, int p_242936_3_) { | ||
int i = this.area.get(p_242936_2_, p_242936_3_); | ||
Biome biome = registry.byId(i); | ||
if (biome == null) | ||
throw new IllegalStateException("Unknown biome id emitted by layers: " + i); | ||
return biome; | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
protected Codec<? extends BiomeSource> codec() { | ||
return CODEC; | ||
} | ||
|
||
@Override | ||
public BiomeSource withSeed(long pSeed) { | ||
return new BiomeProvider(pSeed, registry); | ||
} | ||
|
||
@Override | ||
public Biome getNoiseBiome(int p_186735_, int p_186736_, int p_186737_, Climate.Sampler p_186738_) { | ||
return genBiomes.get(registry, p_186735_, p_186737_); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.xekr.ironstars.world; | ||
|
||
import net.minecraft.world.level.levelgen.synth.ImprovedNoise; | ||
|
||
public interface Context { | ||
int nextRandom(int p_76516_); | ||
|
||
ImprovedNoise getBiomeNoise(); | ||
} |
Oops, something went wrong.