-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
90 additions
and
4 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
17 changes: 17 additions & 0 deletions
17
src/main/java/net/id/paradiselost/world/feature/configs/JaggedOreConfig.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,17 @@ | ||
package net.id.paradiselost.world.feature.configs; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.util.math.intprovider.IntProvider; | ||
import net.minecraft.world.gen.feature.FeatureConfig; | ||
import net.minecraft.world.gen.stateprovider.BlockStateProvider; | ||
|
||
public record JaggedOreConfig(BlockStateProvider block, IntProvider height, IntProvider width, IntProvider length, IntProvider lengthOffset) implements FeatureConfig { | ||
public static final Codec<JaggedOreConfig> CODEC = RecordCodecBuilder.create(instance -> instance.group( | ||
BlockStateProvider.TYPE_CODEC.fieldOf("block").forGetter(JaggedOreConfig::block), | ||
IntProvider.VALUE_CODEC.fieldOf("height").forGetter(JaggedOreConfig::height), | ||
IntProvider.VALUE_CODEC.fieldOf("width").forGetter(JaggedOreConfig::width), | ||
IntProvider.VALUE_CODEC.fieldOf("length").forGetter(JaggedOreConfig::length), | ||
IntProvider.VALUE_CODEC.fieldOf("lengthOffset").forGetter(JaggedOreConfig::lengthOffset) | ||
).apply(instance, JaggedOreConfig::new)); | ||
} |
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
48 changes: 48 additions & 0 deletions
48
src/main/java/net/id/paradiselost/world/feature/features/JaggedOreFeature.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,48 @@ | ||
package net.id.paradiselost.world.feature.features; | ||
|
||
import com.mojang.serialization.Codec; | ||
import net.id.paradiselost.blocks.FloatingBlock; | ||
import net.id.paradiselost.blocks.ParadiseLostBlocks; | ||
import net.id.paradiselost.tag.ParadiseLostBlockTags; | ||
import net.id.paradiselost.world.feature.configs.JaggedOreConfig; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.random.Random; | ||
import net.minecraft.world.StructureWorldAccess; | ||
import net.minecraft.world.gen.feature.Feature; | ||
import net.minecraft.world.gen.feature.util.FeatureContext; | ||
|
||
public class JaggedOreFeature extends Feature<JaggedOreConfig> { | ||
public JaggedOreFeature(Codec<JaggedOreConfig> configCodec) { | ||
super(configCodec); | ||
} | ||
|
||
@Override | ||
public boolean generate(FeatureContext<JaggedOreConfig> context) { | ||
JaggedOreConfig config = context.getConfig(); | ||
BlockPos center = context.getOrigin(); | ||
StructureWorldAccess world = context.getWorld(); | ||
Random rand = context.getRandom(); | ||
|
||
int height = center.getY() + config.height().get(rand); | ||
for (int y = center.getY(); y < height; y++) { | ||
int sizex = config.width().get(rand); | ||
int xOffset = rand.nextBetween(0, 2); | ||
int sizez = config.length().get(rand); | ||
for (int x = 0; x < sizex; x++) { | ||
int zOffset = config.lengthOffset().get(rand); | ||
for (int z = zOffset; z < sizez + zOffset; z++) { | ||
BlockPos iPos = new BlockPos(center.getX() + x + xOffset, y, center.getZ() + z); | ||
if (world.getBlockState(iPos).isIn(ParadiseLostBlockTags.BASE_PARADISE_LOST_STONE)) { | ||
BlockState block = config.block().getBlockState(rand, center); | ||
if (!(block.getBlock() instanceof FloatingBlock && !world.getBlockState(iPos.up()).isOpaque())) | ||
world.setBlockState(iPos, config.block().getBlockState(rand, iPos), Block.NOTIFY_LISTENERS); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
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
Binary file modified
BIN
-45 Bytes
(94%)
src/main/resources/assets/paradise_lost/textures/block/levita.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -106,7 +106,6 @@ | |
"gred", | ||
"swatgred", | ||
"groot", | ||
"malk", | ||
"mert", | ||
"cokmert" | ||
] | ||
|