-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added generation of the 'monster_egg:97' block in over world
- Loading branch information
1 parent
457ec28
commit a8bc7e5
Showing
7 changed files
with
172 additions
and
22 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
...c/main/java/org/imesense/dynamicspawncontrol/gameplay/worldgenerator/BlockMonsterEgg.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,96 @@ | ||
package org.imesense.dynamicspawncontrol.gameplay.worldgenerator; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.chunk.IChunkProvider; | ||
import net.minecraft.world.gen.IChunkGenerator; | ||
import net.minecraft.world.gen.feature.WorldGenMinable; | ||
import net.minecraft.world.gen.feature.WorldGenerator; | ||
import net.minecraftforge.fml.common.IWorldGenerator; | ||
import org.imesense.dynamicspawncontrol.debug.CodeGenericUtils; | ||
import org.imesense.dynamicspawncontrol.technical.configs.ConfigWorldGenerator; | ||
|
||
import java.util.Objects; | ||
import java.util.Random; | ||
|
||
/** | ||
* | ||
* OldSerpskiStalker: | ||
* <a href="https://forum.mcmodding.ru/threads/1-12-2-generacija.21375/">...</a> | ||
*/ | ||
public final class BlockMonsterEgg implements IWorldGenerator | ||
{ | ||
/** | ||
* | ||
*/ | ||
private final WorldGenerator CLASS_MONSTER_EGG_GENERATOR; | ||
|
||
/** | ||
* | ||
*/ | ||
public BlockMonsterEgg() | ||
{ | ||
CodeGenericUtils.printInitClassToLog(BlockMonsterEgg.class); | ||
|
||
CLASS_MONSTER_EGG_GENERATOR = new WorldGenMinable( | ||
Objects.requireNonNull(Block.getBlockFromName("monster_egg")).getDefaultState(), 5); | ||
} | ||
|
||
/** | ||
* | ||
* @param gen | ||
* @param world | ||
* @param rand | ||
* @param chunkX | ||
* @param chunkZ | ||
* @param chance | ||
* @param minHeight | ||
* @param maxHeight | ||
*/ | ||
private void run(WorldGenerator gen, World world, Random rand, int chunkX, int chunkZ, int chance, int minHeight, int maxHeight) | ||
{ | ||
int heightDiff = maxHeight - minHeight + 1; | ||
|
||
for (int i = 0; i < chance; i++) | ||
{ | ||
int x = chunkX * 16 + rand.nextInt(16); | ||
int y = minHeight + rand.nextInt(heightDiff); | ||
int z = chunkZ * 16 + rand.nextInt(16); | ||
|
||
x += rand.nextInt(10) - 6 / 2; | ||
z += rand.nextInt(10) - 6 / 2; | ||
|
||
gen.generate(world, rand, new BlockPos(x, y, z)); | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param random | ||
* @param chunkX | ||
* @param chunkZ | ||
* @param world | ||
* @param chunkGenerator | ||
* @param chunkProvider | ||
*/ | ||
@Override | ||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) | ||
{ | ||
switch (world.provider.getDimension()) | ||
{ | ||
case 0: | ||
{ | ||
run( | ||
CLASS_MONSTER_EGG_GENERATOR, world, random, chunkX, chunkZ, | ||
ConfigWorldGenerator.settingsGenerationBlockNetherRack.BlockNetherRackChanceSpawn, | ||
ConfigWorldGenerator.settingsGenerationBlockNetherRack.GetBlockNetherRackMinHeight, | ||
ConfigWorldGenerator.settingsGenerationBlockNetherRack.GetBlockNetherRackMaxHeight | ||
); | ||
break; | ||
} | ||
|
||
case 1: case -1: default: break; | ||
} | ||
} | ||
} |
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
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