This commit is contained in:
kuba6000 committed 2022-10-12 21:09:45 +02:00
1 parent d993c90c3e
commit 14a712260b
156 files changed
+14896 -13422

No files matched your search

@@ -1,83 +1,74 @@
package magicbees.world.feature;
import java.util.Random;
import magicbees.main.utils.BlockUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import magicbees.main.utils.BlockUtil;
public class FeatureOreVein {
public static final FeatureOreVein redstoneGen;
public static final FeatureOreVein netherQuartzGen;
public static final FeatureOreVein glowstoneGen;
public static final FeatureOreVein endStoneGen;
public class FeatureOreVein
{
public static final FeatureOreVein redstoneGen;
public static final FeatureOreVein netherQuartzGen;
public static final FeatureOreVein glowstoneGen;
public static final FeatureOreVein endStoneGen;
static {
redstoneGen = new FeatureOreVein(Blocks.redstone_ore, Blocks.stone);
netherQuartzGen = new FeatureOreVein(Blocks.quartz_ore, Blocks.netherrack);
glowstoneGen = new FeatureOreVein(Blocks.glowstone, Blocks.stone);
endStoneGen = new FeatureOreVein(Blocks.end_stone, Blocks.stone);
}
static
{
redstoneGen = new FeatureOreVein(Blocks.redstone_ore, Blocks.stone);
netherQuartzGen = new FeatureOreVein(Blocks.quartz_ore, Blocks.netherrack);
glowstoneGen = new FeatureOreVein(Blocks.glowstone, Blocks.stone);
endStoneGen = new FeatureOreVein(Blocks.end_stone, Blocks.stone);
}
private final Block veinBlock;
private final int veinBlockMeta;
private final Block replacesBlock;
private final Block veinBlock;
private final int veinBlockMeta;
private final Block replacesBlock;
public FeatureOreVein(Block block, Block replacesBlock) {
this(block, 0, replacesBlock);
}
public FeatureOreVein(Block block, Block replacesBlock)
{
this(block, 0, replacesBlock);
}
public FeatureOreVein(Block block, int meta, Block replacesBlock) {
this.veinBlock = block;
this.veinBlockMeta = meta;
this.replacesBlock = replacesBlock;
}
public FeatureOreVein(Block block, int meta, Block replacesBlock)
{
this.veinBlock = block;
this.veinBlockMeta = meta;
this.replacesBlock = replacesBlock;
}
public void generateVein(World world, Random random, int startX, int startY, int startZ, int maxSpawnCount) {
int currentX = startX;
int currentY = startY;
int currentZ = startZ;
int spawnAttempts = 0;
int spawnCount = 0;
public void generateVein(World world, Random random, int startX, int startY, int startZ, int maxSpawnCount)
{
int currentX = startX;
int currentY = startY;
int currentZ = startZ;
int spawnAttempts = 0;
int spawnCount = 0;
while (spawnCount < maxSpawnCount && spawnAttempts < maxSpawnCount * 2) {
++spawnAttempts;
while (spawnCount < maxSpawnCount && spawnAttempts < maxSpawnCount * 2)
{
++spawnAttempts;
if (!world.isAirBlock(currentX, currentY, currentZ)
&& BlockUtil.canBlockReplaceAt(world, currentX, currentY, currentZ, replacesBlock)) {
world.setBlock(currentX, currentY, currentZ, this.veinBlock, this.veinBlockMeta, 2);
++spawnCount;
}
if (!world.isAirBlock(currentX, currentY, currentZ) && BlockUtil.canBlockReplaceAt(world, currentX, currentY, currentZ, replacesBlock))
{
world.setBlock(currentX, currentY, currentZ, this.veinBlock, this.veinBlockMeta, 2);
++spawnCount;
}
switch (random.nextInt(6))
{
case 0:
++currentY;
break;
case 1:
--currentY;
break;
case 2:
++currentZ;
break;
case 3:
--currentZ;
break;
case 4:
++currentX;
break;
case 5:
--currentX;
break;
}
}
}
switch (random.nextInt(6)) {
case 0:
++currentY;
break;
case 1:
--currentY;
break;
case 2:
++currentZ;
break;
case 3:
--currentZ;
break;
case 4:
++currentX;
break;
case 5:
--currentX;
break;
}
}
}
}
@@ -6,29 +6,24 @@ import net.minecraft.world.World;
public class HiveGenNether extends HiveGenUnderground {
public HiveGenNether(int minLevel, int range, int surroundCount)
{
super(minLevel, range, Blocks.netherrack, surroundCount);
}
public HiveGenNether(int minLevel, int range, int surroundCount) {
super(minLevel, range, Blocks.netherrack, surroundCount);
}
@Override
public int getYForHive(World world, int x, int z)
{
int y = super.getYForHive(world, x, z);
@Override
public int getYForHive(World world, int x, int z) {
int y = super.getYForHive(world, x, z);
if (!isValidLocation(world, x, y, z))
{
int searchDirection = world.rand.nextBoolean() ? 4 : -4;
while (!Block.isEqualTo(world.getBlock(x, y, z), replace))
{
y += searchDirection;
if (y < minLevel || y > minLevel + range)
{
return -1;
}
}
}
if (!isValidLocation(world, x, y, z)) {
int searchDirection = world.rand.nextBoolean() ? 4 : -4;
while (!Block.isEqualTo(world.getBlock(x, y, z), replace)) {
y += searchDirection;
if (y < minLevel || y > minLevel + range) {
return -1;
}
}
}
return y;
}
return y;
}
}
@@ -1,63 +1,55 @@
package magicbees.world.feature;
import forestry.api.apiculture.hives.IHiveGen;
import magicbees.main.utils.BlockUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.apiculture.hives.IHiveGen;
import magicbees.main.utils.BlockUtil;
public class HiveGenOblivion implements IHiveGen {
@Override
public int getYForHive(World world, int x, int z) {
@Override
public int getYForHive(World world, int x, int z) {
int surface = world.getHeightValue(x, z);
if (surface == 0)
{
return -1;
}
int surface = world.getHeightValue(x, z);
if (surface == 0) {
return -1;
}
int y = 10;
int y = 10;
// get to the end stone
while (!Block.isEqualTo(world.getBlock(x, y - 1, z), Blocks.end_stone) && y < surface)
{
y += 8;
}
// get to the end stone
while (!Block.isEqualTo(world.getBlock(x, y - 1, z), Blocks.end_stone) && y < surface) {
y += 8;
}
// hive must be embedded one deep into the stone
while (!Block.isEqualTo(world.getBlock(x, y - 2, z), Blocks.air) && y > -1)
{
y--;
}
// hive must be embedded one deep into the stone
while (!Block.isEqualTo(world.getBlock(x, y - 2, z), Blocks.air) && y > -1) {
y--;
}
return y;
}
return y;
}
@Override
public boolean isValidLocation(World world, int x, int y, int z) {
@Override
public boolean isValidLocation(World world, int x, int y, int z) {
if (BlockUtil.getSurroundCount(world, x, y, z, Blocks.end_stone) != 6)
{
return false;
}
if (BlockUtil.getSurroundCount(world, x, y, z, Blocks.end_stone) != 6) {
return false;
}
for (int i = 2; i < 4; i++)
{
if (!world.isAirBlock(x, y - i, z))
{
return false;
}
}
for (int i = 2; i < 4; i++) {
if (!world.isAirBlock(x, y - i, z)) {
return false;
}
}
return true;
}
return true;
}
@Override
public boolean canReplace(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return Block.isEqualTo(block, Blocks.end_stone);
}
@Override
public boolean canReplace(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
return Block.isEqualTo(block, Blocks.end_stone);
}
}
@@ -1,47 +1,40 @@
package magicbees.world.feature;
import forestry.api.apiculture.hives.IHiveGen;
import magicbees.main.utils.BlockUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.apiculture.hives.IHiveGen;
public class HiveGenUnderground implements IHiveGen {
protected final int minLevel;
protected final int range;
protected final Block replace;
private final int surroundCount;
import magicbees.main.utils.BlockUtil;
public HiveGenUnderground(int minLevel, int range, int surroundCount) {
this(minLevel, range, Blocks.stone, surroundCount);
}
public class HiveGenUnderground implements IHiveGen
{
protected final int minLevel;
protected final int range;
protected final Block replace;
private final int surroundCount;
public HiveGenUnderground(int minLevel, int range, Block replace, int surroundCount) {
this.minLevel = minLevel;
this.range = range;
this.replace = replace;
this.surroundCount = surroundCount;
}
public HiveGenUnderground(int minLevel, int range, int surroundCount) {
this(minLevel, range, Blocks.stone, surroundCount);
}
@Override
public int getYForHive(World world, int x, int z) {
return minLevel + world.rand.nextInt(range);
}
public HiveGenUnderground(int minLevel, int range, Block replace, int surroundCount)
{
this.minLevel = minLevel;
this.range = range;
this.replace = replace;
this.surroundCount = surroundCount;
}
@Override
public boolean isValidLocation(World world, int x, int y, int z) {
return BlockUtil.getSurroundCount(world, x, y, z, replace) >= surroundCount;
}
@Override
public int getYForHive(World world, int x, int z)
{
return minLevel + world.rand.nextInt(range);
}
@Override
public boolean isValidLocation(World world, int x, int y, int z)
{
return BlockUtil.getSurroundCount(world, x, y, z, replace) >= surroundCount;
}
@Override
public boolean canReplace(World world, int x, int y, int z)
{
return !world.isAirBlock(x, y, z) && BlockUtil.canBlockReplaceAt(world, x, y, z, replace);
}
@Override
public boolean canReplace(World world, int x, int y, int z) {
return !world.isAirBlock(x, y, z) && BlockUtil.canBlockReplaceAt(world, x, y, z, replace);
}
}