Compile-Fixes in BetterEnd
This commit is contained in:
parent
b6321cec93
commit
a57845f96b
11 changed files with 82 additions and 42 deletions
|
@ -78,13 +78,13 @@ public class BaseCropBlock extends BasePlantBlock {
|
|||
if (tool != null && tool.isCorrectToolForDrops(state)) {
|
||||
int enchantment = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);
|
||||
if (enchantment > 0) {
|
||||
int countSeeds = MHelper.randRange(Mth.clamp(1 + enchantment, 1, 3), 3, MHelper.RANDOM);
|
||||
int countDrops = MHelper.randRange(Mth.clamp(1 + enchantment, 1, 2), 2, MHelper.RANDOM);
|
||||
int countSeeds = MHelper.randRange(Mth.clamp(1 + enchantment, 1, 3), 3, MHelper.RANDOM_SOURCE);
|
||||
int countDrops = MHelper.randRange(Mth.clamp(1 + enchantment, 1, 2), 2, MHelper.RANDOM_SOURCE);
|
||||
return Lists.newArrayList(new ItemStack(this, countSeeds), new ItemStack(drop, countDrops));
|
||||
}
|
||||
}
|
||||
int countSeeds = MHelper.randRange(1, 3, MHelper.RANDOM);
|
||||
int countDrops = MHelper.randRange(1, 2, MHelper.RANDOM);
|
||||
int countSeeds = MHelper.randRange(1, 3, MHelper.RANDOM_SOURCE);
|
||||
int countDrops = MHelper.randRange(1, 2, MHelper.RANDOM_SOURCE);
|
||||
return Lists.newArrayList(new ItemStack(this, countSeeds), new ItemStack(drop, countDrops));
|
||||
}
|
||||
|
||||
|
|
|
@ -89,9 +89,9 @@ public class BaseOreBlock extends DropExperienceBlock implements BlockModelProvi
|
|||
if (min == max) {
|
||||
return Collections.singletonList(new ItemStack(dropItem, max));
|
||||
}
|
||||
count = MHelper.randRange(min, max, MHelper.RANDOM);
|
||||
count = MHelper.randRange(min, max, MHelper.RANDOM_SOURCE);
|
||||
} else {
|
||||
count = MHelper.randRange(minCount, maxCount, MHelper.RANDOM);
|
||||
count = MHelper.randRange(minCount, maxCount, MHelper.RANDOM_SOURCE);
|
||||
}
|
||||
return Collections.singletonList(new ItemStack(dropItem, count));
|
||||
}
|
||||
|
|
|
@ -39,37 +39,52 @@ import ru.bclib.items.tool.BaseShearsItem;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
||||
public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock{
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||
|
||||
public BasePlantBlock() {
|
||||
this(false);
|
||||
this(false, p->p);
|
||||
}
|
||||
|
||||
|
||||
public BasePlantBlock(int light) {
|
||||
this(false, light);
|
||||
this(light, p->p);
|
||||
}
|
||||
|
||||
public BasePlantBlock(boolean replaceable) {
|
||||
public BasePlantBlock(int light, Function<Properties, Properties> propMod) {
|
||||
this(false, light, propMod);
|
||||
}
|
||||
|
||||
public BasePlantBlock(boolean replaceabled) {
|
||||
this(replaceabled, p->p);
|
||||
}
|
||||
public BasePlantBlock(boolean replaceable, Function<Properties, Properties> propMod) {
|
||||
this(
|
||||
FabricBlockSettings
|
||||
propMod.apply(FabricBlockSettings
|
||||
.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public BasePlantBlock(boolean replaceable, int light) {
|
||||
|
||||
public BasePlantBlock(boolean replaceable, int light){
|
||||
this(replaceable, light, p->p);
|
||||
}
|
||||
public BasePlantBlock(boolean replaceable, int light, Function<Properties, Properties> propMod) {
|
||||
this(
|
||||
FabricBlockSettings
|
||||
propMod.apply(FabricBlockSettings
|
||||
.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
.luminance(light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,18 +12,26 @@ import net.minecraft.world.level.block.state.StateDefinition;
|
|||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
||||
public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
|
||||
public static final IntegerProperty AGE = BlockProperties.AGE;
|
||||
|
||||
public BasePlantWithAgeBlock() {
|
||||
this(p->p);
|
||||
}
|
||||
|
||||
public BasePlantWithAgeBlock(Function<Properties, Properties> propMod) {
|
||||
this(
|
||||
FabricBlockSettings.of(Material.PLANT)
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks()
|
||||
.noCollission()
|
||||
);
|
||||
propMod.apply(FabricBlockSettings.of(Material.PLANT)
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks()
|
||||
.noCollission())
|
||||
);
|
||||
}
|
||||
|
||||
public BasePlantWithAgeBlock(Properties settings) {
|
||||
|
|
|
@ -34,7 +34,10 @@ import ru.bclib.items.tool.BaseShearsItem;
|
|||
import ru.bclib.util.BlocksHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock {
|
||||
|
@ -48,15 +51,18 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
|
|||
public BaseVineBlock(int light) {
|
||||
this(light, false);
|
||||
}
|
||||
|
||||
public BaseVineBlock(int light, boolean bottomOnly) {
|
||||
|
||||
public BaseVineBlock(int light, boolean bottomOnly){
|
||||
this(light, bottomOnly, p->p);
|
||||
}
|
||||
public BaseVineBlock(int light, boolean bottomOnly, Function<Properties, Properties> propMod) {
|
||||
this(
|
||||
FabricBlockSettings
|
||||
propMod.apply(FabricBlockSettings
|
||||
.of(Material.PLANT)
|
||||
.sound(SoundType.GRASS)
|
||||
.lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,29 +35,37 @@ import ru.bclib.interfaces.RenderLayerProvider;
|
|||
import ru.bclib.items.tool.BaseShearsItem;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
||||
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||
|
||||
public UnderwaterPlantBlock() {
|
||||
|
||||
public UnderwaterPlantBlock(){this(p->p);}
|
||||
public UnderwaterPlantBlock(Function<Properties, Properties> propMod) {
|
||||
this(
|
||||
FabricBlockSettings
|
||||
propMod.apply(FabricBlockSettings
|
||||
.of(Material.WATER_PLANT)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public UnderwaterPlantBlock(int light) {
|
||||
this(light, p->p);
|
||||
}
|
||||
|
||||
public UnderwaterPlantBlock(int light, Function<Properties, Properties> propMod) {
|
||||
this(
|
||||
FabricBlockSettings
|
||||
propMod.apply(FabricBlockSettings
|
||||
.of(Material.WATER_PLANT)
|
||||
.luminance(light)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission()
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ)
|
||||
.offsetType(BlockBehaviour.OffsetType.XZ))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ public class BlocksHelper {
|
|||
* @param random - {@link Random}.
|
||||
* @return {@link Direction}.
|
||||
*/
|
||||
public static Direction randomHorizontal(Random random) {
|
||||
public static Direction randomHorizontal(RandomSource random) {
|
||||
return HORIZONTAL[random.nextInt(4)];
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class BlocksHelper {
|
|||
* @param random - {@link Random}.
|
||||
* @return {@link Direction}.
|
||||
*/
|
||||
public static Direction randomDirection(Random random) {
|
||||
public static Direction randomDirection(RandomSource random) {
|
||||
return DIRECTIONS[random.nextInt(6)];
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.math.Vector3f;
|
|||
import net.minecraft.core.Vec3i;
|
||||
|
||||
import java.util.Random;import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.levelgen.LegacyRandomSource;
|
||||
|
||||
public class MHelper {
|
||||
private static final Vec3i[] RANDOM_OFFSETS = new Vec3i[3 * 3 * 3 - 1];
|
||||
|
@ -11,16 +12,17 @@ public class MHelper {
|
|||
public static final float PHI = (float) (Math.PI * (3 - Math.sqrt(5)));
|
||||
public static final float PI2 = (float) (Math.PI * 2);
|
||||
public static final Random RANDOM = new Random();
|
||||
public static final RandomSource RANDOM_SOURCE = new LegacyRandomSource(RANDOM.nextLong());
|
||||
|
||||
public static int randRange(int min, int max, Random random) {
|
||||
public static int randRange(int min, int max, RandomSource random) {
|
||||
return min + random.nextInt(max - min + 1);
|
||||
}
|
||||
|
||||
public static double randRange(double min, double max, Random random) {
|
||||
public static double randRange(double min, double max, RandomSource random) {
|
||||
return min + random.nextDouble() * (max - min);
|
||||
}
|
||||
|
||||
public static float randRange(float min, float max, Random random) {
|
||||
public static float randRange(float min, float max, RandomSource random) {
|
||||
return min + random.nextFloat() * (max - min);
|
||||
}
|
||||
|
||||
|
@ -195,7 +197,7 @@ public class MHelper {
|
|||
return (float) Math.acos(dot / Math.sqrt(length1 * length2));
|
||||
}
|
||||
|
||||
public static Vector3f randomHorizontal(Random random) {
|
||||
public static Vector3f randomHorizontal(RandomSource random) {
|
||||
float angleY = randRange(0, PI2, random);
|
||||
float vx = (float) Math.sin(angleY);
|
||||
float vz = (float) Math.cos(angleY);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SplineHelper {
|
|||
return new Vector3f(x, y, z);
|
||||
}
|
||||
|
||||
public static void offsetParts(List<Vector3f> spline, Random random, float dx, float dy, float dz) {
|
||||
public static void offsetParts(List<Vector3f> spline, RandomSource random, float dx, float dy, float dz) {
|
||||
int count = spline.size();
|
||||
for (int i = 1; i < count; i++) {
|
||||
Vector3f pos = spline.get(i);
|
||||
|
|
|
@ -130,6 +130,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
|
||||
@Override
|
||||
public void setSeed(long seed) {
|
||||
if (seed==currentSeed) return;
|
||||
super.setSeed(seed);
|
||||
biomePicker.rebuild();
|
||||
initMap(seed);
|
||||
|
|
|
@ -34,7 +34,7 @@ public class DoubleBlockSurfaceNoiseCondition extends SurfaceNoiseCondition {
|
|||
final int z = context.getBlockZ();
|
||||
if (lastX==x && lastZ==z) return lastValue > threshold;
|
||||
|
||||
double value = NOISE.eval(x * 0.1, z * 0.1) + MHelper.randRange(-0.4, 0.4, MHelper.RANDOM);
|
||||
double value = NOISE.eval(x * 0.1, z * 0.1) + MHelper.randRange(-0.4, 0.4, MHelper.RANDOM_SOURCE);
|
||||
|
||||
lastX=x;
|
||||
lastZ=z;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue