Skip to content

Commit

Permalink
Fiery Shrine Randomizer Processor
Browse files Browse the repository at this point in the history
  • Loading branch information
JT122406 committed Jan 23, 2024
1 parent 1afcbd7 commit 255a744
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Random;

public class FieryShrineRandomizerProcessor extends StructureProcessor {

public static final FieryShrineRandomizerProcessor INSTANCE = new FieryShrineRandomizerProcessor();
Expand All @@ -23,12 +26,48 @@ public class FieryShrineRandomizerProcessor extends StructureProcessor {
public StructureTemplate.StructureBlockInfo processBlock(@NotNull LevelReader level, @NotNull BlockPos blockPos, @NotNull BlockPos pos, StructureTemplate.@NotNull StructureBlockInfo blockInfo, StructureTemplate.@NotNull StructureBlockInfo relativeBlockInfo, @NotNull StructurePlaceSettings settings) {
Block block = relativeBlockInfo.state().getBlock();
if (GenerationsStructures.CONFIG.randomization.randomizeFieryShrineBlocks)
return relativeBlockInfo;
if (block == Blocks.POLISHED_BLACKSTONE || block == Blocks.POLISHED_BLACKSTONE_BRICKS || block == Blocks.BLACKSTONE || block == Blocks.GILDED_BLACKSTONE)
return new StructureTemplate.StructureBlockInfo(relativeBlockInfo.pos(), randomizeBaseBlocks(block).defaultBlockState(), relativeBlockInfo.nbt());
else if (block == Blocks.NETHER_BRICKS || block == Blocks.CRACKED_NETHER_BRICKS)
return new StructureTemplate.StructureBlockInfo(relativeBlockInfo.pos(), randomizeNetherBricks(block).defaultBlockState(), relativeBlockInfo.nbt());


return relativeBlockInfo;
}

private Block randomizeBaseBlocks(Block block) {
switch (new Random().nextInt(5)) {
case 0 -> {
return Blocks.POLISHED_BLACKSTONE;
}
case 1 -> {
return Blocks.POLISHED_BLACKSTONE_BRICKS;
}
case 2 -> {
return Blocks.BLACKSTONE;
}
case 3 -> {
return Blocks.GILDED_BLACKSTONE;
}
default -> {
return block;
}
}
}

private Block randomizeNetherBricks(Block block) {
switch (new Random().nextInt(2)) {
case 0 -> {
return Blocks.NETHER_BRICKS;
}
case 1 -> {
return Blocks.CRACKED_NETHER_BRICKS;
}
default -> {
return block;
}
}
}

@Override
protected @NotNull StructureProcessorType<?> getType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.staticShrine;

import com.mojang.serialization.Codec;
import generations.gg.generations.structures.generationsstructures.GenerationsStructures;
import generations.gg.generations.structures.generationsstructures.processors.StructureProcessors;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
Expand All @@ -22,14 +20,14 @@ public class StaticShrineRandomizerProcessor extends StructureProcessor {
@Nullable
@Override
public StructureTemplate.StructureBlockInfo processBlock(@NotNull LevelReader level, @NotNull BlockPos blockPos, @NotNull BlockPos pos, StructureTemplate.@NotNull StructureBlockInfo blockInfo, StructureTemplate.@NotNull StructureBlockInfo relativeBlockInfo, @NotNull StructurePlaceSettings settings) {
Block block = relativeBlockInfo.state().getBlock();
if (GenerationsStructures.CONFIG.randomization.randomizeStaticShrineBlocks)
return relativeBlockInfo;

// Block block = relativeBlockInfo.state().getBlock();
// if (GenerationsStructures.CONFIG.randomization.randomizeStaticShrineBlocks)

return relativeBlockInfo;
}



@Override
protected @NotNull StructureProcessorType<?> getType() {
return StructureProcessors.STATIC_SHRINE_RANDOMIZER_PROCESSOR;
Expand Down

0 comments on commit 255a744

Please sign in to comment.